@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.
- package/CHANGELOG.md +8 -2
- package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-BGohJFsQ.js} +1 -1
- package/dist/assets/Addons-BDlFntTI.js +5 -0
- package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-fCxxHmc-.js} +1 -1
- package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DDqDbMM3.js} +1 -1
- package/dist/assets/AiProfiles-BFi1Kn6N.js +3 -0
- package/dist/assets/Archive-ChqpFwH8.js +1 -0
- package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-BLWj6csX.js} +1 -1
- package/dist/assets/{Build-BoiB-nPA.js → Build-DfHu8hDx.js} +4 -4
- package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-Cxw9P8Uq.js} +1 -1
- package/dist/assets/Cluster-BwIvlnpz.js +1 -0
- package/dist/assets/{CompositionBlockEditor-BloGManS.js → CompositionBlockEditor-DyGQ4aIz.js} +2 -2
- package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DRISSQzb.js} +1 -1
- package/dist/assets/Data-B1NgedRI.js +2 -0
- package/dist/assets/DeviceDetail-BzGdZ7Q_.js +1 -0
- package/dist/assets/{Devices-BJRvDHiT.js → Devices-CdmWPr7S.js} +1 -1
- package/dist/assets/EmbedDevicePage-CfSj9caC.js +1 -0
- package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-DEP8gdti.js} +1 -1
- package/dist/assets/History-Bg9tQAqJ.js +1 -0
- package/dist/assets/Identity-Oyg78Wgg.js +1 -0
- package/dist/assets/InstancesTable-CItURWVx.js +1 -0
- package/dist/assets/IntegrationDetail-B05HfycS.js +1 -0
- package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-Bpw7S0et.js} +2 -2
- package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-wpQtKhSO.js} +1 -1
- package/dist/assets/Library-afeuqgc6.js +1 -0
- package/dist/assets/Locations-DPd9tJpI.js +3 -0
- package/dist/assets/Logs-DSnFwEPX.js +1 -0
- package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-DATKwWoi.js} +1 -1
- package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-BrUyigty.js} +1 -1
- package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-DTWeghN4.js} +1 -1
- package/dist/assets/{Network-L7e5c9RP.js → Network-CzBJb8Ro.js} +1 -1
- package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-DC6qeg0K.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-DwR6THxT.js +1 -0
- package/dist/assets/Notifications-8WkrgioY.js +1 -0
- package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cqel4gq_.js} +2 -2
- package/dist/assets/Pipeline-Dlg9wnRY.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-jcKOGH_r.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-HfoxsYJf.js} +1 -1
- package/dist/assets/SessionsList-CIOmkBhu.js +2 -0
- package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-BgfY_eRn.js} +1 -1
- package/dist/assets/StorageLocationsTable-CbwL3VQY.js +1 -0
- package/dist/assets/System-DXC-3shW.js +2 -0
- package/dist/assets/{TemplateEditorDialog-8D78AUfO.js → TemplateEditorDialog-DXIGdBCR.js} +1 -1
- package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-Di7l31qa.js} +5 -5
- package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-aXqehRmF.js} +1 -1
- package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-C71XpHjW.js} +1 -1
- 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
- package/dist/assets/{action-draft-BTVZLATm.js → action-draft-qcGhRMv4.js} +1 -1
- package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-CEBa_im9.js} +1 -1
- package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-DdSU1Zo6.js} +1 -1
- package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-BZy-JJ_o.js} +1 -1
- package/dist/assets/{board-model-CPA2IZpg.js → board-model-DIWwdMST.js} +1 -1
- package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Bq_R4oG5.js} +1 -1
- package/dist/assets/{client-Cng2SeYA.js → client-DLuByuRa.js} +1 -1
- package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-CvGdlD2o.js} +1 -1
- package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-Dd9uw4UF.js} +1 -1
- package/dist/assets/device-picker-model-PIGdnO_G.js +1 -0
- package/dist/assets/{dist-D7Gew3v3.js → dist-CDyYOITf.js} +1 -1
- package/dist/assets/{dist-CxrdebAP.js → dist-CFXBYJXQ.js} +1 -1
- package/dist/assets/{format-BopmTOzZ.js → format-CrKdqqCK.js} +1 -1
- package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-CYHcdoYA.js} +1 -1
- package/dist/assets/i18n-CLov6T90.js +1 -0
- package/dist/assets/{icons-bi-mcO5N.js → icons-BLtyw4fH.js} +1 -1
- package/dist/assets/index-CFJEFXwr.js +6 -0
- package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BPZYWQoj.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-129d9964.js} +2 -2
- package/dist/assets/mount-PIGdnO_G.js +1 -0
- package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-DeN2cEgy.js} +1 -1
- package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-CgADEsQt.js} +1 -1
- package/dist/assets/remoteEntry-Cc7yyabb.js +1 -0
- package/dist/assets/{src-eL0OacoB.js → src-CA2_9YJD.js} +20 -20
- package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-BXELI2t0.js} +1 -1
- package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-BFq40l6S.js} +1 -1
- package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-DyQPnSjQ.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CKwvXhAP.js} +1 -1
- package/dist/assets/useEventInvalidation-PIGdnO_G.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-cFOr6zMH.js} +1 -1
- 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
- package/dist/index.html +8 -8
- package/dist/server/addon.js +10 -3
- package/package.json +2 -2
- package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
- package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
- package/dist/assets/Archive-y1aPYCx8.js +0 -1
- package/dist/assets/Cluster-DN0Cwciw.js +0 -1
- package/dist/assets/Data-LT-PQ05n.js +0 -2
- package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
- package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
- package/dist/assets/History-BPF9alct.js +0 -1
- package/dist/assets/Identity-dLFVHYZR.js +0 -1
- package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
- package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
- package/dist/assets/Library-D4-BDy54.js +0 -1
- package/dist/assets/Locations-DGZ_lrp3.js +0 -3
- package/dist/assets/Logs-CUV00qxb.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
- package/dist/assets/Notifications-CucZNxjj.js +0 -1
- package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
- package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
- package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
- package/dist/assets/System-DZXA2QSs.js +0 -2
- package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
- package/dist/assets/device-picker-model-B-FI9413.js +0 -1
- package/dist/assets/i18n--GTAj4mB.js +0 -1
- package/dist/assets/index-DbXFHmBJ.js +0 -6
- package/dist/assets/mount-B-FI9413.js +0 -1
- package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
- package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
|
@@ -1107,7 +1107,7 @@ ${d.map(({leaf:e,path:t})=>o_e(e,t)).join(`
|
|
|
1107
1107
|
for (const dispose of disposers) dispose()
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
|
-
`}function __e(e){return`subjects`in e?e.subjects:e.classes.map(Wg)}var v_e=new Set(Object.values(Vg.mapping));function y_e(e){return Vg.mapping[e]??e}function b_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:v_e.has(n)&&y_e(r)===n}function x_e(e){return e===`start`||e===`update`||e===`end`}var S_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=__e(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`||!x_e(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=Gg(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 C_e(e){return`classes`in e}function w_e(e){return e===`appeared`||e===`departed`}function T_e(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!w_e(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=C_e(e)?e.classes?.map(Wg):e.subjects;if(c!==void 0){let e=Gg(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}}var nb=x({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),w()).nullable(),timestamp:n().meta(N(`none`)),seq:n().meta(N(`count`))}),rb=x({eventTypes:C(l()),vocabulary:C(Gpe).default([]),lastEvent:nb.nullable(),eventCountSinceStart:n().meta(N(`count`))}),ib={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EventEmitter],methods:{},events:{onEvent:{data:nb,trigger:{category:T.EventEmitted,label:F(`Fired an event`,`Ha generato un evento`),phrase:F(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:rb,kind:`push`},runtimeState:rb,durability:`session`,history:`none`,vocabulary:{noun:F(`Event source`,`Sorgente di eventi`),order:5280}},E_e=3,D_e=32;function O_e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function ab(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ob(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=D_e)){if(O_e(e)){t[r]=e;return}if(!(!ab(e)||i>=E_e))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(ab(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function k_e(e,t){let n=e;for(let e of t.split(`.`)){if(!ab(n))return;n=n[e]}return n}function sb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var cb=`recovered by reconcile`,A_e=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=nb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?sb(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=rb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Zpe(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:sb(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??Ype([e.eventType]);return(mg(t,e.eventType,e.sourceId)??mg(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=ob(e.data);for(let t of a??[]){let n=k_e(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} — ${cb}`:l,vars:s,data:c}}},lb=6e4;function ub(e){return(e/lb).toFixed(1)}var j_e=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*lb;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 ${ub(n)} min ago`};let r=`${ub(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 ${ub(n)} min ago, ${r}`}}},db=S([`string`,`number`,`boolean`,`select`]),M_e=/^[A-Za-z_][A-Za-z0-9_]*$/,fb=h([l(),n(),y()]),pb=x({name:l().regex(M_e),label:l().min(1).max(120).optional(),type:db,required:y().optional(),default:fb.optional(),options:C(l().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&&mb(e,e.default)!==null&&t.addIssue({code:`custom`,message:mb(e,e.default)??`invalid default`,path:[`default`]})});function mb(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 N_e(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=mb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var hb=S([`internal`,`addon`]),gb=`internal:`;function P_e(e){return`${gb}${e}`}function _b(e){return e.startsWith(`internal:`)&&e.length>9}function vb(e){if(_b(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var yb=x({isRunning:y(),lastRunAt:n().nullable(),lastError:l().nullable()}),F_e={isRunning:!1,lastRunAt:null,lastError:null},bb=n().int().min(0).max(86400),xb=x({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:hb,readOnly:y(),steps:C(K_).min(1).max(50).optional(),variables:C(pb).max(20).optional(),minDelaySec:bb.optional(),tags:Eh.optional(),status:yb}).superRefine((e,t)=>{if(e.source===`internal`){_b(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`]}),vb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Sb=x({name:l().min(1).max(120),steps:C(K_).min(1).max(50),variables:C(pb).max(20).optional(),minDelaySec:bb.optional(),tags:Eh.optional()}),Cb=x({blockId:l().min(1).optional()}),wb=h([qv,p(`started`),p(`timed-out`)]),Tb=x({runId:l().min(1),outcome:wb,message:l().optional()}),I_e=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),L_e=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},Eb=x({actionId:l(),runId:l(),isRunning:y(),outcome:qv.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function R_e(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 Db(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...R_e(e).flatMap(Db)]}async function z_e(e,t){let n=e.flatMap(Db);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){Ta(e,void 0);for(let n of t)Tne(e,n,i.get(n)??[])}}async function B_e(e,t,n=Date.now,r,i,a){let o=r?.mirror??new Iy(My(e));await o.refresh(t);let s=Uy(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 V_e(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function H_e(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await V_e(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 U_e(e,t){return`timed out after ${e} s: ${t}`}function Ob(e){return Ki(e)}function kb(e){let t=Ob(e);if(t===void 0)return[];let n=gl(t);return n===void 0?[t]:[t,...xl(n).filter(e=>e!==t)]}var Ab=x({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function W_e(e){let t=Mg(e);return t instanceof ce?t:void 0}function jb(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[...Ng(r.schema),...r.itemArray===void 0?[]:Tme(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=W_e(i)?.shape[r];return a===void 0?void 0:Mme(a)}}}function Mb(e){return Fg(e)??e}function Nb(e){return kb(e).length>1}function Pb(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function G_e(e,t){Bg({value:1,unit:e,target:t})}function K_e(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:Ob(r),a=zg(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new Lg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(zg(e.value)){let t=Bg({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:Mb(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?Nb(r)?{leaf:e,warnings:[Pb({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(G_e(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function Fb(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=K_e(e,t,n);return{value:r,warnings:i}}case`not`:{let r=Fb(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)=>Fb(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 q_e(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ta(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 Lg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);G_e(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(zg(u)?(o[l]=Bg({value:u.value,unit:u.unit,target:e.unit}),s[l]=Mb(u.unit)):typeof u==`number`&&s[l]===void 0&&Nb(e.quantity)&&c.push(Pb({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 Ib(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=q_e(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function Lb(e,t){let n=Fb(e.when,t,`when`),r=Ib(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function Rb(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||kb(n).length<2)return e;let r=Ob(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:Rb(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>Rb(e,t))};default:return e}}function J_e(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=Ta(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&&kb(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function zb(e,t){let n={...e,when:Rb(e.when,t),actions:e.actions.map(e=>J_e(e,t))};try{return{ok:!0,recipe:Lb(n,t).value}}catch(e){if(e instanceof Lg)return{ok:!1,error:e.message};throw e}}var Y_e=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],Bb=[`trigger`,`any`],Vb=[`trigger`,`guard`,`any`],Hb={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Vb,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:Vb,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:Vb,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:Vb,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:Vb,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},Ub=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function X_e(e){return Hb[e]}function Z_e(e){return Hb[e].seed()}function Q_e(e){return Ub.filter(t=>Hb[t].allowedIn.includes(e))}function Wb(e){return e instanceof Error?e.message:String(e)}function $_e(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function eve(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=Wb(e),i=$_e(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function tve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await td(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:Tu.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=Wb(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function nve(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 Gb=l().min(1),Kb=x({instanceId:Gb.optional()}),qb=x({instanceId:Gb,name:l(),enabled:y(),kind:l().optional(),nameRule:l().optional()}),Jb=`export-instance-unknown`,Yb=class extends Error{code=Jb;instanceId;constructor(e,t){super(`${Jb}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Xb(e){return`instanceId`in e?e.instanceId:void 0}function rve(e,t,n){if(n!==void 0&&n!==t)throw new Yb(e,n)}var ive=S([`unlinked`,`linked`,`error`]),Zb=x({label:l(),value:l(),secret:y().optional()}),Qb=x({qr:l().optional(),fields:C(Zb).readonly().optional(),note:l().optional()}),$b=x({linkState:ive,exposedDeviceCount:n(),error:l().optional(),setup:Qb.optional()}),ave=l(),ex=x({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:C(l()).optional()}),tx=x({instanceId:Gb,deviceId:l(),capabilities:C(l()).optional(),exposedName:l().nullable().optional()}),nx=x({instanceId:Gb,deviceId:l(),name:l().nullable(),dryRun:y().optional()}),rx=`export-name-refused`,ix=class extends Error{code=rx;instanceId;reason;constructor(e,t){super(`${rx}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},ax=x({instanceId:Gb,deviceId:l()}),ox=S([`device`,`action`,`notifier`]),sx=i(`kind`,[x({kind:p(`device`),deviceId:l()}),x({kind:p(`action`),actionId:l().min(1)}),x({kind:p(`notifier`),targetId:l().min(1)})]),cx=x({entity:sx,exposedAs:l().optional()}),lx=x({instanceId:Gb,entity:sx}),ux=x({instanceId:Gb,entity:sx}),dx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:$b,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:A(Kb,$b),listInstances:A(v(),C(qb)),listSupportedDeviceKinds:A(Kb,C(ave)),listExposedDevices:A(Kb,C(ex)),exposeDevice:A(tx,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:A(ax,v(),{kind:`mutation`,auth:`admin`}),setExposedName:A(nx,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:j(v(),C(ox)),listExposedEntities:j(Kb,C(cx)),exposeEntity:j(lx,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:j(ux,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},fx=`exposedNames`,ove=m(l(),l());function px(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 mx(e){let t=ove.safeParse(e[fx]);return t.success?t.data:{}}function sve(e,t,n){let r=mx(e)[t];if(r===void 0)return null;let i=px(r,n);return i.ok?i.name:null}function hx(e,t,n){let r=Object.fromEntries(Object.entries(mx(e)).filter(([e])=>e!==t));return{[fx]:n===null?r:{...r,[t]:n}}}async function cve(e){let t=px(e.raw,e.validate);if(!t.ok)throw new ix(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(mx(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,hx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function lve(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 uve(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))mx(a)[t]!==void 0&&(await e.writeDeviceStore(i,hx(a,t,null)),r.push(i));return r}function dve(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 gx=[`automation`,`action`,`scheduler`,`composition`],fve=S(gx),_x=x({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:C(l().min(1)),zones:C(l().min(1)).optional()}),pve=x({timeZone:l().min(1),location:x({latitude:n(),longitude:n()}).nullable(),rooms:C(l().min(1)),devices:C(_x).min(1),actions:C(x({id:l().min(1),name:l().min(1)})).default([])}),mve=60,vx=x({childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),yx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Switch,E.Light,E.Sensor,E.Climate,E.Cover,E.Lock,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Generic],methods:{setChildHidden:A(x({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:n(),childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:n(),childDeviceId:n(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:vx,kind:`command-driven`},vocabulary:{noun:F(`Accessories`,`Accessori`),order:3e3}},bx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:A(x({}),C(xb),{auth:`admin`}),runAction:A(x({actionId:l().min(1),variables:m(l(),fb).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:A(x({actionId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},hve=60*6e4,gve=3e4,xx=363e4;function _ve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Sx=x({actionId:l().min(1)}),Cx=x({deviceId:n().int().nonnegative(),actionIds:C(l().min(1)).max(100)}),wx={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(xb),{auth:`admin`}),get:A(x({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),x({action:xb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:A(x({actionId:l().min(1),variables:m(l(),fb).optional(),wait:y().optional(),origin:Cb.optional(),deviceId:n().int().nonnegative().optional()}),Tb,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:xx}),stop:A(Sx,v(),{kind:`mutation`,auth:`admin`}),getTraces:A(Sx,x({traces:C(ny)}),{auth:`admin`}),create:A(x({action:Sb}),x({action:xb,warnings:C(Ab).optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({actionId:l().min(1),action:Sb.partial()}),x({action:xb,warnings:C(Ab).optional()}),{kind:`mutation`,auth:`admin`}),delete:A(Sx,v(),{kind:`mutation`,auth:`admin`}),listForCamera:A(x({deviceId:n().int().nonnegative()}),C(xb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:A(x({deviceId:n().int().nonnegative()}),Cx,{auth:`admin`}),setLinks:A(Cx,Cx,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:Eb}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},vve=x({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),Tx=x({addonId:l(),page:vve,bundleUrl:l()}),Ex={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:A(v(),C(Tx).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},yve=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:S([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),bve=x({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:w(),headers:m(l(),l()),instanceId:l().optional(),user:x({id:l(),username:l(),isAdmin:y()}).optional(),scopedToken:w().optional()}),xve=x({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:w().optional(),contentType:l().optional()}),Dx={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:A(v(),C(yve)),invoke:A(bve,xve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Ox=x({id:l(),label:l(),icon:l(),order:n().optional()}),kx=x({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:C(ge())}),Ax=x({tabs:C(Ox).optional(),sections:C(kx)}),jx=m(l(),w()),Mx=S(Gn),Sve=x({cap:l(),scope:Mx,sectionIds:C(l())}),Nx=x({success:p(!0)}),Px={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional()}),Ax.nullable()),listScopedSettings:A(x({addonId:l(),nodeId:l().optional()}),C(Sve).nullable()),updateScopedSettings:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`}),readScopedValues:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional()}),m(l(),w()).nullable()),getDeclaredSettingsKeys:A(x({addonId:l(),nodeId:l().optional()}),x({keys:C(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:A(x({addonId:l(),nodeId:l().optional(),keys:C(l())}),x({removed:C(l()),refused:C(x({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional()}),Ax.nullable()),updateDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},Fx=S([`device-tab`,`dashboard`,`integration-detail`]),Ix=S([`xs`,`sm`,`md`,`lg`,`xl`]),Lx=x({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),Rx=x({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:Lx,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:C(Fx).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:Ix.default(`md`),allowedSizes:C(Ix).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),zx={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:A(v(),C(Rx).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Bx=Rx.extend({addonId:l(),bundleUrl:l()}),Vx={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:A(v(),C(Bx).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Hx=S([`install`,`update`,`uninstall`,`restart`]),Ux=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),Wx=S([`framework`,`addon`]),Gx=x({tsMs:n(),nodeId:l(),packageName:l(),phase:Ux,message:l()}),Kx=x({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:Wx,phase:Ux,stagedPath:l().nullable(),attempts:n(),steps:C(Gx),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),qx=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),Jx=S([`single`,`bulk`,`cluster`]),Yx=x({jobId:l(),kind:Hx,createdAtMs:n(),createdBy:l(),scope:Jx,tasks:C(Kx),state:qx,schemaVersion:p(1)}),Xx=S([`debug`,`info`,`warn`,`error`]),Zx=S([`off`,`latest`,`beta`]),Qx=S([`off`,`latest`,`beta`,`inherit`]),Cve=x({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:C(w()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:x({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),wve=x({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),Tve=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:x({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),$x=x({manifest:Cve,declaration:w().optional(),source:l(),installSource:l().optional(),process:wve.optional(),hasBackup:y().optional(),health:Tve.nullable().optional()}),eS=x({name:l(),version:l(),dir:l(),installSource:l().optional()}),tS=x({name:l(),currentVersion:l(),latestVersion:l(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(au).readonly().optional()}),nS=x({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:C(l()).readonly()}),rS=i(`status`,[x({status:p(`ok`),markdown:l()}),x({status:p(`missing`)}),x({status:p(`error`),message:l()})]),Eve=x({name:l(),version:l(),readme:rS,changelog:rS}),iS=x({name:l(),version:l(),description:l(),keywords:C(l()).readonly(),publishedAt:l(),author:l(),installed:y(),installedVersion:l().optional(),capabilities:C(l()).readonly().nullable()}),aS=x({channel:Zx,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),oS=Qx,Dve=w(),Ove=w(),kve=w(),sS=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),cS=x({nodeId:l(),outcome:sS,error:l().optional(),addonIds:C(l()).readonly(),runnersStopped:C(l()).readonly(),warnings:C(l()).readonly()}),lS=x({success:y(),packageName:l(),results:C(cS).readonly()}),uS=x({packageName:l(),nodeId:l(),nodeName:l(),isHub:y(),isOnline:y(),version:l().nullable(),addonIds:C(l()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),dS=x({installations:C(uS).readonly(),unreachable:C(x({nodeId:l(),error:l()})).readonly()}),Ave=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),jve=x({name:l(),isSystem:y(),fromVersion:l(),toVersion:l(),status:Ave,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),Mve=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:Mve,cancelled:y(),items:C(jve).readonly()});var Nve=x({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:y(),description:l().optional(),buildId:l().nullable()}),fS=x({timestamp:l(),level:l(),message:l(),scope:l().optional()}),Pve=w(),pS=x({addonId:l().min(1),action:l().min(1),input:w()}),mS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:A(x({nodeId:l().optional()}).optional(),C($x).readonly()),getLogs:A(x({addonId:l(),limit:n().min(1).max(500).default(100),level:Xx.optional()}),C(Pve)),listPackages:A(v(),C(eS).readonly()),installPackage:A(x({packageName:l(),version:l().optional()}),Ove,{kind:`mutation`,auth:`admin`}),uninstallPackage:A(x({packageName:l().min(1),nodeId:l().optional(),everywhere:y().optional()}),lS,{kind:`mutation`,auth:`admin`}),listInstallations:A(x({packageName:l().optional()}),dS,{auth:`admin`}),reloadPackages:A(v(),kve,{kind:`mutation`,auth:`admin`}),searchAvailable:A(x({query:l().optional(),capability:l().optional()}),C(iS)),listUpdates:A(x({nodeId:l().optional()}),C(tS).readonly(),{auth:`admin`}),updatePackage:A(x({name:l().min(1),version:l().optional(),nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),rollbackPackage:A(x({name:l().min(1)}),x({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:A(x({nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),restartServer:A(x({confirm:p(!0)}),w(),{kind:`mutation`,auth:`admin`}),getLastRestart:A(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:A(v(),C(Nve).readonly(),{auth:`admin`}),listCapabilityProviders:A(x({capName:l().min(1)}),C(x({addonId:l(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:A(x({capName:l().min(1),addonId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:A(x({name:l()}),C(nS).readonly()),getPackageDocs:A(x({name:l().min(1),version:l().min(1).optional()}),Eve,{auth:`admin`}),restartAddon:A(x({addonId:l()}),Dve,{kind:`mutation`,auth:`admin`}),retryLoad:A(x({packageName:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:A(v(),aS,{auth:`admin`}),setAutoUpdateSettings:A(x({channel:Zx,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),w(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:A(x({addonId:l()}),oS,{auth:`admin`}),setAddonAutoUpdate:A(x({addonId:l(),channel:Qx}),w(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:A(x({channel:Zx}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:A(pS,w(),{role:`viewer`,kind:`mutation`}),startJob:A(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:l().min(1),version:l().min(1)})).min(1),nodeIds:C(l()).optional()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:A(x({jobId:l()}),Yx.nullable(),{auth:`admin`}),listJobs:A(x({activeOnly:y().optional()}),C(Yx),{auth:`admin`}),cancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:A(x({addonId:l(),level:Xx.optional()}),fS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},hS=x({co2:n().min(0).optional().meta(N(`concentration-volume`)),voc:n().min(0).optional().meta(N(`concentration-ppb`)),pm25:n().min(0).optional().meta(N(`concentration-mass`)),pm10:n().min(0).optional().meta(N(`concentration-mass`)),aqi:n().optional().meta(N(`index`)),lastFetchedAt:n()}),gS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:hS,kind:`push`},runtimeState:hS,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:F(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:F(`the CO₂`,`la CO₂`),label:F(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:F(`the VOC level`,`il livello di COV`),label:F(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:F(`the PM2.5`,`il PM2,5`),label:F(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:F(`the PM10`,`il PM10`),label:F(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:F(`the air quality index`,`l’indice di qualità dell’aria`),label:F(`AQI`,`IQA`),icon:`wind`}]}},_S=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),vS=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),yS=x({state:_S,targetMode:vS.nullable().optional(),availableModes:C(vS),codeRequired:y().nullable(),lastChangedAt:n()}),bS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.AlarmPanel],methods:{trigger:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:F(`Trigger alarm`,`Fai scattare l’allarme`),phrase:F(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:F(`Disarm`,`Disinserisci`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:A(x({deviceId:n().int().nonnegative(),mode:vS,code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:F(`Arm home`,`Inserisci in casa`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:F(`Arm away`,`Inserisci fuori casa`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:F(`Arm night`,`Inserisci notte`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:F(`Arm vacation`,`Inserisci vacanza`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:F(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:yS,kind:`push`},runtimeState:yS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:F(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:F(`Disarmed`,`Disinserito`),phrase:F(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:F(`Armed home`,`Inserito in casa`),phrase:F(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:F(`Armed away`,`Inserito fuori casa`),phrase:F(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:F(`Armed night`,`Inserito notte`),phrase:F(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:F(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:F(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:F(`Arming`,`In inserimento`)},{value:`disarming`,label:F(`Disarming`,`In disinserimento`)},{value:`pending`,label:F(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:F(`Triggered`,`In allarme`),phrase:F(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},xS=S([`info`,`success`,`warning`,`error`,`critical`]),Fve=x({addonId:l().min(1),action:l().min(1),input:m(l(),w()).optional()}),Ive=x({label:l(),href:l().optional(),invoke:Fve.optional(),navigation:S([`app`,`server`]).optional()}),SS=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),CS=x({type:l(),id:l()}),wS=x({id:l(),category:l(),severity:xS,title:l(),message:l(),action:Ive.optional(),status:SS,progress:n().optional(),read:y(),createdAt:n(),updatedAt:n(),source:CS.optional(),metadata:m(l(),w()).optional()}),TS={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:A(wS,v(),{kind:`mutation`}),update:A(x({alertId:l(),patch:wS.partial()}),v(),{kind:`mutation`}),list:A(x({unreadOnly:y().optional(),limit:n().optional()}).optional(),C(wS).readonly()),getUnreadCount:A(v(),n()),markRead:A(x({alertId:l()}),v(),{kind:`mutation`}),markAllRead:A(v(),v(),{kind:`mutation`}),dismiss:A(x({alertId:l()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},ES=x({illuminance:n().min(0).nullable().meta(N(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),DS={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:ES,kind:`push`},runtimeState:ES,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:F(`the light level`,`la luminosità`),label:F(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},OS={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:A(x({deviceId:n()}),ve())},events:{onAudioLevel:Lr(x({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:F(`Audio analysis`,`Analisi audio`),order:3010}},Lve=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),kS=x({data:ve(),format:Lve,width:n(),height:n(),timestamp:n()}),AS=x({x:n(),y:n(),w:n(),h:n()}),Rve=x({class:l(),originalClass:l(),score:n(),bbox:AS}),jS=x({data:b(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),MS=x({rms:n(),dbfs:n()}),NS=x({className:l(),originalClass:l().optional(),score:n()}),PS=[`superseded`,`error`,`timeout`,`disposed`],FS=i(`state`,[x({state:p(`classified`)}),x({state:p(`not-classified`),reason:S(PS)})]),IS=x({level:MS,classification:x({labels:C(NS).readonly(),inferenceMs:n()}).optional(),classifyOutcome:FS,timestamp:n()}),LS=x({minConfidence:n().min(0).max(1).default(.3),allowedClasses:C(l()).default([])}),RS=x({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:LS}),zS=x({attached:y(),replaced:y()}),BS=x({detached:y()}),VS=x({labels:C(NS).readonly(),rawLabels:C(NS).readonly().optional(),inferenceMs:n()}),zve=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],Bve={audioBackend:`auto`,probedBestAudioBackend:``},HS={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:A(x({chunk:jS,settings:LS}),IS.nullable(),{kind:`mutation`}),classify:A(jS,VS,{timeoutMs:3e4}),attachDevice:A(RS,zS,{kind:`mutation`}),detachDevice:A(x({deviceId:n()}),BS,{kind:`mutation`}),isReady:A(v(),y()),dispose:A(v(),v(),{kind:`mutation`}),reprobeAudioEngine:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},US=S([`f32le`,`s16le`]),WS=x({codec:l(),canDecode:y(),canEncode:y(),label:l().optional()}),GS=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:US.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),KS=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:US.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),qS=x({data:b(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:US,pts:n()}),JS=x({data:b(Uint8Array),codec:l(),pts:n(),frameComplete:y()}),Vve=x({sessionId:l(),kind:S([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:US,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),YS={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:A(v(),C(WS).readonly()),canHandle:A(x({codec:l(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:A(GS,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:A(KS,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:A(x({sessionId:l(),nodeId:l().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullPcm:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(qS)),pushPcm:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullEncoded:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(JS)),flushEncode:A(x({sessionId:l(),nodeId:l().optional()}),C(JS),{kind:`mutation`}),listActiveSessions:A(v(),C(Vve).readonly())},vocabulary:{notOperatorFacing:M.INTERNAL}},XS=x({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),ZS=x({ts:n().int(),windowSec:n().int().positive(),level:x({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:x({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:C(XS).readonly()}),QS=x({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),$S=x({points:C(QS).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),eC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCurrentSnapshot:A(x({deviceId:n()}),ZS.nullable()),getHistory:A(x({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),$S)},runtimeState:ZS,durability:`session`,history:`none`,vocabulary:{noun:F(`Audio metrics`,`Metriche audio`),order:3020}},tC=x({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:y().default(!1)}),nC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:A(x({username:l(),password:l()}),tC.nullable(),{kind:`mutation`}),getLoginUrl:A(x({state:l()}),l()),handleCallback:A(m(l(),l()),tC,{kind:`mutation`}),validateToken:A(x({token:l()}),tC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},rC=x({enabled:y(),isRunning:y(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),iC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Automation],methods:{enable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:F(`Enable automation`,`Abilita l’automazione`),phrase:F(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:F(`Disable automation`,`Disabilita l’automazione`),phrase:F(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:A(x({deviceId:n().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:F(`Trigger automation`,`Avvia l’automazione`),phrase:F(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:rC,kind:`push`},runtimeState:rC,durability:`session`,history:`none`,vocabulary:{noun:F(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:F(`Enabled`,`Abilitata`),whenTrue:F(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:F(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},Hve=`.backup-snapshot`,Uve=`.backup-snapshot-partial`,aC=30*6e4,oC=x({databases:C(x({databaseId:Ud,livePath:l()}))}),sC=x({name:l(),rows:n().int().nonnegative()}),cC=x({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:C(sC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),lC=cC.extend({databaseId:Ud}),uC=x({databaseId:Ud}),dC=cC.extend({livePath:l(),snapshotPath:l(),databaseId:Ud.optional()}),fC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:A(x({}),oC,{auth:`admin`}),writeSnapshot:A(uC,lC,{kind:`mutation`,auth:`admin`,timeoutMs:aC})},vocabulary:{notOperatorFacing:M.INTERNAL}},pC=x({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:y(),restoreSupported:y()}).extend({id:l(),addonId:l(),enabled:y(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),mC=x({scheme:l(),keyId:l()}),hC=x({enabled:y(),active:x({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:C(x({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),Wve=x({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:C(l()).readonly(),encryption:mC.optional(),databases:C(Ud).readonly().optional()}),gC=x({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:C(l()).optional(),encryption:mC.optional()}),_C=x({path:l(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),vC=x({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:C(l()),entries:C(_C),totalBytes:n(),totalFiles:n(),sqliteSnapshots:C(dC).optional(),omittedDatabases:C(Ud).optional()}),yC=x({name:l(),sizeBytes:n(),fileCount:n(),present:y()}),bC=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),xC=S([`queued`,`building`,`uploading`,`done`]),SC=x({id:l(),state:bC,phase:xC,destinationIds:C(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:C(l()).readonly(),failedDestinationIds:C(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),CC=x({runId:l(),queued:y(),joined:y(),cancelled:y(),entries:C(gC).readonly()}),wC=x({id:l(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(Ud).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),TC={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:A(v(),C(pC).readonly(),{auth:`admin`}),trigger:A(x({destinations:C(l()).optional(),locations:C(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:C(Ud).optional()}).optional(),CC,{kind:`mutation`,auth:`admin`}),listRuns:A(v(),C(SC).readonly(),{auth:`admin`}),cancel:A(x({runId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:A(v(),C(gC).readonly(),{auth:`admin`}),listLocations:A(v(),C(yC).readonly(),{auth:`admin`}),getEntries:A(x({destinationId:l(),backupId:l()}),vC.nullable(),{auth:`admin`}),restore:A(x({destinationId:l(),backupId:l(),locations:C(l()).optional(),backupSecretKey:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:A(v(),hC,{auth:`admin`}),setupEncryption:A(x({}),x({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:A(x({}),x({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:A(x({backupSecretKey:l()}),x({valid:y(),keyId:l().nullable(),known:y(),active:y(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:A(x({destinationId:l(),backupId:l()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:A(x({destinationId:l()}),C(Wve).readonly(),{auth:`admin`}),upsertDestinationPolicy:A(x({locationId:l(),enabled:y(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:A(x({cron:l(),count:n().int().min(1).max(20).optional()}),x({ok:y(),error:l().optional(),nextRuns:C(n()).readonly()})),listSchedules:A(v(),C(wC).readonly(),{auth:`admin`}),listAvailableDatabases:A(v(),x({answered:y(),databases:C(Ud).readonly()}),{auth:`admin`}),upsertSchedule:A(x({id:l().optional(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(Ud).readonly().optional()}),wC,{kind:`mutation`,auth:`admin`}),deleteSchedule:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},EC=x({level:n().min(0).max(100).nullable().meta(N(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:n().meta(N(`none`)),voltage:n().nullable().optional().meta(N(`voltage`,{label:`Voltage`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:y().optional().meta({label:`Binary indicator`})}),DC=[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.EventEmitter],Gve={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:DC,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}]},OC={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:DC,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:EC}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:EC,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:EC,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:Gve,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:F(`Asleep`,`In sospensione`),whenTrue:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:F(`Charging`,`Ricarica`),values:[{value:`dc`,label:F(`Charging from mains`,`In carica da rete`),phrase:F(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:F(`Charging from solar`,`In carica dal pannello solare`),phrase:F(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:F(`Not charging`,`Non in carica`),phrase:F(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:T.DeviceAwake,label:F(`Woke up`,`Risvegliato`),phrase:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:T.DeviceSleeping,label:F(`Went to sleep`,`In sospensione`),phrase:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},kC=x({on:y().meta({label:`On`}),lastChangedAt:n()}),AC={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:kC,kind:`push`},runtimeState:kC,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:F(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[O.MotionSensor]:{state:{on:{label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[O.ContactSensor]:{state:{on:{label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[O.LeakSensor]:{state:{on:{label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[O.SmokeSensor]:{state:{on:{label:F(`Smoke`,`Fumo`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[O.COSensor]:{state:{on:{label:F(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[O.GasSensor]:{state:{on:{label:F(`Gas`,`Gas`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[O.TamperSensor]:{state:{on:{label:F(`Tampered`,`Manomesso`),whenTrue:F(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:F(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[O.VibrationSensor]:{state:{on:{label:F(`Vibration`,`Vibrazione`),whenTrue:F(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:F(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[O.ConnectivitySensor]:{state:{on:{label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[O.SoundSensor]:{state:{on:{label:F(`Sound`,`Suono`),whenTrue:F(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:F(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[O.BatterySensor]:{state:{on:{label:F(`Battery low`,`Batteria scarica`),whenTrue:F(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:F(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[O.BinaryHelper]:{state:{on:{label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},jC=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),Kve=x({sourceId:l(),name:l()}),qve=x({configuration:l(),name:l(),address:l().nullable()}),MC=x({ok:p(!1),reason:jC,detail:l().optional()}),Jve=i(`ok`,[x({ok:p(!0),boards:C(qve).readonly()}),MC]),Yve=i(`ok`,[x({ok:p(!0),key:l()}),MC]),NC={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:A(v(),C(Kve).readonly(),{auth:`admin`}),listBoards:A(x({sourceId:l().min(1)}),Jve,{auth:`admin`}),getBoardKey:A(x({sourceId:l().min(1),configuration:l().min(1)}),Yve,{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},PC=x({level:n().min(0).max(100).meta(N(`percentage`)),lastChangedAt:n()}),FC={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setBrightness:A(x({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:F(`Full brightness`,`Luminosità massima`),phrase:F(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:F(`Half brightness`,`Luminosità a metà`),phrase:F(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:F(`Brightness off`,`Luminosità a zero`),phrase:F(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:F(`Set brightness`,`Imposta la luminosità`),phrase:F(`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:F(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:PC,kind:`command-driven`},runtimeState:PC,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:F(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:F(`the brightness`,`la luminosità`),label:F(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},Xve=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),IC=x({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),Zve=x({id:l()}),Qve=m(l(),w()),LC=x({brokerId:l(),target:m(l(),w()),payload:w().optional()}),RC=x({brokerId:l(),filter:m(l(),w())}),zC=x({subscriptionId:l()}),BC=x({brokerId:l(),subscriptionId:l()}),VC=x({brokerId:l(),key:l()}),HC={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:IC,kind:`poll`},methods:{getBrokerConfig:A(Zve,Qve.nullable(),{auth:`admin`}),publish:A(LC,w(),{kind:`mutation`,auth:`admin`}),subscribe:A(RC,zC,{kind:`mutation`,auth:`admin`}),unsubscribe:A(BC,v(),{kind:`mutation`,auth:`admin`}),getState:A(VC,w().nullable(),{auth:`admin`}),getStatus:A(v(),IC)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},UC={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button],methods:{press:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:F(`Press`,`Premi`),phrase:F(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:F(`Button`,`Pulsante`),order:1130}},WC=S([`ha`,`addon`]),GC=x({id:l().min(1),name:l().min(1),source:WC,enabled:y(),instanceId:l().min(1).optional()}),KC=x({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:y().optional(),description:l().optional(),location:l().optional()}),qC=x({calendarIds:C(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),JC={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:A(v(),C(GC).readonly(),{auth:`admin`}),listEvents:A(qC,C(KC).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}};function YC(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function XC(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=YC(e.startMs),n=YC(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 $ve(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=XC(e);return i.startMs<r&&i.endMs>t}var ZC=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),QC=GC.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:ZC,color:ZC,visible:y()}),$C=x({visible:y().optional(),color:ZC.optional()}),ew=x({calendars:m(l(),$C)}),tw=x({calendarId:l().min(1),visible:y().optional(),color:ZC.nullable().optional()}),nw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:A(v(),C(QC).readonly(),{auth:`admin`}),listEvents:A(qC,C(KC).readonly(),{auth:`admin`}),getPreferences:A(x({}),ew,{auth:`admin`,caller:`required`}),setCalendarPreference:A(tw,ew,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},rw=x({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:y().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),iw=x({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:l().nullable()}),aw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCredentials:A(x({deviceId:n()}),rw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:iw,kind:`command-driven`},vocabulary:{noun:F(`Camera credentials`,`Credenziali della telecamera`),order:3030}},ow=x({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),sw=x({deviceId:n().int().positive(),source:ow,cell:ow}),eye=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(n().int().positive()),canvas:l(),published:y()}),cw=x({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:C(sw),profiles:C(eye)}),lw=x({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(sw).max(16)}),uw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getLayout:A(x({deviceId:n().int().nonnegative()}),cw.nullable(),{auth:`admin`}),saveLayout:A(lw,cw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Grid layout`,`Layout a griglia`),order:3040}},dw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},fw=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),pw=S([`mp4`,`gif`]),mw=x({kind:pw,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),hw=x({fromTs:n(),toTs:n(),packets:n().int()}),gw=x({media:C(mw).readonly(),coverage:hw,profile:P,video:S([`copy`,`encode`])}),_w=x({brokerId:l(),url:l(),mutedUrl:l(),enabled:y(),codec:l().optional(),resolution:x({width:n().int().positive(),height:n().int().positive()}).optional()}),vw=x({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:y(),muted:y(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),yw=x({tag:l(),subscribedAt:n(),chunksDelivered:n()}),bw=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),xw=x({kind:bw,label:l().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),Sw=x({id:l(),channel:S([`annexb`,`rtp`]),attribution:xw,subscribedAt:n(),packetsDelivered:n()}),Cw=x({rtsp:C(vw).readonly(),audio:C(yw).readonly(),encoded:C(Sw).readonly(),pipeClients:n(),encodedSubscribers:n()}),ww=x({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),tye=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),nye=S([`h264`,`h265`,`copy`]),rye=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),Tw=x({deviceId:n().int().nonnegative(),video:nye,audio:rye.optional(),profile:P.optional(),targetResolution:x({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:C(l()).optional(),audioEgress:y().optional(),hostname:l().optional(),tag:l().optional()}),Ew=x({url:l(),sentryUrl:l().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:l(),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),pipelineKey:l()}),Dw=id.omit({inputArgs:!0,outputArgs:!0}),Ow=S([`tight`,`relaxed`]),kw=x({deviceId:n().int().nonnegative(),source:i(`kind`,[x({kind:p(`profile`),profile:P}),x({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:Dw,rateControl:Ow.optional(),bitstreamFilter:S([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:y().optional(),pixelFormat:S([`yuv420p`,`nv12`]).optional(),decodeHwAccel:S([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:l().optional(),tag:l().optional()}),Aw=x({url:l(),pipelineKey:l(),videoCodec:S([`H264`,`H265`]),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),jw={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:A(x({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:Xi,url:l().optional(),codec:l().optional(),resolution:Zi.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:C(l()).optional(),autoEligible:y().optional(),profileHint:P.optional(),metadata:m(l(),w()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:id.optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:A(x({deviceId:n().int().nonnegative(),profile:P,camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:A(x({deviceId:n().int().nonnegative()}),x({derivedStreamsDeleted:C(l()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),x({base64:l(),mime:l(),bytes:n().int(),profile:P,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:C(pw).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),gw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:A(x({handle:l()}),x({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:A(v(),C(Qi).readonly()),listAllProfileSlots:A(v(),C(ea).readonly()),getBrokerStats:A(x({brokerId:l()}),ca),probeStream:A(x({brokerId:l()}),x({probed:y(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:A(x({brokerId:l()}),Cw),getLiveViewerCounts:A(v(),C(ww).readonly(),{role:`viewer`}),killClient:A(x({brokerId:l(),channel:S([`rtsp`,`audio`]),handle:l()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:A(x({streamId:l(),format:fw}),x({url:l()})),getStreamWithCodec:A(Tw,Ew,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:A(kw,Aw,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:A(aa,oa,{kind:`mutation`}),pullAudioChunks:A(x({subscriptionId:l(),maxCount:n().int().positive().default(8)}),C(ia).readonly()),unsubscribeAudioChunks:A(x({subscriptionId:l()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:A(x({brokerId:l(),seconds:n().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:A(x({brokerId:l()}),x({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:A(v(),n()),getAllRtspEntries:A(x({hostname:l().optional()}),C(_w).readonly()),getRtspEntry:A(x({brokerId:l(),hostname:l().optional()}),_w.nullable()),regenerateRtspToken:A(x({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:A(x({brokerId:l(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:A(x({brokerId:l()}),y()),getDeviceAudioMute:A(x({deviceId:n().int()}),x({muted:y(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:A(x({deviceId:n().int(),muted:y()}),x({muted:y(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l(),profile:P})),onCamStreamIdle:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:M.PIPELINE}},Mw=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),Nw=x({acceptCodecs:C(Mw).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(Mw).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),Pw=x({preferredProviders:C(l()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),Fw=x({camStreamId:l(),codec:l().optional(),resolution:Zi.optional(),transcodes:y(),reason:l(),profile:P.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),Iw={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{getCameraStreams:A(x({deviceId:n().int().nonnegative()}),C(Qi).readonly()),getBrokerStreams:A(x({deviceId:n().int().nonnegative()}),C(ea).readonly()),getRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(_w).readonly()),getProfileRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(la).readonly()),pickStream:A(x({deviceId:n().int().nonnegative(),requirements:Nw,preferences:Pw.optional()}),Fw.nullable())},events:{onCamStreamsChanged:Lr(x({deviceId:n().int().nonnegative(),camStreams:C(Qi).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:Lr(x({deviceId:n().int().nonnegative(),profileSlots:C(ea).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:$i.optional(),mid:$i.optional(),low:$i.optional()}),slotErrors:x({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:F(`Camera streams`,`Flussi della telecamera`),order:3060}},Lw=x({detected:y(),lastChangedAt:n()}),Rw={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:Lw,kind:`push`},runtimeState:Lw,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},zw=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Bw=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),Vw=x({mode:zw,action:Bw.nullable().optional(),availableModes:C(zw),fanMode:l(),availableFanModes:C(l()),preset:l(),availablePresets:C(l()),target:n().nullable().meta(N(`temperature`)),targetHigh:n().nullable().meta(N(`temperature`)),targetLow:n().nullable().meta(N(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),currentTemp:n().nullable().meta(N(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:n().nullable().optional().meta(N(`temperature`)),maxTemp:n().nullable().optional().meta(N(`temperature`)),tempStep:n().positive().nullable().optional().meta(N(`temperature`)),lastActiveMode:zw.exclude([`off`]).optional(),lastFetchedAt:n()}),iye=[E.Climate];function Hw(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:iye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var Uw=[Hw(`room-temperature`,`currentTemp`),Hw(`room-humidity`,`currentHumidity`)],aye={version:1,overridable:Uw.map(e=>({path:e.path,by:e.id})),targets:Uw},Ww={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:A(x({deviceId:n().int().nonnegative(),mode:zw}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:F(`Climate off`,`Clima spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:F(`Heat`,`Riscalda`),phrase:F(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:F(`Cool`,`Raffresca`),phrase:F(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:F(`Climate auto`,`Clima automatico`),phrase:F(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Spento`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:A(x({deviceId:n().int().nonnegative(),target:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:F(`Set temperature`,`Imposta la temperatura`),phrase:F(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:j(x({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:F(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:F(`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:F(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:F(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:j(x({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`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:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:j(x({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:F(`Set fan mode`,`Imposta la ventilazione`),phrase:F(`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:F(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:F(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:F(`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:F(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:F(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:F(`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:F(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:F(`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:Vw,kind:`push`},runtimeState:Vw,customize:aye,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:F(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:F(`Mode`,`Modalità`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`),phrase:F(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`),phrase:F(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:F(`the temperature`,`la temperatura`),label:F(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:F(`the set temperature`,`la temperatura impostata`),label:F(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Gw=S([`backup`,`hub-server`,`agent-server`,`addons`]),Kw=S([`pending`,`running`,`ok`,`failed`,`skipped`]),qw=S([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),Jw=x({kind:Gw,nodeId:l().optional(),status:Kw,detail:l(),reason:qw.optional(),fromVersion:l().nullable().optional(),packages:C(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),Yw=S([`running`,`succeeded`,`failed`]),Xw=x({id:l(),state:Yw,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:C(Jw).readonly(),stoppedAt:l().optional(),reason:qw.optional(),skippedOffline:C(l()).readonly()}),Zw=x({version:l().optional(),addons:y().optional(),backup:y().optional()}),Qw=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),$w=x({targetVersion:l().nullable(),steps:C(Jw).readonly(),skippedOffline:C(l()).readonly(),blocker:Qw.nullable(),blockerDetail:l().nullable()}),eT=x({accepted:y(),jobId:l().nullable(),blocker:Qw.nullable(),message:l()}),tT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:A(Zw,$w,{auth:`admin`}),startClusterUpdate:A(Zw,eT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:A(x({jobId:l().optional()}),Xw.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},nT=x({r:n().int().min(0).max(255).meta(N(`none`)),g:n().int().min(0).max(255).meta(N(`none`)),b:n().int().min(0).max(255).meta(N(`none`))}),rT=x({h:n().min(0).max(360).meta(N(`none`)),s:n().min(0).max(100).meta(N(`none`)),v:n().min(0).max(100).meta(N(`none`))}),iT=i(`mode`,[x({mode:p(`rgb`),rgb:nT}),x({mode:p(`hsv`),hsv:rT}),x({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),aT=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:nT.optional(),hsv:rT.optional(),colorTemperature:n().int().optional().meta(N(`colour-temperature`)),lastChangedAt:n()});function oye(e){let t=iT.safeParse(e);return t.success?t.data:null}var oT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setColor:A(x({deviceId:n().int().nonnegative(),color:iT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:F(`Warm white`,`Bianco caldo`),phrase:F(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:F(`Cool white`,`Bianco freddo`),phrase:F(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:F(`Red`,`Rosso`),phrase:F(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:F(`Green`,`Verde`),phrase:F(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:F(`Blue`,`Blu`),phrase:F(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:x({deviceId:n(),mode:S([`rgb`,`hsv`,`mired`]),rgb:nT.optional(),hsv:rT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:aT,kind:`command-driven`},runtimeState:aT,durability:`session`,history:`none`,vocabulary:{noun:F(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:F(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:F(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:F(`HSV colour`,`Colore HSV`)},{value:`mired`,label:F(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function sT(e,t){let n=e;for(let e of t.split(`.`)){let t=Mg(n);if(!(t instanceof ce))return null;let r=t.shape[e];if(!(r instanceof ie))return null;n=r}return n}function cT(e,t){let n=Ng(e).find(e=>e.path===t);if(n===void 0)return null;let r=sT(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 lT(e){return new Map(Ng(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=cT(e,t.path);return n===null?[]:[[t.path,n]]}))}function uT(e){let t=Mg(e);return t instanceof ce?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]):[]}function dT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=sT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var fT={"doorbell.onPressed":T.DoorbellOnPressed},sye=fT,pT=x({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:S(T),stateField:l(),fieldKey:l()});function mT(e,t,n){return{code:e,path:t,message:n}}function cye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function hT(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?cT(e.runtimeState,s.field):null;if(l===null){r.push(mT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(mT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=sye[u];if(d===void 0){r.push(mT(`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(mT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${cye(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(mT(`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 gT=S(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator.link-contribution-removed`.split(`.`)),_T=x({code:gT,path:l(),message:l()}),vT=S([`string`,`number`,`boolean`,`enum`]),yT=S([`null`,`offline`,`unknown`,`release`,`omit`]),bT=S([`derived`,`clock`,`constant`,`accumulator`]),xT=x({arrayPath:l(),key:l(),label:l(),resettable:y().optional()}),ST=x({cap:l(),path:l(),item:xT.optional(),featureIndex:n().int().nonnegative(),kind:vT,nullable:y(),required:y(),unavailable:yT,role:bT,source:Fc,reads:C(Dc)});function CT(e){let t=e.item===void 0?e.path:cl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var wT=S([`new`,`add`,`replace`]),TT=x({featureIndex:n().int().nonnegative(),cap:l(),mode:wT}),ET=x({ok:y(),problems:C(_T),fields:C(ST),features:C(TT),events:C(pT)}),DT=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),OT=S([`fresh`,`stale`,`unavailable`]),kT=x({cap:l(),path:l(),item:xT.optional(),state:OT,value:h([l(),n(),y(),ae()]),reason:l().optional()}),AT=x({blockId:l(),deviceId:n().nullable(),status:DT,reason:l().optional(),fields:C(kT)}),lye=Tc,jT=x({id:l().min(1),name:l().min(1).max(120),enabled:y(),updatedAt:n(),composition:tl}),MT=x({id:l().min(1),name:l().nullable(),error:l()}),NT=x({deviceId:n().int(),capName:l(),owner:l(),error:l()}),PT=x({integrationId:l().nullable(),storeLoaded:y(),blocks:C(jT),restartBlockIds:C(l()),unreadableBlocks:C(MT),retiredBlockIds:C(l()).optional()}),FT=x({blockId:l(),status:DT,reason:l().optional()}),IT=x({blocks:C(FT),acted:y(),unreleasedClaims:C(NT).optional()}),LT={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:A(PT,IT,{kind:`mutation`,auth:`admin`}),getStates:A(x({blockIds:C(l())}),x({states:C(AT)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},RT=x({connected:y(),lastChangedAt:n()}),zT={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:RT,kind:`push`},runtimeState:RT,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},BT=S([`wear`,`supply`,`waste`]),VT=S([`part`,`tank`,`product`,`bin`]),HT=S([`ok`,`low`,`empty`,`full`,`replace`]),uye=S([`ok`,`low`,`empty`,`full`]);function UT(e){return e.kind??`wear`}var dye={wear:`part`,waste:`bin`,supply:`product`};function fye(e){return e.form??dye[UT(e)]}var WT=S([`duration`,`count`]),GT=x({value:n().min(0).nullable().meta(N(`device`)),kind:WT}),KT=x({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(N(`percentage`)),status:HT.nullable(),kind:BT.optional(),form:VT.optional(),lastResetAt:n().nullable(),resettable:y(),remaining:GT.optional()}),qT=x({items:C(KT),lastChangedAt:n()}),pye={items:[],lastChangedAt:0},mye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(E),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:KT,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:[...WT.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...HT.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...BT.options],defaultValue:`wear`},{path:`form`,values:[...VT.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},JT={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(E),methods:{reset:A(x({deviceId:n().int().nonnegative(),key:l().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:F(`Mark as replaced`,`Segna come sostituito`),phrase:F(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:F(`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:qT,kind:`push`,empty:pye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:KT,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:qT.extend({lastFetchedAt:n()}),durability:`restored`,customize:mye,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:F(`Consumables`,`Materiali di consumo`),order:2070}},YT=x({entryOpen:y(),lastChangedAt:n()}),XT={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:YT,kind:`push`},runtimeState:YT,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},ZT=S([`numeric`,`select`,`text`,`datetime`]),QT=x({kind:ZT,value:h([n().meta(N(`device`)),l()]),options:C(l()),lastChangedAt:n(),min:n().optional().meta(N(`device`)),max:n().optional().meta(N(`device`)),step:n().optional().meta(N(`device`))}),hye=i(`kind`,[x({kind:p(`numeric`),value:n()}),x({kind:p(`select`),value:l().min(1)}),x({kind:p(`text`),value:l()}),x({kind:p(`datetime`),value:l().min(1)})]),$T=x({deviceId:n().int().nonnegative(),cycle:y().default(!0)}),eE=x({deviceId:n().int().nonnegative()}),tE={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Control],methods:{setValue:A(x({deviceId:n().int().nonnegative(),control:hye}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`the value shape depends on the control kind (numeric / select / text / datetime) read from status; a typed picker for it is a follow-up of the automations rework`}),next:j($T,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:F(`Next option`,`Opzione successiva`),phrase:F(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:F(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:j($T,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:F(`Previous option`,`Opzione precedente`),phrase:F(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:F(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:j(eE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:F(`First option`,`Prima opzione`),phrase:F(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:j(eE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:F(`Last option`,`Ultima opzione`),phrase:F(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:QT,kind:`push`},runtimeState:QT,durability:`session`,history:`none`,vocabulary:{noun:F(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:F(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},B=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},nE=1024,rE=C(n().int()).min(2).max(nE).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]})})}),iE=x({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),gye=.241246,_ye=0;function aE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new B(`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 B(`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 B(`pronto-malformed`,`Pronto header incomplete`);if(r!==_ye)throw new B(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new B(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new B(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*gye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=rE.safeParse(l);if(!u.success)throw new B(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var vye=8192,oE=32,sE=3,yye=264,cE=nE*2;function bye(e){let t=[],n=0,r=e=>{if(t.length+e>cE)throw new B(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new B(`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 B(`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 B(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function xye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=oE){let r=Math.min(i+oE,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+sE<=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<=vye){let t=0;for(;a+t<e.length&&t<yye&&e[r+t]===e[a+t];)t++;t>=sE&&(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 lE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Sye=65535;function Cye(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+=lE[o>>18&63],t+=lE[o>>12&63],t+=n+1<e.length?lE[o>>6&63]:`=`,t+=n+2<e.length?lE[o&63]:`=`}return t}function wye(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new B(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=lE.indexOf(e);if(t<0)throw new B(`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 uE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Sye)throw new B(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),Cye(xye(t))}function dE(e){let t=bye(wye(e));if(t.length===0||t.length%2!=0)throw new B(`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=rE.safeParse(n);if(!r.success)throw new B(`tuya-malformed`,r.error.message);return r.data}var fE=S([`tuya`]),pE=Math.ceil((cE+Math.ceil(cE/32))/3)*4+256,mE=x({format:fE,code:l().min(1).max(pE)}),hE={tuya:{encode:uE,decode:dE}},gE=i(`kind`,[x({kind:p(`raw`),timings:C(n().int()),settings:iE.optional()}),x({kind:p(`pronto`),code:l()}),x({kind:p(`native`),format:fE,code:l()})]);function _E(e){if(e.kind===`pronto`){let t=aE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:hE[e.format].decode(e.code),settings:{}};let t=rE.safeParse(e.timings);if(!t.success)throw new B(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var vE=`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(`.`),yE=[`source_select`];function bE(e){return yE.includes(e)}var xE=`custom:`,Tye=/^[a-z0-9][a-z0-9_]{0,47}$/,Eye=new Set(vE);function SE(e){return Eye.has(e)}function CE(e){return Tye.test(e)}function wE(e){return`${xE}${e}`}function TE(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return CE(t)?t:null}function EE(e){return SE(e)||TE(e)!==null}var DE=l().refine(EE,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),OE=[`digits`,`sequence`,`ir`],Dye=S(OE),Oye=200,kye=16,Aye=6,jye=/^[a-z0-9][a-z0-9_-]{0,47}$/,Mye=RegExp(`^[0-9]{1,6}$`),kE={id:l().regex(jye,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},AE=x({...kE,kind:p(`digits`),number:l().regex(Mye,{message:`up to 6 digits`})}),jE=x({...kE,kind:p(`sequence`),steps:C(DE).min(1).max(16)}),ME=x({...kE,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:gE}),NE=i(`kind`,[AE,jE,ME]),Nye=500,Pye=100,PE=3e3;function FE(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function IE(e){try{return _E(e.payload),null}catch(e){if(e instanceof B)return e.message;throw e}}function Fye(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function LE(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function Iye(e,t){let n=e.find(e=>Fye(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?LE(e,t):r}var RE=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),zE=S([`off`,`all`,`one`]),Lye=x({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),BE=S([`reported`,`assumed`]),VE=S([`state`,`volumeLevel`,`isMuted`,`source`]),HE=x({state:RE,stateSource:BE.default(`reported`),assumedFields:C(VE).default([]),volumeLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:l(),availableSources:C(l()),declaredSources:C(x({name:l(),kind:S(OE),number:l().optional()})).optional(),currentMedia:Lye.nullable(),position:n().int().nonnegative().nullable().meta(N(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(N(`duration-ms`)),shuffle:y().nullable(),repeat:zE.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),Rye=50,UE=x({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),WE=x({deviceId:n().int().nonnegative()}),GE={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:j(WE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:F(`Turn on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:j(WE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:F(`Turn off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:F(`Volume up`,`Alza il volume`),phrase:F(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:F(`Volume down`,`Abbassa il volume`),phrase:F(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:F(`Channel up`,`Canale successivo`),phrase:F(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:F(`Channel down`,`Canale precedente`),phrase:F(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:F(`Play`,`Riproduci`),phrase:F(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:F(`Pause media`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:F(`Stop media`,`Ferma la riproduzione`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:F(`Next track`,`Brano successivo`),phrase:F(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:F(`Previous track`,`Brano precedente`),phrase:F(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:j(x({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:j(x({deviceId:n().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:F(`Mute`,`Silenzia`),phrase:F(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:F(`Unmute`,`Riattiva l’audio`),phrase:F(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:j(x({deviceId:n().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:F(`Shuffle on`,`Riproduzione casuale attiva`),phrase:F(`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:F(`Shuffle off`,`Riproduzione casuale spenta`),phrase:F(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:j(x({deviceId:n().int().nonnegative(),repeat:zE}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:F(`Set repeat`,`Imposta la ripetizione`),phrase:F(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:F(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Disattivata`)},{value:`all`,label:F(`All`,`Tutti i brani`)},{value:`one`,label:F(`One track`,`Un brano`)}]}}]}]}),selectSource:j(x({deviceId:n().int().nonnegative(),source:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:F(`Select source`,`Scegli la sorgente`),phrase:F(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:j(x({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:F(`Seek`,`Vai al punto`),phrase:F(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:j(x({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:F(`Play media`,`Riproduci un contenuto`),phrase:F(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:F(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:F(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:HE,kind:`push`},runtimeState:HE,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:F(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:F(`Playback`,`Riproduzione`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:F(`On`,`Acceso`),phrase:F(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`playing`,label:F(`Playing`,`In riproduzione`),phrase:F(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:F(`Paused`,`In pausa`),phrase:F(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:F(`Buffering`,`In caricamento`)},{value:`standby`,label:F(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:F(`the volume`,`il volume`),label:F(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:F(`Muted`,`Silenziato`),whenTrue:F(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:F(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},KE={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.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:[E.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:[E.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:[E.Camera,E.Light,E.Siren,E.Switch,E.Sensor,E.Climate,E.Button,E.EventEmitter,E.Update,E.Generic,E.Notifier,E.Script,E.Automation,E.Lock,E.Cover,E.Valve,E.Humidifier,E.WaterHeater,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Control,E.Presence,E.Weather,E.WeatherStation,E.Vacuum,E.LawnMower,E.Container,E.Image,E.PetFeeder,E.PetFountain,E.Dishwasher,E.Washer,E.Dryer,E.Gateway,E.HeatPump,E.EnergySystem,E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.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:[E.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:[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.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:{[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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`}]}},qE={"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 V(e,t,n){return{code:e,path:t,message:n}}function JE(...e){return{problems:e,fields:[],features:[],events:[]}}function YE(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var XE={kind:`fixed`,result:[`number`]},ZE={kind:`fixed`,result:[`boolean`]},QE=Object.freeze({min:XE,max:XE,abs:XE,floor:XE,ceil:XE,sqrt:XE,round:XE,pow:XE,clamp:XE,avg:XE,sum:XE,age:XE,convert:XE,coalesce:{kind:`coalesce`},any:ZE,all:ZE,within:ZE,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:XE,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),$E=class extends Error{};function eD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function tD(e){return new Set([e])}function nD(...e){return new Set(e.flatMap(e=>[...e]))}function zye(e){return new Set([...e].filter(e=>e!==`null`))}function Bye(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?tD(`string`):e.every(e=>e===`number`)?tD(`number`):new Set([`number`,`string`])}return tD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function Vye(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function Hye(e,t){let n=Go[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new $E(`${e}: wrong number of arguments (${t.length}); expected ${Vye(n)}`);let r=QE[e];if(r===void 0)throw new $E(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=nD(...t.map(zye));return t.every(e=>e.has(`null`))?nD(i,tD(`null`)):i}function rD(e,t){switch(e.kind){case`literal`:return tD(eD(e.value));case`identifier`:{if(e.name===`now`)return tD(`number`);let n=t.get(e.name);if(n===void 0)throw new $E(`unbound identifier '${e.name}'`);return n}case`unary`:return tD(e.op===`!`?`boolean`:`number`);case`binary`:return Bye(e.op,rD(e.left,t),rD(e.right,t));case`logical`:return nD(rD(e.left,t),rD(e.right,t));case`conditional`:return nD(rD(e.consequent,t),rD(e.alternate,t));case`call`:return Hye(e.callee,e.args.map(e=>rD(e,t)))}}function iD(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return iD(e.operand,t);case`binary`:case`logical`:return iD(e.left,t)||iD(e.right,t);case`conditional`:return iD(e.test,t)||iD(e.consequent,t)||iD(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>iD(e,t))}}function aD(e,t){let n=ns(e);return n.ok&&iD(n.parsed.ast,t)}function oD(e){let t=ns(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:rD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof $E)return{ok:!1,error:e.message};throw e}}function Uye(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function Wye(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 sD(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=cT(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 cD(e,t,n){return V(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function lD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function uD(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=cT(a,e.fieldPath),s=lD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function dD(e,t){if(e.kind===`from`)return sD(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return Wye(e);if(e.kind===`series`)return Uye(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([eD(i.value)]));continue}let e=sD(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=oD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function fD(e,t,n,r){let i=lD(t);if(i===null)return[cD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(V(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(V(`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 Gye(e){if(e.kind!==`expression`)return null;let t=ns(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function pD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=Gye(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return V(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function mD(e){if(e.kind!==`expression`)return`derived`;if(aD(e.expr,`count`))return`accumulator`;if(sl(e).length>0)return`derived`;let t=ns(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function hD(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:V(`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 gD={resettable:!1};function Kye(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(gD)])}function qye(e,t,n){let r=cT(e.itemSchema,t);return r===null||!r.required?!1:dT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function Jye({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Ng(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!qye(t,o.path,a))return[];let s=cT(t.itemSchema,o.path);return s===null||s.nullable?[]:[V(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Yye(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 JE(V(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=cT(r.itemSchema,c);if(d===null)return JE(V(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return JE(cD(n,c,u));let f=dD(l,a);if(!f.ok)return JE(V(f.code,u,f.message));let p=mD(l),m=hD(d,p,e.mode,n,u);if(!m.ok)return JE(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:[...sl(l)]},g=pD(n,d,l,u);return{problems:[...fD(n,d,uD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function _D(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return JE(V(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return JE(V(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${Wc}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Kye(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:Jye(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Yye(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 vD=`deviceId`;function yD(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 bD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Xc(e)?yD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[nl(e),e])).values()]}function Xye(e,t){return e.name===`switch`&&t===`toggle`}function xD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Xye(e,t)).map(([e])=>e)}function Zye(){return Object.fromEntries(xD(GE).map(e=>[e,{kind:`extension`,target:`remote`}]))}var SD={all:new Set,required:new Set};function CD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=Mg(n);if(!(r instanceof ce))return null;let i=Object.entries(r.shape).filter(([e])=>e!==vD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]))}}function wD(e){return typeof e==`object`?zc(e)?[e.$input]:Object.values(e).flatMap(wD):[]}function TD(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function Qye(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[V(`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:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function $ye(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(V(`command-input-unknown`,`${i}.args.${vD}`,`\`${vD}\` 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(V(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${TD(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(V(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${TD(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:SD;if(c!==null)for(let t of Object.values(r).flatMap(wD))c.all.has(t)||s.push(V(`command-input-unknown`,`${i}.args`,c===SD?`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 ${TD(c.all)})`));return s}function ebe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:SD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(V(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${TD(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(V(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${TD(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function ED(e,t,n){let r=Qye(t,n);if(r.def===null)return r.problems;let i=CD(e,t.method),a=CD(r.def,t.command.method),o=t.command.args;return o===void 0?ebe(t,i,a):$ye(t,i,a,o)}function DD(e,t,n){let r=new Set(xD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[V(`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 OD(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Xc(e)?[]:yD(e,n).flatMap(e=>{let n=nl(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[V(`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`?[V(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[V(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var kD={fieldPath:`lastFetchedAt`,expr:`now`},AD={fieldPath:`lastChangedAt`,expr:`now`};function jD(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:Ki(e.quantity),aggregates:$s,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var MD=[E.Climate];function ND(e){return{...e,family:`binary`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:ec,empty:`offline`}}var PD=[jD({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:O.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[kD],alsoFrom:{deviceTypes:MD,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),jD({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[kD],alsoFrom:{deviceTypes:MD,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),jD({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:O.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),jD({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:O.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),jD({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:O.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[kD]}),jD({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:O.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[kD]}),jD({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),jD({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:O.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),ND({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:O.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),ND({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:O.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[AD]}),ND({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:O.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[AD]}),ND({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:O.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[AD]}),ND({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:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[AD]}),ND({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[AD]}),FD({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:E.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),FD({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:E.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),FD({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:E.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),FD({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:E.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),FD({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:E.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),FD({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:E.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),FD({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:E.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),FD({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:E.Climate,memberDeviceTypes:[E.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 FD(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:ec,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[AD]}}var tbe=new Map(PD.map(e=>[e.id,e]));function ID(e){return tbe.get(e)??null}var LD={"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:[E.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`}}},nbe={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`}}}},RD={"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}},rbe=`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 zD(e){return LD[e]??{}}function ibe(e,t,n){return BD(e.deviceTypes,t,n)}function BD(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Co(t,n)&&e.includes(E.Light)}function abe(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 VD(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:HD(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function HD(e){let t=[];for(let n of Object.keys(LD))for(let[r,i]of Object.entries(zD(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function obe(e){if(e===`derivative`)return{...VD(`statistic`),accept:UD()};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:UD(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function UD(){return HD(`statistic`).filter(e=>e.valueKind===`number`)}var WD=[`switch`,`brightness`,`color`],sbe=[D.LightColorRgb,D.LightColorHsv,D.LightColorMired],cbe=4;function GD(e){return e===`all`?`all`:`any`}function lbe(e){return e===`all`?`all`:`at-least-one`}function ube(e){return e.length===0?[]:WD.filter(t=>e.every(e=>e.includes(t)))}function dbe(e){return e.length===0?[]:sbe.filter(t=>e.every(e=>e.includes(t)))}function fbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function pbe(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 mbe={kind:`expression`,expr:`now`,bindings:{}};function KD(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function hbe(e){return{included:KD(e,`included`,`offline`),excluded:KD(e,`excluded`,`offline`),total:KD(e,`total`,`offline`)}}var gbe={second:`s`,minute:`min`,hour:`h`};function _be(e){let t=zD(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${gbe[e.per]}`}function qD(e){let t=zD(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function JD(e){return qD(e)===null?[V(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function YD(e){return{target:{kind:`new`,type:E.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:KD(e.member,`value`,e.empty),lastFetchedAt:mbe}},{kind:`fields`,cap:`group-status`,fields:hbe(e.member)}]}}function XD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source);r===`enum`&&n.push(V(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(V(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=Ys(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:YD({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function ZD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source);(r===`enum`||r===`boolean`)&&n.push(V(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=Ys(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:YD({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function QD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(V(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(V(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(V(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=Xs(e.reset,t);a.ok||n.push(V(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:YD({role:o?O.EnergySensor:O.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var vbe=/^\d+(?:\.\d+)?$/,ybe=/^-?\d+(?:\.\d+)?$/,bbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,xbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Sbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,Cbe=/^[A-Za-z_][A-Za-z0-9_]*$/;function $D(e){return lO(e,vbe)}function eO(e){return lO(e,ybe)}function tO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?eO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function nO(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 rO(e){return Cbe.test(e)}function iO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function aO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function oO(e){let t=bbe.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 sO(e){let t=xbe.exec(e);if(t!==null)return uO(t[1],t[2],t[3],t[4],t[5]);let n=Sbe.exec(e);return n===null?null:uO(n[1],n[2],n[3],void 0,void 0)}function cO(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 lO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function uO(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 dO={kind:`expression`,expr:`now`,bindings:{}};function fO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function pO(e,t){return{kind:`expression`,expr:e,bindings:t}}function wbe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function mO(e,t,n=[]){return{target:{kind:`new`,type:E.Sensor,role:O.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:dO}},...n]}}function hO(e,t){return{target:{kind:`new`,type:E.Sensor,role:O.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:dO}}]}}function gO(e){let t=[],n=eO(e.high),r=eO(e.low);n===null&&t.push(V(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(V(`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=$D(e.onForMs),a=$D(e.offForMs);(i===null||a===null)&&t.push(V(`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:hO(e,pO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:fO(e.source)}))}}var Tbe=[`a`,`b`];function Ebe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(V(`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(V(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>wbe(e,n))&&t.push(V(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var Dbe=[`included`,`excluded`,`total`];function _O(e){let t=Ebe(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(Dbe.map(e=>[e,r(e)]));return{problems:t,draft:mO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[Tbe[t]??`a`,fO(e)]));return{problems:t,draft:mO(e,pO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Obe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;rO(e.name)||t.push(V(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(V(`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,fO(e.member)])),i=fs({expr:e.expr,bindings:r});return i===null?[]:[V(`expression-invalid`,`helper.expr`,i)]}function vO(e){let t=Obe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,fO(e.member)])),r=pO(e.expr,n);return{problems:t,draft:e.output===`boolean`?hO(e,r):mO(e,r)}}function kbe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Abe(e,t){return kbe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function jbe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Mbe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!jbe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(V(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Abe(e,n))&&a.push(V(`member-constraint`,i,`this member is already in the group`)),a})}function yO(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 Nbe(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,Fbe(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]:yO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:yO(e,t,n,`included`),excluded:yO(e,t,n,`excluded`),total:yO(e,t,n,`total`)}}]}}function Pbe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[V(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=GD(t.active);return t.aggregate===n?[]:[V(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[V(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function bO(e){let t=tl.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[V(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function Fbe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function xO(e,t=Ns){switch(e.kind){case`group`:return Lbe(e);case`statistic`:{let n=XD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`integral`:{let n=QD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`derivative`:{let n=ZD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`threshold`:return SO(gO(e));case`arithmetic`:return SO(_O(e));case`expression`:return SO(vO(e));case`grid`:case`terminal`:return bO(Ibe(e))}}function Ibe(e){return{target:{kind:`new`,type:E.Camera},helper:e,features:[]}}function SO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:bO(e.draft)}function Lbe(e){let t=ID(e.templateId);if(t===null)return{ok:!1,problems:[V(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=Pbe(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:[V(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Mbe(t,e);return r.length>0?{ok:!1,problems:r}:bO(Nbe(t,e))}function CO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function Rbe(e){return e.kind===`group`?ID(e.templateId)?.memberDeviceType??null:null}function zbe(e,t){if(e.kind!==`group`)return[];let n=ID(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(nl(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[V(`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?[]:[V(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function Bbe(e,t){if(e.kind!==`group`)return[];let n=ID(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(nl(e.source)),a=i?.deviceType;return a===void 0||BD(n.memberDeviceTypes,a,i?.role)?[]:[V(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function wO(e,t){let n=e.helper;if(n===void 0)return[];let r=xO(n);return r.ok?CO(e,r.composition)?n.kind===`arithmetic`?Vbe(n,t):n.kind===`group`?[...zbe(n,t),...Bbe(n,t)]:[]:[V(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function Vbe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(nl(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[V(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var TO=class extends Error{};function Hbe(e){return new Set(e.composition.features.flatMap(e=>!Xc(e)||e.kind!==`fields`?[]:ll(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function Ube(e,t,n){if(nl(n.source)!==nl(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function Wbe(e){let t=Hbe(e);return e.composition.features.flatMap(n=>!Xc(n)||n.kind!==`fields`?[]:ll(n).map(({fieldPath:r,source:i})=>[il({source:e.target,cap:n.cap,fieldPath:r}),sl(i).filter(n=>Ube(e,t,n)).map(il)]))}function Gbe(e,t){let n=nl(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=nl(i.target);if(t===n)throw new TO(`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 TO(`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 EO(e,t){let n=Gbe(e,t).flatMap(Wbe);return new Map(n)}function Kbe(e,t){let n=EO(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 qbe(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 Jbe(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 DO(e,t){let n=EO(e,t),r=`${nl(e.target)}#`;return qbe(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:Jbe(t,i,n),component:i}]})}var Ybe=3,Xbe=120,Zbe=10,OO=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),kO=i(`accepted`,[x({accepted:p(!0)}),x({accepted:p(!1),reason:OO,message:l()})]),AO=x({linked:y(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),switchSettable:y().nullable().optional(),restartInProgress:y(),offSeconds:n().int()}),jO=x({switchOn:y().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),MO=[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.WaterHeater],Qbe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:MO,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`}}]},NO=x({deviceId:n().int().nonnegative()}),PO={method:`getStatus`,field:`switchSettable`},FO={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:MO,methods:{getStatus:Ir(NO,AO,{auth:`protected`}),powerOn:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:F(`Power on`,`Dai corrente`),phrase:F(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:PO}]}),powerOff:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:F(`Power off`,`Togli corrente`),phrase:F(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:PO}]}),forceRestart:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:F(`Force restart`,`Riavvio forzato`),phrase:F(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:jO,customize:Qbe,durability:`session`,history:`none`,vocabulary:{noun:F(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:F(`Power switch on`,`Presa accesa`),whenTrue:F(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:F(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function IO(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function $be(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 exe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=ol(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=sl(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:IO($be(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var LO=`switch`;function txe(e){let t=new Set;return e.target.kind===`existing`&&t.add(nl(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==LO)&&Xc(e)){for(let n of ul(e))for(let e of sl(n))t.add(nl(e.source));for(let r of yD(e,n))t.add(nl(r.command.source))}}),t}function RO(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=txe(e);return sl(r).filter(e=>e.cap===LO&&i.has(nl(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function zO(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var BO=new Set([`device-status`,`feature-probe`]),nxe={addonId:Tc,stableId:`${we}(unsaved)`},rxe=`(unsaved)`;function ixe(e,t,n){let r=n(e.cap);if(r===null)return V(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(BO.has(r.name))return V(`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?V(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:lT(i)}}function axe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=ID(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function oxe(e,t){return e.name===GE.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function sxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(V(`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=xD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(V(`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=oxe(e,r);for(let a of d?[]:uT(t))a!==u&&(n.has(a)?a in r.fields||s.push(V(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(V(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function cxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?cT(t,n)??void 0:`nested`:e.get(n)}function lxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=cxe(e,o,n);if(l===`nested`)return JE(V(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return JE(V(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return JE(cD(i.name,o,c));let u=dD(s,r);if(!u.ok)return JE(V(u.code,c,u.message));let d=mD(s),f=hD(l,d,n,i.name,c);if(!f.ok)return JE(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:[...sl(s)]},h=pD(i.name,l,s,c);return{problems:[...fD(i.name,l,uD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function uxe(e,t,n,r,i){let a=`features[${n}]`,o=yD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>V(`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!==GE.name?[...s,...c.map(([t])=>V(`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,V(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...DD(e,t,a),...o.flatMap(t=>ED(e,t,i))]}function VO(e,t,n,r,i){let a=`features[${t}]`,o=ixe(e,a,r);if(`code`in o)return JE(o);let s=n.mode===`replace`?[]:[...sxe(o,e,a,n.deviceType,i)];s.push(...uxe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>lxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[_D(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=hT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function HO(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function dxe(e){return`code`in e}function fxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=nl(e.target.device);return t===void 0?V(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?V(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?V(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var pxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function mxe(e,t){let n=t.problems.filter(e=>pxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:JE(e)}var hxe=KE;function gxe(e){let t=hxe[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 _xe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:HO(e.found,r)?gxe(t)?{mode:`replace`,deviceType:e.found.type}:V(`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 UO(e,t,n){let r=fxe(e,n);if(`code`in r)return JE(r);let i=axe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return JE(V(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=_xe(r,e,a);if(dxe(o))return!Xc(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:mxe(o,VO(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=VO(e,n,o,t,i);return Xc(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 vxe(e){let t=e.features.flatMap(e=>Xc(e)&&e.kind===`fields`?ul(e).flatMap(sl).map(e=>e.source):[]);return[...new Map([...t,...bD(e)].map(e=>[nl(e),e])).values()]}function yxe(e,t){return e.features.flatMap(e=>Xc(e)&&e.kind===`fields`?ul(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:cT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function bxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??nxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:WO(n)}}function WO(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(CT))}function xxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>CT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[V(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:HO(r.native,e.cap)?[]:[V(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Sxe(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?[]:[V(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Cxe(e,t,n){let r=nl(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=YE(i),s=nl(a.source);if(s===r)return xxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[V(`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`?[V(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Sxe(i,a,c,o):[V(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function wxe(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 Txe(e,t,n){for(let r of e){let e=wxe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>CT(e)===i);if(a!==void 0)return YE(a)}return`features`}function Exe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function Dxe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=nl(i.target),o=t.unreadTargets??new Map;try{return DO(i,t.peers).map(e=>{let t=Txe(e.path,a,n),r=Exe([...e.component],o);return r===null?V(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):V(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof TO)return[V(`duplicate-target`,`features`,e.message)];throw e}}function GO(e,t){let n=UO(e,t.lookupCap,t.target??void 0),r=bxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=Dxe(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,...Cxe(n.fields,t,r),...OD(e,t.sources),...a,...wO(e,o),...RO(e).map(e=>V(`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 KO=x({path:l(),kind:vT,nullable:y(),required:y(),enumValues:C(l()).optional()}),qO=x({cap:l(),fields:C(KO),itemArray:x({path:l(),keyField:l()}).optional()}),JO=x({caps:C(qO)});function YO(e,t){if(BO.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=lT(n),a=e.status?.itemArray?.path??null;return uT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),hT(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 Oxe(e,t){return e.filter(e=>YO(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...lT(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 XO=x({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),kxe=x({kind:p(`identity`)}),Axe=x({kind:p(`invert`)}),ZO=x({kind:p(`threshold`),comparison:S([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),QO=i(`kind`,[kxe,Axe,ZO,x({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),x({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),x({kind:p(`number`)})]),jxe=x({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:XO,transform:QO}),Mxe=x({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:XO,transform:QO}),Nxe=x({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:y(),debounceMs:n().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(XO).min(1)}),Pxe=XO.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),Fxe=i(`kind`,[jxe,Mxe,Nxe,x({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:C(Pxe)})]),Ixe=x({targetId:l().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),$O=S([`raw`,`5m`]),ek=S([`high`,`medium`,`low`]),tk=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),nk=x({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),rk=x({tier:$O,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:nk}),ik=x({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),ak=i(`state`,[x({state:p(`proposal`),transform:ZO,evidence:rk,confidence:ek,notes:C(l())}),x({state:p(`insufficient`),reason:tk,evidence:ik,fallback:ZO})]),ok=x({apply:y()}),sk=x({apply:y(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:y()}),ck=`core-block-`,lk=`core-blocks`;function Lxe(e){return`${ck}${e}`}function Rxe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var uk=h([p(`hub`),l().min(1)]),dk=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),fk=`main.ts`,pk=m(l().min(1).max(260),l().max(2e5)),mk=ve(),hk=x({name:l().min(1).max(120),code:l().max(2e5).optional(),files:pk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:uk,integrationId:l().optional(),settingsSchema:mk.optional(),tags:Eh.optional()}),gk=hk.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 _k(e){return e!==void 0&&e.length>0?e:fk}function zxe(e){let t=_k(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function Bxe(e){if(e.files!==void 0){let t=_k(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 vk=i(`kind`,[x({kind:p(`code`)}),x({kind:p(`recipe`),recipe:vv}),x({kind:p(`composition`),composition:tl})]),yk=x({name:l().min(1).max(120).optional(),enabled:y(),composition:tl}),bk=x({name:l().min(1).max(120),code:l().max(2e5),files:pk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:uk,integrationId:l().optional(),settingsSchema:mk.optional(),tags:Eh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:dk,lastError:l().optional(),lastChangedAt:n(),source:vk.optional()});function Vxe(e){return e.source?.kind??`code`}function Hxe(e){return e.source?.kind===`composition`?e.source.composition:null}var xk=i(`kind`,[x({kind:p(`answered`),state:AT.nullable()}),x({kind:p(`unreachable`),error:l()})]),Sk=x({block:bk,state:xk}),Ck=x({state:p(`not-loaded`),reason:l()}),wk=i(`state`,[x({state:p(`loaded`),views:C(Sk)}),Ck]),Tk=i(`state`,[x({state:p(`loaded`),view:Sk.nullable()}),Ck]),Ek=i(`state`,[x({state:p(`loaded`),view:Sk.nullable()}),Ck]),Dk=x({ok:y(),error:l().optional(),line:n().optional(),column:n().optional()}),Ok=x({code:l().optional(),files:pk.optional(),entry:l().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`]})}),kk={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),x({blocks:C(bk)}),{auth:`admin`}),get:A(x({blockId:l()}),x({block:bk.nullable()}),{auth:`admin`}),create:A(x({block:gk}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:A(x({blockId:l(),block:hk.partial()}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:A(x({blockId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({blockId:l(),enabled:y()}),x({block:bk}),{kind:`mutation`,auth:`admin`}),restart:A(x({blockId:l()}),x({block:bk}),{kind:`mutation`,auth:`admin`}),compile:A(Ok,Dk,{kind:`mutation`,auth:`admin`}),getBlockSettings:A(x({blockId:l()}),Ax.nullable(),{auth:`admin`}),updateBlockSettings:A(x({blockId:l(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:A(ok,sk,{kind:`mutation`,auth:`admin`}),getTypeDefs:A(x({}),x({libs:C(x({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:A(x({block:yk}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:A(x({blockId:l(),expectedUpdatedAt:n(),block:yk.partial()}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:A(x({blockId:l()}),Tk,{auth:`admin`}),listCompositions:A(x({}),wk,{auth:`admin`}),getCustomization:A(x({addonId:l().min(1),stableId:l().min(1)}),Ek,{auth:`admin`}),listComposableCaps:A(x({deviceType:S(E)}),JO,{auth:`admin`}),validateComposition:A(x({composition:tl,blockId:l().optional()}),ET,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:A(x({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:S(E).optional()}),ak,{auth:`admin`,access:`view`}),reportAutomationRun:A(x({blockId:l().min(1),trace:ny.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:A(x({blockId:l().min(1)}),ry,{auth:`admin`}),getTraces:A(x({blockId:l().min(1)}),x({traces:C(ny),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Ak=S([`open`,`opening`,`closing`,`closed`,`stopped`]),jk=x({state:Ak,position:n().min(0).max(100).nullable().meta(N(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(N(`percentage`)),lastChangedAt:n()}),Mk={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover],methods:{open:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:F(`Open`,`Apri`),phrase:F(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:F(`Close`,`Chiudi`),phrase:F(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:j(x({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:F(`Set position`,`Imposta la posizione`),phrase:F(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:j(x({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:F(`Set tilt`,`Imposta l’inclinazione`),phrase:F(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:F(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:jk,kind:`push`},runtimeState:jk,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:F(`State`,`Stato`),values:[{value:`open`,label:F(`Open`,`Aperto`),phrase:F(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:F(`Opening`,`In apertura`),phrase:F(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:F(`Closing`,`In chiusura`),phrase:F(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:F(`Closed`,`Chiuso`),phrase:F(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:F(`Stopped`,`Fermo`),phrase:F(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:F(`the opening`,`l’apertura`),label:F(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[O.CoverGarage]:{actions:{"cover.open":{phrase:F(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:F(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[O.CoverGate]:{actions:{"cover.open":{phrase:F(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:F(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[O.CoverDoor]:{actions:{"cover.open":{phrase:F(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:F(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[O.CoverWindow]:{actions:{"cover.open":{phrase:F(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:F(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[O.CoverShutter]:{actions:{"cover.open":{phrase:F(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:F(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[O.CoverAwning]:{actions:{"cover.open":{phrase:F(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:F(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},Nk=x({stepId:l(),entry:Vh}),Pk=x({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),Fk=x({addonId:l(),stepId:l().min(1),entries:C(Vh).min(1).max(4),bundle:x({ticket:ri,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:C(Pk).min(1).max(64),distribute:y()}),Ik=i(`kind`,[x({kind:p(`imported`),modelIds:C(l()).readonly(),distributed:C(x({modelId:l(),nodeId:l(),format:S(va),ok:y(),error:l().optional()})).readonly()}),x({kind:p(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),Lk={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:A(v(),C(Nk).readonly(),{auth:`admin`}),importModelBundle:A(Fk,Ik,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:M.ML}},Rk=x({engineId:l(),kind:S([`relational`,`vector`]),displayName:l()}),zk={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:A(v(),Rk,{auth:`admin`}),get:A(x({namespace:l().optional(),collection:l(),key:l()}),w(),{auth:`admin`}),set:A(x({namespace:l().optional(),collection:l(),key:l(),value:w()}),v(),{kind:`mutation`,auth:`admin`}),query:A(x({namespace:l().optional(),collection:l(),filter:Ld.optional(),columns:C(l()).readonly().optional()}),C(Vd).readonly(),{auth:`admin`}),insert:A(x({namespace:l().optional(),collection:l(),record:x({id:l().optional(),data:m(l(),w())})}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),record:Hd}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),records:C(Hd).readonly()}),x({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:A(x({namespace:l().optional(),collection:l(),records:C(Hd).readonly()}),x({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:A(x({namespace:l().optional(),guard:Gd.optional(),ops:C(Wd).readonly()}),x({applied:y(),current:w().optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({namespace:l().optional(),collection:l(),id:l(),data:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),delete:A(x({namespace:l().optional(),collection:l(),key:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:A(x({namespace:l().optional(),collection:l(),filter:Rd}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:A(x({namespace:l().optional(),collection:l(),filter:Rd,data:m(l(),w())}),x({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:A(x({namespace:l().optional(),collection:l(),filter:Ld.optional()}),n(),{auth:`admin`}),aggregate:A(x({namespace:l().optional(),collection:l(),fields:C(zd).readonly(),filter:Ld.optional()}),Bd,{auth:`admin`}),histogram:A(x({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:Ld.optional()}),C(x({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:A(x({namespace:l().optional(),collection:l()}),y(),{auth:`admin`}),declareCollection:A(Jd,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Bk=S([`auto`,`day`,`night`,`schedule`]),Vk=x({min:n(),max:n(),step:n()}),Hk=x({mode:Bk,sensitivity:n().optional().meta(N(`none`)),switchDelaySec:n().optional().meta(N(`duration`)),lastFetchedAt:n()}),Uk=x({modes:C(Bk),supportsSensitivity:y(),sensitivity:Vk.optional(),supportsSwitchDelay:y(),switchDelaySec:Vk.optional()}),Wk=x({mode:Bk.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),Gk={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),Uk),setSettings:A(x({deviceId:n(),settings:Wk}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:F(`Day/night auto`,`Giorno/notte automatico`),phrase:F(`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:F(`Day mode`,`Modalità giorno`),phrase:F(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:F(`Night mode`,`Modalità notte`),phrase:F(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:Hk,kind:`poll`},runtimeState:Hk,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:F(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:F(`Automatic`,`Automatica`)},{value:`day`,label:F(`Day`,`Giorno`),phrase:F(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:F(`Night`,`Notte`),phrase:F(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:F(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},Uxe=[{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)`}],Wxe={hwaccel:`auto`,probedBestHwaccel:``},Kk={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:A(v(),x({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},qk={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},Jk=S([`device`,`integration`]),Yk=x({url:l(),label:l(),target:Jk,host:l()}),Xk={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:A(x({deviceId:n().int().nonnegative()}),Yk.nullable(),{auth:`admin`})},vocabulary:{noun:F(`Admin link`,`Link di amministrazione`),order:3090}},Zk=S([`online`,`sleeping`,`offline`,`unknown`]),Qk=a(()=>x({childNativeId:l(),name:l(),type:S(E),status:Zk,metadata:x({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:C(l()).readonly().optional(),features:C(l()).readonly().optional(),sourceInfo:Pg.optional(),children:C(Qk).readonly().optional(),parentStableId:l().optional()})),$k=x({id:l(),label:l(),isDefault:y().optional()}),eA=x({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),tA=x({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:eA.optional()}),nA=x({candidates:C(Qk).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),rA=x({integrationId:l(),childNativeId:l()}),iA=x({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),Gxe=x({name:l().min(1).optional(),hiddenChildIds:C(l()).optional()}),aA=x({integrationId:l(),childNativeIds:C(l()).min(1),filter:l().optional(),importLocations:y().optional(),perCandidate:m(l(),Gxe).optional()}),oA=x({adopted:C(x({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:C(n().int().nonnegative()).readonly()})).readonly()}),sA=x({integrationId:l(),camDeviceId:n().int().nonnegative()}),cA=x({camDeviceId:n().int().nonnegative(),resetToSource:y().optional()}),lA=x({changed:y(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),uA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:iA,kind:`poll`},methods:{listCandidateFilters:A(x({integrationId:l()}),x({filters:C($k)}),{auth:`admin`}),listCandidates:A(tA,nA,{auth:`admin`}),getCandidate:A(rA,Qk.nullable(),{auth:`admin`}),refresh:A(x({integrationId:l()}),iA,{kind:`mutation`,auth:`admin`}),adopt:A(aA,oA,{kind:`mutation`,auth:`admin`}),release:A(sA,v(),{kind:`mutation`,auth:`admin`}),resync:A(cA,lA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},dA=i(`state`,[x({state:p(`absent`)}),x({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),x({state:p(`unavailable`),reason:l()})]),fA=x({selfEnrollment:S([`allowed`,`disabled`])}),pA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:A(x({userId:l().min(1).optional(),includeRevoked:y().default(!1)}),C(xpe).readonly(),{auth:`admin`}),startEnrollment:A(x({userId:l().min(1),deviceName:l().min(1).max(80)}),Spe,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:A(x({id:l().min(1)}),x({revoked:y(),sessionsEnded:n().int(),status:cg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:A(x({}),fA,{auth:`admin`}),setDeviceCertificateSettings:A(fA,fA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:A(x({id:l().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:A(x({}),dA,{auth:`admin`}),renameDeviceCredential:A(x({id:l().min(1),deviceName:l().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},Kxe=64,mA=/^[a-z][a-z0-9_]*$/,qxe=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(`.`)),hA=l().max(64).regex(mA);function gA(e){return qxe.has(e)}function _A(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 Jxe(e,t){let n=_A(e);if(!gA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function Yxe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:mA.test(e)?gA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var vA=4096,Xxe=50,Zxe=4096,Qxe=`—`,yA=l().min(1).max(vA),$xe=`now`,eSe=`camera`,bA=h([l(),n(),y()]),xA=x({deviceId:n().int(),values:m(l().min(1).max(64),bA).optional()}),tSe=`values`,nSe=Il(),SA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],CA=x({reason:S(SA),message:l()}),wA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],TA=x({ref:l(),reason:S(wA)}),EA=i(`ok`,[x({ok:p(!0),text:l(),trace:C(TA)}),x({ok:p(!1),refusal:CA,trace:C(TA)})]);function DA(e){return e.replace(/-/g,`_`)}function OA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(OA(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function rSe(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||DA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=kA(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 OA(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=kA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var AA=x({zoneKey:l(),label:l(),icon:xh.nullable(),locationKeys:C(l())});function iSe(e){return e.trim().toLowerCase()}var jA=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],MA=S(jA),NA=S([`read`,`derived`]),aSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,PA=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,FA=/^[0-9a-f][0-9a-f-]{7,}$/,IA=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function LA(e){return x({value:e,origin:NA,readAt:n().int().nonnegative()}).strict()}var oSe=LA(l().regex(aSe)),sSe=LA(l().regex(PA)),cSe=LA(l().regex(FA)),lSe=LA(l().regex(PA)),uSe=LA(l().regex(IA)),dSe=LA(h([_(),o()])),fSe=x({value:l().min(1),origin:NA,readAt:n().int().nonnegative()}).strict(),RA=x({mac:C(oSe).min(1).readonly().optional(),serial:sSe.optional(),"machine-uuid":cSe.optional(),"vendor-uid":lSe.optional(),hostname:uSe.optional(),ip:dSe.optional()}).strict(),pSe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function mSe(e){return pSe[e]}function zA(e){return jA.every(t=>e[t]===void 0)}var hSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,gSe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function BA(e){return{ok:!1,reason:e}}function VA(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return BA(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return gSe.has(n)?BA(`placeholder MAC`):{ok:!0,value:n}}function _Se(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function HA(e,t,n){let r=_Se(e);if(r.length===0)return BA(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?BA(`blank value`):hSe.test(i)?BA(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function vSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return FA.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?BA(`placeholder uuid`):{ok:!0,value:t}:BA(`not a uuid`)}function UA(e){return h([_(),o()]).safeParse(e).success}function ySe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return BA(`blank hostname`);if(UA(t))return BA(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return IA.test(n)?n===`localhost`?BA(`placeholder hostname`):{ok:!0,value:n}:BA(`not a hostname`)}function bSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return UA(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?BA(`loopback or unspecified address`):{ok:!0,value:t}:BA(`not an IP address`)}function WA(e){return e==null||e.trim().length===0}function GA(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(WA(e))continue;let t=o(`mac`,e,VA(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||WA(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,HA(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||WA(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,HA(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=WA(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,vSe(e.machineUuid)),f=WA(e.host)?null:e.host.trim(),p=f!==null&&UA(f.toLowerCase().replace(/^\[|\]$/g,``)),m=WA(e.hostname)?p?null:f:e.hostname,h=WA(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,ySe(m)),_=h===null?void 0:o(`ip`,h,bSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function KA(e,t){return e.value===t.value&&e.origin===t.origin}function qA(e,t){return t!==void 0&&KA(e,t)?t:e}function xSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>qA(e,r.mac?.find(t=>KA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:qA(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 zA(p)?null:p}function SSe(e,t){let n=e=>e==null||zA(e)?``:JSON.stringify(jA.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 JA=S([`auto`,`proposal`]),YA=x({key:MA,value:l()}),XA=x({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),ZA=x({a:XA,b:XA,keys:C(YA).readonly(),confidence:JA}),QA=i(`status`,[x({status:p(`unknown`),reason:l()}),x({status:p(`answered`),pairs:C(ZA).readonly(),undeclaredDeviceIds:C(n().int()).readonly()})]),$A=[`same-device`,`poe-power`],ej=S($A),tj=S([`proposed`,`linked`,`dismissed`]),nj=S([`auto`,`operator`]),rj=x({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),ij=x({kind:ej,a:rj,b:rj,state:tj,origin:nj,evidence:C(YA).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),aj=ij.extend({id:l().min(1)}),oj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:O.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function CSe(e,t){let n=oj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function sj(e){return`${e.addonId}/${e.stableId}`}function wSe(e,t,n){let r=sj(t),i=sj(n);return oj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var cj=i(`status`,[x({status:p(`not-loaded`),reason:l()}),x({status:p(`answered`),links:C(aj).readonly()})]),lj=S([`not-loaded`,`unknown-link`,`wrong-state`]),uj=i(`ok`,[x({ok:p(!0),link:aj}),x({ok:p(!1),reason:lj,message:l()})]),dj=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),TSe=x({linkId:l(),kind:ej,aDeviceId:n().int(),bDeviceId:n().int(),origin:nj,reason:dj.optional()}),ESe=50,DSe=200,fj=x({caps:C(l()).readonly().optional(),actions:C(l()).readonly().optional(),mode:S([`any`,`all`]).optional()}),pj=x({locations:C(l()).readonly().optional(),integrationIds:C(l()).readonly().optional(),types:C(l()).readonly().optional()}),mj=x({text:l().optional(),requires:fj.optional(),filters:pj.optional(),includeIncompatible:y().optional(),contextDeviceId:n().optional(),ids:C(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),hj=x({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:Ui.optional()}),gj=x({id:n(),name:l(),type:S(E),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(hj).readonly()}),_j=x({value:l(),count:n()}),vj=x({id:l(),label:l(),count:n()}),yj=x({locations:C(_j).readonly(),integrations:C(vj).readonly(),types:C(_j).readonly()}),bj=x({items:C(gj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:yj,suggested:C(gj).readonly(),missingIds:C(n()).readonly()}),xj=x({connected:y(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),OSe=x({externalId:l(),name:l(),type:l(),metadata:m(l(),w()).optional()}),Sj=i(`kind`,[x({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),x({kind:p(`ws-discovery`),types:C(l()).optional()}),x({kind:p(`ssdp`),searchTarget:l().min(1)}),x({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),x({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:y().default(!1),acceptStatus:C(n().int()).optional()}),x({kind:p(`custom`),reason:l().min(1)})]),Cj=x({modeIndex:n().int().min(0),host:l(),port:n().int(),http:x({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:x({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:x({payloadHex:l()}).optional(),wsd:x({xaddrs:C(l()),types:C(l()),scopes:C(l())}).optional()}),wj=x({stableId:l(),type:S(E),suggestedName:l(),prefilledConfig:m(l(),w()),sourceInfo:Pg.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:y().optional(),parentStableId:l().optional(),selectable:y().optional(),needsParams:C(l()).optional()}),Tj=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:y(),features:C(l()),config:m(l(),w()),sourceInfo:Pg.optional()}),Ej=x({status:S([`ok`,`error`]),labels:C(l()).optional(),error:l().optional()}),Dj=w(),Oj={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:A(v(),v(),{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getStatus:A(v(),xj),getDevices:A(v(),C(x({id:l(),name:l(),type:l()}))),reloadDevice:A(x({stableId:l()}),x({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:A(x({}),y()),discoverDevices:A(x({params:m(l(),w()).optional()}),C(wj),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:A(x({}),C(Sj)),classifyDiscoveryHits:A(x({hits:C(Cj),params:m(l(),w()).optional()}),C(wj),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:A(x({}),Dj),getManualCreationType:A(x({integrationId:l().optional()}),x({deviceType:S(E).nullable()})),adoptDiscoveredDevice:A(x({candidate:wj,integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),supportsManualCreation:A(x({}),y()),getChildCreationSchema:A(x({type:S(E),integrationId:l().optional()}),Dj),createDevice:A(x({type:S(E),config:m(l(),w()),integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),Ej,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},kj=i(`kind`,[x({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),x({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),kSe=x({addonId:l(),candidate:wj,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),Aj=x({id:l(),addonId:l(),candidate:wj,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),jj=x({childKey:l(),section:l(),order:n().optional(),collapsed:y().optional()}),ASe=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),Mj=x({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:y().optional(),perCap:m(l(),ASe).optional()}),Nj=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),Pj=x({id:n(),stableId:l(),addonId:l(),type:S(E),name:l(),alias:hA.optional(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:y(),probed:y().optional(),features:C(l()),isCamera:y(),config:m(l(),w()),secretConfigPaths:C(l()).optional(),metadata:m(l(),w()).nullable().optional(),identifiers:RA.optional(),attachedIdentifiers:RA.optional(),sourceInfo:Pg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(jj).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),display:Mj.optional()}),Fj=x({key:l(),value:w(),description:l().optional()}),Ij=S([`manual`]),Lj=x({deviceId:n(),name:l(),location:l().nullable(),features:C(l()),producesTrackedEvents:y().optional()}),Rj=x({deviceIds:C(n().int().positive()),trackedDeviceIds:C(n().int().positive()).optional()}),zj={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:[E.Camera],sourceCaps:`any`,cardinality:`many`,value:Rj},jSe=x({deviceId:n(),mode:Ij,devices:C(Lj)}),Bj=x({deviceId:n(),entries:C(x({capName:l(),kind:S([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:C(l()).optional()}))}),Vj=i(`kind`,[x({kind:p(`value`),wrapperAddonId:l().nullable()}),x({kind:p(`missing`)}),x({kind:p(`failed`),error:l()})]),MSe=x({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),NSe=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:y().optional(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),metadata:m(l(),w()).nullable().optional(),identifiers:RA.optional(),attachedIdentifiers:RA.optional(),sourceInfo:Pg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(jj).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),role:l().nullable().optional(),display:Mj.optional()}),PSe=w().nullable(),FSe=x({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),ISe=x({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:y().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:C(l()).optional(),config:m(l(),w()),secretConfigPaths:C(l()).optional()}),Hj=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),Uj=2160*60*60*1e3,Wj=x({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),Gj=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:C(Wj),unreachable:C(l())}),LSe=x({deviceId:n()}),RSe=x({deviceId:n(),data:m(l(),w()),secretConfigPaths:C(l()).optional()}),Kj=S([`off`,`on`,`not-offered`,`unreachable`]),qj=x({deviceId:n(),switchId:wd,outcome:Kj,detail:l().optional()}),Jj=x({sourceId:n(),targetId:n(),switches:C(qj).readonly(),sourceStillLive:C(wd).readonly(),swapped:y()}),Yj={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[zj],methods:{allocateDeviceId:A(x({addonId:l(),stableId:l()}),x({id:n()}),{kind:`mutation`}),migrateDevice:A(x({sourceId:n(),targetId:n()}),Jj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:A(ISe,v(),{kind:`mutation`}),removeDevice:A(LSe,v(),{kind:`mutation`}),persistConfig:A(RSe,v(),{kind:`mutation`,auth:`admin`}),loadConfig:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadRuntimeState:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadMeta:A(x({deviceId:n()}),NSe.nullable()),setName:A(x({deviceId:n(),name:l(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:A(x({deviceId:n(),alias:l()}),i(`ok`,[x({ok:p(!0),alias:hA}),x({ok:p(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:A(x({templates:C(yA).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:xA.optional()}),x({results:C(EA)}),{auth:`admin`}),checkDeviceTemplates:A(x({templates:C(l()).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:xA.optional()}),x({results:C(i(`ok`,[x({ok:p(!0),aliases:C(x({alias:l(),deviceId:n().int().nullable(),allowed:y(),reads:C(l())})),readsClock:y()}),x({ok:p(!1),refusal:CA})]))}),{auth:`admin`}),setLocation:A(x({deviceId:n(),location:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:A(x({deviceId:n(),tags:Eh}),v(),{kind:`mutation`,auth:`admin`}),setType:A(x({deviceId:n(),type:S(E)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:A(x({deviceId:n(),integrationId:l()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:A(x({deviceId:n(),linkDeviceId:n().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:A(x({deviceId:n(),primaryChildEntityId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:A(x({deviceId:n(),childLayout:C(jj).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:A(x({deviceId:n(),primaryChildPreference:C(l()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:A(x({deviceId:n(),display:Mj.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:A(x({}),x({defaults:m(l(),Nj)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:A(x({defaults:m(l(),Nj)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:A(x({deviceId:n(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:l(),fields:C(x({path:l(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(l()).optional(),item:y().optional(),quantity:Ui.optional()})).readonly(),itemArray:x({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:A(x({deviceId:n(),role:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:A(x({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Eh.optional(),type:S(E).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:A(x({deviceId:n(),patch:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:A(x({deviceId:n(),identifiers:RA.nullable(),unread:C(MA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:A(x({}),QA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:A(x({deviceId:n(),identifiers:RA.nullable(),unread:C(MA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:A(x({deviceId:n().int().optional()}),cj,{kind:`query`,auth:`admin`}),confirmIdentityLink:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),listLocations:A(v(),C(l())),addLocation:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:A(x({name:l(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:A(x({from:l(),to:l()}),x({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:A(v(),C(Mpe),{role:`viewer`}),setLocationIcon:A(x({location:l(),icon:xh.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:A(v(),C(Ppe)),setLocationDescription:A(x({location:l(),description:l().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:A(v(),C(AA),{role:`viewer`}),setSiteZone:A(x({name:l(),icon:xh.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:A(x({from:l(),to:l()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:A(x({location:l(),zone:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:A(x({deviceId:n(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:A(x({addonId:l()}),C(MSe)),listAll:A(x({addonId:l().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(n()).optional()}),C(Pj),{role:`viewer`}),search:A(mj,bj,{role:`viewer`}),getDevice:A(x({deviceId:n()}),Pj.nullable()),getChildren:A(x({parentDeviceId:n()}),C(Pj),{role:`viewer`}),getChildrenBatch:A(x({parentDeviceIds:C(n()).max(256)}),m(l(),C(Pj))),getLinkedDevices:A(x({deviceId:n()}),x({mode:Ij,devices:C(Lj)}),{role:`viewer`}),getLinkedDevicesBatch:A(x({deviceIds:C(n())}),C(jSe),{role:`viewer`}),getStreamSources:A(x({deviceId:n()}),C(ta)),getConfigSchema:A(x({deviceId:n()}),C(Fj)),getSettingsSchema:A(x({deviceId:n()}),PSe),updateConfig:A(x({deviceId:n(),values:m(l(),w())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:A(x({sinceMs:n()}),C(Hj).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:A(x({confirm:y()}),Gj,{kind:`mutation`,auth:`admin`}),removeByIntegration:A(x({integrationId:l()}),x({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:A(x({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:A(x({deviceId:n(),profileMap:m(l(),l().nullable())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:A(x({deviceId:n()}),C(FSe),{kind:`mutation`,auth:`admin`}),getBindings:A(x({deviceId:n()}),Bj,{role:`viewer`}),getBindingsBatch:A(x({deviceIds:C(n())}),C(Bj)),getAllBindings:A(x({}),C(Bj)),listDeviceIdsByCaps:A(x({capNames:C(l().min(1)).min(1).max(16)}),C(n()),{role:`viewer`}),setWrapperActive:A(x({deviceId:n(),capName:l(),wrapperAddonId:l(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:A(x({deviceId:n(),capName:l().min(1)}),Vj),listWrappersForCap:A(x({capName:l()}),C(l())),listBindableCapsForDeviceType:A(x({deviceType:l()}),C(x({capName:l(),wrappers:C(l())}))),getDeviceSettingsAggregate:A(x({deviceId:n()}),Ax.nullable()),getDeviceLiveInfoAggregate:A(x({deviceId:n()}),Ax.nullable(),{role:`viewer`}),getDeviceAggregate:A(x({deviceId:n()}),x({settings:Ax.nullable(),live:Ax.nullable()})),runDeviceAction:A(x({deviceId:n().int().nonnegative(),action:l().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:A(x({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:w()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:A(x({deviceId:n(),changes:C(x({writerCapName:l(),writerAddonId:l(),key:l(),value:w()}))}),x({success:p(!0),failures:C(x({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:A(x({addonId:l()}),C(wj),{kind:`mutation`,auth:`admin`}),adoptDevice:A(x({addonId:l(),candidate:wj,integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),getCreationSchema:A(x({addonId:l(),type:S(E),integrationId:l().optional()}),w().nullable()),createDevice:A(x({addonId:l(),type:S(E),config:m(l(),w()),integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({addonId:l(),type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),Ej,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:A(x({addonId:l(),integrationId:l()}),x({filters:C($k)}),{auth:`admin`}),adoptionListCandidates:A(tA.extend({addonId:l()}),nA,{auth:`admin`}),adoptionRefresh:A(x({addonId:l(),integrationId:l()}),iA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:A(aA.extend({addonId:l()}),oA,{kind:`mutation`,auth:`admin`}),adoptionRelease:A(sA.extend({addonId:l()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:A(aA.extend({addonId:l()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:A(x({addonId:l(),integrationId:l().optional()}),C(Cd).readonly(),{auth:`admin`}),adoptionCancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:A(cA,lA,{kind:`mutation`,auth:`admin`}),discoveryProviders:A(x({}),x({providers:C(x({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:A(x({subnets:C(l()).optional()}),x({groups:C(x({addonId:l(),label:l(),candidates:C(wj).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:A(x({addonId:l(),params:m(l(),w()).optional(),subnets:C(l()).optional()}),x({candidates:C(wj).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:A(x({}),x({proposals:C(Aj).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:A(x({id:l()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:A(x({observations:C(kj).max(512)}),x({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:A(x({}),x({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:A(x({addonId:l(),integrationId:l().optional()}),x({deviceType:S(E).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:A(x({addonId:l()}),w(),{auth:`admin`}),testField:A(x({deviceId:n(),key:l(),value:w()}),Ej,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:A(x({deviceId:n(),caps:C(l()).readonly().optional()}),m(l(),w().nullable())),getDeviceStatusAggregateBatch:A(x({deviceIds:C(n()).readonly(),caps:C(l()).readonly().optional()}),m(l(),m(l(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},Xj=[`linked-devices`],Zj=S(Xj),Qj={"linked-devices":{descriptor:zj,declaringCap:`device-manager`,hostDeviceTypes:[E.Camera]}},$j=i(`slot`,[Rj.extend({slot:p(`linked-devices`)})]),eM=[E.Camera],zSe=`:`,BSe=`listSlots`,tM=i(`state`,[x({state:p(`ok`)}),x({state:p(`unreachable`),reason:l()})]),nM=x({source:l(),label:l(),addonId:l().optional(),availability:tM}),rM=S([`ok`,`missing`,`foreign`,`unavailable`]),iM=x({deviceId:n().int(),name:l().nullable(),health:rM,detail:l().optional()}),aM=x({state:S([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),oM=x({state:p(`ok`),slotRef:l(),slot:Zj,authority:l(),activation:aM.nullable(),value:$j,sources:C(iM),impliedSources:C(iM).optional()}),sM=x({state:p(`unreachable`),addonId:l(),reason:l()}),cM=i(`state`,[oM,sM]);function VSe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var lM=x({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:y(),reason:l().nullable()}),uM=x({candidates:C(lM)}),dM=x({applied:p(!0),reload:S([`none`,`host`,`parent`])}),fM=x({deviceId:n().int(),slotRef:l().min(1)}),pM=fM.extend({value:$j}),mM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:eM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:A(x({deviceId:n().int()}),C(nM)),listSlots:A(x({deviceId:n().int()}),C(cM)),listCandidates:A(fM,uM),setSlot:A(pM,dM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Device extension`,`Estensione del dispositivo`),order:3100}},hM=i(`kind`,[x({kind:p(`device`),deviceId:n().int()}),x({kind:p(`node`),nodeId:l().min(1)})]),gM=S([`gauge`,`counter`,`boolean`,`enum`]),_M=S([`gauge`,`counter`,`boolean`]),HSe=`derived:energy.kwh`,vM=S([`raw`,`5m`,`1h`,`1d`]),yM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),USe=x({key:l(),reason:yM,count:n().int()}),bM=x({accepted:n().int(),refused:C(USe).readonly()}),xM=x({key:l(),scope:l(),kind:gM,unit:l().nullable(),displayName:l(),source:S([`cap`,`addon`,`derived`]),values:C(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),WSe=x({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),GSe=x({scope:l(),before:x({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:C(WSe).readonly(),derivedFrom:l().nullable()}),SM={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([vM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},CM=x({resolution:vM,series:C(GSe).readonly(),truncated:y()}),KSe=24,qSe=h([x({deviceId:n().int(),key:l(),scope:l().optional()}),x({forNodeId:l().min(1),key:l(),scope:l().optional()})]),JSe=i(`ok`,[x({ok:p(!0),result:CM}),x({ok:p(!1),error:l()})]),YSe=x({tier:vM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),wM=S([`device-gone`,`undeclared`]),TM=x({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),XSe=x({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:wM,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:TM}),ZSe=200,QSe=50,EM=S([`not-found`,`not-orphan`,`failed`]),$Se=i(`ok`,[x({seriesId:n().int(),ok:p(!0),deleted:TM}),x({seriesId:n().int(),ok:p(!1),reason:EM})]),eCe=x({series:C(XSe).readonly(),truncated:y()}),DM=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),tCe=x({"5m":n().int(),"1h":n().int(),"1d":n().int()}),nCe=i(`ok`,[x({ok:p(!0),dryRun:y(),seriesId:n().int(),rows:TM,rewritten:tCe.nullable()}),x({ok:p(!1),reason:DM})]),OM=x({startedAt:n(),ready:y(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:C(YSe).readonly(),capture:x({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:x({accepted:n().int(),refused:m(l(),n().int())}),rollup:x({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:x({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:x({devices:n().int(),lastRefreshAt:n().nullable()})}),kM={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:A(x({deviceId:n().int()}),C(xM).readonly()),listNodeSeries:A(x({forNodeId:l().min(1)}),C(xM).readonly(),{auth:`admin`}),query:A(x({deviceId:n().int(),...SM}),CM),queryNode:A(x({forNodeId:l().min(1),...SM}),CM,{auth:`admin`}),queryMany:A(x({items:C(qSe).min(1).max(24),from:SM.from,to:SM.to,resolution:SM.resolution,maxPoints:SM.maxPoints}),x({results:C(JSe).readonly()}),{auth:`admin`}),declareSeries:A(x({name:l().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:_M,unit:l().optional(),displayName:l().min(1),ingest:S([`points`,`buckets`])}),x({key:l()}),{kind:`mutation`,auth:`admin`}),record:A(x({points:C(x({key:l(),subject:hM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),bM,{kind:`mutation`,auth:`admin`}),recordBuckets:A(x({buckets:C(x({key:l(),subject:hM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),bM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:A(x({deviceId:n().int()}),x({enabled:y()})),setDeviceEnabled:A(x({deviceId:n().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:A(x({}),OM,{auth:`admin`}),listOrphanSeries:A(x({}),eCe,{auth:`admin`}),deleteOrphanSeries:A(x({seriesIds:C(n().int()).min(1).max(50)}),x({results:C($Se).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:A(x({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:y()}),nCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},AM=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),jM=x({counts:m(l(),n().int().nonnegative())}),MM=x({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),NM={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:A(AM,jM,{kind:`mutation`,auth:`admin`}),listDeviceData:A(v(),C(MM).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},PM=S([`appliance`,`mower`,`vacuum`]),FM=S([`open`,`closed`]),IM=S([`completed`,`aborted`,`error`,`unknown`]),LM=S([`running-state`,`activity`,`reconcile`]),RM=S([`counter-delta`,`history-integral`]),zM=x({phase:l(),at:n()}),BM=x({kind:p(`appliance`),energyKwh:n().nullable().meta(N(`energy`)),energyMethod:RM.nullable(),peakW:n().nullable().meta(N(`power`)),avgW:n().nullable().meta(N(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(N(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(N(`energy`)),powerObservedMs:n()}),VM=i(`kind`,[BM]),HM=x({runId:l(),deviceId:n().int(),kind:PM,state:FM,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:IM.nullable(),startSource:LM,endSource:LM.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(zM),detail:VM}),rCe=[E.Washer,E.Dryer,E.Dishwasher],iCe=200,UM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:rCe,methods:{listRuns:A(x({deviceId:n().int(),outcome:IM.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({runs:C(HM).readonly(),nextCursor:l().nullable()})),getRun:A(x({deviceId:n().int(),runId:l()}),HM.nullable()),getCurrentRun:A(x({deviceId:n().int()}),HM.nullable())},events:{onRunOpened:{data:HM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:HM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:F(`Runs`,`Esecuzioni`),order:2130}},WM=S([`replace`,`add`]),GM=i(`ok`,[x({ok:p(!0),changed:y()}),x({ok:p(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),KM=x({deviceId:n(),capName:l(),owner:l().min(1),mode:WM,fields:C(l().min(1)).min(1)}),qM=i(`state`,[x({state:p(`loaded`),claims:C(KM)}),x({state:p(`not-loaded`),reason:l()})]),JM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:A(x({deviceId:n()}),m(l(),m(l(),w()))),getCapSlice:A(x({deviceId:n(),capName:l(),confirmed:y().optional()}),m(l(),w()).nullable()),getAllSnapshots:A(x({confirmed:y().optional()}),m(l(),m(l(),m(l(),w())))),setCapSlice:A(x({deviceId:n(),capName:l(),slice:m(l(),w())}),v(),{kind:`mutation`}),claimFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),mode:WM,fields:C(l().min(1)).min(1),values:m(l(),w())}),GM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),w())}),GM,{kind:`mutation`,auth:`admin`}),releaseClaim:A(x({deviceId:n(),capName:l(),owner:l().min(1)}),GM,{kind:`mutation`,auth:`admin`}),listClaims:A(x({ownerPrefix:l().optional()}),qM,{auth:`admin`}),getNativeCapSlice:A(x({deviceId:n(),capName:l()}),m(l(),w()).nullable(),{auth:`admin`})},events:{onChanged:Lr(x({deviceId:n(),capName:l(),slice:m(l(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},YM=S([`schedule`,`command`,`burst`]),XM=S([`none`,`partial`,`full`]),ZM=1e3,aCe=x({integrationId:l().min(1),minIntervalMs:n().int().min(ZM),intervalMs:n().int().positive().optional(),batch:y(),push:XM,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function oCe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var QM=[3e3,1e4],$M=1e4,eN=2e3;function sCe(e){let t=QM.filter(t=>t<e),n=e-eN,r=(t[t.length-1]??0)+$M;for(;r<n;)t.push(r),r+=$M;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var cCe=2500,tN=x({deviceId:n().int().nonnegative(),deviceIds:C(n().int().nonnegative()).min(1),reason:YM}),nN=x({deviceId:n().int().nonnegative()}),rN=x({ok:p(!0)}),iN=`the core schedules state refreshes itself; an operator never asks for one`,aN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:A(tN,rN,{kind:`mutation`,auth:`admin`,notOperatorFacing:iN}),resubscribe:A(nN,rN,{kind:`mutation`,auth:`admin`,notOperatorFacing:iN})},vocabulary:{noun:F(`State refresh`,`Aggiornamento dello stato`),order:3247}},oN=x({online:y(),lastChangedAt:n()}),sN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:oN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:oN,kind:`push`},runtimeState:oN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:F(`Online`,`Online`),whenTrue:F(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:F(`Came online`,`Tornato online`),phrase:F(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:F(`Went offline`,`Andato offline`),phrase:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},lCe=200,uCe=500,cN=S([`not-kernel`,`invalid`]),lN=x({written:n().int().nonnegative(),refused:C(x({id:l(),reason:cN})).readonly()}),uN=x({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),dN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(E).filter(e=>e!==E.Container),methods:{listTransitions:A(x({deviceId:n().int(),capName:l().optional(),actorKind:Ri.optional(),outcome:zi.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(Vi).readonly(),nextCursor:l().nullable()})),getTransition:A(x({deviceId:n().int(),id:l()}),Vi.nullable()),listRecentTransitions:Ir(x({actorKind:Ri.optional(),outcome:zi.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(Vi).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:Ir(x({transitions:C(Vi).max(500)}),lN,{kind:`mutation`,auth:`admin`}),getStatus:Ir(x({}),uN,{auth:`admin`})},vocabulary:{noun:F(`Transitions`,`Transizioni`),order:2140}},fN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),pN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),mN=S([`available`,`offline`,`description-missing`]),hN=x({availability:mN,state:fN,operationState:pN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:C(l()),remaining:n().int().nonnegative().nullable().meta(N(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(N(`duration`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:l().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(N(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(l()),errorCode:n().nullable().meta(N(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),gN=n().int().nonnegative(),_N=h([y(),l(),n()]),vN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),yN=x({key:l(),name:l(),type:S([`boolean`,`number`,`enum`,`string`]),access:vN,available:y(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:C(l()).nullable(),defaultValue:_N.nullable()}),bN=x({key:l(),name:l(),available:y(),options:C(yN)}),xN=x({availability:mN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(bN),options:C(yN)}),SN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Dishwasher],methods:{start:A(x({deviceId:gN,program:l().min(1).optional(),options:m(l(),_N).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:F(`Start cycle`,`Avvia il lavaggio`),phrase:F(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:F(`Pause`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:F(`Resume`,`Riprendi`),phrase:F(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:A(x({deviceId:gN,program:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:F(`Choose programme`,`Scegli il programma`),phrase:F(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:F(`Power on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:F(`Power off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:F(`Half load on`,`Mezzo carico attivo`),phrase:F(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:F(`Half load off`,`Mezzo carico spento`),phrase:F(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:F(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:F(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:F(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:F(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:F(`Extra dry on`,`Asciugatura extra attiva`),phrase:F(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:F(`Extra dry off`,`Asciugatura extra spenta`),phrase:F(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:F(`Intensive zone on`,`Zona intensiva attiva`),phrase:F(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:F(`Intensive zone off`,`Zona intensiva spenta`),phrase:F(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:F(`Speed boost on`,`Lavaggio rapido attivo`),phrase:F(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:F(`Speed boost off`,`Lavaggio rapido spento`),phrase:F(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:A(x({deviceId:gN,key:l().min(1),value:_N}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:A(x({deviceId:gN}),xN,{auth:`protected`})},status:{schema:hN,kind:`poll`},runtimeState:hN,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:F(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:F(`Cycle`,`Ciclo`),values:[{value:`idle`,label:F(`Idle`,`Inattiva`)},{value:`running`,label:F(`Running`,`In funzione`),phrase:F(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`finished`,label:F(`Finished`,`Terminato`),phrase:F(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:F(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:F(`the cycle progress`,`l’avanzamento del lavaggio`),label:F(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:F(`Door open`,`Sportello aperto`),whenTrue:F(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:F(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:F(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:F(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:F(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:F(`Machine care due`,`Manutenzione da fare`),whenTrue:F(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:F(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},CN=`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(`.`),wN=`audio`,TN=[.3,.42,.55,.7,.85,1],EN=[`camstack`,`high-contrast`,`okabe-ito`];function dCe(e){return CN.includes(e)}function fCe(e){return EN.includes(e)}var DN={dark:`#0c0a09`,light:`#fafaf9`},pCe=7,mCe=20,hCe=[`live`,`heatmapScrub`],gCe=3,ON=/^#[0-9a-fA-F]{6}$/;function kN(e,t){return Number.parseInt(e.slice(t,t+2),16)}function AN(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function jN(e){let t=AN(kN(e,1)),n=AN(kN(e,3)),r=AN(kN(e,5));return .2126*t+.7152*n+.0722*r}function _Ce(e,t){if(!ON.test(e)||!ON.test(t))return 0;let n=Math.max(jN(e),jN(t)),r=Math.min(jN(e),jN(t));return(n+.05)/(r+.05)}function MN(e){let t=AN(kN(e,1)),n=AN(kN(e,3)),r=AN(kN(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 NN(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 vCe(e,t){if(!ON.test(e)||!ON.test(t))return 0;let n=MN(e),r=MN(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=NN(o,n.b),d=NN(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let _=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),ee=30*Math.exp(-(((g-275)/25)**2)),v=h**7,te=2*Math.sqrt(v/(v+25**7)),y=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,b=l-c;return Math.sqrt((ae/y)**2+(b/ne)**2+(p/re)**2+b/ne*ie*(p/re))}var yCe={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`},bCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],xCe={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`},SCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],CCe={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`},wCe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],PN=l().regex(/^#[0-9a-f]{6}$/),FN=i(`form`,[x({form:p(`solid`),hex:PN}),x({form:p(`gradient`),hex:PN,alphas:C(n().gt(0).lte(1)).length(TN.length)})]),IN=x({status:p(`ready`),presetId:S(EN),customized:y(),source:S([`stored`,`unconfigured`]),swatches:m(l(),FN),fallbacks:C(PN).length(8)}),LN=i(`status`,[IN,x({status:p(`unknown`),reason:l()})]),RN=h([x({presetId:l()}),x({presetId:l(),overrides:m(l(),FN)})]),zN=x({presetId:l(),overrides:m(l(),FN)});function TCe(e){return{form:`solid`,hex:e}}function ECe(e){return{form:`gradient`,hex:e,alphas:[...TN]}}function DCe(e){let t={};for(let n of CN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?ECe(r):TCe(r)}return t}function BN(e,t,n,r){return{id:e,name:t,swatches:DCe(n),fallbacks:r}}var VN=[BN(`camstack`,`CamStack`,yCe,bCe),BN(`high-contrast`,`High contrast`,xCe,SCe),BN(`okabe-ito`,`Colour-blind safe`,CCe,wCe)];function HN(e){return VN.find(t=>t.id===e)}function UN(){let e=HN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return OCe(e,`unconfigured`,!1)}function OCe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function kCe(e){return e.hex}function ACe(e,t){let n=[];for(let t of CN){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 jCe(e){let t=e[wN];return t===void 0||t.form===`gradient`&&TN.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:wN}]}function MCe(e,t){let n=hCe;return n.includes(e)&&n.includes(t)}function WN(e,t){let n=[];for(let t of CN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))dCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...jCe(e));let r=ACe(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=vCe(i.hex,a.hex);o<(MCe(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=_Ce(e.hex,DN[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 NCe(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 GN(e){return e.map(NCe).join(`; `)}var KN=class extends Error{violations;constructor(e){super(GN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function qN(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 JN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[wN];return n===void 0?qN(r,t):n.hex}let i=e[r];return i===void 0?qN(r,t):i.hex}function YN(e,t){return{...e,...t}}function PCe(e){return`overrides`in e?e.overrides:{}}function FCe(e){let t=HN(e.presetId);if(t===void 0||!fCe(e.presetId))throw new KN([{code:`unknown-preset`,presetId:e.presetId}]);let n=PCe(e),r=YN(t.swatches,n),i=WN(r,t.fallbacks);if(!i.ok)throw new KN(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 ICe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function LCe(e){if(e==null||ICe(e))return UN();let t=zN.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=HN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=YN(n.swatches,t.data.overrides),i=WN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:GN(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 RCe(e,t){return{presetId:e.presetId,overrides:{...t}}}var zCe=x({id:l(),name:l(),swatches:m(l(),FN),fallbacks:C(l())}),XN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:A(v(),LN,{auth:`protected`,role:`viewer`}),listPresets:A(v(),C(zCe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:A(RN,IN,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},ZN=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),QN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],methods:{setEnabled:A(x({deviceId:n().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:F(`Do not disturb on`,`Attiva Non disturbare`),phrase:F(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:F(`Do not disturb off`,`Disattiva Non disturbare`),phrase:F(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:ZN,kind:`push`},runtimeState:ZN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:F(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:F(`Do not disturb`,`Non disturbare`),whenTrue:F(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:F(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},$N=2e3,BCe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[E.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:$N,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},eP=x({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(N(`count`))}),tP=x({deviceId:n(),timestamp:n()}),nP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button,E.Camera],methods:{},events:{onPressed:{data:tP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:F(`Rang`,`Ha suonato`),phrase:F(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:eP,kind:`push`},runtimeState:eP,durability:`restored`,history:`none`,customize:BCe,vocabulary:{noun:F(`Doorbell`,`Campanello`),order:5270}},rP=x({embedding:C(n()),inferenceMs:n()}),iP=S([`image`,`text`]),aP=x({modelId:l(),tower:iP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),oP=x({modelId:l(),tower:iP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),sP=x({modelId:l(),embeddingDim:n(),ready:y(),nodeId:l().optional(),failedModels:C(aP).optional(),failedRequirements:C(oP).optional()}),cP=`embedding-model-failed`,lP=`embedding-requirements-unavailable`,uP=`embedding-requirements-failed`,dP=S([cP,lP,uP]);function fP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function VCe(e){return Error(`${fP(cP,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 HCe(e,t){return Error(`${fP(lP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function UCe(e){return Error(`${fP(uP,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 WCe=RegExp(`\\[(${cP}|${lP}|${uP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function pP(e){let t=e instanceof Error?e.message:String(e),n=WCe.exec(t);if(n===null)return null;let r=dP.safeParse(n[1]),i=iP.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 GCe(e){return mP(e)!==null}function mP(e){let t=pP(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 hP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:A(x({crop:b(Uint8Array),width:n(),height:n()}),rP,{auth:`admin`}),encodeText:A(x({text:l(),modelId:l().min(1).optional()}),rP,{auth:`admin`}),getInfo:A(v(),sP,{auth:`admin`}),resetFailedModels:A(x({modelId:l().min(1).optional()}),x({cleared:C(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},gP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),_P=x({powerW:n().nullable().meta(N(`power`)),importKwh:n().nullable().meta(N(`energy`)),exportKwh:n().nullable().meta(N(`energy`)),importTodayKwh:n().nullable().meta(N(`energy`)),exportTodayKwh:n().nullable().meta(N(`energy`))}),vP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),yP=x({stateOfChargePct:n().nullable().meta(N(`percentage`)),storedKwh:n().nullable().meta(N(`energy`)),capacityKwh:n().nullable().meta(N(`energy`)),powerW:n().nullable().meta(N(`power`)),chargedKwh:n().nullable().meta(N(`energy`)),dischargedKwh:n().nullable().meta(N(`energy`)),chargedTodayKwh:n().nullable().meta(N(`energy`)),dischargedTodayKwh:n().nullable().meta(N(`energy`)),healthPct:n().nullable().meta(N(`percentage`))}),bP=x({solar:gP.nullable(),grid:_P.nullable(),house:vP.nullable(),heatPump:vP.nullable(),storage:yP.nullable(),lastFetchedAt:n()});function KCe(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 xP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EnergySystem],methods:{},status:{schema:bP,kind:`push`},runtimeState:bP,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:F(`Energy system`,`Sistema energetico`),order:4020}},qCe=S([`date`,`time`,`datetime`]),SP=x({value:l(),timestamp:y().optional(),lastFetchedAt:n()}),CP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:SP,kind:`push`},runtimeState:SP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:F(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:F(`State`,`Stato`),icon:`list`}]}},wP=S([`warning`,`error`]),TP=x({code:l(),label:l(),severity:wP}),EP=x({active:y().nullable(),code:l().nullable(),label:l().nullable(),severity:wP,since:n().nullable(),faults:C(TP).optional(),lastFetchedAt:n()}),DP={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},OP={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:EP,kind:`push`,empty:DP},runtimeState:EP,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:F(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:F(`Fault`,`Guasto`),whenTrue:F(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:F(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},kP=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),JCe=x({id:l(),source:S([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:AS.optional()}),YCe=x({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:S([`detected`,`photo`]),mediaId:n().int().optional(),comparable:y(),selfMean:n().nullable(),bestForeign:x({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),XCe=x({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:C(YCe).readonly()}),AP=x({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:y(),base64:l().optional(),cropUrl:l().optional(),faceBbox:AS.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),ZCe=S([`unassigned`,`recognized`,`identified`,`all`]),QCe=S([`timestamp`,`suggestionConfidence`]),$Ce=S([`asc`,`desc`]),ewe=x({faceIds:C(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),twe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),jP={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:A(x({includeCrops:y().optional()}).optional(),C(kP).readonly(),{role:`viewer`}),createIdentity:A(x({name:l().min(1)}),kP,{kind:`mutation`,auth:`admin`}),renameIdentity:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:A(x({identityId:l()}),C(JCe).readonly()),auditIdentitySamples:A(x({identityId:l().min(1)}),XCe,{auth:`admin`}),removeSample:A(x({identityId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:A(x({sampleId:l().min(1),toIdentityId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:A(x({deviceId:n().int().optional(),deviceIds:C(n().int()).optional(),limit:n().int().positive().optional(),filter:ZCe.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:QCe.optional(),sortDirection:$Ce.optional(),includeCrops:y().optional()}).optional(),C(AP).readonly()),getFaceByTrack:A(x({deviceId:n().int(),trackId:l()}),AP.nullable(),{role:`viewer`}),getFaceMedia:A(x({faceId:l()}),C(twe).readonly()),assignFace:A(x({faceId:l(),identityId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:A(x({faceIds:C(l()).min(1),identityId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:A(x({faceIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:A(x({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),C(ewe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},MP=x({reason:l(),count:n().int().nonnegative()}),NP=x({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:C(MP).readonly()}),PP={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(NP).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},FP=S([`forward`,`reverse`]),IP=[`horizontal`,`vertical`],LP=S(IP),RP=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],zP=S(RP),BP=[`min`,`max`,`step`],VP=x({oscillating:y().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),HP=x({horizontal:VP.nullable().default(null),vertical:VP.nullable().default(null)}),UP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],WP=S(UP),GP=i(`status`,[x({status:p(`applied`)}),x({status:p(`refused`),reason:WP,field:zP.optional(),detail:l(),applied:C(zP)})]),KP=x({deviceId:n().int().nonnegative(),axis:LP,oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function qP(e,t){return`oscillationAxes.${e}.${t}`}var JP=x({speed:n().min(0).max(100).nullable().meta(N(`percentage`)),percentageStep:n().positive().optional().meta(N(`percentage`)),preset:l(),availablePresets:C(l()),direction:FP.nullable(),oscillating:y().nullable(),oscillationAxes:HP.optional(),lastChangedAt:n()});function nwe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=IP.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var YP=[E.Fan],XP=`oscillation-axes`;function rwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:YP,apply:`replace`,section:XP,path:qP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function ZP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:YP,apply:`replace`,section:XP,path:qP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:BP.map(t=>({kind:`source-field`,path:qP(e,t),field:t}))}:n}var iwe=IP.flatMap(e=>[rwe(e),ZP(e,`angle`),ZP(e,`sweepFrom`),ZP(e,`sweepTo`)]),awe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:YP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},QP=[...iwe,awe],owe={version:1,overridable:QP.map(e=>({path:e.path,by:e.id})),targets:QP},$P={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Fan],methods:{setPercentage:j(x({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:F(`Fan off`,`Ventilatore spento`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:F(`Fan full`,`Ventilatore al massimo`),phrase:F(`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:F(`Set speed`,`Imposta la velocità`),phrase:F(`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:F(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:j(x({deviceId:n().int().nonnegative(),direction:FP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:F(`Spin forward`,`Rotazione avanti`),phrase:F(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:F(`Spin in reverse`,`Rotazione inversa`),phrase:F(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:j(x({deviceId:n().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:F(`Oscillate`,`Oscillazione attiva`),phrase:F(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:F(`Stop oscillating`,`Oscillazione spenta`),phrase:F(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:j(KP,GP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:F(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:F(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:F(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:F(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:F(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:F(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:F(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:JP,kind:`push`},runtimeState:JP,customize:owe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:F(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:F(`the speed`,`la velocità`),label:F(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:F(`Oscillating`,`Oscillazione`),whenTrue:F(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:F(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},swe=12,eF=x({oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),tF=x({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:FP.optional(),oscillationAxes:x({horizontal:eF.optional(),vertical:eF.optional()}).optional()}),nF=x({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:tF}),rF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],iF=S(rF),aF=i(`status`,[x({status:p(`saved`),count:n().int().nonnegative()}),x({status:p(`refused`),reason:iF,detail:l()})]),oF=x({field:l(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),sF=x({status:S([`applied`,`partial`,`refused`]),fields:C(oF)}),cF=[`speed`,`direction`,`preset`,`oscillationAxes`],lF=S(cF),uF=x({what:l(),reason:l()}),dF=x({state:tF,omitted:C(uF)}),fF=x({deviceId:n().int().nonnegative()}),cwe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},pF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:A(fF,C(nF),{auth:`protected`}),setPresets:A(fF.extend({presets:C(nF).max(12)}),aF,{kind:`mutation`,auth:`admin`}),applyPreset:A(fF.extend({presetId:l().min(1)}),sF,{kind:`mutation`,auth:`protected`}),capturePreset:A(fF.extend({fields:C(lF).optional()}),dF,{auth:`protected`})},customize:cwe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},mF=x({flags:m(l(),w()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(N(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),hF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:n(),status:mF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:mF,kind:`push`},runtimeState:mF,durability:`session`,history:`none`,vocabulary:{noun:F(`Feature probe`,`Rilevamento funzioni`),order:3120}},lwe=x({name:l(),path:l()}),uwe=x({path:l(),entries:C(lwe).readonly(),freeBytes:n(),totalBytes:n()}),gF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:A(v(),C(l()).readonly(),{auth:`admin`}),browse:A(x({path:l()}),uwe,{auth:`admin`}),createDir:A(x({path:l()}),x({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},_F=x({flooded:y(),lastChangedAt:n()}),vF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:_F,kind:`push`},runtimeState:_F,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},yF=x({detected:y(),lastChangedAt:n()}),bF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:yF,kind:`push`},runtimeState:yF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},xF=x({active:y().meta({label:`Active`}),lastChangedAt:n()}),SF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:xF,kind:`push`},runtimeState:xF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group state`,`Stato del gruppo`),order:5090}},CF=x({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:y(),error:l().optional(),at:n()}),wF=x({results:C(CF)}),TF={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:wF,kind:`push`},runtimeState:wF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group command`,`Comando di gruppo`),order:5100}},EF=x({included:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Members`}))}),DF={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:EF,kind:`push`},runtimeState:EF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:F(`the members reporting`,`i membri che rispondono`),label:F(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:F(`the members left out`,`i membri esclusi`),label:F(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:F(`the member count`,`il numero di membri`),label:F(`Members`,`Membri`),icon:`sigma`}]}},OF=n().int().nonnegative(),kF=l().min(1),AF=l().min(1),jF=n().finite(),MF={key:`circuitId`,label:F(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},NF={...MF,label:F(`Hot water circuit`,`Circuito acqua calda`),offer:{...MF.offer,where:{key:`kind`,equals:`dhw`}}},PF={key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`text`}},dwe={key:`level`,label:F(`Level`,`Livello`),offer:{kind:`text`}},FF={key:`temp`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},fwe={key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},IF={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{setSilentMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:F(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:F(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:F(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`auto`,label:F(`Auto`,`Auto`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAwayMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:F(`Set away mode`,`Imposta la modalità assente`),phrase:F(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:F(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:F(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:F(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:F(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`manual`,label:F(`Manual`,`Manuale`)},{value:`auto`,label:F(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:F(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:F(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:F(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`hm1`,label:F(`Programme 1`,`Programma 1`)},{value:`hm2`,label:F(`Programme 2`,`Programma 2`)},{value:`hm3`,label:F(`Programme 3`,`Programma 3`)},{value:`hm4`,label:F(`Programme 4`,`Programma 4`)},{value:`hm5`,label:F(`Programme 5`,`Programma 5`)},{value:`hm6`,label:F(`Programme 6`,`Programma 6`)},{value:`hm7`,label:F(`Programme 7`,`Programma 7`)},{value:`hm8`,label:F(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:F(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[MF,PF]}]}),setCircuitHeatCoolMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:F(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[MF,PF]}]}),setCircuitSummerWinter:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:F(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[MF,PF]}]}),setCircuitComfortSetpoint:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:F(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:F(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[MF,FF]}]}),setCircuitEcoSetpoint:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:F(`Set eco temperature`,`Imposta la temperatura eco`),phrase:F(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[MF,FF]}]}),setCircuitMaxFlowTemp:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:F(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:F(`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:[MF,FF]}]}),setDhwOperationMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:F(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[NF,PF]}]}),setDhwTemperatureLevel:A(x({deviceId:OF,circuitId:kF,level:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:F(`Set hot water level`,`Imposta il livello acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[NF,dwe]}]}),setDhwChargeDuration:A(x({deviceId:OF,circuitId:kF,minutes:n().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:F(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:F(`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:[NF,fwe]}]}),startExtraHotWater:A(x({deviceId:OF,circuitId:kF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:F(`Start extra hot water`,`Avvia acqua calda extra`),phrase:F(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[NF]}]})},vocabulary:{noun:F(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},LF=[`heating`,`dhw`,`cooling`,`solar`],RF=S(LF),zF=x({value:l().nullable(),allowed:C(l())}),BF=x({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),VF=x({id:l().min(1),kind:RF,label:l(),icon:xh,currentTemp:n().nullable().meta(N(`temperature`)),targetTemp:n().nullable().meta(N(`temperature`)),mode:l().nullable(),active:y().nullable(),operationMode:zF.nullable(),heatCoolMode:zF.nullable(),summerWinter:zF.nullable(),comfortSetpoint:BF.nullable(),ecoSetpoint:BF.nullable(),maxFlowTemp:BF.nullable(),temperatureLevel:zF.nullable(),chargeDuration:BF.nullable(),extraHotWater:y().nullable()}),HF=x({silent:zF.nullable(),away:zF.nullable(),additionalHeater:zF.nullable(),holiday:zF.nullable()}),UF=x({thermalW:n().nullable().meta(N(`power`)),electricalW:n().nullable().meta(N(`power`)),compressorPct:n().nullable().meta(N(`percentage`))}),WF=x({supply:n().nullable().meta(N(`temperature`)),return:n().nullable().meta(N(`temperature`)),outdoor:n().nullable().meta(N(`temperature`))}),GF=x({thermalKwh:n().nullable().meta(N(`energy`)),electricalKwh:n().nullable().meta(N(`energy`))}),KF=x({circuits:C(VF),system:HF,power:UF,temperatures:WF,energy:GF,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function qF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var JF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{},status:{schema:KF,kind:`push`},runtimeState:KF,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:F(`Heat pump`,`Pompa di calore`),order:4e3}},YF=x({position:n().min(0).max(100).nullable().meta(N(`percentage`)),lastFetchedAt:n()}),XF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],methods:{},status:{schema:YF,kind:`push`},runtimeState:YF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:F(`the valve opening`,`l’apertura della valvola`),label:F(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},ZF=S([`s`,`min`]),pwe=S([`switch`,`pet-fountain`]),QF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},$F={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},eI=[E.Switch,E.PetFountain],tI={[E.Switch]:[O.SwitchHeater]};function nI(e,t){return e===E.PetFountain?$F:e===E.Switch&&t===O.SwitchHeater?QF:null}var mwe=1e3,hwe=6e4;function rI(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?hwe:mwe)))}function gwe(e,t){return t===`min`?e*60:e}function iI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var aI=x({duration:n().positive().finite(),unit:ZF});function oI(e,t){let n=iI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var sI=S([`unsupported-device`,`over-max`,`command-failed`]),cI=i(`ok`,[x({ok:p(!0),activeUntil:n()}),x({ok:p(!1),reason:sI,maxSeconds:n().nullable()})]),lI=x({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:aI.nullable(),lastFetchedAt:n()}),uI=x({unit:ZF,maxDuration:n(),defaultDuration:n()}),dI=x({quickRunDuration:n().positive().finite().nullable().optional()}),fI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:eI,deviceRoles:tI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:A(x({deviceId:n().int()}),uI),setSettings:A(x({deviceId:n().int(),settings:dI}),v(),{kind:`mutation`,auth:`admin`}),runFor:A(x({deviceId:n().int(),duration:n().positive().finite(),unit:ZF}),cI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:F(`Run for minutes`,`Accendi per alcuni minuti`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:F(`Run for seconds`,`Accendi per alcuni secondi`),phrase:F(`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:F(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:A(x({deviceId:n().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:F(`Cancel the timer`,`Annulla il timer`),phrase:F(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:lI,kind:`push`},runtimeState:lI,durability:`session`,history:`none`,vocabulary:{noun:F(`Timed run`,`Esecuzione a tempo`),order:2150}},pI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],mI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],hI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],gI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],_I=S(pI),vI=S(mI),_we=S(hI),yI=x({icon:xh,tone:vI,background:S(gI),animation:_we});function bI(e){let t=RD[e];return t===void 0?null:`cap:${e}.${t.field}`}function vwe(e){return e.enabledCaps.flatMap(e=>{let t=bI(e),n=RD[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 xI=x({en:l(),it:l()}),SI={en:`—`,it:`—`};function ywe(e){return e.en===SI.en&&e.it===SI.it}var CI=[`temperature`,`humidity`,`power`,`contact`,`text`],wI=[`hot`,`mild`,`cold`],TI=[`updated`,`changed`],EI=x({value:n(),quantity:Ui}),DI=x({quantity:S(CI),reading:EI.nullable(),icon:xh.nullable(),value:xI,unit:l().nullable(),band:S(wI).nullable(),level:n().min(0).max(1).nullable(),word:xI,tone:S(mI),since:n().nullable(),sinceKind:S(TI),historyKey:l().nullable()}),bwe=3e3,OI=e=>F(e,e),kI=e=>Math.min(1,Math.max(0,e)),xwe=(e,t)=>String(Number(e.toFixed(t)));function AI(e){return e<12?`cold`:e>28?`hot`:`mild`}var Swe={hot:F(`Hot`,`Caldo`),mild:F(`Normal`,`Normale`),cold:F(`Cold`,`Freddo`)},Cwe={hot:`warning`,mild:`muted`,cold:`info`};function jI(e,t){let n=AI(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:OI(xwe(e,1)),unit:`°C`,band:n,level:null,word:Swe[n],tone:Cwe[n],since:t,sinceKind:`updated`,historyKey:bI(`temperature-sensor`)}}function MI(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:OI(String(Math.round(e))),unit:`%`,band:null,level:kI(e/100),word:n?F(`Dry`,`Secco`):r?F(`Humid`,`Umido`):F(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:bI(`humidity-sensor`)}}function NI(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:OI(String(Math.round(e))),unit:`W`,band:null,level:kI(e/bwe),word:n?F(`Active`,`Attivo`):F(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:bI(`power-meter`)}}function PI(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function FI(e,t){return{quantity:`text`,reading:null,icon:null,value:OI(e),unit:null,band:null,level:null,word:F(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var wwe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:bI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:bI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:bI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function II(e){let t=wwe[e];return{quantity:e,reading:null,icon:t.icon,value:SI,unit:t.unit,band:null,level:null,word:SI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Twe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function LI(e,t){return t===null?!0:!(Twe[e.quantity]?.has(t)??!1)}var RI=`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(`.`),Ewe=S(RI),zI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],BI=x({id:Ewe,mode:S(zI).nullable(),level:n().min(0).max(1).nullable()}),VI={[E.Camera]:`camera`,[E.Light]:`light`,[E.Siren]:`siren`,[E.Switch]:`plug`,[E.Sensor]:`sensor-sparkline`,[E.Climate]:`thermostat`,[E.Button]:`button`,[E.EventEmitter]:`event-stream`,[E.Update]:`update`,[E.Generic]:`generic`,[E.Notifier]:`event-stream`,[E.Script]:`event-stream`,[E.Automation]:`event-stream`,[E.Lock]:`lock`,[E.Cover]:`cover`,[E.Valve]:`control-dial`,[E.Humidifier]:`control-dial`,[E.WaterHeater]:`heater`,[E.HeatPump]:`heat-pump`,[E.EnergySystem]:`generic`,[E.Workload]:`generic`,[E.Fan]:`fan`,[E.MediaPlayer]:`tv`,[E.AlarmPanel]:`alarm`,[E.Control]:`control-dial`,[E.Presence]:`presence`,[E.Weather]:`weather`,[E.WeatherStation]:`weather`,[E.Vacuum]:`vacuum`,[E.LawnMower]:`lawn-mower`,[E.Container]:`generic`,[E.Image]:`camera`,[E.PetFeeder]:`pet-feeder`,[E.PetFountain]:`pet-fountain`,[E.Dishwasher]:`dishwasher`,[E.Washer]:`washer`,[E.Dryer]:`dryer`,[E.Gateway]:`gateway`},HI={[O.Siren]:`siren`,[O.Floodlight]:`light`,[O.Spotlight]:`light`,[O.PirSensor]:`presence`,[O.Chime]:`speaker`,[O.Autotrack]:`inherit`,[O.Nightvision]:`inherit`,[O.PrivacyMask]:`inherit`,[O.Doorbell]:`inherit`,[O.CoverBlind]:`inherit`,[O.CoverShutter]:`inherit`,[O.CoverAwning]:`inherit`,[O.CoverCurtain]:`inherit`,[O.CoverGarage]:`inherit`,[O.CoverGate]:`inherit`,[O.CoverDoor]:`inherit`,[O.CoverWindow]:`inherit`,[O.BinaryHelper]:`inherit`,[O.Outlet]:`plug`,[O.SwitchHeater]:`heater`,[O.SwitchFan]:`fan`,[O.SwitchLight]:`light`,[O.PoePort]:`plug`,[O.ClimateAc]:`ac`,[O.ClimateThermostat]:`inherit`,[O.ClimateFloor]:`inherit`,[O.ClimateRadiator]:`inherit`,[O.ClimateHeater]:`inherit`,[O.ClimateHeatPumpCircuit]:`inherit`,[O.MotionSensor]:`presence`,[O.ContactSensor]:`contact`,[O.LeakSensor]:`inherit`,[O.SmokeSensor]:`alarm`,[O.COSensor]:`alarm`,[O.GasSensor]:`alarm`,[O.TamperSensor]:`inherit`,[O.VibrationSensor]:`inherit`,[O.ConnectivitySensor]:`inherit`,[O.SoundSensor]:`inherit`,[O.BinarySensor]:`inherit`,[O.TemperatureSensor]:`sensor-sparkline`,[O.HumiditySensor]:`sensor-sparkline`,[O.AmbientLightSensor]:`inherit`,[O.PressureSensor]:`weather`,[O.WindSensor]:`weather`,[O.RainSensor]:`weather`,[O.UvSensor]:`weather`,[O.SolarRadiationSensor]:`weather`,[O.SoilMoistureSensor]:`inherit`,[O.PowerSensor]:`plug`,[O.EnergySensor]:`plug`,[O.VoltageSensor]:`plug`,[O.CurrentSensor]:`plug`,[O.AirQualitySensor]:`inherit`,[O.BatterySensor]:`inherit`,[O.NumericSensor]:`inherit`,[O.EnumSensor]:`inherit`,[O.DateTimeSensor]:`inherit`,[O.GenericSensor]:`inherit`,[O.NumericControl]:`control-dial`,[O.SelectControl]:`control-dial`,[O.TextControl]:`inherit`,[O.DateTimeControl]:`inherit`,[O.MobilePushNotifier]:`inherit`,[O.MessagingNotifier]:`inherit`,[O.EmailNotifier]:`inherit`,[O.GenericNotifier]:`inherit`,[O.IrTransmitter]:`inherit`,[O.Vm]:`inherit`,[O.AppContainer]:`inherit`,[O.Lxc]:`inherit`,[O.App]:`inherit`,[O.Host]:`inherit`,[O.Ups]:`inherit`};function Dwe(e){return Object.values(E).includes(e)}function Owe(e){return Object.values(O).includes(e)}function UI(e,t){let n=e!==null&&Owe(e)?HI[e]:void 0;return n!==void 0&&n!==`inherit`?n:Dwe(t)?VI[t]:`generic`}var WI=`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(`.`),GI=S(WI),kwe={progress:F(`Progress`,`Avanzamento`),"run-for":F(`Run for`,`Avvia per`),cycle:F(`Cycle`,`Ciclo`),program:F(`Program`,`Programma`),"appliance-power":F(`Appliance`,`Elettrodomestico`),"now-playing":F(`Now playing`,`In riproduzione`),playback:F(`Playback`,`Riproduzione`),volume:F(`Volume`,`Volume`),source:F(`Source`,`Sorgente`),contact:F(`Door`,`Porta`),"motion-trigger":F(`Motion`,`Movimento`),lock:F(`Lock`,`Serratura`),alarm:F(`Alarm`,`Allarme`),fan:F(`Fan`,`Ventola`),vacuum:F(`Cleaning`,`Pulizia`),"vacuum-suction":F(`Suction`,`Aspirazione`),mower:F(`Mowing`,`Taglio`),feeder:F(`Feed now`,`Eroga ora`),fountain:F(`Pump`,`Pompa`),"pump-cycle":F(`Pump cycle`,`Ciclo pompa`),automation:F(`Automation`,`Automazione`),script:F(`Script`,`Script`),"do-not-disturb":F(`Do not disturb`,`Non disturbare`),brightness:F(`Brightness`,`Luminosità`),color:F(`Colour`,`Colore`),cover:F(`Position`,`Posizione`),valve:F(`Valve`,`Valvola`),humidifier:F(`Humidifier`,`Umidificatore`),update:F(`Firmware`,`Firmware`),button:F(`Action`,`Azione`),"climate-mode":F(`Mode`,`Modalità`),"climate-fan":F(`Fan`,`Ventola`),setpoint:F(`Setpoint`,`Temperatura`),channel:F(`Channel`,`Canale`),control:F(`Control`,`Controllo`),circuit:F(`Circuit`,`Circuito`),"heat-pump-power":F(`Power`,`Potenza`),"system-mode":F(`Mode`,`Modalità`)},KI=a(()=>h([l(),n(),y(),m(l(),KI)])),Awe=m(l(),KI);function qI(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]:qI(o,i,n)}}function jwe(e,t,n){return qI(e,t.split(`.`),n)}var JI=x({cap:l(),method:l(),args:Awe}),Mwe=S([`off-while-running`,`unlock`,`install`,`press`]),YI=x({id:l(),label:xI,icon:xh,call:JI,emphasis:S([`primary`,`normal`]),confirm:Mwe.nullable()}),XI=i(`kind`,[x({kind:p(`action`),action:YI}),x({kind:p(`toggle`),id:l(),label:xI,on:y().nullable(),turnOn:YI,turnOff:YI}),x({kind:p(`slider`),id:l(),label:xI,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:JI,valueArg:l()}),x({kind:p(`picker`),id:l(),label:xI,current:l().nullable(),options:C(l()),optionLabels:m(l(),xI).optional(),call:JI,valueArg:l()}),x({kind:p(`number`),id:l(),label:xI,value:n().nullable(),step:n().nullable(),unit:l(),call:JI,valueArg:l()}),x({kind:p(`text`),id:l(),label:xI,value:l().nullable(),call:JI,valueArg:l()})]),Nwe=x({icon:xh.nullable(),text:xI,tone:vI}),Pwe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Fwe=x({id:GI,placement:S([`row`,`scene`]).optional(),label:xI.optional(),group:xI.optional(),pills:C(Nwe).optional(),icon:xh,status:xI.nullable(),controls:C(XI),progress:n().min(0).max(1).nullable().optional()}),ZI=x({label:xI,value:h([n(),l()]),unit:l().nullable()}),Iwe=x({id:S([`battery`,`network-link`,`integration`]),icon:xh,tone:vI,value:n().nullable(),label:xI}),QI=`remote.open`,Lwe=x({commands:n().int().nullable(),open:YI.optional()}),Rwe=x({items:C(x({key:l(),label:l(),level:n().nullable(),needsAttention:y()})),attention:n().int()}),zwe=i(`kind`,[x({kind:p(`power`),watts:n(),detail:C(ZI)}),x({kind:p(`running`),running:y().nullable(),since:n().nullable(),phase:l().nullable(),detail:C(ZI)})]),Bwe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:YI,turnOff:YI}),Vwe=x({activeUntil:n().nullable(),quickRun:aI,run:YI,cancel:YI,remaining:n().nullable()}),Hwe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:YI.nullable(),powerOff:YI.nullable(),restart:YI}),$I=x({token:S(gI),animation:S(hI)}),eL=x({id:S([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:xh.nullable(),text:xI,tone:vI}),tL=x({label:xI,value:xI,tone:vI.optional(),at:n().optional()}),Uwe=x({left:C(tL).max(2),right:C(tL).max(2)}),Wwe=i(`kind`,[x({kind:p(`artwork`),url:l(),fallback:$I}),x({kind:p(`state`),...$I.shape})]),Gwe=x({partId:l(),cap:l()}),Kwe=x({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:_I,stateAssumed:y(),look:yI,background:Wwe,scene:BI,facts:C(eL),sideTiles:Uwe,title:xI,caption:xI.optional(),badges:C(Iwe),remote:Lwe.nullable(),historyLabel:xI,consumables:Rwe.nullable(),consumption:zwe.nullable(),ownPower:Bwe.nullable(),timedRun:Vwe.nullable(),powerSupply:Hwe.nullable(),rows:C(Fwe),measurement:DI.optional(),gated:C(l()),provenance:C(Gwe)}),qwe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:S([`min`,`s`])}),nL=x({deviceId:n().int(),name:l(),type:l(),state:_I,stateAssumed:y(),look:yI,scene:BI,statusLine:C(xI),primary:XI.nullable(),primaryGated:y().optional(),timedRun:qwe.nullable(),extras:C(XI).max(2).optional(),trailing:eL.nullable(),measurement:DI.optional()}),rL=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Jwe=[`power`,`battery`,`consumables`],Ywe=new Set(rL);function Xwe(e){for(let t of Jwe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Ywe.has(t.id)&&t.text.en===e.title.en)??null}var Zwe={[E.Climate]:`climate.mode`};function Qwe(e){let t=Zwe[e.type];if(t!==void 0){let n=aL(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 $we={[E.Climate]:[`climate.target`],[E.Vacuum]:[`vacuum.base`],[E.LawnMower]:[`mower.dock`],[E.MediaPlayer]:[`volume.level`,QI],[E.Automation]:[`automation.enabled`]},iL=e=>e.kind===`action`?e.action.id:e.id;function aL(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=>iL(e)===t);if(r!==void 0)return r}return null}function eTe(e,t){let n=$we[e.type]??[],r=t===null?null:iL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=aL(e,t);return n===null?[]:[n]}).slice(0,2)}function tTe(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 nTe(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 rTe(e){let t=Xwe(e),{control:n,gated:r}=Qwe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:tTe(e,t),primary:n,primaryGated:r,timedRun:nTe(e),extras:eTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var iTe=x({deviceId:n().int().nonnegative(),canActuate:y().optional()}),aTe=500,oTe=x({deviceIds:C(n().int().nonnegative()).max(500),canActuate:y().optional()}),oL=x({type:l(),rows:C(GI)}),sL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:A(iTe,Kwe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:A(oTe,C(nL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:A(x({deviceType:l(),role:l().nullable().optional()}),oL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},cL=x({on:y(),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),mode:l().nullable(),availableModes:C(l()),action:l().nullable(),minHumidity:n().nullable().meta(N(`humidity`)),maxHumidity:n().nullable().meta(N(`humidity`)),lastChangedAt:n()}),lL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:F(`Humidifier on`,`Umidificatore acceso`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:F(`Humidifier off`,`Umidificatore spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:A(x({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:A(x({deviceId:n().int().nonnegative(),mode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:cL,kind:`push`},runtimeState:cL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:F(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},uL=x({humidity:n().min(0).max(100).nullable().meta(N(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),dL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Climate],methods:{},status:{schema:uL,kind:`push`},runtimeState:uL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},fL=x({url:l().nullable(),lastUpdated:n().nullable().meta(N(`none`))}),pL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Image],methods:{},status:{schema:fL,kind:`push`},runtimeState:fL,durability:`session`,history:`none`,vocabulary:{noun:F(`Image`,`Immagine`),order:3130}},mL=S([`0`,`90`,`180`,`270`]),hL=S([`auto`,`manual`]),gL=S([`auto`,`manual`]),_L=S([`off`,`blc`,`wdr`,`hlc`]),vL=x({min:n(),max:n(),step:n()}),yL=x({brightness:n().optional().meta(N(`none`)),contrast:n().optional().meta(N(`none`)),saturation:n().optional().meta(N(`none`)),sharpness:n().optional().meta(N(`none`)),mirror:y().optional(),flip:y().optional(),rotate:mL.optional(),whiteBalance:hL.optional(),warmth:n().optional().meta(N(`none`)),exposureMode:gL.optional(),backlightMode:_L.optional(),lastFetchedAt:n()}),bL=x({supportsBrightness:y(),brightness:vL.optional(),supportsContrast:y(),contrast:vL.optional(),supportsSaturation:y(),saturation:vL.optional(),supportsSharpness:y(),sharpness:vL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(mL),whiteBalanceModes:C(hL),supportsWarmth:y(),warmth:vL.optional(),exposureModes:C(gL),backlightModes:C(_L)}),xL=x({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:y().optional(),flip:y().optional(),rotate:mL.optional(),whiteBalance:hL.optional(),warmth:n().optional(),exposureMode:gL.optional(),backlightMode:_L.optional()}),SL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),bL),setSettings:A(x({deviceId:n(),settings:xL}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:yL,kind:`poll`},runtimeState:yL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Image settings`,`Impostazioni immagine`),order:3140}},CL=x({id:l(),addonId:l(),name:l(),enabled:y(),switchUnknown:p(!0).optional(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),wL=x({id:l(),addonId:l(),name:l(),enabled:y(),switchUnknown:p(!0).optional(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),TL=x({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:S([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:l(),name:l()})),canAdd:y()}),EL=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),DL=x({success:y(),error:l().optional(),status:EL.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),OL=x({id:l(),name:l().optional(),enabled:y().optional(),info:m(l(),w()).optional()}),kL=x({success:y(),deletedId:l()}),AL={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:A(v(),C(CL)),get:A(x({id:l()}),CL),getByAddonId:A(x({addonId:l()}),wL.nullable()),update:A(OL,wL,{kind:`mutation`,auth:`admin`}),delete:A(x({id:l()}),kL,{kind:`mutation`,auth:`admin`}),getAvailableTypes:A(v(),C(TL),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},sTe=ve(),jL=l().min(1),ML=S([`single`,`multiple`]),NL=S([`devices`,`services`]),PL=x({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:C(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:NL.optional(),canTest:y().optional(),signIn:x({basePath:l().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:C(x({id:l().min(1),placement:S([`connection`,`model`])})).optional()}),FL=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),IL=x({kind:l().min(1),field:l().min(1),to:x({cap:l().min(1),kind:l().min(1).optional()})}),LL=x({role:NL,discovery:FL.optional(),instanceMode:ML,kind:l(),canTest:y(),kinds:C(PL).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(IL).optional(),userScoped:y().optional()}),RL=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),zL=S([`scan`,`children`,`none`]),BL=x({id:jL,name:l(),configured:y(),enabled:y().optional(),kind:l().min(1),formValues:m(l(),w()),status:RL.optional(),lastCheckedAt:n().optional(),addDevice:zL.optional()}),VL=x({id:jL,name:l().min(1).optional(),values:m(l(),w())}),HL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:A(v(),LL,{auth:`admin`}),instanceFormSchema:A(x({id:jL.nullable(),kind:l().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),sTe,{auth:`admin`}),listInstances:A(se({}),C(BL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:A(x({id:jL}),BL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:A(x({id:jL.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),w()).optional(),originStableId:l().min(1).optional(),seed:x({info:m(l(),w())}).optional()}),x({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:A(VL,x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:A(x({id:jL,enabled:y()}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:A(x({id:jL}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:j(x({id:jL.nullable(),values:m(l(),w()),kind:l().min(1).optional()}),DL,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:M.INTERNAL}},UL=x({codecs:C(l()),sampleRate:n().meta(N(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:n().meta(N(`duration-ms`))}),WL=x({talking:y(),lastSessionAt:n().nullable(),ability:UL.nullable()}),cTe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),GL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{startSession:A(x({deviceId:n()}),x({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:A(x({deviceId:n(),sessionId:l(),sdpAnswer:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:A(x({deviceId:n(),sessionId:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:A(x({deviceId:n()}),x({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:A(x({deviceId:n(),audioBase64:l(),codec:cTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:n(),status:WL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:WL,kind:`command-driven`},runtimeState:WL,durability:`session`,history:`none`,vocabulary:{noun:F(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:F(`Talking`,`In conversazione`),whenTrue:F(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:F(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},KL=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),qL=S([`ir`,`rf`]),JL=x({ok:p(!0),ignoredSettings:C(l())}),YL=x({media:C(qL),settable:C(KL),maxTimings:n().int().positive(),learn:y().default(!1),formats:C(fE).default([])}),XL=2e4,ZL=6e4,QL=x({native:mE.nullable(),timings:rE,carrierHz:n().int().positive().nullable()}),$L=x({at:n(),ok:y(),error:l().nullable()}),eR=$L.extend({medium:qL}),tR=x({lastSend:eR.nullable(),lastLearn:$L.nullable(),lastFetchedAt:n()});function nR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function lTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return nR(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 uTe(e){return Or(e)?.code??null}var rR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Generic],methods:{send:A(x({deviceId:n().int().nonnegative(),timings:rE.optional(),native:mE.optional(),settings:iE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),JL,{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:A(x({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(ZL).default(XL)}),QL,{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:A(x({deviceId:n().int().nonnegative()}),YL,{kind:`query`,auth:`protected`})},runtimeState:tR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},iR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),aR=i(`state`,[x({state:p(`ready`)}),x({state:p(`locked`),reason:iR})]),oR=i(`kind`,[x({kind:p(`value`),value:l(),version:n().int()}),x({kind:p(`missing`)}),x({kind:p(`unavailable`),reason:iR}),x({kind:p(`forbidden`)})]),sR=m(l(),oR),cR=x({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),dTe=512,lR=C(l().min(1)).max(512),uR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:A(x({refs:lR}),sR,{auth:`admin`}),delete:A(x({refs:lR}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:A(x({deviceId:n().int()}),x({refs:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:A(x({refs:lR,onBehalfOf:l().min(1)}),x({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:A(x({}),C(cR).readonly(),{auth:`admin`}),getState:A(x({}),aR,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},dR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),fR=x({kind:dR,path:l().optional(),sharesBackupWithDatabase:y()}),fTe=`trigger-file`,pR=x({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:C(l()).readonly(),acknowledgedAt:n().nullable()}),mR=x({keychain:aR,keySource:fR.nullable(),configuredSource:fR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:y(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:pR.nullable()}),hR=S([`in-use`,`orphan`,`unknown`]),gR=cR.extend({usage:hR}),_R=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),vR=x({id:l(),at:n(),action:_R,actor:l(),ref:l().nullable(),detail:l().nullable()}),yR=`RESET KEYCHAIN`,bR=S([`jwt-signing-key`]),xR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:A(x({}),mR,{auth:`admin`}),listSecrets:A(x({}),C(gR).readonly(),{auth:`admin`}),listAudit:A(x({limit:n().int().min(1).max(500).optional()}),C(vR).readonly(),{auth:`admin`}),reveal:A(x({ref:l().min(1)}),x({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:A(x({name:bR,value:l().min(16)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:A(x({refs:C(l().min(1)).max(1e3)}),x({deleted:C(l()).readonly(),kept:C(x({ref:l(),usage:hR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:A(x({}),x({fingerprint:l(),keySource:fR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:A(x({}),x({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:A(x({}),x({key:l(),fingerprint:l(),keySource:fR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:A(x({confirm:p(yR)}),x({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:A(x({}),x({reset:pR.nullable(),pendingReentry:C(cR).readonly()}),{auth:`admin`}),acknowledgeReset:A(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:M.IDENTITY}},SR=S([`idle`,`mowing`,`paused`,`docked`,`error`]),CR=S([`info`,`warning`,`error`]),wR=x({activity:SR,batteryLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),currentCode:n().nullable().meta(N(`none`)),currentCodeLabel:l().nullable(),severity:CR,lastChangedAt:n()}),TR={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.LawnMower],methods:{startMowing:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:F(`Start mowing`,`Avvia il taglio`),phrase:F(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:F(`Pause mower`,`Metti in pausa il tosaerba`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:F(`Dock mower`,`Riporta alla base`),phrase:F(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:wR,kind:`push`},runtimeState:wR,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:F(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`mowing`,label:F(`Mowing`,`In taglio`),phrase:F(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`docked`,label:F(`Docked`,`Alla base`),phrase:F(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},ER=6e5,pTe=60*6e4,DR=x({inputTokens:n(),outputTokens:n()}),OR=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),kR=x({ok:p(!0),text:l(),model:l(),usage:DR,truncated:y(),latencyMs:n()}),AR=S([`guardrail`,`model`]),jR=x({ok:p(!1),code:OR,message:l(),retryAfterMs:n().optional(),refusalSource:AR.optional()}),MR=i(`ok`,[kR,jR]),NR=x({bytes:b(Uint8Array),mimeType:l()}),PR=x({enabled:y().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),mTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},FR=x({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),w()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:PR.optional(),requestId:l().optional()}),IR=x({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),LR=i(`kind`,[x({kind:p(`catalog`),catalogId:l()}),x({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:C(IR).optional()}),x({kind:p(`path`),path:l()})]),RR=x({nodeId:l(),engine:S([`llama-cpp`]),model:LR,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(l()).default([]),autoStart:y().default(!1),idleStopMinutes:n().int().default(30)}),zR=x({phase:S([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),BR=x({nodeId:l(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:zR.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),VR=x({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),HR=x({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),UR=FR.extend({images:C(NR).optional(),runtime:RR,timeoutMs:n().int().positive().optional()}),WR=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),GR=i(`state`,[x({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:C(l()),imageInput:y()}),x({state:p(`unavailable`),reason:WR,osVersion:l().nullable(),detail:l()}),x({state:p(`unsupported-platform`),platform:l()}),x({state:p(`unknown`),error:l()})]),KR=FR.extend({images:C(NR).optional(),timeoutMs:n().int().positive().optional()}),qR=x({requestId:l()}),JR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:A(UR,MR,{kind:`mutation`,auth:`admin`,timeoutMs:ER}),ensureStarted:A(x({runtime:RR}),BR,{kind:`mutation`,auth:`admin`,timeoutMs:ER}),stop:A(x({}),v(),{kind:`mutation`,auth:`admin`}),status:A(x({}),BR,{auth:`admin`}),installModel:A(x({model:LR}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:pTe}),deleteModel:A(x({file:l()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:A(x({}),C(VR),{auth:`admin`}),getDiskUsage:A(x({}),HR,{auth:`admin`}),cancel:A(qR,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:A(x({}),GR,{auth:`admin`}),completeApple:A(KR,MR,{kind:`mutation`,auth:`admin`,timeoutMs:ER})},vocabulary:{notOperatorFacing:M.ML}},YR=/^[a-z0-9][a-z0-9-]{0,63}$/,XR=l().regex(YR,`a kind id is lower-case letters, digits and dashes`),ZR=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),QR=x({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:ZR.partial().optional()}),$R=m(l(),w()),hTe=x({id:l(),name:l(),kind:XR,addonId:l(),enabled:y(),model:l(),supportsVision:y(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:PR.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:$R.default({})}),ez=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),tz=x({id:l(),placement:S([`connection`,`model`]),requires:C(l()).optional()}),nz=w(),gTe=x({kind:XR,label:l(),icon:l(),addonId:l(),connectionSchema:nz,advancedSchema:nz.optional(),features:ZR,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(QR).optional(),profileFields:C(ez),providerWidgets:C(tz).optional()}),rz=x({addonId:l(),kind:XR,profileId:l().optional(),connection:$R.optional()}),iz=S([`auth`,`network`,`unsupported`,`invalid`]),az=i(`ok`,[x({ok:p(!0),models:C(QR)}),x({ok:p(!1),code:iz,message:l()})]),oz=h([x({consumer:l()}),x({purpose:S([`text`,`vision`])})]),sz=x({selector:oz,profileId:l()}),cz=x({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),lz=x({id:l(),label:l(),family:l(),purpose:S([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),uz=i(`ok`,[x({ok:p(!0),model:LR,label:l(),repo:l(),quantization:l(),purpose:S([`text`,`vision`]),totalBytes:n(),extraFilenames:C(l())}),x({ok:p(!1),code:l(),message:l(),candidates:C(l()).optional(),requiredBytes:n().optional()})]),dz=x({nodeId:l(),reachable:y(),status:BR.optional(),disk:HR.optional(),error:l().optional(),apple:GR.optional()}),_Te=FR.extend({images:C(NR).min(1)}),fz=x({addonId:l(),profileId:l()}),pz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:A(FR,MR,{kind:`mutation`,timeoutMs:ER}),generateVision:A(_Te,MR,{kind:`mutation`,timeoutMs:ER}),cancel:A(x({addonId:l().optional(),requestId:l()}),v(),{kind:`mutation`}),listModels:A(rz,az,{kind:`mutation`,auth:`admin`}),getDefaults:A(x({}),C(sz)),setDefault:A(x({selector:oz,profileId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:A(x({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),C(cz)),listModelCatalog:A(x({}),C(lz)),listRuntimeNodes:A(x({}),C(dz)),listNodeModels:A(x({nodeId:l()}),C(VR)),resolveModelRef:A(x({ref:l(),maxBytes:n().positive().optional()}),uz,{kind:`mutation`,auth:`admin`}),installModel:A(x({nodeId:l(),model:LR}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:A(x({nodeId:l(),file:l()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:A(fz,BR),startRuntime:A(fz,BR,{kind:`mutation`,auth:`admin`}),stopRuntime:A(fz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},mz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],hz=[`measured`,`accounted`,`unattributable`],gz=x({role:S(mz),deviceId:n().int().positive().nullable(),attribution:S(hz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),_z={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(gz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},vz=`https://camstack.zentik.app`,yz=`/viewer/camstack`;function bz(e){if(e==null||e===``)return!1;try{return new URL(e).origin===vz}catch{return!1}}function vTe(e){let t=e.baseUrl??e.resolved;return bz(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function xz(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 yTe(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=xz(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 bTe(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 Sz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function xTe(e){let t=bTe(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:xz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${vz}${t.path}${Sz(n)}`}return r===``||bz(r)?null:`${r}${yz}${t.path}${Sz(t.query)}`}var Cz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],STe=[`notificationTaps`,`internal`,`publicEndpoint`];function CTe(e){return e!==`appConnections`}var wTe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},TTe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function wz(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function ETe(e){return e.replace(/\/+$/,``)}function Tz(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function DTe(e){return e.kind===`public`&&e.interfaceKind===`public`}function Ez(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function Dz(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=wz(e.baseUrl);return t!==null&&TTe.test(t)}function Oz(e){return e.stable===!1}function OTe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||wz(t.baseUrl)===null||Oz(t)?null:e===`internal`?Dz(t)?0:Ez(t)?1:Tz(t)?2:null:DTe(t)?0:Tz(t)?1:Dz(t)?2:Ez(t)?3:null}var kTe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function ATe(e){let t=e.toLowerCase();return kTe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function kz(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.`}:ATe(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 Az=`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 jz(e,t,n={}){if(bz(t))return e===`notificationTaps`?{ok:!0,baseUrl:vz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=kz(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:Az}:r}function Mz(e,t){if(t===null||t===``)return null;let n=jz(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function jTe(e,t){let n=e.flatMap(e=>{let n=OTe(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:ETe(n.endpoint.baseUrl)}function Nz(e,t,n){let r=Mz(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=jTe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function Pz(e,t){return Nz(e,`internal`,t.internal)}function Fz(e,t){return Nz(e,`publicEndpoint`,t.publicEndpoint)}function Iz(e){let t=Mz(`notificationTaps`,e.notificationTaps);return t!==null&&!bz(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:vz,source:`auto`}}function Lz(e){return Oz(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function Rz(e,t){let n=e.filter(Lz);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 zz(e,t){let n=new Set(t.appConnections),r=Rz(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 MTe(e,t,n){return{appConnections:zz(e,n),notificationTaps:Iz(n),internal:Pz(t,n),publicEndpoint:Fz(t,n)}}function NTe(e){return e===null?null:wz(e)}var PTe=`camstack`,FTe=`_camstack._tcp.local`,ITe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},LTe=`hub`,Bz=/^hub-[0-9a-f]{16}$/;function RTe(e){return typeof e==`string`&&Bz.test(e)}var zTe=`camstack-agent`,BTe=`_camstack-agent._tcp.local`,VTe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},HTe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),Vz=x({name:l(),family:S([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:y(),mac:l(),kind:HTe,preferred:y(),plausible:y(),plausibleReason:l()}),UTe=x({interfaces:C(Vz).readonly(),probedAt:n()}),WTe=Vz.nullable(),Hz=x({label:l(),baseUrl:l(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:l(),priority:n(),stable:y().optional()}),GTe=S([`server-config`,`server-env`,`caller-hint`,`default`]),KTe=x({port:n().int().min(1).max(65535),source:GTe}),qTe=x({endpoints:C(Hz).readonly(),localPort:KTe}),Uz=x({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),Wz=x({baseUrls:C(l()).readonly(),resolved:C(l()).readonly()}),Gz=x({override:l().nullable(),resolved:l().nullable(),source:S([`override`,`auto`,`none`])}),JTe=x({cluster:Gz,browser:Gz}),Kz=S(Cz),qz=S([`flagged`,`auto`,`none`]),Jz=x({flagged:l().nullable(),resolved:l().nullable(),source:qz}),YTe=x({flagged:C(l()).readonly(),resolved:C(l()).readonly(),source:qz}),Yz=x({rows:C(Hz.extend({detected:y(),custom:y(),flags:C(Kz).readonly(),inUse:C(Kz).readonly(),eligible:C(Kz).readonly()})).readonly(),roles:x({appConnections:YTe,notificationTaps:Jz,internal:Jz,publicEndpoint:Jz}),appLinkHub:l().nullable(),listenerOrigins:C(l()).readonly().optional()}),Xz=x({addresses:C(l()).readonly()}),Zz=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:C(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:l().nullable(),storedUpload:x({leafFingerprintSha256:l(),validTo:l(),hasCa:y()}).nullable()}),XTe=x({providerId:l().min(1),modes:C(Sj)}),ZTe=x({providerId:l().optional(),mode:l().optional(),message:l()}),QTe=x({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),x({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),$Te=x({hits:C(x({providerId:l(),hit:Cj})),subnetsScanned:C(l()),errors:C(ZTe),stats:QTe}),Qz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:A(v(),UTe),getPreferred:A(v(),WTe),getConnectionEndpoints:A(x({port:n().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),qTe),getNotificationEndpoint:A(v(),Uz),setNotificationEndpoint:A(x({baseUrl:l().nullable()}),Uz,{kind:`mutation`}),getViewerEndpoints:A(v(),Wz),setViewerEndpoints:A(x({baseUrls:C(l()).readonly()}),Wz,{kind:`mutation`}),getAddresses:A(x({scheme:S([`http`,`https`]).optional()}).optional(),Yz),addCustomAddress:A(x({baseUrl:l(),label:l().max(80)}),Yz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:A(x({baseUrl:l()}),Yz,{kind:`mutation`,auth:`admin`}),setAddressRole:A(x({role:Kz,baseUrl:l().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),Yz,{kind:`mutation`,auth:`admin`}),getHubAddresses:A(v(),JTe),getAllowedAddresses:A(v(),Xz),setAllowedAddresses:A(Xz,x({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:A(v(),Xz,{kind:`mutation`}),getTlsStatus:A(v(),Zz),regenerateCertificate:A(x({reason:l().optional()}),Zz,{kind:`mutation`,auth:`admin`}),uploadCertificate:A(x({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),Zz,{kind:`mutation`,auth:`admin`}),downloadCa:A(v(),x({pem:l()})),useStoredUploadedCertificate:A(v(),Zz,{kind:`mutation`,auth:`admin`}),scanNetwork:A(x({requests:C(XTe),subnets:C(l()).optional()}),$Te,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:A(v(),x({subnets:C(l())}),{auth:`admin`}),setScanSubnets:A(x({subnets:C(l())}),x({subnets:C(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:A(v(),Zz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:M.NETWORK}},$z=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),eB=x({state:$z,codeRequired:y().nullable().optional(),lastChangedAt:n()}),eEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[E.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},tB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Lock],methods:{lock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:F(`Lock`,`Chiudi a chiave`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:F(`Unlock`,`Apri la serratura`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:F(`Open latch`,`Apri lo scrocco`),phrase:F(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:eB,kind:`push`},runtimeState:eB,customize:eEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:F(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:F(`Locked`,`Chiusa a chiave`),phrase:F(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:F(`Unlocked`,`Sbloccata`),phrase:F(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:F(`Locking`,`In chiusura`),phrase:F(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:F(`Unlocking`,`In apertura`),phrase:F(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:F(`Jammed`,`Inceppata`),phrase:F(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:F(`Door open`,`Porta aperta`),phrase:F(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},nB=x({armed:n().int().min(0),unknown:C(l()).readonly()}),rB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(ih).readonly()),apply:A(x({windows:C(ah).readonly()}),nB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},iB=S([`debug`,`info`,`warn`,`error`]),aB=x({timestamp:g(),level:iB,scope:C(l()),message:l(),meta:m(l(),w()).optional(),tags:m(l(),l()).optional()}),oB=x({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:iB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),sB=x({id:l().optional(),timestamp:n(),level:iB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),w()).optional()}),cB=x({entries:C(sB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:y(),cancelled:y().optional()}),tEe=x({instanceId:l().min(1).max(200).optional()}),lB=x({readable:y(),reason:l().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:n().nullable()}),uB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:A(aB,v(),{kind:`mutation`}),describeRead:j(tEe,lB,{auth:`admin`}),read:j(oB,cB,{auth:`admin`}),cancelRead:j(x({requestId:l().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},dB=S([`primary`,`second-factor`]),fB=x({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:dB,linkable:y().optional(),app:eg.nullable().optional()}),pB=x({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:Lx,stage:dB,app:eg.nullable().optional()}),mB=x({kind:p(`passkey`),id:l(),label:l(),stage:dB,rpId:l(),origin:l().nullable(),app:eg.nullable().optional()}),hB=i(`kind`,[fB,pB,mB]),gB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:A(v(),C(hB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},_B=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(N(`none`))}),vB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{wakeUp:A(x({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:_B,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:_B,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},nEe=x({id:l(),label:l(),scope:S([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`])}),yB=x({id:l(),hostname:l(),magicDns:l(),addresses:C(l()).readonly(),os:l().optional(),online:y(),lastSeenMs:n(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:C(l()).readonly(),exitNodeOption:y(),advertisedRoutes:C(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),bB=x({joined:y(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:C(nEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),xB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:A(v(),bB),join:A(x({authKey:l().min(8),hostname:l().optional()}),x({joined:p(!0)}),{kind:`mutation`}),startLogin:A(x({hostname:l().optional()}),x({loginUrl:l()}),{kind:`mutation`}),leave:A(v(),x({left:p(!0)}),{kind:`mutation`}),logout:A(v(),x({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:A(v(),x({peers:C(yB).readonly()}))},vocabulary:{notOperatorFacing:M.NETWORK}},SB=x({value:n().nullable().meta(N(`device`,{label:`Total`})),lastFetchedAt:n()}),CB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:SB,kind:`push`},runtimeState:SB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:F(`the total`,`il totale`),label:F(`Total`,`Totale`),icon:`gauge`}]}},rEe=x({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),iEe=x({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),aEe=x({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),oEe=x({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),wB=x({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),sEe=x({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),TB=x({avg10:n(),avg60:n(),avg300:n()}),EB=x({some:TB,full:TB.nullable()}),DB=x({cpu:rEe,memory:iEe,gpu:wB.nullable(),network:oEe,disk:aEe,pressure:x({cpu:EB.nullable(),memory:EB.nullable(),io:EB.nullable()}),process:sEe,cpuTemperature:n().nullable(),timestampMs:n()}),cEe=x({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),OB=x({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),lEe=x({addonId:l(),nodeId:l(),role:S([`hub`,`worker`]),pid:n(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),uEe=x({pid:n(),ppid:n(),pgid:n(),classification:S([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),dEe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),fEe=x({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),pEe=x({key:l(),kind:S([`addon`,`root`,`unattributed`]),points:C(fEe).readonly()}),mEe=x({nodeId:l(),series:C(pEe).readonly(),containerMemory:C(dEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:y()}),hEe=x({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),kB=x({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),AB={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:A(v(),DB),getCached:A(v(),DB.nullable()),getCurrent:A(v(),kB),getDiskSpace:A(x({dirPath:l()}),cEe),getGpuInfo:A(v(),wB.nullable()),getCpuTemperature:A(v(),n().nullable()),getProcessStats:A(x({pids:C(n())}),C(OB)),listAddonInstances:A(v(),C(lEe).readonly()),getAddonStats:A(x({addonId:l()}),OB.nullable()),listNodeProcesses:A(v(),C(uEe).readonly()),getLoadSeries:A(hEe,mEe)},vocabulary:{notOperatorFacing:M.CLUSTER}},jB=l().min(1).max(256),MB=m(l(),w()),NB=x({id:jB,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:MB}),PB=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:MB}),FB=m(Hr,h([l(),n(),y(),x({in:C(h([l(),n(),y()])).min(1).max(_n)}),x({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),IB={kind:Jr},LB={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},RB=x({...IB,...LB,where:FB.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:n().int().min(1).max(yn).default(100),cursor:l().min(1).optional()}),zB=x({records:C(PB),nextCursor:l().nullable()}),gEe=S([`created`,`unchanged`,`updated`]),BB=x({kindId:n().int(),state:gEe,createdIndexes:C(l())}),VB=C(l()),HB=i(`op`,[x({op:p(`put`),kind:Jr,record:NB,ifRev:n().int().min(0).optional()}),x({op:p(`patch`),kind:Jr,id:jB,data:MB,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({op:p(`delete`),kind:Jr,id:jB})]),UB=m(l(),m(l(),l())),WB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:A(x({kinds:m(Jr,qr)}),x({kinds:m(l(),BB)}),{kind:`mutation`,auth:`admin`}),get:A(x({...IB,id:jB}),PB.nullable(),{auth:`admin`}),getMany:A(x({...IB,ids:C(jB).min(1).max(_n)}),C(PB),{auth:`admin`}),secretRefs:A(x({...IB,ids:C(jB).min(1).max(_n)}),UB,{auth:`admin`}),put:A(x({...IB,record:NB,ifRev:n().int().min(0).optional()}),x({rev:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),putMany:A(x({...IB,records:C(NB).min(1).max(_n)}),x({count:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),patch:A(x({...IB,id:jB,data:MB,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({rev:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),delete:A(x({...IB,id:jB}),x({deleted:y(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),deleteMany:A(x({...IB,ids:C(jB).min(1).max(_n)}),x({deleted:n().int(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),query:A(RB,zB,{auth:`admin`}),count:A(x({...IB,...LB,where:FB.optional()}),x({count:n().int()}),{auth:`admin`}),histogram:A(x({...IB,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),x({buckets:C(x({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:A(x({...IB,op:S([`sum`,`min`,`max`,`count`]),field:Hr.optional(),groupBy:Hr.optional(),where:FB.optional()}),x({rows:C(x({group:h([l(),n(),ae()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:A(x({...IB,deviceId:n().int().optional(),atBefore:n().optional(),where:FB.optional()}),x({deleted:n().int(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),transact:A(x({ops:C(HB).min(1).max(_n)}),x({results:C(x({rev:n().int().nullable(),deleted:y()})),releasedRefs:VB,secretRefs:VB}),{kind:`mutation`,auth:`admin`}),deleteDevice:A(x({deviceId:n().int(),kinds:C(Jr).optional()}),x({deleted:m(l(),n().int()),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),allocateId:A(x(IB),x({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},GB=m(l(),w()),KB=x({integrationId:l().min(1)}),qB=x({id:l().min(1)}),JB=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:GB}),YB={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:GB},XB=x({id:l(),addonId:l(),name:l(),info:GB,enabled:y().optional(),originStableId:l().optional()}),_Ee=x({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),ZB=x({version:n().int(),methods:C(l())}),QB=x({message:l(),meta:GB.optional(),tags:x({deviceId:n().int().optional()}).optional()}),vEe={"ledger.declare":{input:x({owner:l().min(1),metas:C(rf)}),output:x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(vf),migrationApi:ZB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:l().min(1)}),output:x({proceed:y(),state:h([p(`pending`),mf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:l().min(1),result:pf}),output:x({status:mf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:KB,output:GB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:KB,output:x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:KB.extend({patch:GB}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:KB.extend({keys:C(l().min(1))}),output:x({present:y(),removed:GB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:qB,output:JB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:qB,output:JB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...YB,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(YB))}),output:x({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:qB.extend({partial:GB,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:qB,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:FB.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(JB),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:n().int().optional(),atBefore:n().optional(),where:FB.optional()}),output:x({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:GB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:GB}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(l().min(1))}),output:x({removed:C(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(n().int())}),output:x({blobs:m(l(),GB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(l())}),output:x({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:l().min(1),value:l()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(l())}),output:x({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(XB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:l().min(1)}),output:XB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:l().min(1),integrationId:l().min(1).optional()}),output:x({devices:C(_Ee)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:n().int()}),output:x({id:n().int(),integrationId:l().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(n().int())}),output:x({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:n().int(),integrationId:l().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:QB,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:QB,output:x({}),behaviours:[`log.warn.writes-a-line`]}},$B={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:A(x({}),x({entries:C(hf)}),{auth:`admin`}),listPending:A(x({owner:l().optional()}),x({pending:C(gf)}),{auth:`admin`}),dryRun:A(x({id:l().min(1)}),_f,{auth:`admin`}),markFailed:A(x({id:l().min(1),error:l().min(1)}),hf,{kind:`mutation`,auth:`admin`}),retry:A(x({id:l().min(1)}),x({entries:C(hf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:A(x({database:Ud,snapshotId:l().min(1)}),x({scheduled:y(),held:C(l()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:A(x({owner:l().min(1),metas:C(rf),retired:C(l().min(1)).optional()}),x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(vf),migrationApi:ZB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:A(x({id:l().min(1)}),x({proceed:y(),state:h([p(`pending`),mf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:A(x({id:l().min(1),result:pf}),x({status:mf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:A(x({integrationId:l().min(1)}),m(l(),w()),{auth:`admin`}),clearLegacyIntegrationRows:A(x({integrationId:l().min(1)}),x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:A(x({integrationId:l().min(1),patch:m(l(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:A(x({integrationId:l().min(1),keys:C(l().min(1))}),x({present:y(),removed:m(l(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},eV=x({sourceUrl:l(),metadata:vde,targets:C(_de).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),tV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:A(eV,bde,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:M.ML}},nV=x({targetNodeId:l(),modelId:l(),format:S(va),entry:Vh}),rV=x({ok:y(),sha256:l(),bytes:n(),path:l()}),iV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:A(nV,rV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},aV=i(`kind`,[x({kind:p(`camera`)}),x({kind:p(`sensor`),deviceId:n().int().positive()})]),oV=Object.freeze({kind:`camera`});function yEe(e){if(e===void 0)return{triggeredBy:oV,malformed:!1};let t=aV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:oV,malformed:!0}}var bEe=`cameraSensors`,xEe=8,sV=x({addonId:l().min(1),stableId:l().min(1)});function cV(e){return`${e.addonId}/${e.stableId}`}var lV=S([`in-addition`,`confirm`,`replace`]),uV=`in-addition`,dV=sV.extend({mode:lV.default(uV)}),fV=x({sensors:C(dV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=cV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),pV={addonId:l(),stableId:l(),mode:lV.default(uV)},mV=i(`state`,[x({...pV,state:p(`ready`),deviceId:n(),name:l(),caps:C(l()).readonly()}),x({...pV,state:p(`offline`),deviceId:n(),name:l(),reason:S([`offline`,`disabled`])}),x({...pV,state:p(`missing`),reason:l()}),x({...pV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),x({...pV,state:p(`unreadable`),reason:l()})]),hV=S([`onboard-not-listed`,`no-active-detection`]),gV=S([`always`,`when-confirmed`,`never`]),_V=S([`provider-not-split`]),vV=x({detected:y(),atMs:n()}),yV=i(`state`,[x({state:p(`not-configured`),cameraLevel:vV.optional()}),x({state:p(`unreadable`),reason:l(),cameraLevel:vV.optional()}),x({state:p(`configured`),cameraLevel:vV.optional(),sensors:C(mV).readonly(),cameraMotion:gV.optional(),notForwarded:hV.optional(),notEnforced:_V.optional()})]),SEe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),bV=x({bbox:AS,pixelCount:n(),intensity:n()}),xV=x({detected:y(),regionCount:n(),regions:C(bV).readonly(),rawRegions:C(bV).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),SV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{analyze:A(x({deviceId:n(),frame:kS.optional(),frameHandle:na.optional()}),xV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:A(x({deviceId:n()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:A(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:n(),detected:y(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:F(`Motion analysis`,`Analisi del movimento`),order:3160}},CV=x({package:y(),confidence:n().min(0).max(1),reason:l().min(1)}),wV=x({x:n(),y:n()}),TV=x({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),EV=x({kind:p(`polygon`),points:C(wV)}),DV=x({kind:p(`grid`),gridWidth:n().meta(N(`none`)),gridHeight:n().meta(N(`none`)),cells:C(y())}),OV=x({kind:p(`line`),points:C(wV)}),CEe=i(`kind`,[TV,EV,DV,OV]),kV=S([`rect`,`polygon`,`grid`,`line`]),AV=x({min:n(),max:n()}),jV=x({width:n(),height:n()}),MV=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],NV=[{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)`}]}],wEe=`cluster-step-models`;function PV(e){return`clusterModel:${e}`}function TEe(e){return NV.some(t=>t.stepId===e)}var FV=Object.freeze(Object.fromEntries(NV.map(e=>[e.stepId,e.defaultModelId])));function IV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function LV(e){let t=[];for(let n of NV){let r=IV(e[PV(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function RV(e){let t={};for(let n of NV){let r=IV(e[PV(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function EEe(e){return typeof e==`object`&&!!e&&`key`in e}function DEe(e){return e===null?FV:RV(BV(e,zV()))}function OEe(e){return e===null?[]:LV(BV(e,zV()))}function zV(){return new Set(NV.map(e=>PV(e.stepId)))}function BV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!EEe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function kEe(e,t){let n=NV.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var AEe=24,VV=[{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 HV(e,t){return`clusterStepSetting:${e}:${t}`}function jEe(e){return VV.filter(t=>t.stepId===e)}var MEe=n().finite();function UV(e){let t={};for(let n of VV){let r=MEe.safeParse(e[HV(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var WV=UV({});function NEe(e){return e===null?WV:UV(BV(e,new Set(VV.map(e=>HV(e.stepId,e.key)))))}function PEe(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 GV=S([`new`,`entered`,`left`,`moving`,`idle`]),KV=S([`motion`,`object`,`audio`]),qV=i(`kind`,[TV,EV]),JV=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),YV=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),FEe=S([`macro`,`sub`]),XV=x({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:JV,category:YV,parentKind:l().nullable(),level:FEe,source:x({capName:l(),deviceId:n()})}),ZV=x({deviceId:n(),kinds:C(XV).readonly()}),QV=x({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),w()).nullable(),timestamp:n()}),$V=x({x:n(),y:n(),timestamp:n(),bbox:AS,source:S([`frame`,`recovery`]).optional(),score:n().optional()}),IEe=x({timestamp:n(),position:$V,mediaId:n().int()}),eH=x({minX:n(),minY:n(),maxX:n(),maxY:n()}),tH=S([`full`,`slim`]),nH=x({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),rH=S([`pipeline`,`onboard`,`sensor`,`audio`]),iH=S([`none`,`staging`,`trained`]),LEe=500,aH={markForTrain:y().optional(),debug:y().optional(),debugNote:l().max(500).optional(),favourited:y().optional()},oH={retrainStatus:iH.optional()},sH=x(aH),cH=x({trackId:l(),markForTrain:y(),debug:y(),debugNote:l(),favourited:y(),retrainStatus:iH}),REe=h([p(1),p(2)]),lH=x({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),uH={label:l().optional(),labelScore:n().optional(),labelMeta:lH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:lH.optional()},dH=x({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),fH=x({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:y(),devices:C(dH).readonly()}),pH=x({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),mH=x({trackId:l(),deviceId:n(),className:l(),...uH,producingDeviceName:l().optional(),source:rH.optional(),firstSeen:n(),lastSeen:n(),positions:C($V).readonly(),snapshots:C(IEe).readonly(),zonesVisited:C(l()).readonly(),zoneNames:C(l()).readonly().optional(),classes:C(l()).readonly().optional(),totalDistance:n(),state:GV,active:y(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:C(nH).readonly().optional(),envelope:eH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:pH.optional(),closedPlacement:pH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...aH,...oH}),hH={id:n().int(),deviceId:n(),timestamp:n()},gH=x({...hH,kind:p(`motion`),regionCount:n(),regions:C(x({bbox:AS,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:aV.optional(),durationMs:n().nullable().optional(),edges:C(n()).readonly().optional()}),_H=S([`pipeline`,`onboard`]),vH=S([`enter`,`exit`]),yH=x({direction:vH,zoneId:l(),zoneName:l().optional()}),zEe=x({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),bH=x({...hH,kind:p(`object`),source:_H.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...uH,confidence:n().optional(),bbox:AS.optional(),zones:C(l()).readonly().optional(),zoneOverlaps:C(zEe).readonly().optional(),spawnRefused:l().optional(),state:GV.optional(),zoneCrossing:yH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:y().optional(),packageLlmVerdict:CV.optional(),importance:n().optional()}),xH=x({...hH,kind:p(`audio`),rms:n(),dbfs:n(),classification:x({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:FS.optional(),mediaUrl:l().optional()}),SH=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),CH=x({mediaId:n().int(),kind:SH,sizeBytes:n(),timestamp:n()}),wH=CH.extend({url:l(),base64:l()}),TH=wH.omit({base64:!0}),EH=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),DH=S([`subject`,`model_error`]),OH=S([`operator`,`assist`,`pipeline`,`llm`]),kH=x({x:n(),y:n(),w:n(),h:n()}),AH=x({source:OH,ref:l().min(1),bbox:kH,macroClass:EH,label:l().optional(),score:n().optional(),modelId:l().optional()}),jH=x({ref:l().min(1),snapshot:AH}),MH=S(Gf),NH=x({ref:l(),savedId:l().optional(),status:MH,approximate:y(),origin:AH.optional(),macroClass:EH.optional(),label:l().optional(),iou:n().optional()}),PH=x({boxes:C(NH).readonly(),summary:x({counts:m(MH,n().int()),total:n().int(),changed:n().int(),approximate:y()})}),FH=x({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:kH,macroClass:EH,label:l().optional(),subLabel:l().optional(),kind:DH,source:OH,assistModelId:l().optional(),assistScore:n().optional(),origin:AH.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),IH=FH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),LH=S([`correct`,`wrong`,`wrong-label`]),RH=x({verdict:LH,suggestedClass:l().optional(),suggestedMacroClass:EH.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),zH=x({trackId:l(),className:l(),label:l().optional(),bbox:kH.optional(),verdict:LH,suggestedClass:l().optional(),at:n().optional()}),BH=x({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:RH.optional()}),VH=x({mediaId:n().int(),kind:SH,timestamp:n(),sizeBytes:n().int(),copied:y()}),HH=x({bbox:kH,macroClass:EH,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:n()}),UH=S([`track`,`recording`]),WH=x({frameId:l(),deviceId:n(),origin:UH,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:SH,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:y(),pipelineBoxes:C(HH).readonly().optional(),collectionIds:C(l()).readonly().optional(),verdict:RH.optional(),revision:n().int().optional(),dismissed:C(jH).readonly().optional(),review:PH.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),GH=S([`source-missing`,`unreadable-image`,`write-failed`]),KH=x({copied:C(WH).readonly(),refused:C(x({sourceMediaId:n().int(),reason:GH})).readonly()}),qH=x({candidates:C(VH).readonly(),copies:C(WH).readonly(),autoPickMediaId:n().int().optional()}),JH=S([`unannotated`,`annotated`,`complete`]),YH=x({workState:JH.optional(),deviceIds:C(n()).max(500).optional(),collectionId:l().optional(),classes:C(EH).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),XH=WH.extend({workState:JH}),ZH=x({frames:C(XH).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),QH=x({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),$H=x({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:C(QH).readonly()}),eU=x({deviceIds:C(n()).optional(),frameIds:C(l()).max(2e4).optional(),collectionIds:C(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:y().optional(),workState:JH.optional(),classes:C(EH).optional()}),tU=S([`frames`,`crops`]),nU=x({kind:p(`http`),method:S([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),rU=x({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),iU=i(`kind`,[x({kind:p(`package`),zone:kH.optional()}),x({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),aU=i(`kind`,[x({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:C(IH).readonly(),belowThreshold:n().int()}),x({kind:p(`refused`),reason:l(),detail:l().optional()})]),oU=x({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),sU=i(`kind`,[x({kind:p(`created`),collection:oU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),cU=i(`kind`,[x({kind:p(`renamed`),collection:oU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),lU=i(`kind`,[x({kind:p(`added`),collectionId:l(),frame:WH,reused:y()}),x({kind:p(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),uU=x({id:l(),name:l(),model:l(),kind:l(),leavesHouse:y()}),dU=IH.extend({reason:l()}),fU=x({ref:l(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:EH.optional(),reason:l()}),pU=i(`kind`,[x({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:y(),proposals:C(dU).readonly(),reviews:C(fU).readonly(),rejected:n().int()}),x({kind:p(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),mU=x({deviceIds:C(n()).readonly().optional(),collectionIds:C(l()).max(200).readonly().optional(),frameIds:C(l()).max(2e4).readonly().optional()}),hU=x({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:C(x({macroClass:l(),deviceId:n(),lighting:S([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:C(x({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),BEe=x({id:l(),name:l(),createdAt:n(),selection:mU,layout:tU,completeOnly:y(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:hU}),gU=x({collectionIds:C(l()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),_U=i(`kind`,[x({kind:p(`resolved`),frameIds:C(l()).max(2e4).readonly(),stats:hU,annotationHash:l(),layout:tU}),x({kind:p(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:l()})]),vU=x({trackId:l(),retrainStatus:iH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),yU=1e3,bU=5e3,xU=x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(bU).default(yU),projection:S([`full`,`slim`]).optional()}),VEe=xU.extend({classFilter:l().optional()}),SU=x({deviceIds:C(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:tH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(rH).optional()}),CU=x({tracks:C(mH).readonly(),nextCursor:l().nullable()}),wU=50,TU=200,HEe=x({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(TU).default(wU),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),EU=x({id:l(),trackId:l(),timestamp:n(),className:l(),...uH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:C(nH).readonly().optional(),...aH,...oH}),UEe=x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(TU).default(wU),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),WEe=x({deviceId:n(),events:C(EU).readonly()}),DU=x({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),GEe=200,OU=x({deviceId:n(),read:S([`read`,`unreadable`]),buckets:C(DU).readonly()}),KEe=x({trackId:l(),className:l(),confidence:n(),bbox:AS,zones:C(l()).readonly(),state:GV}),qEe=se({id:l(),kind:S([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:x({x:n(),y:n(),width:n(),height:n()}),labels:C(se({label:l(),score:n()})).readonly(),parentId:l().optional()}),kU=bH.extend({score:n()}),JEe=x({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:Nue.optional(),modelId:l().min(1).optional()}),AU=x({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),YEe=x({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),XEe=x({deviceId:n(),rows:n().int(),bytes:n().int()}),ZEe=x({totalRows:n().int(),totalBytes:n().int(),devices:C(XEe).readonly()}),QEe=x({kind:SH,rows:n().int(),bytes:n().int()}),$Ee=x({totalRows:n().int(),totalBytes:n().int(),kinds:C(QEe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),jU=x({motion:n().int(),object:n().int(),audio:n().int()}),eDe=x({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:y().optional()}),tDe=x({deleted:n(),failedIndexes:C(l()).optional()}),MU=S([`stores-unavailable`,...MV,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),nDe=x({started:y(),alreadyRunning:y(),refusal:MU.optional(),modelId:l().optional(),index:l().optional()}),rDe=x({running:y(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:x({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:y().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),iDe=x({started:y(),alreadyRunning:y()}),aDe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(n().int()).min(1).optional(),restart:y().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),oDe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),NU=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]),sDe=`|`;function cDe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function lDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var PU=x({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),FU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:A(x({deviceId:n()}),C(mH).readonly()),getTrack:A(x({deviceId:n(),trackId:l()}),mH.nullable()),listTracks:A(x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:qV.optional(),projection:tH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(rH).optional()}),C(mH).readonly()),listRecentTracks:A(SU,CU),clearTracks:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:A(xU,C(gH).readonly()),getObjectEvents:A(VEe,C(bH).readonly()),getAudioEvents:A(xU,C(xH).readonly()),listEventKinds:A(x({deviceId:n()}),C(XV).readonly()),listEventKindsBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(ZV).readonly()),getSensorEvents:A(x({deviceId:n(),since:n().optional(),until:n().optional(),kinds:C(l()).optional(),limit:n().int().min(1).max(bU).default(yU)}),C(QV).readonly()),getKeyEvents:A(HEe,C(EU).readonly()),getKeyEventsBatch:A(UEe,C(WEe).readonly()),readLongTermSeries:A(x({deviceId:n(),series:NU,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),C(PU).readonly()),getEventDensity:A(x({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),C(DU).readonly()),getEventDensityBatch:A(x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),C(OU).readonly()),pruneEventsBefore:A(x({deviceId:n(),cutoffMs:n()}),x({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:A(x({deviceId:n(),cutoffMs:n()}),AU,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:A(x({deviceId:n()}),AU,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(x({deviceId:n()}),YEe,{kind:`mutation`,auth:`admin`}),deleteTracks:A(x({deviceId:n(),trackIds:C(l()).min(1)}),x({deleted:n().int(),failed:C(l()).readonly(),sparedMediaIds:C(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:A(x({deviceId:n(),trackId:l(),flags:sH}),cH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:A(np,C(tp).readonly(),{kind:`query`}),setTrackRelation:A(cp,op,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:A(lp,up,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:A(dp,fp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:A(pp,mp,{kind:`query`}),listBirthDecisions:A(ep,C($f).readonly(),{kind:`query`}),getEventStoreFootprint:A(x({}),ZEe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:A(x({deviceId:n().int().optional()}),$Ee,{kind:`query`,auth:`admin`}),pruneEvents:A(x({olderThanMs:n(),reason:Sp.optional()}),jU,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:A(x({deviceId:n()}),jU,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(Xp,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(am,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),qp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:A($p,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:A(x({}),tm,{auth:`admin`}),getMediaLocationCensus:A(nm,im,{kind:`query`,auth:`admin`}),countRelocatableMedia:A(jm,Am,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:A(x({}),C(qp).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(wp,C(Cp).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:A(aDe,iDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:A(x({}),oDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:A(x({deviceIds:C(n()).optional()}),fH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:A(x({deviceIds:C(n()).optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:A(x({deviceIds:C(n()).optional(),limit:n().int().min(1).max(500).optional()}),C(BH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:A(YH,ZH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:A(x({}),$H,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:A(x({trackId:l()}),qH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:A(x({deviceId:n(),trackId:l(),mediaIds:C(n().int()).min(1)}),KH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:A(x({deviceId:n(),trackId:l().optional(),frameId:l()}),x({removed:y(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:A(x({frameId:l()}),x({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),subject:iU,nodeId:l().optional()}),aU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:A(x({trackId:l().optional(),frameIds:C(l()).max(2e3).optional()}),C(FH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:C(IH),expectedRevision:n().int().optional(),dismissed:C(jH).optional()}),C(FH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:C(x({annotationId:l(),origin:AH})).min(1).max(500)}),x({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:A(x({deviceId:n(),trackId:l()}),vU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:A(x({deviceId:n(),trackId:l()}),vU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:A(eU.extend({layout:tU.optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),complete:y()}),WH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:A(x({filter:eU,layout:tU,target:nU}),rU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:A(x({filter:eU,layout:tU}),x({ticket:ri,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:A(x({}),C(uU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:C(EH).min(1),boxes:C(x({ref:l(),bbox:kH,macroClass:EH,label:l().optional()})).max(50),allowCloud:y()}),pU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:A(x({name:l().max(120)}),sU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:A(x({}),C(oU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:A(gU,_U,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:A(x({id:l(),name:l().max(120)}),cU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:A(x({id:l()}),x({deleted:y(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:A(x({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:zH.optional()}),lU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:A(x({collectionId:l(),frameIds:C(l()).min(1).max(500)}),x({added:n().int(),alreadyMember:n().int(),unknownFrameIds:C(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:A(x({collectionId:l(),frameId:l()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:A(x({collectionId:l()}),C(WH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:A(x({ownerType:Ql,eventId:n().int(),kind:SH.optional(),deviceId:n()}),C(wH).readonly()),getTrackMedia:A(x({trackId:l(),kinds:C(SH).optional(),deviceId:n()}),C(wH).readonly()),listTrackMedia:A(x({trackId:l(),deviceId:n()}),C(TH).readonly()),listEventMedia:A(x({ownerType:Ql,eventId:n().int(),deviceId:n()}),C(TH).readonly()),ownersWithMedia:A(x({deviceId:n(),ownerKind:eu,ownerIds:C(l()).max(5e3)}),C(l()).readonly()),searchObjectEvents:A(JEe,C(kU).readonly(),{caller:`required`}),wipeObjectEmbeddings:A(x({}),tDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:A(eDe,nDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:A(x({}),rDe)},events:{onFrameTracked:{data:x({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:C(qEe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:n(),trackId:l(),className:l()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:F(`Subject appeared`,`Soggetto comparso`),phrase:F(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:F(`Subject left`,`Soggetto uscito`),phrase:F(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:n(),kind:KV,eventId:l(),timestamp:n()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:F(`Detection event`,`Evento di rilevamento`),phrase:F(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:F(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:F(`Package delivered`,`Pacco consegnato`),phrase:F(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:F(`Package picked up`,`Pacco ritirato`),phrase:F(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},IU=x({x:n(),y:n(),w:n(),h:n()}),LU=x({stepId:l(),modelId:l(),detections:C(x({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:C(x({x:n(),y:n()})).optional()})).min(1)}),RU=x({handle:na,cropFrameSpace:x({x:n(),y:n(),w:n(),h:n()})});x({crop:x({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:x({width:n().int().positive(),height:n().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var uDe=x({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),zU=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),BU=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),VU=x({runtime:p(`python`),backend:l(),format:zU,device:l().optional()}),HU=x({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),dDe=x({engine:VU,devices:C(x({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),UU=a(()=>x({addonId:l(),addonName:l(),slot:BU,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),enabled:y(),modelId:l(),children:C(UU).readonly(),group:l().optional(),settings:m(l(),w()).optional()})),fDe=x({id:l(),name:l(),formats:m(l(),ude),group:Rh.optional(),legacy:y().optional(),provider:zh.optional(),defaultConfidence:n().optional(),suppliesSteps:C(Bh).readonly().optional()}),pDe=ve(),mDe=x({id:l(),name:l(),slot:BU,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),childSlots:C(BU).readonly(),models:C(fDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:y().optional(),defaultConfidence:n(),group:l().optional(),configSchema:C(pDe).readonly().optional()}),hDe=x({id:BU,label:l(),priority:n(),parentSlot:BU.nullable(),addons:C(mDe).readonly()}),gDe=x({availableEngines:C(dDe).readonly(),selectedEngine:VU,slots:C(hDe).readonly()}),_De=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:C(l()).optional()}),WU=x({addonId:l(),chosen:l(),running:l(),format:l()}),GU=x({addonId:l(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),KU=x({ok:y(),issues:C(GU).readonly(),substitutions:C(WU).readonly(),format:l()}),vDe=x({filename:l(),stepIds:C(l()).readonly().optional()}),yDe=x({base64:l(),filename:l()}),bDe=x({filename:l(),sizeKb:n()}),xDe=x({base64:l()}),SDe=x({id:l(),name:l(),description:l(),available:y(),rawLabels:C(l()).readonly().optional()}),CDe=x({activeBackend:l(),availableBackends:C(SDe).readonly(),sampleRate:n(),chunkDurationMs:n()}),wDe=x({filePath:l(),sizeMB:n(),durationMs:n()}),TDe=x({success:y(),error:l().optional(),frame:ve().optional()}),EDe=ve(),DDe=ve(),ODe=ve(),kDe=ve(),qU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:A(v(),C(VU)),getSelectedEngine:A(v(),VU),getEngineProvisioning:A(x({nodeId:l()}),_De),getVideoPipelineSteps:A(v(),m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))),setVideoPipelineSteps:A(x({steps:m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:A(x({nodeId:l()}),x({unhealthy:C(x({deviceKey:l(),state:S([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l()})).readonly()})),rearmInferenceDevice:A(x({nodeId:l(),deviceKey:l()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:A(v(),gDe),getOrchestratorConfigSchema:A(v(),EDe),validatePipeline:A(x({steps:C(Ea),deviceKey:l().optional()}),KU),getCapabilities:A(v(),ODe),getAddonModels:A(x({addonId:l()}),kDe),downloadModel:A(x({addonId:l(),modelId:l(),format:zU}),wDe,{kind:`mutation`}),deleteModel:A(x({addonId:l(),modelId:l(),format:zU}),x({success:p(!0)}),{kind:`mutation`}),runPipeline:A(x({steps:C(Ea).min(1),frame:kS.optional(),frameRef:uDe.optional(),frameHandle:na.optional(),imageBase64:l().optional(),image:b(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:RU.optional(),replay:p(!0).optional(),suppliedRoot:LU.optional(),motionRegions:C(IU).optional()}),Da,{kind:`mutation`}),runPipelineBatch:A(x({steps:C(Ea).min(1),frames:C(kS).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),x({results:C(Da).readonly()}),{kind:`mutation`}),cacheFrameInPool:A(x({data:b(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:A(x({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),w()),{kind:`mutation`}),uncacheFrame:A(x({frameId:n().int()}),v(),{kind:`mutation`}),getEffectiveTuning:A(x({deviceKey:l().optional()}),HU),listLoadedEngines:A(v(),C(x({engineKey:l(),engine:VU,modelsLoaded:C(l()).readonly(),inUseByCameras:C(n()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:A(x({engine:VU}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:A(x({engine:VU,force:y().optional()}),x({success:y(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:A(v(),C(vDe).readonly()),getReferenceImage:A(x({filename:l()}),yDe.nullable()),getReferenceAudioFiles:A(v(),C(bDe).readonly()),getReferenceAudio:A(x({filename:l()}),xDe.nullable()),getAudioCapabilities:A(v(),CDe),runAudioTest:A(x({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),w()).optional()}),TDe,{kind:`mutation`}),getDetectionConfigSchema:A(v(),DDe)},vocabulary:{notOperatorFacing:M.PIPELINE}},ADe=x({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),JU=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:S([`idle`,`watching`,`active`])}),YU=JU.extend({deviceId:n()}),XU=S([`polygon`,`tripwire`]),ZU=x({x:n(),y:n()}),QU=x({id:l(),name:l(),kind:XU.default(`polygon`),polygon:C(ZU).readonly(),color:l().default(`#3b82f6`)}),$U={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{listZones:A(x({deviceId:n()}),C(QU).readonly()),addZone:A(x({deviceId:n(),zone:QU}),v(),{kind:`mutation`,auth:`admin`}),removeZone:A(x({deviceId:n(),zoneId:l()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:A(x({deviceId:n(),zone:QU}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(QU).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:F(`Zones`,`Zone`),order:3370}},eW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},tW=S([`device`,`pipeline`]),nW=x({deviceKey:l().min(1),modelIds:C(l().min(1)).min(1).max(eW.maxModelsPerDevice)}),rW=x({nodeId:l().min(1),devices:C(nW).min(1),phases:C(tW).min(1).default([`device`,`pipeline`]),steps:C(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(eW.fpsPerStream),budgetMinutes:n().int().min(eW.minBudgetMinutes).max(eW.maxBudgetMinutes).default(eW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),iW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),aW=x({kind:iW,detail:l(),overridable:y()}),oW=x({deviceId:n(),placedOnNode:y(),pinnedToNode:y()}),sW=x({deviceId:n(),reason:p(`only-frame-source`)}),cW=x({nodeId:l(),online:y(),moving:C(oW).readonly(),staying:C(sW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:C(tW).readonly(),steps:C(l()).readonly(),devices:C(nW).readonly(),headroom:x({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:C(aW).readonly(),canStart:y()}),lW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),uW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),dW=x({load:n(),pass:y(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:C(l()).readonly()}),fW=x({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:uW,warmupMs:n(),ramp:C(dW).readonly()}),pW=x({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:C(l()).readonly(),maxSessions:n(),limitedBy:uW,stepsFired:C(l()).readonly(),warmupMs:n(),ramp:C(dW).readonly()}),mW=i(`phase`,[fW,pW]),hW=x({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),x({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),gW=x({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),_W=x({runId:l().min(1),devices:C(nW).min(1),phases:C(tW).min(1),steps:C(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(eW.settleSec),measureSec:n().min(2).max(300).default(eW.measureSec),keepDownloadedModels:y().default(!1)}),vW=S([`running`,`done`,`failed`,`aborted`]),yW=x({runId:l(),nodeId:l(),state:vW,progress:lW.nullable(),cells:C(mW).readonly(),fingerprint:hW.nullable(),clip:gW.nullable(),activeCameraIds:C(n()).readonly(),deletedModels:C(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),bW=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),xW=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),SW=x({runId:l(),nodeId:l(),state:bW,plan:rW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:xW.nullable(),error:l().nullable(),moved:C(n()).readonly(),staying:C(n()).readonly(),contaminated:y(),progress:lW.nullable(),resultIds:C(l()).readonly()}),CW=x({modeNodeId:l().nullable(),run:SW.nullable()}),wW=x({id:l(),runId:l(),nodeId:l(),cell:mW,fpsPerStream:n(),fingerprint:hW.nullable(),clip:gW.nullable(),contaminated:y(),stayingCameras:C(n()).readonly(),partialRun:y(),measuredAtMs:n()}),TW=x({nodeId:l().optional(),deviceKey:l().optional()}),EW=wW.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),jDe=x({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:rW,moved:C(n()).readonly(),staying:C(n()).readonly()}),DW=x({nodeId:l(),reachable:y(),devices:C(x({deviceKey:l(),enabled:y(),available:y(),suggested:C(l()).readonly(),all:C(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:C(x({id:l(),name:l(),slot:l()})).readonly()}),OW=x({x:n(),y:n(),w:n(),h:n()}),kW=x({bytes:b(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),AW=S([`keyFrame`,`thumbnail`]),jW=S([`handle-gone`,`encode-failed`]),MW=i(`parked`,[x({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:y()}),x({parked:p(!1),nodeId:l(),reason:jW,handleAgeMs:n().nullable(),detail:l().optional()})]),NW=x({jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),MDe=x({bbox:OW,className:l()}),PW=x({stepId:l(),className:l(),score:n(),bbox:OW.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:C(x({x:n(),y:n()})).optional()}),NDe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),PDe=i(`kind`,[x({kind:p(`ran`),nodeId:l(),modelId:l(),details:C(PW)}),x({kind:p(`refused`),nodeId:l(),reason:NDe,detail:l()})]),FW={min:0,max:6e4,default:3e4,step:500},IW={min:0,max:6e5,default:12e4,step:5e3},LW={min:5e3,max:6e5,default:9e4,step:5e3},RW={min:1,max:30,default:4,step:1},zW={min:1,max:30,default:10,step:1},BW={min:0,max:300,default:300,step:5},VW={min:1,max:10,default:4,step:1},HW={min:0,max:30,default:12,step:1},UW=S([`onboard`,`analyzer`,`device-activity`]),WW=x({source:UW,triggeredBy:aV,sensorName:l().optional()}),GW=C(UW),KW={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function FDe(e){let t=UW.safeParse(e);return t.success?KW[t.data]:e}var IDe=[`analyzer`,`onboard`,`device-activity`],qW=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(_H).max(1)),JW=x({deviceId:n(),detected:y(),source:UW.default(`analyzer`),regions:C(bV).readonly().optional()}),YW=i(`kind`,[x({kind:p(`local-broker`)}),x({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),XW=x({modelId:l().optional(),settings:m(l(),w()).optional()}),ZW=x({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),XW).optional(),disabledSteps:C(l()).readonly().optional()}),QW=x({deviceId:n(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(FW.min).default(FW.default),maxSessionHoldMs:n().min(IW.min).max(IW.max).optional(),audioMotionWindowMs:n().min(LW.min).max(LW.max).optional(),motionFps:n().min(RW.min).max(RW.max).default(RW.default),detectionFps:n().min(zW.min).max(zW.max).default(zW.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:Yi.optional(),motionSources:GW.default([`analyzer`]),sessionTrigger:WW.optional(),detectionSources:qW.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(Ea).readonly().optional(),audio:x({modelId:l().optional(),enabled:y()}).nullable().optional(),zones:C(QU).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:n().min(HW.min).max(HW.max).default(HW.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:n().min(BW.min).max(BW.max).default(BW.default),occupancyRecheckFrames:n().min(VW.min).max(VW.max).default(VW.default),frameSource:YW.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:C(ZW).readonly().optional()}),LDe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:IDe.map(e=>e===`onboard`?{value:e,label:KW[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:KW[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:RW.min,max:RW.max,step:RW.step,default:RW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:zW.min,max:zW.max,step:zW.step,default:zW.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:FW.min,max:FW.max,step:FW.step,default:FW.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:IW.min,max:IW.max,step:IW.step,default:IW.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:LW.min,max:LW.max,step:LW.step,default:LW.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:HW.min,max:HW.max,step:HW.step,default:HW.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:BW.min,max:BW.max,step:BW.step,default:BW.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:VW.min,max:VW.max,step:VW.step,default:VW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],$W=x({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:C(x({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),eG=x({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),tG=x({node:eG,cameras:C(eG.extend({deviceId:n()}))}),nG=x({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:tG.optional()}),rG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),iG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:A(QW,x({success:p(!0)}),{kind:`mutation`}),detachCamera:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`}),reportMotion:A(JW,x({success:p(!0)}),{kind:`mutation`}),getLocalLoad:A(v(),$W),getLocalMetrics:A(v(),nG),getCameraMetrics:A(x({deviceId:n()}),JU.nullable()),getAllCameraMetrics:A(v(),C(YU).readonly()),getLocalCameras:A(v(),C(n()).readonly()),requestOccupancyBurst:A(x({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),x({started:y(),refusedBecause:rG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:A(x({handle:na,bbox:OW,maxWidth:n().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),kW.nullable()),runDetailSubtree:A(x({deviceId:n(),frameHandle:na.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:MDe,steps:C(l()).optional(),supplied:x({stepId:l(),modelId:l(),boxes:C(x({bbox:OW,score:n()})).min(1)}).optional()}),x({details:C(PW)}).nullable(),{kind:`mutation`}),runStatelessStep:A(x({stepId:l(),modelId:l(),frameJpeg:l(),bbox:OW,className:l(),sourceDeviceId:n()}),PDe,{kind:`mutation`}),parkTrackFrame:A(x({deviceId:n(),trackId:l(),kind:AW,handle:na,bbox:OW,maxWidth:n().int().positive().optional(),timestamp:n()}),MW,{kind:`mutation`}),getParkedTrackFrame:A(x({deviceId:n(),trackId:l(),kind:AW,acceptJpegBytes:y().optional()}),NW.nullable()),releaseParkedTrackFrames:A(x({deviceId:n(),trackId:l()}),x({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:A(_W,x({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:A(x({runId:l()}),yW.nullable(),{auth:`admin`}),abortNodeBench:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},aG=3e4,RDe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[E.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:aG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},zDe=15e3,oG=x({detected:y(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(N(`duration-ms`))}),sG=x({deviceId:n(),detected:y(),timestamp:n(),source:UW,regions:C(bV).readonly().optional(),triggeredBy:aV.optional()}),cG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[E.Camera,E.Sensor],methods:{isDetected:A(x({deviceId:n()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:sG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:oG,kind:`push`},runtimeState:oG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}}},customize:RDe,vocabulary:{noun:F(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},lG=x({enabled:y(),lastChangedAt:n()}),uG=lG.extend({lastFetchedAt:n()}),dG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light,E.Siren,E.Switch],methods:{setMotionTrigger:A(x({deviceId:n().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:F(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:F(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:F(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:F(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:n(),enabled:y(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:lG,kind:`command-driven`},runtimeState:uG,durability:`session`,history:`none`,vocabulary:{noun:F(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:F(`Motion trigger`,`Attivazione al movimento`),whenTrue:F(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:F(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},fG=x({id:n(),enabled:y(),shape:DV}),pG=x({enabled:y(),sensitivity:n().meta(N(`none`)),regions:C(fG),lastFetchedAt:n()}),mG=x({maxRegions:n(),supportedShapes:C(kV),grid:jV,sensitivity:x({min:n(),max:n(),step:n()})}),hG=x({enabled:y().optional(),sensitivity:n().optional(),regions:C(fG).optional()}),gG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:A(x({deviceId:n()}),mG),setZone:A(x({deviceId:n(),patch:hG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:pG,kind:`poll`},runtimeState:pG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Motion zones`,`Zone di movimento`),order:3170}},BDe=S([`external`,`embedded`]),VDe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),_G=x({id:l(),name:l(),url:l(),kind:BDe,status:VDe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),vG=x({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),yG=x({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),HDe=x({id:l()}),bG=x({id:l()}),xG=x({port:n().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:l().optional(),password:l().optional()}),UDe=x({id:l(),url:l()}),SG=x({brokerCount:n(),embeddedRunning:y()}),CG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:SG,kind:`poll`},methods:{listBrokers:A(v(),C(_G)),getBrokerConfig:A(bG,vG,{auth:`admin`}),addBroker:A(yG,HDe,{kind:`mutation`,auth:`admin`}),removeBroker:A(bG,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:A(xG,UDe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:A(bG,v(),{kind:`mutation`,auth:`admin`}),getStatus:A(v(),SG)},vocabulary:{notOperatorFacing:M.NETWORK}},wG=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),TG=x({class:wG,timestamp:n(),confidence:n().min(0).max(1).optional()}),EG=x({lastByClass:d(wG,TG.nullable()),supportedClasses:C(wG).readonly(),enabled:y()}),DG=S([`boxed`,`while-streaming`,`flag-only`]),OG=x({supportedClasses:C(wG).readonly(),geometry:DG}),kG=x({enabled:y().optional()}),AG=EG.extend({lastFetchedAt:n()}),jG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getOptions:A(x({deviceId:n()}),OG),setSettings:A(x({deviceId:n(),settings:kG}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:F(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:F(`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:F(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:F(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:n(),detection:TG}),trigger:{category:T.DetectionCameraNative,label:F(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:F(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:EG,kind:`push`},runtimeState:AG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:F(`On-camera detection`,`Rilevamento a bordo`),whenTrue:F(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:F(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},MG=x({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),NG=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),PG=S([`action`,`sound`]),FG=x({id:l(),kind:PG,label:l(),icon:l(),soundId:n().int().optional(),enabled:y()}),WDe=[{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}],IG=x({x:n(),y:n()}),LG=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),RG=S([`auto`,`manual`]),GDe=40,KDe=100,zG=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),BG=x({mode:zG,following:y(),flash:y(),lightMode:RG,lightLevel:n().min(40).max(100).meta(N(`none`)),lastChangedAt:n()}),VG=BG.extend({lastFetchedAt:n()}),HG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:A(MG.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:A(IG.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:A(x({deviceId:n()}),C(FG)),runAction:A(x({deviceId:n(),actionId:NG}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:F(`Run a routine`,`Esegui una routine`),phrase:F(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:F(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:F(`go home`,`torna alla base`)},{value:`locate`,label:F(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:F(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:F(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:F(`follow a person`,`segui una persona`)},{value:`stop`,label:F(`stop`,`fermati`)},{value:`startClean`,label:F(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:F(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:F(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:F(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:F(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:F(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:A(x({deviceId:n(),soundId:n().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:A(x({deviceId:n(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:F(`Light on`,`Luce accesa`),phrase:F(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:F(`Light off`,`Luce spenta`),phrase:F(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:A(x({deviceId:n(),mode:RG,level:n().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:F(`Light automatic`,`Luce automatica`),phrase:F(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:A(x({deviceId:n(),level:n().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:F(`Set light level`,`Imposta la luce`),phrase:F(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:F(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:A(x({deviceId:n()}),LG)},events:{onStatusChanged:{data:x({deviceId:n(),status:BG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:BG,kind:`push`},runtimeState:VG,durability:`session`,history:`none`,vocabulary:{noun:F(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`cleaning`,label:F(`Cleaning`,`In pulizia`)},{value:`spot`,label:F(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:F(`Following`,`In inseguimento`)},{value:`goto`,label:F(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:F(`Returning`,`In rientro`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},UG=x({url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`]),stable:y().optional()}),qDe=x({url:l(),stable:y().optional(),updated:y().optional()}),WG=x({connected:y(),endpoint:UG.nullable(),error:l().optional()}),JDe=UG.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),GG={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:A(v(),UG,{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getEndpoint:A(v(),UG.nullable()),getStatus:A(v(),WG),listEndpoints:A(v(),C(JDe).readonly())},vocabulary:{notOperatorFacing:M.NETWORK}},KG=[`wifi`,`ethernet`,`cellular`,`unknown`],qG=x({type:S(KG),signal:n().min(0).max(100).nullable().meta(N(`percentage`)),rssi:n().optional().meta(N(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(N(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:n().meta(N(`none`))}),JG={type:`unknown`,signal:null,lastUpdated:0};function YDe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function XDe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var YG={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.Light,E.Lock,E.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:qG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:qG,kind:`push`,empty:JG},runtimeState:qG,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:F(`the signal strength`,`l’intensità del segnale`),label:F(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:F(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:F(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:F(`Ethernet`,`Ethernet`)},{value:`cellular`,label:F(`Cellular`,`Rete mobile`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},XG=x({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),ZG=x({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),QG=x({deviceId:n(),streams:m(l(),XG),client:ZG.optional()}),$G={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:A(x({deviceId:n()}),QG.nullable()),getAllStats:A(v(),C(QG).readonly()),reportClientStats:A(x({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.NETWORK}},eK=x({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),tK=x({fingerprintSha256:l(),issuer:l(),sans:C(l()),notBefore:n(),notAfter:n()}),nK=i(`state`,[x({state:p(`served`),leaf:tK}),x({state:p(`not-issued`),reason:l()})]),rK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:A(x({}),x({nodeId:l(),mesh:eK.nullable(),https:nK}),{auth:`admin`}),prepareMeshRenewal:A(x({}),x({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:A(x({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),x({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:A(x({fingerprintSha256:l()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:A(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:A(x({}),x({csrPem:l(),hostnames:C(l()),addresses:C(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:A(x({}),x({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:A(x({certPem:l().min(1),caCertPem:l().min(1),caRotation:y().optional()}),tK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},iK=x({nodeId:l().min(1),removedAt:n()}),aK=x({counts:m(l(),n().int().nonnegative())}),oK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:A(iK,aK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},sK=x({addonId:l(),capabilities:C(l()).readonly(),status:l()}),cK=x({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:C(sK).readonly(),groupId:l().optional()}),ZDe=x({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),QDe=x({category:l(),total:n(),healthy:n(),addons:C(ZDe).readonly()}),$De=x({name:l(),version:l()}),lK=x({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:C(l()).readonly(),isHub:y(),isOnline:y(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:C(l()).readonly(),addons:C(x({id:l(),capabilities:C(l()).readonly(),status:l()})).readonly(),processes:C(cK).readonly(),categories:C(QDe).readonly(),rootPackage:$De.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),eOe=x({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),uK=x({nodeId:l(),name:l(),version:l(),status:l(),synced:y()}),dK=x({hubVersion:l(),nodes:C(uK)}),fK=x({nodeId:l(),addonId:l()}),tOe=x({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),pK=x({success:y()}),nOe=x({success:y(),reason:l().optional()}),rOe=x({restarted:C(l()).readonly(),failed:C(l()).readonly()}),iOe=x({nodeId:l(),name:l()}),mK=x({id:l(),name:l(),isHub:y(),isOnline:y()}),hK=x({nodes:C(mK).readonly(),complete:y()}),gK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:A(v(),C(lK).readonly(),{auth:`admin`}),directory:A(v(),hK,{auth:`admin`}),deployAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),undeployAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),restartAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),restartProcess:A(x({nodeId:l(),processName:l()}),nOe,{kind:`mutation`,auth:`admin`}),restartNode:A(x({nodeId:l()}),rOe,{kind:`mutation`,auth:`admin`}),shutdownNode:A(x({nodeId:l()}),pK,{kind:`mutation`,auth:`admin`}),renameNode:A(x({nodeId:l(),name:l().min(1).max(64)}),iOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:A(v(),m(l(),dK),{auth:`admin`}),getCapUsageGraph:A(x({windowSeconds:n().int().positive().max(300).default(60)}),C(eOe).readonly(),{auth:`admin`}),getNodeAddons:A(x({nodeId:l()}),C(tOe).readonly(),{auth:`admin`}),setProcessLogLevel:A(x({nodeId:l(),level:l()}),pK,{kind:`mutation`,auth:`admin`}),executeQuery:A(x({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},_K=[{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`}],vK={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},yK={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},bK=new Map;for(let[e,t]of Object.entries(vK.mapping))bK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(yK.mapping))bK.set(e.toLowerCase(),t);function aOe(e){return bK.get(e.toLowerCase())??null}function oOe(){return _K.map(e=>e.id)}var xK=UN();function SK(e){return JN(xK.swatches,xK.fallbacks,e)}function sOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var cOe=sOe(xK.fallbacks);function lOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var CK=new Map;function wK(e,t,n,r){CK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:SK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function TK(e,t,n,r,i){CK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:SK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}wK(`motion`,`motion`,`motion`,`Motion`),wK(`audio`,`audio`,`audio`,`Audio`),wK(`person`,`detection`,`person`,`Person`),wK(`vehicle`,`detection`,`vehicle`,`Vehicle`),wK(`animal`,`detection`,`animal`,`Animal`),wK(`package`,`package`,`package`,`Package`),wK(`sensor`,`sensor`,`sensor`,`Sensor`),wK(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Vg.mapping))t!==`vehicle`&&t!==`animal`||CK.has(e)||TK(e,t,`detection`,e,lOe(e));TK(`package-delivered`,`package`,`package`,`package`,`Package delivered`),TK(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),TK(`contact`,`sensor`,`sensor`,`door`,`Contact`),TK(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),TK(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),TK(`flood`,`sensor`,`sensor`,`water`,`Water leak`),TK(`gas`,`sensor`,`sensor`,`gas`,`Gas`),TK(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),TK(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),TK(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),TK(`presence`,`sensor`,`sensor`,`presence`,`Presence`),TK(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),TK(`device-event`,`sensor`,`sensor`,`button`,`Device event`),TK(`lock`,`control`,`control`,`lock`,`Lock`),TK(`cover`,`control`,`control`,`door`,`Cover`),TK(`switch`,`control`,`control`,`switch`,`Switch`),TK(`siren`,`control`,`control`,`siren`,`Siren`),TK(`button`,`control`,`control`,`button`,`Button`),TK(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),TK(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of _K){let t=`audio-${e.id}`;CK.has(t)||TK(t,`audio`,`audio`,t,e.name)}var EK=Object.freeze(Object.fromEntries(CK));function DK(e){return EK[e]}function uOe(e){return SK(e)}function dOe(e){let t=[];for(let n of Object.values(EK))n.parentKind===e&&t.push(n);return t}var OK=x({kind:l(),label:l(),parentKind:l().nullable()}),kK=x({videoClasses:C(OK),audioKinds:C(OK),labels:C(OK)});function AK(e,t,n){return{kind:e,label:t,parentKind:n}}function jK(){let e=Object.values(EK);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>AK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>AK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>AK(e.kind,e.label,e.parentKind))}}var fOe=Object.freeze(jK()),MK=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),NK=S(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),PK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],pOe=new Set(PK),mOe=NK.options.filter(e=>!pOe.has(e)),FK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],hOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],IK=[`device-consumable-low`,`device-consumable-normal`],gOe=15,_Oe=95,LK=[`confirmed`,`already`,`unconfirmed`,`failed`],RK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],zK=x({kinds:C(NK).min(1),deviceIds:C(n().int()).min(1).optional(),deviceTypes:C(l().min(1)).min(1).optional(),excludeDeviceIds:C(n().int()).min(1).optional(),nodeIds:C(l().min(1)).min(1).optional(),packageNames:C(l().min(1)).min(1).optional(),commandActions:C(l().min(1)).min(1).optional(),commandOutcomes:C(S(LK)).min(1).optional(),commandActorKinds:C(S(RK)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function vOe(e){return e.consumableLowPercent??15}var yOe=1,BK=1440,bOe=[10,30,60],VK=x({days:C(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),HK=x({windows:C(VK).min(1),timezone:l().optional(),invert:y().optional()}),UK=S([`instant`,`summary`]),xOe=S([`activation`,`deactivation`,`schedule`]),WK=S([`rule`,`section`]),GK=i(`mode`,[x({mode:p(`instant`)}),x({mode:p(`summary`),schedule:HK,split:WK.optional()}),x({mode:p(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:HK,grouping:WK}).optional()})]),KK=x({values:C(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),qK=x({zoneId:l().optional(),className:l().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),SOe=-96,JK=x({labels:C(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),YK=S([`enter`,`exit`,`any`]),XK=S([`raised`,`cleared`]),ZK=x({ids:C(l().min(1)).min(1),match:S([`any`,`all`]).optional()}),QK=l().min(1),$K=C(QK).max(4),eq=x({id:l().min(1).max(64),label:l().min(1).max(40),actionId:QK,icon:xu.optional(),destructive:y().optional()}),tq=x({onActivation:$K.optional(),onDeactivation:$K.optional(),onTrigger:$K.optional(),onTriggerOff:$K.optional(),buttons:C(eq).max(8).optional()}),nq=x({deviceId:n().int(),states:C(l().min(1)).min(1)}),rq=x({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),iq=x({deviceState:nq.optional(),scene:rq.optional(),devices:C(n()).optional(),devicesExclude:C(n()).min(1).optional(),classes:C(l().min(1)).optional(),classesExclude:C(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:ZK.optional(),zonesExclude:C(l().min(1)).optional(),crossing:YK.optional(),labelEquals:C(l().min(1)).optional(),identities:C(l().min(1)).optional(),plates:KK.optional(),identitiesExclude:C(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:C(l().min(1)).optional(),sensorKinds:C(l().min(1)).optional(),sensorTransition:XK.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:zK.optional(),customZones:C(EV).optional(),occupancy:qK.optional(),audio:JK.optional()}),aq=x({targetId:l().min(1),params:m(l(),w()).optional()}),COe=500,oq=S([`none`,`image`,`clip`,`gif`]),sq=x({template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:HK.optional(),priority:n().int().min(1).max(5).optional(),attachment:oq.optional(),actions:y().optional()}),cq=m(l(),sq),lq=S([`scene-boxes`,`crop`,`clean`,`none`]),uq=S([`cropped`,`full`,`boxed`]),dq=S([`mosaic`,`each`]),wOe=4,TOe=6,fq=x({image:lq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:uq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:P.optional(),linkedCameras:dq.optional(),wakeSleepingCamera:y().optional()}),pq=S([`shared`,`per-class`]),mq=x({cooldownSec:n().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:pq.optional()}),hq=1e3,gq=2e4,_q=8e3,EOe=448,vq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),yq=x({enabled:y().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:vq.optional(),timeoutMs:n().int().min(hq).max(gq).default(_q),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),DOe=5,OOe=20,kOe=60,AOe=5,jOe=0,MOe=300,bq=x({name:l().min(1).max(200),enabled:y().default(!0),delivery:MK,conditions:iq.default({}),schedule:HK.optional(),systemEventDelivery:GK.optional(),targets:C(aq),targetUsers:C(l()).optional(),targetOverrides:cq.optional(),media:fq.default({}),throttle:mq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(n().int().min(1).max(BK)).max(4).optional(),actions:tq.optional(),confirm:yq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Eh.optional()}),xq=S([`event`,`summary`,`timelapse`,`calendar-events`]),Sq=x({kind:xq,ruleId:l(),tags:C(l())}),Cq=bq.partial().extend({disabledTargetIds:C(l()).optional(),enabled:y().optional(),conditions:iq.optional(),media:fq.optional(),throttle:mq.optional(),priority:n().int().min(1).max(5).optional()}),wq=[`waitForEnhancement`,`groupIdleSec`];function NOe(e){return wq.some(t=>t===e)}var Tq=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],Eq=S(Tq),Dq=x({ruleId:l(),patch:Cq,clear:C(Eq).optional()}),Oq=bq.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:C(l()).default([])}),kq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],Aq=S(kq),jq=x({id:Aq,status:S([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),Mq=x({section:Aq.optional(),title:l(),text:l(),count:n().int().nonnegative()}),Nq=x({empty:y(),count:n().int().nonnegative(),text:l(),sections:C(jq),dropped:m(l(),n().int().nonnegative()),excludedGroups:C(l()),split:WK.optional(),rows:C(Mq).optional()}),Pq=x({recordId:l(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:y(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),Fq=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),Iq=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),Lq=x({id:S([`appliance-cycle`]),kind:Fq,title:l(),body:l()}),Rq=S([`rule`,`timelapse`,`summary`]),zq=S([`title`,`body`,`previewText`,`captionText`]),Bq=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),Vq=x({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:Bq,families:C(Rq).min(1),fields:C(zq).optional(),kinds:C(Iq).optional(),deliveries:C(MK).optional(),systemEventKinds:C(NK).optional(),systemEventDeliveries:C(UK).optional(),dynamic:x({prefix:p(`count_`),from:p(`classes`)}).optional()}),Hq=x({family:Rq,field:zq,kind:Fq.optional(),delivery:MK.optional(),systemEventKinds:C(NK).optional(),systemEventDelivery:UK.optional()}),Uq=x({context:Hq,template:x({title:l().max(500).optional(),body:l().max(2e3).optional()})}),Wq=x({title:l().nullable(),body:l().nullable(),unknown:C(l())}),Gq=x({id:l(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(MK),phase:l(),description:l().optional(),options:C(x({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),POe=[{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.`}],Kq=S([`pending`,`sent`,`dead`]),qq=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),Jq=x({className:l(),label:l().optional(),confidence:n().optional(),zones:C(l()),timestamp:n(),systemEvent:x({kind:NK,subject:l(),title:l(),body:l(),data:m(l(),w())}).optional()}),Yq=x({id:l(),ruleId:l(),ruleName:l(),delivery:MK,targetId:l(),deviceId:n(),recordKind:qq,recordId:l(),trackId:l().optional(),status:Kq,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:Jq,title:l().optional(),body:l().optional(),artifactIds:C(l().min(1)).optional(),groupedInto:l().min(1).optional()}),FOe=100,IOe=500,Xq=x({ruleId:l().optional(),deviceId:n().optional(),status:Kq.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),Zq=x({ruleId:l(),lastAt:n(),status:Kq,deviceId:n()}),Qq=x({runs:C(Zq),horizonMs:n().nonnegative().nullable()}),$q=S([`rule`,`device`,`all`]),eJ=x({scope:$q,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(BK),global:y().optional(),summary:y().optional()}),tJ=x({id:l(),userId:l(),scope:$q,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:y(),summary:y(),digestSentAt:n().optional()}),LOe=x({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),ROe=600,nJ=3600,zOe=200,rJ=n().int().min(0).max(600),iJ=n().int().min(0).max(nJ),aJ=e=>new Set(e.map(e=>e.mode)).size===e.length,oJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),sJ=x({mode:vS,exitDelaySec:rJ.optional(),entryDelaySec:rJ.optional(),triggeredDurationSec:iJ.optional(),postTriggeredAction:oJ.optional(),schedule:HK.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),BOe=C(sJ).max(8).refine(aJ,{message:`modeDelays: at most one entry per arm mode`}),cJ=x({mode:vS,exitDelaySec:rJ.nullable().optional(),entryDelaySec:rJ.nullable().optional(),triggeredDurationSec:iJ.nullable().optional(),postTriggeredAction:oJ.nullable().optional(),schedule:HK.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),VOe=C(cJ).max(8).refine(aJ,{message:`modeDelays: at most one edit per arm mode`}),lJ=x({mode:vS,deviceId:n().int().positive(),nonBlocking:y()}),uJ=x({mode:vS,deviceId:n().int().positive(),blocking:y()}),dJ=x({mode:vS,deviceId:n().int().positive(),secureOnArm:y()}),fJ=x({mode:vS,deviceIds:C(n().int()).max(200)}),pJ=fJ,mJ=fJ,hJ=fJ,gJ=C(pJ).max(8).refine(aJ,{message:`nonBlocking: at most one list per arm mode`}),_J=C(mJ).max(8).refine(aJ,{message:`blocking: at most one list per arm mode`}),vJ=C(hJ).max(8).refine(aJ,{message:`secureOnArmOff: at most one list per arm mode`}),yJ=x({exitDelaySec:rJ,entryDelaySec:rJ,triggeredDurationSec:iJ,postTriggeredAction:oJ.optional(),announceArm:y().optional(),announceTargets:C(l().min(1)).max(16),nonBlocking:gJ.default([]),blocking:_J.default([]),secureOnArmOff:vJ.default([]),modeDelays:BOe.default([])}),bJ=x({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:y()}),xJ=x({activeId:l().min(1),items:C(bJ).min(1)}),SJ=x({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),CJ=x({id:l().min(1).max(64),name:l().min(1).max(64)}),wJ=x({id:l().min(1).max(64)}),TJ=yJ.extend({nonBlocking:gJ,blocking:_J,secureOnArmOff:vJ,modeDelays:VOe,nonBlockingEdit:lJ,blockingEdit:uJ,secureOnArmEdit:dJ}).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=S([`muted`,`detection-off`,`offline`]),DJ=x({deviceId:n().int(),reason:EJ}),OJ=x({mode:vS,ruleCount:n().int().min(0),allDevices:y(),deviceIds:C(n().int()),allDevicesExcept:C(n().int()).default([]),skippedDevices:C(DJ).default([])}),HOe=x({deviceId:n().int(),name:l(),state:l(),blocking:y()}),UOe=x({deviceId:n().int(),name:l(),phase:S([`open`,`closed`])}),WOe=x({mode:vS,devices:C(HOe),unknown:C(n().int())}),GOe=x({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),KOe=x({state:_S,targetMode:vS.nullable(),availableModes:C(vS),openings:C(WOe),exclusions:C(UOe),bypassedInputs:C(GOe).default([])}),kJ=x({deviceId:n().int().nullable(),settings:yJ,profiles:xJ.optional(),coverage:C(OJ),live:KOe.optional()}),qOe=500,AJ=S([`open`,`closed`,`unknown`,`not-opening`]),jJ=x({deviceId:n().int().positive(),reading:AJ,state:l().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),MJ=x({deviceIds:C(n().int().positive()).max(500)}),NJ=x({sensors:C(jJ),readAt:n().int().nonnegative()}),JOe=60,PJ=x({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:P.optional(),ruleId:l(),ruleName:l(),reason:S([`window`,`occupancy`])}),FJ=x({rulesLoaded:y(),asks:C(PJ).readonly()}),IJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:A(x({}),x({rules:C(Oq)}),{auth:`admin`}),getRule:A(x({ruleId:l()}),x({rule:Oq.nullable()}),{auth:`admin`}),createRule:A(x({rule:bq}),x({rule:Oq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:A(Dq,x({rule:Oq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:A(x({ruleId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:A(x({ruleId:l(),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:A(x({}),x({rules:C(Sq)}),{kind:`query`,auth:`admin`}),setRuleTags:A(x({kind:xq,ruleId:l(),tags:Eh}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:A(x({}),FJ,{auth:`admin`}),listDeviceMutes:A(x({}),x({mutedDeviceIds:C(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:A(x({deviceId:n().int(),muted:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:A(x({rule:bq,lookbackMinutes:n().int().min(1).max(1440).default(60)}),x({results:C(Pq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:A(x({rule:bq}),Nq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:A(x({}),x({catalog:C(Gq),taxonomy:kK.optional()})),getTemplateCatalog:A(x({}),x({vars:C(Vq),defaults:C(Lq)})),previewTemplate:A(Uq,Wq,{kind:`mutation`,access:`view`}),getHistory:A(x({filter:Xq.default({limit:100})}),x({entries:C(Yq)}),{auth:`admin`}),getRuleLastRuns:A(x({}),Qq,{auth:`admin`}),resolveArtifactUrl:A(x({artifactId:l().min(1)}),x({url:l().nullable()}),{auth:`admin`}),listSnoozes:A(x({}),x({snoozes:C(tJ)}),{caller:`required`}),createSnooze:A(x({snooze:eJ}),x({snooze:tJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:A(x({snoozeId:l()}),x({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:A(x({}),kJ,{auth:`admin`}),setAlarmConfig:A(x({patch:TJ}),kJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:A(SJ,kJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:A(CJ,kJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:A(wJ,kJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:A(wJ,kJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:A(MJ,NJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},YOe=S([`min`,`low`,`normal`,`high`]),XOe=x({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:y().optional()}),ZOe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),LJ=x({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(N(`count`)),supports:ZOe}),QOe=x({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:YOe.optional(),channel:l().optional(),recipients:C(l()).optional(),actions:C(XOe).optional(),data:m(l(),w()).optional()}),$Oe=x({notificationId:l(),acceptedAt:n()}),RJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Notifier],methods:{send:A(QOe,$Oe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:F(`Send a notification`,`Invia una notifica`),phrase:F(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:F(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:F(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:F(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:F(`Minimal`,`Minima`)},{value:`low`,label:F(`Low`,`Bassa`)},{value:`normal`,label:F(`Normal`,`Normale`)},{value:`high`,label:F(`High`,`Alta`)}]},optional:!0}]}]}),cancel:A(x({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:n(),notificationId:l(),success:y(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:LJ,kind:`command-driven`},runtimeState:LJ,durability:`session`,history:`none`,vocabulary:{noun:F(`Notifier`,`Notificatore`),order:2110}},zJ=x({value:n().nullable().meta(N(`device`)),lastFetchedAt:n()}),BJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:zJ,kind:`push`},runtimeState:zJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:F(`the reading`,`il valore`),label:F(`Reading`,`Valore`),icon:`gauge`}]}},VJ=x({integrationId:l(),displayName:l(),requestedScopes:C(Kh),allowedRedirectPrefixes:C(l()).min(1),allowedPrivateHostPaths:C(l()).optional(),requiresPkce:y().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:C(x({id:l(),displayName:l()})).optional()}),HJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:A(v(),VJ,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},UJ=S([`text`,`timestamp`,`watermark`]),WJ=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),GJ=x({id:l(),kind:UJ,enabled:y(),text:l().optional(),position:WJ.optional(),availablePositions:C(WJ).readonly(),readOnly:y().optional(),maxCharacters:n().int().positive().optional()}),KJ=x({overlays:C(GJ).readonly()}),qJ=x({enabled:y().optional(),text:l().optional(),position:WJ.optional()}).partial(),JJ={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{setOverlay:A(x({deviceId:n(),overlayId:l(),patch:qJ}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:n(),status:KJ}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:KJ,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:F(`On-screen text`,`Testo in sovrimpressione`),order:3190}},YJ=1024,XJ=x({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(YJ).default(``)}),ZJ=i(`kind`,[x({kind:p(`none`)}),x({kind:p(`static`),text:l().max(YJ)}),x({kind:p(`template`),templateId:l().min(1).max(64)})]),QJ=x({enabled:y().default(!0),source:ZJ,schedule:HK.optional(),conditions:iq.optional()}),$J=x({slotId:l(),kind:UJ,readOnly:y(),cameraEnabled:y(),cameraText:l().optional(),binding:QJ.nullable()}),eY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),tY=x({slotId:l(),outcome:eY,text:l(),reason:l().optional()}),nY=x({ok:y(),text:l(),notes:C(l())}),rY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:A(x({deviceId:n().int()}),x({supported:y(),slots:C($J)}),{auth:`admin`}),getConditionSupport:A(x({}),x({supported:C(l()),catalog:C(Gq)}),{auth:`admin`}),setSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1),binding:QJ}),x({slot:$J,render:tY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:A(x({deviceId:n().int(),slotId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:A(x({sourceDeviceId:n().int(),targetDeviceId:n().int()}),x({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:A(x({deviceId:n().int(),slotId:l().min(1),binding:QJ.optional()}),tY,{kind:`mutation`,auth:`admin`}),previewTemplate:A(x({deviceId:n().int(),text:l().max(YJ)}),nY,{kind:`mutation`,auth:`admin`}),renderDevice:A(x({deviceId:n().int()}),x({results:C(tY)}),{kind:`mutation`,auth:`admin`}),listTemplates:A(x({}),x({templates:C(XJ)}),{auth:`admin`}),upsertTemplate:A(x({template:XJ}),x({template:XJ}),{kind:`mutation`,auth:`admin`}),deleteTemplate:A(x({templateId:l().min(1).max(64)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},iY=1e4,eke=4,tke=200,nke=S([`normal`,`offline`,`on_batteries`]),aY=n().int().min(4).max(200),oY=aY.meta(kme({quantity:`mass`,unit:`g`})),sY=x({foodLevel:n().nullable().meta(N(`none`)),bowlFood:n().nullable().meta(N(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:n().nullable().meta(N(`none`)),food2:n().nullable().meta(N(`none`)),lowFood:y(),batteryPower:n().min(0).max(100).nullable().meta(N(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(N(`duration`)),feeding:y(),status:nke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(N(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:n().meta(N(`none`)),lastFeedGrams:aY.nullable(),lastFeedHopper1:aY.nullable(),lastFeedHopper2:aY.nullable(),lastFetchedAt:n()}),cY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFeeder],methods:{feed:A(x({deviceId:n().int().nonnegative(),grams:oY.optional(),hopper1:oY.optional(),hopper2:oY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:F(`Feed`,`Dai da mangiare`),phrase:F(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:iY},openArgs:[{key:`grams`,label:F(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:F(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:F(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:iY},openArgs:[{key:`hopper1`,label:F(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:F(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:F(`Cancel feeding`,`Annulla l’erogazione`),phrase:F(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:F(`Call pet`,`Chiama l’animale`),phrase:F(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:A(x({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:F(`Desiccant replaced`,`Essiccante sostituito`),phrase:F(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:F(`Food refilled`,`Cibo ricaricato`),phrase:F(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`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:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:F(`Indicator light on`,`Spia accesa`),phrase:F(`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:F(`Indicator light off`,`Spia spenta`),phrase:F(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:F(`Feeding sound on`,`Suono di erogazione attivo`),phrase:F(`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:F(`Feeding sound off`,`Suono di erogazione spento`),phrase:F(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:A(x({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:sY,kind:`poll`},runtimeState:sY,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:F(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:F(`Food low`,`Cibo in esaurimento`),whenTrue:F(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:F(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:F(`Feeding`,`In erogazione`),whenTrue:F(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:F(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:F(`the desiccant life`,`la durata dell’essiccante`),label:F(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},lY=x({waterLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),waterVolume:n().min(0).nullable().meta(N(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:l().nullable(),lastFetchedAt:n()}),uY=`water`;function rke(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:uY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ike=n().int().nonnegative(),dY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:A(x({deviceId:ike,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:F(`Pump on`,`Pompa accesa`),phrase:F(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:F(`Pump off`,`Pompa spenta`),phrase:F(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:lY,kind:`push`},runtimeState:lY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:F(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:F(`Tank empty`,`Serbatoio vuoto`),whenTrue:F(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:F(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:F(`the water level`,`il livello dell’acqua`),label:F(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},ake=S(va),oke=2,fY={min:1,max:8},pY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),mY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),hY=i(`kind`,[x({kind:p(`capacity`),sessions:n(),minSessions:n()}),x({kind:p(`tie-faster`),over:l(),recallDelta:n()}),x({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),x({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),x({kind:p(`derived-latency`),modelId:l()}),x({kind:p(`cpu-device`)}),x({kind:p(`device-disabled`)}),x({kind:p(`device-unavailable`)}),x({kind:p(`node-offline`)}),x({kind:p(`no-hardware-facts`)}),x({kind:p(`no-measured-data`),hardwareClass:pY}),x({kind:p(`no-family-build`),format:ake}),x({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),gY=S([`custom-pin`]),_Y=i(`kind`,[x({kind:p(`table`)}),x({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),x({kind:p(`estimated`),estimatedFrom:pY})]),vY=x({modelId:l(),p50Ms:n(),fps:n(),measured:y(),source:_Y.optional(),estimatedFrom:pY.optional(),capacitySessions:n(),personRecall:n()}),yY=x({deviceKey:l(),accelerator:mY.nullable(),enabled:y(),available:y(),chosen:vY.nullable(),kept:gY.optional(),reasons:C(hY).readonly()}),bY=x({nodeId:l(),reachable:y(),hardwareClass:pY.nullable(),cpuModel:l().nullable(),skipped:y(),acceleratorModelId:l().nullable(),devices:C(yY).readonly(),reasons:C(hY).readonly()}),xY=x({stepId:l(),before:l().nullable(),after:l().nullable()}),SY=x({nodeId:l(),deviceKey:l(),madeExplicit:y(),modelPins:C(xY).readonly(),thresholds:C(x({stepId:l(),keys:C(l()).readonly()})).readonly()}),CY=i(`kind`,[x({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),x({kind:p(`custom-registry-unreadable`),error:l()})]),wY=x({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(fY.min).max(fY.max).default(2)}),TY=x({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:C(bY).readonly(),nodeChanges:C(SY).readonly(),warnings:C(CY).readonly()}),EY=x({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(fY.min).max(fY.max).default(2)}),DY=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:l()}),OY=i(`kind`,[x({kind:p(`applied`),planHash:l(),phases:C(DY).readonly()}),x({kind:p(`aborted`),phases:C(DY).readonly()}),x({kind:p(`stale`),plan:TY}),x({kind:p(`refused`),reason:S([`apply-in-progress`])})]),kY=S([`least-loaded`,`share`]),AY=`share`,ske=`sessionPlacement`;function cke(e){let t=kY.safeParse(e);return t.success?t.data:AY}var jY=x({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),MY=x({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),NY=x({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),PY=x({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:C(NY).readonly()}),FY=x({deviceId:n(),deviceKey:l(),reason:S([`disabled`,`absent`])}),IY=x({policy:kY,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:C(PY).readonly(),stalePins:C(FY).readonly()}),LY=S([`hardware`,`benchmark`]),RY=S([`no-benchmark-results`,`partial-benchmark-results`]),zY=x({headroom:n().min(.3).max(.5).default(.4),source:LY.default(`hardware`)}),BY=x({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:y(),suggestedMaxSessions:n().nullable()}),VY=x({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:C(BY).readonly(),skippedReason:l().nullable(),capacitySource:LY.nullable(),capacityFallback:RY.nullable()}),HY=x({headroom:n(),source:LY,cameraFps:n(),minSessionsPerDevice:n(),nodes:C(VY).readonly()}),UY=S([`hardware`,`benchmark`,`manual`]),WY=`benchmark`;function GY(e){return e!==`manual`}var lke=.4,uke=`shareSource`;function dke(e){if(e===`auto`)return`hardware`;let t=UY.safeParse(e);return t.success?t.data:WY}var KY=x({source:UY}),fke=x({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),qY=x({deviceKey:l(),eligible:y(),configuredPct:n(),effectivePct:n()}),JY=x({nodeId:l(),eligible:y(),configuredPct:n(),effectivePct:n(),capacitySource:LY.nullable(),capacityFallback:RY.nullable(),devices:C(qY).readonly()}),YY=x({source:UY,policy:kY,autoPending:y(),computedAt:n().nullable(),trigger:l().nullable(),nodes:C(JY).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),XY=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],ZY=S(XY),QY=S([`info`,`warning`,`critical`]),$Y=i(`type`,[x({type:p(`camera`),deviceId:n()}),x({type:p(`node`),nodeId:l()}),x({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),eX=x({id:l(),kind:ZY,severity:QY,subject:$Y,what:l(),evidence:m(l(),n().nullable()),action:l()}),tX=x({source:l(),entries:n().nullable()}),nX=x({nodeId:l(),sessionsNow:n(),unusableDevices:C(l()).readonly(),devices:C(x({deviceKey:l(),sessionsNow:n(),usable:y()})).readonly()}),rX=x({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),iX=x({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:C(eX).readonly(),cameraSignals:C(rX).readonly(),nodes:C(nX).readonly(),sources:C(tX).readonly(),notCovered:C(l()).readonly()}),aX=x({history:n().int().min(1).max(24).default(1)}),oX=x({latest:iX.nullable(),previous:C(iX).readonly()}),pke=x({engine:VU.optional(),steps:C(Ea).readonly(),audio:x({engine:VU.optional(),modelId:l().optional(),enabled:y(),settings:m(l(),w()).readonly().optional()}).nullable().optional()}),sX=x({modelId:l().optional(),settings:m(l(),w()).optional(),jumpDeviceKey:l().optional(),enabled:y().optional()}),cX=x({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:fl.optional(),stepSettings:m(l(),m(l(),w()).readonly()).optional(),stepEnabled:m(l(),y()).optional(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),sX).optional()})).optional()}),mke=m(l(),m(l(),w()).readonly()),lX=S([`pipeline`,`onboard`,`none`]),hke=x({stepToggles:m(l(),y()).optional(),stepSettings:mke.optional()}),uX=x({deviceId:n(),agentNodeId:l(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),dX=x({nodeId:l(),online:y(),load:$W,score:n(),decodeHwaccel:l().nullable()}),fX=x({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),pX=m(l(),l()),mX=x({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),hX=x({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),gX=x({streams:C(hX).readonly()}),_X=x({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),vX=x({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),yX=x({profiles:C(vX).readonly(),webrtcSessions:n(),rtspRestream:y()}),bX=x({nodeId:l()}),xX=x({enabled:y(),fps:n()}),SX=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),CX=x({state:SX,error:l().optional()}),wX=S([`idle`,`watching`,`active`]),TX=x({nodeId:l(),engine:x({backend:l(),device:l()}),phase:wX,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:CX}),EX=x({nodeId:l(),enabled:y()}),DX=Mp,OX=x({mode:DX,active:y(),storageBytes:n()}),kX=S([`source`,`broker`,`detection`,`recording`,`switches`]),AX=S([`timeout`,`error`,`partial`]),jX=x({stage:kX,reason:AX,elapsedMs:n()}),MX=x({state:S([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:C(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),NX=x({deviceId:n(),assignment:_X,source:gX,broker:yX.nullable(),decoder:bX.nullable(),motion:xX.nullable(),detection:TX.nullable(),audio:EX.nullable(),recording:OX.nullable(),switchedOff:C(wd).readonly(),cameraSensors:yV.optional(),degraded:C(jX).readonly(),fetchedAt:n()}),PX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`],FX=S(PX),gke=x({key:l(),backend:l(),device:l(),format:S(va),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),sX).optional(),exclusion:FX.nullable()}),IX=i(`kind`,[x({kind:p(`stored`),modelId:l()}),x({kind:p(`absent`),defaultModelId:l()}),x({kind:p(`unreadable`),reason:S(MV),error:l().optional()})]),_ke=x({nodeId:l(),reachable:y(),devices:C(gke).readonly()}),LX=S([`off`,`on`,`opt-in`]),RX=i(`kind`,[x({kind:p(`on`)}),x({kind:p(`off-cluster`)}),x({kind:p(`off-node`)}),x({kind:p(`off-device`)}),x({kind:p(`jump`),toDeviceKey:l()}),x({kind:p(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:p(`zone-driven`)}),x({kind:p(`supplied-by-root`),rootModelId:l()}),x({kind:p(`opt-in-unused`)})]),vke=x({deviceKey:l(),format:S(va),stepEnabled:y().nullable(),eligible:y(),cell:RX}),yke=x({nodeId:l(),reachable:y(),stepEnabled:y().nullable(),devices:C(vke).readonly()}),zX=x({steps:C(x({stepId:l(),name:l(),slot:l(),clusterMode:LX.nullable(),effectiveMode:LX,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:C(yke).readonly()})).readonly()}),BX=x({deviceId:n().int().nonnegative(),config:fV.nullable()}),VX=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),HX=x({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),UX=x({scheduled:y(),dueInMs:n().optional(),refusedBecause:VX.optional()}),WX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:A(HX,UX,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:A(x({deviceId:n(),agentNodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:A(x({deviceId:n(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:A(x({deviceId:n()}),x({deviceKey:l().nullable()})),rebalance:A(v(),x({migrated:n(),skipped:C(x({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:A(v(),C(uX).readonly()),getPipelineAssignment:A(x({deviceId:n()}),uX.nullable()),getAgentLoad:A(v(),C(dX).readonly()),getClusterModelChoice:A(x({stepId:l()}),IX),getGlobalMetrics:A(v(),fX),getCameraMetrics:A(x({deviceId:n()}),JU.nullable()),getCapabilityBindings:A(x({nodeId:l()}),pX),setCapabilityBinding:A(x({nodeId:l(),capName:l(),addonId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:A(v(),mX),assignAudio:A(x({deviceId:n(),nodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:A(x({deviceId:n()}),x({nodeId:l(),pinned:y(),assignedAt:n()}).nullable()),getAudioNodeLoad:A(v(),C(x({nodeId:l(),deviceCount:n()}))),getAudioAssignments:A(v(),C(x({deviceId:n(),nodeId:l(),pinned:y(),assignedAt:n()}))),getAgentSettings:A(x({agentNodeId:l()}),cX.nullable()),listAgentSettings:A(v(),C(x({nodeId:l(),settings:cX})).readonly()),removeAgentSettings:A(x({agentNodeId:l()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:A(x({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:A(x({agentNodeId:l(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:A(x({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:A(x({agentNodeId:l(),reachableHost:l().nullable().optional(),color:fl.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:A(x({agentNodeId:l(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),sX).optional()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:A(x({agentNodeId:l(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:A(x({stepId:l(),mode:LX.nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:A(x({agentNodeId:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:A(x({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:A(v(),zX),getNodeInferenceDevices:A(x({nodeId:l()}),_ke),forgetInferenceDevice:A(x({agentNodeId:l(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:A(x({agentNodeId:l()}),x({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:A(wY,TY,{auth:`admin`}),applyAutoTune:A(EY,OY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:A(jY,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:A(MY,IY,{auth:`admin`}),getHealthDigest:A(aX,oX,{auth:`admin`}),suggestShares:A(zY,HY,{auth:`admin`}),getEffectiveShares:A(v(),YY,{auth:`admin`}),setShareSource:A(KY,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:A(rW,cW,{auth:`admin`}),startNodeBenchmark:A(rW,i(`kind`,[x({kind:p(`started`),runId:l()}),x({kind:p(`refused`),preflight:cW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:A(v(),CW,{auth:`admin`}),abortNodeBenchmark:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:A(x({nodeId:l()}),DW,{auth:`admin`}),listNodeBenchmarkResults:A(TW,C(EW).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:A(x({id:l()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:A(x({deviceId:n()}),hke.nullable()),setCameraStepToggle:A(x({deviceId:n(),addonId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:A(x({deviceId:n()}),x({source:lX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:A(x({deviceId:n(),source:lX}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:A(x({deviceId:n(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:A(x({deviceId:n(),agentNodeId:l().optional()}),pke),getCameraSwitches:A(x({deviceId:n()}),Ad,{role:`viewer`}),setCameraSwitch:A(x({deviceId:n(),switchId:wd,enabled:y()}),Ad,{kind:`mutation`,auth:`admin`}),getCameraStatus:A(x({deviceId:n()}),NX),getCameraStatuses:A(x({deviceIds:C(n()).optional()}),C(NX).readonly()),setCameraSensors:A(BX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(v(),MX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:A(v(),MX,{auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},GX=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),bke=x({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:AS.optional()}),KX=x({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:y(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:y(),plateBbox:AS.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),xke=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),Ske=x({plateIds:C(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),qX={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:A(x({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}).optional(),C(KX).readonly()),getPlateByTrack:A(x({deviceId:n().int(),trackId:l()}),KX.nullable(),{role:`viewer`}),getPlateMedia:A(x({plateId:l()}),C(xke).readonly()),searchPlates:A(x({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}),C(KX).readonly()),suggestPlateClusters:A(x({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),C(Ske).readonly()),correctPlateText:A(x({plateId:l(),text:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:A(x({includeCrops:y().optional()}).optional(),C(GX).readonly()),createVehicle:A(x({name:l().min(1)}),GX,{kind:`mutation`,auth:`admin`}),renameVehicle:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:A(x({vehicleId:l()}),C(bke).readonly()),removeVehicleSample:A(x({vehicleId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:A(x({sampleId:l().min(1),toVehicleId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:A(x({plateId:l(),vehicleId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:A(x({plateIds:C(l()).min(1),vehicleId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:A(x({plateIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},JX={"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}}}},YX={"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}},XX=.5,Cke=2,wke=.05,Tke=24,Eke=750,Dke=64,ZX=2e3,Oke=12,QX=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),$X=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),eZ=x({int8:QX,fp16:QX}),tZ=x({deviceKey:l(),fullDeviceName:$X,executionUnits:QX,clockMHz:QX,gops:eZ.nullable(),architecture:$X,npuName:$X,tops:QX,vendor:$X,webgpuArchitecture:$X,webgpuDevice:$X,computeUnits:QX}),kke=x({accelerators:C(tZ).nullable()}),nZ=[{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*ZX}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function Ake(e){let t=kke.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function rZ(e){return e!==null&&e>0?e:null}function iZ(e){let t=[],n=rZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=rZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=rZ(e.executionUnits),a=rZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=rZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=rZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function aZ(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 oZ(e,t,n){for(let r of iZ(e))if(aZ(t,r,n)!==null)return r;return null}function sZ(e,t,n=nZ){return oZ(e,t,n)!==null}function cZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function jke(e){return Math.round(e*10)/10}function Mke(e){return Math.min(2,Math.max(XX,e))}function Nke(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:jke(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function lZ(e){let t=e.perf??JX,n=e.references??nZ,r=cZ(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:oZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=aZ(e.accelerator,i,n),o=a===null?void 0:cZ(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:Nke(o,Mke(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var uZ=S(va),Pke=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),Fke=x({preferred:C(l()).readonly(),rationale:l()}),dZ=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:dZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:l().optional()})).readonly(),defaultH264:dZ,defaultH265:dZ,probedAt:n()}),x({methods:C(l()).readonly(),probedAt:n()});var Ike=S([`darwin`,`linux`,`win32`]),Lke=S([`arm64`,`x64`]),Rke=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),zke=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),fZ=S([`usb`,`pci`]),Bke=x({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:C(x({bus:fZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:fZ,count:n().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),pZ=x({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),Vke=i(`usable`,[pZ.extend({usable:p(!0)}),pZ.extend({usable:p(!1),reason:S([`no-cuda-execution-provider`])})]),mZ=x({platform:Ike,arch:Lke,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:Rke.nullable(),npu:zke.nullable(),coral:Bke.nullable().optional(),nvidia:Vke.nullable().optional(),accelerators:C(tZ).readonly().optional()}),hZ=x({runtime:p(`python`),backend:l(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:y()}),gZ=x({key:l(),backend:l(),device:l(),format:uZ,runtime:p(`python`),score:n(),available:y()}),Hke=x({hardware:mZ,scores:C(hZ).readonly(),bestScore:hZ,pythonPath:l().nullable(),devices:C(gZ).readonly()}),Uke=x({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:C(l()).readonly()}),Wke=x({modelId:l(),runtime:p(`python`),backend:l(),format:uZ,reason:l()}),Gke=x({devices:C(gZ).readonly(),appeared:C(l()).readonly(),disappeared:C(l()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),_Z={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:A(v(),Hke),getHardware:A(v(),mZ),resolveInferenceConfig:A(x({requirements:C(Uke).readonly()}),Wke),resolveHwAccel:A(x({prefer:Pke}),Fke),rescanAccelerators:A(v(),Gke,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.CLUSTER}},vZ=x({power:n().optional().meta(N(`power`,{label:`Power`})),deliveredPower:n().optional().meta(N(`power`,{label:`Delivered`})),energy:n().optional().meta(N(`energy`,{label:`Energy`})),voltage:n().optional().meta(N(`voltage`,{label:`Voltage`})),current:n().optional().meta(N(`current`,{label:`Current`})),apparentPower:n().optional().meta(N(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(N(`ratio`)),lastFetchedAt:n()});function Kke(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var yZ=[E.Sensor,E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],qke=yZ.filter(e=>e!==E.Sensor);function bZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:qke,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 Jke={version:1,targets:[bZ(`power`,`W`),bZ(`energy`,`kWh`),bZ(`voltage`,`V`),bZ(`current`,`A`)]},xZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:yZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:vZ,kind:`push`},runtimeState:vZ,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:Jke,vocabulary:{noun:F(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:F(`the power draw`,`il consumo`),label:F(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:F(`the energy used`,`l’energia consumata`),label:F(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:F(`the voltage`,`la tensione`),label:F(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:F(`the current`,`la corrente`),label:F(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},Yke=x({latitude:n().min(-90).max(90).meta(N(`angle`)),longitude:n().min(-180).max(180).meta(N(`angle`)),accuracyMeters:n().nonnegative().meta(N(`length`))}),SZ=x({state:l(),location:l().nullable(),gps:Yke.nullable(),lastChangedAt:n()}),CZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Presence],methods:{},status:{schema:SZ,kind:`push`},runtimeState:SZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:F(`Where`,`Posizione`),phrase:F(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},wZ=x({pressure:n().nullable().meta(N(`pressure`,{precision:0})),lastFetchedAt:n()}),TZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:wZ,kind:`push`},runtimeState:wZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:F(`the pressure`,`la pressione`),label:F(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},EZ=i(`kind`,[TV,EV]),DZ=x({id:n(),enabled:y(),shape:EZ}),OZ=x({enabled:y(),regions:C(DZ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:n()}),kZ=x({maxRegions:n(),supportedShapes:C(kV),polygonVertices:AV.optional(),supportsAudioMute:y()}),AZ=x({enabled:y().optional(),regions:C(DZ).optional()}),jZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:A(x({deviceId:n()}),kZ),setMask:A(x({deviceId:n(),patch:AZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:F(`Privacy mask on`,`Maschera privacy attiva`),phrase:F(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:F(`Privacy mask off`,`Maschera privacy spenta`),phrase:F(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:F(`Microphone on`,`Microfono attivo`),phrase:F(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:F(`Microphone off`,`Microfono spento`),phrase:F(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:OZ,kind:`poll`},runtimeState:OZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:F(`Privacy mask`,`Maschera privacy`),whenTrue:F(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:F(`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:F(`Microphone`,`Microfono`),whenTrue:F(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:F(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function Xke(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var MZ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),NZ=x({id:l(),name:l(),fn:MZ.nullable(),writable:y()}),PZ=x({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),FZ=x({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),IZ=PZ.extend({autofocus:y()}),LZ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:n().optional(),hasAutofocus:y(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),RZ=x({presetId:l().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),zZ=x({enabled:y(),seconds:n().int()}),BZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:A(FZ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:A(FZ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:F(`PTZ go home`,`Torna alla posizione iniziale`),phrase:F(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:A(x({deviceId:n()}),C(NZ)),goToPreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:F(`PTZ go to preset`,`Vai a un preset`),phrase:F(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:A(x({deviceId:n(),presetId:l(),name:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:F(`Save PTZ preset here`,`Salva qui un preset`),phrase:F(`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:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:F(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:A(x({deviceId:n()}),LZ),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:F(`Stop moving`,`Ferma il movimento`),phrase:F(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:A(x({deviceId:n()}),RZ),setHomePreset:A(x({deviceId:n(),presetId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:F(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:F(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:F(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:F(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:A(x({deviceId:n()}),zZ.nullable()),setHomeReturn:A(x({deviceId:n(),enabled:y(),seconds:n().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:F(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:F(`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:F(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:F(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:A(x({deviceId:n()}),PZ),setAutofocus:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:F(`Autofocus on`,`Autofocus attivo`),phrase:F(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:F(`Autofocus off`,`Autofocus spento`),phrase:F(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:IZ,kind:`command-driven`},vocabulary:{noun:F(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},VZ=x({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(N(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(N(`duration`))}),HZ=x({value:l(),label:l()}),UZ=x({enabled:y(),lastChangedAt:n(),currentSettings:VZ.nullable(),supportedTargetTypes:C(HZ)}),WZ=UZ.extend({lastFetchedAt:n()}),GZ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:A(x({deviceId:n()}),UZ),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:F(`Autotrack on`,`Inseguimento attivo`),phrase:F(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:F(`Autotrack off`,`Inseguimento spento`),phrase:F(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:A(x({deviceId:n()}),VZ.nullable()),setSettings:A(x({deviceId:n(),settings:VZ.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:n(),status:UZ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:UZ,kind:`command-driven`},runtimeState:WZ,durability:`session`,history:`none`,vocabulary:{noun:F(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:F(`Autotracking`,`Inseguimento automatico`),whenTrue:F(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:F(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},KZ=x({enabled:y().nullable(),onTime:n().min(0).nullable().meta(N(`duration`)),offTime:n().min(0).nullable().meta(N(`duration`)),lastFetchedAt:n()}),qZ=n().int().nonnegative(),JZ=n().int().min(0),YZ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],methods:{setEnabled:A(x({deviceId:qZ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:F(`Pump cycle on`,`Ciclo pompa attivo`),phrase:F(`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:F(`Pump cycle off`,`Ciclo pompa spento`),phrase:F(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:A(x({deviceId:qZ,minutes:JZ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:F(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:A(x({deviceId:qZ,minutes:JZ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:F(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:KZ,kind:`push`},runtimeState:KZ,durability:`session`,history:`none`,vocabulary:{noun:F(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:F(`Pump cycle`,`Ciclo pompa`),whenTrue:F(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:F(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},XZ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Switch,E.Gateway],methods:{reboot:A(x({deviceId:n().int().nonnegative()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:F(`Reboot device`,`Riavvia il dispositivo`),phrase:F(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:F(`Reboot`,`Riavvio`),order:3240}},ZZ=x({owner:l(),kind:Jr,title:l(),nameField:l(),fields:m(l(),w()),secretPaths:C(l()),rows:n().int().nonnegative()}),QZ=x({id:jB,name:l(),rev:n().int(),updatedAt:n(),data:MB}),$Z={owner:l().min(1),kind:Jr},eQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:A(x({}),x({kinds:C(ZZ)}),{auth:`admin`}),listEntries:A(x({...$Z}),x({entries:C(QZ)}),{auth:`admin`}),putEntry:A(x({...$Z,id:jB.optional(),data:MB,ifRev:n().int().min(1).optional()}),x({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:A(x({...$Z,id:jB}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Zke=`camstack`,Qke=`recorder`,tQ=x({profile:l(),startMs:n(),endMs:n()}),nQ=S([`read`,`unreadable`]),rQ=x({deviceId:n(),read:nQ,ranges:C(tQ),profilesWithFootage:C(l())}),iQ=x({deviceId:n(),read:nQ,days:C(n())}),aQ=x({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:C(l())}),oQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),sQ=x({source:l(),label:l(),addonId:l().optional(),availability:oQ}),cQ=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly(),exclusive:y()}),lQ=i(`kind`,[x({kind:p(`hls`),manifest:aQ}),x({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),x({kind:p(`none`),reason:l()})]),uQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listSources:A(x({deviceId:n()}),C(sQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),rQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),iQ,{kind:`query`,auth:`protected`}),getPlayback:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:P.optional()}),lQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(x({deviceId:n(),provider:l().min(1)}),cQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Recording`,`Registrazione`),order:3250}},dQ=x({deviceId:n(),enabled:y(),activeMode:Mp,nodeId:l(),storageBytes:n()}),$ke=200,fQ=x({deviceId:n(),read:S([`read`,`unreadable`]),ranges:C(tQ).readonly(),profilesWithFootage:C(l()).readonly()}),pQ=x({deviceId:n(),read:S([`read`,`unreadable`]),days:C(n()).readonly()}),mQ=x({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),hQ=x({locationId:l().nullable(),locationIds:C(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),gQ=x({nodeId:l(),totalUsedBytes:n(),devices:C(mQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(hQ).optional()}),_Q=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),vQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),yQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:vQ}),bQ=x({moves:C(_Q),skipped:C(yQ),bytesToMove:n(),jobIds:C(l())}),xQ=x({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),eAe=x({deviceId:n().int(),profile:l(),locationId:l()}),tAe=x({deviceId:n().int(),locationId:l()}),nAe=x({assignments:C(eAe),pins:C(tAe),defaultLocations:m(l(),l())}),rAe=x({deviceId:n().int(),locationId:l().nullable()}),SQ=i(`kind`,[x({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),x({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),CQ=x({data:b(Uint8Array)}),wQ=x({data:b(Uint8Array),gopStartMs:n(),gopDurMs:n()}),TQ=i(`kind`,[x({kind:p(`ok`),data:b(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:y()}),x({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),EQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:dQ,kind:`command-driven`},methods:{getAvailabilityBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n()}),C(fQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),C(pQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:A(x({}),gQ,{kind:`query`,auth:`admin`}),getDeviceConfig:A(x({deviceId:n()}),Hp,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:A(x({deviceId:n(),profile:l(),epochMs:n()}),SQ,{kind:`query`,auth:`admin`}),readSegmentBytes:A(x({deviceId:n(),profile:l(),startMs:n()}),CQ,{kind:`query`,auth:`admin`}),readGopBytes:A(x({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),wQ,{kind:`query`,auth:`admin`}),readWindowBytes:A(x({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),TQ,{kind:`query`,auth:`admin`}),setDeviceConfig:A(x({deviceId:n(),config:Hp}),Hp,{kind:`mutation`,auth:`admin`}),rescanStorage:A(x({deviceId:n()}),dQ,{kind:`mutation`,auth:`admin`}),pruneFootage:A(x({deviceId:n(),reason:Sp.optional()}),x({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:A(x({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),x({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(wp,C(Cp).readonly(),{kind:`query`,auth:`admin`}),renderGif:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),x({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),x({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(Xp,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Zp,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),qp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:A(Yp,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:A(x({}),C(qp).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:A(Cm,wm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:A(Tm,km,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:A(xQ,bQ,{kind:`query`,auth:`admin`}),startStorageRebalance:A(xQ,bQ,{kind:`mutation`,auth:`admin`}),getPlacement:A(x({}),nAe,{kind:`query`,auth:`admin`}),setDevicePlacement:A(rAe,x({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.STORAGE}},iAe=24,aAe=3,oAe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),sAe=S([`deferred`,`final`]),cAe=`x-camstack-reason`,lAe=500;function uAe(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 dAe=`x-camstack-reason-code`,fAe=`x-camstack-disposition`,pAe=`x-camstack-clip-transport`,DQ=x({id:l(),source:l(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:n(),endMs:n()}),labels:C(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:C(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:C(x({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:C(l()).optional(),behaviours:C(l()).optional(),streams:x({sub:x({id:l(),bytes:n().optional()}).optional(),main:x({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:l().optional(),inProgress:y().optional()}),OQ=x({playbackUrl:l(),format:S([`hls`,`mp4`]).optional(),served:P.optional(),playbackEndpoints:C(l()).optional(),token:l().optional()}),kQ=S([`authorised`]),mAe=50*1024*1024,hAe=500*1024*1024,AQ=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:P,durationMs:n().positive().optional()}),jQ=x({ticket:ri,contentType:l(),name:l(),served:P,durationMs:n().positive().optional()}),MQ=S([`opus`,`pcmu`,`none`]),NQ=S([`not-requested`,`unsupported-ask`]),PQ=x({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:P,servedAudio:MQ,audioReason:NQ.optional()}),FQ=[.25,.5,1,1.5,2,4,8],IQ=[.25,.5,1,1.5,2,4],LQ=[.25,.5,1],RQ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly()}),zQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),BQ=x({source:l(),label:l(),addonId:l().optional(),availability:zQ}),VQ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:A(x({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),C(DQ).readonly(),{kind:`query`,auth:`protected`}),listSources:A(x({deviceId:n()}),C(BQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:A(x({deviceId:n(),clipId:l(),profile:P.optional()}),OQ,{kind:`query`,auth:`protected`}),readClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:kQ.optional()}),AQ,{kind:`query`,auth:`protected`}),offerClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:kQ.optional()}),jQ,{kind:`query`,auth:`protected`}),dialClipStream:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),audio:MQ.optional(),wake:kQ.optional()}),PQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:j(x({deviceId:n(),provider:l().min(1)}),RQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Video clips`,`Clip video`),order:3330}},gAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:IQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:LQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:FQ}},HQ=n().min(.25).max(32),UQ=x({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),_Ae=200,WQ=x({everyMs:n().int().positive(),ranges:C(UQ).min(1).max(200)}),GQ=x({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:WQ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:le.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),KQ=x({speed:HQ.optional(),timelapse:GQ.optional(),includeAudio:y(),maxLifeMs:n().int().positive(),deleteAfterDownload:y(),title:l().max(200).optional(),notifyTargetIds:C(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:le.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),qQ=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),JQ=x({kind:p(`footage`),deviceId:n(),profiles:C(l()).min(1),fromMs:n(),toMs:n()}),YQ=x({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:x({sinceMs:n(),untilMs:n()}),profile:S([`high`,`mid`,`low`]),wake:kQ.optional()}),XQ=i(`kind`,[JQ,YQ]),ZQ=x({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:XQ.optional(),options:KQ,state:qQ,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:y(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),QQ=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function vAe(e,t){return t.length>0?`${e}: ${t}`:e}function yAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=QQ.safeParse(t.trim());return n.success?n.data:null}var $Q=x({url:l(),endpoints:C(l())}),bAe=50*1024*1024,e$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function t$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var xAe=x({deviceId:n(),profile:l().optional(),profiles:C(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:XQ.optional(),options:KQ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:le.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:le.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:le.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:le.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:t$(e)).length<1&&t.addIssue({code:le.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function SAe(e){if(e.subject!==void 0)return e.subject;let t=t$(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 CAe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var n$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:A(xAe,ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:A(x({deviceId:n().optional()}),C(ZQ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:A(x({exportId:l()}),$Q,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:A(x({exportId:l()}),e$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},r$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),i$=x({trigger:r$,day:n().int().min(0).max(6).meta(N(`none`)),startMinute:n().int().min(0).max(1439).meta(N(`none`)),endMinute:n().int().min(1).max(1440).meta(N(`none`))}),a$=x({id:l(),label:l().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:y().optional()}),o$=i(`kind`,[x({kind:p(`present`),volumes:C(a$)}),x({kind:p(`absent`),reason:l()}),x({kind:p(`unknown`),reason:l()})]),s$=x({id:l(),enabled:y(),isVideo:y(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:y().nullable()}),c$=x({storage:o$,tracks:C(s$),primaryTrackId:l().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:n().nullable().meta(N(`duration`)),postRecordSec:n().nullable().meta(N(`duration`)),segmentMinutes:n().nullable().meta(N(`none`)),windows:C(i$),unreadableWindows:n().meta(N(`count`)),recordingToNowhere:y(),lastFetchedAt:n()}),l$=x({min:n(),max:n(),step:n()}),u$=x({values:C(n()).min(1),sentinel:x({value:n(),meaning:S([`no-limit`,`disabled`])}).optional()}),d$=x({readable:y(),writable:y(),reason:l().optional()}),f$=x({support:d$,granularityMinutes:n(),triggers:C(r$),supportsOverlappingTriggers:y()}),p$=x({enabled:d$,overwriteWhenFull:d$,preRecordSec:d$,preRecordSecRange:l$.optional(),preRecordSecAllowed:u$.optional(),postRecordSec:d$,postRecordSecRange:l$.optional(),postRecordSecAllowed:u$.optional(),segmentMinutes:d$,segmentMinutesRange:l$.optional(),segmentMinutesAllowed:u$.optional(),schedule:f$}),m$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:C(i$).optional()}),h$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:A(x({deviceId:n()}),p$),setSettings:A(x({deviceId:n(),settings:m$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:F(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:F(`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:F(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:F(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:c$,kind:`poll`},runtimeState:c$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:F(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:F(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:F(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},g$=x({active:y(),reason:l(),lastChangedAt:n()}),_$=g$.extend({lastFetchedAt:n()}),v$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getStatus:A(x({deviceId:n()}),g$)},status:{schema:g$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:_$,durability:`session`,history:`none`,vocabulary:{noun:F(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:F(`Recording`,`In registrazione`),whenTrue:F(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:F(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},y$=x({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),w()).optional(),argUnits:m(l(),l().min(1)).optional()}),b$=x({action:y$}),x$=x({key:l().refine(CE,{message:`a lowercase slug`}),name:l().min(1).max(60)}),wAe=200,TAe=100;function EAe(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=IE(a);e!==null&&s(e,`payload`)}for(let t of FE(a))bE(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 S$=x({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),C$=x({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),b$),customButtons:C(x$).max(100),sources:C(NE).max(200).default([]),stepDelayMs:n().int().min(100).max(PE).default(500),refusedSources:C(S$).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)bE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):EE(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=TE(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}EAe(e,t)}),DAe=se({sources:C(w())}),OAe=x({id:l(),name:l()}).partial();function kAe(e){let t=DAe.safeParse(e);if(!t.success)return w$(C$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=NE.safeParse(e),a=i.success&&i.data.kind===`ir`?IE(i.data):null;if(i.success&&a===null){n.push(e);return}let o=OAe.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=w$(C$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function w$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var AAe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},jAe=x({power:x({state:S([`on`,`off`]),at:n()}).nullable(),muted:x({value:y(),at:n()}).nullable(),source:x({name:l(),at:n()}).nullable().default(null)}),MAe={power:null,muted:null,source:null},NAe=24,PAe=50,T$=[`rect`,`rounded`,`round`,`pill`],E$=S(T$),D$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],O$=S(D$),k$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],A$=S(k$),j$=x({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:DE,shape:E$.optional(),tone:O$.optional(),showLegend:y().optional(),groupId:l().min(1).max(40).optional()}),M$=x({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:A$,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function N$(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 P$(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 FAe(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&&N$(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`]),P$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>N$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var F$=x({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:C(j$).max(200),groups:C(M$).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)}}),FAe(e,t)}),IAe=50,I$=x({role:DE,label:l().optional(),custom:y()}),L$=x({layoutTemplateId:l().nullable(),commands:C(I$),sources:C(NE)}),R$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],z$=S(R$),B$=i(`status`,[x({status:p(`sent`),sends:n().int().min(1)}),x({status:p(`skipped`),reason:p(`already-in-state`)}),x({status:p(`refused`),reason:z$,detail:l().optional(),step:x({index:n().int().min(1),role:l()}).optional()})]),V$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],H$=S(V$),U$=i(`status`,[...B$.options,x({status:p(`not-routed`)})]),W$=[`unknown-template`,`not-a-media-player`],G$=i(`status`,[x({status:p(`saved`)}),x({status:p(`refused`),reason:S(W$),detail:l()})]),K$=x({deviceId:n().int().nonnegative()}),LAe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[E.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},q$={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:A(K$,C$,{auth:`admin`}),setConfig:A(K$.extend({config:C$}),G$,{kind:`mutation`,auth:`admin`}),listCommands:A(K$,L$,{auth:`protected`}),sendCommand:A(K$.extend({role:DE,repeat:n().int().min(1).max(50).default(1)}),B$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:A(K$,HE.nullable(),{auth:`protected`}),sendMediaCommand:A(K$.extend({command:H$,muted:y().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),U$,{kind:`mutation`,auth:`protected`})},customize:LAe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},J$=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],Y$=S(J$),RAe=40,zAe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,X$=x({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:DE,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:E$.optional(),tone:O$.optional(),showLegend:y().optional()}),Z$=x({id:l().max(80).regex(zAe,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:x({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:Y$,size:x({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:x({frame:A$,title:l().min(1).max(40).optional()}).nullable(),buttons:C(X$).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&&N$(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`]})}),Q$={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:A(x({}),C(Z$),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},$$=x({deviceId:n().int().nonnegative(),resetToSource:y().optional()}),e1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Container,E.Workload,E.WeatherStation],methods:{resync:A($$,lA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:F(`Re-sync`,`Risincronizzazione`),order:3245}},BAe=5,VAe=2,t1=3e4,n1=18e4,r1={startDwellMs:t1,stopDwellMs:n1,minSamples:2},i1={[E.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function a1(e){return e!==void 0&&i1[e]!==void 0}function o1(e){return e===void 0?r1:i1[e]??r1}var HAe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},s1=S([`native`,`assigned`]),c1=x({running:y().nullable(),since:n().nullable().meta(N(`none`)),source:s1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),l1=x({deviceId:n(),since:n().nullable(),phase:l().nullable()}),UAe=Object.values(E),u1=[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.PetFeeder],WAe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:u1,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:t1,defaultStopDwellMs:n1,deviceTypeDefaults:i1,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}]},d1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:UAe,methods:{},events:{onStarted:{data:l1,trigger:{category:T.RunningStarted,label:F(`Started running`,`Ha iniziato a funzionare`),phrase:F(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:l1,trigger:{category:T.RunningFinished,label:F(`Finished`,`Ha finito`),phrase:F(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:c1,kind:`push`},runtimeState:c1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:WAe,vocabulary:{noun:F(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:F(`Running`,`In funzione`),whenTrue:F(`When {device} starts`,`Quando {device} inizia`),whenFalse:F(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[E.Washer]:{state:{running:{whenTrue:F(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:F(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[E.Dryer]:{state:{running:{whenTrue:F(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:F(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[E.Dishwasher]:{state:{running:{whenTrue:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},f1=l(),GAe=[`day`,`ir`,`night`,`dawn`,`dusk`],p1=S([`skip`,`judge-anyway`]),KAe=`__diverged__`,m1=S([`matched`,`diverged`,`unknown`]),h1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),g1=x({embedding:C(n()),modelId:l(),condition:f1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:C(n()).optional()}),_1=x({id:l(),label:l(),references:C(g1),textPrompts:C(l()).optional(),referenceCount:n(),currentlyMatched:y()}),v1=i(`mode`,[x({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),x({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),qAe=60,JAe=120,YAe=60,y1=.85,b1=`skip`,x1=8e3,XAe=448,ZAe=!0,S1=x({enabled:y().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default(x1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),C1=x({id:l(),label:l(),roi:TV,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:v1,states:C(_1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:f1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:m1,latched:y(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:S1.optional(),anchorThreshold:n().min(0).max(1).default(y1),autoRestore:y().default(!1),onUncoveredCondition:p1.default(b1),suspendedCondition:f1.nullable().default(null),unavailable:h1.nullable(),coveredConditions:C(f1)}),w1=x({monitors:C(C1),lastFetchedAt:n()}),T1=x({deviceId:n(),status:w1.nullable()}),E1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listScenes:A(x({deviceId:n()}),w1),listScenesBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(T1).readonly()),createScene:A(x({deviceId:n(),label:l(),roi:TV,check:v1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),C1,{kind:`mutation`,auth:`admin`}),updateScene:A(x({deviceId:n(),monitorId:l(),patch:x({label:l().optional(),roi:TV.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:v1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:p1.optional(),confirm:S1.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:A(x({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:f1.optional()}),x({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:A(x({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:F(`Re-check a scene`,`Ricontrolla una scena`),phrase:F(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:F(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:A(x({deviceId:n(),monitorId:l(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:w1,kind:`push`},runtimeState:w1,durability:`session`,history:`none`,vocabulary:{noun:F(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:F(`Scene changed`,`Scena cambiata`),phrase:F(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},D1=x({schedulerId:l().min(1)}),O1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(Pv),{auth:`admin`}),get:A(D1,x({scheduler:Pv.nullable()}),{auth:`admin`}),create:A(x({scheduler:Nv}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),update:A(x({schedulerId:l().min(1),scheduler:Nv}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),delete:A(D1,v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:y()}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),preview:A(x({schedulerId:l().min(1),date:l().regex(Bv).optional()}),Hv,{auth:`admin`}),conflicts:A(x({scheduler:Nv,schedulerId:l().min(1).optional()}),x({conflicts:C(Uv)}),{auth:`admin`}),getStatus:A(x({}),C(Gv),{auth:`admin`}),getTraces:A(D1,x({traces:C(ny)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},k1=x({isRunning:y(),lastRunAt:n(),lastRunSuccess:y().nullable(),lastError:l().nullable(),lastChangedAt:n()}),A1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Script],methods:{run:A(x({deviceId:n().int().nonnegative(),variables:m(l(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:F(`Run script`,`Esegui lo script`),phrase:F(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:iY}}]}),stop:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:F(`Stop script`,`Ferma lo script`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:k1,kind:`push`},runtimeState:k1,durability:`session`,history:`none`,vocabulary:{noun:F(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},j1=S([`workspace`,`baked`,`data-root`]),M1=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),N1=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),P1=x({state:N1,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:l()}),F1=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),I1=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:l()}),L1=x({kind:F1,evidence:C(I1),currentVersion:l().nullable()}),R1=x({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),z1=x({version:l(),update:x({available:y(),downloaded:y(),version:l().nullable(),checking:y(),error:l().nullable()}),stateAtMs:n(),stale:y()}),B1=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),V1=x({accepted:y(),reason:B1.nullable()}),H1=x({runnerId:l(),addonIds:C(l()),reason:l()}),U1=x({checkedAtMs:n(),expected:n(),running:n(),failed:C(l()),refused:C(H1),missing:C(l()),pending:C(l()).optional(),planKnown:y()}),W1=x({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:y().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),bootMode:j1,updateState:M1,pendingVersion:l().nullable(),rolledBack:R1.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:n().nullable(),imageContract:P1.optional(),wrapper:L1.optional(),runners:U1.optional(),desktopApp:z1.optional()}),G1=x({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:y().optional()}),K1=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),q1=x({addonId:l(),reason:l(),remedy:l()}),J1=x({accepted:y(),targetVersion:l().nullable(),restarting:y(),message:l(),outcome:K1.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:C(q1).optional(),unmet:C(au).optional(),requiredAddonUpdates:C(ou).optional()}),Y1=x({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),QAe=x({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),$Ae=Y1.extend({restartRequired:y()}),X1={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:A(v(),W1,{auth:`admin`}),checkServerUpdate:A(v(),G1,{kind:`mutation`,auth:`admin`}),applyServerUpdate:A(x({version:l().optional(),acknowledgeRefusals:y().optional()}),J1,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:A(v(),V1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:A(v(),J1,{kind:`mutation`,auth:`admin`}),restartServer:A(v(),J1,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:A(v(),Y1,{auth:`admin`}),setLaunchOverrides:A(QAe,$Ae,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},Z1={Seconds:`seconds`,Plays:`plays`},Q1={Camera:`camera`,Fallback:`fallback`},$1=x({min:n().positive(),max:n().positive(),step:n().positive()}),e0=x({allowedSeconds:C(n().positive()).nullable(),rangeSeconds:$1.nullable(),defaultSeconds:n().positive(),allowedPlays:C(n().int().positive()).nullable().default(null),rangePlays:$1.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:S([Z1.Seconds,Z1.Plays]),secondsPerPlay:n().positive().nullable(),source:S([Q1.Camera,Q1.Fallback]),fetchedAt:n()}),t0=x({active:y(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:n()}),n0=x({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().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`]}),r0=t0.extend({lastFetchedAt:n()}),i0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Siren],methods:{getOptions:A(x({deviceId:n().int().nonnegative()}),e0,{kind:`query`,auth:`protected`}),getPlayChoices:A(x({deviceId:n().int().nonnegative()}),C(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:A(n0,t0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:F(`Sound the siren`,`Fai suonare la sirena`),phrase:F(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:F(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:F(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:F(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:A(x({deviceId:n().int().nonnegative()}),t0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:F(`Silence the siren`,`Zittisci la sirena`),phrase:F(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:n(),active:y(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:t0,kind:`command-driven`},runtimeState:r0,durability:`session`,history:`none`,vocabulary:{noun:F(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:F(`Siren sounding`,`Sirena in funzione`),whenTrue:F(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:F(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},a0=x({detected:y(),lastChangedAt:n()}),o0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:a0,kind:`push`},runtimeState:a0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},eje=3,s0=5*1024*1024,c0=`<!--camstack-images-->`,l0=x({ticket:ri,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:S([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),u0=0;function d0(e){return u0+=1,`camstack_${e}_${u0.toString(36)}_${Date.now().toString(36)}`}function tje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function f0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function nje(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function p0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function rje(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 __e(e){return`subjects`in e?e.subjects:e.classes.map(Wg)}var v_e=new Set(Object.values(Vg.mapping));function y_e(e){return Vg.mapping[e]??e}function b_e(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n===r?!0:v_e.has(n)&&y_e(r)===n}function x_e(e){return e===`start`||e===`update`||e===`end`}var S_e=class{trigger;fired=new Map;subjects;constructor(e){this.trigger=e,this.subjects=__e(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`||!x_e(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=Gg(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 C_e(e){return`classes`in e}function w_e(e){return e===`appeared`||e===`departed`}function T_e(e,t){let{deviceId:n,entryId:r,phase:i}=t;if(typeof n!=`number`||typeof r!=`string`||!w_e(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=C_e(e)?e.classes?.map(Wg):e.subjects;if(c!==void 0){let e=Gg(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}}var nb=x({deviceId:n(),eventType:l(),sourceId:l().optional(),data:m(l(),w()).nullable(),timestamp:n().meta(N(`none`)),seq:n().meta(N(`count`))}),rb=x({eventTypes:C(l()),vocabulary:C(Gpe).default([]),lastEvent:nb.nullable(),eventCountSinceStart:n().meta(N(`count`))}),ib={name:`event-emitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EventEmitter],methods:{},events:{onEvent:{data:nb,trigger:{category:T.EventEmitted,label:F(`Fired an event`,`Ha generato un evento`),phrase:F(`When {device} fires an event`,`Quando {device} genera un evento`),icon:`zap`}}},status:{schema:rb,kind:`push`},runtimeState:rb,durability:`session`,history:`none`,vocabulary:{noun:F(`Event source`,`Sorgente di eventi`),order:5280}},E_e=3,D_e=32;function O_e(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function ab(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ob(e){let t={},n=(e,r,i)=>{if(!(Object.keys(t).length>=D_e)){if(O_e(e)){t[r]=e;return}if(!(!ab(e)||i>=E_e))for(let[t,a]of Object.entries(e))n(a,`${r}.${t}`,i+1)}};if(ab(e))for(let[t,r]of Object.entries(e))n(r,`data.${t}`,1);return t}function k_e(e,t){let n=e;for(let e of t.split(`.`)){if(!ab(n))return;n=n[e]}return n}function sb(e,t){return t===null?!0:e.timestamp===t.timestamp?e.seq>t.seq:e.timestamp>t.timestamp}var cb=`recovered by reconcile`,A_e=class{leaf;#e=null;#t=!1;#n=null;constructor(e){this.leaf=e}onEvent(e){let t=nb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`malformed event`};let n=t.data;return n.deviceId===this.leaf.deviceId?sb(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=rb.safeParse(e);if(!t.success)return{kind:`ignore`,why:`the event-emitter status is unreadable`};this.#n=Zpe(t.data);let n=t.data.lastEvent,r=!this.#t;return this.#t=!0,n===null?{kind:`ignore`,why:`the device has not fired`}:sb(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??Ype([e.eventType]);return(mg(t,e.eventType,e.sourceId)??mg(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=ob(e.data);for(let t of a??[]){let n=k_e(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} — ${cb}`:l,vars:s,data:c}}},lb=6e4;function ub(e){return(e/lb).toFixed(1)}var j_e=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*lb;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 ${ub(n)} min ago`};let r=`${ub(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 ${ub(n)} min ago, ${r}`}}},db=S([`string`,`number`,`boolean`,`select`]),M_e=/^[A-Za-z_][A-Za-z0-9_]*$/,fb=h([l(),n(),y()]),pb=x({name:l().regex(M_e),label:l().min(1).max(120).optional(),type:db,required:y().optional(),default:fb.optional(),options:C(l().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&&mb(e,e.default)!==null&&t.addIssue({code:`custom`,message:mb(e,e.default)??`invalid default`,path:[`default`]})});function mb(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 N_e(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=mb(e,t);if(n!==null)return{ok:!1,error:n};i[e.name]=t}return{ok:!0,values:i}}var hb=S([`internal`,`addon`]),gb=`internal:`;function P_e(e){return`${gb}${e}`}function _b(e){return e.startsWith(`internal:`)&&e.length>9}function vb(e){if(_b(e))return null;let t=e.indexOf(`:`);return t>0&&t<e.length-1?e.slice(0,t):null}var yb=x({isRunning:y(),lastRunAt:n().nullable(),lastError:l().nullable()}),F_e={isRunning:!1,lastRunAt:null,lastError:null},bb=n().int().min(0).max(86400),xb=x({id:l().min(3),name:l().min(1).max(120),addonId:l().min(1),source:hb,readOnly:y(),steps:C(K_).min(1).max(50).optional(),variables:C(pb).max(20).optional(),minDelaySec:bb.optional(),tags:Eh.optional(),status:yb}).superRefine((e,t)=>{if(e.source===`internal`){_b(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`]}),vb(e.id)===null&&t.addIssue({code:`custom`,message:`an addon action id is <addonId>:<localId>`,path:[`id`]})}),Sb=x({name:l().min(1).max(120),steps:C(K_).min(1).max(50),variables:C(pb).max(20).optional(),minDelaySec:bb.optional(),tags:Eh.optional()}),Cb=x({blockId:l().min(1).optional()}),wb=h([qv,p(`started`),p(`timed-out`)]),Tb=x({runId:l().min(1),outcome:wb,message:l().optional()}),I_e=S([`not-found`,`read-only`,`invalid-variables`,`invalid-steps`,`not-linked`,`template-scope`,`busy`]),L_e=class extends Error{code;constructor(e,t){super(`[${e}] ${t}`),this.name=`ActionError`,this.code=e}},Eb=x({actionId:l(),runId:l(),isRunning:y(),outcome:qv.optional(),lastRunAt:n().nullable(),lastError:l().nullable()});function R_e(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 Db(e){return[...e.kind===`command`&&e.target.kind===`devices`?[{actionId:e.actionId,ids:e.target.ids}]:[],...R_e(e).flatMap(Db)]}async function z_e(e,t){let n=e.flatMap(Db);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){Ta(e,void 0);for(let n of t)Tne(e,n,i.get(n)??[])}}async function B_e(e,t,n=Date.now,r,i,a){let o=r?.mirror??new Iy(My(e));await o.refresh(t);let s=Uy(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 V_e(e){try{return await e()}catch(e){return{result:`unknown`,reason:e instanceof Error?e.message:String(e)}}}async function H_e(e){let t=e.now(),n=t+e.timeoutMs;for(;;){let r=await V_e(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 U_e(e,t){return`timed out after ${e} s: ${t}`}function Ob(e){return Ki(e)}function kb(e){let t=Ob(e);if(t===void 0)return[];let n=gl(t);return n===void 0?[t]:[t,...xl(n).filter(e=>e!==t)]}var Ab=x({path:l(),deviceId:n().int().optional(),field:l(),value:n(),assumedUnit:l(),message:l()});function W_e(e){let t=Mg(e);return t instanceof ce?t:void 0}function jb(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[...Ng(r.schema),...r.itemArray===void 0?[]:Tme(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=W_e(i)?.shape[r];return a===void 0?void 0:Mme(a)}}}function Mb(e){return Fg(e)??e}function Nb(e){return kb(e).length>1}function Pb(e){return{...e,message:`${e.field}: the bare number ${e.value} was taken as ${e.assumedUnit} — send { value, unit } to state the unit`}}function G_e(e,t){Bg({value:1,unit:e,target:t})}function K_e(e,t,n){let r=t.fieldQuantity(e.cap,e.fieldPath),i=r===void 0?void 0:Ob(r),a=zg(e.value)||e.unit!==void 0;if(i===void 0||r===void 0){if(a)throw new Lg(`no-quantity`,`${e.cap}.${e.fieldPath} is not a quantity — it takes no unit`);return{leaf:e,warnings:[]}}if(zg(e.value)){let t=Bg({value:e.value.value,unit:e.value.unit,target:i});return{leaf:{...e,value:t,unit:Mb(e.value.unit)},warnings:[]}}return typeof e.value==`number`?e.unit===void 0?Nb(r)?{leaf:e,warnings:[Pb({path:n,deviceId:e.deviceId,field:e.fieldPath,value:e.value,assumedUnit:i})]}:{leaf:e,warnings:[]}:(G_e(e.unit,i),{leaf:e,warnings:[]}):{leaf:e,warnings:[]}}function Fb(e,t,n=`when`){switch(e.kind){case`device-is`:{let{leaf:r,warnings:i}=K_e(e,t,n);return{value:r,warnings:i}}case`not`:{let r=Fb(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)=>Fb(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 q_e(e,t,n){let r=e.target.kind===`devices`&&e.target.ids.length===1?e.target.ids[0]:void 0,{cap:i,method:a}=Ta(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 Lg(`no-quantity`,`${i}.${a}(${n}) is not a quantity — it takes no unit`);G_e(r,e.unit)}for(let[l,u]of Object.entries(e.args??{})){let e=t.paramMeta(i,a,l);e!==void 0&&(zg(u)?(o[l]=Bg({value:u.value,unit:u.unit,target:e.unit}),s[l]=Mb(u.unit)):typeof u==`number`&&s[l]===void 0&&Nb(e.quantity)&&c.push(Pb({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 Ib(e,t,n=`steps`){let r=[],i=[];return e.forEach((e,a)=>{if(e.kind!==`command`){r.push(e);return}let o=q_e(e,t,`${n}.${a}`);r.push(o.value),i.push(...o.warnings)}),{value:r,warnings:i}}function Lb(e,t){let n=Fb(e.when,t,`when`),r=Ib(e.actions,t,`actions`);return{value:{...e,when:n.value,actions:r.value},warnings:[...n.warnings,...r.warnings]}}function Rb(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||kb(n).length<2)return e;let r=Ob(n);return r===void 0?e:{...e,unit:r}}case`not`:return{...e,child:Rb(e.child,t)};case`all`:case`any`:return{...e,children:e.children.map(e=>Rb(e,t))};default:return e}}function J_e(e,t){if(e.kind!==`command`||e.args===void 0)return e;let{cap:n,method:r}=Ta(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&&kb(e.quantity).length>1&&(i[a]=e.unit)}return Object.keys(i).length===0?e:{...e,argUnits:i}}function zb(e,t){let n={...e,when:Rb(e.when,t),actions:e.actions.map(e=>J_e(e,t))};try{return{ok:!0,recipe:Lb(n,t).value}}catch(e){if(e instanceof Lg)return{ok:!1,error:e.message};throw e}}var Y_e=[`devices`,`time`,`cameras`,`events`,`logic`,`system`],Bb=[`trigger`,`any`],Vb=[`trigger`,`guard`,`any`],Hb={detection:{kind:`detection`,category:`cameras`,role:`event`,allowedIn:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Bb,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:Vb,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:Vb,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:Vb,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:Vb,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:Vb,i18nKey:`automation.leafCatalog.expression`,keywords:[`formula`,`math`,`arithmetic`,`sum`,`compare`,`calculate`,`held`],needsDeviceValue:!1,seed:()=>({kind:`expression`,expr:``,bindings:{}})}},Ub=[`detection`,`stationary`,`device-becomes`,`device-fired`,`device-event`,`schedule`,`interval`,`manual`,`device-is`,`stationary-present`,`time-is`,`triggered-by`,`expression`];function X_e(e){return Hb[e]}function Z_e(e){return Hb[e].seed()}function Q_e(e){return Ub.filter(t=>Hb[t].allowedIn.includes(e))}function Wb(e){return e instanceof Error?e.message:String(e)}function $_e(e){return e.startsWith(`[busy]`)?`already-running`:e.startsWith(`[not-found]`)?`not-found`:null}async function eve(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=Wb(e),i=$_e(n);return i===null?(t.warn(`${r}: exported action failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}):o(i,n)}}async function tve(e,t,n){let{exporter:r,targetId:i}=n,a={targetId:i};try{let{targets:o,unreadable:s}=await td(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:Tu.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=Wb(e);return t.warn(`${r}: exported notifier send failed`,{tags:a,meta:{message:n}}),{status:`failed`,message:n}}}function nve(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 Gb=l().min(1),Kb=x({instanceId:Gb.optional()}),qb=x({instanceId:Gb,name:l(),enabled:y(),kind:l().optional(),nameRule:l().optional()}),Jb=`export-instance-unknown`,Yb=class extends Error{code=Jb;instanceId;constructor(e,t){super(`${Jb}: ${e} serves no instance "${t}"`),this.name=`ExportInstanceUnknownError`,this.instanceId=t}};function Xb(e){return`instanceId`in e?e.instanceId:void 0}function rve(e,t,n){if(n!==void 0&&n!==t)throw new Yb(e,n)}var ive=S([`unlinked`,`linked`,`error`]),Zb=x({label:l(),value:l(),secret:y().optional()}),Qb=x({qr:l().optional(),fields:C(Zb).readonly().optional(),note:l().optional()}),$b=x({linkState:ive,exposedDeviceCount:n(),error:l().optional(),setup:Qb.optional()}),ave=l(),ex=x({deviceId:l(),exposedAs:l().optional(),exposedName:l().optional(),capabilities:C(l()).optional()}),tx=x({instanceId:Gb,deviceId:l(),capabilities:C(l()).optional(),exposedName:l().nullable().optional()}),nx=x({instanceId:Gb,deviceId:l(),name:l().nullable(),dryRun:y().optional()}),rx=`export-name-refused`,ix=class extends Error{code=rx;instanceId;reason;constructor(e,t){super(`${rx}: ${t}`),this.name=`ExportNameRefusedError`,this.instanceId=e,this.reason=t}},ax=x({instanceId:Gb,deviceId:l()}),ox=S([`device`,`action`,`notifier`]),sx=i(`kind`,[x({kind:p(`device`),deviceId:l()}),x({kind:p(`action`),actionId:l().min(1)}),x({kind:p(`notifier`),targetId:l().min(1)})]),cx=x({entity:sx,exposedAs:l().optional()}),lx=x({instanceId:Gb,entity:sx}),ux=x({instanceId:Gb,entity:sx}),dx={name:`device-export`,scope:`system`,mode:`collection`,providerKind:`device-export`,status:{schema:$b,kind:`poll`},exposesDeviceSettings:!0,methods:{getStatus:A(Kb,$b),listInstances:A(v(),C(qb)),listSupportedDeviceKinds:A(Kb,C(ave)),listExposedDevices:A(Kb,C(ex)),exposeDevice:A(tx,v(),{kind:`mutation`,auth:`admin`}),unexposeDevice:A(ax,v(),{kind:`mutation`,auth:`admin`}),setExposedName:A(nx,v(),{kind:`mutation`,auth:`admin`}),listSupportedEntityKinds:j(v(),C(ox)),listExposedEntities:j(Kb,C(cx)),exposeEntity:j(lx,v(),{kind:`mutation`,auth:`admin`}),unexposeEntity:j(ux,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`exports to other ecosystems — configured on the export pages`}},fx=`exposedNames`,ove=m(l(),l());function px(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 mx(e){let t=ove.safeParse(e[fx]);return t.success?t.data:{}}function sve(e,t,n){let r=mx(e)[t];if(r===void 0)return null;let i=px(r,n);return i.ok?i.name:null}function hx(e,t,n){let r=Object.fromEntries(Object.entries(mx(e)).filter(([e])=>e!==t));return{[fx]:n===null?r:{...r,[t]:n}}}async function cve(e){let t=px(e.raw,e.validate);if(!t.ok)throw new ix(e.instanceId,t.reason);if(e.dryRun===!0)return{changed:!1,name:t.name};let n=await e.store.read(e.deviceId);return(mx(n)[e.instanceId]??null)===t.name?{changed:!1,name:t.name}:(await e.store.write(e.deviceId,hx(n,e.instanceId,t.name)),{changed:!0,name:t.name})}function lve(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 uve(e,t){let n=await e.listDeviceStoreIds();if(n.length===0)return[];let r=[];for(let[i,a]of await e.readDeviceStoreBatch(n))mx(a)[t]!==void 0&&(await e.writeDeviceStore(i,hx(a,t,null)),r.push(i));return r}function dve(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 gx=[`automation`,`action`,`scheduler`,`composition`],fve=S(gx),_x=x({id:n().int().nonnegative(),name:l().min(1),type:l().min(1),room:l().min(1).nullable(),addonId:l().min(1),stableId:l().min(1),caps:C(l().min(1)),zones:C(l().min(1)).optional()}),pve=x({timeZone:l().min(1),location:x({latitude:n(),longitude:n()}).nullable(),rooms:C(l().min(1)),devices:C(_x).min(1),actions:C(x({id:l().min(1),name:l().min(1)})).default([])}),mve=60,vx=x({childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),yx={name:`accessories`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Switch,E.Light,E.Sensor,E.Climate,E.Cover,E.Lock,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Generic],methods:{setChildHidden:A(x({deviceId:n().int().nonnegative(),childDeviceId:n().int().nonnegative(),hidden:y()}),v(),{kind:`mutation`,auth:`admin`})},events:{onAccessoriesChanged:{data:x({deviceId:n(),childDeviceIds:C(n()).readonly(),hiddenChildIds:C(n()).readonly()}),notOperatorFacing:`the device’s child list changed — administration, not a happening`},onChildVisibilityChanged:{data:x({deviceId:n(),childDeviceId:n(),hidden:y()}),notOperatorFacing:`an operator hid or showed a child — administration, not a happening`}},status:{schema:vx,kind:`command-driven`},vocabulary:{noun:F(`Accessories`,`Accessori`),order:3e3}},bx={name:`action-source`,scope:`system`,mode:`collection`,methods:{listActions:A(x({}),C(xb),{auth:`admin`}),runAction:A(x({actionId:l().min(1),variables:m(l(),fb).optional()}),v(),{kind:`mutation`,auth:`admin`}),stopAction:A(x({actionId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},hve=60*6e4,gve=3e4,xx=363e4;function _ve(e){let t=0;for(let n of e)n.kind===`wait`&&(t+=n.seconds*1e3);return t}var Sx=x({actionId:l().min(1)}),Cx=x({deviceId:n().int().nonnegative(),actionIds:C(l().min(1)).max(100)}),wx={name:`actions`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(xb),{auth:`admin`}),get:A(x({actionId:l().min(1),deviceId:n().int().nonnegative().optional()}),x({action:xb.nullable()}),{role:`viewer`,auth:`protected`,kind:`query`,caller:`required`}),run:A(x({actionId:l().min(1),variables:m(l(),fb).optional(),wait:y().optional(),origin:Cb.optional(),deviceId:n().int().nonnegative().optional()}),Tb,{role:`viewer`,auth:`protected`,kind:`mutation`,caller:`required`,timeoutMs:xx}),stop:A(Sx,v(),{kind:`mutation`,auth:`admin`}),getTraces:A(Sx,x({traces:C(ny)}),{auth:`admin`}),create:A(x({action:Sb}),x({action:xb,warnings:C(Ab).optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({actionId:l().min(1),action:Sb.partial()}),x({action:xb,warnings:C(Ab).optional()}),{kind:`mutation`,auth:`admin`}),delete:A(Sx,v(),{kind:`mutation`,auth:`admin`}),listForCamera:A(x({deviceId:n().int().nonnegative()}),C(xb),{role:`viewer`,auth:`protected`,kind:`query`}),getLinks:A(x({deviceId:n().int().nonnegative()}),Cx,{auth:`admin`}),setLinks:A(Cx,Cx,{kind:`mutation`,auth:`admin`})},events:{onRunChanged:{data:Eb}},vocabulary:{notOperatorFacing:`declared actions — run from the Actions page and from the cameras that link them`}},vve=x({id:l(),label:l(),icon:l(),path:l(),remoteName:l(),bundle:l(),section:l().optional(),sectionLabel:l().optional()}),Tx=x({addonId:l(),page:vve,bundleUrl:l()}),Ex={name:`addon-pages`,scope:`system`,mode:`singleton`,methods:{listPages:A(v(),C(Tx).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},yve=x({method:S([`GET`,`POST`,`PUT`,`DELETE`,`PATCH`]),path:l(),access:S([`public`,`authenticated`,`admin`]).optional(),description:l().optional(),rateLimit:S([`auth`]).optional(),perInstance:y().optional()}),bve=x({method:l(),path:l(),params:m(l(),l()),query:m(l(),l()),body:w(),headers:m(l(),l()),instanceId:l().optional(),user:x({id:l(),username:l(),isAdmin:y()}).optional(),scopedToken:w().optional()}),xve=x({status:n().int(),headers:m(l(),l()),redirectUrl:l().nullable(),body:w().optional(),contentType:l().optional()}),Dx={name:`addon-routes`,scope:`system`,mode:`collection`,internal:!0,methods:{getRoutes:A(v(),C(yve)),invoke:A(bve,xve,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Ox=x({id:l(),label:l(),icon:l(),order:n().optional()}),kx=x({id:l(),title:l(),titleKey:l().optional(),description:l().optional(),descriptionKey:l().optional(),style:S([`card`,`accordion`]).optional(),defaultCollapsed:y().optional(),columns:h([p(1),p(2),p(3),p(4)]).optional(),tab:l().optional(),location:S([`settings`,`top-tab`,`hero`]).optional(),order:n().optional(),fields:C(ge())}),Ax=x({tabs:C(Ox).optional(),sections:C(kx)}),jx=m(l(),w()),Mx=S(Gn),Sve=x({cap:l(),scope:Mx,sectionIds:C(l())}),Nx=x({success:p(!0)}),Px={name:`addon-settings`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{getScopedSettings:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional()}),Ax.nullable()),listScopedSettings:A(x({addonId:l(),nodeId:l().optional()}),C(Sve).nullable()),updateScopedSettings:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`}),readScopedValues:A(x({addonId:l(),cap:l(),scope:Mx,nodeId:l().optional()}),m(l(),w()).nullable()),getDeclaredSettingsKeys:A(x({addonId:l(),nodeId:l().optional()}),x({keys:C(l())}).nullable(),{auth:`admin`}),unsetStoredSettingsKeys:A(x({addonId:l(),nodeId:l().optional(),keys:C(l())}),x({removed:C(l()),refused:C(x({key:l(),reason:l()})),secretsCleared:n()}),{kind:`mutation`,auth:`admin`}),getDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional()}),Ax.nullable()),updateDeviceSettings:A(x({addonId:l(),deviceId:n(),nodeId:l().optional(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},Fx=S([`device-tab`,`dashboard`,`integration-detail`]),Ix=S([`xs`,`sm`,`md`,`lg`,`xl`]),Lx=x({remoteName:l(),exposedModule:l(),componentKey:l().optional()}),Rx=x({tab:l(),subTab:l().optional(),label:l(),order:n().optional(),kind:p(`remote`),remote:Lx,stableId:l(),description:l().optional(),icon:l().optional(),bundle:l(),hosts:C(Fx).readonly(),requires:x({deviceContext:y().default(!1),integrationContext:y().default(!1)}),preAuth:y().optional().default(!1),defaultSize:Ix.default(`md`),allowedSizes:C(Ix).readonly().default([`sm`,`md`,`lg`]),defaultColumns:n().int().min(1).max(12).default(6),defaultRows:n().int().min(1).max(12).default(1)}),zx={name:`addon-widgets-source`,scope:`system`,mode:`collection`,internal:!0,methods:{listWidgets:A(v(),C(Rx).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Bx=Rx.extend({addonId:l(),bundleUrl:l()}),Vx={name:`addon-widgets`,scope:`system`,mode:`singleton`,methods:{listWidgets:A(v(),C(Bx).readonly())},vocabulary:{notOperatorFacing:M.UI_PLUMBING}},Hx=S([`install`,`update`,`uninstall`,`restart`]),Ux=S([`queued`,`fetching`,`staged`,`validating`,`applying`,`restarting`,`applied`,`done`,`failed`,`skipped`]),Wx=S([`framework`,`addon`]),Gx=x({tsMs:n(),nodeId:l(),packageName:l(),phase:Ux,message:l()}),Kx=x({taskId:l(),nodeId:l(),packageName:l(),fromVersion:l().nullable(),toVersion:l(),target:Wx,phase:Ux,stagedPath:l().nullable(),attempts:n(),steps:C(Gx),error:l().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable()}),qx=S([`running`,`completed`,`failed`,`partially-failed`,`cancelled`]),Jx=S([`single`,`bulk`,`cluster`]),Yx=x({jobId:l(),kind:Hx,createdAtMs:n(),createdBy:l(),scope:Jx,tasks:C(Kx),state:qx,schemaVersion:p(1)}),Xx=S([`debug`,`info`,`warn`,`error`]),Zx=S([`off`,`latest`,`beta`]),Qx=S([`off`,`latest`,`beta`,`inherit`]),Cve=x({id:l(),name:l().optional(),version:l().optional(),description:l().optional(),icon:l().optional(),color:l().optional(),capabilities:C(w()).readonly().optional(),packageName:l(),packageVersion:l(),packageDisplayName:l().optional(),bundle:x({displayName:l(),description:l().optional(),icon:l().optional()}).optional(),protected:y().optional(),removable:y().optional(),integrationSection:S([`system`,`providers`]).optional()}),wve=x({pid:n().optional(),mode:l(),state:l(),reason:l().optional()}),Tve=x({phase:S([`pending`,`healthy`,`failed`]),retryCount:n(),firstFailureAt:n().nullable(),lastAttemptAt:n().nullable(),lastError:x({message:l(),stack:l().optional()}).nullable(),nextRetryAt:n().nullable(),alertEmitted:y(),retrying:y(),inGracePeriod:y()}),$x=x({manifest:Cve,declaration:w().optional(),source:l(),installSource:l().optional(),process:wve.optional(),hasBackup:y().optional(),health:Tve.nullable().optional()}),eS=x({name:l(),version:l(),dir:l(),installSource:l().optional()}),tS=x({name:l(),currentVersion:l(),latestVersion:l(),category:S([`addon`,`core`]),requiresRestart:y(),isSystem:y(),blockedBy:C(au).readonly().optional()}),nS=x({version:l(),publishedAt:l(),deprecated:l().optional(),distTags:C(l()).readonly()}),rS=i(`status`,[x({status:p(`ok`),markdown:l()}),x({status:p(`missing`)}),x({status:p(`error`),message:l()})]),Eve=x({name:l(),version:l(),readme:rS,changelog:rS}),iS=x({name:l(),version:l(),description:l(),keywords:C(l()).readonly(),publishedAt:l(),author:l(),installed:y(),installedVersion:l().optional(),capabilities:C(l()).readonly().nullable()}),aS=x({channel:Zx,intervalSeconds:n(),updateCheckIntervalSeconds:n()}),oS=Qx,Dve=w(),Ove=w(),kve=w(),sS=S([`uninstalled`,`not-installed`,`refused`,`failed`,`pending-reconnect`]),cS=x({nodeId:l(),outcome:sS,error:l().optional(),addonIds:C(l()).readonly(),runnersStopped:C(l()).readonly(),warnings:C(l()).readonly()}),lS=x({success:y(),packageName:l(),results:C(cS).readonly()}),uS=x({packageName:l(),nodeId:l(),nodeName:l(),isHub:y(),isOnline:y(),version:l().nullable(),addonIds:C(l()).readonly(),source:S([`live`,`recorded`]),onHub:y()}),dS=x({installations:C(uS).readonly(),unreachable:C(x({nodeId:l(),error:l()})).readonly()}),Ave=S([`queued`,`updating`,`done`,`done-pending-restart`,`failed`]),jve=x({name:l(),isSystem:y(),fromVersion:l(),toVersion:l(),status:Ave,error:l().optional(),startedAtMs:n().optional(),completedAtMs:n().optional()}),Mve=S([`regular`,`system`,`restarting`,`finalizing`]);x({id:l(),nodeId:l(),startedAtMs:n(),completedAtMs:n().optional(),total:n(),completed:n(),failed:n(),current:l().nullable(),phase:Mve,cancelled:y(),items:C(jve).readonly()});var Nve=x({packageName:l(),currentVersion:l(),latestVersion:l().nullable(),hasUpdate:y(),description:l().optional(),buildId:l().nullable()}),fS=x({timestamp:l(),level:l(),message:l(),scope:l().optional()}),Pve=w(),pS=x({addonId:l().min(1),action:l().min(1),input:w()}),mS={name:`addons`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{list:A(x({nodeId:l().optional()}).optional(),C($x).readonly()),getLogs:A(x({addonId:l(),limit:n().min(1).max(500).default(100),level:Xx.optional()}),C(Pve)),listPackages:A(v(),C(eS).readonly()),installPackage:A(x({packageName:l(),version:l().optional()}),Ove,{kind:`mutation`,auth:`admin`}),uninstallPackage:A(x({packageName:l().min(1),nodeId:l().optional(),everywhere:y().optional()}),lS,{kind:`mutation`,auth:`admin`}),listInstallations:A(x({packageName:l().optional()}),dS,{auth:`admin`}),reloadPackages:A(v(),kve,{kind:`mutation`,auth:`admin`}),searchAvailable:A(x({query:l().optional(),capability:l().optional()}),C(iS)),listUpdates:A(x({nodeId:l().optional()}),C(tS).readonly(),{auth:`admin`}),updatePackage:A(x({name:l().min(1),version:l().optional(),nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),rollbackPackage:A(x({name:l().min(1)}),x({rolledBackTo:l().nullable()}),{kind:`mutation`,auth:`admin`}),forceRefresh:A(x({nodeId:l().optional()}),w(),{kind:`mutation`,auth:`admin`}),restartServer:A(x({confirm:p(!0)}),w(),{kind:`mutation`,auth:`admin`}),getLastRestart:A(v(),x({kind:S([`framework-update`,`manual`,`system`,`framework-bulk-update`]),packageName:l().optional(),fromVersion:l().optional(),toVersion:l().optional(),requestedBy:l().optional(),requestedAt:n()}).nullable(),{auth:`admin`}),listFrameworkPackages:A(v(),C(Nve).readonly(),{auth:`admin`}),listCapabilityProviders:A(x({capName:l().min(1)}),C(x({addonId:l(),mode:S([`singleton`,`collection`]),isActive:y()})).readonly()),setCapabilityProviderEnabled:A(x({capName:l().min(1),addonId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getVersions:A(x({name:l()}),C(nS).readonly()),getPackageDocs:A(x({name:l().min(1),version:l().min(1).optional()}),Eve,{auth:`admin`}),restartAddon:A(x({addonId:l()}),Dve,{kind:`mutation`,auth:`admin`}),retryLoad:A(x({packageName:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAutoUpdateSettings:A(v(),aS,{auth:`admin`}),setAutoUpdateSettings:A(x({channel:Zx,intervalSeconds:n().min(300).max(86400).optional(),updateCheckIntervalSeconds:n().min(900).max(604800).optional()}),w(),{kind:`mutation`,auth:`admin`}),getAddonAutoUpdate:A(x({addonId:l()}),oS,{auth:`admin`}),setAddonAutoUpdate:A(x({addonId:l(),channel:Qx}),w(),{kind:`mutation`,auth:`admin`}),applyAutoUpdateToAll:A(x({channel:Zx}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),custom:A(pS,w(),{role:`viewer`,kind:`mutation`}),startJob:A(x({kind:S([`install`,`update`,`uninstall`,`restart`]),targets:C(x({name:l().min(1),version:l().min(1)})).min(1),nodeIds:C(l()).optional()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getJob:A(x({jobId:l()}),Yx.nullable(),{auth:`admin`}),listJobs:A(x({activeOnly:y().optional()}),C(Yx),{auth:`admin`}),cancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),onAddonLogs:A(x({addonId:l(),level:Xx.optional()}),fS,{kind:`subscription`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},hS=x({co2:n().min(0).optional().meta(N(`concentration-volume`)),voc:n().min(0).optional().meta(N(`concentration-ppb`)),pm25:n().min(0).optional().meta(N(`concentration-mass`)),pm10:n().min(0).optional().meta(N(`concentration-mass`)),aqi:n().optional().meta(N(`index`)),lastFetchedAt:n()}),gS={name:`air-quality-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:hS,kind:`push`},runtimeState:hS,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:F(`Air quality`,`Qualità dell’aria`),order:5e3,state:[{kind:`numeric`,field:`co2`,quantity:F(`the CO₂`,`la CO₂`),label:F(`CO₂`,`CO₂`),unit:`ppm`,icon:`wind`},{kind:`numeric`,field:`voc`,quantity:F(`the VOC level`,`il livello di COV`),label:F(`VOC`,`COV`),unit:`ppb`,icon:`wind`},{kind:`numeric`,field:`pm25`,quantity:F(`the PM2.5`,`il PM2,5`),label:F(`PM2.5`,`PM2,5`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`pm10`,quantity:F(`the PM10`,`il PM10`),label:F(`PM10`,`PM10`),unit:`µg/m³`,icon:`cloud-fog`},{kind:`numeric`,field:`aqi`,quantity:F(`the air quality index`,`l’indice di qualità dell’aria`),label:F(`AQI`,`IQA`),icon:`wind`}]}},_S=S([`disarmed`,`armed_home`,`armed_away`,`armed_night`,`armed_vacation`,`armed_custom_bypass`,`arming`,`disarming`,`pending`,`triggered`]),vS=S([`home`,`away`,`night`,`vacation`,`custom_bypass`]),yS=x({state:_S,targetMode:vS.nullable().optional(),availableModes:C(vS),codeRequired:y().nullable(),lastChangedAt:n()}),bS={name:`alarm-panel`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.AlarmPanel],methods:{trigger:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.trigger`,label:F(`Trigger alarm`,`Fai scattare l’allarme`),phrase:F(`Trigger the alarm on {device}`,`Fai scattare l’allarme su {device}`),icon:`siren`}]}),disarm:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.disarm`,label:F(`Disarm`,`Disinserisci`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),arm:A(x({deviceId:n().int().nonnegative(),mode:vS,code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`alarm.arm.home`,label:F(`Arm home`,`Inserisci in casa`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.away`,label:F(`Arm away`,`Inserisci fuori casa`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.night`,label:F(`Arm night`,`Inserisci notte`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.vacation`,label:F(`Arm vacation`,`Inserisci vacanza`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]},{id:`alarm.arm.custom_bypass`,label:F(`Arm custom bypass`,`Inserisci con esclusioni`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]})},status:{schema:yS,kind:`push`},runtimeState:yS,durability:`restored`,restoredFieldRenames:{requiresCode:`codeRequired`},history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Alarm panel`,`Centrale d’allarme`),order:1120,state:[{kind:`enum`,field:`state`,label:F(`Alarm state`,`Stato dell’allarme`),values:[{value:`disarmed`,label:F(`Disarmed`,`Disinserito`),phrase:F(`When {device} is disarmed`,`Quando {device} viene disinserito`)},{value:`armed_home`,label:F(`Armed home`,`Inserito in casa`),phrase:F(`When {device} is armed for home`,`Quando {device} viene inserito in modalità casa`)},{value:`armed_away`,label:F(`Armed away`,`Inserito fuori casa`),phrase:F(`When {device} is armed for away`,`Quando {device} viene inserito in modalità fuori casa`)},{value:`armed_night`,label:F(`Armed night`,`Inserito notte`),phrase:F(`When {device} is armed for the night`,`Quando {device} viene inserito in modalità notte`)},{value:`armed_vacation`,label:F(`Armed vacation`,`Inserito vacanza`)},{value:`armed_custom_bypass`,label:F(`Armed with bypass`,`Inserito con esclusioni`)},{value:`arming`,label:F(`Arming`,`In inserimento`)},{value:`disarming`,label:F(`Disarming`,`In disinserimento`)},{value:`pending`,label:F(`Entry delay`,`Ritardo d’ingresso`)},{value:`triggered`,label:F(`Triggered`,`In allarme`),phrase:F(`When {device} goes off`,`Quando {device} scatta`)}],icon:`shield`}]}},xS=S([`info`,`success`,`warning`,`error`,`critical`]),Fve=x({addonId:l().min(1),action:l().min(1),input:m(l(),w()).optional()}),Ive=x({label:l(),href:l().optional(),invoke:Fve.optional(),navigation:S([`app`,`server`]).optional()}),SS=S([`active`,`in-progress`,`completed`,`failed`,`dismissed`]),CS=x({type:l(),id:l()}),wS=x({id:l(),category:l(),severity:xS,title:l(),message:l(),action:Ive.optional(),status:SS,progress:n().optional(),read:y(),createdAt:n(),updatedAt:n(),source:CS.optional(),metadata:m(l(),w()).optional()}),TS={name:`alerts`,scope:`system`,mode:`singleton`,methods:{emit:A(wS,v(),{kind:`mutation`}),update:A(x({alertId:l(),patch:wS.partial()}),v(),{kind:`mutation`}),list:A(x({unreadOnly:y().optional(),limit:n().optional()}).optional(),C(wS).readonly()),getUnreadCount:A(v(),n()),markRead:A(x({alertId:l()}),v(),{kind:`mutation`}),markAllRead:A(v(),v(),{kind:`mutation`}),dismiss:A(x({alertId:l()}),v(),{kind:`mutation`})},vocabulary:{notOperatorFacing:`the alert centre — read and acknowledged on its own page`}},ES=x({illuminance:n().min(0).nullable().meta(N(`illuminance`,{precision:0,label:`Illuminance`})),lastFetchedAt:n()}),DS={name:`ambient-light-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:ES,kind:`push`},runtimeState:ES,durability:`restored`,history:{fields:{illuminance:{kind:`gauge`,unit:`lx`,deadbandPct:10,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Light level`,`Luminosità ambiente`),order:5010,state:[{kind:`numeric`,field:`illuminance`,quantity:F(`the light level`,`la luminosità`),label:F(`Illuminance`,`Illuminamento`),unit:`lx`,icon:`sun`}]}},OS={name:`audio-analysis`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{resolveDeviceSettings:A(x({deviceId:n()}),ve())},events:{onAudioLevel:Lr(x({deviceId:n(),rms:n(),dbfs:n()}),{notOperatorFacing:`a sound-level sample at stream rate; loud-noise rules belong to the detection pipeline`})},vocabulary:{noun:F(`Audio analysis`,`Analisi audio`),order:3010}},Lve=S([`jpeg`,`rgb`,`bgr`,`yuv420`,`gray`]),kS=x({data:ve(),format:Lve,width:n(),height:n(),timestamp:n()}),AS=x({x:n(),y:n(),w:n(),h:n()}),Rve=x({class:l(),originalClass:l(),score:n(),bbox:AS}),jS=x({data:b(Uint8Array),sampleRate:n(),channels:n(),timestamp:n(),deviceId:n().optional()}),MS=x({rms:n(),dbfs:n()}),NS=x({className:l(),originalClass:l().optional(),score:n()}),PS=[`superseded`,`error`,`timeout`,`disposed`],FS=i(`state`,[x({state:p(`classified`)}),x({state:p(`not-classified`),reason:S(PS)})]),IS=x({level:MS,classification:x({labels:C(NS).readonly(),inferenceMs:n()}).optional(),classifyOutcome:FS,timestamp:n()}),LS=x({minConfidence:n().min(0).max(1).default(.3),allowedClasses:C(l()).default([])}),RS=x({deviceId:n(),brokerId:l(),ingestNodeId:l(),settings:LS}),zS=x({attached:y(),replaced:y()}),BS=x({detached:y()}),VS=x({labels:C(NS).readonly(),rawLabels:C(NS).readonly().optional(),inferenceMs:n()}),zve=[{value:`auto`,label:`Auto (platform default)`},{value:`apple-soundanalysis`,label:`Apple SoundAnalysis (macOS 12+)`},{value:`yamnet-onnx`,label:`YAMNet ONNX (cross-platform)`}],Bve={audioBackend:`auto`,probedBestAudioBackend:``},HS={name:`audio-analyzer`,scope:`system`,mode:`singleton`,methods:{analyseChunk:A(x({chunk:jS,settings:LS}),IS.nullable(),{kind:`mutation`}),classify:A(jS,VS,{timeoutMs:3e4}),attachDevice:A(RS,zS,{kind:`mutation`}),detachDevice:A(x({deviceId:n()}),BS,{kind:`mutation`}),isReady:A(v(),y()),dispose:A(v(),v(),{kind:`mutation`}),reprobeAudioEngine:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},US=S([`f32le`,`s16le`]),WS=x({codec:l(),canDecode:y(),canEncode:y(),label:l().optional()}),GS=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),extraData:b(Uint8Array).optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),targetFormat:US.optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),KS=x({codec:l(),sourceSampleRate:n().int().positive(),sourceChannels:n().int().positive(),sourceFormat:US.optional(),targetSampleRate:n().int().positive(),targetChannels:n().int().positive(),bitrateKbps:n().int().positive().optional(),idleMs:n().int().positive().optional(),tag:l().optional()}),qS=x({data:b(Uint8Array),sampleRate:n().int().positive(),channels:n().int().positive(),format:US,pts:n()}),JS=x({data:b(Uint8Array),codec:l(),pts:n(),frameComplete:y()}),Vve=x({sessionId:l(),kind:S([`decode`,`encode`]),codec:l(),sourceSampleRate:n(),sourceChannels:n(),targetSampleRate:n(),targetChannels:n(),format:US,tag:l().optional(),createdAtMs:n(),lastActivityMs:n(),framesIn:n(),framesOut:n()}),YS={name:`audio-codec`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{listSupportedCodecs:A(v(),C(WS).readonly()),canHandle:A(x({codec:l(),kind:S([`decode`,`encode`])}),y()),createDecodeSession:A(GS,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),createEncodeSession:A(KS,x({sessionId:l(),nodeId:l()}),{kind:`mutation`}),closeSession:A(x({sessionId:l(),nodeId:l().optional()}),v(),{kind:`mutation`}),pushEncodedFrame:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullPcm:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(qS)),pushPcm:A(x({sessionId:l(),nodeId:l().optional(),data:b(Uint8Array),pts:n().optional()}),v(),{kind:`mutation`}),pullEncoded:A(x({sessionId:l(),nodeId:l().optional(),maxCount:n().int().positive().default(8)}),C(JS)),flushEncode:A(x({sessionId:l(),nodeId:l().optional()}),C(JS),{kind:`mutation`}),listActiveSessions:A(v(),C(Vve).readonly())},vocabulary:{notOperatorFacing:M.INTERNAL}},XS=x({className:l(),hits:n().int().nonnegative(),avgScore:n().min(0).max(1),peakScore:n().min(0).max(1)}),ZS=x({ts:n().int(),windowSec:n().int().positive(),level:x({rms:n(),dbfs:n()}),peakDbfs:n(),avgDbfs:n(),current:x({className:l(),score:n().min(0).max(1),timestamp:n().int()}).nullable(),byClass:C(XS).readonly()}),QS=x({ts:n().int(),dbfs:n().nullable(),peakDbfs:n(),avgDbfs:n(),topClass:l().nullable(),topScore:n().min(0).max(1).nullable()}),$S=x({points:C(QS).readonly(),effectiveSampleEveryMs:n().int().positive(),windowMsActual:n().int().nonnegative()}),eC={name:`audio-metrics`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCurrentSnapshot:A(x({deviceId:n()}),ZS.nullable()),getHistory:A(x({deviceId:n(),windowSec:n().int().positive().optional(),sampleEveryMs:n().int().positive().optional()}),$S)},runtimeState:ZS,durability:`session`,history:`none`,vocabulary:{noun:F(`Audio metrics`,`Metriche audio`),order:3020}},tC=x({userId:l(),username:l(),email:l().optional(),displayName:l().optional(),isAdmin:y().default(!1)}),nC={name:`auth-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{validateCredentials:A(x({username:l(),password:l()}),tC.nullable(),{kind:`mutation`}),getLoginUrl:A(x({state:l()}),l()),handleCallback:A(m(l(),l()),tC,{kind:`mutation`}),validateToken:A(x({token:l()}),tC.nullable())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},rC=x({enabled:y(),isRunning:y(),lastTriggeredAt:n(),lastError:l().nullable(),lastChangedAt:n()}),iC={name:`automation-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Automation],methods:{enable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.enable`,effect:{field:`enabled`,value:!0},label:F(`Enable automation`,`Abilita l’automazione`),phrase:F(`Enable {device}`,`Abilita {device}`),icon:`toggle-right`}]}),disable:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.disable`,effect:{field:`enabled`,value:!1},label:F(`Disable automation`,`Disabilita l’automazione`),phrase:F(`Disable {device}`,`Disabilita {device}`),icon:`toggle-left`}]}),trigger:A(x({deviceId:n().int().nonnegative(),skipCondition:y().optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`haAutomation.trigger`,label:F(`Trigger automation`,`Avvia l’automazione`),phrase:F(`Run {device} now`,`Esegui subito {device}`),icon:`workflow`}]})},status:{schema:rC,kind:`push`},runtimeState:rC,durability:`session`,history:`none`,vocabulary:{noun:F(`Automation`,`Automazione`),order:2100,state:[{kind:`boolean`,field:`enabled`,label:F(`Enabled`,`Abilitata`),whenTrue:F(`When {device} is enabled`,`Quando {device} viene abilitata`),whenFalse:F(`When {device} is disabled`,`Quando {device} viene disabilitata`),icon:`toggle-right`},{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`workflow`}]}},Hve=`.backup-snapshot`,Uve=`.backup-snapshot-partial`,aC=30*6e4,oC=x({databases:C(x({databaseId:Ud,livePath:l()}))}),sC=x({name:l(),rows:n().int().nonnegative()}),cC=x({livePath:l(),snapshotPath:l(),sizeBytes:n().int().nonnegative(),pageCount:n().int().nonnegative(),pageSize:n().int().positive(),tables:C(sC),copyMs:n().nonnegative(),verifyMs:n().nonnegative(),takenAt:n()}),lC=cC.extend({databaseId:Ud}),uC=x({databaseId:Ud}),dC=cC.extend({livePath:l(),snapshotPath:l(),databaseId:Ud.optional()}),fC={name:`database-snapshot`,scope:`system`,mode:`singleton`,internal:!0,methods:{listDatabases:A(x({}),oC,{auth:`admin`}),writeSnapshot:A(uC,lC,{kind:`mutation`,auth:`admin`,timeoutMs:aC})},vocabulary:{notOperatorFacing:M.INTERNAL}},pC=x({subId:l(),displayName:l(),description:l().optional(),kind:l(),triggerSupported:y(),restoreSupported:y()}).extend({id:l(),addonId:l(),enabled:y(),retentionCount:n(),label:l().optional(),lastSuccessAt:n().optional(),lastSuccessSizeBytes:n().optional(),cron:l().optional(),nextRunAt:n().optional(),lastAttemptAt:n().optional(),lastError:l().optional()}),mC=x({scheme:l(),keyId:l()}),hC=x({enabled:y(),active:x({keyId:l(),publicKey:l(),createdAt:n()}).nullable(),keys:C(x({keyId:l(),createdAt:n(),retiredAt:n().nullable()})).readonly()}),Wve=x({id:l(),filename:l(),createdAt:n(),sizeBytes:n(),label:l().optional(),locations:C(l()).readonly(),encryption:mC.optional(),databases:C(Ud).readonly().optional()}),gC=x({id:l(),destinationId:l().optional(),label:l().optional(),createdAt:n(),sizeBytes:n(),locations:C(l()).optional(),encryption:mC.optional()}),_C=x({path:l(),kind:S([`file`,`dir`,`symlink`]),sizeBytes:n(),mtime:n()}),vC=x({archiveVersion:p(1),createdAt:n(),dataDir:l(),locations:C(l()),entries:C(_C),totalBytes:n(),totalFiles:n(),sqliteSnapshots:C(dC).optional(),omittedDatabases:C(Ud).optional()}),yC=x({name:l(),sizeBytes:n(),fileCount:n(),present:y()}),bC=S([`queued`,`running`,`succeeded`,`failed`,`cancelled`]),xC=S([`queued`,`building`,`uploading`,`done`]),SC=x({id:l(),state:bC,phase:xC,destinationIds:C(l()).readonly(),label:l().optional(),requestedAt:n(),startedAt:n().optional(),finishedAt:n().optional(),stagedBytes:n(),archiveSizeBytes:n().optional(),uploadedBytes:n(),completedDestinationIds:C(l()).readonly(),failedDestinationIds:C(l()).readonly(),error:l().optional(),queuePosition:n().int().min(1).optional()}),CC=x({runId:l(),queued:y(),joined:y(),cancelled:y(),entries:C(gC).readonly()}),wC=x({id:l(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(Ud).readonly().optional(),lastAttemptAt:n().optional(),lastSuccessAt:n().optional(),lastError:l().optional(),nextRunAt:n().optional()}),TC={name:`backup`,scope:`system`,mode:`singleton`,methods:{listDestinations:A(v(),C(pC).readonly(),{auth:`admin`}),trigger:A(x({destinations:C(l()).optional(),locations:C(l()).optional(),label:l().optional(),retentionCount:n().int().min(1).max(1e3).optional(),databases:C(Ud).optional()}).optional(),CC,{kind:`mutation`,auth:`admin`}),listRuns:A(v(),C(SC).readonly(),{auth:`admin`}),cancel:A(x({runId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),list:A(v(),C(gC).readonly(),{auth:`admin`}),listLocations:A(v(),C(yC).readonly(),{auth:`admin`}),getEntries:A(x({destinationId:l(),backupId:l()}),vC.nullable(),{auth:`admin`}),restore:A(x({destinationId:l(),backupId:l(),locations:C(l()).optional(),backupSecretKey:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),getEncryption:A(v(),hC,{auth:`admin`}),setupEncryption:A(x({}),x({keyId:l(),secretKey:l(),publicKey:l(),createdAt:n(),replacedKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),disableEncryption:A(x({}),x({disabledKeyId:l().nullable()}),{kind:`mutation`,auth:`admin`}),checkBackupKey:A(x({backupSecretKey:l()}),x({valid:y(),keyId:l().nullable(),known:y(),active:y(),error:l().optional()}),{kind:`mutation`,auth:`admin`}),delete:A(x({destinationId:l(),backupId:l()}),v(),{kind:`mutation`,auth:`admin`}),listArchives:A(x({destinationId:l()}),C(Wve).readonly(),{auth:`admin`}),upsertDestinationPolicy:A(x({locationId:l(),enabled:y(),retentionCount:n().int().min(1).max(1e3),label:l().optional()}),v(),{kind:`mutation`,auth:`admin`}),previewSchedule:A(x({cron:l(),count:n().int().min(1).max(20).optional()}),x({ok:y(),error:l().optional(),nextRuns:C(n()).readonly()})),listSchedules:A(v(),C(wC).readonly(),{auth:`admin`}),listAvailableDatabases:A(v(),x({answered:y(),databases:C(Ud).readonly()}),{auth:`admin`}),upsertSchedule:A(x({id:l().optional(),label:l(),cron:l(),enabled:y(),locationIds:C(l()).readonly(),retentionCount:n().int().min(1).max(1e3),dataSources:C(l()).readonly().optional(),databases:C(Ud).readonly().optional()}),wC,{kind:`mutation`,auth:`admin`}),deleteSchedule:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`system backups — run and restored from the Backups page`}},EC=x({level:n().min(0).max(100).nullable().meta(N(`percentage`,{label:`Charge`})),charging:S([`dc`,`solar`,`none`,`unknown`]).meta({label:`Charging source`}),sleeping:y().meta({label:`Sleeping`}),lastUpdated:n().meta(N(`none`)),voltage:n().nullable().optional().meta(N(`voltage`,{label:`Voltage`})),lastContactAt:n().optional(),lastFullRefreshAt:n().optional(),binary:y().optional().meta({label:`Binary indicator`})}),DC=[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.EventEmitter],Gve={version:1,targets:[{id:`level`,cardinality:`scalar`,vocabulary:{cap:`battery`,stateField:`level`},deviceTypes:DC,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}]},OC={name:`battery`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:DC,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:EC}),notOperatorFacing:`the level / sleeping / charging state triggers each read one field of this change`}},status:{schema:EC,kind:`push`,empty:{level:null,charging:`unknown`,sleeping:!1,lastUpdated:0}},runtimeState:EC,durability:`restored`,history:{fields:{level:{kind:`gauge`,unit:`%`},voltage:{kind:`gauge`,unit:`V`}}},customize:Gve,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Battery`,`Batteria`),order:5240,state:[{kind:`numeric`,field:`level`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`},{kind:`boolean`,field:`sleeping`,label:F(`Asleep`,`In sospensione`),whenTrue:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),whenFalse:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`moon`},{kind:`enum`,field:`charging`,label:F(`Charging`,`Ricarica`),values:[{value:`dc`,label:F(`Charging from mains`,`In carica da rete`),phrase:F(`When {device} starts charging`,`Quando {device} inizia a caricarsi`)},{value:`solar`,label:F(`Charging from solar`,`In carica dal pannello solare`),phrase:F(`When {device} charges from its solar panel`,`Quando {device} si carica dal pannello solare`)},{value:`none`,label:F(`Not charging`,`Non in carica`),phrase:F(`When {device} stops charging`,`Quando {device} smette di caricarsi`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`battery-charging`}],extraEvents:[{category:T.DeviceAwake,label:F(`Woke up`,`Risvegliato`),phrase:F(`When {device} wakes up`,`Quando {device} si risveglia`),icon:`sun`},{category:T.DeviceSleeping,label:F(`Went to sleep`,`In sospensione`),phrase:F(`When {device} goes to sleep`,`Quando {device} va in sospensione`),icon:`moon`}]}},kC=x({on:y().meta({label:`On`}),lastChangedAt:n()}),AC={name:`binary`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:kC,kind:`push`},runtimeState:kC,durability:`restored`,history:{fields:{on:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Binary sensor`,`Sensore binario`),order:5020,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns active`,`Quando {device} si attiva`),whenFalse:F(`When {device} turns inactive`,`Quando {device} si disattiva`),icon:`toggle-right`}],overrides:{byRole:{[O.MotionSensor]:{state:{on:{label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}}},[O.ContactSensor]:{state:{on:{label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}}},[O.LeakSensor]:{state:{on:{label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}}},[O.SmokeSensor]:{state:{on:{label:F(`Smoke`,`Fumo`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}}},[O.COSensor]:{state:{on:{label:F(`Carbon monoxide`,`Monossido di carbonio`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}}},[O.GasSensor]:{state:{on:{label:F(`Gas`,`Gas`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}}},[O.TamperSensor]:{state:{on:{label:F(`Tampered`,`Manomesso`),whenTrue:F(`When {device} is tampered with`,`Quando {device} viene manomesso`),whenFalse:F(`When the tamper alert on {device} clears`,`Quando l’allarme di manomissione di {device} rientra`),icon:`shield-alert`}}},[O.VibrationSensor]:{state:{on:{label:F(`Vibration`,`Vibrazione`),whenTrue:F(`When {device} vibrates`,`Quando {device} vibra`),whenFalse:F(`When {device} is still again`,`Quando {device} torna fermo`),icon:`vibrate`}}},[O.ConnectivitySensor]:{state:{on:{label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}}},[O.SoundSensor]:{state:{on:{label:F(`Sound`,`Suono`),whenTrue:F(`When {device} hears a sound`,`Quando {device} sente un suono`),whenFalse:F(`When {device} is quiet again`,`Quando {device} torna silenzioso`),icon:`ear`}}},[O.BatterySensor]:{state:{on:{label:F(`Battery low`,`Batteria scarica`),whenTrue:F(`When the battery of {device} runs low`,`Quando la batteria di {device} si scarica`),whenFalse:F(`When the battery of {device} is fine again`,`Quando la batteria di {device} torna a posto`),icon:`battery-low`}}},[O.BinaryHelper]:{state:{on:{label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`toggle-right`}}}}}}},jC=S([`unknown-source`,`not-admin`,`no-builder`,`no-ingress-url`,`unreachable`,`unknown-board`,`no-encryption-key`,`unreadable-config`]),Kve=x({sourceId:l(),name:l()}),qve=x({configuration:l(),name:l(),address:l().nullable()}),MC=x({ok:p(!1),reason:jC,detail:l().optional()}),Jve=i(`ok`,[x({ok:p(!0),boards:C(qve).readonly()}),MC]),Yve=i(`ok`,[x({ok:p(!0),key:l()}),MC]),NC={name:`board-key-source`,scope:`system`,mode:`collection`,methods:{listSources:A(v(),C(Kve).readonly(),{auth:`admin`}),listBoards:A(x({sourceId:l().min(1)}),Jve,{auth:`admin`}),getBoardKey:A(x({sourceId:l().min(1),configuration:l().min(1)}),Yve,{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},PC=x({level:n().min(0).max(100).meta(N(`percentage`)),lastChangedAt:n()}),FC={name:`brightness`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setBrightness:A(x({deviceId:n().int().nonnegative(),level:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`brightness.full`,label:F(`Full brightness`,`Luminosità massima`),phrase:F(`Set {device} to full brightness`,`Porta {device} alla massima luminosità`),icon:`sun`,effect:{field:`level`,value:100},args:{level:100}},{id:`brightness.half`,label:F(`Half brightness`,`Luminosità a metà`),phrase:F(`Dim {device} to half`,`Abbassa {device} a metà luminosità`),icon:`sun-dim`,effect:{field:`level`,value:50},args:{level:50}},{id:`brightness.off`,label:F(`Brightness off`,`Luminosità a zero`),phrase:F(`Dim {device} to zero`,`Abbassa {device} a zero`),icon:`lightbulb-off`,effect:{field:`level`,value:0},args:{level:0}},{id:`brightness.set`,label:F(`Set brightness`,`Imposta la luminosità`),phrase:F(`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:F(`Percentage`,`Percentuale`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},events:{onBrightnessChanged:{data:x({deviceId:n(),level:n().min(0).max(100),lastChangedAt:n()}),notOperatorFacing:"the `level` state trigger reads the same change"}},status:{schema:PC,kind:`command-driven`},runtimeState:PC,durability:`session`,history:{fields:{level:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},vocabulary:{noun:F(`Brightness`,`Luminosità`),order:1010,state:[{kind:`numeric`,field:`level`,quantity:F(`the brightness`,`la luminosità`),label:F(`Brightness`,`Luminosità`),unit:`%`,icon:`sun`}]}},Xve=S([`connected`,`disconnected`,`connecting`,`auth-failed`,`unreachable`,`error`]),IC=x({brokerCount:n().int().nonnegative(),connectedCount:n().int().nonnegative()}),Zve=x({id:l()}),Qve=m(l(),w()),LC=x({brokerId:l(),target:m(l(),w()),payload:w().optional()}),RC=x({brokerId:l(),filter:m(l(),w())}),zC=x({subscriptionId:l()}),BC=x({brokerId:l(),subscriptionId:l()}),VC=x({brokerId:l(),key:l()}),HC={name:`broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:IC,kind:`poll`},methods:{getBrokerConfig:A(Zve,Qve.nullable(),{auth:`admin`}),publish:A(LC,w(),{kind:`mutation`,auth:`admin`}),subscribe:A(RC,zC,{kind:`mutation`,auth:`admin`}),unsubscribe:A(BC,v(),{kind:`mutation`,auth:`admin`}),getState:A(VC,w().nullable(),{auth:`admin`}),getStatus:A(v(),IC)},vocabulary:{notOperatorFacing:`message-broker connections — configured, not actuated`}},UC={name:`button`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button],methods:{press:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`button.press`,label:F(`Press`,`Premi`),phrase:F(`Press {device}`,`Premi {device}`),icon:`circle-dot`}]})},vocabulary:{noun:F(`Button`,`Pulsante`),order:1130}},WC=S([`ha`,`addon`]),GC=x({id:l().min(1),name:l().min(1),source:WC,enabled:y(),instanceId:l().min(1).optional()}),KC=x({id:l().min(1),calendarId:l().min(1),title:l(),startMs:n().int(),endMs:n().int(),allDay:y().optional(),description:l().optional(),location:l().optional()}),qC=x({calendarIds:C(l().min(1)).max(64).optional(),startMs:n().int(),endMs:n().int()}),JC={name:`calendar-source`,scope:`system`,mode:`collection`,internal:!0,providerKind:`calendar`,methods:{listCalendars:A(v(),C(GC).readonly(),{auth:`admin`}),listEvents:A(qC,C(KC).readonly(),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}};function YC(e){let t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()).getTime()}function XC(e){if(e.allDay!==!0)return{startMs:e.startMs,endMs:e.endMs};let t=YC(e.startMs),n=YC(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 $ve(e,t){let n=new Date(t),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()+1).getTime(),i=XC(e);return i.startMs<r&&i.endMs>t}var ZC=l().regex(/^#[0-9A-Fa-f]{6}$/,`expected #RRGGBB`),QC=GC.extend({id:l().min(1),providerAddonId:l().min(1).optional(),defaultColor:ZC,color:ZC,visible:y()}),$C=x({visible:y().optional(),color:ZC.optional()}),ew=x({calendars:m(l(),$C)}),tw=x({calendarId:l().min(1),visible:y().optional(),color:ZC.nullable().optional()}),nw={name:`calendars`,scope:`system`,mode:`singleton`,methods:{listCalendars:A(v(),C(QC).readonly(),{auth:`admin`}),listEvents:A(qC,C(KC).readonly(),{auth:`admin`}),getPreferences:A(x({}),ew,{auth:`admin`,caller:`required`}),setCalendarPreference:A(tw,ew,{auth:`admin`,kind:`mutation`,caller:`required`})},vocabulary:{notOperatorFacing:`calendars feed schedules and conditions, not device actions`}},rw=x({host:l(),port:n().int().positive().optional(),onvifPort:n().int().positive().optional(),rtspPort:n().int().positive().optional(),https:y().optional(),username:l().optional(),password:l().optional(),onvifProfile:l().optional()}),iw=x({host:l(),port:n().int().positive().nullable(),onvifPort:n().int().positive().nullable(),rtspPort:n().int().positive().nullable(),https:y().nullable(),hasUsername:y(),hasPassword:y(),onvifProfile:l().nullable()}),aw={name:`camera-credentials`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getCredentials:A(x({deviceId:n()}),rw.nullable(),{kind:`query`,auth:`admin`})},status:{schema:iw,kind:`command-driven`},vocabulary:{noun:F(`Camera credentials`,`Credenziali della telecamera`),order:3030}},ow=x({x:n().min(0).max(1),y:n().min(0).max(1),width:n().gt(0).max(1),height:n().gt(0).max(1)}),sw=x({deviceId:n().int().positive(),source:ow,cell:ow}),eye=x({profile:S([`high`,`mid`,`low`]),offered:y(),missingSources:C(n().int().positive()),canvas:l(),published:y()}),cw=x({blockId:l(),deviceId:n().int().nonnegative(),name:l(),fps:n().int(),cells:C(sw),profiles:C(eye)}),lw=x({deviceId:n().int().nonnegative(),fps:n().int().min(1).max(60).optional(),publishedProfiles:C(S([`high`,`mid`,`low`])).max(3).optional(),cells:C(sw).max(16)}),uw={name:`camera-grid-layout`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getLayout:A(x({deviceId:n().int().nonnegative()}),cw.nullable(),{auth:`admin`}),saveLayout:A(lw,cw,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Grid layout`,`Layout a griglia`),order:3040}},dw={name:`camera-pipeline-config`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection settings`,`Impostazioni di rilevamento`),order:3050}},fw=S([`webrtc`,`hls`,`mjpeg`,`rtsp`]),pw=S([`mp4`,`gif`]),mw=x({kind:pw,handle:l(),nodeId:l(),mime:l(),bytes:n().int(),width:n().int(),height:n().int()}),hw=x({fromTs:n(),toTs:n(),packets:n().int()}),gw=x({media:C(mw).readonly(),coverage:hw,profile:P,video:S([`copy`,`encode`])}),_w=x({brokerId:l(),url:l(),mutedUrl:l(),enabled:y(),codec:l().optional(),resolution:x({width:n().int().positive(),height:n().int().positive()}).optional()}),vw=x({sessionId:l(),remoteAddr:l(),userAgent:l().nullish(),playing:y(),muted:y(),connectedAt:n(),lastRtpAt:n(),bytesSent:n()}),yw=x({tag:l(),subscribedAt:n(),chunksDelivered:n()}),bw=S([`alexa`,`homekit`,`webrtc-browser`,`webrtc-mobile`,`webrtc-whep`,`rtsp-listen`,`derived-broker`,`recording`,`pipeline`,`snapshot`,`warmup`,`unknown`]),xw=x({kind:bw,label:l().optional(),media:S([`audio`,`video`,`both`]).optional(),targetCodec:l().optional(),transport:S([`passthrough`,`repacketize`,`transcode`]).optional(),remoteAddr:l().optional(),userAgent:l().optional(),userId:l().optional(),sessionId:l().optional(),extra:m(l(),l()).optional()}).readonly(),Sw=x({id:l(),channel:S([`annexb`,`rtp`]),attribution:xw,subscribedAt:n(),packetsDelivered:n()}),Cw=x({rtsp:C(vw).readonly(),audio:C(yw).readonly(),encoded:C(Sw).readonly(),pipeClients:n(),encodedSubscribers:n()}),ww=x({deviceId:n().int().nonnegative(),viewers:n().int().positive()}),tye=S([`reconnecting`,`sleeping`,`offline`,`disabled`,`waking`]),nye=S([`h264`,`h265`,`copy`]),rye=S([`aac`,`opus`,`pcmu`,`copy`,`none`]),Tw=x({deviceId:n().int().nonnegative(),video:nye,audio:rye.optional(),profile:P.optional(),targetResolution:x({width:n().int().positive(),height:n().int().positive()}).optional(),outputArgs:C(l()).optional(),audioEgress:y().optional(),hostname:l().optional(),tag:l().optional()}),Ew=x({url:l(),sentryUrl:l().nullable().optional(),videoCodec:S([`H264`,`H265`]),audioCodec:l(),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),pipelineKey:l()}),Dw=id.omit({inputArgs:!0,outputArgs:!0}),Ow=S([`tight`,`relaxed`]),kw=x({deviceId:n().int().nonnegative(),source:i(`kind`,[x({kind:p(`profile`),profile:P}),x({kind:p(`cam-stream`),camStreamId:l().min(1)})]),encode:Dw,rateControl:Ow.optional(),bitstreamFilter:S([`dump_extra`,`h264_mp4toannexb`,`hevc_mp4toannexb`]).optional(),publishLocally:y().optional(),pixelFormat:S([`yuv420p`,`nv12`]).optional(),decodeHwAccel:S([`auto`,`none`,`videotoolbox`,`vaapi`,`qsv`,`cuda`]).optional(),hostname:l().optional(),tag:l().optional()}),Aw=x({url:l(),pipelineKey:l(),videoCodec:S([`H264`,`H265`]),resolution:x({width:n().int().positive(),height:n().int().positive()}),transcoded:y(),encoder:l(),decodeHwAccel:l().nullable(),camStreamId:l().nullable()}),jw={name:`stream-broker`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,methods:{reportStreamSignal:A(x({deviceId:n().int().nonnegative(),code:l().min(1),at:n().optional()}),x({accepted:y(),reason:S([`woke`,`hold-extended`,`not-enabled`,`no-consumer`,`unknown-code`])}),{kind:`mutation`}),publishCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1),kind:Xi,url:l().optional(),codec:l().optional(),resolution:Zi.optional(),fps:n().positive().optional(),label:l().optional(),deviceFeatures:C(l()).optional(),autoEligible:y().optional(),profileHint:P.optional(),metadata:m(l(),w()).optional(),sourceCamStreamId:l().min(1).optional(),encodeProfile:id.optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),retractCameraStream:A(x({deviceId:n().int().nonnegative(),camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),assignProfile:A(x({deviceId:n().int().nonnegative(),profile:P,camStreamId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),forgetDeviceHardware:A(x({deviceId:n().int().nonnegative()}),x({derivedStreamsDeleted:C(l()).readonly(),assignmentsPurged:y(),probeSnapshotsDropped:n().int().nonnegative(),rtspTokenRowsDeleted:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),renderPreBufferClip:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preRollSec:n().min(0).max(20).default(3),postRollSec:n().min(0).max(20).default(5),format:S([`gif`,`mp4`]).default(`gif`),maxWidth:n().int().min(120).max(1920).default(480),fps:n().int().min(1).max(15).default(5),speed:n().min(1).max(8).default(2)}),x({base64:l(),mime:l(),bytes:n().int(),profile:P,durationMs:n()}),{kind:`mutation`,auth:`admin`}),produceEventMedia:A(x({deviceId:n(),profile:P.optional(),aroundMs:n(),preSeconds:n().min(0).max(20).default(4),postSeconds:n().min(0).max(20).default(6),kinds:C(pw).min(1).default([`mp4`]),gifMaxWidth:n().int().min(120).max(1280).default(640),gifFps:n().int().min(1).max(15).default(12),gifSpeed:n().min(1).max(8).default(4),speed:n().min(1).max(8).default(4)}),gw,{kind:`mutation`,auth:`admin`}),fetchEventMedia:A(x({handle:l()}),x({base64:l(),mime:l(),bytes:n().int()}).nullable(),{kind:`mutation`,auth:`admin`}),listAllCameraStreams:A(v(),C(Qi).readonly()),listAllProfileSlots:A(v(),C(ea).readonly()),getBrokerStats:A(x({brokerId:l()}),ca),probeStream:A(x({brokerId:l()}),x({probed:y(),summary:l()}),{kind:`mutation`,auth:`admin`}),listClients:A(x({brokerId:l()}),Cw),getLiveViewerCounts:A(v(),C(ww).readonly(),{role:`viewer`}),killClient:A(x({brokerId:l(),channel:S([`rtsp`,`audio`]),handle:l()}),x({killed:y()}),{kind:`mutation`,auth:`admin`}),restartProfile:A(x({deviceId:n().int().nonnegative(),profile:P}),x({success:y()}),{kind:`mutation`,auth:`admin`}),getStreamUrl:A(x({streamId:l(),format:fw}),x({url:l()})),getStreamWithCodec:A(Tw,Ew,{kind:`mutation`,auth:`admin`}),releaseStreamWithCodec:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),acquireEgressTranscode:A(kw,Aw,{kind:`mutation`,auth:`admin`}),releaseEgressTranscode:A(x({pipelineKey:l()}),x({released:y(),refcount:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),subscribeAudioChunks:A(aa,oa,{kind:`mutation`}),pullAudioChunks:A(x({subscriptionId:l(),maxCount:n().int().positive().default(8)}),C(ia).readonly()),unsubscribeAudioChunks:A(x({subscriptionId:l()}),x({released:y()}),{kind:`mutation`}),setPreBufferDuration:A(x({brokerId:l(),seconds:n().min(0).max(30)}),v(),{kind:`mutation`,auth:`admin`}),getPreBufferInfo:A(x({brokerId:l()}),x({configuredSec:n(),bufferedMs:n(),packetCount:n()})),getRtspPort:A(v(),n()),getAllRtspEntries:A(x({hostname:l().optional()}),C(_w).readonly()),getRtspEntry:A(x({brokerId:l(),hostname:l().optional()}),_w.nullable()),regenerateRtspToken:A(x({brokerId:l()}),l().nullable(),{kind:`mutation`,auth:`admin`}),setRtspEnabled:A(x({brokerId:l(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`}),isRtspEnabled:A(x({brokerId:l()}),y()),getDeviceAudioMute:A(x({deviceId:n().int()}),x({muted:y(),appliedBrokers:n().int().nonnegative()})),setDeviceAudioMute:A(x({deviceId:n().int(),muted:y()}),x({muted:y(),appliedBrokers:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`})},events:{onCamStreamDemand:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l(),profile:P})),onCamStreamIdle:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l()})),onRequestStreamSourceRefresh:Lr(x({deviceId:n().int().nonnegative(),camStreamId:l(),brokerId:l()}))},vocabulary:{notOperatorFacing:M.PIPELINE}},Mw=S([`h264`,`h265`,`hevc`,`av1`,`mjpeg`,`vp8`,`vp9`]),Nw=x({acceptCodecs:C(Mw).readonly().optional(),minHeight:n().int().positive().optional(),maxHeight:n().int().positive().optional(),minWidth:n().int().positive().optional(),excludeDerived:y().optional(),requireSiblingCodec:C(Mw).readonly().optional(),allowTranscode:y().optional(),requireProfileBound:y().optional()}).readonly(),Pw=x({preferredProviders:C(l()).readonly().optional(),resolutionPreference:S([`highest`,`lowest`]).optional(),targetHeight:n().int().positive().optional()}).readonly(),Fw=x({camStreamId:l(),codec:l().optional(),resolution:Zi.optional(),transcodes:y(),reason:l(),profile:P.optional(),brokerId:l().optional(),url:l().optional(),fps:n().positive().optional(),fpsSource:S([`published`,`measured`]).optional()}),Iw={name:`camera-streams`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{getCameraStreams:A(x({deviceId:n().int().nonnegative()}),C(Qi).readonly()),getBrokerStreams:A(x({deviceId:n().int().nonnegative()}),C(ea).readonly()),getRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(_w).readonly()),getProfileRtspEntries:A(x({deviceId:n().int().nonnegative(),hostname:l().optional()}),C(la).readonly()),pickStream:A(x({deviceId:n().int().nonnegative(),requirements:Nw,preferences:Pw.optional()}),Fw.nullable())},events:{onCamStreamsChanged:Lr(x({deviceId:n().int().nonnegative(),camStreams:C(Qi).readonly()}),{notOperatorFacing:`the stream catalog was rebuilt — plumbing, not a happening`}),onProfileSlotsChanged:Lr(x({deviceId:n().int().nonnegative(),profileSlots:C(ea).readonly()}),{notOperatorFacing:`stream profiles were reassigned — plumbing, not a happening`})},runtimeState:x({online:y(),slotStatuses:x({high:$i.optional(),mid:$i.optional(),low:$i.optional()}),slotErrors:x({high:l().optional(),mid:l().optional(),low:l().optional()}),lastChangedAt:n()}),durability:`session`,history:`none`,vocabulary:{noun:F(`Camera streams`,`Flussi della telecamera`),order:3060}},Lw=x({detected:y(),lastChangedAt:n()}),Rw={name:`carbon-monoxide`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:Lw,kind:`push`},runtimeState:Lw,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Carbon monoxide`,`Monossido di carbonio`),order:5030,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects carbon monoxide`,`Quando {device} rileva monossido di carbonio`),whenFalse:F(`When the carbon monoxide clears on {device}`,`Quando il monossido su {device} rientra`),icon:`cloud-alert`}]}},zw=S([`off`,`heat`,`cool`,`auto`,`heat_cool`,`fan_only`,`dry`]),Bw=S([`heating`,`cooling`,`drying`,`fan`,`idle`,`off`]),Vw=x({mode:zw,action:Bw.nullable().optional(),availableModes:C(zw),fanMode:l(),availableFanModes:C(l()),preset:l(),availablePresets:C(l()),target:n().nullable().meta(N(`temperature`)),targetHigh:n().nullable().meta(N(`temperature`)),targetLow:n().nullable().meta(N(`temperature`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),currentTemp:n().nullable().meta(N(`temperature`)),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),swingVertical:y().nullable(),swingHorizontal:y().nullable(),minTemp:n().nullable().optional().meta(N(`temperature`)),maxTemp:n().nullable().optional().meta(N(`temperature`)),tempStep:n().positive().nullable().optional().meta(N(`temperature`)),lastActiveMode:zw.exclude([`off`]).optional(),lastFetchedAt:n()}),iye=[E.Climate];function Hw(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`climate-control`,stateField:t},deviceTypes:iye,apply:`replace`,path:t,sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}var Uw=[Hw(`room-temperature`,`currentTemp`),Hw(`room-humidity`,`currentHumidity`)],aye={version:1,overridable:Uw.map(e=>({path:e.path,by:e.id})),targets:Uw},Ww={name:`climate-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],power:{kind:`mode`,field:`mode`,offValue:`off`,set:`setMode`,lastField:`lastActiveMode`},methods:{setMode:A(x({deviceId:n().int().nonnegative(),mode:zw}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.off`,label:F(`Climate off`,`Clima spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`mode`,value:`off`},args:{mode:`off`}},{id:`climate.heat`,label:F(`Heat`,`Riscalda`),phrase:F(`Set {device} to heat`,`Metti {device} in riscaldamento`),icon:`flame`,effect:{field:`mode`,value:`heat`},args:{mode:`heat`}},{id:`climate.cool`,label:F(`Cool`,`Raffresca`),phrase:F(`Set {device} to cool`,`Metti {device} in raffrescamento`),icon:`snowflake`,effect:{field:`mode`,value:`cool`},args:{mode:`cool`}},{id:`climate.auto`,label:F(`Climate auto`,`Clima automatico`),phrase:F(`Set {device} to automatic`,`Metti {device} in automatico`),icon:`thermometer`,effect:{field:`mode`,value:`auto`},args:{mode:`auto`}},{id:`climate.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`thermometer`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Spento`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}]}}]}]}),setTarget:A(x({deviceId:n().int().nonnegative(),target:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.target`,label:F(`Set temperature`,`Imposta la temperatura`),phrase:F(`Set {device} to {target}`,`Imposta {device} a {target}`),icon:`thermometer`,effect:{field:`target`,fromArg:`target`},openArgs:[{key:`target`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetRange:j(x({deviceId:n().int().nonnegative(),targetLow:n(),targetHigh:n()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetRange`,label:F(`Set temperature range`,`Imposta l’intervallo di temperatura`),phrase:F(`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:F(`Lowest`,`Minima`),offer:{kind:`number`,step:.5,unit:`°C`}},{key:`targetHigh`,label:F(`Highest`,`Massima`),offer:{kind:`number`,step:.5,unit:`°C`}}]}]}),setTargetHumidity:j(x({deviceId:n().int().nonnegative(),targetHumidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.targetHumidity`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`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:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setFanMode:j(x({deviceId:n().int().nonnegative(),fanMode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.fanMode`,label:F(`Set fan mode`,`Imposta la ventilazione`),phrase:F(`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:F(`Fan mode`,`Ventilazione`),offer:{kind:`dynamic`,from:`status`,field:`availableFanModes`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setSwingVertical:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingVerticalOn`,label:F(`Vertical swing on`,`Oscillazione verticale attiva`),phrase:F(`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:F(`Vertical swing off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical swing of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,effect:{field:`swingVertical`,value:!1},args:{on:!1}}]}),setSwingHorizontal:j(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`climate.swingHorizontalOn`,label:F(`Horizontal swing on`,`Oscillazione orizzontale attiva`),phrase:F(`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:F(`Horizontal swing off`,`Oscillazione orizzontale spenta`),phrase:F(`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:Vw,kind:`push`},runtimeState:Vw,customize:aye,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:F(`Climate`,`Clima`),order:1070,state:[{kind:`enum`,field:`mode`,label:F(`Mode`,`Modalità`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`heat`,label:F(`Heat`,`Riscaldamento`),phrase:F(`When {device} starts heating`,`Quando {device} passa al riscaldamento`)},{value:`cool`,label:F(`Cool`,`Raffrescamento`),phrase:F(`When {device} starts cooling`,`Quando {device} passa al raffrescamento`)},{value:`auto`,label:F(`Automatic`,`Automatico`)},{value:`heat_cool`,label:F(`Heat and cool`,`Caldo e freddo`)},{value:`fan_only`,label:F(`Fan only`,`Solo ventilazione`)},{value:`dry`,label:F(`Dry`,`Deumidificazione`)}],icon:`thermometer`},{kind:`numeric`,field:`currentTemp`,quantity:F(`the temperature`,`la temperatura`),label:F(`Temperature`,`Temperatura`),unit:`°C`,icon:`thermometer`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`},{kind:`numeric`,field:`target`,quantity:F(`the set temperature`,`la temperatura impostata`),label:F(`Set temperature`,`Temperatura impostata`),unit:`°C`,icon:`thermometer`}]}},Gw=S([`backup`,`hub-server`,`agent-server`,`addons`]),Kw=S([`pending`,`running`,`ok`,`failed`,`skipped`]),qw=S([`backup-unavailable`,`backup-failed`,`server-refused`,`server-not-on-target`,`node-capless`,`status-unreadable`,`addon-update-failed`,`addons-not-converged`,`interrupted`,`timeout-stall`,`timeout-ceiling`]),Jw=x({kind:Gw,nodeId:l().optional(),status:Kw,detail:l(),reason:qw.optional(),fromVersion:l().nullable().optional(),packages:C(l()).readonly().optional(),startedAt:n().optional(),finishedAt:n().optional()}),Yw=S([`running`,`succeeded`,`failed`]),Xw=x({id:l(),state:Yw,targetVersion:l(),requestedBy:l(),startedAt:n(),finishedAt:n().optional(),steps:C(Jw).readonly(),stoppedAt:l().optional(),reason:qw.optional(),skippedOffline:C(l()).readonly()}),Zw=x({version:l().optional(),addons:y().optional(),backup:y().optional()}),Qw=S([`no-target`,`node-busy`,`job-running`,`nothing-to-do`,`status-unreadable`]),$w=x({targetVersion:l().nullable(),steps:C(Jw).readonly(),skippedOffline:C(l()).readonly(),blocker:Qw.nullable(),blockerDetail:l().nullable()}),eT=x({accepted:y(),jobId:l().nullable(),blocker:Qw.nullable(),message:l()}),tT={name:`cluster-update`,scope:`system`,mode:`singleton`,methods:{previewClusterUpdate:A(Zw,$w,{auth:`admin`}),startClusterUpdate:A(Zw,eT,{kind:`mutation`,auth:`admin`}),getClusterUpdateJob:A(x({jobId:l().optional()}),Xw.nullable(),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},nT=x({r:n().int().min(0).max(255).meta(N(`none`)),g:n().int().min(0).max(255).meta(N(`none`)),b:n().int().min(0).max(255).meta(N(`none`))}),rT=x({h:n().min(0).max(360).meta(N(`none`)),s:n().min(0).max(100).meta(N(`none`)),v:n().min(0).max(100).meta(N(`none`))}),iT=i(`mode`,[x({mode:p(`rgb`),rgb:nT}),x({mode:p(`hsv`),hsv:rT}),x({mode:p(`mired`),colorTemperature:n().int().min(50).max(1e3)})]),aT=x({mode:S([`rgb`,`hsv`,`mired`]),rgb:nT.optional(),hsv:rT.optional(),colorTemperature:n().int().optional().meta(N(`colour-temperature`)),lastChangedAt:n()});function oye(e){let t=iT.safeParse(e);return t.success?t.data:null}var oT={name:`color`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light],methods:{setColor:A(x({deviceId:n().int().nonnegative(),color:iT}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`color.warmWhite`,label:F(`Warm white`,`Bianco caldo`),phrase:F(`Set {device} to warm white`,`Imposta {device} su bianco caldo`),icon:`sun`,args:{color:{mode:`mired`,colorTemperature:370}}},{id:`color.coolWhite`,label:F(`Cool white`,`Bianco freddo`),phrase:F(`Set {device} to cool white`,`Imposta {device} su bianco freddo`),icon:`snowflake`,args:{color:{mode:`mired`,colorTemperature:200}}},{id:`color.red`,label:F(`Red`,`Rosso`),phrase:F(`Turn {device} red`,`Colora {device} di rosso`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:255,g:0,b:0}}}},{id:`color.green`,label:F(`Green`,`Verde`),phrase:F(`Turn {device} green`,`Colora {device} di verde`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:255,b:0}}}},{id:`color.blue`,label:F(`Blue`,`Blu`),phrase:F(`Turn {device} blue`,`Colora {device} di blu`),icon:`palette`,args:{color:{mode:`rgb`,rgb:{r:0,g:0,b:255}}}}]})},events:{onColorChanged:{data:x({deviceId:n(),mode:S([`rgb`,`hsv`,`mired`]),rgb:nT.optional(),hsv:rT.optional(),colorTemperature:n().int().optional(),lastChangedAt:n()}),notOperatorFacing:"a colour change is read through the `mode` state trigger"}},status:{schema:aT,kind:`command-driven`},runtimeState:aT,durability:`session`,history:`none`,vocabulary:{noun:F(`Colour`,`Colore`),order:1020,state:[{kind:`enum`,field:`mode`,label:F(`Colour mode`,`Modalità colore`),values:[{value:`rgb`,label:F(`RGB colour`,`Colore RGB`)},{value:`hsv`,label:F(`HSV colour`,`Colore HSV`)},{value:`mired`,label:F(`White temperature`,`Temperatura del bianco`)}],icon:`palette`}]}};function sT(e,t){let n=e;for(let e of t.split(`.`)){let t=Mg(n);if(!(t instanceof ce))return null;let r=t.shape[e];if(!(r instanceof ie))return null;n=r}return n}function cT(e,t){let n=Ng(e).find(e=>e.path===t);if(n===void 0)return null;let r=sT(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 lT(e){return new Map(Ng(e).filter(e=>!e.path.includes(`.`)).flatMap(t=>{let n=cT(e,t.path);return n===null?[]:[[t.path,n]]}))}function uT(e){let t=Mg(e);return t instanceof ce?Object.entries(t.shape).flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]):[]}function dT(e,t){let n=t.split(`.`);return n.slice(0,-1).flatMap((t,r)=>{let i=n.slice(0,r+1).join(`.`),a=sT(e,i);return a!==null&&a.safeParse(void 0).success?[i]:[]})}var fT={"doorbell.onPressed":T.DoorbellOnPressed},sye=fT,pT=x({featureIndex:n().int().nonnegative(),cap:l(),eventName:l(),category:S(T),stateField:l(),fieldKey:l()});function mT(e,t,n){return{code:e,path:t,message:n}}function cye(e){return e.issues.map(e=>`${e.path.length===0?`payload`:e.path.join(`.`)}: ${e.message}`).join(`; `)}function hT(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?cT(e.runtimeState,s.field):null;if(l===null){r.push(mT(`unknown-field`,c,`\`${e.name}.${a}\` derives from missing state field \`${s.field}\``));continue}if(l.kind!==`number`){r.push(mT(`kind-mismatch`,c,`\`${e.name}.${a}\` needs a numeric state field; \`${s.field}\` is ${l.kind}`));continue}let u=`${e.name}.${a}`,d=sye[u];if(d===void 0){r.push(mT(`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(mT(`not-composable`,`features[${t.featureIndex}].cap`,`\`${u}\` cannot be derived from { deviceId, timestamp }: ${cye(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(mT(`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 gT=S(`reserved-variant.unknown-capability.not-composable.wrong-device-type.has-commands.unknown-field.nested-field.missing-field.kind-mismatch.source-kind-mismatch.may-be-null.source-missing.source-unreadable.source-capability-missing.source-field-unknown.expression-invalid.cycle.duplicate-target.not-item-array.item-field-reserved.target-missing.target-unreadable.not-replaceable.native-capability-replace.mixed-quantity.helper-mismatch.member-constraint.retention.command-method-unknown.command-source-unknown.command-input-unknown.command-input-missing.power-source-is-actuator.link-contribution-removed`.split(`.`)),_T=x({code:gT,path:l(),message:l()}),vT=S([`string`,`number`,`boolean`,`enum`]),yT=S([`null`,`offline`,`unknown`,`release`,`omit`]),bT=S([`derived`,`clock`,`constant`,`accumulator`]),xT=x({arrayPath:l(),key:l(),label:l(),resettable:y().optional()}),ST=x({cap:l(),path:l(),item:xT.optional(),featureIndex:n().int().nonnegative(),kind:vT,nullable:y(),required:y(),unavailable:yT,role:bT,source:Fc,reads:C(Dc)});function CT(e){let t=e.item===void 0?e.path:cl(e.item.arrayPath,e.item.key,e.path);return`${e.cap}.${t}`}var wT=S([`new`,`add`,`replace`]),TT=x({featureIndex:n().int().nonnegative(),cap:l(),mode:wT}),ET=x({ok:y(),problems:C(_T),fields:C(ST),features:C(TT),events:C(pT)}),DT=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),OT=S([`fresh`,`stale`,`unavailable`]),kT=x({cap:l(),path:l(),item:xT.optional(),state:OT,value:h([l(),n(),y(),ae()]),reason:l().optional()}),AT=x({blockId:l(),deviceId:n().nullable(),status:DT,reason:l().optional(),fields:C(kT)}),lye=Tc,jT=x({id:l().min(1),name:l().min(1).max(120),enabled:y(),updatedAt:n(),composition:tl}),MT=x({id:l().min(1),name:l().nullable(),error:l()}),NT=x({deviceId:n().int(),capName:l(),owner:l(),error:l()}),PT=x({integrationId:l().nullable(),storeLoaded:y(),blocks:C(jT),restartBlockIds:C(l()),unreadableBlocks:C(MT),retiredBlockIds:C(l()).optional()}),FT=x({blockId:l(),status:DT,reason:l().optional()}),IT=x({blocks:C(FT),acted:y(),unreleasedClaims:C(NT).optional()}),LT={name:`composer`,scope:`system`,mode:`singleton`,internal:!0,methods:{applyBlocks:A(PT,IT,{kind:`mutation`,auth:`admin`}),getStates:A(x({blockIds:C(l())}),x({states:C(AT)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`device composition — an authoring tool, not an action`}},RT=x({connected:y(),lastChangedAt:n()}),zT={name:`connectivity`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:RT,kind:`push`},runtimeState:RT,durability:`restored`,history:{fields:{connected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Connectivity`,`Connettività`),order:5040,state:[{kind:`boolean`,field:`connected`,label:F(`Connected`,`Connesso`),whenTrue:F(`When {device} connects`,`Quando {device} si connette`),whenFalse:F(`When {device} disconnects`,`Quando {device} si disconnette`),icon:`wifi`}]}},BT=S([`wear`,`supply`,`waste`]),VT=S([`part`,`tank`,`product`,`bin`]),HT=S([`ok`,`low`,`empty`,`full`,`replace`]),uye=S([`ok`,`low`,`empty`,`full`]);function UT(e){return e.kind??`wear`}var dye={wear:`part`,waste:`bin`,supply:`product`};function fye(e){return e.form??dye[UT(e)]}var WT=S([`duration`,`count`]),GT=x({value:n().min(0).nullable().meta(N(`device`)),kind:WT}),KT=x({key:l().min(1),label:l().min(1),level:n().min(0).max(100).nullable().meta(N(`percentage`)),status:HT.nullable(),kind:BT.optional(),form:VT.optional(),lastResetAt:n().nullable(),resettable:y(),remaining:GT.optional()}),qT=x({items:C(KT),lastChangedAt:n()}),pye={items:[],lastChangedAt:0},mye={version:1,targets:[{id:`items`,cardinality:`keyedArray`,vocabulary:{cap:`consumables`},deviceTypes:Object.values(E),apply:`add`,path:`items`,keyField:`key`,labelField:`label`,itemSchema:KT,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:[...WT.options]}]},{path:`status`,sources:[{kind:`enum`,transforms:[{kind:`enum-map`,outputValues:[...HT.options],unmapped:null}]}]}],traits:[{path:`kind`,values:[...BT.options],defaultValue:`wear`},{path:`form`,values:[...VT.options],defaultValue:`part`}],companions:[{kind:`clock`,path:`lastChangedAt`,when:`add`},{kind:`clock`,path:`lastFetchedAt`,when:`add`}],advancedExpression:!0}]},JT={name:`consumables`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:Object.values(E),methods:{reset:A(x({deviceId:n().int().nonnegative(),key:l().min(1)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`consumables.reset`,label:F(`Mark as replaced`,`Segna come sostituito`),phrase:F(`Mark {key} as replaced on {device}`,`Segna {key} come sostituito su {device}`),icon:`refresh-cw`,openArgs:[{key:`key`,label:F(`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:qT,kind:`push`,empty:pye,itemArray:{path:`items`,keyField:`key`,labelField:`label`,itemSchema:KT,emptyItem:{key:``,label:``,level:null,status:null,lastResetAt:null,resettable:!1}}},runtimeState:qT.extend({lastFetchedAt:n()}),durability:`restored`,customize:mye,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:F(`Consumables`,`Materiali di consumo`),order:2070}},YT=x({entryOpen:y(),lastChangedAt:n()}),XT={name:`contact`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:YT,kind:`push`},runtimeState:YT,durability:`restored`,history:{fields:{entryOpen:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Contact`,`Contatto`),order:5050,state:[{kind:`boolean`,field:`entryOpen`,label:F(`Open`,`Aperto`),whenTrue:F(`When {device} opens`,`Quando {device} si apre`),whenFalse:F(`When {device} closes`,`Quando {device} si chiude`),icon:`door-open`}]}},ZT=S([`numeric`,`select`,`text`,`datetime`]),QT=x({kind:ZT,value:h([n().meta(N(`device`)),l()]),options:C(l()),lastChangedAt:n(),min:n().optional().meta(N(`device`)),max:n().optional().meta(N(`device`)),step:n().optional().meta(N(`device`))}),hye=i(`kind`,[x({kind:p(`numeric`),value:n()}),x({kind:p(`select`),value:l().min(1)}),x({kind:p(`text`),value:l()}),x({kind:p(`datetime`),value:l().min(1)})]),$T=x({deviceId:n().int().nonnegative(),cycle:y().default(!0)}),eE=x({deviceId:n().int().nonnegative()}),tE={name:`control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Control],methods:{setValue:A(x({deviceId:n().int().nonnegative(),control:hye}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`the value shape depends on the control kind (numeric / select / text / datetime) read from status; a typed picker for it is a follow-up of the automations rework`}),next:j($T,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.next`,label:F(`Next option`,`Opzione successiva`),phrase:F(`Select the next option on {device}`,`Seleziona l’opzione successiva su {device}`),icon:`skip-forward`,openArgs:[{key:`cycle`,label:F(`Wrap to the first option`,`Ricomincia dalla prima opzione`),offer:{kind:`boolean`}}]}]}),previous:j($T,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.previous`,label:F(`Previous option`,`Opzione precedente`),phrase:F(`Select the previous option on {device}`,`Seleziona l’opzione precedente su {device}`),icon:`skip-back`,openArgs:[{key:`cycle`,label:F(`Wrap to the last option`,`Ricomincia dall’ultima opzione`),offer:{kind:`boolean`}}]}]}),first:j(eE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.first`,label:F(`First option`,`Prima opzione`),phrase:F(`Select the first option on {device}`,`Seleziona la prima opzione su {device}`),icon:`chevron-first`}]}),last:j(eE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`select.last`,label:F(`Last option`,`Ultima opzione`),phrase:F(`Select the last option on {device}`,`Seleziona l’ultima opzione su {device}`),icon:`chevron-last`}]})},status:{schema:QT,kind:`push`},runtimeState:QT,durability:`session`,history:`none`,vocabulary:{noun:F(`Control`,`Controllo`),order:1150,state:[{kind:`value`,field:`value`,label:F(`Value`,`Valore`),offer:{kind:`dynamic`,from:`status`,field:`options`},icon:`sliders-horizontal`}]}},B=class extends Error{code;constructor(e,t){super(t),this.name=`IrCodecError`,this.code=e}},nE=1024,rE=C(n().int()).min(2).max(nE).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]})})}),iE=x({carrierHz:n().int().positive().optional(),dutyCyclePercent:n().int().min(1).max(100).optional(),repeat:n().int().min(0).max(20).optional(),repeatDelayMs:n().int().min(0).optional()}),gye=.241246,_ye=0;function aE(e){let t=e.trim().split(/\s+/).filter(e=>e.length>0);if(t.length<4)throw new B(`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 B(`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 B(`pronto-malformed`,`Pronto header incomplete`);if(r!==_ye)throw new B(`pronto-unsupported-form`,`Pronto form ${t[0]??``} is not supported, only the learned 0000 form`);if(i===0)throw new B(`pronto-malformed`,`Pronto frequency word is zero`);let s=a+o;if(s===0||n.length!==4+s*2)throw new B(`pronto-malformed`,`Pronto declares ${s} burst pairs but carries ${(n.length-4)/2} word pairs`);let c=i*gye,l=n.slice(4).map((e,t)=>{let n=Math.max(1,Math.round(e*c));return t%2==0?n:-n}),u=rE.safeParse(l);if(!u.success)throw new B(`invalid-timings`,`Pronto decoded to invalid timings: ${u.error.message}`);return{timings:u.data,carrierHz:Math.round(1e6/c)}}var vye=8192,oE=32,sE=3,yye=264,cE=nE*2;function bye(e){let t=[],n=0,r=e=>{if(t.length+e>cE)throw new B(`tuya-malformed`,`decompressed code is larger than any IR train`)},i=()=>{let t=e[n++];if(t===void 0)throw new B(`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 B(`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 B(`tuya-malformed`,`back-reference is invalid`);t.push(n)}}return Uint8Array.from(t)}function xye(e){let t=[],n=new Map,r=0,i=n=>{for(let i=r;i<n;i+=oE){let r=Math.min(i+oE,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+sE<=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<=vye){let t=0;for(;a+t<e.length&&t<yye&&e[r+t]===e[a+t];)t++;t>=sE&&(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 lE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Sye=65535;function Cye(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+=lE[o>>18&63],t+=lE[o>>12&63],t+=n+1<e.length?lE[o>>6&63]:`=`,t+=n+2<e.length?lE[o&63]:`=`}return t}function wye(e){let t=e.trim().replace(/=+$/,``);if(t.length===0||t.length%4==1)throw new B(`tuya-malformed`,`not a base64 string`);let n=[],r=0,i=0;for(let e of t){let t=lE.indexOf(e);if(t<0)throw new B(`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 uE(e){let t=new Uint8Array(e.length*2);return e.forEach((e,n)=>{let r=Math.abs(e);if(r===0||r>Sye)throw new B(`invalid-timings`,`timing ${n} does not fit 16 bits`);t[n*2]=r&255,t[n*2+1]=r>>8}),Cye(xye(t))}function dE(e){let t=bye(wye(e));if(t.length===0||t.length%2!=0)throw new B(`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=rE.safeParse(n);if(!r.success)throw new B(`tuya-malformed`,r.error.message);return r.data}var fE=S([`tuya`]),pE=Math.ceil((cE+Math.ceil(cE/32))/3)*4+256,mE=x({format:fE,code:l().min(1).max(pE)}),hE={tuya:{encode:uE,decode:dE}},gE=i(`kind`,[x({kind:p(`raw`),timings:C(n().int()),settings:iE.optional()}),x({kind:p(`pronto`),code:l()}),x({kind:p(`native`),format:fE,code:l()})]);function _E(e){if(e.kind===`pronto`){let t=aE(e.code);return{timings:t.timings,settings:{carrierHz:t.carrierHz}}}if(e.kind===`native`)return{timings:hE[e.format].decode(e.code),settings:{}};let t=rE.safeParse(e.timings);if(!t.success)throw new B(`invalid-timings`,t.error.message);return{timings:t.data,settings:e.settings??{}}}var vE=`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(`.`),yE=[`source_select`];function bE(e){return yE.includes(e)}var xE=`custom:`,Tye=/^[a-z0-9][a-z0-9_]{0,47}$/,Eye=new Set(vE);function SE(e){return Eye.has(e)}function CE(e){return Tye.test(e)}function wE(e){return`${xE}${e}`}function TE(e){if(!e.startsWith(`custom:`))return null;let t=e.slice(7);return CE(t)?t:null}function EE(e){return SE(e)||TE(e)!==null}var DE=l().refine(EE,{message:`a role is one of the known roles or custom:<key> (lowercase letters, digits, _)`}),OE=[`digits`,`sequence`,`ir`],Dye=S(OE),Oye=200,kye=16,Aye=6,jye=/^[a-z0-9][a-z0-9_-]{0,47}$/,Mye=RegExp(`^[0-9]{1,6}$`),kE={id:l().regex(jye,{message:`a lowercase slug`}),name:l().trim().min(1).max(60)},AE=x({...kE,kind:p(`digits`),number:l().regex(Mye,{message:`up to 6 digits`})}),jE=x({...kE,kind:p(`sequence`),steps:C(DE).min(1).max(16)}),ME=x({...kE,kind:p(`ir`),transmitterId:n().int().nonnegative().optional(),payload:gE}),NE=i(`kind`,[AE,jE,ME]),Nye=500,Pye=100,PE=3e3;function FE(e){switch(e.kind){case`sequence`:return e.steps;case`digits`:return Array.from(e.number,e=>`digit_${e}`);case`ir`:return[]}}function IE(e){try{return _E(e.payload),null}catch(e){if(e instanceof B)return e.message;throw e}}function Fye(e,t){return e.trim().toLowerCase()===t.trim().toLowerCase()}function LE(e,t){let n=t.trim();for(let t of e)if(t.kind===`digits`&&t.number===n)return t;return null}function Iye(e,t){let n=e.find(e=>Fye(e.name,t));if(n!==void 0)return n;let r=e.find(e=>e.id===t.trim());return r===void 0?LE(e,t):r}var RE=S([`off`,`on`,`idle`,`playing`,`paused`,`buffering`,`standby`]),zE=S([`off`,`all`,`one`]),Lye=x({type:l(),title:l(),artist:l().optional(),album:l().optional(),imageUrl:l().optional()}),BE=S([`reported`,`assumed`]),VE=S([`state`,`volumeLevel`,`isMuted`,`source`]),HE=x({state:RE,stateSource:BE.default(`reported`),assumedFields:C(VE).default([]),volumeLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),isMuted:y().nullable(),muteReadback:y().optional(),source:l(),availableSources:C(l()),declaredSources:C(x({name:l(),kind:S(OE),number:l().optional()})).optional(),currentMedia:Lye.nullable(),position:n().int().nonnegative().nullable().meta(N(`duration-ms`)),duration:n().int().nonnegative().nullable().meta(N(`duration-ms`)),shuffle:y().nullable(),repeat:zE.nullable(),positionUpdatedAt:n().nullable().default(null),lastChangedAt:n()}),Rye=50,UE=x({deviceId:n().int().nonnegative(),steps:n().int().min(1).max(50).default(1)}),WE=x({deviceId:n().int().nonnegative()}),GE={name:`media-player`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],power:{kind:`methods`,field:`state`,offValues:[`off`,`standby`],on:`turnOn`,off:`turnOff`},methods:{turnOn:j(WE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOn`,label:F(`Turn on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`}]}),turnOff:j(WE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.turnOff`,label:F(`Turn off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power`}]}),volumeUp:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeUp`,label:F(`Volume up`,`Alza il volume`),phrase:F(`Raise the volume of {device}`,`Alza il volume di {device}`),icon:`volume-2`}]}),volumeDown:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volumeDown`,label:F(`Volume down`,`Abbassa il volume`),phrase:F(`Lower the volume of {device}`,`Abbassa il volume di {device}`),icon:`volume-2`}]}),channelUp:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelUp`,label:F(`Channel up`,`Canale successivo`),phrase:F(`Go to the next channel on {device}`,`Passa al canale successivo su {device}`),icon:`skip-forward`}]}),channelDown:j(UE,v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.channelDown`,label:F(`Channel down`,`Canale precedente`),phrase:F(`Go to the previous channel on {device}`,`Torna al canale precedente su {device}`),icon:`skip-back`}]}),play:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.play`,effect:{field:`state`,value:`playing`},label:F(`Play`,`Riproduci`),phrase:F(`Play on {device}`,`Avvia la riproduzione su {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.pause`,effect:{field:`state`,value:`paused`},label:F(`Pause media`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.stop`,label:F(`Stop media`,`Ferma la riproduzione`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),next:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.next`,label:F(`Next track`,`Brano successivo`),phrase:F(`Skip to the next track on {device}`,`Passa al brano successivo su {device}`),icon:`skip-forward`}]}),previous:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.previous`,label:F(`Previous track`,`Brano precedente`),phrase:F(`Go back to the previous track on {device}`,`Torna al brano precedente su {device}`),icon:`skip-back`}]}),setVolume:j(x({deviceId:n().int().nonnegative(),volumeLevel:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.volume`,effect:{field:`volumeLevel`,fromArg:`volumeLevel`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {volumeLevel}`,`Imposta il volume di {device} al {volumeLevel}`),icon:`volume-2`,openArgs:[{key:`volumeLevel`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMute:j(x({deviceId:n().int().nonnegative(),muted:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.mute`,effect:{field:`isMuted`,value:!0},label:F(`Mute`,`Silenzia`),phrase:F(`Mute {device}`,`Silenzia {device}`),icon:`volume-x`,args:{muted:!0}},{id:`media.unmute`,effect:{field:`isMuted`,value:!1},label:F(`Unmute`,`Riattiva l’audio`),phrase:F(`Unmute {device}`,`Riattiva l’audio di {device}`),icon:`volume-2`,args:{muted:!1}}]}),setShuffle:j(x({deviceId:n().int().nonnegative(),shuffle:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.shuffleOn`,effect:{field:`shuffle`,value:!0},label:F(`Shuffle on`,`Riproduzione casuale attiva`),phrase:F(`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:F(`Shuffle off`,`Riproduzione casuale spenta`),phrase:F(`Turn off shuffle on {device}`,`Disattiva la riproduzione casuale su {device}`),icon:`shuffle`,args:{shuffle:!1}}]}),setRepeat:j(x({deviceId:n().int().nonnegative(),repeat:zE}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.repeat`,effect:{field:`repeat`,fromArg:`repeat`},label:F(`Set repeat`,`Imposta la ripetizione`),phrase:F(`Set repeat on {device} to {repeat}`,`Imposta la ripetizione di {device} su {repeat}`),icon:`repeat`,openArgs:[{key:`repeat`,label:F(`Repeat`,`Ripetizione`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Disattivata`)},{value:`all`,label:F(`All`,`Tutti i brani`)},{value:`one`,label:F(`One track`,`Un brano`)}]}}]}]}),selectSource:j(x({deviceId:n().int().nonnegative(),source:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.source`,effect:{field:`source`,fromArg:`source`},label:F(`Select source`,`Scegli la sorgente`),phrase:F(`Switch {device} to {source}`,`Passa {device} alla sorgente {source}`),icon:`cast`,openArgs:[{key:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`}}]}]}),seek:j(x({deviceId:n().int().nonnegative(),position:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.seek`,label:F(`Seek`,`Vai al punto`),phrase:F(`Move {device} to {position}`,`Porta {device} al punto {position}`),icon:`fast-forward`,openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,step:1e3,unit:`ms`}}]}]}),playMedia:j(x({deviceId:n().int().nonnegative(),mediaId:l().min(1),mediaType:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`media.playMedia`,label:F(`Play media`,`Riproduci un contenuto`),phrase:F(`Play {mediaId} on {device}`,`Riproduci {mediaId} su {device}`),icon:`music`,openArgs:[{key:`mediaId`,label:F(`Media`,`Contenuto`),offer:{kind:`text`}},{key:`mediaType`,label:F(`Media type`,`Tipo di contenuto`),offer:{kind:`text`}}]}]})},status:{schema:HE,kind:`push`},runtimeState:HE,durability:`session`,history:{fields:{volumeLevel:{kind:`gauge`,unit:`%`,deadband:1},isMuted:{kind:`boolean`}}},vocabulary:{noun:F(`Media player`,`Lettore multimediale`),order:2060,state:[{kind:`enum`,field:`state`,label:F(`Playback`,`Riproduzione`),values:[{value:`off`,label:F(`Off`,`Spento`),phrase:F(`When {device} turns off`,`Quando {device} si spegne`)},{value:`on`,label:F(`On`,`Acceso`),phrase:F(`When {device} turns on`,`Quando {device} si accende`)},{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`playing`,label:F(`Playing`,`In riproduzione`),phrase:F(`When {device} starts playing`,`Quando {device} inizia a riprodurre`)},{value:`paused`,label:F(`Paused`,`In pausa`),phrase:F(`When {device} is paused`,`Quando {device} va in pausa`)},{value:`buffering`,label:F(`Buffering`,`In caricamento`)},{value:`standby`,label:F(`Standby`,`In standby`)}],icon:`music`},{kind:`numeric`,field:`volumeLevel`,quantity:F(`the volume`,`il volume`),label:F(`Volume`,`Volume`),unit:`%`,icon:`volume-2`},{kind:`boolean`,field:`isMuted`,label:F(`Muted`,`Silenziato`),whenTrue:F(`When {device} is muted`,`Quando {device} viene silenziato`),whenFalse:F(`When {device} is unmuted`,`Quando l’audio di {device} torna attivo`),icon:`volume-x`},{kind:`value`,field:`source`,label:F(`Source`,`Sorgente`),offer:{kind:`dynamic`,from:`status`,field:`availableSources`},icon:`cast`}]}},KE={battery:{version:1,targets:[{id:`level`,cardinality:`scalar`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.PetFeeder,E.Container,E.Climate,E.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:[E.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:[E.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:[E.Camera,E.Light,E.Siren,E.Switch,E.Sensor,E.Climate,E.Button,E.EventEmitter,E.Update,E.Generic,E.Notifier,E.Script,E.Automation,E.Lock,E.Cover,E.Valve,E.Humidifier,E.WaterHeater,E.Fan,E.MediaPlayer,E.AlarmPanel,E.Control,E.Presence,E.Weather,E.WeatherStation,E.Vacuum,E.LawnMower,E.Container,E.Image,E.PetFeeder,E.PetFountain,E.Dishwasher,E.Washer,E.Dryer,E.Gateway,E.HeatPump,E.EnergySystem,E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.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:[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.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:[E.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:[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.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:{[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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:[E.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`}]}},qE={"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 V(e,t,n){return{code:e,path:t,message:n}}function JE(...e){return{problems:e,fields:[],features:[],events:[]}}function YE(e){let t=e.item===void 0?`fields`:`items.${e.item.key}.fields`;return`features[${e.featureIndex}].${t}.${e.path}`}var XE={kind:`fixed`,result:[`number`]},ZE={kind:`fixed`,result:[`boolean`]},QE=Object.freeze({min:XE,max:XE,abs:XE,floor:XE,ceil:XE,sqrt:XE,round:XE,pow:XE,clamp:XE,avg:XE,sum:XE,age:XE,convert:XE,coalesce:{kind:`coalesce`},any:ZE,all:ZE,within:ZE,latest:{kind:`fixed`,result:[`number`,`null`]},number:{kind:`fixed`,result:[`number`,`null`]},rose:{kind:`fixed`,result:[`number`,`null`]},count:XE,dwell:{kind:`fixed`,result:[`boolean`,`null`]},latchedAt:{kind:`fixed`,result:[`number`,`null`]},schmitt:{kind:`fixed`,result:[`boolean`,`null`]}}),$E=class extends Error{};function eD(e){return e===null?`null`:typeof e==`number`?`number`:typeof e==`string`?`string`:`boolean`}function tD(e){return new Set([e])}function nD(...e){return new Set(e.flatMap(e=>[...e]))}function zye(e){return new Set([...e].filter(e=>e!==`null`))}function Bye(e,t,n){if(e===`+`){let e=[...t,...n];return e.every(e=>e===`string`)?tD(`string`):e.every(e=>e===`number`)?tD(`number`):new Set([`number`,`string`])}return tD(e===`-`||e===`*`||e===`/`||e===`%`?`number`:`boolean`)}function Vye(e){return e.minArgs===e.maxArgs?`exactly ${e.minArgs}`:e.maxArgs===1/0?`at least ${e.minArgs}`:`${e.minArgs}–${e.maxArgs}`}function Hye(e,t){let n=Go[e];if(n!==void 0&&(t.length<n.minArgs||t.length>n.maxArgs))throw new $E(`${e}: wrong number of arguments (${t.length}); expected ${Vye(n)}`);let r=QE[e];if(r===void 0)throw new $E(`no result-kind rule for builtin '${e}'`);if(r.kind===`fixed`)return new Set(r.result);let i=nD(...t.map(zye));return t.every(e=>e.has(`null`))?nD(i,tD(`null`)):i}function rD(e,t){switch(e.kind){case`literal`:return tD(eD(e.value));case`identifier`:{if(e.name===`now`)return tD(`number`);let n=t.get(e.name);if(n===void 0)throw new $E(`unbound identifier '${e.name}'`);return n}case`unary`:return tD(e.op===`!`?`boolean`:`number`);case`binary`:return Bye(e.op,rD(e.left,t),rD(e.right,t));case`logical`:return nD(rD(e.left,t),rD(e.right,t));case`conditional`:return nD(rD(e.consequent,t),rD(e.alternate,t));case`call`:return Hye(e.callee,e.args.map(e=>rD(e,t)))}}function iD(e,t){switch(e.kind){case`literal`:case`identifier`:return!1;case`unary`:return iD(e.operand,t);case`binary`:case`logical`:return iD(e.left,t)||iD(e.right,t);case`conditional`:return iD(e.test,t)||iD(e.consequent,t)||iD(e.alternate,t);case`call`:return e.callee===t||e.args.some(e=>iD(e,t))}}function aD(e,t){let n=ns(e);return n.ok&&iD(n.parsed.ast,t)}function oD(e){let t=ns(e.expr);if(!t.ok)return{ok:!1,error:t.error};try{return{ok:!0,kinds:rD(t.parsed.ast,e.bindingKinds)}}catch(e){if(e instanceof $E)return{ok:!1,error:e.message};throw e}}function Uye(e){return e.publish===`value`&&e.empty===`null`?{ok:!0,kinds:new Set([`number`,`null`])}:{ok:!0,kinds:new Set([`number`])}}function Wye(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 sD(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=cT(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 cD(e,t,n){return V(`kind-mismatch`,n,`\`${e}.${t}\` is a union — it is read as a source, never written`)}function lD(e){return e.kind===`union`?null:e.kind===`enum`?`string`:e.kind}function uD(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=cT(a,e.fieldPath),s=lD(t);return o?.kind!==`union`||s===null||!n.has(s)?n:new Set(n.has(`null`)?[s,`null`]:[s])}function dD(e,t){if(e.kind===`from`)return sD(e,t);if(e.kind===`code`)return{ok:!1,code:`reserved-variant`,message:`code fields arrive in slice 4`};if(e.kind===`aggregate`)return Wye(e);if(e.kind===`series`)return Uye(e);let n=new Map;for(let[r,i]of Object.entries(e.bindings)){if(i.kind===`literal`){n.set(r,new Set([eD(i.value)]));continue}let e=sD(i,t);if(!e.ok)return{...e,message:`binding \`${r}\`: ${e.message}`};n.set(r,e.kinds)}let r=oD({expr:e.expr,bindingKinds:n});return r.ok?{ok:!0,kinds:r.kinds}:{ok:!1,code:`expression-invalid`,message:r.error}}function fD(e,t,n,r){let i=lD(t);if(i===null)return[cD(e,t.path,r)];let a=[...n].filter(e=>e!==`null`&&e!==i),o=[];return a.length>0&&o.push(V(`kind-mismatch`,r,`\`${e}.${t.path}\` is a ${t.kind}; this source can produce ${a.join(` or `)}`)),n.has(`null`)&&!t.nullable&&o.push(V(`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 Gye(e){if(e.kind!==`expression`)return null;let t=ns(e.expr);if(!t.ok)return null;let n=t.parsed.ast;return n.kind===`literal`&&typeof n.value==`string`?n.value:null}function pD(e,t,n,r){if(t.kind!==`enum`||t.enumValues===void 0)return null;let i=Gye(n);if(i===null||t.enumValues.includes(i))return null;let a=t.enumValues.map(e=>`\`${e}\``).join(`, `);return V(`kind-mismatch`,r,`\`${e}.${t.path}\` accepts only ${a}; this source is the literal \`${i}\``)}function mD(e){if(e.kind!==`expression`)return`derived`;if(aD(e.expr,`count`))return`accumulator`;if(sl(e).length>0)return`derived`;let t=ns(e.expr);return t.ok&&t.parsed.identifiers.has(`now`)?`clock`:`constant`}function hD(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:V(`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 gD={resettable:!1};function Kye(e){return new Set([e.keyField,...e.labelField===void 0?[]:[e.labelField],...Object.keys(gD)])}function qye(e,t,n){let r=cT(e.itemSchema,t);return r===null||!r.required?!1:dT(e.itemSchema,t).every(e=>n.some(t=>t.startsWith(`${e}.`)))}function Jye({capName:e,itemArray:t,reserved:n},r,i){let a=Object.keys(r.fields);return Ng(t.itemSchema).flatMap(o=>{if(n.has(o.path)||o.path in r.fields||!qye(t,o.path,a))return[];let s=cT(t.itemSchema,o.path);return s===null||s.nullable?[]:[V(`missing-field`,`${i}.fields.${o.path}`,`\`${e}.${t.path}[].${o.path}\` is required and has no source`)]})}function Yye(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 JE(V(`item-field-reserved`,u,`\`${n}.${r.path}[].${c}\` is set by the composer itself — it takes no source`));let d=cT(r.itemSchema,c);if(d===null)return JE(V(`unknown-field`,u,`a \`${n}\` item has no field \`${c}\``));if(d.kind===`union`)return JE(cD(n,c,u));let f=dD(l,a);if(!f.ok)return JE(V(f.code,u,f.message));let p=mD(l),m=hD(d,p,e.mode,n,u);if(!m.ok)return JE(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:[...sl(l)]},g=pD(n,d,l,u);return{problems:[...fD(n,d,uD(l,d,f.kinds,a),u),...g===null?[]:[g]],fields:[h],features:[],events:[]}}function _D(e,t,n,r,i=`new`){let a=`features[${n}].items`,o=e.status?.itemArray;if(o===void 0)return JE(V(`not-item-array`,a,`\`${e.name}\` has no item array — it takes no \`items\``));if(o.path!==`items`)return JE(V(`not-item-array`,a,`\`${e.name}\`'s item array is at \`${o.path}\`, not \`${Wc}\` — not composable yet`));let s={capName:e.name,itemArray:o,reserved:Kye(o),featureIndex:n,lookupCap:r,mode:i},c=Object.entries(t.items??{}).flatMap(([e,t])=>[{problems:Jye(s,t,`${a}.${e}`),fields:[],features:[],events:[]},...Object.entries(t.fields).map(([n,r])=>Yye(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 vD=`deviceId`;function yD(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 bD(e){let t=e.features.flatMap((e,t)=>e.kind===`fields`&&Xc(e)?yD(e,t).map(e=>e.command.source):[]);return[...new Map(t.map(e=>[nl(e),e])).values()]}function Xye(e,t){return e.name===`switch`&&t===`toggle`}function xD(e){return Object.entries(e.methods).filter(([t,n])=>n.systemOnly!==!0&&e.composedMethods?.[t]===void 0&&!Xye(e,t)).map(([e])=>e)}function Zye(){return Object.fromEntries(xD(GE).map(e=>[e,{kind:`extension`,target:`remote`}]))}var SD={all:new Set,required:new Set};function CD(e,t){let n=e.methods[t]?.input;if(n===void 0)return null;let r=Mg(n);if(!(r instanceof ce))return null;let i=Object.entries(r.shape).filter(([e])=>e!==vD);return{all:new Set(i.map(([e])=>e)),required:new Set(i.flatMap(([e,t])=>t instanceof ie&&!t.safeParse(void 0).success?[e]:[]))}}function wD(e){return typeof e==`object`?zc(e)?[e.$input]:Object.values(e).flatMap(wD):[]}function TD(e){return[...e].map(e=>`\`${e}\``).join(`, `)}function Qye(e,t){let{command:n,at:r}=e,i=t(n.cap);if(i===null)return{def:null,problems:[V(`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:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}\` has no method \`${n.method}\` to forward to`)]}:a.kind===`mutation`?{def:i,problems:[]}:{def:null,problems:[V(`command-source-unknown`,`${r}.method`,`\`${n.cap}.${n.method}\` is a query — a command calls a mutation of the source`)]}}function $ye(e,t,n,r){let{at:i,command:a}=e,o=`${a.cap}.${a.method}`,s=[];if(`deviceId`in r&&s.push(V(`command-input-unknown`,`${i}.args.${vD}`,`\`${vD}\` 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(V(`command-input-unknown`,`${i}.args.${e}`,`\`${o}\` has no input field \`${e}\` (it takes ${TD(n.all)})`));let e=[...n.required].filter(e=>!(e in r));e.length>0&&s.push(V(`command-input-missing`,`${i}.args`,`\`${o}\` needs ${TD(e)}, which \`args\` does not provide`))}let c=e.itemKey===void 0?t:SD;if(c!==null)for(let t of Object.values(r).flatMap(wD))c.all.has(t)||s.push(V(`command-input-unknown`,`${i}.args`,c===SD?`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 ${TD(c.all)})`));return s}function ebe(e,t,n){let{at:r,command:i}=e,a=`${i.cap}.${i.method}`,o=e.itemKey===void 0?t:SD;if(o===null||n===null)return[];let s=[];for(let t of[...o.all].filter(e=>!n.all.has(e)))s.push(V(`command-input-unknown`,`${r}.args`,`\`${e.method}\` takes \`${t}\`, which \`${a}\` does not (it takes ${TD(n.all)}) — add \`args\` to map it`));let c=[...n.required].filter(e=>!o.all.has(e));return c.length>0&&s.push(V(`command-input-missing`,`${r}.args`,`\`${a}\` needs ${TD(c)}, which \`${e.method}\` does not take — add \`args\` to provide it`)),s}function ED(e,t,n){let r=Qye(t,n);if(r.def===null)return r.problems;let i=CD(e,t.method),a=CD(r.def,t.command.method),o=t.command.args;return o===void 0?ebe(t,i,a):$ye(t,i,a,o)}function DD(e,t,n){let r=new Set(xD(e));return Object.keys(t.commands??{}).flatMap(t=>{if(r.has(t))return[];let i=e.composedMethods?.[t]!==void 0;return[V(`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 OD(e,t){return e.features.flatMap((e,n)=>e.kind!==`fields`||!Xc(e)?[]:yD(e,n).flatMap(e=>{let n=nl(e.command.source),r=t.get(n),i=`${e.at}.source`;return r===void 0||r.kind===`unreadable`?[V(`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`?[V(`source-missing`,i,`source \`${n}\` does not exist`)]:r.caps.has(e.command.cap)?[]:[V(`source-capability-missing`,i,`source \`${n}\` (device ${r.deviceId}) has no \`${e.command.cap}\``)]}))}var kD={fieldPath:`lastFetchedAt`,expr:`now`},AD={fieldPath:`lastChangedAt`,expr:`now`};function jD(e){let{alsoFrom:t,...n}=e;return{...n,family:`numeric`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor,...t?.deviceTypes??[]],activeWhen:void 0,commandCaps:[],baseUnit:Ki(e.quantity),aggregates:$s,accept:[{cap:e.outputCap,fieldPath:e.outputField},...t===void 0?[]:[t.accept]]}}var MD=[E.Climate];function ND(e){return{...e,family:`binary`,deviceType:E.Sensor,memberDeviceType:E.Sensor,memberDeviceTypes:[E.Sensor],activeWhen:void 0,commandCaps:[],quantity:`none`,baseUnit:void 0,aggregates:ec,empty:`offline`}}var PD=[jD({id:`temperature`,summary:`Mean, median, min, max or sum of temperatures. Offline and unknown members are left out, never read as 0 °C.`,role:O.TemperatureSensor,outputCap:`temperature-sensor`,outputField:`temperature`,quantity:`temperature`,defaultAggregate:`mean`,empty:`null`,companions:[kD],alsoFrom:{deviceTypes:MD,accept:{cap:`climate-control`,fieldPath:`currentTemp`}}}),jD({id:`humidity`,summary:`Humidity in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.HumiditySensor,outputCap:`humidity-sensor`,outputField:`humidity`,quantity:`humidity`,defaultAggregate:`mean`,empty:`null`,companions:[kD],alsoFrom:{deviceTypes:MD,accept:{cap:`climate-control`,fieldPath:`currentHumidity`}}}),jD({id:`pressure`,summary:`Pressure in hectopascals. Offline and unknown members are left out, never read as 0 hPa.`,role:O.PressureSensor,outputCap:`pressure-sensor`,outputField:`pressure`,quantity:`pressure`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),jD({id:`illuminance`,summary:`Illuminance in lux. Offline and unknown members are left out, never read as 0 lx.`,role:O.AmbientLightSensor,outputCap:`ambient-light-sensor`,outputField:`illuminance`,quantity:`illuminance`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),jD({id:`power`,summary:`Power in watts, summed by default. Nobody reporting omits the key rather than writing 0 W.`,role:O.PowerSensor,outputCap:`power-meter`,outputField:`power`,quantity:`power`,defaultAggregate:`sum`,empty:`omit`,companions:[kD]}),jD({id:`energy`,summary:`Energy in kilowatt-hours, summed by default. Nobody reporting omits the key rather than writing 0 kWh.`,role:O.EnergySensor,outputCap:`power-meter`,outputField:`energy`,quantity:`energy`,defaultAggregate:`sum`,empty:`omit`,companions:[kD]}),jD({id:`battery`,summary:`Battery charge in percent. Offline and unknown members are left out, never read as 0 %.`,role:O.BatterySensor,outputCap:`battery`,outputField:`level`,quantity:`percentage`,defaultAggregate:`mean`,empty:`null`,companions:[{fieldPath:`charging`,expr:`"unknown"`},{fieldPath:`sleeping`,expr:`false`},{fieldPath:`lastUpdated`,expr:`now`}]}),jD({id:`numeric`,summary:`A numeric reading in the members’ shared quantity. Mixed quantities are refused. Nobody reporting publishes null, not 0.`,role:O.NumericSensor,outputCap:`numeric-sensor`,outputField:`value`,quantity:`device`,defaultAggregate:`mean`,empty:`null`,companions:[kD]}),ND({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:O.MotionSensor,outputCap:`motion`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`}],companions:[{fieldPath:`lastDetectedAt`,expr:`null`},{fieldPath:`autoClearAfterMs`,expr:`null`}]}),ND({id:`contact`,summary:`Any or all open contacts. Offline and unknown members are left out, never read as closed.`,role:O.ContactSensor,outputCap:`contact`,outputField:`entryOpen`,defaultAggregate:`any`,accept:[{cap:`contact`,fieldPath:`entryOpen`}],companions:[AD]}),ND({id:`leak`,summary:`Any or all leak detections. Offline and unknown members are left out, never read as dry.`,role:O.LeakSensor,outputCap:`flood`,outputField:`flooded`,defaultAggregate:`any`,accept:[{cap:`flood`,fieldPath:`flooded`}],companions:[AD]}),ND({id:`smoke`,summary:`Any or all smoke detections. Offline and unknown members are left out, never read as clear.`,role:O.SmokeSensor,outputCap:`smoke`,outputField:`detected`,defaultAggregate:`any`,accept:[{cap:`smoke`,fieldPath:`detected`}],companions:[AD]}),ND({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:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`motion`,fieldPath:`detected`},{cap:`binary`,fieldPath:`on`}],companions:[AD]}),ND({id:`binary`,summary:`Any or all generic binary sensors. Offline and unknown members are left out, never read as off.`,role:O.BinarySensor,outputCap:`binary`,outputField:`on`,defaultAggregate:`any`,accept:[{cap:`binary`,fieldPath:`on`}],companions:[AD]}),FD({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:E.Switch,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`]}),FD({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:E.Light,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`brightness`,`color`]}),FD({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:E.Fan,outputCap:`switch`,outputField:`on`,member:{cap:`switch`,fieldPath:`on`},commandCaps:[`switch`,`fan-control`]}),FD({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:E.Cover,outputCap:`group-active`,outputField:`active`,member:{cap:`cover`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`cover`]}),FD({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:E.Valve,outputCap:`group-active`,outputField:`active`,member:{cap:`valve`,fieldPath:`state`},activeWhen:[`open`,`opening`,`stopped`],commandCaps:[`valve`]}),FD({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:E.Lock,outputCap:`group-active`,outputField:`active`,member:{cap:`lock-control`,fieldPath:`state`},activeWhen:[`locked`],commandCaps:[`lock-control`]}),FD({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:E.MediaPlayer,outputCap:`group-active`,outputField:`active`,member:{cap:`media-player`,fieldPath:`state`},activeWhen:[`playing`,`buffering`],commandCaps:[`media-player`]}),FD({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:E.Climate,memberDeviceTypes:[E.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 FD(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:ec,defaultAggregate:`any`,empty:`offline`,accept:[e.member],companions:[AD]}}var tbe=new Map(PD.map(e=>[e.id,e]));function ID(e){return tbe.get(e)??null}var LD={"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:[E.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`}}},nbe={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`}}}},RD={"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}},rbe=`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 zD(e){return LD[e]??{}}function ibe(e,t,n){return BD(e.deviceTypes,t,n)}function BD(e,t,n){return e.length===0||e.some(e=>e===t)?!0:Co(t,n)&&e.includes(E.Light)}function abe(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 VD(e){return{fieldChoice:`operator`,purpose:`historised`,multiple:!1,max:1,deviceTypes:[],accept:HD(e),history:{required:!0,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function HD(e){let t=[];for(let n of Object.keys(LD))for(let[r,i]of Object.entries(zD(n)))i.kind!==`enum`&&(e===`integral`&&i.kind!==`gauge`||t.push({cap:n,fieldPath:r,valueKind:i.kind===`boolean`?`boolean`:`number`}));return t}function obe(e){if(e===`derivative`)return{...VD(`statistic`),accept:UD()};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:UD(),history:{required:!1,minRetentionMs:null},mustBindCaps:[],exclude:[]}}function UD(){return HD(`statistic`).filter(e=>e.valueKind===`number`)}var WD=[`switch`,`brightness`,`color`],sbe=[D.LightColorRgb,D.LightColorHsv,D.LightColorMired],cbe=4;function GD(e){return e===`all`?`all`:`any`}function lbe(e){return e===`all`?`all`:`at-least-one`}function ube(e){return e.length===0?[]:WD.filter(t=>e.every(e=>e.includes(t)))}function dbe(e){return e.length===0?[]:sbe.filter(t=>e.every(e=>e.includes(t)))}function fbe(e,t,n,r){return e.flatMap(e=>e.caps.includes(t)?[{deviceId:e.deviceId,cap:t,method:n,args:{...r}}]:[])}async function pbe(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 mbe={kind:`expression`,expr:`now`,bindings:{}};function KD(e,t,n){return{kind:`series`,read:{source:e.source,cap:e.cap,fieldPath:e.fieldPath},publish:t,empty:n}}function hbe(e){return{included:KD(e,`included`,`offline`),excluded:KD(e,`excluded`,`offline`),total:KD(e,`total`,`offline`)}}var gbe={second:`s`,minute:`min`,hour:`h`};function _be(e){let t=zD(e.source.cap)[e.source.fieldPath]?.unit;return t===void 0?null:`${t}/${gbe[e.per]}`}function qD(e){let t=zD(e.cap)[e.fieldPath];return t===void 0?null:t.kind}function JD(e){return qD(e)===null?[V(`member-constraint`,`helper.source`,`${e.cap}.${e.fieldPath} has no history declaration`)]:[]}function YD(e){return{target:{kind:`new`,type:E.Sensor,role:e.role},helper:e.spec,features:[{kind:`fields`,cap:e.cap,fields:{[e.field]:KD(e.member,`value`,e.empty),lastFetchedAt:mbe}},{kind:`fields`,cap:`group-status`,fields:hbe(e.member)}]}}function XD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source);r===`enum`&&n.push(V(`kind-mismatch`,`helper.source`,`a statistic reads a number or a boolean, not a state`)),e.stat===`sum`&&r!==`counter`&&n.push(V(`kind-mismatch`,`helper.stat`,`a gauge has no sum — that is the integral template`));let i=Ys(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:YD({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function ZD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source);(r===`enum`||r===`boolean`)&&n.push(V(`kind-mismatch`,`helper.source`,`a derivative reads a number that moves, not a yes/no or a state`));let i=Ys(e.window,t);return i.ok||n.push(V(`retention`,`helper.window`,i.reason)),{problems:n,draft:YD({role:O.NumericSensor,cap:`numeric-sensor`,field:`value`,empty:`null`,spec:e,member:e.source})}}function QD(e,t=Ns){let n=[...JD(e.source)],r=qD(e.source),i=e.source.cap===`power-meter`&&e.source.fieldPath===`power`;(r===`counter`||r===`boolean`||r===`enum`)&&n.push(V(`kind-mismatch`,`helper.source`,`an integral reads an instantaneous gauge, not a counter or a state`)),e.output===`energy`&&!i&&n.push(V(`kind-mismatch`,`helper.output`,`energy is the integral of power-meter.power; another reading uses the meter`)),e.output===`meter`&&i&&n.push(V(`kind-mismatch`,`helper.output`,`power integrates to power-meter.energy, which energy dashboards already read`));let a=Xs(e.reset,t);a.ok||n.push(V(`retention`,`helper.reset`,a.reason));let o=e.output===`energy`;return{problems:n,draft:YD({role:o?O.EnergySensor:O.NumericSensor,cap:o?`power-meter`:`meter`,field:o?`energy`:`value`,empty:`offline`,spec:e,member:e.source})}}var vbe=/^\d+(?:\.\d+)?$/,ybe=/^-?\d+(?:\.\d+)?$/,bbe=/^dwell\(x (>=|<=) (\d+(?:\.\d+)?), (\d+(?:\.\d+)?), (\d+(?:\.\d+)?)(?:, (\d+))?\)$/,xbe=/^clamp\((x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?), (-?\d+(?:\.\d+)?)\)$/,Sbe=/^(x|number\(x\)) \* (-?\d+(?:\.\d+)?) \+ (-?\d+(?:\.\d+)?)$/,Cbe=/^[A-Za-z_][A-Za-z0-9_]*$/;function $D(e){return lO(e,vbe)}function eO(e){return lO(e,ybe)}function tO(e){return typeof e==`string`?JSON.stringify(e):typeof e==`number`?eO(e):typeof e==`boolean`?e?`true`:`false`:`null`}function nO(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 rO(e){return Cbe.test(e)}function iO(e,t,n,r,i=1){return`dwell(x ${e===`gte`?`>=`:`<=`} ${t}, ${n}, ${r}${i>1?`, ${i}`:``})`}function aO(e,t,n,r,i){let a=`${e} * ${t} + ${n}`;return r===null||i===null?a:`clamp(${a}, ${r}, ${i})`}function oO(e){let t=bbe.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 sO(e){let t=xbe.exec(e);if(t!==null)return uO(t[1],t[2],t[3],t[4],t[5]);let n=Sbe.exec(e);return n===null?null:uO(n[1],n[2],n[3],void 0,void 0)}function cO(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 lO(e,t){if(!Number.isFinite(e))return null;let n=Object.is(e,-0)?`0`:String(e);return t.test(n)?n:null}function uO(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 dO={kind:`expression`,expr:`now`,bindings:{}};function fO(e){return{kind:`from`,source:e.source,cap:e.cap,fieldPath:e.fieldPath}}function pO(e,t){return{kind:`expression`,expr:e,bindings:t}}function wbe(e,t){return e.source.addonId===t.source.addonId&&e.source.stableId===t.source.stableId&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function mO(e,t,n=[]){return{target:{kind:`new`,type:E.Sensor,role:O.NumericSensor},helper:e,features:[{kind:`fields`,cap:`numeric-sensor`,fields:{value:t,lastFetchedAt:dO}},...n]}}function hO(e,t){return{target:{kind:`new`,type:E.Sensor,role:O.BinarySensor},helper:e,features:[{kind:`fields`,cap:`binary`,fields:{on:t,lastChangedAt:dO}}]}}function gO(e){let t=[],n=eO(e.high),r=eO(e.low);n===null&&t.push(V(`kind-mismatch`,`helper.high`,`the high edge is a finite number`)),r===null&&t.push(V(`kind-mismatch`,`helper.low`,`the low edge is a finite number`)),n!==null&&r!==null&&e.low>e.high&&t.push(V(`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=$D(e.onForMs),a=$D(e.offForMs);(i===null||a===null)&&t.push(V(`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:hO(e,pO(`coalesce(schmitt(x, ${n??`0`}, ${r??`0`}${o}), false)`,{x:fO(e.source)}))}}var Tbe=[`a`,`b`];function Ebe(e){let t=[],n=e.op!==`sum`;return n&&e.inputs.length!==2&&t.push(V(`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(V(`member-constraint`,`helper.inputs`,`a sum takes two or more readings`)),e.inputs.forEach((n,r)=>{e.inputs.slice(0,r).some(e=>wbe(e,n))&&t.push(V(`member-constraint`,`helper.inputs[${r}]`,`this reading is already an input`))}),t}var Dbe=[`included`,`excluded`,`total`];function _O(e){let t=Ebe(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(Dbe.map(e=>[e,r(e)]));return{problems:t,draft:mO(e,r(`value`),[{kind:`fields`,cap:`group-status`,fields:i}])}}let n=Object.fromEntries(e.inputs.slice(0,2).map((e,t)=>[Tbe[t]??`a`,fO(e)]));return{problems:t,draft:mO(e,pO(e.op===`difference`?`a - b`:`b == 0 ? null : a / b`,n))}}function Obe(e){let t=[],n=new Set;if(e.inputs.forEach((e,r)=>{let i=`helper.inputs[${r}].name`;rO(e.name)||t.push(V(`expression-invalid`,i,`\`${e.name}\` is not a name — use letters, digits and _, starting with a letter`)),n.has(e.name)&&t.push(V(`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,fO(e.member)])),i=fs({expr:e.expr,bindings:r});return i===null?[]:[V(`expression-invalid`,`helper.expr`,i)]}function vO(e){let t=Obe(e),n=Object.fromEntries(e.inputs.map(e=>[e.name,fO(e.member)])),r=pO(e.expr,n);return{problems:t,draft:e.output===`boolean`?hO(e,r):mO(e,r)}}function kbe(e,t){return e.addonId===t.addonId&&e.stableId===t.stableId}function Abe(e,t){return kbe(e.source,t.source)&&e.cap===t.cap&&e.fieldPath===t.fieldPath}function jbe(e,t){return e.accept.some(e=>e.cap===t.cap&&e.fieldPath===t.fieldPath)}function Mbe(e,t){return t.members.flatMap((n,r)=>{let i=`helper.members[${r}]`,a=[];if(!jbe(e,n)){let t=e.accept.map(e=>`${e.cap}.${e.fieldPath}`).join(` or `);a.push(V(`member-constraint`,i,`a ${e.id} group reads ${t}; this member is ${n.cap}.${n.fieldPath}`))}return t.members.slice(0,r).some(e=>Abe(e,n))&&a.push(V(`member-constraint`,i,`this member is already in the group`)),a})}function yO(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 Nbe(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,Fbe(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]:yO(e,t,n,`value`),...r}},{kind:`fields`,cap:`group-status`,fields:{included:yO(e,t,n,`included`),excluded:yO(e,t,n,`excluded`),total:yO(e,t,n,`total`)}}]}}function Pbe(e,t){if(e.family===`actuator`){if(t.active===void 0)return[V(`kind-mismatch`,`helper.active`,`a ${e.id} group needs an active criterion (at-least-one or all)`)];let n=GD(t.active);return t.aggregate===n?[]:[V(`kind-mismatch`,`helper.aggregate`,`active \`${t.active}\` aggregates by \`${n}\`, not \`${t.aggregate}\``)]}return t.active===void 0?[]:[V(`kind-mismatch`,`helper.active`,`a ${e.id} group has no active criterion — that belongs to an actuator group`)]}function bO(e){let t=tl.safeParse(e);return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:[V(`helper-mismatch`,`helper`,`the template did not compile: ${t.error.issues.map(e=>e.message).join(`; `)}`)]}}function Fbe(e,t={}){return{kind:`expression`,expr:e,bindings:t}}function xO(e,t=Ns){switch(e.kind){case`group`:return Lbe(e);case`statistic`:{let n=XD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`integral`:{let n=QD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`derivative`:{let n=ZD(e,t);return n.problems.length>0?{ok:!1,problems:n.problems}:bO(n.draft)}case`threshold`:return SO(gO(e));case`arithmetic`:return SO(_O(e));case`expression`:return SO(vO(e));case`grid`:case`terminal`:return bO(Ibe(e))}}function Ibe(e){return{target:{kind:`new`,type:E.Camera},helper:e,features:[]}}function SO(e){return e.problems.length>0?{ok:!1,problems:e.problems}:bO(e.draft)}function Lbe(e){let t=ID(e.templateId);if(t===null)return{ok:!1,problems:[V(`member-constraint`,`helper.templateId`,`unknown template \`${e.templateId}\``)]};let n=Pbe(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:[V(`kind-mismatch`,`helper.aggregate`,`a ${t.id} group aggregates by ${n}, not \`${e.aggregate}\``)]}}let r=Mbe(t,e);return r.length>0?{ok:!1,problems:r}:bO(Nbe(t,e))}function CO(e,t){return JSON.stringify(e.target)===JSON.stringify(t.target)&&JSON.stringify(e.features)===JSON.stringify(t.features)}function Rbe(e){return e.kind===`group`?ID(e.templateId)?.memberDeviceType??null:null}function zbe(e,t){if(e.kind!==`group`)return[];let n=ID(e.templateId);if(n===null||n.family!==`numeric`)return[];let r=e.members.flatMap((e,n)=>{let r=t.get(nl(e.source))?.quantity;return r===void 0?[]:[{index:n,quantity:r}]});if(n.quantity!==`device`)return r.flatMap(e=>e.quantity===n.quantity?[]:[V(`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?[]:[V(`mixed-quantity`,`helper.members`,`a numeric group requires one quantity; members report ${i.join(` and `)}`)]}function Bbe(e,t){if(e.kind!==`group`)return[];let n=ID(e.templateId);return n===null?[]:e.members.flatMap((e,r)=>{let i=t.get(nl(e.source)),a=i?.deviceType;return a===void 0||BD(n.memberDeviceTypes,a,i?.role)?[]:[V(`member-constraint`,`helper.members[${r}]`,`a ${n.id} group takes ${n.memberDeviceTypes.join(` or `)} devices; this member is a ${a}`)]})}function wO(e,t){let n=e.helper;if(n===void 0)return[];let r=xO(n);return r.ok?CO(e,r.composition)?n.kind===`arithmetic`?Vbe(n,t):n.kind===`group`?[...zbe(n,t),...Bbe(n,t)]:[]:[V(`helper-mismatch`,`helper`,`the stored features are not this template — the helper spec is the only writer`)]:r.problems}function Vbe(e,t){let n=e.inputs.flatMap(e=>{let n=t.get(nl(e.source))?.quantity;return n===void 0?[]:[n]}),r=[...new Set(n)];return r.length<=1?[]:[V(`mixed-quantity`,`helper.inputs`,`a ${e.op} needs readings of one quantity; these inputs report ${r.join(` and `)}`)]}var TO=class extends Error{};function Hbe(e){return new Set(e.composition.features.flatMap(e=>!Xc(e)||e.kind!==`fields`?[]:ll(e).map(({fieldPath:t})=>`${e.cap}.${t}`)))}function Ube(e,t,n){if(nl(n.source)!==nl(e.target))return!0;let r=`${n.cap}.${n.fieldPath}`;return t.has(r)&&e.replaced?.has(r)!==!0}function Wbe(e){let t=Hbe(e);return e.composition.features.flatMap(n=>!Xc(n)||n.kind!==`fields`?[]:ll(n).map(({fieldPath:r,source:i})=>[il({source:e.target,cap:n.cap,fieldPath:r}),sl(i).filter(n=>Ube(e,t,n)).map(il)]))}function Gbe(e,t){let n=nl(e.target),r=new Map;for(let i of t){if(i.blockId===e.blockId)continue;let t=nl(i.target);if(t===n)throw new TO(`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 TO(`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 EO(e,t){let n=Gbe(e,t).flatMap(Wbe);return new Map(n)}function Kbe(e,t){let n=EO(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 qbe(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 Jbe(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 DO(e,t){let n=EO(e,t),r=`${nl(e.target)}#`;return qbe(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:Jbe(t,i,n),component:i}]})}var Ybe=3,Xbe=120,Zbe=10,OO=S([`no-power-source`,`switch-missing`,`switch-offline`,`switch-unknown`,`restart-in-progress`,`switch-call-failed`,`switch-options-unreadable`,`not-settable`,`switch-is-actuator`,`link-lost`,`link-unknown`]),kO=i(`accepted`,[x({accepted:p(!0)}),x({accepted:p(!1),reason:OO,message:l()})]),AO=x({linked:y(),switchDeviceId:n().nullable(),switchName:l().nullable(),switchOn:y().nullable(),switchOnline:y().nullable(),switchSettable:y().nullable().optional(),restartInProgress:y(),offSeconds:n().int()}),jO=x({switchOn:y().nullable(),offSeconds:n().int(),lastFetchedAt:n()}),MO=[E.Gateway,E.Camera,E.Sensor,E.MediaPlayer,E.Vacuum,E.Generic,E.Washer,E.Dryer,E.Dishwasher,E.PetFountain,E.Fan,E.Humidifier,E.Climate,E.WaterHeater],Qbe={version:1,targets:[{id:`switch`,cardinality:`scalar`,vocabulary:{cap:`power-source`,stateField:`switchOn`},deviceTypes:MO,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`}}]},NO=x({deviceId:n().int().nonnegative()}),PO={method:`getStatus`,field:`switchSettable`},FO={name:`power-source`,scope:`device`,mode:`singleton`,deviceTypes:MO,methods:{getStatus:Ir(NO,AO,{auth:`protected`}),powerOn:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.on`,label:F(`Power on`,`Dai corrente`),phrase:F(`Power on {device}`,`Dai corrente a {device}`),icon:`power`,offeredWhen:PO}]}),powerOff:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.off`,label:F(`Power off`,`Togli corrente`),phrase:F(`Cut the power of {device}`,`Togli la corrente a {device}`),icon:`power-off`,offeredWhen:PO}]}),forceRestart:Ir(NO,kO,{kind:`mutation`,auth:`protected`,actions:[{id:`powerSource.forceRestart`,label:F(`Force restart`,`Riavvio forzato`),phrase:F(`Force restart {device} by cutting its power`,`Riavvia {device} togliendo la corrente`),icon:`refresh-cw`}]})},runtimeState:jO,customize:Qbe,durability:`session`,history:`none`,vocabulary:{noun:F(`Power source`,`Alimentazione`),order:1050,state:[{kind:`boolean`,field:`switchOn`,label:F(`Power switch on`,`Presa accesa`),whenTrue:F(`When the power of {device} comes on`,`Quando arriva la corrente a {device}`),whenFalse:F(`When the power of {device} is cut`,`Quando manca la corrente a {device}`),icon:`power`}]}};function IO(e){return typeof e!=`number`||!Number.isFinite(e)?10:Math.min(120,Math.max(3,Math.round(e)))}function $be(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 exe(e,t){if(e===null)return null;let n;if(e.target.kind===`existing`)n=e.target.device;else if(t!==void 0)n=ol(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=sl(i).find(e=>e.cap===`switch`);return a===void 0?null:{device:n,switch:a.source,offSeconds:IO($be(e)),...r.contributedBy===void 0?{}:{contributedBy:r.contributedBy}}}var LO=`switch`;function txe(e){let t=new Set;return e.target.kind===`existing`&&t.add(nl(e.target.device)),e.features.forEach((e,n)=>{if(!(e.kind!==`fields`||e.cap!==LO)&&Xc(e)){for(let n of ul(e))for(let e of sl(n))t.add(nl(e.source));for(let r of yD(e,n))t.add(nl(r.command.source))}}),t}function RO(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=txe(e);return sl(r).filter(e=>e.cap===LO&&i.has(nl(e.source))).map(e=>({path:`features[${t}].fields.switchOn`,switch:e.source}))}function zO(e){let t=new Map(e.map(e=>[e.name,e]));return e=>t.get(e)??null}var BO=new Set([`device-status`,`feature-probe`]),nxe={addonId:Tc,stableId:`${we}(unsaved)`},rxe=`(unsaved)`;function ixe(e,t,n){let r=n(e.cap);if(r===null)return V(`unknown-capability`,`${t}.cap`,`no capability is named \`${e.cap}\``);if(BO.has(r.name))return V(`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?V(`not-composable`,`${t}.cap`,`\`${r.name}\` has no per-device state to compose`):{def:r,state:i,fields:lT(i)}}function axe(e){let t=e.helper;if(t===void 0||t.kind!==`group`)return new Set;let n=ID(t.templateId);return n===null||n.family!==`actuator`?new Set:new Set(n.commandCaps)}function oxe(e,t){return e.name===GE.name&&Object.values(t.commands??{}).some(e=>e.kind===`extension`)}function sxe({def:e,state:t,fields:n},r,i,a,o){let s=[];e.deviceTypes!==void 0&&!e.deviceTypes.includes(a)&&s.push(V(`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=xD(e).filter(e=>!c.has(e)).map(e=>`\`${e}\``);l.length>0&&!o.has(e.name)&&s.push(V(`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=oxe(e,r);for(let a of d?[]:uT(t))a!==u&&(n.has(a)?a in r.fields||s.push(V(`missing-field`,`${i}.fields.${a}`,`\`${e.name}.${a}\` is required and has no source`)):s.push(V(`not-composable`,`${i}.fields`,`\`${e.name}.${a}\` is not a scalar — nested fields arrive in a later slice`)));return s}function cxe({fields:e,state:t},n,r){return n.includes(`.`)?r===`replace`?cT(t,n)??void 0:`nested`:e.get(n)}function lxe(e,t,n,r){let{def:i}=e,{featureIndex:a,path:o,source:s}=t,c=`features[${a}].fields.${o}`,l=cxe(e,o,n);if(l===`nested`)return JE(V(`nested-field`,c,`\`${o}\` is nested — a nested field is planned only on a declared replace (D1034)`));if(l===void 0)return JE(V(`unknown-field`,c,`\`${i.name}\` has no field \`${o}\``));if(l.kind===`union`)return JE(cD(i.name,o,c));let u=dD(s,r);if(!u.ok)return JE(V(u.code,c,u.message));let d=mD(s),f=hD(l,d,n,i.name,c);if(!f.ok)return JE(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:[...sl(s)]},h=pD(i.name,l,s,c);return{problems:[...fD(i.name,l,uD(s,l,u.kinds,r),c),...h===null?[]:[h]],fields:[m],features:[],events:[]}}function uxe(e,t,n,r,i){let a=`features[${n}]`,o=yD(t,n),s=Object.entries(t.commands??{}).filter(([,e])=>e.kind===`code`).map(([e])=>V(`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!==GE.name?[...s,...c.map(([t])=>V(`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,V(`reserved-variant`,`${a}.commands`,"commands (`forward`) are served only by a capability a NEW device builds — not on an existing device")]:[...s,...DD(e,t,a),...o.flatMap(t=>ED(e,t,i))]}function VO(e,t,n,r,i){let a=`features[${t}]`,o=ixe(e,a,r);if(`code`in o)return JE(o);let s=n.mode===`replace`?[]:[...sxe(o,e,a,n.deviceType,i)];s.push(...uxe(o.def,e,t,n.mode,r));let c=Object.entries(e.fields).map(([e,i])=>lxe(o,{featureIndex:t,path:e,source:i},n.mode,r)),l=e.items===void 0?[]:[_D(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=hT(o.def,f,d);return{problems:[...s,...u.flatMap(e=>e.problems),...p.problems],fields:d,features:[f],events:p.events}}function HO(e,t){let n=e.nativeCaps.get(t);return n!==void 0&&n!==`composer`}function dxe(e){return`code`in e}function fxe(e,t){if(e.target.kind===`new`)return{kind:`new`,type:e.target.type};let n=nl(e.target.device);return t===void 0?V(`target-unreadable`,`target`,`target device \`${n}\` was not read — the save is refused rather than stored unchecked`):t.kind===`absent`?V(`target-missing`,`target`,`target device \`${n}\` does not exist`):t.kind===`unreadable`?V(`target-unreadable`,`target`,`could not read target device \`${n}\` (${t.error}) — the save is refused rather than stored unchecked`):{kind:`existing`,found:t}}var pxe=new Set([`not-composable`,`unknown-capability`,`reserved-variant`]);function mxe(e,t){let n=t.problems.filter(e=>pxe.has(e.code));return n.length>0?{problems:n,fields:[],features:[],events:[]}:JE(e)}var hxe=KE;function gxe(e){let t=hxe[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 _xe(e,t,n){let r=t.cap;return e.kind===`new`?{mode:`new`,deviceType:e.type}:HO(e.found,r)?gxe(t)?{mode:`replace`,deviceType:e.found.type}:V(`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 UO(e,t,n){let r=fxe(e,n);if(`code`in r)return JE(r);let i=axe(e),a=e.features.map((e,n)=>{let a=`features[${n}]`;if(e.kind===`passthrough`)return JE(V(`reserved-variant`,a,`whole-capability passthrough of \`${e.cap}\` arrives in slice 3`));let o=_xe(r,e,a);if(dxe(o))return!Xc(e)||r.kind!==`existing`?{problems:[],fields:[],features:[],events:[]}:mxe(o,VO(e,n,{mode:`add`,deviceType:r.found.type},t,i));let s=VO(e,n,o,t,i);return Xc(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 vxe(e){let t=e.features.flatMap(e=>Xc(e)&&e.kind===`fields`?ul(e).flatMap(sl).map(e=>e.source):[]);return[...new Map([...t,...bD(e)].map(e=>[nl(e),e])).values()]}function yxe(e,t){return e.features.flatMap(e=>Xc(e)&&e.kind===`fields`?ul(e).flatMap(e=>{if(e.kind!==`from`)return[];let n=t(e.cap),r=n?.runtimeState??n?.status?.schema;return r===void 0?[]:cT(r,e.fieldPath)?.kind===`union`?[e]:[]}):[])}function bxe(e,t,n){return{ref:e.target.kind===`existing`?e.target.device:t.self??nxe,native:e.target.kind===`existing`&&t.target?.kind===`found`?t.target:null,replaced:WO(n)}}function WO(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(CT))}function xxe(e,t,n,r){let i=`${e.cap}.${e.fieldPath}`;return n.some(e=>CT(e)===i&&!r.replaced.has(i))?[]:r.native===null?[V(`source-field-unknown`,t,`this device has no composed field \`${e.cap}.${e.fieldPath}\``)]:HO(r.native,e.cap)?[]:[V(`source-capability-missing`,t,`the target device (device ${r.native.deviceId}) has no native \`${e.cap}\``)]}function Sxe(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?[]:[V(`source-kind-mismatch`,r,`\`${t.cap}.${t.fieldPath}\` of device ${n.deviceId} reads a ${i} now; \`${e.cap}.${e.path}\` takes a ${a}`)]}function Cxe(e,t,n){let r=nl(n.ref);return e.flatMap(i=>i.reads.flatMap(a=>{let o=YE(i),s=nl(a.source);if(s===r)return xxe(a,o,e,n);let c=t.sources.get(s);return c===void 0||c.kind===`unreadable`?[V(`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`?[V(`source-missing`,o,`source \`${s}\` does not exist`)]:c.caps.has(a.cap)?Sxe(i,a,c,o):[V(`source-capability-missing`,o,`source \`${s}\` (device ${c.deviceId}) has no \`${a.cap}\``)]}))}function wxe(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 Txe(e,t,n){for(let r of e){let e=wxe(r,t);if(e===null)continue;let i=`${e.cap}.${e.fieldPath}`,a=n.find(e=>CT(e)===i);if(a!==void 0)return YE(a)}return`features`}function Exe(e,t){for(let[n,r]of t)if(e.some(e=>e.startsWith(`${n}#`)))return{key:n,error:r};return null}function Dxe(e,t,n,r){let i={blockId:t.blockId??`(unsaved)`,target:r.ref,composition:e,replaced:r.replaced},a=nl(i.target),o=t.unreadTargets??new Map;try{return DO(i,t.peers).map(e=>{let t=Txe(e.path,a,n),r=Exe([...e.component],o);return r===null?V(`cycle`,t,`a field reads itself: ${e.path.join(` → `)}`):V(`cycle`,t,`possible cycle through \`${r.key}\` — its state could not be read (${r.error}): ${e.path.join(` → `)}`)})}catch(e){if(e instanceof TO)return[V(`duplicate-target`,`features`,e.message)];throw e}}function GO(e,t){let n=UO(e,t.lookupCap,t.target??void 0),r=bxe(e,t,n),i=n.problems.filter(e=>e.code===`native-capability-replace`).map(e=>e.path),a=Dxe(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,...Cxe(n.fields,t,r),...OD(e,t.sources),...a,...wO(e,o),...RO(e).map(e=>V(`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 KO=x({path:l(),kind:vT,nullable:y(),required:y(),enumValues:C(l()).optional()}),qO=x({cap:l(),fields:C(KO),itemArray:x({path:l(),keyField:l()}).optional()}),JO=x({caps:C(qO)});function YO(e,t){if(BO.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=lT(n),a=e.status?.itemArray?.path??null;return uT(n).some(e=>e!==a&&!i.has(e))&&r.push(`not-composable`),hT(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 Oxe(e,t){return e.filter(e=>YO(e,t).length===0).map(e=>{let t=e.runtimeState,n=t===void 0?[]:[...lT(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 XO=x({addonId:l().min(1),stableId:l().min(1),cap:l().min(1),fieldPath:l().min(1)}),kxe=x({kind:p(`identity`)}),Axe=x({kind:p(`invert`)}),ZO=x({kind:p(`threshold`),comparison:S([`gte`,`lte`]),threshold:n(),startDwellMs:n().nonnegative(),stopDwellMs:n().nonnegative(),minSamples:n().int().min(1).optional()}),QO=i(`kind`,[kxe,Axe,ZO,x({kind:p(`linear`),scale:n(),offset:n(),clampMin:n().optional(),clampMax:n().optional()}),x({kind:p(`enum-map`),mapping:m(l(),l().nullable())}),x({kind:p(`number`)})]),jxe=x({kind:p(`scalar`),cap:l().min(1),targetId:l().min(1),source:XO,transform:QO}),Mxe=x({kind:p(`keyedArray`),cap:l().min(1),targetId:l().min(1),key:l().min(1),label:l().min(1),fieldPath:l().min(1),source:XO,transform:QO}),Nxe=x({kind:p(`pulse`),cap:l().min(1),targetId:l().min(1),enabled:y(),debounceMs:n().nonnegative(),edges:C(S([`rising`,`button`,`native-event`])).min(1).optional(),sources:C(XO).min(1)}),Pxe=XO.extend({mode:S([`in-addition`,`confirm`,`replace`]).optional()}),Fxe=i(`kind`,[jxe,Mxe,Nxe,x({kind:p(`span`),cap:l().min(1),targetId:l().min(1),timeoutMs:n().nonnegative(),cooldownMs:n().nonnegative().optional(),sources:C(Pxe)})]),Ixe=x({targetId:l().min(1),configured:y(),source:S([`native`,`assigned`]),state:S([`active`,`stale`,`released`,`unavailable`]),reason:l().nullable()}),$O=S([`raw`,`5m`]),ek=S([`high`,`medium`,`low`]),tk=S([`no-history`,`span-too-short`,`truncated`,`no-idle-floor`,`no-runs`,`no-separation`]),nk=x({intervals:n().int().nonnegative(),extra:n().int().nonnegative(),missed:n().int().nonnegative()}),rk=x({tier:$O,spanMs:n().nonnegative(),from:n(),to:n(),points:n().int().nonnegative(),runsFound:n().int().nonnegative(),pausesFound:n().int().nonnegative(),longestPauseMs:n().nonnegative(),pulsesFound:n().int().nonnegative(),longestPulseMs:n().nonnegative(),idleFloorW:n(),noiseCeilingW:n(),plateauW:n(),replay:nk}),ik=x({spanMs:n().nonnegative(),points:n().int().nonnegative(),runsFound:n().int().nonnegative()}),ak=i(`state`,[x({state:p(`proposal`),transform:ZO,evidence:rk,confidence:ek,notes:C(l())}),x({state:p(`insufficient`),reason:tk,evidence:ik,fallback:ZO})]),ok=x({apply:y()}),sk=x({apply:y(),rows:n().int(),raw:n().int(),markers:n().int(),migrated:n().int(),failed:n().int(),remainingRaw:n().int(),unresolvedMarkers:n().int(),redundantCopies:n().int().optional(),verified:y()}),ck=`core-block-`,lk=`core-blocks`;function Lxe(e){return`${ck}${e}`}function Rxe(e){if(!e.startsWith(`core-block-`))return null;let t=e.slice(11);return t.length>0?t:null}var uk=h([p(`hub`),l().min(1)]),dk=S([`stopped`,`starting`,`running`,`degraded`,`incomplete`,`failed`]),fk=`main.ts`,pk=m(l().min(1).max(260),l().max(2e5)),mk=ve(),hk=x({name:l().min(1).max(120),code:l().max(2e5).optional(),files:pk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:uk,integrationId:l().optional(),settingsSchema:mk.optional(),tags:Eh.optional()}),gk=hk.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 _k(e){return e!==void 0&&e.length>0?e:fk}function zxe(e){let t=_k(e.entry);return e.files===void 0?{files:{[t]:e.code},entry:t}:{files:{...e.files},entry:t}}function Bxe(e){if(e.files!==void 0){let t=_k(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 vk=i(`kind`,[x({kind:p(`code`)}),x({kind:p(`recipe`),recipe:vv}),x({kind:p(`composition`),composition:tl})]),yk=x({name:l().min(1).max(120).optional(),enabled:y(),composition:tl}),bk=x({name:l().min(1).max(120),code:l().max(2e5),files:pk.optional(),entry:l().min(1).max(260).optional(),enabled:y(),placement:uk,integrationId:l().optional(),settingsSchema:mk.optional(),tags:Eh.optional(),id:l(),createdAt:n(),updatedAt:n(),createdBy:l(),status:dk,lastError:l().optional(),lastChangedAt:n(),source:vk.optional()});function Vxe(e){return e.source?.kind??`code`}function Hxe(e){return e.source?.kind===`composition`?e.source.composition:null}var xk=i(`kind`,[x({kind:p(`answered`),state:AT.nullable()}),x({kind:p(`unreachable`),error:l()})]),Sk=x({block:bk,state:xk}),Ck=x({state:p(`not-loaded`),reason:l()}),wk=i(`state`,[x({state:p(`loaded`),views:C(Sk)}),Ck]),Tk=i(`state`,[x({state:p(`loaded`),view:Sk.nullable()}),Ck]),Ek=i(`state`,[x({state:p(`loaded`),view:Sk.nullable()}),Ck]),Dk=x({ok:y(),error:l().optional(),line:n().optional(),column:n().optional()}),Ok=x({code:l().optional(),files:pk.optional(),entry:l().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`]})}),kk={name:`core-blocks`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),x({blocks:C(bk)}),{auth:`admin`}),get:A(x({blockId:l()}),x({block:bk.nullable()}),{auth:`admin`}),create:A(x({block:gk}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),update:A(x({blockId:l(),block:hk.partial()}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),delete:A(x({blockId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({blockId:l(),enabled:y()}),x({block:bk}),{kind:`mutation`,auth:`admin`}),restart:A(x({blockId:l()}),x({block:bk}),{kind:`mutation`,auth:`admin`}),compile:A(Ok,Dk,{kind:`mutation`,auth:`admin`}),getBlockSettings:A(x({blockId:l()}),Ax.nullable(),{auth:`admin`}),updateBlockSettings:A(x({blockId:l(),patch:jx}),Nx,{kind:`mutation`,auth:`admin`}),migrateRawSecrets:A(ok,sk,{kind:`mutation`,auth:`admin`}),getTypeDefs:A(x({}),x({libs:C(x({filePath:l(),content:l()}))}),{auth:`admin`}),createComposition:A(x({block:yk}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateComposition:A(x({blockId:l(),expectedUpdatedAt:n(),block:yk.partial()}),x({block:bk}),{kind:`mutation`,auth:`admin`,caller:`required`}),getComposition:A(x({blockId:l()}),Tk,{auth:`admin`}),listCompositions:A(x({}),wk,{auth:`admin`}),getCustomization:A(x({addonId:l().min(1),stableId:l().min(1)}),Ek,{auth:`admin`}),listComposableCaps:A(x({deviceType:S(E)}),JO,{auth:`admin`}),validateComposition:A(x({composition:tl,blockId:l().optional()}),ET,{kind:`mutation`,auth:`admin`,access:`view`}),proposeRunningThreshold:A(x({deviceId:n().int(),cap:l().min(1),fieldPath:l().min(1),deviceType:S(E).optional()}),ak,{auth:`admin`,access:`view`}),reportAutomationRun:A(x({blockId:l().min(1),trace:ny.optional(),runStartedAt:n().optional(),keepTraces:n().int().min(1).max(100).optional()}),v(),{kind:`mutation`,auth:`admin`}),getAutomationRunState:A(x({blockId:l().min(1)}),ry,{auth:`admin`}),getTraces:A(x({blockId:l().min(1)}),x({traces:C(ny),lastError:l().nullable()}),{auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Ak=S([`open`,`opening`,`closing`,`closed`,`stopped`]),jk=x({state:Ak,position:n().min(0).max(100).nullable().meta(N(`percentage`)),tiltPosition:n().min(0).max(100).nullable().meta(N(`percentage`)),lastChangedAt:n()}),Mk={name:`cover`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover],methods:{open:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.open`,label:F(`Open`,`Apri`),phrase:F(`Open {device}`,`Apri {device}`),icon:`arrow-up-to-line`,effect:{field:`state`,value:`open`}}]}),close:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.close`,label:F(`Close`,`Chiudi`),phrase:F(`Close {device}`,`Chiudi {device}`),icon:`arrow-down-to-line`,effect:{field:`state`,value:`closed`}}]}),stop:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setPosition:j(x({deviceId:n().int().nonnegative(),position:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.position`,label:F(`Set position`,`Imposta la posizione`),phrase:F(`Move {device} to {position} open`,`Porta {device} al {position} di apertura`),icon:`blinds`,effect:{field:`position`,fromArg:`position`},openArgs:[{key:`position`,label:F(`Position`,`Posizione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setTiltPosition:j(x({deviceId:n().int().nonnegative(),tiltPosition:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`cover.tilt`,label:F(`Set tilt`,`Imposta l’inclinazione`),phrase:F(`Tilt {device} to {tiltPosition}`,`Inclina {device} al {tiltPosition}`),icon:`blinds`,effect:{field:`tiltPosition`,fromArg:`tiltPosition`},openArgs:[{key:`tiltPosition`,label:F(`Tilt`,`Inclinazione`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]})},status:{schema:jk,kind:`push`},runtimeState:jk,durability:`restored`,history:{fields:{position:{kind:`gauge`,unit:`%`,minIntervalMs:0}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Cover`,`Copertura`),order:1030,state:[{kind:`enum`,field:`state`,label:F(`State`,`Stato`),values:[{value:`open`,label:F(`Open`,`Aperto`),phrase:F(`When {device} is fully open`,`Quando {device} è tutto aperto`)},{value:`opening`,label:F(`Opening`,`In apertura`),phrase:F(`When {device} starts opening`,`Quando {device} inizia ad aprirsi`)},{value:`closing`,label:F(`Closing`,`In chiusura`),phrase:F(`When {device} starts closing`,`Quando {device} inizia a chiudersi`)},{value:`closed`,label:F(`Closed`,`Chiuso`),phrase:F(`When {device} is fully closed`,`Quando {device} è tutto chiuso`)},{value:`stopped`,label:F(`Stopped`,`Fermo`),phrase:F(`When {device} stops part-way`,`Quando {device} si ferma a metà`)}],icon:`blinds`},{kind:`numeric`,field:`position`,quantity:F(`the opening`,`l’apertura`),label:F(`Position`,`Posizione`),unit:`%`,icon:`blinds`}],overrides:{byRole:{[O.CoverGarage]:{actions:{"cover.open":{phrase:F(`Open the garage door {device}`,`Apri il garage {device}`),icon:`warehouse`},"cover.close":{phrase:F(`Close the garage door {device}`,`Chiudi il garage {device}`),icon:`warehouse`}}},[O.CoverGate]:{actions:{"cover.open":{phrase:F(`Open the gate {device}`,`Apri il cancello {device}`),icon:`fence`},"cover.close":{phrase:F(`Close the gate {device}`,`Chiudi il cancello {device}`),icon:`fence`}}},[O.CoverDoor]:{actions:{"cover.open":{phrase:F(`Open the door {device}`,`Apri la porta {device}`),icon:`door-open`},"cover.close":{phrase:F(`Close the door {device}`,`Chiudi la porta {device}`),icon:`door-closed`}}},[O.CoverWindow]:{actions:{"cover.open":{phrase:F(`Open the window {device}`,`Apri la finestra {device}`),icon:`app-window`},"cover.close":{phrase:F(`Close the window {device}`,`Chiudi la finestra {device}`),icon:`app-window`}}},[O.CoverShutter]:{actions:{"cover.open":{phrase:F(`Raise the shutter {device}`,`Alza la tapparella {device}`)},"cover.close":{phrase:F(`Lower the shutter {device}`,`Abbassa la tapparella {device}`)}}},[O.CoverAwning]:{actions:{"cover.open":{phrase:F(`Extend the awning {device}`,`Apri la tenda da sole {device}`)},"cover.close":{phrase:F(`Retract the awning {device}`,`Chiudi la tenda da sole {device}`)}}}}}}},Nk=x({stepId:l(),entry:Vh}),Pk=x({path:l().min(1),bytes:n().int().nonnegative(),sha256:l().regex(/^[0-9a-f]{64}$/)}),Fk=x({addonId:l(),stepId:l().min(1),entries:C(Vh).min(1).max(4),bundle:x({ticket:ri,bytes:n().int().positive(),sha256:l().regex(/^[0-9a-f]{64}$/)}),files:C(Pk).min(1).max(64),distribute:y()}),Ik=i(`kind`,[x({kind:p(`imported`),modelIds:C(l()).readonly(),distributed:C(x({modelId:l(),nodeId:l(),format:S(va),ok:y(),error:l().optional()})).readonly()}),x({kind:p(`refused`),reason:S([`transfer-failed`,`checksum-mismatch`,`bundle-mismatch`,`invalid-entry`,`id-taken`]),detail:l()})]),Lk={name:`custom-model-registry`,scope:`system`,mode:`collection`,internal:!0,methods:{listModels:A(v(),C(Nk).readonly(),{auth:`admin`}),importModelBundle:A(Fk,Ik,{kind:`mutation`,auth:`admin`,timeoutMs:30*6e4})},vocabulary:{notOperatorFacing:M.ML}},Rk=x({engineId:l(),kind:S([`relational`,`vector`]),displayName:l()}),zk={name:`data-store-provider`,scope:`system`,mode:`collection`,internal:!0,methods:{getEngineInfo:A(v(),Rk,{auth:`admin`}),get:A(x({namespace:l().optional(),collection:l(),key:l()}),w(),{auth:`admin`}),set:A(x({namespace:l().optional(),collection:l(),key:l(),value:w()}),v(),{kind:`mutation`,auth:`admin`}),query:A(x({namespace:l().optional(),collection:l(),filter:Ld.optional(),columns:C(l()).readonly().optional()}),C(Vd).readonly(),{auth:`admin`}),insert:A(x({namespace:l().optional(),collection:l(),record:x({id:l().optional(),data:m(l(),w())})}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsert:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),record:Hd}),x({id:h([l(),n()])}),{kind:`mutation`,auth:`admin`}),upsertMany:A(x({namespace:l().optional(),collection:l(),conflict:C(l()).readonly(),records:C(Hd).readonly()}),x({upserted:n().int()}),{kind:`mutation`,auth:`admin`}),insertMany:A(x({namespace:l().optional(),collection:l(),records:C(Hd).readonly()}),x({inserted:n().int()}),{kind:`mutation`,auth:`admin`}),transact:A(x({namespace:l().optional(),guard:Gd.optional(),ops:C(Wd).readonly()}),x({applied:y(),current:w().optional()}),{kind:`mutation`,auth:`admin`}),update:A(x({namespace:l().optional(),collection:l(),id:l(),data:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),delete:A(x({namespace:l().optional(),collection:l(),key:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteWhere:A(x({namespace:l().optional(),collection:l(),filter:Rd}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),updateWhere:A(x({namespace:l().optional(),collection:l(),filter:Rd,data:m(l(),w())}),x({updated:n().int()}),{kind:`mutation`,auth:`admin`}),count:A(x({namespace:l().optional(),collection:l(),filter:Ld.optional()}),n(),{auth:`admin`}),aggregate:A(x({namespace:l().optional(),collection:l(),fields:C(zd).readonly(),filter:Ld.optional()}),Bd,{auth:`admin`}),histogram:A(x({namespace:l().optional(),collection:l(),field:l(),bucketSize:n().int().positive(),origin:n().int(),filter:Ld.optional()}),C(x({bucket:n().int(),count:n().int()})).readonly(),{auth:`admin`}),isEmpty:A(x({namespace:l().optional(),collection:l()}),y(),{auth:`admin`}),declareCollection:A(Jd,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Bk=S([`auto`,`day`,`night`,`schedule`]),Vk=x({min:n(),max:n(),step:n()}),Hk=x({mode:Bk,sensitivity:n().optional().meta(N(`none`)),switchDelaySec:n().optional().meta(N(`duration`)),lastFetchedAt:n()}),Uk=x({modes:C(Bk),supportsSensitivity:y(),sensitivity:Vk.optional(),supportsSwitchDelay:y(),switchDelaySec:Vk.optional()}),Wk=x({mode:Bk.optional(),sensitivity:n().optional(),switchDelaySec:n().optional()}),Gk={name:`day-night`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`day-night`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),Uk),setSettings:A(x({deviceId:n(),settings:Wk}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`dayNight.auto`,label:F(`Day/night auto`,`Giorno/notte automatico`),phrase:F(`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:F(`Day mode`,`Modalità giorno`),phrase:F(`Force {device} into day mode`,`Forza {device} in modalità giorno`),icon:`sun`,args:{settings:{mode:`day`}}},{id:`dayNight.night`,label:F(`Night mode`,`Modalità notte`),phrase:F(`Force {device} into night mode`,`Forza {device} in modalità notte`),icon:`moon`,args:{settings:{mode:`night`}}}]})},status:{schema:Hk,kind:`poll`},runtimeState:Hk,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Day/night`,`Giorno/notte`),order:3070,state:[{kind:`enum`,field:`mode`,label:F(`Day/night mode`,`Modalità giorno/notte`),values:[{value:`auto`,label:F(`Automatic`,`Automatica`)},{value:`day`,label:F(`Day`,`Giorno`),phrase:F(`When {device} switches to day mode`,`Quando {device} passa in modalità giorno`)},{value:`night`,label:F(`Night`,`Notte`),phrase:F(`When {device} switches to night mode`,`Quando {device} passa in modalità notte`)},{value:`schedule`,label:F(`Scheduled`,`Programmata`)}],icon:`sun-moon`}]}},Uxe=[{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)`}],Wxe={hwaccel:`auto`,probedBestHwaccel:``},Kk={name:`decoder`,scope:`system`,mode:`singleton`,preferredProvider:`decoder-nodeav`,methods:{getInfo:A(v(),x({id:l(),name:l(),hwaccel:l().optional(),probedBestHwaccel:l().optional()})),reprobeHwaccel:A(v(),x({backend:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},qk={name:`detection-pipeline`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{},vocabulary:{noun:F(`Detection pipeline`,`Pipeline di rilevamento`),order:3080}},Jk=S([`device`,`integration`]),Yk=x({url:l(),label:l(),target:Jk,host:l()}),Xk={name:`device-admin-link`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{getAdminLink:A(x({deviceId:n().int().nonnegative()}),Yk.nullable(),{auth:`admin`})},vocabulary:{noun:F(`Admin link`,`Link di amministrazione`),order:3090}},Zk=S([`online`,`sleeping`,`offline`,`unknown`]),Qk=a(()=>x({childNativeId:l(),name:l(),type:S(E),status:Zk,metadata:x({model:l().optional(),serialNumber:l().optional(),uid:l().optional(),rtspChannel:n().int().nonnegative().optional(),isBattery:y().optional(),isDoorbell:y().optional(),isMultifocal:y().optional(),externalLocation:l().optional(),manufacturer:l().optional(),integration:l().optional()}).default({}),alreadyAdopted:y(),adoptedDeviceId:n().int().nonnegative().nullable(),capabilities:C(l()).readonly().optional(),features:C(l()).readonly().optional(),sourceInfo:Pg.optional(),children:C(Qk).readonly().optional(),parentStableId:l().optional()})),$k=x({id:l(),label:l(),isDefault:y().optional()}),eA=x({search:l().optional(),area:l().optional(),manufacturer:l().optional(),adoptedOnly:y().optional(),unadoptedOnly:y().optional()}),tA=x({integrationId:l(),page:n().int().positive().default(1),pageSize:n().int().positive().max(2e4).default(50),filter:l().optional(),filterText:eA.optional()}),nA=x({candidates:C(Qk).readonly(),totalCount:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),rA=x({integrationId:l(),childNativeId:l()}),iA=x({lastDiscoveryAt:n().int().nonnegative().nullable(),candidateCount:n().int().nonnegative(),adoptedCount:n().int().nonnegative(),lastError:l().nullable()}),Gxe=x({name:l().min(1).optional(),hiddenChildIds:C(l()).optional()}),aA=x({integrationId:l(),childNativeIds:C(l()).min(1),filter:l().optional(),importLocations:y().optional(),perCandidate:m(l(),Gxe).optional()}),oA=x({adopted:C(x({childNativeId:l(),parentDeviceId:n().int().nonnegative(),accessoryDeviceIds:C(n().int().nonnegative()).readonly()})).readonly()}),sA=x({integrationId:l(),camDeviceId:n().int().nonnegative()}),cA=x({camDeviceId:n().int().nonnegative(),resetToSource:y().optional()}),lA=x({changed:y(),rebuiltChildren:n().int().nonnegative(),removedChildren:n().int().nonnegative().optional()}),uA={name:`device-adoption`,scope:`system`,mode:`collection`,status:{schema:iA,kind:`poll`},methods:{listCandidateFilters:A(x({integrationId:l()}),x({filters:C($k)}),{auth:`admin`}),listCandidates:A(tA,nA,{auth:`admin`}),getCandidate:A(rA,Qk.nullable(),{auth:`admin`}),refresh:A(x({integrationId:l()}),iA,{kind:`mutation`,auth:`admin`}),adopt:A(aA,oA,{kind:`mutation`,auth:`admin`}),release:A(sA,v(),{kind:`mutation`,auth:`admin`}),resync:A(cA,lA,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`device adoption — an onboarding flow, not an action`}},dA=i(`state`,[x({state:p(`absent`)}),x({state:p(`ready`),subject:l(),fingerprintSha256:l(),validTo:l()}),x({state:p(`unavailable`),reason:l()})]),fA=x({selfEnrollment:S([`allowed`,`disabled`])}),pA={name:`device-credentials`,scope:`system`,mode:`singleton`,methods:{listDeviceCredentials:A(x({userId:l().min(1).optional(),includeRevoked:y().default(!1)}),C(xpe).readonly(),{auth:`admin`}),startEnrollment:A(x({userId:l().min(1),deviceName:l().min(1).max(80)}),Spe,{kind:`mutation`,auth:`admin`,caller:`required`}),revokeDeviceCredential:A(x({id:l().min(1)}),x({revoked:y(),sessionsEnded:n().int(),status:cg}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCertificateSettings:A(x({}),fA,{auth:`admin`}),setDeviceCertificateSettings:A(fA,fA,{kind:`mutation`,auth:`admin`}),deleteDeviceCredential:A(x({id:l().min(1)}),x({result:S([`deleted`,`live`,`unknown`])}),{kind:`mutation`,auth:`admin`,caller:`required`}),getDeviceCaStatus:A(x({}),dA,{auth:`admin`}),renameDeviceCredential:A(x({id:l().min(1),deviceName:l().min(1).max(80)}),x({renamed:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},Kxe=64,mA=/^[a-z][a-z0-9_]*$/,qxe=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(`.`)),hA=l().max(64).regex(mA);function gA(e){return qxe.has(e)}function _A(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 Jxe(e,t){let n=_A(e);if(!gA(n)&&!t(n))return n;for(let e=2;;e+=1){let r=`${n}_${e}`;if(!t(r))return r}}function Yxe(e,t){return e.length===0?{ok:!1,reason:`empty`}:e.length>64?{ok:!1,reason:`too-long`}:mA.test(e)?gA(e)?{ok:!1,reason:`reserved`}:t(e)?{ok:!1,reason:`taken`}:{ok:!0,alias:e}:{ok:!1,reason:`grammar`}}var vA=4096,Xxe=50,Zxe=4096,Qxe=`—`,yA=l().min(1).max(vA),$xe=`now`,eSe=`camera`,bA=h([l(),n(),y()]),xA=x({deviceId:n().int(),values:m(l().min(1).max(64),bA).optional()}),tSe=`values`,nSe=Il(),SA=[`too-long`,`syntax`,`forbidden-syntax`,`forbidden-member`,`unknown-filter`,`ambiguous-field`,`busy`,`budget-exceeded`,`timeout`,`output-too-large`,`render-failed`,`out-of-scope`,`unavailable`],CA=x({reason:S(SA),message:l()}),wA=[`unknown-alias`,`unknown-field`,`no-field`,`unavailable`],TA=x({ref:l(),reason:S(wA)}),EA=i(`ok`,[x({ok:p(!0),text:l(),trace:C(TA)}),x({ok:p(!1),refusal:CA,trace:C(TA)})]);function DA(e){return e.replace(/-/g,`_`)}function OA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kA(e,t){let n=e;for(let e of t)if(Array.isArray(n)&&typeof e==`number`)n=n[e];else if(OA(n)&&Object.hasOwn(n,String(e)))n=n[String(e)];else return;return n}function rSe(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||DA(e)===n);if(i!==void 0){let n=t.slice(1);if(n.length===0)return{kind:`missing`,reason:`no-field`};let r=kA(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 OA(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=kA(e.slices[o],t);return s===void 0?{kind:`missing`,reason:`unknown-field`}:{kind:`value`,cap:o,fieldPath:t,value:s}}var AA=x({zoneKey:l(),label:l(),icon:xh.nullable(),locationKeys:C(l())});function iSe(e){return e.trim().toLowerCase()}var jA=[`mac`,`serial`,`machine-uuid`,`vendor-uid`,`hostname`,`ip`],MA=S(jA),NA=S([`read`,`derived`]),aSe=/^[0-9a-f]{2}(?::[0-9a-f]{2}){5}$/,PA=/^[a-z0-9][a-z0-9._-]*:[^\sA-Z]+$/,FA=/^[0-9a-f][0-9a-f-]{7,}$/,IA=/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;function LA(e){return x({value:e,origin:NA,readAt:n().int().nonnegative()}).strict()}var oSe=LA(l().regex(aSe)),sSe=LA(l().regex(PA)),cSe=LA(l().regex(FA)),lSe=LA(l().regex(PA)),uSe=LA(l().regex(IA)),dSe=LA(h([_(),o()])),fSe=x({value:l().min(1),origin:NA,readAt:n().int().nonnegative()}).strict(),RA=x({mac:C(oSe).min(1).readonly().optional(),serial:sSe.optional(),"machine-uuid":cSe.optional(),"vendor-uid":lSe.optional(),hostname:uSe.optional(),ip:dSe.optional()}).strict(),pSe={mac:`strong`,serial:`strong`,"machine-uuid":`strong`,"vendor-uid":`strong`,hostname:`weak`,ip:`weak`};function mSe(e){return pSe[e]}function zA(e){return jA.every(t=>e[t]===void 0)}var hSe=/^(?:unknown|none|n\/?a|null|undefined|default|0+|-+)$/i,gSe=new Set([`00:00:00:00:00:00`,`ff:ff:ff:ff:ff:ff`]);function BA(e){return{ok:!1,reason:e}}function VA(e){let t=e.trim().toLowerCase().replace(/[\s:.-]/g,``);if(!/^[0-9a-f]{12}$/.test(t))return BA(`not a 48-bit MAC`);let n=(t.match(/../g)??[]).join(`:`);return gSe.has(n)?BA(`placeholder MAC`):{ok:!0,value:n}}function _Se(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[-._]+|[-._]+$/g,``)}function HA(e,t,n){let r=_Se(e);if(r.length===0)return BA(`no ${n}`);let i=t.trim().toLowerCase().replace(/\s+/g,``);return i.length===0?BA(`blank value`):hSe.test(i)?BA(`placeholder value`):{ok:!0,value:`${r}:${i}`}}function vSe(e){let t=e.trim().toLowerCase().replace(/^\{|\}$/g,``);return FA.test(t)?/^[0-]+$/.test(t)||/^[f-]+$/.test(t)?BA(`placeholder uuid`):{ok:!0,value:t}:BA(`not a uuid`)}function UA(e){return h([_(),o()]).safeParse(e).success}function ySe(e){let t=e.trim().toLowerCase().replace(/\.$/,``);if(t.length===0)return BA(`blank hostname`);if(UA(t))return BA(`an address, not a hostname`);let n=t.split(`.`)[0]??``;return IA.test(n)?n===`localhost`?BA(`placeholder hostname`):{ok:!0,value:n}:BA(`not a hostname`)}function bSe(e){let t=e.trim().toLowerCase().replace(/^\[|\]$/g,``);return UA(t)?t===`0.0.0.0`||t===`::`||t===`::1`||t.startsWith(`127.`)?BA(`loopback or unspecified address`):{ok:!0,value:t}:BA(`not an IP address`)}function WA(e){return e==null||e.trim().length===0}function GA(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(WA(e))continue;let t=o(`mac`,e,VA(e));t!==void 0&&!c.some(e=>e.value===t.value)&&c.push(t)}let l=e.serial===null||e.serial===void 0||WA(e.serial.serial)?void 0:o(`serial`,`${e.serial.manufacturer}:${e.serial.serial}`,HA(e.serial.manufacturer,e.serial.serial,`manufacturer`)),u=e.vendorUid===null||e.vendorUid===void 0||WA(e.vendorUid.id)?void 0:o(`vendor-uid`,`${e.vendorUid.vendor}:${e.vendorUid.id}`,HA(e.vendorUid.vendor,e.vendorUid.id,`vendor`)),d=WA(e.machineUuid)?void 0:o(`machine-uuid`,e.machineUuid,vSe(e.machineUuid)),f=WA(e.host)?null:e.host.trim(),p=f!==null&&UA(f.toLowerCase().replace(/^\[|\]$/g,``)),m=WA(e.hostname)?p?null:f:e.hostname,h=WA(e.ip)?p?f:null:e.ip,g=m===null?void 0:o(`hostname`,m,ySe(m)),_=h===null?void 0:o(`ip`,h,bSe(h));return{identifiers:{...c.length>0?{mac:c}:{},...l===void 0?{}:{serial:l},...d===void 0?{}:{"machine-uuid":d},...u===void 0?{}:{"vendor-uid":u},...g===void 0?{}:{hostname:g},..._===void 0?{}:{ip:_}},rejected:a}}function KA(e,t){return e.value===t.value&&e.origin===t.origin}function qA(e,t){return t!==void 0&&KA(e,t)?t:e}function xSe(e,t,n=[]){let r=e??{},i=t??{},a=new Set(n),o=a.has(`mac`)?r.mac:i.mac?.map(e=>qA(e,r.mac?.find(t=>KA(t,e)))),s=e=>{if(a.has(e))return r[e];let t=i[e];return t===void 0?void 0:qA(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 zA(p)?null:p}function SSe(e,t){let n=e=>e==null||zA(e)?``:JSON.stringify(jA.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 JA=S([`auto`,`proposal`]),YA=x({key:MA,value:l()}),XA=x({deviceId:n().int(),addonId:l(),integrationId:l().nullable()}),ZA=x({a:XA,b:XA,keys:C(YA).readonly(),confidence:JA}),QA=i(`status`,[x({status:p(`unknown`),reason:l()}),x({status:p(`answered`),pairs:C(ZA).readonly(),undeclaredDeviceIds:C(n().int()).readonly()})]),$A=[`same-device`,`poe-power`],ej=S($A),tj=S([`proposed`,`linked`,`dismissed`]),nj=S([`auto`,`operator`]),rj=x({addonId:l().min(1),stableId:l().min(1),deviceId:n().int()}),ij=x({kind:ej,a:rj,b:rj,state:tj,origin:nj,evidence:C(YA).readonly(),evidenceGone:p(!0).optional(),createdAt:n().int().nonnegative(),decidedAt:n().int().nonnegative().optional()}),aj=ij.extend({id:l().min(1)}),oj={"same-device":{directional:!1,attachingRole:null,contributions:[]},"poe-power":{directional:!0,attachingRole:O.PoePort,contributions:[{cap:`power-source`,targetId:`switch`,host:`b`,source:`a`,sourceCap:`switch`,sourceField:`on`}]}};function CSe(e,t){let n=oj[e].attachingRole;return n===null||t===n?null:`attaching-side-role`}function sj(e){return`${e.addonId}/${e.stableId}`}function wSe(e,t,n){let r=sj(t),i=sj(n);return oj[e].directional||r<=i?`${e}:${r}|${i}`:`${e}:${i}|${r}`}var cj=i(`status`,[x({status:p(`not-loaded`),reason:l()}),x({status:p(`answered`),links:C(aj).readonly()})]),lj=S([`not-loaded`,`unknown-link`,`wrong-state`]),uj=i(`ok`,[x({ok:p(!0),link:aj}),x({ok:p(!1),reason:lj,message:l()})]),dj=S([`evidence-gone`,`device-removed`,`operator-unlinked`]),TSe=x({linkId:l(),kind:ej,aDeviceId:n().int(),bDeviceId:n().int(),origin:nj,reason:dj.optional()}),ESe=50,DSe=200,fj=x({caps:C(l()).readonly().optional(),actions:C(l()).readonly().optional(),mode:S([`any`,`all`]).optional()}),pj=x({locations:C(l()).readonly().optional(),integrationIds:C(l()).readonly().optional(),types:C(l()).readonly().optional()}),mj=x({text:l().optional(),requires:fj.optional(),filters:pj.optional(),includeIncompatible:y().optional(),contextDeviceId:n().optional(),ids:C(n()).readonly().optional(),cursor:l().nullable().optional(),limit:n().int().min(1).max(200).optional()}),hj=x({cap:l(),path:l(),label:l(),reading:l().nullable(),unit:l().nullable().optional(),quantity:Ui.optional()}),gj=x({id:n(),name:l(),type:S(E),location:l().nullable(),integrationId:l().nullable(),integrationLabel:l().nullable(),online:y().nullable(),disabled:y(),compatible:y(),values:C(hj).readonly()}),_j=x({value:l(),count:n()}),vj=x({id:l(),label:l(),count:n()}),yj=x({locations:C(_j).readonly(),integrations:C(vj).readonly(),types:C(_j).readonly()}),bj=x({items:C(gj).readonly(),nextCursor:l().nullable(),total:n(),compatibleTotal:n(),fleetTotal:n(),hiddenIncompatible:n(),facets:yj,suggested:C(gj).readonly(),missingIds:C(n()).readonly()}),xj=x({connected:y(),deviceCount:n(),error:l().optional(),motionSliceWriter:p(`orchestrator`).optional()}),OSe=x({externalId:l(),name:l(),type:l(),metadata:m(l(),w()).optional()}),Sj=i(`kind`,[x({kind:p(`mdns`),serviceType:l().min(1),instancePattern:l().optional()}),x({kind:p(`ws-discovery`),types:C(l()).optional()}),x({kind:p(`ssdp`),searchTarget:l().min(1)}),x({kind:p(`udp-broadcast`),port:n().int().min(1).max(65535),payloadHex:l().regex(/^([0-9a-fA-F]{2})*$/),listenPort:n().int().min(1).max(65535).optional()}),x({kind:p(`http-probe`),port:n().int().min(1).max(65535),path:l().startsWith(`/`),method:S([`GET`,`POST`]).default(`GET`),bodyText:l().optional(),contentType:l().optional(),tls:y().default(!1),acceptStatus:C(n().int()).optional()}),x({kind:p(`custom`),reason:l().min(1)})]),Cj=x({modeIndex:n().int().min(0),host:l(),port:n().int(),http:x({status:n().int(),headers:m(l(),l()),bodyText:l()}).optional(),mdns:x({instance:l(),host:l(),port:n().int(),txt:m(l(),l())}).optional(),udp:x({payloadHex:l()}).optional(),wsd:x({xaddrs:C(l()),types:C(l()),scopes:C(l())}).optional()}),wj=x({stableId:l(),type:S(E),suggestedName:l(),prefilledConfig:m(l(),w()),sourceInfo:Pg.optional(),alreadyOnboarded:y().optional(),onboardedDeviceId:n().optional(),onboardedName:l().optional(),setupIntegration:y().optional(),parentStableId:l().optional(),selectable:y().optional(),needsParams:C(l()).optional()}),Tj=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),parentDeviceId:n().nullable(),online:y(),features:C(l()),config:m(l(),w()),sourceInfo:Pg.optional()}),Ej=x({status:S([`ok`,`error`]),labels:C(l()).optional(),error:l().optional()}),Dj=w(),Oj={name:`device-provider`,scope:`system`,mode:`collection`,methods:{start:A(v(),v(),{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getStatus:A(v(),xj),getDevices:A(v(),C(x({id:l(),name:l(),type:l()}))),reloadDevice:A(x({stableId:l()}),x({deviceId:n()}),{kind:`mutation`,timeoutMs:3*6e4}),supportsDiscovery:A(x({}),y()),discoverDevices:A(x({params:m(l(),w()).optional()}),C(wj),{kind:`mutation`,auth:`admin`}),getDiscoveryModes:A(x({}),C(Sj)),classifyDiscoveryHits:A(x({hits:C(Cj),params:m(l(),w()).optional()}),C(wj),{kind:`mutation`,auth:`admin`}),getDiscoveryParamsSchema:A(x({}),Dj),getManualCreationType:A(x({integrationId:l().optional()}),x({deviceType:S(E).nullable()})),adoptDiscoveredDevice:A(x({candidate:wj,integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),supportsManualCreation:A(x({}),y()),getChildCreationSchema:A(x({type:S(E),integrationId:l().optional()}),Dj),createDevice:A(x({type:S(E),config:m(l(),w()),integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),Ej,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},kj=i(`kind`,[x({kind:p(`mdns`),serviceType:l(),instance:l(),host:l(),address:l().nullable(),port:n().int(),txt:m(l(),l())}),x({kind:p(`ssdp`),host:l(),port:n().int(),target:l(),headers:m(l(),l())})]),kSe=x({addonId:l(),candidate:wj,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),Aj=x({id:l(),addonId:l(),candidate:wj,firstSeenAt:n(),lastSeenAt:n(),dismissed:y()}),jj=x({childKey:l(),section:l(),order:n().optional(),collapsed:y().optional()}),ASe=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional()}),Mj=x({icon:l().min(1).optional(),label:l().min(1).optional(),unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),hidden:y().optional(),perCap:m(l(),ASe).optional()}),Nj=x({unit:l().min(1).optional(),precision:n().int().min(0).max(10).optional(),icon:l().min(1).optional()}),Pj=x({id:n(),stableId:l(),addonId:l(),type:S(E),name:l(),alias:hA.optional(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional(),online:y(),probed:y().optional(),features:C(l()),isCamera:y(),config:m(l(),w()),secretConfigPaths:C(l()).optional(),metadata:m(l(),w()).nullable().optional(),identifiers:RA.optional(),attachedIdentifiers:RA.optional(),sourceInfo:Pg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(jj).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),display:Mj.optional()}),Fj=x({key:l(),value:w(),description:l().optional()}),Ij=S([`manual`]),Lj=x({deviceId:n(),name:l(),location:l().nullable(),features:C(l()),producesTrackedEvents:y().optional()}),Rj=x({deviceIds:C(n().int().positive()),trackedDeviceIds:C(n().int().positive()).optional()}),zj={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:[E.Camera],sourceCaps:`any`,cardinality:`many`,value:Rj},jSe=x({deviceId:n(),mode:Ij,devices:C(Lj)}),Bj=x({deviceId:n(),entries:C(x({capName:l(),kind:S([`native`,`wrapped`]),providerAddonId:l(),providerNodeId:l(),nativeAddonId:l(),implementedMethods:C(l()).optional()}))}),Vj=i(`kind`,[x({kind:p(`value`),wrapperAddonId:l().nullable()}),x({kind:p(`missing`)}),x({kind:p(`failed`),error:l()})]),MSe=x({id:n(),stableId:l(),type:l(),name:l(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),role:l().nullable().optional()}),NSe=x({id:n(),stableId:l(),addonId:l(),type:l(),name:l(),userNamed:y().optional(),location:l().nullable(),tags:Eh.optional(),disabled:y(),parentDeviceId:n().nullable(),metadata:m(l(),w()).nullable().optional(),identifiers:RA.optional(),attachedIdentifiers:RA.optional(),sourceInfo:Pg.optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),primaryChildEntityId:l().nullable().optional(),childLayout:C(jj).readonly().optional(),primaryChildPreference:C(l()).readonly().optional(),role:l().nullable().optional(),display:Mj.optional()}),PSe=w().nullable(),FSe=x({streamId:l(),width:n().optional(),height:n().optional(),codec:l().optional(),fps:n().optional(),bitrateKbps:n().optional()}),ISe=x({addonId:l(),stableId:l(),id:n(),type:l(),name:l(),location:l().nullable().optional(),disabled:y().optional(),parentDeviceId:n().nullable(),role:l().nullable().optional(),features:C(l()).optional(),config:m(l(),w()),secretConfigPaths:C(l()).optional()}),Hj=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),Uj=2160*60*60*1e3,Wj=x({deviceId:n().int().positive(),stores:m(l(),n().int().nonnegative())}),Gj=x({status:S([`skipped`,`dry-run`,`cleaned`]),reason:l().nullable(),devices:C(Wj),unreachable:C(l())}),LSe=x({deviceId:n()}),RSe=x({deviceId:n(),data:m(l(),w()),secretConfigPaths:C(l()).optional()}),Kj=S([`off`,`on`,`not-offered`,`unreachable`]),qj=x({deviceId:n(),switchId:wd,outcome:Kj,detail:l().optional()}),Jj=x({sourceId:n(),targetId:n(),switches:C(qj).readonly(),sourceStillLive:C(wd).readonly(),swapped:y()}),Yj={name:`device-manager`,scope:`system`,mode:`singleton`,extensionSlots:[zj],methods:{allocateDeviceId:A(x({addonId:l(),stableId:l()}),x({id:n()}),{kind:`mutation`}),migrateDevice:A(x({sourceId:n(),targetId:n()}),Jj,{kind:`mutation`,auth:`admin`,timeoutMs:12*6e4}),registerDevice:A(ISe,v(),{kind:`mutation`}),removeDevice:A(LSe,v(),{kind:`mutation`}),persistConfig:A(RSe,v(),{kind:`mutation`,auth:`admin`}),loadConfig:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadRuntimeState:A(x({deviceId:n()}),m(l(),w()),{auth:`admin`}),loadMeta:A(x({deviceId:n()}),NSe.nullable()),setName:A(x({deviceId:n(),name:l(),stampUserNamed:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),setAlias:A(x({deviceId:n(),alias:l()}),i(`ok`,[x({ok:p(!0),alias:hA}),x({ok:p(!1),reason:S([`empty`,`too-long`,`grammar`,`reserved`,`taken`]),takenBy:n().optional()})]),{kind:`mutation`,auth:`admin`}),renderDeviceTemplates:A(x({templates:C(yA).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:xA.optional()}),x({results:C(EA)}),{auth:`admin`}),checkDeviceTemplates:A(x({templates:C(l()).max(64),allowedDeviceIds:C(n().int()).optional(),thisDevice:xA.optional()}),x({results:C(i(`ok`,[x({ok:p(!0),aliases:C(x({alias:l(),deviceId:n().int().nullable(),allowed:y(),reads:C(l())})),readsClock:y()}),x({ok:p(!1),refusal:CA})]))}),{auth:`admin`}),setLocation:A(x({deviceId:n(),location:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setTags:A(x({deviceId:n(),tags:Eh}),v(),{kind:`mutation`,auth:`admin`}),setType:A(x({deviceId:n(),type:S(E)}),v(),{kind:`mutation`,auth:`admin`}),setIntegrationId:A(x({deviceId:n(),integrationId:l()}),v(),{kind:`mutation`,auth:`admin`}),setLinkDeviceId:A(x({deviceId:n(),linkDeviceId:n().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildEntityId:A(x({deviceId:n(),primaryChildEntityId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setChildLayout:A(x({deviceId:n(),childLayout:C(jj).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setPrimaryChildPreference:A(x({deviceId:n(),primaryChildPreference:C(l()).readonly()}),v(),{kind:`mutation`,auth:`admin`}),setDisplay:A(x({deviceId:n(),display:Mj.nullable()}),v(),{kind:`mutation`,auth:`admin`}),getRoleDisplayDefaults:A(x({}),x({defaults:m(l(),Nj)}),{role:`viewer`,kind:`query`}),setRoleDisplayDefaults:A(x({defaults:m(l(),Nj)}),v(),{kind:`mutation`,auth:`admin`}),getWireableFields:A(x({deviceId:n(),includeSynthesizable:y().optional()}),x({caps:C(x({cap:l(),fields:C(x({path:l(),kind:S([`string`,`number`,`boolean`,`enum`,`union`]),unionMembers:C(S([`string`,`number`,`boolean`])).optional(),enumValues:C(l()).optional(),item:y().optional(),quantity:Ui.optional()})).readonly(),itemArray:x({path:l(),keyField:l()}).optional()})).readonly()}),{kind:`query`}),setRole:A(x({deviceId:n(),role:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),applyInitialMeta:A(x({deviceId:n(),name:l().optional(),location:l().nullable().optional(),tags:Eh.optional(),type:S(E).optional(),integrationId:l().optional(),linkDeviceId:n().nullable().optional(),role:l().nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),setMetadata:A(x({deviceId:n(),patch:m(l(),w())}),v(),{kind:`mutation`,auth:`admin`}),setIdentifiers:A(x({deviceId:n(),identifiers:RA.nullable(),unread:C(MA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityCandidates:A(x({}),QA,{kind:`query`,auth:`admin`}),setAttachedIdentifiers:A(x({deviceId:n(),identifiers:RA.nullable(),unread:C(MA).optional()}),v(),{kind:`mutation`,auth:`admin`}),listIdentityLinks:A(x({deviceId:n().int().optional()}),cj,{kind:`query`,auth:`admin`}),confirmIdentityLink:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),dismissIdentityLink:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),unlinkIdentity:A(x({linkId:l().min(1)}),uj,{kind:`mutation`,auth:`admin`}),listLocations:A(v(),C(l())),addLocation:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),removeLocation:A(x({name:l(),cascade:y().optional()}),v(),{kind:`mutation`,auth:`admin`}),renameLocation:A(x({from:l(),to:l()}),x({moved:n()}),{kind:`mutation`,auth:`admin`}),listLocationIcons:A(v(),C(Mpe),{role:`viewer`}),setLocationIcon:A(x({location:l(),icon:xh.nullable()}),v(),{kind:`mutation`,auth:`admin`}),listLocationDescriptions:A(v(),C(Ppe)),setLocationDescription:A(x({location:l(),description:l().max(400).nullable()}),v(),{kind:`mutation`,auth:`admin`}),listSiteZones:A(v(),C(AA),{role:`viewer`}),setSiteZone:A(x({name:l(),icon:xh.nullable().optional()}),v(),{kind:`mutation`,auth:`admin`}),removeSiteZone:A(x({name:l()}),v(),{kind:`mutation`,auth:`admin`}),renameSiteZone:A(x({from:l(),to:l()}),v(),{kind:`mutation`,auth:`admin`}),setLocationZone:A(x({location:l(),zone:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),setDisabled:A(x({deviceId:n(),disabled:y()}),v(),{kind:`mutation`,auth:`admin`}),listPersistedByAddon:A(x({addonId:l()}),C(MSe)),listAll:A(x({addonId:l().optional(),projection:S([`full`,`slim`]).optional(),isCamera:y().optional(),deviceIds:C(n()).optional()}),C(Pj),{role:`viewer`}),search:A(mj,bj,{role:`viewer`}),getDevice:A(x({deviceId:n()}),Pj.nullable()),getChildren:A(x({parentDeviceId:n()}),C(Pj),{role:`viewer`}),getChildrenBatch:A(x({parentDeviceIds:C(n()).max(256)}),m(l(),C(Pj))),getLinkedDevices:A(x({deviceId:n()}),x({mode:Ij,devices:C(Lj)}),{role:`viewer`}),getLinkedDevicesBatch:A(x({deviceIds:C(n())}),C(jSe),{role:`viewer`}),getStreamSources:A(x({deviceId:n()}),C(ta)),getConfigSchema:A(x({deviceId:n()}),C(Fj)),getSettingsSchema:A(x({deviceId:n()}),PSe),updateConfig:A(x({deviceId:n(),values:m(l(),w())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),enable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),disable:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),remove:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listDeletedSince:A(x({sinceMs:n()}),C(Hj).readonly(),{auth:`admin`}),cleanupDeletedDevicesData:A(x({confirm:y()}),Gj,{kind:`mutation`,auth:`admin`}),removeByIntegration:A(x({integrationId:l()}),x({removed:n()}),{kind:`mutation`,auth:`admin`}),getStreamProfileMap:A(x({deviceId:n()}),m(l(),l().nullable())),setStreamProfileMap:A(x({deviceId:n(),profileMap:m(l(),l().nullable())}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),probeStreams:A(x({deviceId:n()}),C(FSe),{kind:`mutation`,auth:`admin`}),getBindings:A(x({deviceId:n()}),Bj,{role:`viewer`}),getBindingsBatch:A(x({deviceIds:C(n())}),C(Bj)),getAllBindings:A(x({}),C(Bj)),listDeviceIdsByCaps:A(x({capNames:C(l().min(1)).min(1).max(16)}),C(n()),{role:`viewer`}),setWrapperActive:A(x({deviceId:n(),capName:l(),wrapperAddonId:l(),active:y()}),v(),{kind:`mutation`,auth:`admin`}),getWrapperActivation:A(x({deviceId:n(),capName:l().min(1)}),Vj),listWrappersForCap:A(x({capName:l()}),C(l())),listBindableCapsForDeviceType:A(x({deviceType:l()}),C(x({capName:l(),wrappers:C(l())}))),getDeviceSettingsAggregate:A(x({deviceId:n()}),Ax.nullable()),getDeviceLiveInfoAggregate:A(x({deviceId:n()}),Ax.nullable(),{role:`viewer`}),getDeviceAggregate:A(x({deviceId:n()}),x({settings:Ax.nullable(),live:Ax.nullable()})),runDeviceAction:A(x({deviceId:n().int().nonnegative(),action:l().min(1),input:w()}),w(),{kind:`mutation`}),updateDeviceField:A(x({deviceId:n(),writerCapName:l(),writerAddonId:l(),key:l(),value:w()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),updateDeviceFieldsBatch:A(x({deviceId:n(),changes:C(x({writerCapName:l(),writerAddonId:l(),key:l(),value:w()}))}),x({success:p(!0),failures:C(x({writerCapName:l(),writerAddonId:l(),error:l()}))}),{kind:`mutation`,auth:`admin`}),discoverDevices:A(x({addonId:l()}),C(wj),{kind:`mutation`,auth:`admin`}),adoptDevice:A(x({addonId:l(),candidate:wj,integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),getCreationSchema:A(x({addonId:l(),type:S(E),integrationId:l().optional()}),w().nullable()),createDevice:A(x({addonId:l(),type:S(E),config:m(l(),w()),integrationId:l().optional()}),Tj,{kind:`mutation`,auth:`admin`}),testCreationField:A(x({addonId:l(),type:S(E),key:l(),value:w(),formValues:m(l(),w()).optional()}),Ej,{kind:`mutation`,auth:`admin`}),adoptionListCandidateFilters:A(x({addonId:l(),integrationId:l()}),x({filters:C($k)}),{auth:`admin`}),adoptionListCandidates:A(tA.extend({addonId:l()}),nA,{auth:`admin`}),adoptionRefresh:A(x({addonId:l(),integrationId:l()}),iA,{kind:`mutation`,auth:`admin`}),adoptionAdopt:A(aA.extend({addonId:l()}),oA,{kind:`mutation`,auth:`admin`}),adoptionRelease:A(sA.extend({addonId:l()}),v(),{kind:`mutation`,auth:`admin`}),adoptionStartJob:A(aA.extend({addonId:l()}),x({jobId:l()}),{kind:`mutation`,auth:`admin`}),adoptionListJobs:A(x({addonId:l(),integrationId:l().optional()}),C(Cd).readonly(),{auth:`admin`}),adoptionCancelJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),adoptionResync:A(cA,lA,{kind:`mutation`,auth:`admin`}),discoveryProviders:A(x({}),x({providers:C(x({addonId:l(),label:l()})).readonly()}),{auth:`admin`}),discoverAllProviders:A(x({subnets:C(l()).optional()}),x({groups:C(x({addonId:l(),label:l(),candidates:C(wj).readonly(),error:l().nullable()})).readonly()}),{kind:`mutation`,auth:`admin`}),discoverProvider:A(x({addonId:l(),params:m(l(),w()).optional(),subnets:C(l()).optional()}),x({candidates:C(wj).readonly()}),{kind:`mutation`,auth:`admin`}),listDiscoveryProposals:A(x({}),x({proposals:C(Aj).readonly()}),{auth:`admin`}),dismissDiscoveryProposal:A(x({id:l()}),x({dismissed:y()}),{kind:`mutation`,auth:`admin`}),reportDiscoveryObservations:A(x({observations:C(kj).max(512)}),x({proposed:n().int()}),{kind:`mutation`,auth:`admin`}),runDiscoverySweep:A(x({}),x({providers:n().int(),proposed:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),providerCreationType:A(x({addonId:l(),integrationId:l().optional()}),x({deviceType:S(E).nullable()}),{auth:`admin`}),providerDiscoveryParamsSchema:A(x({addonId:l()}),w(),{auth:`admin`}),testField:A(x({deviceId:n(),key:l(),value:w()}),Ej,{kind:`mutation`,auth:`admin`}),getDeviceStatusAggregate:A(x({deviceId:n(),caps:C(l()).readonly().optional()}),m(l(),w().nullable())),getDeviceStatusAggregateBatch:A(x({deviceIds:C(n()).readonly(),caps:C(l()).readonly().optional()}),m(l(),m(l(),w().nullable())),{role:`viewer`})},vocabulary:{notOperatorFacing:`the device registry itself — rename, move and remove are administration`}},Xj=[`linked-devices`],Zj=S(Xj),Qj={"linked-devices":{descriptor:zj,declaringCap:`device-manager`,hostDeviceTypes:[E.Camera]}},$j=i(`slot`,[Rj.extend({slot:p(`linked-devices`)})]),eM=[E.Camera],zSe=`:`,BSe=`listSlots`,tM=i(`state`,[x({state:p(`ok`)}),x({state:p(`unreachable`),reason:l()})]),nM=x({source:l(),label:l(),addonId:l().optional(),availability:tM}),rM=S([`ok`,`missing`,`foreign`,`unavailable`]),iM=x({deviceId:n().int(),name:l().nullable(),health:rM,detail:l().optional()}),aM=x({state:S([`active`,`inactive`,`unknown`]),authority:l(),detail:l().optional()}),oM=x({state:p(`ok`),slotRef:l(),slot:Zj,authority:l(),activation:aM.nullable(),value:$j,sources:C(iM),impliedSources:C(iM).optional()}),sM=x({state:p(`unreachable`),addonId:l(),reason:l()}),cM=i(`state`,[oM,sM]);function VSe(e,t){return{state:`unreachable`,addonId:e,reason:t}}var lM=x({deviceId:n().int(),name:l(),type:l(),location:l().nullable(),parentName:l().nullable(),suggested:y(),reason:l().nullable()}),uM=x({candidates:C(lM)}),dM=x({applied:p(!0),reload:S([`none`,`host`,`parent`])}),fM=x({deviceId:n().int(),slotRef:l().min(1)}),pM=fM.extend({value:$j}),mM={name:`device-extension`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:eM,deviceConfig:{ui:{kind:`widget`,widgetId:`host/extensions-panel`,tab:`general`,label:`Extensions`,order:72}},methods:{listSources:A(x({deviceId:n().int()}),C(nM)),listSlots:A(x({deviceId:n().int()}),C(cM)),listCandidates:A(fM,uM),setSlot:A(pM,dM,{kind:`mutation`,auth:`admin`})},vocabulary:{noun:F(`Device extension`,`Estensione del dispositivo`),order:3100}},hM=i(`kind`,[x({kind:p(`device`),deviceId:n().int()}),x({kind:p(`node`),nodeId:l().min(1)})]),gM=S([`gauge`,`counter`,`boolean`,`enum`]),_M=S([`gauge`,`counter`,`boolean`]),HSe=`derived:energy.kwh`,vM=S([`raw`,`5m`,`1h`,`1d`]),yM=S([`undeclared`,`not-owner`,`opted-out`,`not-a-real-device`,`rate`,`ingest-mismatch`,`out-of-range`]),USe=x({key:l(),reason:yM,count:n().int()}),bM=x({accepted:n().int(),refused:C(USe).readonly()}),xM=x({key:l(),scope:l(),kind:gM,unit:l().nullable(),displayName:l(),source:S([`cap`,`addon`,`derived`]),values:C(l()).readonly().nullable(),firstTs:n(),lastTs:n()}),WSe=x({t:n(),samples:n().int(),mean:n().nullable(),twMean:n().nullable(),min:n(),max:n(),last:n().nullable(),delta:n().nullable(),state:l().nullable(),states:m(l(),n()).nullable()}),GSe=x({scope:l(),before:x({t:n(),value:n().nullable(),state:l().nullable()}).nullable(),points:C(WSe).readonly(),derivedFrom:l().nullable()}),SM={key:l(),scope:l().optional(),from:n(),to:n(),resolution:h([vM,p(`auto`)]).default(`auto`),maxPoints:n().int().positive().max(5e3).default(1e3)},CM=x({resolution:vM,series:C(GSe).readonly(),truncated:y()}),KSe=24,qSe=h([x({deviceId:n().int(),key:l(),scope:l().optional()}),x({forNodeId:l().min(1),key:l(),scope:l().optional()})]),JSe=i(`ok`,[x({ok:p(!0),result:CM}),x({ok:p(!1),error:l()})]),YSe=x({tier:vM,rows:n().int().nullable(),approxBytes:n().nullable(),countedAt:n().nullable()}),wM=S([`device-gone`,`undeclared`]),TM=x({raw:n().int(),"5m":n().int(),"1h":n().int(),"1d":n().int()}),XSe=x({seriesId:n().int(),deviceId:n().int(),key:l(),scope:l(),displayName:l().nullable(),reason:wM,missingSince:n().nullable(),firstTs:n(),lastTs:n(),rows:TM}),ZSe=200,QSe=50,EM=S([`not-found`,`not-orphan`,`failed`]),$Se=i(`ok`,[x({seriesId:n().int(),ok:p(!0),deleted:TM}),x({seriesId:n().int(),ok:p(!1),reason:EM})]),eCe=x({series:C(XSe).readonly(),truncated:y()}),DM=S([`invalid-range`,`range-too-large`,`series-not-found`,`not-a-point-series`]),tCe=x({"5m":n().int(),"1h":n().int(),"1d":n().int()}),nCe=i(`ok`,[x({ok:p(!0),dryRun:y(),seriesId:n().int(),rows:TM,rewritten:tCe.nullable()}),x({ok:p(!1),reason:DM})]),OM=x({startedAt:n(),ready:y(),series:n().int(),metrics:n().int(),optedOutDevices:n().int(),tiers:C(YSe).readonly(),capture:x({eventsSeen:n().int(),pointsEmitted:n().int(),pointsWritten:n().int(),pointsDropped:n().int(),bufferDepth:n().int(),trailingEmitted:n().int(),reconciledPoints:n().int(),reconcileRuns:n().int(),reconcileFailures:n().int(),lastReconcileAt:n().nullable(),lastFlushAt:n().nullable(),flushFailures:n().int(),skipped:m(l(),n().int())}),ingest:x({accepted:n().int(),refused:m(l(),n().int())}),rollup:x({last5mAt:n().nullable(),last1hAt:n().nullable(),last1dAt:n().nullable(),errors:n().int(),dirty5m:n().int(),dirty1h:n().int(),dirty1d:n().int()}),retention:x({lastRunAt:n().nullable(),deleted:m(l(),n().int()),purgedSeries:n().int()}),directory:x({devices:n().int(),lastRefreshAt:n().nullable()})}),kM={name:`device-history`,scope:`system`,mode:`singleton`,methods:{listSeries:A(x({deviceId:n().int()}),C(xM).readonly()),listNodeSeries:A(x({forNodeId:l().min(1)}),C(xM).readonly(),{auth:`admin`}),query:A(x({deviceId:n().int(),...SM}),CM),queryNode:A(x({forNodeId:l().min(1),...SM}),CM,{auth:`admin`}),queryMany:A(x({items:C(qSe).min(1).max(24),from:SM.from,to:SM.to,resolution:SM.resolution,maxPoints:SM.maxPoints}),x({results:C(JSe).readonly()}),{auth:`admin`}),declareSeries:A(x({name:l().regex(/^[a-z0-9-]+$/),subjectKind:S([`device`,`node`]),kind:_M,unit:l().optional(),displayName:l().min(1),ingest:S([`points`,`buckets`])}),x({key:l()}),{kind:`mutation`,auth:`admin`}),record:A(x({points:C(x({key:l(),subject:hM,scope:l().default(``),ts:n(),value:n()})).max(5e3)}),bM,{kind:`mutation`,auth:`admin`}),recordBuckets:A(x({buckets:C(x({key:l(),subject:hM,scope:l().default(``),bucketStart:n(),samples:n().int().positive(),sum:n(),min:n(),max:n(),last:n().nullable(),lastTs:n().nullable()})).max(5e3)}),bM,{kind:`mutation`,auth:`admin`}),getDeviceEnabled:A(x({deviceId:n().int()}),x({enabled:y()})),setDeviceEnabled:A(x({deviceId:n().int(),enabled:y()}),x({enabled:y()}),{kind:`mutation`,auth:`admin`}),getStatus:A(x({}),OM,{auth:`admin`}),listOrphanSeries:A(x({}),eCe,{auth:`admin`}),deleteOrphanSeries:A(x({seriesIds:C(n().int()).min(1).max(50)}),x({results:C($Se).readonly()}),{kind:`mutation`,auth:`admin`}),deleteSeriesRange:A(x({deviceId:n().int(),key:l().min(1),scope:l(),fromMs:n().int().nonnegative(),toMs:n().int().nonnegative(),dryRun:y()}),nCe,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`recorded history of device state — read by charts, not actuated`}},AM=x({deviceId:n().int().positive(),deletedAt:n(),providerAddonId:l()}),jM=x({counts:m(l(),n().int().nonnegative())}),MM=x({store:l(),deviceId:n().int().positive(),count:n().int().nonnegative()}),NM={name:`device-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onDeviceRemoved:A(AM,jM,{kind:`mutation`,auth:`admin`}),listDeviceData:A(v(),C(MM).readonly(),{auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},PM=S([`appliance`,`mower`,`vacuum`]),FM=S([`open`,`closed`]),IM=S([`completed`,`aborted`,`error`,`unknown`]),LM=S([`running-state`,`activity`,`reconcile`]),RM=S([`counter-delta`,`history-integral`]),zM=x({phase:l(),at:n()}),BM=x({kind:p(`appliance`),energyKwh:n().nullable().meta(N(`energy`)),energyMethod:RM.nullable(),peakW:n().nullable().meta(N(`power`)),avgW:n().nullable().meta(N(`power`)),program:l().nullable(),remainingAtStartSec:n().nullable().meta(N(`duration`)),finalPhase:l().nullable(),energyStartKwh:n().nullable().meta(N(`energy`)),powerObservedMs:n()}),VM=i(`kind`,[BM]),HM=x({runId:l(),deviceId:n().int(),kind:PM,state:FM,startedAt:n(),endedAt:n().nullable(),durationMs:n().nullable(),outcome:IM.nullable(),startSource:LM,endSource:LM.nullable(),runningSource:S([`native`,`assigned`]).nullable(),phases:C(zM),detail:VM}),rCe=[E.Washer,E.Dryer,E.Dishwasher],iCe=200,UM={name:`device-runs`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:rCe,methods:{listRuns:A(x({deviceId:n().int(),outcome:IM.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({runs:C(HM).readonly(),nextCursor:l().nullable()})),getRun:A(x({deviceId:n().int(),runId:l()}),HM.nullable()),getCurrentRun:A(x({deviceId:n().int()}),HM.nullable())},events:{onRunOpened:{data:HM,notOperatorFacing:`the durable record of a run that the running-state start flip already announces`},onRunClosed:{data:HM,notOperatorFacing:`the durable record of a run that the running-state finish flip already announces`}},vocabulary:{noun:F(`Runs`,`Esecuzioni`),order:2130}},WM=S([`replace`,`add`]),GM=i(`ok`,[x({ok:p(!0),changed:y()}),x({ok:p(!1),code:S([`owned-by-other`,`not-claimed`,`field-not-claimed`,`invalid-slice`,`unknown-device`,`row-unreadable`,`migration-in-flight`]),message:l()})]),KM=x({deviceId:n(),capName:l(),owner:l().min(1),mode:WM,fields:C(l().min(1)).min(1)}),qM=i(`state`,[x({state:p(`loaded`),claims:C(KM)}),x({state:p(`not-loaded`),reason:l()})]),JM={name:`device-state`,scope:`system`,mode:`singleton`,methods:{getSnapshot:A(x({deviceId:n()}),m(l(),m(l(),w()))),getCapSlice:A(x({deviceId:n(),capName:l(),confirmed:y().optional()}),m(l(),w()).nullable()),getAllSnapshots:A(x({confirmed:y().optional()}),m(l(),m(l(),m(l(),w())))),setCapSlice:A(x({deviceId:n(),capName:l(),slice:m(l(),w())}),v(),{kind:`mutation`}),claimFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),mode:WM,fields:C(l().min(1)).min(1),values:m(l(),w())}),GM,{kind:`mutation`,auth:`admin`}),patchOwnedFields:A(x({deviceId:n(),capName:l(),owner:l().min(1),values:m(l(),w())}),GM,{kind:`mutation`,auth:`admin`}),releaseClaim:A(x({deviceId:n(),capName:l(),owner:l().min(1)}),GM,{kind:`mutation`,auth:`admin`}),listClaims:A(x({ownerPrefix:l().optional()}),qM,{auth:`admin`}),getNativeCapSlice:A(x({deviceId:n(),capName:l()}),m(l(),w()).nullable(),{auth:`admin`})},events:{onChanged:Lr(x({deviceId:n(),capName:l(),slice:m(l(),w())}))},vocabulary:{notOperatorFacing:`the runtime-state mirror every trigger already reads through`}},YM=S([`schedule`,`command`,`burst`]),XM=S([`none`,`partial`,`full`]),ZM=1e3,aCe=x({integrationId:l().min(1),minIntervalMs:n().int().min(ZM),intervalMs:n().int().positive().optional(),batch:y(),push:XM,heartbeatMs:n().int().positive().optional(),connectionEpoch:n().int().nonnegative().optional()});function oCe(e){let t=e.intervalMs??0;return Math.max(e.minIntervalMs,t)}var QM=[3e3,1e4],$M=1e4,eN=2e3;function sCe(e){let t=QM.filter(t=>t<e),n=e-eN,r=(t[t.length-1]??0)+$M;for(;r<n;)t.push(r),r+=$M;let i=t[t.length-1];return(i===void 0?n>0:n-i>=1e3)&&t.push(n),t}var cCe=2500,tN=x({deviceId:n().int().nonnegative(),deviceIds:C(n().int().nonnegative()).min(1),reason:YM}),nN=x({deviceId:n().int().nonnegative()}),rN=x({ok:p(!0)}),iN=`the core schedules state refreshes itself; an operator never asks for one`,aN={name:`device-state-refresh`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{refresh:A(tN,rN,{kind:`mutation`,auth:`admin`,notOperatorFacing:iN}),resubscribe:A(nN,rN,{kind:`mutation`,auth:`admin`,notOperatorFacing:iN})},vocabulary:{noun:F(`State refresh`,`Aggiornamento dello stato`),order:3247}},oN=x({online:y(),lastChangedAt:n()}),sN={name:`device-status`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:oN}),notOperatorFacing:"the `online` state trigger phrases both edges of this change"}},status:{schema:oN,kind:`push`},runtimeState:oN,durability:`restored`,history:{fields:{online:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Reachability`,`Raggiungibilità`),order:5260,state:[{kind:`boolean`,field:`online`,label:F(`Online`,`Online`),whenTrue:F(`When {device} comes back online`,`Quando {device} torna online`),whenFalse:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi`}],extraEvents:[{category:T.DeviceOnline,label:F(`Came online`,`Tornato online`),phrase:F(`When {device} comes back online`,`Quando {device} torna online`),icon:`wifi`},{category:T.DeviceOffline,label:F(`Went offline`,`Andato offline`),phrase:F(`When {device} goes offline`,`Quando {device} va offline`),icon:`wifi-off`}]}},lCe=200,uCe=500,cN=S([`not-kernel`,`invalid`]),lN=x({written:n().int().nonnegative(),refused:C(x({id:l(),reason:cN})).readonly()}),uN=x({rows:n().int().nullable(),lastWriteAt:n().nullable(),refused:m(l(),n())}),dN={name:`device-transitions`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:Object.values(E).filter(e=>e!==E.Container),methods:{listTransitions:A(x({deviceId:n().int(),capName:l().optional(),actorKind:Ri.optional(),outcome:zi.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(Vi).readonly(),nextCursor:l().nullable()})),getTransition:A(x({deviceId:n().int(),id:l()}),Vi.nullable()),listRecentTransitions:Ir(x({actorKind:Ri.optional(),outcome:zi.optional(),atFrom:n().optional(),atTo:n().optional(),limit:n().int().positive().max(200).default(50),cursor:l().optional()}),x({transitions:C(Vi).readonly(),nextCursor:l().nullable()}),{auth:`admin`}),record:Ir(x({transitions:C(Vi).max(500)}),lN,{kind:`mutation`,auth:`admin`}),getStatus:Ir(x({}),uN,{auth:`admin`})},vocabulary:{noun:F(`Transitions`,`Transizioni`),order:2140}},fN=S([`idle`,`running`,`paused`,`finished`,`error`,`unavailable`]),pN=S([`Inactive`,`Ready`,`DelayedStart`,`Run`,`Pause`,`ActionRequired`,`Finished`,`Error`,`Aborting`]),mN=S([`available`,`offline`,`description-missing`]),hN=x({availability:mN,state:fN,operationState:pN.nullable(),program:l().nullable(),selectedProgram:l().nullable(),availablePrograms:C(l()),remaining:n().int().nonnegative().nullable().meta(N(`duration`)),delayedStart:n().int().nonnegative().nullable().meta(N(`duration`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),doorOpen:y().nullable(),doorLocked:y().nullable(),remoteStartAllowed:y().nullable(),remoteControlActive:y().nullable(),localControlActive:y().nullable(),powerOn:y().nullable(),powerState:l().nullable(),filterCleaningDue:y().nullable(),machineCareDue:y().nullable(),machineCareRemainingRuns:n().int().nonnegative().nullable().meta(N(`count`)),halfLoad:y().nullable(),hygienePlus:y().nullable(),extraDry:y().nullable(),intensiveZone:y().nullable(),varioSpeedPlus:y().nullable(),childLock:y().nullable(),activeEvents:C(l()),errorCode:n().nullable().meta(N(`none`)),errorLabel:l().nullable(),lastFetchedAt:n()}),gN=n().int().nonnegative(),_N=h([y(),l(),n()]),vN=S([`none`,`read`,`readWrite`,`writeOnly`,`readStatic`]),yN=x({key:l(),name:l(),type:S([`boolean`,`number`,`enum`,`string`]),access:vN,available:y(),unit:l().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable(),enumValues:C(l()).nullable(),defaultValue:_N.nullable()}),bN=x({key:l(),name:l(),available:y(),options:C(yN)}),xN=x({availability:mN,supportsStart:y(),supportsPause:y(),supportsResume:y(),supportsStop:y(),supportsPower:y(),programs:C(bN),options:C(yN)}),SN={name:`dishwasher`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Dishwasher],methods:{start:A(x({deviceId:gN,program:l().min(1).optional(),options:m(l(),_N).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.start`,label:F(`Start cycle`,`Avvia il lavaggio`),phrase:F(`Start {device}`,`Avvia {device}`),icon:`play`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`},optional:!0}]}]}),pause:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.pause`,label:F(`Pause`,`Metti in pausa`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),resume:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.resume`,label:F(`Resume`,`Riprendi`),phrase:F(`Resume {device}`,`Riprendi il lavaggio di {device}`),icon:`play`}]}),stop:A(x({deviceId:gN}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),setProgram:A(x({deviceId:gN,program:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.program`,label:F(`Choose programme`,`Scegli il programma`),phrase:F(`Select the {program} programme on {device}`,`Seleziona il programma {program} su {device}`),icon:`list`,openArgs:[{key:`program`,label:F(`Programme`,`Programma`),offer:{kind:`dynamic`,from:`status`,field:`availablePrograms`}}]}]}),setPower:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.powerOn`,label:F(`Power on`,`Accendi`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,args:{on:!0}},{id:`dishwasher.powerOff`,label:F(`Power off`,`Spegni`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,args:{on:!1}}]}),setHalfLoad:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.halfLoadOn`,label:F(`Half load on`,`Mezzo carico attivo`),phrase:F(`Turn on half load on {device}`,`Attiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!0}},{id:`dishwasher.halfLoadOff`,label:F(`Half load off`,`Mezzo carico spento`),phrase:F(`Turn off half load on {device}`,`Disattiva il mezzo carico su {device}`),icon:`contrast`,args:{on:!1}}]}),setHygienePlus:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.hygienePlusOn`,label:F(`Hygiene Plus on`,`Igiene Plus attiva`),phrase:F(`Turn on Hygiene Plus on {device}`,`Attiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!0}},{id:`dishwasher.hygienePlusOff`,label:F(`Hygiene Plus off`,`Igiene Plus spenta`),phrase:F(`Turn off Hygiene Plus on {device}`,`Disattiva Igiene Plus su {device}`),icon:`sparkles`,args:{on:!1}}]}),setExtraDry:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.extraDryOn`,label:F(`Extra dry on`,`Asciugatura extra attiva`),phrase:F(`Turn on extra dry on {device}`,`Attiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!0}},{id:`dishwasher.extraDryOff`,label:F(`Extra dry off`,`Asciugatura extra spenta`),phrase:F(`Turn off extra dry on {device}`,`Disattiva l’asciugatura extra su {device}`),icon:`sun`,args:{on:!1}}]}),setIntensiveZone:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.intensiveZoneOn`,label:F(`Intensive zone on`,`Zona intensiva attiva`),phrase:F(`Turn on the intensive zone on {device}`,`Attiva la zona intensiva su {device}`),icon:`flame`,args:{on:!0}},{id:`dishwasher.intensiveZoneOff`,label:F(`Intensive zone off`,`Zona intensiva spenta`),phrase:F(`Turn off the intensive zone on {device}`,`Disattiva la zona intensiva su {device}`),icon:`flame`,args:{on:!1}}]}),setVarioSpeedPlus:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.varioSpeedOn`,label:F(`Speed boost on`,`Lavaggio rapido attivo`),phrase:F(`Turn on the speed boost on {device}`,`Attiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!0}},{id:`dishwasher.varioSpeedOff`,label:F(`Speed boost off`,`Lavaggio rapido spento`),phrase:F(`Turn off the speed boost on {device}`,`Disattiva il lavaggio rapido su {device}`),icon:`zap`,args:{on:!1}}]}),setChildLock:A(x({deviceId:gN,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dishwasher.childLockOn`,label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`Turn on the child lock of {device}`,`Attiva il blocco bambini di {device}`),icon:`lock`,args:{on:!0}},{id:`dishwasher.childLockOff`,label:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setOption:A(x({deviceId:gN,key:l().min(1),value:_N}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`a raw appliance option key/value; every option worth naming has its own action above`}),getOptions:A(x({deviceId:gN}),xN,{auth:`protected`})},status:{schema:hN,kind:`poll`},runtimeState:hN,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:F(`Dishwasher`,`Lavastoviglie`),order:2020,state:[{kind:`enum`,field:`state`,label:F(`Cycle`,`Ciclo`),values:[{value:`idle`,label:F(`Idle`,`Inattiva`)},{value:`running`,label:F(`Running`,`In funzione`),phrase:F(`When {device} starts a cycle`,`Quando {device} inizia un lavaggio`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`finished`,label:F(`Finished`,`Terminato`),phrase:F(`When {device} finishes`,`Quando {device} finisce il lavaggio`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)},{value:`unavailable`,label:F(`Unavailable`,`Non disponibile`)}],icon:`washing-machine`},{kind:`numeric`,field:`progress`,quantity:F(`the cycle progress`,`l’avanzamento del lavaggio`),label:F(`Progress`,`Avanzamento`),unit:`%`,icon:`loader`},{kind:`boolean`,field:`doorOpen`,label:F(`Door open`,`Sportello aperto`),whenTrue:F(`When the door of {device} opens`,`Quando si apre lo sportello di {device}`),whenFalse:F(`When the door of {device} closes`,`Quando si chiude lo sportello di {device}`),icon:`door-open`},{kind:`boolean`,field:`filterCleaningDue`,label:F(`Filter cleaning due`,`Pulizia filtro da fare`),whenTrue:F(`When {device} asks for its filter to be cleaned`,`Quando {device} chiede di pulire il filtro`),whenFalse:F(`When the filter reminder of {device} clears`,`Quando l’avviso filtro di {device} rientra`),icon:`funnel`},{kind:`boolean`,field:`machineCareDue`,label:F(`Machine care due`,`Manutenzione da fare`),whenTrue:F(`When {device} asks for a machine-care cycle`,`Quando {device} chiede un ciclo di manutenzione`),whenFalse:F(`When the machine-care reminder of {device} clears`,`Quando l’avviso di manutenzione di {device} rientra`),icon:`wrench`}]}},CN=`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(`.`),wN=`audio`,TN=[.3,.42,.55,.7,.85,1],EN=[`camstack`,`high-contrast`,`okabe-ito`];function dCe(e){return CN.includes(e)}function fCe(e){return EN.includes(e)}var DN={dark:`#0c0a09`,light:`#fafaf9`},pCe=7,mCe=20,hCe=[`live`,`heatmapScrub`],gCe=3,ON=/^#[0-9a-fA-F]{6}$/;function kN(e,t){return Number.parseInt(e.slice(t,t+2),16)}function AN(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function jN(e){let t=AN(kN(e,1)),n=AN(kN(e,3)),r=AN(kN(e,5));return .2126*t+.7152*n+.0722*r}function _Ce(e,t){if(!ON.test(e)||!ON.test(t))return 0;let n=Math.max(jN(e),jN(t)),r=Math.min(jN(e),jN(t));return(n+.05)/(r+.05)}function MN(e){let t=AN(kN(e,1)),n=AN(kN(e,3)),r=AN(kN(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 NN(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 vCe(e,t){if(!ON.test(e)||!ON.test(t))return 0;let n=MN(e),r=MN(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=NN(o,n.b),d=NN(s,r.b),f=0;c*l!==0&&(f=d-u,f>180?f-=360:f<-180&&(f+=360));let p=2*Math.sqrt(c*l)*Math.sin(f*Math.PI/360),m=(n.L+r.L)/2,h=(c+l)/2,g=u+d;c*l!==0&&(Math.abs(u-d)>180&&(g+=g<360?360:-360),g/=2);let _=1-.17*Math.cos((g-30)*Math.PI/180)+.24*Math.cos(2*g*Math.PI/180)+.32*Math.cos((3*g+6)*Math.PI/180)-.2*Math.cos((4*g-63)*Math.PI/180),ee=30*Math.exp(-(((g-275)/25)**2)),v=h**7,te=2*Math.sqrt(v/(v+25**7)),y=1+.015*(m-50)**2/Math.sqrt(20+(m-50)**2),ne=1+.045*h,re=1+.015*h*_,ie=-Math.sin(2*ee*Math.PI/180)*te,ae=r.L-n.L,b=l-c;return Math.sqrt((ae/y)**2+(b/ne)**2+(p/re)**2+b/ne*ie*(p/re))}var yCe={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`},bCe=[`#b34dc7`,`#1d7d34`,`#db6b6c`,`#a43d29`,`#0e6ee6`,`#29a10b`,`#a98731`,`#0181c6`],xCe={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`},SCe=[`#817f3b`,`#a0733e`,`#8658b2`,`#956301`,`#bc652d`,`#647331`,`#a14c9e`,`#d14e71`],CCe={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`},wCe=[`#9a3784`,`#a7392c`,`#409d50`,`#6987e7`,`#ee5b3d`,`#c0430d`,`#af79b3`,`#4b6628`],PN=l().regex(/^#[0-9a-f]{6}$/),FN=i(`form`,[x({form:p(`solid`),hex:PN}),x({form:p(`gradient`),hex:PN,alphas:C(n().gt(0).lte(1)).length(TN.length)})]),IN=x({status:p(`ready`),presetId:S(EN),customized:y(),source:S([`stored`,`unconfigured`]),swatches:m(l(),FN),fallbacks:C(PN).length(8)}),LN=i(`status`,[IN,x({status:p(`unknown`),reason:l()})]),RN=h([x({presetId:l()}),x({presetId:l(),overrides:m(l(),FN)})]),zN=x({presetId:l(),overrides:m(l(),FN)});function TCe(e){return{form:`solid`,hex:e}}function ECe(e){return{form:`gradient`,hex:e,alphas:[...TN]}}function DCe(e){let t={};for(let n of CN){let r=e[n];if(r===void 0)throw Error(`palette table missing ${n}`);t[n]=n===`audio`?ECe(r):TCe(r)}return t}function BN(e,t,n,r){return{id:e,name:t,swatches:DCe(n),fallbacks:r}}var VN=[BN(`camstack`,`CamStack`,yCe,bCe),BN(`high-contrast`,`High contrast`,xCe,SCe),BN(`okabe-ito`,`Colour-blind safe`,CCe,wCe)];function HN(e){return VN.find(t=>t.id===e)}function UN(){let e=HN(`camstack`);if(e===void 0)throw Error(`CamStack preset missing`);return OCe(e,`unconfigured`,!1)}function OCe(e,t,n){return{status:`ready`,presetId:e.id,customized:n,source:t,swatches:e.swatches,fallbacks:[...e.fallbacks]}}function kCe(e){return e.hex}function ACe(e,t){let n=[];for(let t of CN){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 jCe(e){let t=e[wN];return t===void 0||t.form===`gradient`&&TN.every((e,n)=>t.alphas[n]===e)?[]:[{code:`bad-gradient`,entry:wN}]}function MCe(e,t){let n=hCe;return n.includes(e)&&n.includes(t)}function WN(e,t){let n=[];for(let t of CN)e[t]===void 0&&n.push({code:`missing-entry`,entry:t});for(let t of Object.keys(e))dCe(t)||n.push({code:`unknown-entry`,entry:t});t.length!==8&&n.push({code:`bad-fallbacks`}),n.push(...jCe(e));let r=ACe(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=vCe(i.hex,a.hex);o<(MCe(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=_Ce(e.hex,DN[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 NCe(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 GN(e){return e.map(NCe).join(`; `)}var KN=class extends Error{violations;constructor(e){super(GN(e)),this.name=`PaletteRejectedError`,this.violations=e}};function qN(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 JN(e,t,n){let r=n.trim().toLowerCase();if(r.startsWith(`audio-`)){let n=e[wN];return n===void 0?qN(r,t):n.hex}let i=e[r];return i===void 0?qN(r,t):i.hex}function YN(e,t){return{...e,...t}}function PCe(e){return`overrides`in e?e.overrides:{}}function FCe(e){let t=HN(e.presetId);if(t===void 0||!fCe(e.presetId))throw new KN([{code:`unknown-preset`,presetId:e.presetId}]);let n=PCe(e),r=YN(t.swatches,n),i=WN(r,t.fallbacks);if(!i.ok)throw new KN(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 ICe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.keys(e).length===0}function LCe(e){if(e==null||ICe(e))return UN();let t=zN.safeParse(e);if(!t.success)return{status:`unknown`,reason:`stored palette is unreadable`};let n=HN(t.data.presetId);if(n===void 0)return{status:`unknown`,reason:`unknown preset ${t.data.presetId}`};let r=YN(n.swatches,t.data.overrides),i=WN(r,n.fallbacks);if(!i.ok)return{status:`unknown`,reason:GN(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 RCe(e,t){return{presetId:e.presetId,overrides:{...t}}}var zCe=x({id:l(),name:l(),swatches:m(l(),FN),fallbacks:C(l())}),XN={name:`display-palette`,scope:`system`,mode:`singleton`,methods:{getPalette:A(v(),LN,{auth:`protected`,role:`viewer`}),listPresets:A(v(),C(zCe).readonly(),{auth:`protected`,role:`viewer`}),setPalette:A(RN,IN,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the cluster display palette — one colour table for every client, not a device action`}},ZN=x({enabled:y().nullable().meta({label:`Do not disturb`}),lastChangedAt:n()}),QN={name:`do-not-disturb`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.MediaPlayer],methods:{setEnabled:A(x({deviceId:n().int(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`dnd.on`,label:F(`Do not disturb on`,`Attiva Non disturbare`),phrase:F(`Turn on Do not disturb on {device}`,`Attiva Non disturbare su {device}`),icon:`bell-off`,args:{enabled:!0}},{id:`dnd.off`,label:F(`Do not disturb off`,`Disattiva Non disturbare`),phrase:F(`Turn off Do not disturb on {device}`,`Disattiva Non disturbare su {device}`),icon:`bell`,args:{enabled:!1}}]})},status:{schema:ZN,kind:`push`},runtimeState:ZN,durability:`session`,history:{fields:{enabled:{kind:`boolean`}}},vocabulary:{noun:F(`Do not disturb`,`Non disturbare`),order:2160,state:[{kind:`boolean`,field:`enabled`,label:F(`Do not disturb`,`Non disturbare`),whenTrue:F(`When Do not disturb turns on on {device}`,`Quando {device} attiva Non disturbare`),whenFalse:F(`When Do not disturb turns off on {device}`,`Quando {device} disattiva Non disturbare`),icon:`bell-off`}]}},$N=2e3,BCe={version:1,targets:[{id:`pressed`,cardinality:`event`,shape:`pulse`,vocabulary:{cap:`doorbell`,eventName:`onPressed`},deviceTypes:[E.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:$N,changedAtRequired:!0},sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!0}]},eP=x({lastPressedAt:n().nullable(),pressCountSinceStart:n().meta(N(`count`))}),tP=x({deviceId:n(),timestamp:n()}),nP={name:`doorbell`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Button,E.Camera],methods:{},events:{onPressed:{data:tP,fromState:{field:`lastPressedAt`,on:`advance`},trigger:{category:T.DoorbellOnPressed,label:F(`Rang`,`Ha suonato`),phrase:F(`When someone rings {device}`,`Quando qualcuno suona a {device}`),icon:`bell-ring`}}},status:{schema:eP,kind:`push`},runtimeState:eP,durability:`restored`,history:`none`,customize:BCe,vocabulary:{noun:F(`Doorbell`,`Campanello`),order:5270}},rP=x({embedding:C(n()),inferenceMs:n()}),iP=S([`image`,`text`]),aP=x({modelId:l(),tower:iP,nodeId:l(),crashes:n(),windowMs:n(),sinceMs:n(),lastReason:l()}),oP=x({modelId:l(),tower:iP,nodeId:l(),attempts:n(),sinceMs:n(),lastReason:l()}),sP=x({modelId:l(),embeddingDim:n(),ready:y(),nodeId:l().optional(),failedModels:C(aP).optional(),failedRequirements:C(oP).optional()}),cP=`embedding-model-failed`,lP=`embedding-requirements-unavailable`,uP=`embedding-requirements-failed`,dP=S([cP,lP,uP]);function fP(e,t){return`[${e} model=${t.modelId} tower=${t.tower} node=${t.nodeId}]`}function VCe(e){return Error(`${fP(cP,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 HCe(e,t){return Error(`${fP(lP,e)} ${e.modelId} (${e.tower} tower) on ${e.nodeId}: ${t}`)}function UCe(e){return Error(`${fP(uP,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 WCe=RegExp(`\\[(${cP}|${lP}|${uP}) model=([^\\s\\]]+) tower=(image|text) node=([^\\s\\]]+)\\]`);function pP(e){let t=e instanceof Error?e.message:String(e),n=WCe.exec(t);if(n===null)return null;let r=dP.safeParse(n[1]),i=iP.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 GCe(e){return mP(e)!==null}function mP(e){let t=pP(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 hP={name:`embedding-encoder`,scope:`system`,mode:`collection`,internal:!0,methods:{encode:A(x({crop:b(Uint8Array),width:n(),height:n()}),rP,{auth:`admin`}),encodeText:A(x({text:l(),modelId:l().min(1).optional()}),rP,{auth:`admin`}),getInfo:A(v(),sP,{auth:`admin`}),resetFailedModels:A(x({modelId:l().min(1).optional()}),x({cleared:C(l()),nodeId:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},gP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),_P=x({powerW:n().nullable().meta(N(`power`)),importKwh:n().nullable().meta(N(`energy`)),exportKwh:n().nullable().meta(N(`energy`)),importTodayKwh:n().nullable().meta(N(`energy`)),exportTodayKwh:n().nullable().meta(N(`energy`))}),vP=x({powerW:n().nullable().meta(N(`power`)),energyKwh:n().nullable().meta(N(`energy`)),todayKwh:n().nullable().meta(N(`energy`))}),yP=x({stateOfChargePct:n().nullable().meta(N(`percentage`)),storedKwh:n().nullable().meta(N(`energy`)),capacityKwh:n().nullable().meta(N(`energy`)),powerW:n().nullable().meta(N(`power`)),chargedKwh:n().nullable().meta(N(`energy`)),dischargedKwh:n().nullable().meta(N(`energy`)),chargedTodayKwh:n().nullable().meta(N(`energy`)),dischargedTodayKwh:n().nullable().meta(N(`energy`)),healthPct:n().nullable().meta(N(`percentage`))}),bP=x({solar:gP.nullable(),grid:_P.nullable(),house:vP.nullable(),heatPump:vP.nullable(),storage:yP.nullable(),lastFetchedAt:n()});function KCe(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 xP={name:`energy-system`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.EnergySystem],methods:{},status:{schema:bP,kind:`push`},runtimeState:bP,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:F(`Energy system`,`Sistema energetico`),order:4020}},qCe=S([`date`,`time`,`datetime`]),SP=x({value:l(),timestamp:y().optional(),lastFetchedAt:n()}),CP={name:`enum-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:SP,kind:`push`},runtimeState:SP,durability:`restored`,history:{fields:{value:{kind:`enum`,skipWhenSet:`timestamp`}}},volatileStateFields:[`lastFetchedAt`,`timestamp`],vocabulary:{noun:F(`State sensor`,`Sensore di stato`),order:5060,state:[{kind:`value`,field:`value`,label:F(`State`,`Stato`),icon:`list`}]}},wP=S([`warning`,`error`]),TP=x({code:l(),label:l(),severity:wP}),EP=x({active:y().nullable(),code:l().nullable(),label:l().nullable(),severity:wP,since:n().nullable(),faults:C(TP).optional(),lastFetchedAt:n()}),DP={active:null,code:null,label:null,severity:`error`,since:null,lastFetchedAt:0},OP={name:`error`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},status:{schema:EP,kind:`push`,empty:DP},runtimeState:EP,durability:`restored`,volatileStateFields:[`lastFetchedAt`],history:`none`,vocabulary:{noun:F(`Fault`,`Guasto`),order:5265,state:[{kind:`boolean`,field:`active`,label:F(`Fault`,`Guasto`),whenTrue:F(`When {device} reports a fault`,`Quando {device} segnala un guasto`),whenFalse:F(`When the fault of {device} clears`,`Quando il guasto di {device} si risolve`),icon:`triangle-alert`}]}},kP=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),JCe=x({id:l(),source:S([`detected`,`photo`]),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),faceBbox:AS.optional()}),YCe=x({sampleId:l(),enrolledAt:n().int(),deviceId:n().int().optional(),source:S([`detected`,`photo`]),mediaId:n().int().optional(),comparable:y(),selfMean:n().nullable(),bestForeign:x({identityId:l(),name:l(),score:n()}).optional(),suspicion:n()}),XCe=x({identityId:l(),name:l(),modelId:l(),totalSamples:n().int(),comparableSamples:n().int(),flagged:n().int(),flagThreshold:n(),rows:C(YCe).readonly()}),AP=x({faceId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),recognizedIdentityId:l().optional(),identityName:l().optional(),assigned:y(),base64:l().optional(),cropUrl:l().optional(),faceBbox:AS.optional(),keyFrameMediaId:n().int().optional(),bestMatchScore:n().optional(),nativeFaceShortSidePx:n().optional(),suggestedIdentityId:l().optional(),suggestedMatchScore:n().optional()}),ZCe=S([`unassigned`,`recognized`,`identified`,`all`]),QCe=S([`timestamp`,`suggestionConfidence`]),$Ce=S([`asc`,`desc`]),ewe=x({faceIds:C(l()).readonly(),representativeFaceId:l(),size:n().int(),cohesion:n()}),twe=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),jP={name:`face-gallery`,role:{feature:`face-assignment`},scope:`system`,mode:`singleton`,methods:{listIdentities:A(x({includeCrops:y().optional()}).optional(),C(kP).readonly(),{role:`viewer`}),createIdentity:A(x({name:l().min(1)}),kP,{kind:`mutation`,auth:`admin`}),renameIdentity:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteIdentity:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listIdentitySamples:A(x({identityId:l()}),C(JCe).readonly()),auditIdentitySamples:A(x({identityId:l().min(1)}),XCe,{auth:`admin`}),removeSample:A(x({identityId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveIdentitySample:A(x({sampleId:l().min(1),toIdentityId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),listRecentFaces:A(x({deviceId:n().int().optional(),deviceIds:C(n().int()).optional(),limit:n().int().positive().optional(),filter:ZCe.optional(),since:n().int().optional(),until:n().int().optional(),sortBy:QCe.optional(),sortDirection:$Ce.optional(),includeCrops:y().optional()}).optional(),C(AP).readonly()),getFaceByTrack:A(x({deviceId:n().int(),trackId:l()}),AP.nullable(),{role:`viewer`}),getFaceMedia:A(x({faceId:l()}),C(twe).readonly()),assignFace:A(x({faceId:l(),identityId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),deleteFace:A(x({faceId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignFaces:A(x({faceIds:C(l()).min(1),identityId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignFaces:A(x({faceIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),suggestFaceClusters:A(x({threshold:n().min(0).max(1).optional(),minClusterSize:n().int().min(2).optional(),maxClusters:n().int().positive().optional(),limit:n().int().positive().optional(),maxFacesScanned:n().int().positive().optional()}).optional(),C(ewe).readonly())},vocabulary:{notOperatorFacing:`the face gallery — curated on its own page`}},MP=x({reason:l(),count:n().int().nonnegative()}),NP=x({family:l(),deviceId:n().int().positive(),variant:l().optional(),sinceMs:n(),atMs:n(),attempts:n().int().nonnegative(),succeeded:n().int().nonnegative(),reasons:C(MP).readonly()}),PP={name:`failure-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(NP).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},FP=S([`forward`,`reverse`]),IP=[`horizontal`,`vertical`],LP=S(IP),RP=[`oscillating`,`angle`,`sweepFrom`,`sweepTo`],zP=S(RP),BP=[`min`,`max`,`step`],VP=x({oscillating:y().nullable().default(null),angle:n().nullable().default(null),sweepFrom:n().nullable().default(null),sweepTo:n().nullable().default(null),min:n().nullable().default(null),max:n().nullable().default(null),step:n().nullable().default(null)}),HP=x({horizontal:VP.nullable().default(null),vertical:VP.nullable().default(null)}),UP=[`nothing-to-set`,`axis-not-linked`,`out-of-range`,`source-gone`,`source-unknown`,`source-call-failed`],WP=S(UP),GP=i(`status`,[x({status:p(`applied`)}),x({status:p(`refused`),reason:WP,field:zP.optional(),detail:l(),applied:C(zP)})]),KP=x({deviceId:n().int().nonnegative(),axis:LP,oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()});function qP(e,t){return`oscillationAxes.${e}.${t}`}var JP=x({speed:n().min(0).max(100).nullable().meta(N(`percentage`)),percentageStep:n().positive().optional().meta(N(`percentage`)),preset:l(),availablePresets:C(l()),direction:FP.nullable(),oscillating:y().nullable(),oscillationAxes:HP.optional(),lastChangedAt:n()});function nwe(e){let t=e.oscillationAxes;if(t===void 0)return e.oscillating;let n=IP.flatMap(e=>{let n=t[e]?.oscillating;return n==null?[]:[n]});return n.length===0?e.oscillating:n.some(Boolean)}var YP=[E.Fan],XP=`oscillation-axes`;function rwe(e){return{id:`${e}-oscillating`,cardinality:`scalar`,vocabulary:{cap:`fan-control`,stateField:`oscillating`},deviceTypes:YP,apply:`replace`,section:XP,path:qP(e,`oscillating`),sources:[{kind:`switch`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}}function ZP(e,t){let n={id:`${e}-${t}`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:YP,apply:`replace`,section:XP,path:qP(e,t),sources:[{kind:`numeric`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}};return t===`angle`?{...n,companions:BP.map(t=>({kind:`source-field`,path:qP(e,t),field:t}))}:n}var iwe=IP.flatMap(e=>[rwe(e),ZP(e,`angle`),ZP(e,`sweepFrom`),ZP(e,`sweepTo`)]),awe={id:`preset`,cardinality:`scalar`,vocabulary:{cap:`fan-control`},deviceTypes:YP,apply:`replace`,path:`preset`,sources:[{kind:`field`,valueKinds:[`string`],transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}},QP=[...iwe,awe],owe={version:1,overridable:QP.map(e=>({path:e.path,by:e.id})),targets:QP},$P={name:`fan-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Fan],methods:{setPercentage:j(x({deviceId:n().int().nonnegative(),speed:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.off`,label:F(`Fan off`,`Ventilatore spento`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`power-off`,effect:{field:`speed`,value:0},args:{speed:0}},{id:`fan.full`,label:F(`Fan full`,`Ventilatore al massimo`),phrase:F(`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:F(`Set speed`,`Imposta la velocità`),phrase:F(`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:F(`Speed`,`Velocità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setPreset:j(x({deviceId:n().int().nonnegative(),preset:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.preset`,label:F(`Set preset`,`Imposta il preset`),phrase:F(`Set {device} to preset {preset}`,`Imposta {device} sul preset {preset}`),icon:`list`,effect:{field:`preset`,fromArg:`preset`},openArgs:[{key:`preset`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`status`,field:`availablePresets`}}]}]}),setDirection:j(x({deviceId:n().int().nonnegative(),direction:FP}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.forward`,label:F(`Spin forward`,`Rotazione avanti`),phrase:F(`Spin {device} forward`,`Fai girare {device} in avanti`),icon:`refresh-cw`,effect:{field:`direction`,value:`forward`},args:{direction:`forward`}},{id:`fan.reverse`,label:F(`Spin in reverse`,`Rotazione inversa`),phrase:F(`Spin {device} in reverse`,`Fai girare {device} al contrario`),icon:`rotate-ccw`,effect:{field:`direction`,value:`reverse`},args:{direction:`reverse`}}]}),setOscillating:j(x({deviceId:n().int().nonnegative(),oscillating:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`fan.oscillateOn`,label:F(`Oscillate`,`Oscillazione attiva`),phrase:F(`Make {device} oscillate`,`Fai oscillare {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!0},args:{oscillating:!0}},{id:`fan.oscillateOff`,label:F(`Stop oscillating`,`Oscillazione spenta`),phrase:F(`Stop {device} oscillating`,`Ferma l’oscillazione di {device}`),icon:`move-horizontal`,effect:{field:`oscillating`,value:!1},args:{oscillating:!1}}]}),setOscillationAxis:j(KP,GP,{kind:`mutation`,auth:`protected`,actions:[{id:`fan.horizontalOscillateOn`,label:F(`Horizontal oscillation on`,`Oscillazione orizzontale attiva`),phrase:F(`Start the horizontal oscillation of {device}`,`Attiva l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!0}},{id:`fan.horizontalOscillateOff`,label:F(`Horizontal oscillation off`,`Oscillazione orizzontale spenta`),phrase:F(`Stop the horizontal oscillation of {device}`,`Ferma l’oscillazione orizzontale di {device}`),icon:`move-horizontal`,args:{axis:`horizontal`,oscillating:!1}},{id:`fan.verticalOscillateOn`,label:F(`Vertical oscillation on`,`Oscillazione verticale attiva`),phrase:F(`Start the vertical oscillation of {device}`,`Attiva l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!0}},{id:`fan.verticalOscillateOff`,label:F(`Vertical oscillation off`,`Oscillazione verticale spenta`),phrase:F(`Stop the vertical oscillation of {device}`,`Ferma l’oscillazione verticale di {device}`),icon:`move-vertical`,args:{axis:`vertical`,oscillating:!1}}]})},status:{schema:JP,kind:`push`},runtimeState:JP,customize:owe,durability:`session`,history:{fields:{speed:{kind:`gauge`,unit:`%`,minIntervalMs:0},oscillating:{kind:`boolean`}}},vocabulary:{noun:F(`Fan`,`Ventilatore`),order:1080,state:[{kind:`numeric`,field:`speed`,quantity:F(`the speed`,`la velocità`),label:F(`Speed`,`Velocità`),unit:`%`,icon:`fan`},{kind:`boolean`,field:`oscillating`,label:F(`Oscillating`,`Oscillazione`),whenTrue:F(`When {device} starts oscillating`,`Quando {device} inizia a oscillare`),whenFalse:F(`When {device} stops oscillating`,`Quando {device} smette di oscillare`),icon:`move-horizontal`}]}},swe=12,eF=x({oscillating:y().optional(),angle:n().optional(),sweepFrom:n().optional(),sweepTo:n().optional()}),tF=x({speed:n().min(0).max(100).optional(),preset:l().min(1).optional(),direction:FP.optional(),oscillationAxes:x({horizontal:eF.optional(),vertical:eF.optional()}).optional()}),nF=x({id:l().min(1).max(64),name:l().trim().min(1).max(40),state:tF}),rF=[`empty-state`,`duplicate-name`,`duplicate-id`,`too-many`,`not-a-fan`],iF=S(rF),aF=i(`status`,[x({status:p(`saved`),count:n().int().nonnegative()}),x({status:p(`refused`),reason:iF,detail:l()})]),oF=x({field:l(),outcome:S([`applied`,`failed`,`not-run`,`refused`]),message:l().optional()}),sF=x({status:S([`applied`,`partial`,`refused`]),fields:C(oF)}),cF=[`speed`,`direction`,`preset`,`oscillationAxes`],lF=S(cF),uF=x({what:l(),reason:l()}),dF=x({state:tF,omitted:C(uF)}),fF=x({deviceId:n().int().nonnegative()}),cwe={version:1,targets:[{id:`presets`,cardinality:`config`,vocabulary:{cap:`fan-presets`},deviceTypes:[E.Fan],apply:`add`,readMethod:`getPresets`,writeMethod:`setPresets`}]},pF={name:`fan-presets`,scope:`system`,mode:`singleton`,methods:{getPresets:A(fF,C(nF),{auth:`protected`}),setPresets:A(fF.extend({presets:C(nF).max(12)}),aF,{kind:`mutation`,auth:`admin`}),applyPreset:A(fF.extend({presetId:l().min(1)}),sF,{kind:`mutation`,auth:`protected`}),capturePreset:A(fF.extend({fields:C(lF).optional()}),dF,{auth:`protected`})},customize:cwe,vocabulary:{notOperatorFacing:`the per-fan presets — authored in the Customize presets editor, applied through the actions the exports list`}},mF=x({flags:m(l(),w()),deviceType:l().nullable(),model:l().nullable(),channelCount:n().nullable().meta(N(`count`)),lastProbedAt:n(),lastFetchedAt:n()}),hF={name:`feature-probe`,scope:`device`,deviceNative:!0,mode:`singleton`,methods:{},events:{onProbeChanged:{data:x({deviceId:n(),status:mF}),notOperatorFacing:`the device’s capabilities were re-probed — plumbing, not a happening`}},status:{schema:mF,kind:`push`},runtimeState:mF,durability:`session`,history:`none`,vocabulary:{noun:F(`Feature probe`,`Rilevamento funzioni`),order:3120}},lwe=x({name:l(),path:l()}),uwe=x({path:l(),entries:C(lwe).readonly(),freeBytes:n(),totalBytes:n()}),gF={name:`filesystem-browse`,scope:`system`,mode:`singleton`,internal:!0,methods:{listAllowedRoots:A(v(),C(l()).readonly(),{auth:`admin`}),browse:A(x({path:l()}),uwe,{auth:`admin`}),createDir:A(x({path:l()}),x({path:l()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},_F=x({flooded:y(),lastChangedAt:n()}),vF={name:`flood`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:_F,kind:`push`},runtimeState:_F,durability:`restored`,history:{fields:{flooded:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Leak sensor`,`Sensore di allagamento`),order:5070,state:[{kind:`boolean`,field:`flooded`,label:F(`Leak`,`Perdita`),whenTrue:F(`When {device} detects a leak`,`Quando {device} rileva una perdita`),whenFalse:F(`When {device} is dry again`,`Quando {device} torna asciutto`),icon:`droplets`}]}},yF=x({detected:y(),lastChangedAt:n()}),bF={name:`gas`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:yF,kind:`push`},runtimeState:yF,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Gas sensor`,`Sensore di gas`),order:5080,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects gas`,`Quando {device} rileva gas`),whenFalse:F(`When the gas clears on {device}`,`Quando il gas su {device} rientra`),icon:`flame`}]}},xF=x({active:y().meta({label:`Active`}),lastChangedAt:n()}),SF={name:`group-active`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:xF,kind:`push`},runtimeState:xF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group state`,`Stato del gruppo`),order:5090}},CF=x({deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),ok:y(),error:l().optional(),at:n()}),wF=x({results:C(CF)}),TF={name:`group-commands`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:wF,kind:`push`},runtimeState:wF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group command`,`Comando di gruppo`),order:5100}},EF=x({included:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Reporting`})),excluded:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Excluded`})),total:n().int().nonnegative().meta(N(`count`,{precision:0,label:`Members`}))}),DF={name:`group-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Switch,E.Light,E.Fan,E.Cover,E.Valve,E.Lock,E.MediaPlayer,E.Climate],methods:{},status:{schema:EF,kind:`push`},runtimeState:EF,durability:`session`,history:`none`,vocabulary:{noun:F(`Group`,`Gruppo`),order:5110,state:[{kind:`numeric`,field:`included`,quantity:F(`the members reporting`,`i membri che rispondono`),label:F(`Reporting`,`Rispondono`),icon:`users`},{kind:`numeric`,field:`excluded`,quantity:F(`the members left out`,`i membri esclusi`),label:F(`Excluded`,`Esclusi`),icon:`users`},{kind:`numeric`,field:`total`,quantity:F(`the member count`,`il numero di membri`),label:F(`Members`,`Membri`),icon:`sigma`}]}},OF=n().int().nonnegative(),kF=l().min(1),AF=l().min(1),jF=n().finite(),MF={key:`circuitId`,label:F(`Circuit`,`Circuito`),offer:{kind:`dynamic`,from:`status`,cap:`heat-pump-status`,field:`circuits`,valueKey:`id`,labelKey:`label`,where:{key:`kind`,equals:`heating`}}},NF={...MF,label:F(`Hot water circuit`,`Circuito acqua calda`),offer:{...MF.offer,where:{key:`kind`,equals:`dhw`}}},PF={key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`text`}},dwe={key:`level`,label:F(`Level`,`Livello`),offer:{kind:`text`}},FF={key:`temp`,label:F(`Temperature`,`Temperatura`),offer:{kind:`number`,step:.5,unit:`°C`}},fwe={key:`minutes`,label:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}},IF={name:`heat-pump-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{setSilentMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.silent`,label:F(`Set silent mode`,`Imposta la modalità silenziosa`),phrase:F(`Set silent mode of {device} to {mode}`,`Imposta la modalità silenziosa di {device} su {mode}`),icon:`volume-x`,openArgs:[{key:`mode`,label:F(`Silent mode`,`Modalità silenziosa`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`auto`,label:F(`Auto`,`Auto`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAwayMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.away`,label:F(`Set away mode`,`Imposta la modalità assente`),phrase:F(`Set away mode of {device} to {mode}`,`Imposta la modalità assente di {device} su {mode}`),icon:`plane`,openArgs:[{key:`mode`,label:F(`Away mode`,`Modalità assente`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`on`,label:F(`On`,`On`)}]}}]}]}),setAdditionalHeaterMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.additionalHeater`,label:F(`Set additional heater`,`Imposta il riscaldatore aggiuntivo`),phrase:F(`Set the additional heater of {device} to {mode}`,`Imposta il riscaldatore aggiuntivo di {device} su {mode}`),icon:`flame`,openArgs:[{key:`mode`,label:F(`Additional heater`,`Riscaldatore aggiuntivo`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`manual`,label:F(`Manual`,`Manuale`)},{value:`auto`,label:F(`Auto`,`Auto`)}]}}]}]}),setHolidayMode:A(x({deviceId:OF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.holiday`,label:F(`Set holiday mode`,`Imposta la modalità vacanza`),phrase:F(`Set holiday mode of {device} to {mode}`,`Imposta la modalità vacanza di {device} su {mode}`),icon:`tree-palm`,openArgs:[{key:`mode`,label:F(`Holiday programme`,`Programma vacanza`),offer:{kind:`enum`,values:[{value:`off`,label:F(`Off`,`Off`)},{value:`hm1`,label:F(`Programme 1`,`Programma 1`)},{value:`hm2`,label:F(`Programme 2`,`Programma 2`)},{value:`hm3`,label:F(`Programme 3`,`Programma 3`)},{value:`hm4`,label:F(`Programme 4`,`Programma 4`)},{value:`hm5`,label:F(`Programme 5`,`Programma 5`)},{value:`hm6`,label:F(`Programme 6`,`Programma 6`)},{value:`hm7`,label:F(`Programme 7`,`Programma 7`)},{value:`hm8`,label:F(`Programme 8`,`Programma 8`)}]}}]}]}),setCircuitOperationMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitOperationMode`,label:F(`Set circuit operation mode`,`Imposta la modalità del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`thermometer`,openArgs:[MF,PF]}]}),setCircuitHeatCoolMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitHeatCoolMode`,label:F(`Set circuit heat / cool`,`Imposta caldo / freddo del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun-snow`,openArgs:[MF,PF]}]}),setCircuitSummerWinter:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitSummerWinter`,label:F(`Set circuit summer / winter`,`Imposta estate / inverno del circuito`),phrase:F(`Set {circuitId} of {device} to {mode}`,`Imposta {circuitId} di {device} su {mode}`),icon:`sun`,openArgs:[MF,PF]}]}),setCircuitComfortSetpoint:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitComfortSetpoint`,label:F(`Set comfort temperature`,`Imposta la temperatura comfort`),phrase:F(`Set the comfort temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura comfort di {circuitId} su {device} a {temp}`),icon:`thermometer-sun`,openArgs:[MF,FF]}]}),setCircuitEcoSetpoint:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitEcoSetpoint`,label:F(`Set eco temperature`,`Imposta la temperatura eco`),phrase:F(`Set the eco temperature of {circuitId} on {device} to {temp}`,`Imposta la temperatura eco di {circuitId} su {device} a {temp}`),icon:`leaf`,openArgs:[MF,FF]}]}),setCircuitMaxFlowTemp:A(x({deviceId:OF,circuitId:kF,temp:jF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.circuitMaxFlowTemp`,label:F(`Set maximum flow temperature`,`Imposta la temperatura massima di mandata`),phrase:F(`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:[MF,FF]}]}),setDhwOperationMode:A(x({deviceId:OF,circuitId:kF,mode:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwOperationMode`,label:F(`Set hot water mode`,`Imposta la modalità acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to {mode}`,`Imposta l'acqua calda {circuitId} di {device} su {mode}`),icon:`shower-head`,openArgs:[NF,PF]}]}),setDhwTemperatureLevel:A(x({deviceId:OF,circuitId:kF,level:AF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwTemperatureLevel`,label:F(`Set hot water level`,`Imposta il livello acqua calda`),phrase:F(`Set hot water {circuitId} of {device} to level {level}`,`Imposta l'acqua calda {circuitId} di {device} al livello {level}`),icon:`droplet`,openArgs:[NF,dwe]}]}),setDhwChargeDuration:A(x({deviceId:OF,circuitId:kF,minutes:n().int().positive()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.dhwChargeDuration`,label:F(`Set hot water charge duration`,`Imposta la durata della carica acqua calda`),phrase:F(`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:[NF,fwe]}]}),startExtraHotWater:A(x({deviceId:OF,circuitId:kF}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`heatPump.extraHotWater`,label:F(`Start extra hot water`,`Avvia acqua calda extra`),phrase:F(`Start an extra hot water charge of {circuitId} on {device}`,`Avvia una carica extra di acqua calda {circuitId} su {device}`),icon:`droplets`,openArgs:[NF]}]})},vocabulary:{noun:F(`Heat pump settings`,`Impostazioni pompa di calore`),order:4010}},LF=[`heating`,`dhw`,`cooling`,`solar`],RF=S(LF),zF=x({value:l().nullable(),allowed:C(l())}),BF=x({value:n().nullable(),min:n().nullable(),max:n().nullable(),step:n().nullable()}),VF=x({id:l().min(1),kind:RF,label:l(),icon:xh,currentTemp:n().nullable().meta(N(`temperature`)),targetTemp:n().nullable().meta(N(`temperature`)),mode:l().nullable(),active:y().nullable(),operationMode:zF.nullable(),heatCoolMode:zF.nullable(),summerWinter:zF.nullable(),comfortSetpoint:BF.nullable(),ecoSetpoint:BF.nullable(),maxFlowTemp:BF.nullable(),temperatureLevel:zF.nullable(),chargeDuration:BF.nullable(),extraHotWater:y().nullable()}),HF=x({silent:zF.nullable(),away:zF.nullable(),additionalHeater:zF.nullable(),holiday:zF.nullable()}),UF=x({thermalW:n().nullable().meta(N(`power`)),electricalW:n().nullable().meta(N(`power`)),compressorPct:n().nullable().meta(N(`percentage`))}),WF=x({supply:n().nullable().meta(N(`temperature`)),return:n().nullable().meta(N(`temperature`)),outdoor:n().nullable().meta(N(`temperature`))}),GF=x({thermalKwh:n().nullable().meta(N(`energy`)),electricalKwh:n().nullable().meta(N(`energy`))}),KF=x({circuits:C(VF),system:HF,power:UF,temperatures:WF,energy:GF,waterPressureBar:n().nullable(),starts:n().nullable(),lastFetchedAt:n()});function qF(e){let{thermalW:t,electricalW:n}=e;return t===null||n===null||n<=0?null:t/n}var JF={name:`heat-pump-status`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.HeatPump],methods:{},status:{schema:KF,kind:`push`},runtimeState:KF,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:F(`Heat pump`,`Pompa di calore`),order:4e3}},YF=x({position:n().min(0).max(100).nullable().meta(N(`percentage`)),lastFetchedAt:n()}),XF={name:`heating-valve`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Climate],methods:{},status:{schema:YF,kind:`push`},runtimeState:YF,durability:`session`,history:{fields:{position:{kind:`gauge`,unit:`%`,deadband:1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Radiator valve`,`Valvola termostatica`),order:1110,state:[{kind:`numeric`,field:`position`,quantity:F(`the valve opening`,`l’apertura della valvola`),label:F(`Valve opening`,`Apertura della valvola`),unit:`%`,icon:`heater`}]}},ZF=S([`s`,`min`]),pwe=S([`switch`,`pet-fountain`]),QF={actuator:`switch`,maxSeconds:10800,unit:`min`,quickRunDefault:30},$F={actuator:`pet-fountain`,maxSeconds:300,unit:`s`,quickRunDefault:60},eI=[E.Switch,E.PetFountain],tI={[E.Switch]:[O.SwitchHeater]};function nI(e,t){return e===E.PetFountain?$F:e===E.Switch&&t===O.SwitchHeater?QF:null}var mwe=1e3,hwe=6e4;function rI(e,t,n){let r=e-t;return r<=0?0:Math.max(1,Math.ceil(r/(n===`min`?hwe:mwe)))}function gwe(e,t){return t===`min`?e*60:e}function iI(e){return e.unit===`min`?Math.floor(e.maxSeconds/60):e.maxSeconds}var aI=x({duration:n().positive().finite(),unit:ZF});function oI(e,t){let n=iI(e);return{duration:Math.min((t!==null&&Number.isFinite(t)&&t>0?t:null)??e.quickRunDefault,n),unit:e.unit}}var sI=S([`unsupported-device`,`over-max`,`command-failed`]),cI=i(`ok`,[x({ok:p(!0),activeUntil:n()}),x({ok:p(!1),reason:sI,maxSeconds:n().nullable()})]),lI=x({activeUntil:n().nullable(),requestedBy:l().nullable(),quickRun:aI.nullable(),lastFetchedAt:n()}),uI=x({unit:ZF,maxDuration:n(),defaultDuration:n()}),dI=x({quickRunDuration:n().positive().finite().nullable().optional()}),fI={name:`timed-run`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:eI,deviceRoles:tI,deviceConfig:{ui:{kind:`derived-form`,builderId:`timed-run`,tab:`general`}},methods:{getOptions:A(x({deviceId:n().int()}),uI),setSettings:A(x({deviceId:n().int(),settings:dI}),v(),{kind:`mutation`,auth:`admin`}),runFor:A(x({deviceId:n().int(),duration:n().positive().finite(),unit:ZF}),cI,{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.runForMinutes`,label:F(`Run for minutes`,`Accendi per alcuni minuti`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:1,step:1,unit:`min`}}]},{id:`timedRun.runForSeconds`,label:F(`Run for seconds`,`Accendi per alcuni secondi`),phrase:F(`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:F(`Seconds`,`Secondi`),offer:{kind:`number`,min:1,step:1,unit:`s`}}]}]}),cancel:A(x({deviceId:n().int()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`timedRun.cancel`,label:F(`Cancel the timer`,`Annulla il timer`),phrase:F(`Cancel the pending switch-off of {device}`,`Annulla lo spegnimento programmato di {device}`),icon:`timer-off`}]})},status:{schema:lI,kind:`push`},runtimeState:lI,durability:`session`,history:`none`,vocabulary:{noun:F(`Timed run`,`Esecuzione a tempo`),order:2150}},pI=[`on`,`off`,`running`,`idle`,`standby`,`alert`,`offline`,`unknown`],mI=[`success`,`warning`,`danger`,`primary`,`info`,`muted`],hI=[`none`,`pulse`,`spin`,`glow`,`halo`,`wave`,`rise`,`fall`,`tumble`,`equalizer`,`blink`,`breathe`],gI=[`plain`,`heat-rise`,`cool-fall`,`glow`,`water`,`drum`,`sky`,`mist`,`alert-wash`],_I=S(pI),vI=S(mI),_we=S(hI),yI=x({icon:xh,tone:vI,background:S(gI),animation:_we});function bI(e){let t=RD[e];return t===void 0?null:`cap:${e}.${t.field}`}function vwe(e){return e.enabledCaps.flatMap(e=>{let t=bI(e),n=RD[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 xI=x({en:l(),it:l()}),SI={en:`—`,it:`—`};function ywe(e){return e.en===SI.en&&e.it===SI.it}var CI=[`temperature`,`humidity`,`power`,`contact`,`text`],wI=[`hot`,`mild`,`cold`],TI=[`updated`,`changed`],EI=x({value:n(),quantity:Ui}),DI=x({quantity:S(CI),reading:EI.nullable(),icon:xh.nullable(),value:xI,unit:l().nullable(),band:S(wI).nullable(),level:n().min(0).max(1).nullable(),word:xI,tone:S(mI),since:n().nullable(),sinceKind:S(TI),historyKey:l().nullable()}),bwe=3e3,OI=e=>F(e,e),kI=e=>Math.min(1,Math.max(0,e)),xwe=(e,t)=>String(Number(e.toFixed(t)));function AI(e){return e<12?`cold`:e>28?`hot`:`mild`}var Swe={hot:F(`Hot`,`Caldo`),mild:F(`Normal`,`Normale`),cold:F(`Cold`,`Freddo`)},Cwe={hot:`warning`,mild:`muted`,cold:`info`};function jI(e,t){let n=AI(e);return{quantity:`temperature`,reading:{value:e,quantity:`temperature`},icon:`thermometer`,value:OI(xwe(e,1)),unit:`°C`,band:n,level:null,word:Swe[n],tone:Cwe[n],since:t,sinceKind:`updated`,historyKey:bI(`temperature-sensor`)}}function MI(e,t){let n=e<30,r=e>70;return{quantity:`humidity`,reading:{value:e,quantity:`humidity`},icon:`droplets`,value:OI(String(Math.round(e))),unit:`%`,band:null,level:kI(e/100),word:n?F(`Dry`,`Secco`):r?F(`Humid`,`Umido`):F(`Normal`,`Normale`),tone:n||r?`warning`:`info`,since:t,sinceKind:`updated`,historyKey:bI(`humidity-sensor`)}}function NI(e,t){let n=e>0;return{quantity:`power`,reading:{value:e,quantity:`power`},icon:`zap`,value:OI(String(Math.round(e))),unit:`W`,band:null,level:kI(e/bwe),word:n?F(`Active`,`Attivo`):F(`Idle`,`Inattivo`),tone:n?`primary`:`muted`,since:t,sinceKind:`updated`,historyKey:bI(`power-meter`)}}function PI(e,t){return{quantity:`contact`,reading:null,icon:e?`door-open`:`door-closed`,value:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),unit:null,band:null,level:+!!e,word:e?F(`Open`,`Aperto`):F(`Closed`,`Chiuso`),tone:e?`warning`:`success`,since:t,sinceKind:`changed`,historyKey:null}}function FI(e,t){return{quantity:`text`,reading:null,icon:null,value:OI(e),unit:null,band:null,level:null,word:F(`Changed`,`Cambiato`),tone:`muted`,since:t,sinceKind:`updated`,historyKey:null}}var wwe={temperature:{icon:`thermometer`,unit:`°C`,sinceKind:`updated`,historyKey:bI(`temperature-sensor`)},humidity:{icon:`droplets`,unit:`%`,sinceKind:`updated`,historyKey:bI(`humidity-sensor`)},power:{icon:`zap`,unit:`W`,sinceKind:`updated`,historyKey:bI(`power-meter`)},contact:{icon:null,unit:null,sinceKind:`changed`,historyKey:null},text:{icon:null,unit:null,sinceKind:`updated`,historyKey:null}};function II(e){let t=wwe[e];return{quantity:e,reading:null,icon:t.icon,value:SI,unit:t.unit,band:null,level:null,word:SI,tone:`muted`,since:null,sinceKind:t.sinceKind,historyKey:t.historyKey}}var Twe={power:new Set([`energy-sensor`,`voltage-sensor`,`current-sensor`])};function LI(e,t){return t===null?!0:!(Twe[e.quantity]?.has(t)??!1)}var RI=`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(`.`),Ewe=S(RI),zI=[`cool`,`heat`,`dry`,`fan`,`auto`,`playing`,`paused`,`open`,`closed`],BI=x({id:Ewe,mode:S(zI).nullable(),level:n().min(0).max(1).nullable()}),VI={[E.Camera]:`camera`,[E.Light]:`light`,[E.Siren]:`siren`,[E.Switch]:`plug`,[E.Sensor]:`sensor-sparkline`,[E.Climate]:`thermostat`,[E.Button]:`button`,[E.EventEmitter]:`event-stream`,[E.Update]:`update`,[E.Generic]:`generic`,[E.Notifier]:`event-stream`,[E.Script]:`event-stream`,[E.Automation]:`event-stream`,[E.Lock]:`lock`,[E.Cover]:`cover`,[E.Valve]:`control-dial`,[E.Humidifier]:`control-dial`,[E.WaterHeater]:`heater`,[E.HeatPump]:`heat-pump`,[E.EnergySystem]:`generic`,[E.Workload]:`generic`,[E.Fan]:`fan`,[E.MediaPlayer]:`tv`,[E.AlarmPanel]:`alarm`,[E.Control]:`control-dial`,[E.Presence]:`presence`,[E.Weather]:`weather`,[E.WeatherStation]:`weather`,[E.Vacuum]:`vacuum`,[E.LawnMower]:`lawn-mower`,[E.Container]:`generic`,[E.Image]:`camera`,[E.PetFeeder]:`pet-feeder`,[E.PetFountain]:`pet-fountain`,[E.Dishwasher]:`dishwasher`,[E.Washer]:`washer`,[E.Dryer]:`dryer`,[E.Gateway]:`gateway`},HI={[O.Siren]:`siren`,[O.Floodlight]:`light`,[O.Spotlight]:`light`,[O.PirSensor]:`presence`,[O.Chime]:`speaker`,[O.Autotrack]:`inherit`,[O.Nightvision]:`inherit`,[O.PrivacyMask]:`inherit`,[O.Doorbell]:`inherit`,[O.CoverBlind]:`inherit`,[O.CoverShutter]:`inherit`,[O.CoverAwning]:`inherit`,[O.CoverCurtain]:`inherit`,[O.CoverGarage]:`inherit`,[O.CoverGate]:`inherit`,[O.CoverDoor]:`inherit`,[O.CoverWindow]:`inherit`,[O.BinaryHelper]:`inherit`,[O.Outlet]:`plug`,[O.SwitchHeater]:`heater`,[O.SwitchFan]:`fan`,[O.SwitchLight]:`light`,[O.PoePort]:`plug`,[O.ClimateAc]:`ac`,[O.ClimateThermostat]:`inherit`,[O.ClimateFloor]:`inherit`,[O.ClimateRadiator]:`inherit`,[O.ClimateHeater]:`inherit`,[O.ClimateHeatPumpCircuit]:`inherit`,[O.MotionSensor]:`presence`,[O.ContactSensor]:`contact`,[O.LeakSensor]:`inherit`,[O.SmokeSensor]:`alarm`,[O.COSensor]:`alarm`,[O.GasSensor]:`alarm`,[O.TamperSensor]:`inherit`,[O.VibrationSensor]:`inherit`,[O.ConnectivitySensor]:`inherit`,[O.SoundSensor]:`inherit`,[O.BinarySensor]:`inherit`,[O.TemperatureSensor]:`sensor-sparkline`,[O.HumiditySensor]:`sensor-sparkline`,[O.AmbientLightSensor]:`inherit`,[O.PressureSensor]:`weather`,[O.WindSensor]:`weather`,[O.RainSensor]:`weather`,[O.UvSensor]:`weather`,[O.SolarRadiationSensor]:`weather`,[O.SoilMoistureSensor]:`inherit`,[O.PowerSensor]:`plug`,[O.EnergySensor]:`plug`,[O.VoltageSensor]:`plug`,[O.CurrentSensor]:`plug`,[O.AirQualitySensor]:`inherit`,[O.BatterySensor]:`inherit`,[O.NumericSensor]:`inherit`,[O.EnumSensor]:`inherit`,[O.DateTimeSensor]:`inherit`,[O.GenericSensor]:`inherit`,[O.NumericControl]:`control-dial`,[O.SelectControl]:`control-dial`,[O.TextControl]:`inherit`,[O.DateTimeControl]:`inherit`,[O.MobilePushNotifier]:`inherit`,[O.MessagingNotifier]:`inherit`,[O.EmailNotifier]:`inherit`,[O.GenericNotifier]:`inherit`,[O.IrTransmitter]:`inherit`,[O.Vm]:`inherit`,[O.AppContainer]:`inherit`,[O.Lxc]:`inherit`,[O.App]:`inherit`,[O.Host]:`inherit`,[O.Ups]:`inherit`};function Dwe(e){return Object.values(E).includes(e)}function Owe(e){return Object.values(O).includes(e)}function UI(e,t){let n=e!==null&&Owe(e)?HI[e]:void 0;return n!==void 0&&n!==`inherit`?n:Dwe(t)?VI[t]:`generic`}var WI=`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(`.`),GI=S(WI),kwe={progress:F(`Progress`,`Avanzamento`),"run-for":F(`Run for`,`Avvia per`),cycle:F(`Cycle`,`Ciclo`),program:F(`Program`,`Programma`),"appliance-power":F(`Appliance`,`Elettrodomestico`),"now-playing":F(`Now playing`,`In riproduzione`),playback:F(`Playback`,`Riproduzione`),volume:F(`Volume`,`Volume`),source:F(`Source`,`Sorgente`),contact:F(`Door`,`Porta`),"motion-trigger":F(`Motion`,`Movimento`),lock:F(`Lock`,`Serratura`),alarm:F(`Alarm`,`Allarme`),fan:F(`Fan`,`Ventola`),vacuum:F(`Cleaning`,`Pulizia`),"vacuum-suction":F(`Suction`,`Aspirazione`),mower:F(`Mowing`,`Taglio`),feeder:F(`Feed now`,`Eroga ora`),fountain:F(`Pump`,`Pompa`),"pump-cycle":F(`Pump cycle`,`Ciclo pompa`),automation:F(`Automation`,`Automazione`),script:F(`Script`,`Script`),"do-not-disturb":F(`Do not disturb`,`Non disturbare`),brightness:F(`Brightness`,`Luminosità`),color:F(`Colour`,`Colore`),cover:F(`Position`,`Posizione`),valve:F(`Valve`,`Valvola`),humidifier:F(`Humidifier`,`Umidificatore`),update:F(`Firmware`,`Firmware`),button:F(`Action`,`Azione`),"climate-mode":F(`Mode`,`Modalità`),"climate-fan":F(`Fan`,`Ventola`),setpoint:F(`Setpoint`,`Temperatura`),channel:F(`Channel`,`Canale`),control:F(`Control`,`Controllo`),circuit:F(`Circuit`,`Circuito`),"heat-pump-power":F(`Power`,`Potenza`),"system-mode":F(`Mode`,`Modalità`)},KI=a(()=>h([l(),n(),y(),m(l(),KI)])),Awe=m(l(),KI);function qI(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]:qI(o,i,n)}}function jwe(e,t,n){return qI(e,t.split(`.`),n)}var JI=x({cap:l(),method:l(),args:Awe}),Mwe=S([`off-while-running`,`unlock`,`install`,`press`]),YI=x({id:l(),label:xI,icon:xh,call:JI,emphasis:S([`primary`,`normal`]),confirm:Mwe.nullable()}),XI=i(`kind`,[x({kind:p(`action`),action:YI}),x({kind:p(`toggle`),id:l(),label:xI,on:y().nullable(),turnOn:YI,turnOff:YI}),x({kind:p(`slider`),id:l(),label:xI,value:n().nullable(),min:n(),max:n(),step:n(),unit:l(),call:JI,valueArg:l()}),x({kind:p(`picker`),id:l(),label:xI,current:l().nullable(),options:C(l()),optionLabels:m(l(),xI).optional(),call:JI,valueArg:l()}),x({kind:p(`number`),id:l(),label:xI,value:n().nullable(),step:n().nullable(),unit:l(),call:JI,valueArg:l()}),x({kind:p(`text`),id:l(),label:xI,value:l().nullable(),call:JI,valueArg:l()})]),Nwe=x({icon:xh.nullable(),text:xI,tone:vI}),Pwe=new Set([`cover`,`valve`,`lock`,`vacuum`,`playback`,`brightness`]),Fwe=x({id:GI,placement:S([`row`,`scene`]).optional(),label:xI.optional(),group:xI.optional(),pills:C(Nwe).optional(),icon:xh,status:xI.nullable(),controls:C(XI),progress:n().min(0).max(1).nullable().optional()}),ZI=x({label:xI,value:h([n(),l()]),unit:l().nullable()}),Iwe=x({id:S([`battery`,`network-link`,`integration`]),icon:xh,tone:vI,value:n().nullable(),label:xI}),QI=`remote.open`,Lwe=x({commands:n().int().nullable(),open:YI.optional()}),Rwe=x({items:C(x({key:l(),label:l(),level:n().nullable(),needsAttention:y()})),attention:n().int()}),zwe=i(`kind`,[x({kind:p(`power`),watts:n(),detail:C(ZI)}),x({kind:p(`running`),running:y().nullable(),since:n().nullable(),phase:l().nullable(),detail:C(ZI)})]),Bwe=x({source:S([`switch`,`media-player`,`climate-control`]),on:y().nullable(),assumed:y(),turnOn:YI,turnOff:YI}),Vwe=x({activeUntil:n().nullable(),quickRun:aI,run:YI,cancel:YI,remaining:n().nullable()}),Hwe=x({on:y().nullable(),confirmOffWhileRunning:y(),running:y().nullable(),powerOn:YI.nullable(),powerOff:YI.nullable(),restart:YI}),$I=x({token:S(gI),animation:S(hI)}),eL=x({id:S([`power`,`energy`,`battery`,`link`,`phase`,`remaining`,`volume`,`source`,`consumables`,`since`,`speed`,`progress`,`level`,`last-run`,`event`,`members`,`failures`,`reading`,`climate`,`temperature`,`humidity`,`pressure`,`air-quality`,`illuminance`,`valve`]),icon:xh.nullable(),text:xI,tone:vI}),tL=x({label:xI,value:xI,tone:vI.optional(),at:n().optional()}),Uwe=x({left:C(tL).max(2),right:C(tL).max(2)}),Wwe=i(`kind`,[x({kind:p(`artwork`),url:l(),fallback:$I}),x({kind:p(`state`),...$I.shape})]),Gwe=x({partId:l(),cap:l()}),Kwe=x({deviceId:n().int(),type:l(),role:l().nullable(),name:l(),state:_I,stateAssumed:y(),look:yI,background:Wwe,scene:BI,facts:C(eL),sideTiles:Uwe,title:xI,caption:xI.optional(),badges:C(Iwe),remote:Lwe.nullable(),historyLabel:xI,consumables:Rwe.nullable(),consumption:zwe.nullable(),ownPower:Bwe.nullable(),timedRun:Vwe.nullable(),powerSupply:Hwe.nullable(),rows:C(Fwe),measurement:DI.optional(),gated:C(l()),provenance:C(Gwe)}),qwe=x({id:S([`timed-run.run`,`timed-run.cancel`]),duration:n(),unit:S([`min`,`s`])}),nL=x({deviceId:n().int(),name:l(),type:l(),state:_I,stateAssumed:y(),look:yI,scene:BI,statusLine:C(xI),primary:XI.nullable(),primaryGated:y().optional(),timedRun:qwe.nullable(),extras:C(XI).max(2).optional(),trailing:eL.nullable(),measurement:DI.optional()}),rL=[`temperature`,`humidity`,`pressure`,`illuminance`,`reading`,`air-quality`,`valve`],Jwe=[`power`,`battery`,`consumables`],Ywe=new Set(rL);function Xwe(e){for(let t of Jwe){let n=e.facts.find(e=>e.id===t);if(n!==void 0)return n}return e.facts.find(t=>Ywe.has(t.id)&&t.text.en===e.title.en)??null}var Zwe={[E.Climate]:`climate.mode`};function Qwe(e){let t=Zwe[e.type];if(t!==void 0){let n=aL(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 $we={[E.Climate]:[`climate.target`],[E.Vacuum]:[`vacuum.base`],[E.LawnMower]:[`mower.dock`],[E.MediaPlayer]:[`volume.level`,QI],[E.Automation]:[`automation.enabled`]},iL=e=>e.kind===`action`?e.action.id:e.id;function aL(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=>iL(e)===t);if(r!==void 0)return r}return null}function eTe(e,t){let n=$we[e.type]??[],r=t===null?null:iL(t);return n.filter(e=>e!==r).flatMap(t=>{let n=aL(e,t);return n===null?[]:[n]}).slice(0,2)}function tTe(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 nTe(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 rTe(e){let t=Xwe(e),{control:n,gated:r}=Qwe(e);return{deviceId:e.deviceId,name:e.name,type:e.type,state:e.state,stateAssumed:e.stateAssumed,look:e.look,scene:e.scene,statusLine:tTe(e,t),primary:n,primaryGated:r,timedRun:nTe(e),extras:eTe(e,n),trailing:t,...e.measurement===void 0?{}:{measurement:e.measurement}}}var iTe=x({deviceId:n().int().nonnegative(),canActuate:y().optional()}),aTe=500,oTe=x({deviceIds:C(n().int().nonnegative()).max(500),canActuate:y().optional()}),oL=x({type:l(),rows:C(GI)}),sL={name:`hero-layout`,scope:`system`,mode:`singleton`,methods:{getHeroModel:A(iTe,Kwe.nullable(),{auth:`protected`,role:`viewer`}),getRowModels:A(oTe,C(nL.nullable()),{auth:`protected`,role:`viewer`}),getLayout:A(x({deviceType:l(),role:l().nullable().optional()}),oL,{auth:`protected`,role:`viewer`})},vocabulary:{notOperatorFacing:`the device hero model — read-only data the UI draws, never actuated`}},cL=x({on:y(),currentHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),targetHumidity:n().min(0).max(100).nullable().meta(N(`humidity`)),mode:l().nullable(),availableModes:C(l()),action:l().nullable(),minHumidity:n().nullable().meta(N(`humidity`)),maxHumidity:n().nullable().meta(N(`humidity`)),lastChangedAt:n()}),lL={name:`humidifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Humidifier],power:{kind:`field`,field:`on`,set:`setOn`},methods:{setOn:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.on`,label:F(`Humidifier on`,`Umidificatore acceso`),phrase:F(`Turn on {device}`,`Accendi {device}`),icon:`power`,effect:{field:`on`,value:!0},args:{on:!0}},{id:`humidifier.off`,label:F(`Humidifier off`,`Umidificatore spento`),phrase:F(`Turn off {device}`,`Spegni {device}`),icon:`power-off`,effect:{field:`on`,value:!1},args:{on:!1}}]}),setTargetHumidity:A(x({deviceId:n().int().nonnegative(),humidity:n().min(0).max(100)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.target`,label:F(`Set humidity`,`Imposta l’umidità`),phrase:F(`Set {device} to {humidity} humidity`,`Imposta {device} al {humidity} di umidità`),icon:`droplets`,effect:{field:`targetHumidity`,fromArg:`humidity`},openArgs:[{key:`humidity`,label:F(`Humidity`,`Umidità`),offer:{kind:`number`,min:0,max:100,step:1,unit:`%`}}]}]}),setMode:A(x({deviceId:n().int().nonnegative(),mode:l().min(1)}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`humidifier.mode`,label:F(`Set mode`,`Imposta la modalità`),phrase:F(`Set {device} to {mode}`,`Imposta {device} su {mode}`),icon:`list`,effect:{field:`mode`,fromArg:`mode`},openArgs:[{key:`mode`,label:F(`Mode`,`Modalità`),offer:{kind:`dynamic`,from:`status`,field:`availableModes`}}]}]})},status:{schema:cL,kind:`push`},runtimeState:cL,durability:`session`,history:{fields:{currentHumidity:{kind:`gauge`,unit:`%`,deadband:.5},on:{kind:`boolean`}}},vocabulary:{noun:F(`Humidifier`,`Umidificatore`),order:1090,state:[{kind:`boolean`,field:`on`,label:F(`On`,`Acceso`),whenTrue:F(`When {device} turns on`,`Quando {device} si accende`),whenFalse:F(`When {device} turns off`,`Quando {device} si spegne`),icon:`power`},{kind:`numeric`,field:`currentHumidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},uL=x({humidity:n().min(0).max(100).nullable().meta(N(`humidity`,{precision:0,label:`Humidity`})),lastFetchedAt:n()}),dL={name:`humidity-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor,E.Climate],methods:{},status:{schema:uL,kind:`push`},runtimeState:uL,durability:`restored`,history:{primary:`humidity`,priority:90,fields:{humidity:{kind:`gauge`,unit:`%`,deadband:.5}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Humidity`,`Umidità`),order:5120,state:[{kind:`numeric`,field:`humidity`,quantity:F(`the humidity`,`l’umidità`),label:F(`Humidity`,`Umidità`),unit:`%`,icon:`droplets`}]}},fL=x({url:l().nullable(),lastUpdated:n().nullable().meta(N(`none`))}),pL={name:`image`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Image],methods:{},status:{schema:fL,kind:`push`},runtimeState:fL,durability:`session`,history:`none`,vocabulary:{noun:F(`Image`,`Immagine`),order:3130}},mL=S([`0`,`90`,`180`,`270`]),hL=S([`auto`,`manual`]),gL=S([`auto`,`manual`]),_L=S([`off`,`blc`,`wdr`,`hlc`]),vL=x({min:n(),max:n(),step:n()}),yL=x({brightness:n().optional().meta(N(`none`)),contrast:n().optional().meta(N(`none`)),saturation:n().optional().meta(N(`none`)),sharpness:n().optional().meta(N(`none`)),mirror:y().optional(),flip:y().optional(),rotate:mL.optional(),whiteBalance:hL.optional(),warmth:n().optional().meta(N(`none`)),exposureMode:gL.optional(),backlightMode:_L.optional(),lastFetchedAt:n()}),bL=x({supportsBrightness:y(),brightness:vL.optional(),supportsContrast:y(),contrast:vL.optional(),supportsSaturation:y(),saturation:vL.optional(),supportsSharpness:y(),sharpness:vL.optional(),supportsMirror:y(),supportsFlip:y(),rotateOptions:C(mL),whiteBalanceModes:C(hL),supportsWarmth:y(),warmth:vL.optional(),exposureModes:C(gL),backlightModes:C(_L)}),xL=x({brightness:n().optional(),contrast:n().optional(),saturation:n().optional(),sharpness:n().optional(),mirror:y().optional(),flip:y().optional(),rotate:mL.optional(),whiteBalance:hL.optional(),warmth:n().optional(),exposureMode:gL.optional(),backlightMode:_L.optional()}),SL={name:`image-settings`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`image-settings`,tab:`image`}},methods:{getOptions:A(x({deviceId:n()}),bL),setSettings:A(x({deviceId:n(),settings:xL}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:yL,kind:`poll`},runtimeState:yL,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Image settings`,`Impostazioni immagine`),order:3140}},CL=x({id:l(),addonId:l(),name:l(),enabled:y(),switchUnknown:p(!0).optional(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n(),processState:l()}),wL=x({id:l(),addonId:l(),name:l(),enabled:y(),switchUnknown:p(!0).optional(),info:m(l(),w()).readonly(),originStableId:l().optional(),createdAt:n(),updatedAt:n()}),TL=x({addonId:l(),name:l(),providerLabel:l().optional(),description:l(),iconUrl:l().nullable(),color:l(),instanceMode:l(),mode:S([`standalone`,`account`,`broker`]),discoveryMode:l(),kind:S([`device-adoption`,`device-provider`]),brokerKind:l().nullable(),supportsLocationImport:y(),canTest:y(),existingInstances:C(x({id:l(),name:l()})),canAdd:y()}),EL=S([`validated`,`rejected`,`inconclusive`,`unsupported`]),DL=x({success:y(),error:l().optional(),status:EL.optional(),testedBy:l().nullable().optional(),latencyMs:n().nonnegative().optional(),detail:l().optional()}),OL=x({id:l(),name:l().optional(),enabled:y().optional(),info:m(l(),w()).optional()}),kL=x({success:y(),deletedId:l()}),AL={name:`integrations`,scope:`system`,mode:`singleton`,methods:{list:A(v(),C(CL)),get:A(x({id:l()}),CL),getByAddonId:A(x({addonId:l()}),wL.nullable()),update:A(OL,wL,{kind:`mutation`,auth:`admin`}),delete:A(x({id:l()}),kL,{kind:`mutation`,auth:`admin`}),getAvailableTypes:A(v(),C(TL),{auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.ADDON_ADMIN}},sTe=ve(),jL=l().min(1),ML=S([`single`,`multiple`]),NL=S([`devices`,`services`]),PL=x({id:l().min(1),label:l().min(1),functionCap:l().min(1),brokerKind:l().min(1).optional(),alsoServes:C(l().min(1)).optional(),iconUrl:l().min(1).optional(),iconMediaType:l().min(1).optional(),role:NL.optional(),canTest:y().optional(),signIn:x({basePath:l().min(1),methods:C(S([`device-code`,`proxy`])).optional()}).optional(),connectPath:l().min(1).optional(),disconnectPath:l().min(1).optional(),widgets:C(x({id:l().min(1),placement:S([`connection`,`model`])})).optional()}),FL=x({mode:S([`none`,`lan`,`account`]),scopedToInstance:y()}),IL=x({kind:l().min(1),field:l().min(1),to:x({cap:l().min(1),kind:l().min(1).optional()})}),LL=x({role:NL,discovery:FL.optional(),instanceMode:ML,kind:l(),canTest:y(),kinds:C(PL).min(1),allowRestoreId:y().optional(),mintsId:y().optional(),links:C(IL).optional(),userScoped:y().optional()}),RL=x({state:S([`ok`,`off`,`error`,`unknown`]),detail:l().optional(),label:l().optional()}),zL=S([`scan`,`children`,`none`]),BL=x({id:jL,name:l(),configured:y(),enabled:y().optional(),kind:l().min(1),formValues:m(l(),w()),status:RL.optional(),lastCheckedAt:n().optional(),addDevice:zL.optional()}),VL=x({id:jL,name:l().min(1).optional(),values:m(l(),w())}),HL={name:`integration-instances`,scope:`system`,mode:`collection`,methods:{describe:A(v(),LL,{auth:`admin`}),instanceFormSchema:A(x({id:jL.nullable(),kind:l().min(1).optional(),mode:S([`standalone`,`account`,`broker`]).optional(),candidateStableId:l().min(1).optional()}),sTe,{auth:`admin`}),listInstances:A(se({}),C(BL).readonly(),{auth:`protected`,caller:`scoped`}),getInstance:A(x({id:jL}),BL.nullable(),{auth:`protected`,caller:`scoped`}),createInstance:A(x({id:jL.optional(),name:l().min(1),kind:l().min(1).optional(),values:m(l(),w()).optional(),originStableId:l().min(1).optional(),seed:x({info:m(l(),w())}).optional()}),x({id:l()}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),updateInstance:A(VL,x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),setInstanceEnabled:A(x({id:jL,enabled:y()}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),deleteInstance:A(x({id:jL}),x({ok:p(!0)}),{kind:`mutation`,auth:`protected`,caller:`scoped`}),testInstance:j(x({id:jL.nullable(),values:m(l(),w()),kind:l().min(1).optional()}),DL,{kind:`mutation`,auth:`protected`,caller:`scoped`})},vocabulary:{notOperatorFacing:M.INTERNAL}},UL=x({codecs:C(l()),sampleRate:n().meta(N(`none`)),duplex:S([`half`,`full`]),maxBacklogMs:n().meta(N(`duration-ms`))}),WL=x({talking:y(),lastSessionAt:n().nullable(),ability:UL.nullable()}),cTe=S([`opus`,`s16le`,`g711ulaw`,`g711alaw`]),GL={name:`intercom`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{startSession:A(x({deviceId:n()}),x({sessionId:l(),sdpOffer:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),handleAnswer:A(x({deviceId:n(),sessionId:l(),sdpAnswer:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),stopSession:A(x({deviceId:n(),sessionId:l()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),startTalkSession:A(x({deviceId:n()}),x({sessionId:l()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`two-way talk is a person speaking through the viewer, not an automation step`}),pushTalkAudio:A(x({deviceId:n(),audioBase64:l(),codec:cTe.optional(),sampleRate:n().int().positive().optional(),channels:n().int().positive().optional(),sequenceNumber:n().int()}),x({accepted:y()}),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`}),endTalkSession:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`protected`,notOperatorFacing:`live-stream session plumbing driven by a viewer, never a discrete step`})},events:{onStatusChanged:{data:x({deviceId:n(),status:WL}),notOperatorFacing:"the `talking` state trigger phrases both edges of this change"}},status:{schema:WL,kind:`command-driven`},runtimeState:WL,durability:`session`,history:`none`,vocabulary:{noun:F(`Intercom`,`Citofono`),order:3150,state:[{kind:`boolean`,field:`talking`,label:F(`Talking`,`In conversazione`),whenTrue:F(`When someone starts talking through {device}`,`Quando qualcuno inizia a parlare tramite {device}`),whenFalse:F(`When the conversation on {device} ends`,`Quando la conversazione su {device} finisce`),icon:`mic`}]}},KL=S([`carrierHz`,`dutyCyclePercent`,`repeat`,`repeatDelayMs`]),qL=S([`ir`,`rf`]),JL=x({ok:p(!0),ignoredSettings:C(l())}),YL=x({media:C(qL),settable:C(KL),maxTimings:n().int().positive(),learn:y().default(!1),formats:C(fE).default([])}),XL=2e4,ZL=6e4,QL=x({native:mE.nullable(),timings:rE,carrierHz:n().int().positive().nullable()}),$L=x({at:n(),ok:y(),error:l().nullable()}),eR=$L.extend({medium:qL}),tR=x({lastSend:eR.nullable(),lastLearn:$L.nullable(),lastFetchedAt:n()});function nR(e){return!(e.kind===`learn`&&e.error===`ir-transmitter.learn-unsupported`)}function lTe(e,t,n){let r=e??{lastSend:null,lastLearn:null,lastFetchedAt:n};return nR(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 uTe(e){return Or(e)?.code??null}var rR={name:`ir-transmitter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Generic],methods:{send:A(x({deviceId:n().int().nonnegative(),timings:rE.optional(),native:mE.optional(),settings:iE.optional()}).refine(e=>e.timings===void 0!=(e.native===void 0),{message:`send takes exactly one of timings or native`}),JL,{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:A(x({deviceId:n().int().nonnegative(),timeoutMs:n().int().positive().max(ZL).default(XL)}),QL,{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:A(x({deviceId:n().int().nonnegative()}),YL,{kind:`query`,auth:`protected`})},runtimeState:tR,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`IR / RF transmitter`,`Trasmettitore IR / RF`),order:1140}},iR=S([`key-missing`,`wrong-key`,`key-file-unreadable`,`store-unavailable`,`not-initialized`,`decrypt-failed`]),aR=i(`state`,[x({state:p(`ready`)}),x({state:p(`locked`),reason:iR})]),oR=i(`kind`,[x({kind:p(`value`),value:l(),version:n().int()}),x({kind:p(`missing`)}),x({kind:p(`unavailable`),reason:iR}),x({kind:p(`forbidden`)})]),sR=m(l(),oR),cR=x({ref:l(),owner:l(),scope:l(),fieldPath:l(),version:n().int(),createdAt:n(),updatedAt:n(),updatedBy:l(),lastReadAt:n().nullable()}),dTe=512,lR=C(l().min(1)).max(512),uR={name:`keychain`,scope:`system`,mode:`singleton`,internal:!0,methods:{put:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`}),resolve:A(x({refs:lR}),sR,{auth:`admin`}),delete:A(x({refs:lR}),x({deleted:n().int()}),{kind:`mutation`,auth:`admin`}),deleteDeviceScope:A(x({deviceId:n().int()}),x({refs:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),releaseRecordRefs:A(x({refs:lR,onBehalfOf:l().min(1)}),x({released:n().int()}),{kind:`mutation`,auth:`admin`}),listMeta:A(x({}),C(cR).readonly(),{auth:`admin`}),getState:A(x({}),aR,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},dR=S([`mounted-file`,`previous-mounted-file`,`platform`,`default-file`]),fR=x({kind:dR,path:l().optional(),sharesBackupWithDatabase:y()}),fTe=`trigger-file`,pR=x({id:l(),at:n(),actor:l(),lockedReason:l().nullable(),archived:n().int(),archivedCollection:l().nullable(),archivedKeysCollection:l().nullable(),clearedSettingsKeys:C(l()).readonly(),acknowledgedAt:n().nullable()}),mR=x({keychain:aR,keySource:fR.nullable(),configuredSource:fR,fingerprint:l().nullable(),activeKeyId:l().nullable(),rotationPending:y(),retiredWraps:n().int(),recoveryKeyDownloadedAt:n().nullable(),secretCount:n().int(),lastReset:pR.nullable()}),hR=S([`in-use`,`orphan`,`unknown`]),gR=cR.extend({usage:hR}),_R=S([`put`,`delete`,`reveal`,`rotate-master-key`,`purge-retired-keys`,`download-recovery-key`,`delete-orphans`,`reset`,`acknowledge-reset`,`initialize`]),vR=x({id:l(),at:n(),action:_R,actor:l(),ref:l().nullable(),detail:l().nullable()}),yR=`RESET KEYCHAIN`,bR=S([`jwt-signing-key`]),xR={name:`keychain-admin`,scope:`system`,mode:`singleton`,methods:{status:A(x({}),mR,{auth:`admin`}),listSecrets:A(x({}),C(gR).readonly(),{auth:`admin`}),listAudit:A(x({limit:n().int().min(1).max(500).optional()}),C(vR).readonly(),{auth:`admin`}),reveal:A(x({ref:l().min(1)}),x({value:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),setSystemSecret:A(x({name:bR,value:l().min(16)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),importSecret:A(x({ref:l().min(1),value:l().min(1)}),x({ref:l(),version:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteOrphans:A(x({refs:C(l().min(1)).max(1e3)}),x({deleted:C(l()).readonly(),kept:C(x({ref:l(),usage:hR})).readonly()}),{kind:`mutation`,auth:`admin`,caller:`required`}),rotateMasterKey:A(x({}),x({fingerprint:l(),keySource:fR}),{kind:`mutation`,auth:`admin`,caller:`required`}),purgeRetiredKeys:A(x({}),x({purged:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),downloadRecoveryKey:A(x({}),x({key:l(),fingerprint:l(),keySource:fR}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetKeychain:A(x({confirm:p(yR)}),x({archivedCollection:l().nullable(),archived:n().int()}),{kind:`mutation`,auth:`admin`,caller:`required`}),resetReport:A(x({}),x({reset:pR.nullable(),pendingReentry:C(cR).readonly()}),{auth:`admin`}),acknowledgeReset:A(x({}),x({acknowledged:y()}),{kind:`mutation`,auth:`admin`,caller:`required`})},vocabulary:{notOperatorFacing:M.IDENTITY}},SR=S([`idle`,`mowing`,`paused`,`docked`,`error`]),CR=S([`info`,`warning`,`error`]),wR=x({activity:SR,batteryLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),progress:n().min(0).max(100).nullable().meta(N(`percentage`)),currentCode:n().nullable().meta(N(`none`)),currentCodeLabel:l().nullable(),severity:CR,lastChangedAt:n()}),TR={name:`lawn-mower-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.LawnMower],methods:{startMowing:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.start`,label:F(`Start mowing`,`Avvia il taglio`),phrase:F(`Start {device} mowing`,`Fai partire il taglio di {device}`),icon:`play`}]}),pause:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.pause`,label:F(`Pause mower`,`Metti in pausa il tosaerba`),phrase:F(`Pause {device}`,`Metti in pausa {device}`),icon:`pause`}]}),dock:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lawnMower.dock`,label:F(`Dock mower`,`Riporta alla base`),phrase:F(`Send {device} back to its dock`,`Rimanda {device} alla base`),icon:`house`}]})},status:{schema:wR,kind:`push`},runtimeState:wR,durability:`session`,history:{fields:{batteryLevel:{kind:`gauge`,unit:`%`,deadband:2}}},vocabulary:{noun:F(`Robot mower`,`Robot tosaerba`),order:2010,state:[{kind:`enum`,field:`activity`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`mowing`,label:F(`Mowing`,`In taglio`),phrase:F(`When {device} starts mowing`,`Quando {device} inizia a tagliare`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`docked`,label:F(`Docked`,`Alla base`),phrase:F(`When {device} docks`,`Quando {device} arriva alla base`)},{value:`error`,label:F(`Error`,`Errore`),phrase:F(`When {device} reports an error`,`Quando {device} segnala un errore`)}],icon:`bot`},{kind:`numeric`,field:`batteryLevel`,quantity:F(`the battery level`,`il livello della batteria`),label:F(`Battery`,`Batteria`),unit:`%`,icon:`battery`}]}},ER=6e5,pTe=60*6e4,DR=x({inputTokens:n(),outputTokens:n()}),OR=S([`timeout`,`rate-limited`,`auth`,`refusal`,`bad-request`,`unavailable`,`no-profile`,`budget-exceeded`,`adapter-error`]),kR=x({ok:p(!0),text:l(),model:l(),usage:DR,truncated:y(),latencyMs:n()}),AR=S([`guardrail`,`model`]),jR=x({ok:p(!1),code:OR,message:l(),retryAfterMs:n().optional(),refusalSource:AR.optional()}),MR=i(`ok`,[kR,jR]),NR=x({bytes:b(Uint8Array),mimeType:l()}),PR=x({enabled:y().default(!1),maxAttempts:n().int().min(1).max(5).default(1)}),mTe={totalMs:6e4,connectMs:1e4,firstTokenMs:12e4,idleMs:6e4},FR=x({addonId:l().optional(),profileId:l().optional(),consumer:l(),system:l().optional(),prompt:l(),jsonSchema:m(l(),w()).optional(),maxTokens:n().int().positive().optional(),temperature:n().optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),timeoutMs:n().int().positive().optional(),retry:PR.optional(),requestId:l().optional()}),IR=x({url:l(),filename:l(),sizeBytes:n(),sha256:l().optional()}),LR=i(`kind`,[x({kind:p(`catalog`),catalogId:l()}),x({kind:p(`url`),url:l(),sha256:l().optional(),label:l().optional(),sizeBytes:n().optional(),extraFiles:C(IR).optional()}),x({kind:p(`path`),path:l()})]),RR=x({nodeId:l(),engine:S([`llama-cpp`]),model:LR,contextSize:n().int().default(4096),gpuLayers:n().int().default(0),threads:n().int().optional(),parallel:n().int().default(1),batchSize:n().int().positive().optional(),ubatchSize:n().int().positive().optional(),flashAttention:y().default(!1),mlock:y().default(!1),noMmap:y().default(!1),cacheTypeK:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),cacheTypeV:S([`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`]).optional(),extraArgs:C(l()).default([]),autoStart:y().default(!1),idleStopMinutes:n().int().default(30)}),zR=x({phase:S([`downloading`,`verifying`]),file:l(),fileIndex:n().int(),fileCount:n().int(),downloadedBytes:n(),totalBytes:n().optional()}),BR=x({nodeId:l(),state:S([`stopped`,`downloading`,`starting`,`ready`,`crashed`,`failed`]),pid:n().optional(),port:n().optional(),modelPath:l().optional(),modelId:l().optional(),downloadProgress:n().min(0).max(1).optional(),download:zR.optional(),lastError:l().optional(),crashesInWindow:n(),memoryBytes:n().optional(),vramBytes:n().optional()}),VR=x({file:l(),sizeBytes:n(),catalogId:l().optional(),installedAt:n().optional(),path:l().optional()}),HR=x({nodeId:l(),modelsBytes:n(),freeBytes:n().optional()}),UR=FR.extend({images:C(NR).optional(),runtime:RR,timeoutMs:n().int().positive().optional()}),WR=S([`deviceNotEligible`,`appleIntelligenceNotEnabled`,`modelNotReady`,`osTooOld`,`helperMissing`,`helperCrashed`]),GR=i(`state`,[x({state:p(`available`),osVersion:l(),contextSize:n().int().positive(),languages:C(l()),imageInput:y()}),x({state:p(`unavailable`),reason:WR,osVersion:l().nullable(),detail:l()}),x({state:p(`unsupported-platform`),platform:l()}),x({state:p(`unknown`),error:l()})]),KR=FR.extend({images:C(NR).optional(),timeoutMs:n().int().positive().optional()}),qR=x({requestId:l()}),JR={name:`llm-runtime`,scope:`system`,mode:`singleton`,internal:!0,methods:{complete:A(UR,MR,{kind:`mutation`,auth:`admin`,timeoutMs:ER}),ensureStarted:A(x({runtime:RR}),BR,{kind:`mutation`,auth:`admin`,timeoutMs:ER}),stop:A(x({}),v(),{kind:`mutation`,auth:`admin`}),status:A(x({}),BR,{auth:`admin`}),installModel:A(x({model:LR}),v(),{kind:`mutation`,auth:`admin`,timeoutMs:pTe}),deleteModel:A(x({file:l()}),v(),{kind:`mutation`,auth:`admin`}),listLocalModels:A(x({}),C(VR),{auth:`admin`}),getDiskUsage:A(x({}),HR,{auth:`admin`}),cancel:A(qR,v(),{kind:`mutation`,auth:`admin`}),appleAvailability:A(x({}),GR,{auth:`admin`}),completeApple:A(KR,MR,{kind:`mutation`,auth:`admin`,timeoutMs:ER})},vocabulary:{notOperatorFacing:M.ML}},YR=/^[a-z0-9][a-z0-9-]{0,63}$/,XR=l().regex(YR,`a kind id is lower-case letters, digits and dashes`),ZR=x({vision:y(),tools:y(),streaming:y(),reasoning:y().nullable().optional()}),QR=x({id:l(),label:l().optional(),contextLength:n().int().positive().optional(),features:ZR.partial().optional()}),$R=m(l(),w()),hTe=x({id:l(),name:l(),kind:XR,addonId:l(),enabled:y(),model:l(),supportsVision:y(),temperature:n().min(0).max(2).optional(),topP:n().min(0).max(1).optional(),topK:n().int().positive().optional(),maxTokens:n().int().positive().optional(),reasoningEffort:S([`off`,`low`,`medium`,`high`]).optional(),contextLength:n().int().positive().optional(),systemPrompt:l().optional(),timeoutMs:n().int().positive().default(6e4),connectTimeoutMs:n().int().positive().default(1e4),firstTokenTimeoutMs:n().int().positive().default(12e4),idleTimeoutMs:n().int().positive().default(6e4),retry:PR.default({enabled:!1,maxAttempts:1}),toolsEnabled:y().default(!1),providerConfig:$R.default({})}),ez=S([`temperature`,`topP`,`topK`,`maxTokens`,`reasoningEffort`,`contextLength`,`systemPrompt`,`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`]),tz=x({id:l(),placement:S([`connection`,`model`]),requires:C(l()).optional()}),nz=w(),gTe=x({kind:XR,label:l(),icon:l(),addonId:l(),connectionSchema:nz,advancedSchema:nz.optional(),features:ZR,visionEditable:y(),modelCatalog:S([`fetch`,`static`,`none`]),staticModels:C(QR).optional(),profileFields:C(ez),providerWidgets:C(tz).optional()}),rz=x({addonId:l(),kind:XR,profileId:l().optional(),connection:$R.optional()}),iz=S([`auth`,`network`,`unsupported`,`invalid`]),az=i(`ok`,[x({ok:p(!0),models:C(QR)}),x({ok:p(!1),code:iz,message:l()})]),oz=h([x({consumer:l()}),x({purpose:S([`text`,`vision`])})]),sz=x({selector:oz,profileId:l()}),cz=x({day:l(),consumer:l(),profileId:l(),calls:n(),okCalls:n(),errorCalls:n(),inputTokens:n(),outputTokens:n(),avgLatencyMs:n()}),lz=x({id:l(),label:l(),family:l(),purpose:S([`text`,`vision`]),url:l(),sha256:l(),sizeBytes:n(),quantization:l(),minRamBytes:n(),contextSizeDefault:n().int(),mmprojUrl:l().optional()}),uz=i(`ok`,[x({ok:p(!0),model:LR,label:l(),repo:l(),quantization:l(),purpose:S([`text`,`vision`]),totalBytes:n(),extraFilenames:C(l())}),x({ok:p(!1),code:l(),message:l(),candidates:C(l()).optional(),requiredBytes:n().optional()})]),dz=x({nodeId:l(),reachable:y(),status:BR.optional(),disk:HR.optional(),error:l().optional(),apple:GR.optional()}),_Te=FR.extend({images:C(NR).min(1)}),fz=x({addonId:l(),profileId:l()}),pz={name:`llm`,scope:`system`,mode:`collection`,internal:!1,providerKind:`ai`,nodeIdMode:`data`,methods:{generate:A(FR,MR,{kind:`mutation`,timeoutMs:ER}),generateVision:A(_Te,MR,{kind:`mutation`,timeoutMs:ER}),cancel:A(x({addonId:l().optional(),requestId:l()}),v(),{kind:`mutation`}),listModels:A(rz,az,{kind:`mutation`,auth:`admin`}),getDefaults:A(x({}),C(sz)),setDefault:A(x({selector:oz,profileId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`}),getUsage:A(x({since:n().optional(),until:n().optional(),consumer:l().optional(),profileId:l().optional()}),C(cz)),listModelCatalog:A(x({}),C(lz)),listRuntimeNodes:A(x({}),C(dz)),listNodeModels:A(x({nodeId:l()}),C(VR)),resolveModelRef:A(x({ref:l(),maxBytes:n().positive().optional()}),uz,{kind:`mutation`,auth:`admin`}),installModel:A(x({nodeId:l(),model:LR}),v(),{kind:`mutation`,auth:`admin`}),deleteModel:A(x({nodeId:l(),file:l()}),v(),{kind:`mutation`,auth:`admin`}),getRuntimeStatus:A(fz,BR),startRuntime:A(fz,BR,{kind:`mutation`,auth:`admin`}),stopRuntime:A(fz,v(),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},mz=[`decode`,`transcode`,`recording`,`streaming`,`detection`],hz=[`measured`,`accounted`,`unattributable`],gz=x({role:S(mz),deviceId:n().int().positive().nullable(),attribution:S(hz),unit:l(),pid:n().int().positive().optional(),startedAtMs:n().optional(),cpuSeconds:n().optional(),rssBytes:n().optional()}),_z={name:`load-contribution`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(gz).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},vz=`https://camstack.zentik.app`,yz=`/viewer/camstack`;function bz(e){if(e==null||e===``)return!1;try{return new URL(e).origin===vz}catch{return!1}}function vTe(e){let t=e.baseUrl??e.resolved;return bz(t)?{form:`app`,hubBaseUrl:e.appLinkHub??null}:{form:`hub`,hubBaseUrl:t}}function xz(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 yTe(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=xz(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 bTe(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 Sz(e){return e.length===0?``:`?${e.map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`}function xTe(e){let t=bTe(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:xz(r),n=e===null?t.query:[...t.query,[`hub`,e]];return`${vz}${t.path}${Sz(n)}`}return r===``||bz(r)?null:`${r}${yz}${t.path}${Sz(t.query)}`}var Cz=[`appConnections`,`notificationTaps`,`internal`,`publicEndpoint`],STe=[`notificationTaps`,`internal`,`publicEndpoint`];function CTe(e){return e!==`appConnections`}var wTe={appConnections:[],notificationTaps:null,internal:null,publicEndpoint:null},TTe=/^\d{1,3}(?:\.\d{1,3}){3}$/;function wz(e){try{let t=new URL(e).hostname;return t.length>0?t:null}catch{return null}}function ETe(e){return e.replace(/\/+$/,``)}function Tz(e){return e.kind===`public`&&e.interfaceKind===`vpn`}function DTe(e){return e.kind===`public`&&e.interfaceKind===`public`}function Ez(e){return(e.kind===`lan-ipv4`||e.kind===`lan-ipv6`)&&e.plausible}function Dz(e){if(e.kind!==`lan-ipv4`||!e.plausible)return!1;let t=wz(e.baseUrl);return t!==null&&TTe.test(t)}function Oz(e){return e.stable===!1}function OTe(e,t){return t.kind===`loopback`||t.kind===`app-link`||t.kind===`custom`||wz(t.baseUrl)===null||Oz(t)?null:e===`internal`?Dz(t)?0:Ez(t)?1:Tz(t)?2:null:DTe(t)?0:Tz(t)?1:Dz(t)?2:Ez(t)?3:null}var kTe=new Set([`localhost`,`0.0.0.0`,`::1`,`[::1]`,`::`,`[::]`]);function ATe(e){let t=e.toLowerCase();return kTe.has(t)||t.endsWith(`.localhost`)?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}function kz(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.`}:ATe(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 Az=`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 jz(e,t,n={}){if(bz(t))return e===`notificationTaps`?{ok:!0,baseUrl:vz}:{ok:!1,reason:`The CamStack app link is not a hub address — only notification taps can use it.`};let r=kz(t);return r.ok&&e===`publicEndpoint`&&r.baseUrl.startsWith(`http:`)&&n.acceptInsecureHttp!==!0?{ok:!1,reason:Az}:r}function Mz(e,t){if(t===null||t===``)return null;let n=jz(e,t,{acceptInsecureHttp:!0});return n.ok?n.baseUrl:null}function jTe(e,t){let n=e.flatMap(e=>{let n=OTe(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:ETe(n.endpoint.baseUrl)}function Nz(e,t,n){let r=Mz(t,n);if(r!==null)return{flagged:r,resolved:r,source:`flagged`};let i=jTe(e,t);return{flagged:null,resolved:i,source:i===null?`none`:`auto`}}function Pz(e,t){return Nz(e,`internal`,t.internal)}function Fz(e,t){return Nz(e,`publicEndpoint`,t.publicEndpoint)}function Iz(e){let t=Mz(`notificationTaps`,e.notificationTaps);return t!==null&&!bz(t)?{flagged:t,resolved:t,source:`flagged`}:{flagged:null,resolved:vz,source:`auto`}}function Lz(e){return Oz(e)?!1:e.kind===`lan-ipv4`?!0:e.kind===`public`&&e.interfaceKind===`public`}function Rz(e,t){let n=e.filter(Lz);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 zz(e,t){let n=new Set(t.appConnections),r=Rz(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 MTe(e,t,n){return{appConnections:zz(e,n),notificationTaps:Iz(n),internal:Pz(t,n),publicEndpoint:Fz(t,n)}}function NTe(e){return e===null?null:wz(e)}var PTe=`camstack`,FTe=`_camstack._tcp.local`,ITe={nodeId:`nodeId`,version:`version`,role:`role`,url:`url`,hubId:`hubId`},LTe=`hub`,Bz=/^hub-[0-9a-f]{16}$/;function RTe(e){return typeof e==`string`&&Bz.test(e)}var zTe=`camstack-agent`,BTe=`_camstack-agent._tcp.local`,VTe={nodeId:`nodeId`,version:`version`,name:`name`,state:`state`,keyFingerprint:`fp`},HTe=S([`lan`,`wifi`,`docker`,`vpn`,`loopback`,`other`]),Vz=x({name:l(),family:S([`IPv4`,`IPv6`]),address:l(),cidr:l(),netmask:l(),internal:y(),mac:l(),kind:HTe,preferred:y(),plausible:y(),plausibleReason:l()}),UTe=x({interfaces:C(Vz).readonly(),probedAt:n()}),WTe=Vz.nullable(),Hz=x({label:l(),baseUrl:l(),kind:S([`lan-ipv4`,`lan-ipv6`,`public`,`loopback`,`app-link`,`custom`]),interfaceKind:S([`lan`,`wifi`,`docker`,`vpn`,`other`,`loopback`,`public`]),plausible:y(),plausibleReason:l(),priority:n(),stable:y().optional()}),GTe=S([`server-config`,`server-env`,`caller-hint`,`default`]),KTe=x({port:n().int().min(1).max(65535),source:GTe}),qTe=x({endpoints:C(Hz).readonly(),localPort:KTe}),Uz=x({baseUrl:l().nullable(),resolved:l().nullable(),appLinkHub:l().nullable()}),Wz=x({baseUrls:C(l()).readonly(),resolved:C(l()).readonly()}),Gz=x({override:l().nullable(),resolved:l().nullable(),source:S([`override`,`auto`,`none`])}),JTe=x({cluster:Gz,browser:Gz}),Kz=S(Cz),qz=S([`flagged`,`auto`,`none`]),Jz=x({flagged:l().nullable(),resolved:l().nullable(),source:qz}),YTe=x({flagged:C(l()).readonly(),resolved:C(l()).readonly(),source:qz}),Yz=x({rows:C(Hz.extend({detected:y(),custom:y(),flags:C(Kz).readonly(),inUse:C(Kz).readonly(),eligible:C(Kz).readonly()})).readonly(),roles:x({appConnections:YTe,notificationTaps:Jz,internal:Jz,publicEndpoint:Jz}),appLinkHub:l().nullable(),listenerOrigins:C(l()).readonly().optional()}),Xz=x({addresses:C(l()).readonly()}),Zz=x({mode:S([`generated`,`uploaded`,`disabled`]),leafFingerprintSha256:l().nullable(),caFingerprintSha256:l().nullable(),validTo:l().nullable(),sans:C(l()),caCertPem:l().nullable(),reissueError:l().nullable(),restartRequired:y(),caMissing:y(),localCaConstrained:y().nullable(),caReplacedAt:l().nullable(),storedUpload:x({leafFingerprintSha256:l(),validTo:l(),hasCa:y()}).nullable()}),XTe=x({providerId:l().min(1),modes:C(Sj)}),ZTe=x({providerId:l().optional(),mode:l().optional(),message:l()}),QTe=x({hostsProbed:n().int(),hits:n().int(),timeouts:n().int(),byMode:m(l(),x({probed:n().int(),hits:n().int(),timeouts:n().int()}))}),$Te=x({hits:C(x({providerId:l(),hit:Cj})),subnetsScanned:C(l()),errors:C(ZTe),stats:QTe}),Qz={name:`local-network`,scope:`system`,mode:`singleton`,methods:{list:A(v(),UTe),getPreferred:A(v(),WTe),getConnectionEndpoints:A(x({port:n().int().min(1).max(65535).optional(),includeLoopback:y().optional(),ipv4Only:y().optional(),scheme:S([`http`,`https`]).optional(),includeAppLink:y().optional()}),qTe),getNotificationEndpoint:A(v(),Uz),setNotificationEndpoint:A(x({baseUrl:l().nullable()}),Uz,{kind:`mutation`}),getViewerEndpoints:A(v(),Wz),setViewerEndpoints:A(x({baseUrls:C(l()).readonly()}),Wz,{kind:`mutation`}),getAddresses:A(x({scheme:S([`http`,`https`]).optional()}).optional(),Yz),addCustomAddress:A(x({baseUrl:l(),label:l().max(80)}),Yz,{kind:`mutation`,auth:`admin`}),removeCustomAddress:A(x({baseUrl:l()}),Yz,{kind:`mutation`,auth:`admin`}),setAddressRole:A(x({role:Kz,baseUrl:l().nullable(),enabled:y(),acceptInsecureHttp:y().optional()}),Yz,{kind:`mutation`,auth:`admin`}),getHubAddresses:A(v(),JTe),getAllowedAddresses:A(v(),Xz),setAllowedAddresses:A(Xz,x({success:p(!0)}),{kind:`mutation`}),resetAllowlistToBestMatch:A(v(),Xz,{kind:`mutation`}),getTlsStatus:A(v(),Zz),regenerateCertificate:A(x({reason:l().optional()}),Zz,{kind:`mutation`,auth:`admin`}),uploadCertificate:A(x({certPem:l().min(1),keyPem:l().min(1),caPem:l().optional()}),Zz,{kind:`mutation`,auth:`admin`}),downloadCa:A(v(),x({pem:l()})),useStoredUploadedCertificate:A(v(),Zz,{kind:`mutation`,auth:`admin`}),scanNetwork:A(x({requests:C(XTe),subnets:C(l()).optional()}),$Te,{kind:`mutation`,auth:`admin`,timeoutMs:9e4}),getScanSubnets:A(v(),x({subnets:C(l())}),{auth:`admin`}),setScanSubnets:A(x({subnets:C(l())}),x({subnets:C(l())}),{kind:`mutation`,auth:`admin`}),revertToGeneratedCertificate:A(v(),Zz,{kind:`mutation`,auth:`admin`})},mount:{kind:`hub-only`},vocabulary:{notOperatorFacing:M.NETWORK}},$z=S([`locked`,`unlocked`,`locking`,`unlocking`,`jammed`,`door-open`]),eB=x({state:$z,codeRequired:y().nullable().optional(),lastChangedAt:n()}),eEe={version:1,overridable:[{path:`state`,by:`door-contact`}],targets:[{id:`door-contact`,cardinality:`scalar`,vocabulary:{cap:`lock-control`,stateField:`state`},deviceTypes:[E.Lock],apply:`replace`,path:`state`,override:{whenSourceTrue:`door-open`,unlessNative:[`jammed`]},sources:[{kind:`binary`,transforms:[{kind:`identity`}]}],sourceReport:{status:`assignment-status`}}]},tB={name:`lock-control`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Lock],methods:{lock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.lock`,label:F(`Lock`,`Chiudi a chiave`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),unlock:A(x({deviceId:n().int().nonnegative(),code:l().min(1).optional(),confirm:y().optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.unlock`,label:F(`Unlock`,`Apri la serratura`),phrase:F(`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:F(`PIN code`,`Codice PIN`),offer:{kind:`text`,secret:!0},optional:!0}]}]}),open:j(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`lock.open`,label:F(`Open latch`,`Apri lo scrocco`),phrase:F(`Release the latch of {device}`,`Fai scattare lo scrocco di {device}`),icon:`door-open`}]})},status:{schema:eB,kind:`push`},runtimeState:eB,customize:eEe,durability:`restored`,history:{fields:{state:{kind:`enum`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Lock`,`Serratura`),order:1060,state:[{kind:`enum`,field:`state`,label:F(`Lock state`,`Stato della serratura`),values:[{value:`locked`,label:F(`Locked`,`Chiusa a chiave`),phrase:F(`When {device} locks`,`Quando {device} si chiude a chiave`)},{value:`unlocked`,label:F(`Unlocked`,`Sbloccata`),phrase:F(`When {device} unlocks`,`Quando {device} si sblocca`)},{value:`locking`,label:F(`Locking`,`In chiusura`),phrase:F(`When {device} starts locking`,`Quando {device} inizia a chiudersi`)},{value:`unlocking`,label:F(`Unlocking`,`In apertura`),phrase:F(`When {device} starts unlocking`,`Quando {device} inizia a sbloccarsi`)},{value:`jammed`,label:F(`Jammed`,`Inceppata`),phrase:F(`When {device} jams`,`Quando {device} si inceppa`)},{value:`door-open`,label:F(`Door open`,`Porta aperta`),phrase:F(`When the door of {device} opens`,`Quando la porta di {device} si apre`)}],icon:`lock`}]}},nB=x({armed:n().int().min(0),unknown:C(l()).readonly()}),rB={name:`log-channels`,scope:`system`,mode:`collection`,internal:!0,methods:{list:A(v(),C(ih).readonly()),apply:A(x({windows:C(ah).readonly()}),nB,{kind:`mutation`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},iB=S([`debug`,`info`,`warn`,`error`]),aB=x({timestamp:g(),level:iB,scope:C(l()),message:l(),meta:m(l(),w()).optional(),tags:m(l(),l()).optional()}),oB=x({instanceId:l().min(1).max(200).optional(),requestId:l().min(1).max(64).optional(),deviceId:n().int().optional(),fromAddonId:l().min(1).max(200).optional(),fromNodeId:l().min(1).max(200).optional(),tags:m(l(),h([l(),n()])).optional(),level:iB.optional(),text:l().min(1).max(200).optional(),since:n().optional(),until:n().optional(),before:l().min(1).max(1024).optional(),after:l().min(1).max(1024).optional(),limit:n().int().min(1).max(1e3).optional(),budgetMs:n().int().min(50).max(1e4).optional()}),sB=x({id:l().optional(),timestamp:n(),level:iB,scope:l().optional(),message:l(),tags:m(l(),h([l(),n()])).optional(),meta:m(l(),w()).optional()}),cB=x({entries:C(sB),nextBefore:l().nullable(),nextAfter:l().nullable(),scannedBytes:n().int().nonnegative(),done:y(),cancelled:y().optional()}),tEe=x({instanceId:l().min(1).max(200).optional()}),lB=x({readable:y(),reason:l().nullable(),filters:x({deviceId:y(),addonId:y(),nodeId:y(),tags:y(),level:y(),text:y(),timeRange:y()}),retentionDays:n().nullable()}),uB={name:`log-destination`,scope:`system`,mode:`collection`,internal:!0,methods:{write:A(aB,v(),{kind:`mutation`}),describeRead:j(tEe,lB,{auth:`admin`}),read:j(oB,cB,{auth:`admin`}),cancelRead:j(x({requestId:l().min(1).max(64)}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},dB=S([`primary`,`second-factor`]),fB=x({kind:p(`redirect`),id:l(),label:l(),icon:l().optional(),startUrl:l(),stage:dB,linkable:y().optional(),app:eg.nullable().optional()}),pB=x({kind:p(`widget`),id:l(),addonId:l(),bundle:l(),remote:Lx,stage:dB,app:eg.nullable().optional()}),mB=x({kind:p(`passkey`),id:l(),label:l(),stage:dB,rpId:l(),origin:l().nullable(),app:eg.nullable().optional()}),hB=i(`kind`,[fB,pB,mB]),gB={name:`login-method`,scope:`system`,mode:`collection`,internal:!0,methods:{getLoginMethods:A(v(),C(hB).readonly())},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},_B=x({sleeping:y().meta({label:`Sleeping`}),lastContactAt:n().optional(),lastUpdated:n().meta(N(`none`))}),vB={name:`low-power-sleep`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{wakeUp:A(x({deviceId:n(),timeoutMs:n().int().min(500).max(3e4).default(8e3)}),x({awoke:y(),durationMs:n()}),{kind:`mutation`,notOperatorFacing:`a stream consumer wakes a sleeping camera to watch it; an automation that wants footage asks for the footage`})},status:{schema:_B,kind:`push`,empty:{sleeping:!1,lastUpdated:0}},runtimeState:_B,durability:`restored`,history:`none`,volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Low-power sleep`,`Sospensione a basso consumo`),order:5245}},nEe=x({id:l(),label:l(),scope:S([`mesh`,`public`]),url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`])}),yB=x({id:l(),hostname:l(),magicDns:l(),addresses:C(l()).readonly(),os:l().optional(),online:y(),lastSeenMs:n(),isSelf:y(),connection:S([`direct`,`relay`,`idle`]),relay:l().nullable(),lastHandshakeMs:n(),rxBytes:n(),txBytes:n(),tags:C(l()).readonly(),exitNodeOption:y(),advertisedRoutes:C(l()).readonly(),userLogin:l().nullable(),keyExpiry:n().nullable()}),bB=x({joined:y(),meshIp:l(),magicDnsHostname:l(),peerCount:n(),endpoints:C(nEe).readonly(),error:l().optional(),tenantName:l(),magicDnsSuffix:l(),userLogin:l().nullable(),controlPlaneUrl:l(),keyExpiry:n().nullable(),daemonSocket:l().optional(),daemonCliPath:l().optional()}),xB={name:`mesh-network`,scope:`system`,mode:`collection`,providerKind:`mesh`,methods:{getStatus:A(v(),bB),join:A(x({authKey:l().min(8),hostname:l().optional()}),x({joined:p(!0)}),{kind:`mutation`}),startLogin:A(x({hostname:l().optional()}),x({loginUrl:l()}),{kind:`mutation`}),leave:A(v(),x({left:p(!0)}),{kind:`mutation`}),logout:A(v(),x({loggedOut:p(!0)}),{kind:`mutation`}),listPeers:A(v(),x({peers:C(yB).readonly()}))},vocabulary:{notOperatorFacing:M.NETWORK}},SB=x({value:n().nullable().meta(N(`device`,{label:`Total`})),lastFetchedAt:n()}),CB={name:`meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:SB,kind:`push`},runtimeState:SB,durability:`restored`,history:{fields:{value:{kind:`counter`,deadband:.001,minIntervalMs:6e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Meter`,`Contatore`),order:5140,state:[{kind:`numeric`,field:`value`,quantity:F(`the total`,`il totale`),label:F(`Total`,`Totale`),icon:`gauge`}]}},rEe=x({total:n(),user:n(),system:n(),irq:n(),nice:n(),loadAvg:u([n(),n(),n()]),cores:n()}),iEe=x({percent:n().nullable(),totalBytes:n(),usedBytes:n().nullable(),availableBytes:n().nullable(),swapUsedBytes:n(),swapTotalBytes:n()}),aEe=x({readBytes:n(),writeBytes:n(),readOps:n(),writeOps:n(),timestampMs:n()}),oEe=x({rxBytes:n(),txBytes:n(),rxPackets:n(),txPackets:n(),rxErrors:n(),txErrors:n(),timestampMs:n()}),wB=x({utilization:n(),model:l(),memoryUsedBytes:n(),memoryTotalBytes:n(),temperature:n().nullable()}),sEe=x({openFds:n(),threadCount:n(),activeHandles:n(),activeRequests:n()}),TB=x({avg10:n(),avg60:n(),avg300:n()}),EB=x({some:TB,full:TB.nullable()}),DB=x({cpu:rEe,memory:iEe,gpu:wB.nullable(),network:oEe,disk:aEe,pressure:x({cpu:EB.nullable(),memory:EB.nullable(),io:EB.nullable()}),process:sEe,cpuTemperature:n().nullable(),timestampMs:n()}),cEe=x({path:l(),totalBytes:n(),usedBytes:n(),availableBytes:n(),percent:n()}),OB=x({pid:n(),cpu:n(),memory:n(),privateBytes:n().optional(),sharedBytes:n().optional()}),lEe=x({addonId:l(),nodeId:l(),role:S([`hub`,`worker`]),pid:n(),state:S([`starting`,`running`,`stopping`,`stopped`,`crashed`]),uptimeSec:n()}),uEe=x({pid:n(),ppid:n(),pgid:n(),classification:S([`root`,`managed`,`system`]),addonId:l().nullable(),nodeId:l().nullable(),command:l(),cpuPercent:n(),memoryRssBytes:n(),cpuMainPercent:n().nullable(),cpuGcPercent:n().nullable(),threadCount:n().nullable(),uptimeSec:n()}),dEe=x({source:S([`cgroup-v2`,`cgroup-v1`]),currentBytes:n(),limitBytes:n().nullable(),anonBytes:n().nullable(),fileBytes:n().nullable(),shmemBytes:n().nullable(),slabBytes:n().nullable(),gpuShmemBytes:n().nullable()}).extend({atMs:n()}),fEe=x({atMs:n(),samples:n().int(),cpuMainPercent:n().nullable(),cpuMainPercentMin:n().nullable(),cpuGcPercent:n().nullable(),cpuGcPercentMin:n().nullable(),cpuLifetimePercent:n(),cpuLifetimePercentMin:n(),memoryRssBytes:n(),memoryRssBytesMin:n(),processCount:n().int(),processCountMin:n().int()}),pEe=x({key:l(),kind:S([`addon`,`root`,`unattributed`]),points:C(fEe).readonly()}),mEe=x({nodeId:l(),series:C(pEe).readonly(),containerMemory:C(dEe).readonly(),bucketMs:n(),retainedSamples:n(),oldestAtMs:n().nullable(),cadenceMs:n(),durable:y()}),hEe=x({forNodeId:l(),sinceMs:n().optional(),maxPoints:n().int().positive().optional()}),kB=x({cpuPercent:n(),memoryPercent:n().nullable(),memoryUsedMB:n().nullable(),memoryTotalMB:n(),diskPercent:n().optional(),temperature:n().optional(),gpuPercent:n().optional(),gpuMemoryPercent:n().optional()}),AB={name:`metrics-provider`,scope:`system`,mode:`singleton`,methods:{collectSnapshot:A(v(),DB),getCached:A(v(),DB.nullable()),getCurrent:A(v(),kB),getDiskSpace:A(x({dirPath:l()}),cEe),getGpuInfo:A(v(),wB.nullable()),getCpuTemperature:A(v(),n().nullable()),getProcessStats:A(x({pids:C(n())}),C(OB)),listAddonInstances:A(v(),C(lEe).readonly()),getAddonStats:A(x({addonId:l()}),OB.nullable()),listNodeProcesses:A(v(),C(uEe).readonly()),getLoadSeries:A(hEe,mEe)},vocabulary:{notOperatorFacing:M.CLUSTER}},jB=l().min(1).max(256),MB=m(l(),w()),NB=x({id:jB,deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:MB}),PB=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:MB}),FB=m(Hr,h([l(),n(),y(),x({in:C(h([l(),n(),y()])).min(1).max(_n)}),x({gt:h([l(),n()]).optional(),gte:h([l(),n()]).optional(),lt:h([l(),n()]).optional(),lte:h([l(),n()]).optional()}).refine(e=>Object.keys(e).length>0,{message:`name at least one bound`})])),IB={kind:Jr},LB={deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional()},RB=x({...IB,...LB,where:FB.optional(),order:S([`at`,`id`]).optional(),desc:y().optional(),limit:n().int().min(1).max(yn).default(100),cursor:l().min(1).optional()}),zB=x({records:C(PB),nextCursor:l().nullable()}),gEe=S([`created`,`unchanged`,`updated`]),BB=x({kindId:n().int(),state:gEe,createdIndexes:C(l())}),VB=C(l()),HB=i(`op`,[x({op:p(`put`),kind:Jr,record:NB,ifRev:n().int().min(0).optional()}),x({op:p(`patch`),kind:Jr,id:jB,data:MB,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({op:p(`delete`),kind:Jr,id:jB})]),UB=m(l(),m(l(),l())),WB={name:`records`,scope:`system`,mode:`singleton`,internal:!0,methods:{declareKinds:A(x({kinds:m(Jr,qr)}),x({kinds:m(l(),BB)}),{kind:`mutation`,auth:`admin`}),get:A(x({...IB,id:jB}),PB.nullable(),{auth:`admin`}),getMany:A(x({...IB,ids:C(jB).min(1).max(_n)}),C(PB),{auth:`admin`}),secretRefs:A(x({...IB,ids:C(jB).min(1).max(_n)}),UB,{auth:`admin`}),put:A(x({...IB,record:NB,ifRev:n().int().min(0).optional()}),x({rev:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),putMany:A(x({...IB,records:C(NB).min(1).max(_n)}),x({count:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),patch:A(x({...IB,id:jB,data:MB,at:n().int().nullable().optional(),expiresAt:n().int().nullable().optional(),ifRev:n().int().min(1).optional()}),x({rev:n().int(),releasedRefs:VB}),{kind:`mutation`,auth:`admin`}),delete:A(x({...IB,id:jB}),x({deleted:y(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),deleteMany:A(x({...IB,ids:C(jB).min(1).max(_n)}),x({deleted:n().int(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),query:A(RB,zB,{auth:`admin`}),count:A(x({...IB,...LB,where:FB.optional()}),x({count:n().int()}),{auth:`admin`}),histogram:A(x({...IB,deviceId:n().int().optional(),from:n(),to:n(),bucketMs:n().int().positive()}),x({buckets:C(x({bucketStart:n(),count:n().int()}))}),{auth:`admin`}),aggregate:A(x({...IB,op:S([`sum`,`min`,`max`,`count`]),field:Hr.optional(),groupBy:Hr.optional(),where:FB.optional()}),x({rows:C(x({group:h([l(),n(),ae()]),value:n().nullable()}))}),{auth:`admin`}),deleteWhere:A(x({...IB,deviceId:n().int().optional(),atBefore:n().optional(),where:FB.optional()}),x({deleted:n().int(),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),transact:A(x({ops:C(HB).min(1).max(_n)}),x({results:C(x({rev:n().int().nullable(),deleted:y()})),releasedRefs:VB,secretRefs:VB}),{kind:`mutation`,auth:`admin`}),deleteDevice:A(x({deviceId:n().int(),kinds:C(Jr).optional()}),x({deleted:m(l(),n().int()),secretRefs:VB}),{kind:`mutation`,auth:`admin`}),allocateId:A(x(IB),x({id:n().int()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},GB=m(l(),w()),KB=x({integrationId:l().min(1)}),qB=x({id:l().min(1)}),JB=x({id:l(),deviceId:n().int().nullable(),at:n().nullable(),expiresAt:n().nullable(),rev:n().int(),updatedAt:n(),data:GB}),YB={id:l().min(1),deviceId:n().int().optional(),at:n().int().optional(),expiresAt:n().int().optional(),data:GB},XB=x({id:l(),addonId:l(),name:l(),info:GB,enabled:y().optional(),originStableId:l().optional()}),_Ee=x({id:n().int(),integrationId:l().nullable().optional(),parentDeviceId:n().int().nullable().optional(),type:l().optional(),name:l().optional(),stableId:l().optional()}),ZB=x({version:n().int(),methods:C(l())}),QB=x({message:l(),meta:GB.optional(),tags:x({deviceId:n().int().optional()}).optional()}),vEe={"ledger.declare":{input:x({owner:l().min(1),metas:C(rf)}),output:x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(vf),migrationApi:ZB.optional()}),behaviours:[`ledger.declare.answers-steps-in-engine-order`,`ledger.declare.answers-the-migration-api`]},"ledger.start":{input:x({id:l().min(1)}),output:x({proceed:y(),state:h([p(`pending`),mf]),reason:l().nullable()}),behaviours:[`ledger.start.proceeds-when-predecessors-applied`]},"ledger.finish":{input:x({id:l().min(1),result:pf}),output:x({status:mf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),behaviours:[`ledger.finish.records-the-outcome`]},"legacyRows.read":{input:KB,output:GB,behaviours:[`legacyRows.read.returns-stored-rows`,`legacyRows.read.absent-store-is-empty`,`legacyRows.caller.sibling-package`]},"legacyRows.clear":{input:KB,output:x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),behaviours:[`legacyRows.clear.deletes-the-rows`,`legacyRows.clear.absent-store-is-noop`]},"legacyRows.patch":{input:KB.extend({patch:GB}),output:x({written:y()}),behaviours:[`legacyRows.patch.upserts-keys-and-keeps-the-rest`,`legacyRows.patch.absent-store-writes-nothing`]},"legacyRows.deleteKeys":{input:KB.extend({keys:C(l().min(1))}),output:x({present:y(),removed:GB}),behaviours:[`legacyRows.deleteKeys.removes-the-named-keys`,`legacyRows.deleteKeys.absent-store-reports-not-present`]},"records.get":{input:qB,output:JB.nullable(),behaviours:[`records.get.returns-the-row-or-null`]},"records.getResolved":{input:qB,output:JB.nullable(),behaviours:[`records.getResolved.resolves-secret-fields`]},"records.put":{input:x({...YB,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.put.creates-and-replaces`,`records.put.if-rev-conflict-throws`]},"records.putMany":{input:x({records:C(x(YB))}),output:x({count:n().int().nonnegative()}),behaviours:[`records.putMany.writes-every-row`]},"records.patch":{input:qB.extend({partial:GB,ifRev:n().int().optional()}),output:x({rev:n().int()}),behaviours:[`records.patch.merges-and-null-removes`]},"records.delete":{input:qB,output:x({deleted:y()}),behaviours:[`records.delete.reports-whether-a-row-went`]},"records.query":{input:x({deviceId:n().int().optional(),atFrom:n().optional(),atTo:n().optional(),where:FB.optional(),limit:n().int().min(1).optional(),cursor:l().min(1).optional(),resolveSecrets:y().optional()}),output:x({records:C(JB),nextCursor:l().nullable()}),behaviours:[`records.query.pages-with-a-cursor`,`records.query.filters-on-a-declared-index`]},"records.deleteWhere":{input:x({deviceId:n().int().optional(),atBefore:n().optional(),where:FB.optional()}),output:x({count:n().int().nonnegative()}),behaviours:[`records.deleteWhere.deletes-the-matching-rows`]},"settings.read":{input:x({}),output:x({store:GB}),behaviours:[`settings.read.returns-the-addon-store`]},"settings.write":{input:x({patch:GB}),output:x({}),behaviours:[`settings.write.merges-and-keeps-other-keys`]},"settings.deleteKeys":{input:x({keys:C(l().min(1))}),output:x({removed:C(l())}),behaviours:[`settings.deleteKeys.removes-only-the-named-keys`]},"deviceSettings.listIds":{input:x({}),output:x({deviceIds:C(n().int())}),behaviours:[`deviceSettings.listIds.names-only-the-addons-own-devices`]},"deviceSettings.read":{input:x({deviceIds:C(n().int())}),output:x({blobs:m(l(),GB)}),behaviours:[`deviceSettings.read.returns-only-the-addons-own-blobs`]},"secrets.resolve":{input:x({refs:C(l())}),output:x({values:m(l(),l().nullable())}),behaviours:[`secrets.resolve.answers-null-for-a-missing-ref`]},"secrets.put":{input:x({ref:l().min(1),value:l()}),output:x({}),behaviours:[`secrets.put.stores-under-the-owner`]},"secrets.delete":{input:x({refs:C(l())}),output:x({deleted:n().int().nonnegative()}),behaviours:[`secrets.delete.ignores-unknown-refs`]},"integrations.list":{input:x({}),output:x({integrations:C(XB)}),behaviours:[`integrations.list.lists-every-integration`]},"integrations.get":{input:x({id:l().min(1)}),output:XB.nullable(),behaviours:[`integrations.get.null-for-an-unknown-id`]},"devices.list":{input:x({addonId:l().min(1),integrationId:l().min(1).optional()}),output:x({devices:C(_Ee)}),behaviours:[`devices.list.scoped-to-the-addon`,`devices.list.filters-by-integration`]},"devices.get":{input:x({deviceId:n().int()}),output:x({id:n().int(),integrationId:l().nullable(),hasConfig:y()}).nullable(),behaviours:[`devices.get.null-for-an-unknown-id`,`devices.get.reports-link-and-config`]},"devices.aliases":{input:x({deviceIds:C(n().int())}),output:x({aliases:m(l(),l())}),behaviours:[`devices.aliases.answers-for-the-named-ids-only`]},"devices.setIntegrationId":{input:x({deviceId:n().int(),integrationId:l().min(1)}),output:x({}),behaviours:[`devices.setIntegrationId.links-the-device`]},"node.localNodeId":{input:x({}),output:x({nodeId:l()}),behaviours:[`node.localNodeId.names-this-node`]},"log.info":{input:QB,output:x({}),behaviours:[`log.info.writes-a-line`]},"log.warn":{input:QB,output:x({}),behaviours:[`log.warn.writes-a-line`]}},$B={name:`migrations`,scope:`system`,mode:`singleton`,internal:!0,methods:{listLedger:A(x({}),x({entries:C(hf)}),{auth:`admin`}),listPending:A(x({owner:l().optional()}),x({pending:C(gf)}),{auth:`admin`}),dryRun:A(x({id:l().min(1)}),_f,{auth:`admin`}),markFailed:A(x({id:l().min(1),error:l().min(1)}),hf,{kind:`mutation`,auth:`admin`}),retry:A(x({id:l().min(1)}),x({entries:C(hf)}),{kind:`mutation`,auth:`admin`}),restorePreMigration:A(x({database:Ud,snapshotId:l().min(1)}),x({scheduled:y(),held:C(l()),restartRequired:y()}),{kind:`mutation`,auth:`admin`}),declareOwner:A(x({owner:l().min(1),metas:C(rf),retired:C(l().min(1)).optional()}),x({bootId:l(),snapshot:S([`none`,`written`,`refused`]),steps:C(vf),migrationApi:ZB.optional()}),{kind:`mutation`,auth:`admin`}),startMigration:A(x({id:l().min(1)}),x({proceed:y(),state:h([p(`pending`),mf]),reason:l().nullable()}),{kind:`mutation`,auth:`admin`}),finishMigration:A(x({id:l().min(1),result:pf}),x({status:mf,error:l().nullable(),rowsChanged:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),readLegacyIntegrationRows:A(x({integrationId:l().min(1)}),m(l(),w()),{auth:`admin`}),clearLegacyIntegrationRows:A(x({integrationId:l().min(1)}),x({rows:n().int().nonnegative(),secrets:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),patchLegacyIntegrationRows:A(x({integrationId:l().min(1),patch:m(l(),w())}),x({written:y()}),{kind:`mutation`,auth:`admin`}),deleteLegacyIntegrationRowKeys:A(x({integrationId:l().min(1),keys:C(l().min(1))}),x({present:y(),removed:m(l(),w())}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},eV=x({sourceUrl:l(),metadata:vde,targets:C(_de).min(1).readonly(),calibrationRef:l().optional(),sessionId:l().optional()}),tV={name:`model-convert`,scope:`system`,mode:`singleton`,internal:!0,methods:{convert:A(eV,bde,{kind:`mutation`,auth:`admin`,timeoutMs:6e5})},vocabulary:{notOperatorFacing:M.ML}},nV=x({targetNodeId:l(),modelId:l(),format:S(va),entry:Vh}),rV=x({ok:y(),sha256:l(),bytes:n(),path:l()}),iV={name:`model-distributor`,scope:`system`,mode:`singleton`,internal:!0,methods:{distributeModel:A(nV,rV,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.ML}},aV=i(`kind`,[x({kind:p(`camera`)}),x({kind:p(`sensor`),deviceId:n().int().positive()})]),oV=Object.freeze({kind:`camera`});function yEe(e){if(e===void 0)return{triggeredBy:oV,malformed:!1};let t=aV.safeParse(e);return t.success?{triggeredBy:t.data,malformed:!1}:{triggeredBy:oV,malformed:!0}}var bEe=`cameraSensors`,xEe=8,sV=x({addonId:l().min(1),stableId:l().min(1)});function cV(e){return`${e.addonId}/${e.stableId}`}var lV=S([`in-addition`,`confirm`,`replace`]),uV=`in-addition`,dV=sV.extend({mode:lV.default(uV)}),fV=x({sensors:C(dV).min(1).max(8)}).superRefine((e,t)=>{let n=new Set;e.sensors.forEach((e,r)=>{let i=cV(e);n.has(i)&&t.addIssue({code:`custom`,path:[`sensors`,r],message:`duplicate camera sensor ${i}`}),n.add(i)})}),pV={addonId:l(),stableId:l(),mode:lV.default(uV)},mV=i(`state`,[x({...pV,state:p(`ready`),deviceId:n(),name:l(),caps:C(l()).readonly()}),x({...pV,state:p(`offline`),deviceId:n(),name:l(),reason:S([`offline`,`disabled`])}),x({...pV,state:p(`missing`),reason:l()}),x({...pV,state:p(`unsupported`),deviceId:n(),name:l(),reason:l()}),x({...pV,state:p(`unreadable`),reason:l()})]),hV=S([`onboard-not-listed`,`no-active-detection`]),gV=S([`always`,`when-confirmed`,`never`]),_V=S([`provider-not-split`]),vV=x({detected:y(),atMs:n()}),yV=i(`state`,[x({state:p(`not-configured`),cameraLevel:vV.optional()}),x({state:p(`unreadable`),reason:l(),cameraLevel:vV.optional()}),x({state:p(`configured`),cameraLevel:vV.optional(),sensors:C(mV).readonly(),cameraMotion:gV.optional(),notForwarded:hV.optional(),notEnforced:_V.optional()})]),SEe=Object.freeze({state:`unreadable`,reason:`camera sensor mappings not loaded`}),bV=x({bbox:AS,pixelCount:n(),intensity:n()}),xV=x({detected:y(),regionCount:n(),regions:C(bV).readonly(),rawRegions:C(bV).readonly(),frameWidth:n(),frameHeight:n(),analysisMs:n()}),SV={name:`motion-detection`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{analyze:A(x({deviceId:n(),frame:kS.optional(),frameHandle:na.optional()}),xV,{role:`admin`,kind:`mutation`,notOperatorFacing:`the pipeline feeds it frames — an internal stage, never called by a person`}),removeCamera:A(x({deviceId:n()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping when a camera leaves`}),reset:A(v(),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`pipeline housekeeping`})},events:{onMotion:{data:x({deviceId:n(),detected:y(),regionCount:n()}),notOperatorFacing:"the analyzer’s raw verdict; the operator signal is the `motion` cap’s `detected` state"}},vocabulary:{noun:F(`Motion analysis`,`Analisi del movimento`),order:3160}},CV=x({package:y(),confidence:n().min(0).max(1),reason:l().min(1)}),wV=x({x:n(),y:n()}),TV=x({kind:p(`rect`),x:n(),y:n(),width:n(),height:n()}),EV=x({kind:p(`polygon`),points:C(wV)}),DV=x({kind:p(`grid`),gridWidth:n().meta(N(`none`)),gridHeight:n().meta(N(`none`)),cells:C(y())}),OV=x({kind:p(`line`),points:C(wV)}),CEe=i(`kind`,[TV,EV,DV,OV]),kV=S([`rect`,`polygon`,`grid`,`line`]),AV=x({min:n(),max:n()}),jV=x({width:n(),height:n()}),MV=[`owner-not-ready`,`store-read-failed`,`three-way-read-unavailable`,`invalid-stored`,`not-cluster-scoped`],NV=[{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)`}]}],wEe=`cluster-step-models`;function PV(e){return`clusterModel:${e}`}function TEe(e){return NV.some(t=>t.stepId===e)}var FV=Object.freeze(Object.fromEntries(NV.map(e=>[e.stepId,e.defaultModelId])));function IV(e){return e==null||e===``?{kind:`absent`}:typeof e==`string`?{kind:`chosen`,modelId:e}:{kind:`invalid`,value:e}}function LV(e){let t=[];for(let n of NV){let r=IV(e[PV(n.stepId)]);r.kind===`invalid`&&t.push({stepId:n.stepId,value:r.value})}return t}function RV(e){let t={};for(let n of NV){let r=IV(e[PV(n.stepId)]);t[n.stepId]=r.kind===`chosen`?r.modelId:n.defaultModelId}return t}function EEe(e){return typeof e==`object`&&!!e&&`key`in e}function DEe(e){return e===null?FV:RV(BV(e,zV()))}function OEe(e){return e===null?[]:LV(BV(e,zV()))}function zV(){return new Set(NV.map(e=>PV(e.stepId)))}function BV(e,t){let n={};for(let r of e.sections)for(let e of r.fields)!EEe(e)||typeof e.key!=`string`||t.has(e.key)&&(n[e.key]=e.value);return n}function kEe(e,t){let n=NV.find(t=>t.stepId===e);if(n===void 0)return null;let r=t[e];return r!==void 0&&r!==``?r:n.defaultModelId}var AEe=24,VV=[{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 HV(e,t){return`clusterStepSetting:${e}:${t}`}function jEe(e){return VV.filter(t=>t.stepId===e)}var MEe=n().finite();function UV(e){let t={};for(let n of VV){let r=MEe.safeParse(e[HV(n.stepId,n.key)]),i=r.success?r.data:n.default,a=t[n.stepId]??{};t[n.stepId]={...a,[n.key]:i}}return t}var WV=UV({});function NEe(e){return e===null?WV:UV(BV(e,new Set(VV.map(e=>HV(e.stepId,e.key)))))}function PEe(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 GV=S([`new`,`entered`,`left`,`moving`,`idle`]),KV=S([`motion`,`object`,`audio`]),qV=i(`kind`,[TV,EV]),JV=S([`motion`,`audio`,`person`,`vehicle`,`animal`,`door`,`pir`,`smoke`,`water`,`button`,`package`,`generic`]),YV=S([`motion`,`audio`,`detection`,`sensor`,`control`,`custom`,`package`]),FEe=S([`macro`,`sub`]),XV=x({kind:l(),labelKey:l(),label:l(),color:l(),iconId:l(),icon:JV,category:YV,parentKind:l().nullable(),level:FEe,source:x({capName:l(),deviceId:n()})}),ZV=x({deviceId:n(),kinds:C(XV).readonly()}),QV=x({id:l(),deviceId:n(),sourceDeviceId:n(),kind:l(),value:m(l(),w()).nullable(),timestamp:n()}),$V=x({x:n(),y:n(),timestamp:n(),bbox:AS,source:S([`frame`,`recovery`]).optional(),score:n().optional()}),IEe=x({timestamp:n(),position:$V,mediaId:n().int()}),eH=x({minX:n(),minY:n(),maxX:n(),maxY:n()}),tH=S([`full`,`slim`]),nH=x({label:l(),peakScore:n(),count:n(),firstAt:n(),lastAt:n()}),rH=S([`pipeline`,`onboard`,`sensor`,`audio`]),iH=S([`none`,`staging`,`trained`]),LEe=500,aH={markForTrain:y().optional(),debug:y().optional(),debugNote:l().max(500).optional(),favourited:y().optional()},oH={retrainStatus:iH.optional()},sH=x(aH),cH=x({trackId:l(),markForTrain:y(),debug:y(),debugNote:l(),favourited:y(),retrainStatus:iH}),REe=h([p(1),p(2)]),lH=x({stepId:l(),modelId:l().optional(),decidedAt:n(),identityId:l().optional()}),uH={label:l().optional(),labelScore:n().optional(),labelMeta:lH.optional(),subLabel:l().optional(),subLabelScore:n().optional(),subLabelMeta:lH.optional()},dH=x({deviceId:n(),tracks:n().int(),files:n().int(),bytes:n().int()}),fH=x({generatedAt:n(),trackCount:n().int(),fileCount:n().int(),byteCount:n().int(),truncated:y(),devices:C(dH).readonly()}),pH=x({nodeId:l(),deviceKey:l().optional(),modelId:l().optional()}),mH=x({trackId:l(),deviceId:n(),className:l(),...uH,producingDeviceName:l().optional(),source:rH.optional(),firstSeen:n(),lastSeen:n(),positions:C($V).readonly(),snapshots:C(IEe).readonly(),zonesVisited:C(l()).readonly(),zoneNames:C(l()).readonly().optional(),classes:C(l()).readonly().optional(),totalDistance:n(),state:GV,active:y(),importance:n().optional(),bestEventId:l().optional(),importanceReason:l().optional(),audioLabels:C(nH).readonly().optional(),envelope:eH.optional(),hasFace:y().optional(),hasEmbeddedFace:y().optional(),hasRider:y().optional(),previewMissReason:l().optional(),modelId:l().optional(),openedPlacement:pH.optional(),closedPlacement:pH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),...aH,...oH}),hH={id:n().int(),deviceId:n(),timestamp:n()},gH=x({...hH,kind:p(`motion`),regionCount:n(),regions:C(x({bbox:AS,pixelCount:n(),intensity:n()})).readonly().optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaUrl:l().optional(),triggeredBy:aV.optional(),durationMs:n().nullable().optional(),edges:C(n()).readonly().optional()}),_H=S([`pipeline`,`onboard`]),vH=S([`enter`,`exit`]),yH=x({direction:vH,zoneId:l(),zoneName:l().optional()}),zEe=x({zoneId:l(),zoneName:l().optional(),overlapPct:n()}),bH=x({...hH,kind:p(`object`),source:_H.optional(),frameId:l().optional(),idempotencyKey:l().optional(),trackId:l().optional(),className:l(),...uH,confidence:n().optional(),bbox:AS.optional(),zones:C(l()).readonly().optional(),zoneOverlaps:C(zEe).readonly().optional(),spawnRefused:l().optional(),state:GV.optional(),zoneCrossing:yH.optional(),frameWidth:n().optional(),frameHeight:n().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),mediaUrl:l().optional(),observedAt:n().optional(),packagePossible:y().optional(),packageLlmVerdict:CV.optional(),importance:n().optional()}),xH=x({...hH,kind:p(`audio`),rms:n(),dbfs:n(),classification:x({className:l(),originalClass:l().optional(),score:n()}).optional(),classifyOutcome:FS.optional(),mediaUrl:l().optional()}),SH=S([`crop`,`thumbnail`,`snapshot`,`firstFrame`,`lastFrame`,`fullFrame`,`fullFrameBoxed`,`faceCrop`,`plateCrop`,`keyFrame`,`keyFrameSmall`,`thumbnailSmall`,`confirmationCrop`,`debugCrop`,`sceneFrame`,`lastSceneFrame`]),CH=x({mediaId:n().int(),kind:SH,sizeBytes:n(),timestamp:n()}),wH=CH.extend({url:l(),base64:l()}),TH=wH.omit({base64:!0}),EH=S([`person`,`vehicle`,`animal`,`package`,`face`,`plate`]),DH=S([`subject`,`model_error`]),OH=S([`operator`,`assist`,`pipeline`,`llm`]),kH=x({x:n(),y:n(),w:n(),h:n()}),AH=x({source:OH,ref:l().min(1),bbox:kH,macroClass:EH,label:l().optional(),score:n().optional(),modelId:l().optional()}),jH=x({ref:l().min(1),snapshot:AH}),MH=S(Gf),NH=x({ref:l(),savedId:l().optional(),status:MH,approximate:y(),origin:AH.optional(),macroClass:EH.optional(),label:l().optional(),iou:n().optional()}),PH=x({boxes:C(NH).readonly(),summary:x({counts:m(MH,n().int()),total:n().int(),changed:n().int(),approximate:y()})}),FH=x({id:l(),trackId:l().optional(),deviceId:n(),mediaKey:l(),bbox:kH,macroClass:EH,label:l().optional(),subLabel:l().optional(),kind:DH,source:OH,assistModelId:l().optional(),assistScore:n().optional(),origin:AH.nullable().optional(),exportedInBatch:l().optional(),createdAt:n()}),IH=FH.omit({id:!0,trackId:!0,deviceId:!0,mediaKey:!0,createdAt:!0,exportedInBatch:!0}),LH=S([`correct`,`wrong`,`wrong-label`]),RH=x({verdict:LH,suggestedClass:l().optional(),suggestedMacroClass:EH.optional(),suggestedLabel:l().optional(),trackId:l(),at:n().optional()}),zH=x({trackId:l(),className:l(),label:l().optional(),bbox:kH.optional(),verdict:LH,suggestedClass:l().optional(),at:n().optional()}),BH=x({trackId:l(),deviceId:n(),className:l(),label:l().optional(),firstSeen:n(),lastSeen:n(),frameCount:n().int(),annotationCount:n().int(),verdict:RH.optional()}),VH=x({mediaId:n().int(),kind:SH,timestamp:n(),sizeBytes:n().int(),copied:y()}),HH=x({bbox:kH,macroClass:EH,label:l().optional(),subLabel:l().optional(),score:n().optional(),modelId:l().optional(),trackId:l(),basis:S([`subject-box`,`position`,`verdict`]),deltaMs:n()}),UH=S([`track`,`recording`]),WH=x({frameId:l(),deviceId:n(),origin:UH,trackId:l().optional(),sourceMediaId:n().int().optional(),epochMs:n().optional(),sourceKind:SH,sizeBytes:n().int(),width:n().int(),height:n().int(),copiedAt:n(),capturedAt:n().optional(),complete:y(),pipelineBoxes:C(HH).readonly().optional(),collectionIds:C(l()).readonly().optional(),verdict:RH.optional(),revision:n().int().optional(),dismissed:C(jH).readonly().optional(),review:PH.optional(),imageUrl:l().optional(),thumbnailUrl:l().optional()}),GH=S([`source-missing`,`unreadable-image`,`write-failed`]),KH=x({copied:C(WH).readonly(),refused:C(x({sourceMediaId:n().int(),reason:GH})).readonly()}),qH=x({candidates:C(VH).readonly(),copies:C(WH).readonly(),autoPickMediaId:n().int().optional()}),JH=S([`unannotated`,`annotated`,`complete`]),YH=x({workState:JH.optional(),deviceIds:C(n()).max(500).optional(),collectionId:l().optional(),classes:C(EH).optional(),page:n().int().positive().default(1),pageSize:n().int().positive().max(100).default(50)}),XH=WH.extend({workState:JH}),ZH=x({frames:C(XH).readonly(),total:n().int().nonnegative(),page:n().int().positive(),pageSize:n().int().positive()}),QH=x({deviceId:n(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),pctOfCorpus:n().min(0).max(1).nullable()}),$H=x({total:n().int().nonnegative(),unannotated:n().int().nonnegative(),annotated:n().int().nonnegative(),complete:n().int().nonnegative(),cameras:C(QH).readonly()}),eU=x({deviceIds:C(n()).optional(),frameIds:C(l()).max(2e4).optional(),collectionIds:C(l()).max(200).optional(),collectionId:l().optional(),batchId:l().optional(),completeOnly:y().optional(),workState:JH.optional(),classes:C(EH).optional()}),tU=S([`frames`,`crops`]),nU=x({kind:p(`http`),method:S([`PUT`,`POST`]),url:l().url(),headers:m(l(),l()).optional()}),rU=x({batchId:l(),frames:n().int(),crops:n().int(),annotations:n().int(),missing:n().int(),bytes:n().int(),sha256:l(),status:n().int()}),iU=i(`kind`,[x({kind:p(`package`),zone:kH.optional()}),x({kind:p(`objects`),modelId:l(),minScore:n().optional()})]),aU=i(`kind`,[x({kind:p(`proposed`),modelId:l(),stepId:l(),minScore:n(),proposals:C(IH).readonly(),belowThreshold:n().int()}),x({kind:p(`refused`),reason:l(),detail:l().optional()})]),oU=x({id:l(),name:l(),createdAt:n(),frameCount:n().int()}),sU=i(`kind`,[x({kind:p(`created`),collection:oU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`])})]),cU=i(`kind`,[x({kind:p(`renamed`),collection:oU}),x({kind:p(`refused`),reason:S([`empty-name`,`duplicate-name`,`unknown-collection`])})]),lU=i(`kind`,[x({kind:p(`added`),collectionId:l(),frame:WH,reused:y()}),x({kind:p(`refused`),reason:S([`unknown-collection`,`still-unavailable`,`still-busy`,`unreadable-image`,`write-failed`]),detail:l().optional()})]),uU=x({id:l(),name:l(),model:l(),kind:l(),leavesHouse:y()}),dU=IH.extend({reason:l()}),fU=x({ref:l(),verdict:S([`confirmed`,`wrong-class`,`not-an-object`,`uncertain`]),suggestedClass:EH.optional(),reason:l()}),pU=i(`kind`,[x({kind:p(`proposed`),profileId:l(),model:l(),leftHouse:y(),proposals:C(dU).readonly(),reviews:C(fU).readonly(),rejected:n().int()}),x({kind:p(`refused`),reason:S([`unknown-frame`,`unreadable-frame`,`unknown-profile`,`profile-disabled`,`no-vision`,`cloud-not-confirmed`,`llm-error`,`malformed-answer`]),detail:l().optional()})]),mU=x({deviceIds:C(n()).readonly().optional(),collectionIds:C(l()).max(200).readonly().optional(),frameIds:C(l()).max(2e4).readonly().optional()}),hU=x({frames:n().int(),completeFrames:n().int(),completeness:n(),subjects:n().int(),modelErrors:n().int(),hardNegatives:n().int(),cells:C(x({macroClass:l(),deviceId:n(),lighting:S([`day`,`night`,`unknown`]),subjects:n().int(),frames:n().int()})).readonly(),cameras:C(x({deviceId:n(),frames:n().int(),completeFrames:n().int()})).readonly()}),BEe=x({id:l(),name:l(),createdAt:n(),selection:mU,layout:tU,completeOnly:y(),frameCount:n().int(),annotationHash:l(),manifestSchema:l(),stats:hU}),gU=x({collectionIds:C(l()).min(1),workState:S([`complete`,`annotated_or_complete`,`any_annotated`]).default(`complete`)}),_U=i(`kind`,[x({kind:p(`resolved`),frameIds:C(l()).max(2e4).readonly(),stats:hU,annotationHash:l(),layout:tU}),x({kind:p(`refused`),reason:S([`unknown-collection`,`no-frames`]),detail:l()})]),vU=x({trackId:l(),retrainStatus:iH,changed:y(),reason:S([`unknown-track`,`no-frames-copied`,`not-staging`,`not-trained`,`unchanged`]).optional()}),yU=1e3,bU=5e3,xU=x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(bU).default(yU),projection:S([`full`,`slim`]).optional()}),VEe=xU.extend({classFilter:l().optional()}),SU=x({deviceIds:C(n()),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(1e3).default(200),cursor:l().optional(),projection:tH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(rH).optional()}),CU=x({tracks:C(mH).readonly(),nextCursor:l().nullable()}),wU=50,TU=200,HEe=x({deviceId:n(),since:n(),until:n(),limit:n().int().min(1).max(TU).default(wU),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),EU=x({id:l(),trackId:l(),timestamp:n(),className:l(),...uH,importance:n(),bestEventId:l(),windowMs:n().optional(),audioLabels:C(nH).readonly().optional(),...aH,...oH}),UEe=x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),limit:n().int().min(1).max(TU).default(wU),minImportance:n().min(0).max(1).optional(),classFilter:l().optional()}),WEe=x({deviceId:n(),events:C(EU).readonly()}),DU=x({bucketStart:n(),motion:n().int(),object:n().int(),audio:n().int(),audioDbfs:n().optional()}),GEe=200,OU=x({deviceId:n(),read:S([`read`,`unreadable`]),buckets:C(DU).readonly()}),KEe=x({trackId:l(),className:l(),confidence:n(),bbox:AS,zones:C(l()).readonly(),state:GV}),qEe=se({id:l(),kind:S([`first-level`,`detail`]),macroClass:l(),score:n(),bbox:x({x:n(),y:n(),width:n(),height:n()}),labels:C(se({label:l(),score:n()})).readonly(),parentId:l().optional()}),kU=bH.extend({score:n()}),JEe=x({text:l(),deviceId:n().optional(),since:n().optional(),until:n().optional(),classFilter:l().optional(),limit:n().default(50),minScore:n().min(0).max(1).optional(),strictness:Nue.optional(),modelId:l().min(1).optional()}),AU=x({tracks:n().int(),events:n().int(),media:n().int(),faces:n().int(),plates:n().int(),embeddings:n().int()}),YEe=x({mediaDropped:n().int(),tracks:n().int(),events:n().int()}),XEe=x({deviceId:n(),rows:n().int(),bytes:n().int()}),ZEe=x({totalRows:n().int(),totalBytes:n().int(),devices:C(XEe).readonly()}),QEe=x({kind:SH,rows:n().int(),bytes:n().int()}),$Ee=x({totalRows:n().int(),totalBytes:n().int(),kinds:C(QEe).readonly(),unaccountedRows:n().int(),unaccountedBytes:n().int()}),jU=x({motion:n().int(),object:n().int(),audio:n().int()}),eDe=x({deviceId:n().optional(),since:n().optional(),until:n().optional(),maxTracks:n().int().positive().optional(),executeOnNodeId:l().optional(),pacingMs:n().int().nonnegative().optional(),force:y().optional()}),tDe=x({deleted:n(),failedIndexes:C(l()).optional()}),MU=S([`stores-unavailable`,...MV,`method-unavailable`,`read-failed`,`reads-disagree`,`not-a-clip-model`,`force-requires-max-tracks`]),nDe=x({started:y(),alreadyRunning:y(),refusal:MU.optional(),modelId:l().optional(),index:l().optional()}),rDe=x({running:y(),scanned:n(),rebuilt:n(),missingKeyFrame:n(),missingEvent:n(),missingBbox:n(),boxSource:x({subjectBox:n(),positions:n(),event:n(),refused:n()}),alreadyInSpace:n(),force:y().nullable(),forcedInSpace:n(),notRunnable:n(),noCapableNode:n(),failed:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable(),modelId:l().nullable(),index:l().nullable()}),iDe=x({started:y(),alreadyRunning:y()}),aDe=x({mode:S([`report`,`reclaim`]).default(`report`),scopes:C(S([`motion-still`,`track-filmstrip`])).min(1).optional(),deviceIds:C(n().int()).min(1).optional(),restart:y().optional(),pageSize:n().int().min(50).max(5e3).optional(),maxRowsPerDevice:n().int().min(1).max(5e5).optional(),maxReclaimPerDevice:n().int().min(1).max(5e5).optional(),maxBytesPerRun:n().int().min(1).optional(),budgetMinutes:n().int().min(1).max(720).optional(),throttleBytesPerSec:n().int().min(64*1024).optional(),graceMinutes:n().int().min(1).max(10080).optional()}),oDe=x({running:y(),mode:S([`report`,`reclaim`]).nullable(),totalExamined:n(),totalEligible:n(),totalReclaimed:n(),totalBytesReclaimed:n(),totalRefused:n(),devicesDone:n(),complete:y().nullable(),startedAtMs:n().nullable(),finishedAtMs:n().nullable(),error:l().nullable()}),NU=S([`motion`,`audio-dbfs`,`battery`,`occupancy`]),sDe=`|`;function cDe(e,t){let n=e??``;return t===void 0?n:`${n}|${t}`}function lDe(e){let t=e.indexOf(`|`);return t<0?{zoneId:e}:{zoneId:e.slice(0,t),className:e.slice(t+1)}}var PU=x({scope:l(),bucketStart:n().int(),samples:n().int().nonnegative(),sum:n(),min:n(),max:n()}),FU={name:`pipeline-analytics`,scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],exposesDeviceSettings:!0,methods:{getActiveTracks:A(x({deviceId:n()}),C(mH).readonly()),getTrack:A(x({deviceId:n(),trackId:l()}),mH.nullable()),listTracks:A(x({deviceId:n(),since:n().optional(),until:n().optional(),limit:n().optional(),zone:qV.optional(),projection:tH.optional(),includeStationary:y().optional(),classes:C(l()).optional(),excludeSources:C(rH).optional()}),C(mH).readonly()),listRecentTracks:A(SU,CU),clearTracks:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`}),getMotionEvents:A(xU,C(gH).readonly()),getObjectEvents:A(VEe,C(bH).readonly()),getAudioEvents:A(xU,C(xH).readonly()),listEventKinds:A(x({deviceId:n()}),C(XV).readonly()),listEventKindsBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(ZV).readonly()),getSensorEvents:A(x({deviceId:n(),since:n().optional(),until:n().optional(),kinds:C(l()).optional(),limit:n().int().min(1).max(bU).default(yU)}),C(QV).readonly()),getKeyEvents:A(HEe,C(EU).readonly()),getKeyEventsBatch:A(UEe,C(WEe).readonly()),readLongTermSeries:A(x({deviceId:n(),series:NU,scope:l().optional(),from:n(),to:n(),limit:n().int().positive().optional()}),C(PU).readonly()),getEventDensity:A(x({deviceId:n(),since:n(),until:n(),bucketMs:n().int().positive()}),C(DU).readonly()),getEventDensityBatch:A(x({deviceIds:C(n()).min(1).max(200),since:n(),until:n(),bucketMs:n().int().positive()}),C(OU).readonly()),pruneEventsBefore:A(x({deviceId:n(),cutoffMs:n()}),x({motion:n().int(),object:n().int(),audio:n().int()}),{kind:`mutation`,auth:`admin`}),pruneTracksBefore:A(x({deviceId:n(),cutoffMs:n()}),AU,{kind:`mutation`,auth:`admin`}),wipeAllAnalytics:A(x({deviceId:n()}),AU,{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(x({deviceId:n()}),YEe,{kind:`mutation`,auth:`admin`}),deleteTracks:A(x({deviceId:n(),trackIds:C(l()).min(1)}),x({deleted:n().int(),failed:C(l()).readonly(),sparedMediaIds:C(n().int()).readonly().optional()}),{kind:`mutation`,auth:`admin`}),setTrackFlags:A(x({deviceId:n(),trackId:l(),flags:sH}),cH,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listArchivedDebugNotes:A(np,C(tp).readonly(),{kind:`query`}),setTrackRelation:A(cp,op,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),clearTrackRelation:A(lp,up,{kind:`mutation`,notOperatorFacing:`curating recorded tracks in the review UI, not a live step`}),setTrackPurity:A(dp,fp,{kind:`mutation`,notOperatorFacing:`curating a recorded track in the review UI, not a live step`}),listTrackRelations:A(pp,mp,{kind:`query`}),listBirthDecisions:A(ep,C($f).readonly(),{kind:`query`}),getEventStoreFootprint:A(x({}),ZEe,{kind:`query`,auth:`admin`}),getEventMediaFootprintByKind:A(x({deviceId:n().int().optional()}),$Ee,{kind:`query`,auth:`admin`}),pruneEvents:A(x({olderThanMs:n(),reason:Sp.optional()}),jU,{kind:`mutation`,auth:`admin`}),deleteDeviceEvents:A(x({deviceId:n()}),jU,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(Xp,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(am,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),qp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateMedia:A($p,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),countUnstampedEventMedia:A(x({}),tm,{auth:`admin`}),getMediaLocationCensus:A(nm,im,{kind:`query`,auth:`admin`}),countRelocatableMedia:A(jm,Am,{kind:`query`,auth:`admin`}),listRelocateMediaJobs:A(x({}),C(qp).readonly(),{kind:`query`,auth:`admin`}),cancelRelocateMedia:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(wp,C(Cp).readonly(),{kind:`query`,auth:`admin`}),reclaimDebugMedia:A(aDe,iDe,{kind:`mutation`,auth:`admin`}),getMediaReclaimStatus:A(x({}),oDe,{kind:`query`,auth:`admin`}),getTrainingExportSummary:A(x({deviceIds:C(n()).optional()}),fH,{kind:`query`,auth:`admin`}),getTrainingExportUrl:A(x({deviceIds:C(n()).optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),listRetrainStaging:A(x({deviceIds:C(n()).optional(),limit:n().int().min(1).max(500).optional()}),C(BH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainCorpusPage:A(YH,ZH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getRetrainCorpusKpi:A(x({}),$H,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),listRetrainFrames:A(x({trackId:l()}),qH,{role:{feature:`retrain`},kind:`query`,auth:`admin`}),selectRetrainFrames:A(x({deviceId:n(),trackId:l(),mediaIds:C(n().int()).min(1)}),KH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deselectRetrainFrame:A(x({deviceId:n(),trackId:l().optional(),frameId:l()}),x({removed:y(),removedAnnotations:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainFrameImage:A(x({frameId:l()}),x({base64:l(),width:n().int(),height:n().int()}),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),subject:iU,nodeId:l().optional()}),aU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainAnnotations:A(x({trackId:l().optional(),frameIds:C(l()).max(2e3).optional()}),C(FH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),saveRetrainAnnotations:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),annotations:C(IH),expectedRevision:n().int().optional(),dismissed:C(jH).optional()}),C(FH).readonly(),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),backfillRetrainOrigins:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),expectedRevision:n().int().optional(),origins:C(x({annotationId:l(),origin:AH})).min(1).max(500)}),x({updated:n().int(),skipped:n().int(),revision:n().int()}),{kind:`mutation`,auth:`admin`}),completeRetrainTrack:A(x({deviceId:n(),trackId:l()}),vU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),restageRetrainTrack:A(x({deviceId:n(),trackId:l()}),vU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),getRetrainExportUrl:A(eU.extend({layout:tU.optional()}),x({url:l()}),{kind:`query`,auth:`admin`}),setRetrainFrameComplete:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),complete:y()}),WH,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),writeRetrainArchive:A(x({filter:eU,layout:tU,target:nU}),rU,{kind:`mutation`,auth:`admin`,timeoutMs:60*6e4}),offerRetrainArchive:A(x({filter:eU,layout:tU}),x({ticket:ri,frames:n().int(),annotations:n().int()}),{kind:`mutation`,auth:`admin`,timeoutMs:12e4}),listRetrainAssistProfiles:A(x({}),C(uU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),proposeRetrainAnnotationsWithLlm:A(x({deviceId:n(),trackId:l().optional(),frameId:l(),profileId:l(),classes:C(EH).min(1),boxes:C(x({ref:l(),bbox:kH,macroClass:EH,label:l().optional()})).max(50),allowCloud:y()}),pU,{kind:`mutation`,auth:`admin`,timeoutMs:18e4}),createRetrainCollection:A(x({name:l().max(120)}),sU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollections:A(x({}),C(oU).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),resolveRetrainTrainingCorpus:A(gU,_U,{kind:`query`,auth:`admin`,timeoutMs:6e4}),renameRetrainCollection:A(x({id:l(),name:l().max(120)}),cU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),deleteRetrainCollection:A(x({id:l()}),x({deleted:y(),removedFrames:n().int()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),addRetrainFrameFromRecording:A(x({collectionId:l(),deviceId:n(),epochMs:n(),verdictSubject:zH.optional()}),lU,{role:{feature:`retrain`},kind:`mutation`,auth:`admin`,timeoutMs:6e4}),addRetrainFramesToCollection:A(x({collectionId:l(),frameIds:C(l()).min(1).max(500)}),x({added:n().int(),alreadyMember:n().int(),unknownFrameIds:C(l()).readonly()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),removeRetrainFrameFromCollection:A(x({collectionId:l(),frameId:l()}),x({removed:y(),deletedFrame:y()}),{role:{feature:`retrain`},kind:`mutation`,auth:`admin`}),listRetrainCollectionFrames:A(x({collectionId:l()}),C(WH).readonly(),{role:{feature:`retrain`},kind:`query`,auth:`admin`}),getEventMedia:A(x({ownerType:Ql,eventId:n().int(),kind:SH.optional(),deviceId:n()}),C(wH).readonly()),getTrackMedia:A(x({trackId:l(),kinds:C(SH).optional(),deviceId:n()}),C(wH).readonly()),listTrackMedia:A(x({trackId:l(),deviceId:n()}),C(TH).readonly()),listEventMedia:A(x({ownerType:Ql,eventId:n().int(),deviceId:n()}),C(TH).readonly()),ownersWithMedia:A(x({deviceId:n(),ownerKind:eu,ownerIds:C(l()).max(5e3)}),C(l()).readonly()),searchObjectEvents:A(JEe,C(kU).readonly(),{caller:`required`}),wipeObjectEmbeddings:A(x({}),tDe,{kind:`mutation`,auth:`admin`}),rebuildObjectEmbeddings:A(eDe,nDe,{kind:`mutation`,auth:`admin`}),getObjectEmbeddingRebuildStatus:A(x({}),rDe)},events:{onFrameTracked:{data:x({deviceId:n(),timestamp:n(),frameWidth:n(),frameHeight:n(),detections:C(qEe).readonly()}),notOperatorFacing:`one tracker frame — stream rate, never an automation trigger`},onTrackStarted:{data:x({deviceId:n(),trackId:l(),className:l()}),trigger:{category:T.PipelineAnalyticsTrackStarted,label:F(`Subject appeared`,`Soggetto comparso`),phrase:F(`When {device} starts following a subject`,`Quando {device} inizia a seguire un soggetto`),icon:`scan-eye`}},onTrackEnded:{data:x({deviceId:n(),trackId:l(),className:l(),durationMs:n()}),trigger:{category:T.PipelineAnalyticsTrackEnded,label:F(`Subject left`,`Soggetto uscito`),phrase:F(`When a subject leaves the view of {device}`,`Quando un soggetto esce dall’inquadratura di {device}`),icon:`scan-eye`}},onDetectionEvent:{data:x({deviceId:n(),kind:KV,eventId:l(),timestamp:n()}),trigger:{category:T.PipelineAnalyticsDetectionEvent,label:F(`Detection event`,`Evento di rilevamento`),phrase:F(`When {device} records a detection event`,`Quando {device} registra un evento di rilevamento`),icon:`radar`}}},vocabulary:{noun:F(`Tracking`,`Tracciamento`),order:3200,extraEvents:[{category:T.PipelineAnalyticsPackageDelivered,label:F(`Package delivered`,`Pacco consegnato`),phrase:F(`When a package is left in front of {device}`,`Quando viene lasciato un pacco davanti a {device}`),icon:`package`},{category:T.PipelineAnalyticsPackagePickedUp,label:F(`Package picked up`,`Pacco ritirato`),phrase:F(`When a package is picked up in front of {device}`,`Quando viene ritirato un pacco davanti a {device}`),icon:`package-open`}]}},IU=x({x:n(),y:n(),w:n(),h:n()}),LU=x({stepId:l(),modelId:l(),detections:C(x({bbox:u([n(),n(),n(),n()]),score:n(),landmarks:C(x({x:n(),y:n()})).optional()})).min(1)}),RU=x({handle:na,cropFrameSpace:x({x:n(),y:n(),w:n(),h:n()})});x({crop:x({left:n(),top:n(),width:n().positive(),height:n().positive()}).optional(),content:x({width:n().int().positive(),height:n().int().positive()}),fit:S([`stretch`,`contain`]),format:S([`rgb`,`gray`,`jpeg`])});var uDe=x({registryId:l().min(1),id:l().min(1),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`gray`]),timestamp:n(),capturedAt:n().optional()}),zU=S([`onnx`,`coreml`,`openvino`,`tflite`,`pt`,`gguf`]),BU=S([`detector`,`cropper`,`classifier`,`refiner`,`audio-classifier`]),VU=x({runtime:p(`python`),backend:l(),format:zU,device:l().optional()}),HU=x({deviceKey:l().nullable(),runtime:l(),batchMode:l(),windowMs:n(),maxBatchSize:n(),concurrency:n(),numWorkers:n()}),dDe=x({engine:VU,devices:C(x({id:l(),label:l(),description:l().optional()})).readonly(),defaultDevice:l()}),UU=a(()=>x({addonId:l(),addonName:l(),slot:BU,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),enabled:y(),modelId:l(),children:C(UU).readonly(),group:l().optional(),settings:m(l(),w()).optional()})),fDe=x({id:l(),name:l(),formats:m(l(),ude),group:Rh.optional(),legacy:y().optional(),provider:zh.optional(),defaultConfidence:n().optional(),suppliesSteps:C(Bh).readonly().optional()}),pDe=ve(),mDe=x({id:l(),name:l(),slot:BU,inputClasses:C(l()).readonly(),outputClasses:C(l()).readonly(),childSlots:C(BU).readonly(),models:C(fDe).readonly(),defaultModelId:l(),defaultModelIdByFormat:m(l(),l()).optional(),enabledByDefault:y().optional(),defaultConfidence:n(),group:l().optional(),configSchema:C(pDe).readonly().optional()}),hDe=x({id:BU,label:l(),priority:n(),parentSlot:BU.nullable(),addons:C(mDe).readonly()}),gDe=x({availableEngines:C(dDe).readonly(),selectedEngine:VU,slots:C(hDe).readonly()}),_De=x({runtimeId:S([`onnx`,`openvino`,`coreml`,`edgetpu`]).nullable(),device:l().nullable(),state:S([`idle`,`installing`,`verifying`,`ready`,`failed`]),progress:n().optional(),error:l().optional(),nextRetryAt:n().optional(),configIssues:C(l()).optional()}),WU=x({addonId:l(),chosen:l(),running:l(),format:l()}),GU=x({addonId:l(),kind:S([`unknown-addon`,`no-format-build`,`unknown-device`]),detail:l()}),KU=x({ok:y(),issues:C(GU).readonly(),substitutions:C(WU).readonly(),format:l()}),vDe=x({filename:l(),stepIds:C(l()).readonly().optional()}),yDe=x({base64:l(),filename:l()}),bDe=x({filename:l(),sizeKb:n()}),xDe=x({base64:l()}),SDe=x({id:l(),name:l(),description:l(),available:y(),rawLabels:C(l()).readonly().optional()}),CDe=x({activeBackend:l(),availableBackends:C(SDe).readonly(),sampleRate:n(),chunkDurationMs:n()}),wDe=x({filePath:l(),sizeMB:n(),durationMs:n()}),TDe=x({success:y(),error:l().optional(),frame:ve().optional()}),EDe=ve(),DDe=ve(),ODe=ve(),kDe=ve(),qU={name:`pipeline-executor`,scope:`system`,mode:`singleton`,methods:{getAvailableEngines:A(v(),C(VU)),getSelectedEngine:A(v(),VU),getEngineProvisioning:A(x({nodeId:l()}),_De),getVideoPipelineSteps:A(v(),m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))),setVideoPipelineSteps:A(x({steps:m(l(),x({modelId:l(),settings:m(l(),w()).readonly()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getInferenceDeviceHealth:A(x({nodeId:l()}),x({unhealthy:C(x({deviceKey:l(),state:S([`failed`,`backoff`]),since:n(),deaths:n(),lastError:l(),absentReason:S([`no-gpu-device`]).optional()})).readonly()})),rearmInferenceDevice:A(x({nodeId:l(),deviceKey:l()}),x({rearmed:y()}),{kind:`mutation`,auth:`admin`}),getSchema:A(v(),gDe),getOrchestratorConfigSchema:A(v(),EDe),validatePipeline:A(x({steps:C(Ea),deviceKey:l().optional()}),KU),getCapabilities:A(v(),ODe),getAddonModels:A(x({addonId:l()}),kDe),downloadModel:A(x({addonId:l(),modelId:l(),format:zU}),wDe,{kind:`mutation`}),deleteModel:A(x({addonId:l(),modelId:l(),format:zU}),x({success:p(!0)}),{kind:`mutation`}),runPipeline:A(x({steps:C(Ea).min(1),frame:kS.optional(),frameRef:uDe.optional(),frameHandle:na.optional(),imageBase64:l().optional(),image:b(Uint8Array).optional(),referenceImage:l().optional(),deviceId:n().optional(),sessionId:l().optional(),plane:S([`full`,`frame`]).optional(),deviceKey:l().optional(),nativeCropRef:RU.optional(),replay:p(!0).optional(),suppliedRoot:LU.optional(),motionRegions:C(IU).optional()}),Da,{kind:`mutation`}),runPipelineBatch:A(x({steps:C(Ea).min(1),frames:C(kS).min(1).max(255),deviceId:n().optional(),sessionId:l().optional(),frameId:n().int().nonnegative().optional(),deviceKey:l().optional()}),x({results:C(Da).readonly()}),{kind:`mutation`}),cacheFrameInPool:A(x({data:b(Uint8Array),width:n().int().positive(),height:n().int().positive(),format:S([`rgb`,`bgr`,`gray`])}),x({frameId:n(),width:n(),height:n()}),{kind:`mutation`}),inferCached:A(x({stepId:l(),frameId:n().int(),modelId:l().min(1)}),m(l(),w()),{kind:`mutation`}),uncacheFrame:A(x({frameId:n().int()}),v(),{kind:`mutation`}),getEffectiveTuning:A(x({deviceKey:l().optional()}),HU),listLoadedEngines:A(v(),C(x({engineKey:l(),engine:VU,modelsLoaded:C(l()).readonly(),inUseByCameras:C(n()).readonly(),kind:S([`runtime`,`device-pool`]),poolPid:n().nullable(),idleMs:n().nullable(),idleTtlMs:n().nullable()})).readonly()),spinEngine:A(x({engine:VU}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),killEngine:A(x({engine:VU,force:y().optional()}),x({success:y(),reason:l().optional()}),{kind:`mutation`,auth:`admin`}),listReferenceImages:A(v(),C(vDe).readonly()),getReferenceImage:A(x({filename:l()}),yDe.nullable()),getReferenceAudioFiles:A(v(),C(bDe).readonly()),getReferenceAudio:A(x({filename:l()}),xDe.nullable()),getAudioCapabilities:A(v(),CDe),runAudioTest:A(x({addonId:l(),modelId:l(),filename:l().optional(),settings:m(l(),w()).optional()}),TDe,{kind:`mutation`}),getDetectionConfigSchema:A(v(),DDe)},vocabulary:{notOperatorFacing:M.PIPELINE}},ADe=x({activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),JU=x({detectionMode:S([`disabled`,`always-on`,`on-motion`]),configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceTimeMs:n(),droppedFrames:n(),nativeCropMisses:n().optional(),phase:S([`idle`,`watching`,`active`])}),YU=JU.extend({deviceId:n()}),XU=S([`polygon`,`tripwire`]),ZU=x({x:n(),y:n()}),QU=x({id:l(),name:l(),kind:XU.default(`polygon`),polygon:C(ZU).readonly(),color:l().default(`#3b82f6`)}),$U={name:`zones`,scope:`device`,mode:`singleton`,deviceTypes:[E.Camera],methods:{listZones:A(x({deviceId:n()}),C(QU).readonly()),addZone:A(x({deviceId:n(),zone:QU}),v(),{kind:`mutation`,auth:`admin`}),removeZone:A(x({deviceId:n(),zoneId:l()}),v(),{kind:`mutation`,auth:`admin`}),updateZone:A(x({deviceId:n(),zone:QU}),v(),{kind:`mutation`,auth:`admin`})},runtimeState:x({zones:C(QU).readonly()}),durability:`restored`,history:`none`,vocabulary:{noun:F(`Zones`,`Zone`),order:3370}},eW={fpsPerStream:10,budgetMinutes:45,minBudgetMinutes:10,maxBudgetMinutes:120,staleAfterDays:30,settleSec:5,measureSec:20,drainTimeoutSec:120,maxModelsPerDevice:6},tW=S([`device`,`pipeline`]),nW=x({deviceKey:l().min(1),modelIds:C(l().min(1)).min(1).max(eW.maxModelsPerDevice)}),rW=x({nodeId:l().min(1),devices:C(nW).min(1),phases:C(tW).min(1).default([`device`,`pipeline`]),steps:C(l().min(1)).default([]),fpsPerStream:n().int().min(1).max(30).default(eW.fpsPerStream),budgetMinutes:n().int().min(eW.minBudgetMinutes).max(eW.maxBudgetMinutes).default(eW.budgetMinutes),keepDownloadedModels:y().default(!1),acceptInsufficientHeadroom:y().default(!1)}),iW=S([`benchmark-active`,`node-offline`,`unknown-device`,`no-phase`,`insufficient-headroom`]),aW=x({kind:iW,detail:l(),overridable:y()}),oW=x({deviceId:n(),placedOnNode:y(),pinnedToNode:y()}),sW=x({deviceId:n(),reason:p(`only-frame-source`)}),cW=x({nodeId:l(),online:y(),moving:C(oW).readonly(),staying:C(sW).readonly(),estimatedDurationMs:n(),budgetMs:n(),phases:C(tW).readonly(),steps:C(l()).readonly(),devices:C(nW).readonly(),headroom:x({sessionsNow:n(),otherNodesCapacitySessions:n().nullable()}),refusals:C(aW).readonly(),canStart:y()}),lW=x({phase:S([`preparing`,`device`,`pipeline`,`cleanup`]),deviceKey:l().nullable(),modelId:l().nullable(),load:n().nullable(),cellsDone:n(),cellsTotal:n(),message:l()}),uW=S([`p95`,`drops`,`errors`,`stall`,`cpu`,`ram`,`none`]),dW=x({load:n(),pass:y(),p95Ms:n(),dropRatio:n(),fps:n(),cpuPct:n().nullable(),ramFreePct:n().nullable(),failReasons:C(l()).readonly()}),fW=x({phase:p(`device`),deviceKey:l(),modelId:l(),p50Ms:n(),p95Ms:n(),p99Ms:n(),fps:n(),kMax:n(),limitedBy:uW,warmupMs:n(),ramp:C(dW).readonly()}),pW=x({phase:p(`pipeline`),deviceKey:l(),modelId:l(),steps:C(l()).readonly(),maxSessions:n(),limitedBy:uW,stepsFired:C(l()).readonly(),warmupMs:n(),ramp:C(dW).readonly()}),mW=i(`phase`,[fW,pW]),hW=x({pipelineVersion:l().nullable(),cpuModel:l().nullable(),ramGb:n().nullable(),os:l().nullable(),pools:m(l(),x({runtime:l(),numWorkers:n(),concurrency:n(),batchMode:l()})).default({})}),gW=x({id:l(),revision:l().nullable(),frames:n(),width:n(),height:n()}),_W=x({runId:l().min(1),devices:C(nW).min(1),phases:C(tW).min(1),steps:C(l()).default([]),fpsPerStream:n().int().min(1).max(30),deadlineAtMs:n(),settleSec:n().min(0).max(60).default(eW.settleSec),measureSec:n().min(2).max(300).default(eW.measureSec),keepDownloadedModels:y().default(!1)}),vW=S([`running`,`done`,`failed`,`aborted`]),yW=x({runId:l(),nodeId:l(),state:vW,progress:lW.nullable(),cells:C(mW).readonly(),fingerprint:hW.nullable(),clip:gW.nullable(),activeCameraIds:C(n()).readonly(),deletedModels:C(l()).readonly(),error:l().nullable(),startedAtMs:n(),finishedAtMs:n().nullable()}),bW=S([`draining`,`measuring`,`restoring`,`done`,`failed`,`aborted`]),xW=S([`completed`,`operator-abort`,`deadline`,`node-lost`,`runner-lost`,`hub-restart`,`drain-timeout`,`failed`]),SW=x({runId:l(),nodeId:l(),state:bW,plan:rW,startedAtMs:n(),deadlineAtMs:n(),finishedAtMs:n().nullable(),endReason:xW.nullable(),error:l().nullable(),moved:C(n()).readonly(),staying:C(n()).readonly(),contaminated:y(),progress:lW.nullable(),resultIds:C(l()).readonly()}),CW=x({modeNodeId:l().nullable(),run:SW.nullable()}),wW=x({id:l(),runId:l(),nodeId:l(),cell:mW,fpsPerStream:n(),fingerprint:hW.nullable(),clip:gW.nullable(),contaminated:y(),stayingCameras:C(n()).readonly(),partialRun:y(),measuredAtMs:n()}),TW=x({nodeId:l().optional(),deviceKey:l().optional()}),EW=wW.extend({standing:S([`fresh`,`stale`,`superseded`]),staleWhy:S([`age`,`runtime`,`pool-tuning`]).nullable()}),jDe=x({runId:l(),nodeId:l(),startedAtMs:n(),deadlineAtMs:n(),plan:rW,moved:C(n()).readonly(),staying:C(n()).readonly()}),DW=x({nodeId:l(),reachable:y(),devices:C(x({deviceKey:l(),enabled:y(),available:y(),suggested:C(l()).readonly(),all:C(l()).readonly(),currentModelId:l().nullable()})).readonly(),steps:C(x({id:l(),name:l(),slot:l()})).readonly()}),OW=x({x:n(),y:n(),w:n(),h:n()}),kW=x({bytes:b(Uint8Array).optional(),jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),tier:S([`native`,`ram-fullframe`]).optional()}),AW=S([`keyFrame`,`thumbnail`]),jW=S([`handle-gone`,`encode-failed`]),MW=i(`parked`,[x({parked:p(!0),nodeId:l(),width:n().int().positive(),height:n().int().positive(),bytes:n().int().nonnegative(),replaced:y()}),x({parked:p(!1),nodeId:l(),reason:jW,handleAgeMs:n().nullable(),detail:l().optional()})]),NW=x({jpeg:l().optional(),jpegBytes:b(Uint8Array).optional(),width:n().int().positive(),height:n().int().positive(),timestamp:n(),parkedAt:n()}),MDe=x({bbox:OW,className:l()}),PW=x({stepId:l(),className:l(),score:n(),bbox:OW.optional(),embedding:l().optional(),embeddingMagnitude:n().optional(),embeddingModelId:l().optional(),label:l().optional(),labelTier:h([p(1),p(2)]).optional(),labelModelId:l().optional(),alignedCropJpeg:l().optional(),nativeFaceShortSidePx:n().optional(),landmarks:C(x({x:n(),y:n()})).optional()}),NDe=S([`unknown-step`,`model-not-servable`,`unreadable-frame`,`execution-failed`]),PDe=i(`kind`,[x({kind:p(`ran`),nodeId:l(),modelId:l(),details:C(PW)}),x({kind:p(`refused`),nodeId:l(),reason:NDe,detail:l()})]),FW={min:0,max:6e4,default:3e4,step:500},IW={min:0,max:6e5,default:12e4,step:5e3},LW={min:5e3,max:6e5,default:9e4,step:5e3},RW={min:1,max:30,default:4,step:1},zW={min:1,max:30,default:10,step:1},BW={min:0,max:300,default:300,step:5},VW={min:1,max:10,default:4,step:1},HW={min:0,max:30,default:12,step:1},UW=S([`onboard`,`analyzer`,`device-activity`]),WW=x({source:UW,triggeredBy:aV,sensorName:l().optional()}),GW=C(UW),KW={analyzer:`Frame-diff Analyzer (motion addon)`,onboard:`Camera sensors`,"device-activity":`Device activity (the device says it is working)`};function FDe(e){let t=UW.safeParse(e);return t.success?KW[t.data]:e}var IDe=[`analyzer`,`onboard`,`device-activity`],qW=f(e=>Array.isArray(e)&&e.length>1?e.slice(0,1):e,C(_H).max(1)),JW=x({deviceId:n(),detected:y(),source:UW.default(`analyzer`),regions:C(bV).readonly().optional()}),YW=i(`kind`,[x({kind:p(`local-broker`)}),x({kind:p(`remote-restream`),ownerNodeId:l(),ownerReachableHost:l().optional(),hubHostnameOverride:l().optional()})]).describe(`Per-camera frame-source mode for the runner (P2c)`),XW=x({modelId:l().optional(),settings:m(l(),w()).optional()}),ZW=x({deviceKey:l(),weight:n().positive().default(1),maxSessions:n().int().positive().nullable().default(null),steps:m(l(),XW).optional(),disabledSteps:C(l()).readonly().optional()}),QW=x({deviceId:n(),detectionMode:S([`disabled`,`always-on`,`on-motion`]).default(`on-motion`),audioMode:S([`disabled`,`always-on`,`on-motion`]).default(`always-on`),motionCooldownMs:n().min(FW.min).default(FW.default),maxSessionHoldMs:n().min(IW.min).max(IW.max).optional(),audioMotionWindowMs:n().min(LW.min).max(LW.max).optional(),motionFps:n().min(RW.min).max(RW.max).default(RW.default),detectionFps:n().min(zW.min).max(zW.max).default(zW.default),motionStreamId:l(),detectionStreamId:l(),audioStreamPick:Yi.optional(),motionSources:GW.default([`analyzer`]),sessionTrigger:WW.optional(),detectionSources:qW.default([`pipeline`]),pipelineEnabled:y().default(!0),steps:C(Ea).readonly().optional(),audio:x({modelId:l().optional(),enabled:y()}).nullable().optional(),zones:C(QU).readonly().default([]),onboardMotionDrivesAnalyzer:y().default(!0),preRollInferenceEnabled:y().default(!0),preRollInferenceFrames:n().min(HW.min).max(HW.max).default(HW.default),occupancyRecheckEnabled:y().default(!0),occupancyRecheckSec:n().min(BW.min).max(BW.max).default(BW.default),occupancyRecheckFrames:n().min(VW.min).max(VW.max).default(VW.default),frameSource:YW.default({kind:`local-broker`}),deviceKey:l().optional(),inferenceDevices:C(ZW).readonly().optional()}),LDe=[{key:`motionSources`,type:`multiselect`,label:`Motion Sources`,default:[`analyzer`],options:IDe.map(e=>e===`onboard`?{value:e,label:KW[e],description:`The camera's own motion, plus any sensor attached to it`}:{value:e,label:KW[e]})},{key:`motionFps`,type:`slider`,label:`Motion FPS (analyzer)`,min:RW.min,max:RW.max,step:RW.step,default:RW.default,showValue:!0,unit:`fps`,nullable:!0,nullLabel:`Default`,showWhen:{field:`motionSources`,includes:`analyzer`}},{key:`detectionFps`,type:`slider`,label:`Detection FPS`,min:zW.min,max:zW.max,step:zW.step,default:zW.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:FW.min,max:FW.max,step:FW.step,default:FW.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:IW.min,max:IW.max,step:IW.step,default:IW.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:LW.min,max:LW.max,step:LW.step,default:LW.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:HW.min,max:HW.max,step:HW.step,default:HW.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:BW.min,max:BW.max,step:BW.step,default:BW.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:VW.min,max:VW.max,step:VW.step,default:VW.default,showValue:!0,showWhen:{field:`occupancyRecheckEnabled`,equals:!0}}],$W=x({nodeId:l(),attachedCameras:n(),activeCameras:n(),avgInferenceFps:n(),avgInferenceTimeMs:n(),queueDepthTotal:n(),devices:C(x({deviceKey:l(),backend:l(),attachedCameras:n()})).default([]),hardware:x({hasGpu:y(),inferenceBackend:l().optional(),cpuCores:n().optional()}),motionSliceWriter:p(`orchestrator`).optional()}),eG=x({framesDecoded:n(),framesAdmitted:n(),framesDroppedPixelFree:n(),viewsMaterialized:n(),viewsSkipped:n(),workerToRunnerBytes:n(),runnerToPoolRawBytes:n(),runnerToPoolJpegBytes:n(),onDemandFullFrameRequests:n(),onDemandCropRequests:n(),nativeHits:n(),nativeMisses:n(),tileHits:n(),tileMisses:n(),fallbackHits:n(),fallbackMisses:n(),retainedWritesAvoided:n(),residentRefs:n(),residentBytes:n(),releases:n(),evictions:n(),staleMisses:n()}),tG=x({node:eG,cameras:C(eG.extend({deviceId:n()}))}),nG=x({nodeId:l(),activeCameras:n(),throttledCameras:n(),avgInferenceTimeMs:n(),queueDepth:n(),frameLazy:tG.optional()}),rG=S([`not-attached`,`battery-asleep`,`not-watching`,`already-bursting`]),iG={name:`pipeline-runner`,scope:`system`,mode:`singleton`,methods:{attachCamera:A(QW,x({success:p(!0)}),{kind:`mutation`}),detachCamera:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`}),reportMotion:A(JW,x({success:p(!0)}),{kind:`mutation`}),getLocalLoad:A(v(),$W),getLocalMetrics:A(v(),nG),getCameraMetrics:A(x({deviceId:n()}),JU.nullable()),getAllCameraMetrics:A(v(),C(YU).readonly()),getLocalCameras:A(v(),C(n()).readonly()),requestOccupancyBurst:A(x({deviceId:n(),frames:n().int().positive().optional(),reason:l()}),x({started:y(),refusedBecause:rG.optional()}),{auth:`admin`,kind:`mutation`}),getNativeCrop:A(x({handle:na,bbox:OW,maxWidth:n().int().positive().optional(),acceptJpegBytes:y().optional(),encodeJpeg:y().optional()}),kW.nullable()),runDetailSubtree:A(x({deviceId:n(),frameHandle:na.optional(),frameJpeg:l().optional(),cropJpeg:l().optional(),parent:MDe,steps:C(l()).optional(),supplied:x({stepId:l(),modelId:l(),boxes:C(x({bbox:OW,score:n()})).min(1)}).optional()}),x({details:C(PW)}).nullable(),{kind:`mutation`}),runStatelessStep:A(x({stepId:l(),modelId:l(),frameJpeg:l(),bbox:OW,className:l(),sourceDeviceId:n()}),PDe,{kind:`mutation`}),parkTrackFrame:A(x({deviceId:n(),trackId:l(),kind:AW,handle:na,bbox:OW,maxWidth:n().int().positive().optional(),timestamp:n()}),MW,{kind:`mutation`}),getParkedTrackFrame:A(x({deviceId:n(),trackId:l(),kind:AW,acceptJpegBytes:y().optional()}),NW.nullable()),releaseParkedTrackFrames:A(x({deviceId:n(),trackId:l()}),x({released:n().int().nonnegative()}),{kind:`mutation`}),startNodeBench:A(_W,x({accepted:p(!0),runId:l()}),{kind:`mutation`,auth:`admin`}),getNodeBenchStatus:A(x({runId:l()}),yW.nullable(),{auth:`admin`}),abortNodeBench:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},aG=3e4,RDe={version:1,targets:[{id:`detected`,cardinality:`event`,shape:`span`,vocabulary:{cap:`motion`,eventName:`onMotionChanged`},deviceTypes:[E.Camera],apply:`add`,applyAuthority:{kind:`camera-sensors`,timeoutField:`motionCooldownMs`},eventName:`onMotionChanged`,start:`rising-edge`,end:`falling-edge-or-timeout`,timeoutMs:aG,combine:`any`,sourceModes:[`in-addition`,`confirm`,`replace`],sources:[{kind:`binary`},{kind:`switch`}],sourceReport:{status:`assignment-status`},advancedExpression:!1}]},zDe=15e3,oG=x({detected:y(),lastDetectedAt:n().nullable(),autoClearAfterMs:n().nullable().meta(N(`duration-ms`))}),sG=x({deviceId:n(),detected:y(),timestamp:n(),source:UW,regions:C(bV).readonly().optional(),triggeredBy:aV.optional()}),cG={name:`motion`,scope:`device`,mode:`singleton`,deviceNative:!0,deviceTypes:[E.Camera,E.Sensor],methods:{isDetected:A(x({deviceId:n()}),y())},composedMethods:{isDetected:{kind:`slice`,field:`detected`}},events:{onMotionChanged:{data:sG,notOperatorFacing:"the `detected` state trigger phrases both edges, from the mirror that survives a dropped event (D49)"}},status:{schema:oG,kind:`push`},runtimeState:oG,durability:`session`,history:{fields:{detected:{kind:`boolean`,excludeDeviceTypes:[E.Camera]}}},customize:RDe,vocabulary:{noun:F(`Motion`,`Movimento`),order:5130,state:[{kind:`boolean`,field:`detected`,label:F(`Motion`,`Movimento`),whenTrue:F(`When {device} detects motion`,`Quando {device} rileva movimento`),whenFalse:F(`When motion clears on {device}`,`Quando il movimento su {device} cessa`),icon:`activity`}]}},lG=x({enabled:y(),lastChangedAt:n()}),uG=lG.extend({lastFetchedAt:n()}),dG={name:`motion-trigger`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Light,E.Siren,E.Switch],methods:{setMotionTrigger:A(x({deviceId:n().int().nonnegative(),enabled:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`motionTrigger.on`,label:F(`Motion trigger on`,`Attivazione al movimento attiva`),phrase:F(`Let motion trigger {device}`,`Fai attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!0},args:{enabled:!0}},{id:`motionTrigger.off`,label:F(`Motion trigger off`,`Attivazione al movimento spenta`),phrase:F(`Stop motion triggering {device}`,`Non far più attivare {device} dal movimento`),icon:`activity`,effect:{field:`enabled`,value:!1},args:{enabled:!1}}]})},events:{onMotionTriggerChanged:{data:x({deviceId:n(),enabled:y(),lastChangedAt:n()}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:lG,kind:`command-driven`},runtimeState:uG,durability:`session`,history:`none`,vocabulary:{noun:F(`Motion trigger`,`Attivazione al movimento`),order:1160,state:[{kind:`boolean`,field:`enabled`,label:F(`Motion trigger`,`Attivazione al movimento`),whenTrue:F(`When motion triggering is turned on for {device}`,`Quando si attiva l’attivazione al movimento di {device}`),whenFalse:F(`When motion triggering is turned off for {device}`,`Quando si disattiva l’attivazione al movimento di {device}`),icon:`activity`}]}},fG=x({id:n(),enabled:y(),shape:DV}),pG=x({enabled:y(),sensitivity:n().meta(N(`none`)),regions:C(fG),lastFetchedAt:n()}),mG=x({maxRegions:n(),supportedShapes:C(kV),grid:jV,sensitivity:x({min:n(),max:n(),step:n()})}),hG=x({enabled:y().optional(),sensitivity:n().optional(),regions:C(fG).optional()}),gG={name:`motion-zones`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/motion-zones-grid`,tab:`motion`,label:`Motion Zones`}},methods:{getOptions:A(x({deviceId:n()}),mG),setZone:A(x({deviceId:n(),patch:hG}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:pG,kind:`poll`},runtimeState:pG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Motion zones`,`Zone di movimento`),order:3170}},BDe=S([`external`,`embedded`]),VDe=S([`connected`,`disconnected`,`auth-failed`,`unreachable`,`tls-error`]),_G=x({id:l(),name:l(),url:l(),kind:BDe,status:VDe,latencyMs:n().nullable(),error:l().optional(),connectedClients:n().int().nonnegative().optional(),lastCheckedAt:n().optional()}),vG=x({url:l(),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),yG=x({name:l().min(1),url:l().regex(/^(mqtt|mqtts|ws|wss):\/\//,`URL must start with mqtt(s):// or ws(s)://`),username:l().optional(),password:l().optional(),clientIdPrefix:l().optional()}),HDe=x({id:l()}),bG=x({id:l()}),xG=x({port:n().int().min(1).max(65535).default(1883),allowAnonymous:y().default(!1),username:l().optional(),password:l().optional()}),UDe=x({id:l(),url:l()}),SG=x({brokerCount:n(),embeddedRunning:y()}),CG={name:`mqtt-broker`,scope:`system`,mode:`collection`,providerKind:`broker`,status:{schema:SG,kind:`poll`},methods:{listBrokers:A(v(),C(_G)),getBrokerConfig:A(bG,vG,{auth:`admin`}),addBroker:A(yG,HDe,{kind:`mutation`,auth:`admin`}),removeBroker:A(bG,v(),{kind:`mutation`,auth:`admin`}),startEmbeddedBroker:A(xG,UDe,{kind:`mutation`,auth:`admin`}),stopEmbeddedBroker:A(bG,v(),{kind:`mutation`,auth:`admin`}),getStatus:A(v(),SG)},vocabulary:{notOperatorFacing:M.NETWORK}},wG=S([`person`,`vehicle`,`animal`,`face`,`package`,`other`]),TG=x({class:wG,timestamp:n(),confidence:n().min(0).max(1).optional()}),EG=x({lastByClass:d(wG,TG.nullable()),supportedClasses:C(wG).readonly(),enabled:y()}),DG=S([`boxed`,`while-streaming`,`flag-only`]),OG=x({supportedClasses:C(wG).readonly(),geometry:DG}),kG=x({enabled:y().optional()}),AG=EG.extend({lastFetchedAt:n()}),jG={name:`native-object-detection`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getOptions:A(x({deviceId:n()}),OG),setSettings:A(x({deviceId:n(),settings:kG}),v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`nativeDetection.on`,label:F(`On-camera detection on`,`Rilevamento a bordo attivo`),phrase:F(`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:F(`On-camera detection off`,`Rilevamento a bordo spento`),phrase:F(`Turn off the on-camera detection of {device}`,`Disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`,args:{enabled:!1}}]})},events:{onDetected:{data:x({deviceId:n(),detection:TG}),trigger:{category:T.DetectionCameraNative,label:F(`Camera spotted something`,`La telecamera ha rilevato qualcosa`),phrase:F(`When {device} spots something with its own detector`,`Quando {device} rileva qualcosa con il proprio rilevatore`),icon:`scan-eye`}}},status:{schema:EG,kind:`push`},runtimeState:AG,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera detection`,`Rilevamento a bordo`),order:3180,state:[{kind:`boolean`,field:`enabled`,label:F(`On-camera detection`,`Rilevamento a bordo`),whenTrue:F(`When the on-camera detection of {device} is turned on`,`Quando si attiva il rilevamento a bordo di {device}`),whenFalse:F(`When the on-camera detection of {device} is turned off`,`Quando si disattiva il rilevamento a bordo di {device}`),icon:`scan-eye`}]}},MG=x({pan:n().min(-1).max(1).optional(),tilt:n().min(-1).max(1).optional(),speed:n().min(0).max(1).optional()}),NG=S([`goHome`,`locate`,`spotClean`,`findPet`,`personFollow`,`stop`,`startClean`,`pauseClean`,`dockWash`,`autoEmpty`,`flashOn`,`flashOff`]),PG=S([`action`,`sound`]),FG=x({id:l(),kind:PG,label:l(),icon:l(),soundId:n().int().optional(),enabled:y()}),WDe=[{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}],IG=x({x:n(),y:n()}),LG=x({move:y(),stop:y(),goToPoint:y(),runAction:y(),playSound:y(),light:y(),lightMode:y()}),RG=S([`auto`,`manual`]),GDe=40,KDe=100,zG=S([`idle`,`cleaning`,`spot`,`following`,`goto`,`returning`,`paused`,`unknown`]),BG=x({mode:zG,following:y(),flash:y(),lightMode:RG,lightLevel:n().min(40).max(100).meta(N(`none`)),lastChangedAt:n()}),VG=BG.extend({lastFetchedAt:n()}),HG={name:`navigation`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/navigation-panel`,tab:`navigation`,topTab:!0,label:`Navigation`,order:0}},methods:{move:A(MG.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick control from the live view — continuous, not a discrete step`}),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`navigation.stop`,label:F(`Stop`,`Ferma`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]}),goToPoint:A(IG.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`tap-to-go on the live map — the point only means something on that picture`}),listActions:A(x({deviceId:n()}),C(FG)),runAction:A(x({deviceId:n(),actionId:NG}),v(),{kind:`mutation`,actions:[{id:`navigation.runAction`,label:F(`Run a routine`,`Esegui una routine`),phrase:F(`Have {device} {actionId}`,`Fai eseguire a {device}: {actionId}`),icon:`bot`,openArgs:[{key:`actionId`,label:F(`Routine`,`Routine`),offer:{kind:`enum`,values:[{value:`goHome`,label:F(`go home`,`torna alla base`)},{value:`locate`,label:F(`beep so you can find it`,`suona per farsi trovare`)},{value:`spotClean`,label:F(`clean this spot`,`pulisci questo punto`)},{value:`findPet`,label:F(`find the pet`,`cerca l’animale`)},{value:`personFollow`,label:F(`follow a person`,`segui una persona`)},{value:`stop`,label:F(`stop`,`fermati`)},{value:`startClean`,label:F(`start cleaning`,`inizia a pulire`)},{value:`pauseClean`,label:F(`pause cleaning`,`metti in pausa la pulizia`)},{value:`dockWash`,label:F(`wash the mop at the dock`,`lava il mocio alla base`)},{value:`autoEmpty`,label:F(`empty the bin at the dock`,`svuota il contenitore alla base`)},{value:`flashOn`,label:F(`turn the flash on`,`accendi il flash`)},{value:`flashOff`,label:F(`turn the flash off`,`spegni il flash`)}]}}]}]}),playSound:A(x({deviceId:n(),soundId:n().int()}),v(),{kind:`mutation`,actions:[{id:`navigation.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play {soundId} on {device}`,`Riproduci {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`dynamic`,from:`method`,method:`listActions`,valueKey:`soundId`,labelKey:`label`,where:{key:`kind`,equals:`sound`},valueKind:`number`}}]}]}),setLightOn:A(x({deviceId:n(),on:y()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightOn`,label:F(`Light on`,`Luce accesa`),phrase:F(`Turn on the light of {device}`,`Accendi la luce di {device}`),icon:`lightbulb`,args:{on:!0}},{id:`navigation.lightOff`,label:F(`Light off`,`Luce spenta`),phrase:F(`Turn off the light of {device}`,`Spegni la luce di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setLightMode:A(x({deviceId:n(),mode:RG,level:n().min(40).max(100).optional()}),v(),{kind:`mutation`,actions:[{id:`navigation.lightAuto`,label:F(`Light automatic`,`Luce automatica`),phrase:F(`Set the light of {device} to automatic`,`Metti la luce di {device} in automatico`),icon:`lightbulb`,args:{mode:`auto`}}]}),setLightLevel:A(x({deviceId:n(),level:n().min(40).max(100)}),v(),{kind:`mutation`,actions:[{id:`navigation.lightLevel`,label:F(`Set light level`,`Imposta la luce`),phrase:F(`Set the light of {device} to {level}`,`Imposta la luce di {device} al {level}`),icon:`sun-medium`,openArgs:[{key:`level`,label:F(`Level`,`Livello`),offer:{kind:`number`,min:40,max:100,step:1,unit:`%`}}]}]}),getFeatures:A(x({deviceId:n()}),LG)},events:{onStatusChanged:{data:x({deviceId:n(),status:BG}),notOperatorFacing:"the `mode` state trigger reads the same change"}},status:{schema:BG,kind:`push`},runtimeState:VG,durability:`session`,history:`none`,vocabulary:{noun:F(`Robot movement`,`Movimento del robot`),order:2080,state:[{kind:`enum`,field:`mode`,label:F(`Activity`,`Attività`),values:[{value:`idle`,label:F(`Idle`,`Inattivo`)},{value:`cleaning`,label:F(`Cleaning`,`In pulizia`)},{value:`spot`,label:F(`Spot cleaning`,`Pulizia localizzata`)},{value:`following`,label:F(`Following`,`In inseguimento`)},{value:`goto`,label:F(`Moving to a point`,`In movimento verso un punto`)},{value:`returning`,label:F(`Returning`,`In rientro`)},{value:`paused`,label:F(`Paused`,`In pausa`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`bot`}]}},UG=x({url:l(),hostname:l(),port:n(),protocol:S([`http`,`https`]),stable:y().optional()}),qDe=x({url:l(),stable:y().optional(),updated:y().optional()}),WG=x({connected:y(),endpoint:UG.nullable(),error:l().optional()}),JDe=UG.extend({id:l(),label:l(),mode:l().optional(),sourcePort:n().optional()}),GG={name:`network-access`,scope:`system`,mode:`collection`,providerKind:`ingress`,methods:{start:A(v(),UG,{kind:`mutation`}),stop:A(v(),v(),{kind:`mutation`}),getEndpoint:A(v(),UG.nullable()),getStatus:A(v(),WG),listEndpoints:A(v(),C(JDe).readonly())},vocabulary:{notOperatorFacing:M.NETWORK}},KG=[`wifi`,`ethernet`,`cellular`,`unknown`],qG=x({type:S(KG),signal:n().min(0).max(100).nullable().meta(N(`percentage`)),rssi:n().optional().meta(N(`signal-level`)),ssid:l().optional(),speedKbps:n().nonnegative().nullable().optional().meta(N(`bitrate`)),linkUp:y().nullable().optional(),lastUpdated:n().meta(N(`none`))}),JG={type:`unknown`,signal:null,lastUpdated:0};function YDe(e,t){return e===void 0||!Number.isFinite(e)||t<=0||e<0||e>t?null:Math.round(e/t*100)}function XDe(e){return e===void 0||!Number.isFinite(e)||e>0?null:Math.round((Math.min(-50,Math.max(-100,e))+100)*2)}var YG={name:`network-link`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Button,E.Switch,E.Light,E.Lock,E.Siren],methods:{},events:{onStatusChanged:{data:x({deviceId:n(),status:qG}),notOperatorFacing:`the signal / link-type state triggers each read one field of this change`}},status:{schema:qG,kind:`push`,empty:JG},runtimeState:qG,durability:`restored`,history:{fields:{signal:{kind:`gauge`,unit:`%`,deadband:3,minIntervalMs:6e4},rssi:{kind:`gauge`,unit:`dBm`,deadband:2,minIntervalMs:6e4}}},volatileStateFields:[`lastUpdated`],vocabulary:{noun:F(`Network link`,`Collegamento di rete`),order:5250,state:[{kind:`numeric`,field:`signal`,quantity:F(`the signal strength`,`l’intensità del segnale`),label:F(`Signal`,`Segnale`),unit:`%`,icon:`wifi`},{kind:`enum`,field:`type`,label:F(`Link type`,`Tipo di collegamento`),values:[{value:`wifi`,label:F(`Wi-Fi`,`Wi-Fi`)},{value:`ethernet`,label:F(`Ethernet`,`Ethernet`)},{value:`cellular`,label:F(`Cellular`,`Rete mobile`)},{value:`unknown`,label:F(`Unknown`,`Sconosciuto`)}],icon:`network`}]}},XG=x({nominalBitrateKbps:n(),observedBitrateKbps:n(),peakBitrateKbps:n(),packetLossPercent:n(),lastUpdated:n()}),ZG=x({rttMs:n(),jitterMs:n(),estimatedBandwidthKbps:n(),packetLossPercent:n().min(0).max(100),downlinkMbps:n().optional(),downlinkAgeMs:n().optional(),lastUpdated:n()}),QG=x({deviceId:n(),streams:m(l(),XG),client:ZG.optional()}),$G={name:`network-quality`,scope:`system`,mode:`singleton`,methods:{getDeviceStats:A(x({deviceId:n()}),QG.nullable()),getAllStats:A(v(),C(QG).readonly()),reportClientStats:A(x({deviceId:n(),rttMs:n().min(0).max(6e4),jitterMs:n().min(0).max(1e4),estimatedBandwidthKbps:n().min(0).max(1e6),packetLossPercent:n().min(0).max(100),downlinkMbps:n().min(0).max(1e5).optional(),downlinkAgeMs:n().min(0).max(864e5).optional()}),v(),{role:`viewer`,kind:`mutation`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.NETWORK}},eK=x({cn:l(),serial:l(),fingerprintSha256:l(),notBefore:n(),notAfter:n()}),tK=x({fingerprintSha256:l(),issuer:l(),sans:C(l()),notBefore:n(),notAfter:n()}),nK=i(`state`,[x({state:p(`served`),leaf:tK}),x({state:p(`not-issued`),reason:l()})]),rK={name:`node-certificates`,scope:`system`,mode:`singleton`,internal:!0,methods:{getCertificates:A(x({}),x({nodeId:l(),mesh:eK.nullable(),https:nK}),{auth:`admin`}),prepareMeshRenewal:A(x({}),x({csrPem:l()}),{kind:`mutation`,auth:`admin`}),installMeshLeaf:A(x({certPem:l().min(1),caCertPem:l().min(1),confirmWithinMs:n().int().min(1e4).max(6e5)}),x({fingerprintSha256:l(),serial:l()}),{kind:`mutation`,auth:`admin`}),confirmMeshLeaf:A(x({fingerprintSha256:l()}),x({confirmed:y()}),{kind:`mutation`,auth:`admin`}),rollbackMeshLeaf:A(x({}),x({rolledBack:y()}),{kind:`mutation`,auth:`admin`}),prepareHttpsCertificate:A(x({}),x({csrPem:l(),hostnames:C(l()),addresses:C(l()),pinnedCaFingerprintSha256:l().nullable()}),{kind:`mutation`,auth:`admin`}),forgetHub:A(x({}),x({ok:p(!0)}),{kind:`mutation`,auth:`admin`}),installHttpsCertificate:A(x({certPem:l().min(1),caCertPem:l().min(1),caRotation:y().optional()}),tK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.IDENTITY}},iK=x({nodeId:l().min(1),removedAt:n()}),aK=x({counts:m(l(),n().int().nonnegative())}),oK={name:`node-removal-hook`,scope:`system`,mode:`collection`,internal:!0,methods:{onNodeRemoved:A(iK,aK,{kind:`mutation`,auth:`admin`})},mount:{kind:`skip`},vocabulary:{notOperatorFacing:M.INTERNAL}},sK=x({addonId:l(),capabilities:C(l()).readonly(),status:l()}),cK=x({pid:n(),name:l(),state:l(),cpuPercent:n(),memoryRss:n(),uptimeSeconds:n(),services:C(sK).readonly(),groupId:l().optional()}),ZDe=x({id:l(),status:l(),cpuPercent:n(),memoryRss:n()}),QDe=x({category:l(),total:n(),healthy:n(),addons:C(ZDe).readonly()}),$De=x({name:l(),version:l()}),lK=x({id:l(),name:l(),hostname:l(),platform:l(),arch:l(),cpuModel:l().nullable(),cpuCores:n(),memoryMB:n(),engines:C(l()).readonly(),isHub:y(),isOnline:y(),cpuPercent:n(),memoryPercent:n().nullable(),uptime:n(),lastSeen:l(),localIps:C(l()).readonly(),addons:C(x({id:l(),capabilities:C(l()).readonly(),status:l()})).readonly(),processes:C(cK).readonly(),categories:C(QDe).readonly(),rootPackage:$De.nullable(),meshTransport:S([`tls`,`clear`]).optional(),capabilitiesRegistered:y().optional()}),eOe=x({callerAddonId:l(),providerAddonId:l(),capName:l(),callsPerMin:n(),lastCallAtMs:n()}),uK=x({nodeId:l(),name:l(),version:l(),status:l(),synced:y()}),dK=x({hubVersion:l(),nodes:C(uK)}),fK=x({nodeId:l(),addonId:l()}),tOe=x({id:l(),status:l(),version:l().optional(),packageName:l().optional()}),pK=x({success:y()}),nOe=x({success:y(),reason:l().optional()}),rOe=x({restarted:C(l()).readonly(),failed:C(l()).readonly()}),iOe=x({nodeId:l(),name:l()}),mK=x({id:l(),name:l(),isHub:y(),isOnline:y()}),hK=x({nodes:C(mK).readonly(),complete:y()}),gK={name:`nodes`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,methods:{topology:A(v(),C(lK).readonly(),{auth:`admin`}),directory:A(v(),hK,{auth:`admin`}),deployAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),undeployAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),restartAddon:A(fK,pK,{kind:`mutation`,auth:`admin`}),restartProcess:A(x({nodeId:l(),processName:l()}),nOe,{kind:`mutation`,auth:`admin`}),restartNode:A(x({nodeId:l()}),rOe,{kind:`mutation`,auth:`admin`}),shutdownNode:A(x({nodeId:l()}),pK,{kind:`mutation`,auth:`admin`}),renameNode:A(x({nodeId:l(),name:l().min(1).max(64)}),iOe,{kind:`mutation`,auth:`admin`}),clusterAddonStatus:A(v(),m(l(),dK),{auth:`admin`}),getCapUsageGraph:A(x({windowSeconds:n().int().positive().max(300).default(60)}),C(eOe).readonly(),{auth:`admin`}),getNodeAddons:A(x({nodeId:l()}),C(tOe).readonly(),{auth:`admin`}),setProcessLogLevel:A(x({nodeId:l(),level:l()}),pK,{kind:`mutation`,auth:`admin`}),executeQuery:A(x({nodeId:l(),addonId:l(),queryName:l(),params:m(l(),w()).optional()}),w(),{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},_K=[{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`}],vK={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},yK={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},bK=new Map;for(let[e,t]of Object.entries(vK.mapping))bK.set(e.toLowerCase(),t);for(let[e,t]of Object.entries(yK.mapping))bK.set(e.toLowerCase(),t);function aOe(e){return bK.get(e.toLowerCase())??null}function oOe(){return _K.map(e=>e.id)}var xK=UN();function SK(e){return JN(xK.swatches,xK.fallbacks,e)}function sOe(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var cOe=sOe(xK.fallbacks);function lOe(e){return e.split(/[-_ ]/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}var CK=new Map;function wK(e,t,n,r){CK.set(e,{kind:e,parentKind:null,level:`macro`,category:t,color:SK(e),iconId:n,labelKey:`eventKind.${e}`,label:r})}function TK(e,t,n,r,i){CK.set(e,{kind:e,parentKind:t,level:`sub`,category:n,color:SK(e),iconId:r,labelKey:`eventKind.${e}`,label:i})}wK(`motion`,`motion`,`motion`,`Motion`),wK(`audio`,`audio`,`audio`,`Audio`),wK(`person`,`detection`,`person`,`Person`),wK(`vehicle`,`detection`,`vehicle`,`Vehicle`),wK(`animal`,`detection`,`animal`,`Animal`),wK(`package`,`package`,`package`,`Package`),wK(`sensor`,`sensor`,`sensor`,`Sensor`),wK(`control`,`control`,`control`,`Control`);for(let[e,t]of Object.entries(Vg.mapping))t!==`vehicle`&&t!==`animal`||CK.has(e)||TK(e,t,`detection`,e,lOe(e));TK(`package-delivered`,`package`,`package`,`package`,`Package delivered`),TK(`package-picked-up`,`package`,`package`,`package`,`Package picked up`),TK(`contact`,`sensor`,`sensor`,`door`,`Contact`),TK(`motion-sensor`,`sensor`,`sensor`,`pir`,`Motion sensor`),TK(`smoke`,`sensor`,`sensor`,`smoke`,`Smoke`),TK(`flood`,`sensor`,`sensor`,`water`,`Water leak`),TK(`gas`,`sensor`,`sensor`,`gas`,`Gas`),TK(`carbon-monoxide`,`sensor`,`sensor`,`smoke`,`Carbon monoxide`),TK(`vibration`,`sensor`,`sensor`,`vibration`,`Vibration`),TK(`tamper`,`sensor`,`sensor`,`tamper`,`Tamper`),TK(`presence`,`sensor`,`sensor`,`presence`,`Presence`),TK(`enum-sensor`,`sensor`,`sensor`,`generic`,`Sensor state`),TK(`device-event`,`sensor`,`sensor`,`button`,`Device event`),TK(`lock`,`control`,`control`,`lock`,`Lock`),TK(`cover`,`control`,`control`,`door`,`Cover`),TK(`switch`,`control`,`control`,`switch`,`Switch`),TK(`siren`,`control`,`control`,`siren`,`Siren`),TK(`button`,`control`,`control`,`button`,`Button`),TK(`doorbell`,`control`,`control`,`doorbell`,`Doorbell`),TK(`appliance-cycle`,`control`,`control`,`switch`,`Appliance cycle`);for(let e of _K){let t=`audio-${e.id}`;CK.has(t)||TK(t,`audio`,`audio`,t,e.name)}var EK=Object.freeze(Object.fromEntries(CK));function DK(e){return EK[e]}function uOe(e){return SK(e)}function dOe(e){let t=[];for(let n of Object.values(EK))n.parentKind===e&&t.push(n);return t}var OK=x({kind:l(),label:l(),parentKind:l().nullable()}),kK=x({videoClasses:C(OK),audioKinds:C(OK),labels:C(OK)});function AK(e,t,n){return{kind:e,label:t,parentKind:n}}function jK(){let e=Object.values(EK);return{videoClasses:e.filter(e=>e.category===`detection`).map(e=>AK(e.kind,e.label,e.parentKind)),audioKinds:e.filter(e=>e.category===`audio`&&e.level===`sub`).map(e=>AK(e.kind,e.label,e.parentKind)),labels:e.filter(e=>e.category===`sensor`||e.category===`control`).map(e=>AK(e.kind,e.label,e.parentKind))}}var fOe=Object.freeze(jK()),MK=S([`immediate`,`track-end`,`device-event`,`package-event`,`system-event`]),NK=S(`device-online.device-offline.device-disabled.device-enabled.device-battery-low.device-battery-normal.device-consumable-low.device-consumable-normal.stream-online.stream-offline.node-online.node-offline.node-restarting.node-updating.node-inference-unavailable.detection-blind.motion-noisy.motion-calm.package-llm-silent.package-llm-answered.recording-stalled.recording-healthy.recording-degraded.device-attention-required.device-attention-resolved.device-command.storage-location-low.storage-location-critical.storage-location-ok.storage-drain-progress.storage-drain-complete.addon-crash-loop.addon-update-available.server-update-available.wrapper-update-available.alarm-triggered.alarm-armed.alarm-disarmed.alarm-arming.alarm-arm-refused.alarm-pending.alarm-rearmed.alarm-sensor-bypass.alarm-check-failed.addon-updated.server-updated.export-completed.backup-completed.alert-critical.alert-error.alert-critical-resolved.rule-broken.rule-repaired.camera-online.camera-offline.camera-disabled.camera-enabled`.split(`.`)),PK=[`camera-online`,`camera-offline`,`camera-disabled`,`camera-enabled`],pOe=new Set(PK),mOe=NK.options.filter(e=>!pOe.has(e)),FK=[`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`],hOe=[`device-battery-low`,`device-battery-normal`,`device-consumable-low`,`device-consumable-normal`],IK=[`device-consumable-low`,`device-consumable-normal`],gOe=15,_Oe=95,LK=[`confirmed`,`already`,`unconfirmed`,`failed`],RK=[`user`,`addon`,`action`,`scheduler`,`composition`,`node`],zK=x({kinds:C(NK).min(1),deviceIds:C(n().int()).min(1).optional(),deviceTypes:C(l().min(1)).min(1).optional(),excludeDeviceIds:C(n().int()).min(1).optional(),nodeIds:C(l().min(1)).min(1).optional(),packageNames:C(l().min(1)).min(1).optional(),commandActions:C(l().min(1)).min(1).optional(),commandOutcomes:C(S(LK)).min(1).optional(),commandActorKinds:C(S(RK)).min(1).optional(),consumableLowPercent:n().int().min(1).max(95).optional()});function vOe(e){return e.consumableLowPercent??15}var yOe=1,BK=1440,bOe=[10,30,60],VK=x({days:C(n().int().min(0).max(6)).min(1),startMinute:n().int().min(0).max(1439),endMinute:n().int().min(0).max(1439)}),HK=x({windows:C(VK).min(1),timezone:l().optional(),invert:y().optional()}),UK=S([`instant`,`summary`]),xOe=S([`activation`,`deactivation`,`schedule`]),WK=S([`rule`,`section`]),GK=i(`mode`,[x({mode:p(`instant`)}),x({mode:p(`summary`),schedule:HK,split:WK.optional()}),x({mode:p(`modes`),onActivation:y(),onDeactivation:y(),onSchedule:x({schedule:HK,grouping:WK}).optional()})]),KK=x({values:C(l().min(1)),maxDistance:n().int().min(0).max(3).default(1)}),qK=x({zoneId:l().optional(),className:l().optional(),op:S([`became-occupied`,`became-free`,`>=`,`<=`]).default(`became-occupied`),count:n().int().min(0).default(1),sustainSeconds:n().int().min(0).max(3600).default(15)}),SOe=-96,JK=x({labels:C(l().min(1)).min(1).optional(),dbThreshold:n().min(-96).max(0).optional(),hitPercent:n().int().min(1).max(100).default(60),samplingSeconds:n().int().min(1).max(300).default(10),confirmHits:n().int().min(1).max(20).optional(),confirmWindowSec:n().int().min(1).max(60).optional()}),YK=S([`enter`,`exit`,`any`]),XK=S([`raised`,`cleared`]),ZK=x({ids:C(l().min(1)).min(1),match:S([`any`,`all`]).optional()}),QK=l().min(1),$K=C(QK).max(4),eq=x({id:l().min(1).max(64),label:l().min(1).max(40),actionId:QK,icon:xu.optional(),destructive:y().optional()}),tq=x({onActivation:$K.optional(),onDeactivation:$K.optional(),onTrigger:$K.optional(),onTriggerOff:$K.optional(),buttons:C(eq).max(8).optional()}),nq=x({deviceId:n().int(),states:C(l().min(1)).min(1)}),rq=x({sceneId:l().min(1),deviceId:n().int().optional(),requiredState:S([`matched`,`diverged`]),latched:y().optional()}),iq=x({deviceState:nq.optional(),scene:rq.optional(),devices:C(n()).optional(),devicesExclude:C(n()).min(1).optional(),classes:C(l().min(1)).optional(),classesExclude:C(l().min(1)).optional(),minConfidence:n().min(0).max(1).optional(),zones:ZK.optional(),zonesExclude:C(l().min(1)).optional(),crossing:YK.optional(),labelEquals:C(l().min(1)).optional(),identities:C(l().min(1)).optional(),plates:KK.optional(),identitiesExclude:C(l().min(1)).optional(),minImportance:n().min(0).max(1).optional(),minDwellSeconds:n().min(0).optional(),source:S([`pipeline`,`onboard`,`sensor`,`audio`,`any`]).optional(),minLabelConfidence:n().min(0).max(1).optional(),eventTypeTokens:C(l().min(1)).optional(),sensorKinds:C(l().min(1)).optional(),sensorTransition:XK.optional(),packagePhase:S([`delivered`,`picked-up`,`both`]).optional(),systemEvent:zK.optional(),customZones:C(EV).optional(),occupancy:qK.optional(),audio:JK.optional()}),aq=x({targetId:l().min(1),params:m(l(),w()).optional()}),COe=500,oq=S([`none`,`image`,`clip`,`gif`]),sq=x({template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),schedule:HK.optional(),priority:n().int().min(1).max(5).optional(),attachment:oq.optional(),actions:y().optional()}),cq=m(l(),sq),lq=S([`scene-boxes`,`crop`,`clean`,`none`]),uq=S([`cropped`,`full`,`boxed`]),dq=S([`mosaic`,`each`]),wOe=4,TOe=6,fq=x({image:lq.optional(),showTriggerZone:y().optional(),showSubjectPath:y().optional(),attach:S([`best`,`best-matching`,`keyFrame`,`none`]).optional(),frame:uq.optional(),zoneCrop:y().optional(),gif:y().optional(),clip:y().optional(),clipPreRollSec:n().int().min(0).max(30).optional(),clipPostRollSec:n().int().min(0).max(30).optional(),clipSpeed:n().min(1).max(8).optional(),profile:P.optional(),linkedCameras:dq.optional(),wakeSleepingCamera:y().optional()}),pq=S([`shared`,`per-class`]),mq=x({cooldownSec:n().int().min(0).max(86400).default(60),scope:S([`rule`,`rule-device`]).default(`rule-device`),granularity:pq.optional()}),hq=1e3,gq=2e4,_q=8e3,EOe=448,vq=x({op:S([`>=`,`>`,`<=`,`<`,`==`]),count:n().int().min(0).max(1e3)}),yq=x({enabled:y().default(!1),profileId:l().optional(),prompt:l().max(1e3).optional(),expect:vq.optional(),timeoutMs:n().int().min(hq).max(gq).default(_q),onTimeout:S([`fire`,`suppress`]).default(`fire`),maxImagePx:n().int().min(64).max(2048).default(448)}),DOe=5,OOe=20,kOe=60,AOe=5,jOe=0,MOe=300,bq=x({name:l().min(1).max(200),enabled:y().default(!0),delivery:MK,conditions:iq.default({}),schedule:HK.optional(),systemEventDelivery:GK.optional(),targets:C(aq),targetUsers:C(l()).optional(),targetOverrides:cq.optional(),media:fq.default({}),throttle:mq.default({cooldownSec:60,scope:`rule-device`}),template:x({title:l().max(500).optional(),body:l().max(2e3).optional()}).optional(),priority:n().int().min(1).max(5).default(3),ownerUserId:l().optional(),snoozeAllowGlobal:y().optional(),snoozeOptions:C(n().int().min(1).max(BK)).max(4).optional(),actions:tq.optional(),confirm:yq.optional(),groupingSec:n().int().min(5).max(60).optional(),groupWithinSec:n().int().min(0).max(300).optional(),askVerdict:y().optional(),tags:Eh.optional()}),xq=S([`event`,`summary`,`timelapse`,`calendar-events`]),Sq=x({kind:xq,ruleId:l(),tags:C(l())}),Cq=bq.partial().extend({disabledTargetIds:C(l()).optional(),enabled:y().optional(),conditions:iq.optional(),media:fq.optional(),throttle:mq.optional(),priority:n().int().min(1).max(5).optional()}),wq=[`waitForEnhancement`,`groupIdleSec`];function NOe(e){return wq.some(t=>t===e)}var Tq=[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`actions`,`confirm`,`groupingSec`,`waitForEnhancement`,`groupIdleSec`],Eq=S(Tq),Dq=x({ruleId:l(),patch:Cq,clear:C(Eq).optional()}),Oq=bq.extend({id:l(),createdBy:l(),createdAt:n(),updatedAt:n(),disabledTargetIds:C(l()).default([])}),kq=[`device-state`,`streams`,`battery`,`consumables`,`detection-blind`,`nodes`,`addons`,`addon-updates`,`updates`],Aq=S(kq),jq=x({id:Aq,status:S([`read`,`unavailable`]),items:n().int().nonnegative(),reason:l().optional()}),Mq=x({section:Aq.optional(),title:l(),text:l(),count:n().int().nonnegative()}),Nq=x({empty:y(),count:n().int().nonnegative(),text:l(),sections:C(jq),dropped:m(l(),n().int().nonnegative()),excludedGroups:C(l()),split:WK.optional(),rows:C(Mq).optional()}),Pq=x({recordId:l(),recordKind:S([`object-event`,`track`,`device-event`,`package-event`,`system-event`]),deviceId:n(),timestamp:n(),wouldFire:y(),failedCondition:l().optional(),className:l().optional(),label:l().optional()}),Fq=S([`detection`,`sensor`,`occupancy`,`sound`,`device-events`,`system`,`alarm`,`mixed`]),Iq=S([`detection`,`sensor`,`occupancy`,`sound`,`system`]),Lq=x({id:S([`appliance-cycle`]),kind:Fq,title:l(),body:l()}),Rq=S([`rule`,`timelapse`,`summary`]),zq=S([`title`,`body`,`previewText`,`captionText`]),Bq=S([`subject`,`place`,`time`,`rule`,`occupancy`,`sound`,`sensor`,`system`,`digest`,`ai`]),Vq=x({name:l().regex(/^\w+$/),label:l(),description:l().optional(),example:l(),group:Bq,families:C(Rq).min(1),fields:C(zq).optional(),kinds:C(Iq).optional(),deliveries:C(MK).optional(),systemEventKinds:C(NK).optional(),systemEventDeliveries:C(UK).optional(),dynamic:x({prefix:p(`count_`),from:p(`classes`)}).optional()}),Hq=x({family:Rq,field:zq,kind:Fq.optional(),delivery:MK.optional(),systemEventKinds:C(NK).optional(),systemEventDelivery:UK.optional()}),Uq=x({context:Hq,template:x({title:l().max(500).optional(),body:l().max(2e3).optional()})}),Wq=x({title:l().nullable(),body:l().nullable(),unknown:C(l())}),Gq=x({id:l(),group:S([`scope`,`class`,`zones`,`quality`,`label`,`schedule`,`device`,`package`,`occupancy`,`audio`,`system`]),label:l(),valueType:S([`deviceIdList`,`deviceIdExcludeList`,`stringList`,`number01`,`number`,`sourceSelect`,`zoneSelection`,`zoneIdList`,`schedule`,`plateMatcher`,`packagePhase`,`crossingSelect`,`sensorTransition`,`polygonDraw`,`occupancy`,`audio`,`deviceState`,`scene`,`systemEvent`]),operator:S([`in`,`notIn`,`anyOf`,`allOf`,`gte`,`fuzzyIn`,`withinSchedule`]),appliesTo:C(MK),phase:l(),description:l().optional(),options:C(x({value:l(),label:l(),hint:l().optional()})).readonly().optional()}),POe=[{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.`}],Kq=S([`pending`,`sent`,`dead`]),qq=S([`object-event`,`track-end`,`device-event`,`package-event`,`system-event`]),Jq=x({className:l(),label:l().optional(),confidence:n().optional(),zones:C(l()),timestamp:n(),systemEvent:x({kind:NK,subject:l(),title:l(),body:l(),data:m(l(),w())}).optional()}),Yq=x({id:l(),ruleId:l(),ruleName:l(),delivery:MK,targetId:l(),deviceId:n(),recordKind:qq,recordId:l(),trackId:l().optional(),status:Kq,attempts:n().int(),createdAt:n(),updatedAt:n(),error:l().optional(),subject:Jq,title:l().optional(),body:l().optional(),artifactIds:C(l().min(1)).optional(),groupedInto:l().min(1).optional()}),FOe=100,IOe=500,Xq=x({ruleId:l().optional(),deviceId:n().optional(),status:Kq.optional(),since:n().optional(),until:n().optional(),limit:n().int().min(1).max(500).default(100)}),Zq=x({ruleId:l(),lastAt:n(),status:Kq,deviceId:n()}),Qq=x({runs:C(Zq),horizonMs:n().nonnegative().nullable()}),$q=S([`rule`,`device`,`all`]),eJ=x({scope:$q,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),durationMinutes:n().int().min(1).max(BK),global:y().optional(),summary:y().optional()}),tJ=x({id:l(),userId:l(),scope:$q,ruleId:l().optional(),deviceId:n().int().optional(),classes:C(l().min(1)).min(1).optional(),startedAt:n(),expiresAt:n(),global:y(),summary:y(),digestSentAt:n().optional()}),LOe=x({snoozeId:l(),targetId:l(),ruleId:l(),ruleName:l(),deviceId:n().int(),count:n().int(),firstAt:n(),lastAt:n()}),ROe=600,nJ=3600,zOe=200,rJ=n().int().min(0).max(600),iJ=n().int().min(0).max(nJ),aJ=e=>new Set(e.map(e=>e.mode)).size===e.length,oJ=S([`rearmAfter`,`disableAfter`,`doNothing`]),sJ=x({mode:vS,exitDelaySec:rJ.optional(),entryDelaySec:rJ.optional(),triggeredDurationSec:iJ.optional(),postTriggeredAction:oJ.optional(),schedule:HK.optional(),notifyDuringEntryDelay:y().optional(),notifySensorRewatched:y().optional(),notifySensorIgnored:y().optional()}),BOe=C(sJ).max(8).refine(aJ,{message:`modeDelays: at most one entry per arm mode`}),cJ=x({mode:vS,exitDelaySec:rJ.nullable().optional(),entryDelaySec:rJ.nullable().optional(),triggeredDurationSec:iJ.nullable().optional(),postTriggeredAction:oJ.nullable().optional(),schedule:HK.nullable().optional(),notifyDuringEntryDelay:y().nullable().optional(),notifySensorRewatched:y().nullable().optional(),notifySensorIgnored:y().nullable().optional()}),VOe=C(cJ).max(8).refine(aJ,{message:`modeDelays: at most one edit per arm mode`}),lJ=x({mode:vS,deviceId:n().int().positive(),nonBlocking:y()}),uJ=x({mode:vS,deviceId:n().int().positive(),blocking:y()}),dJ=x({mode:vS,deviceId:n().int().positive(),secureOnArm:y()}),fJ=x({mode:vS,deviceIds:C(n().int()).max(200)}),pJ=fJ,mJ=fJ,hJ=fJ,gJ=C(pJ).max(8).refine(aJ,{message:`nonBlocking: at most one list per arm mode`}),_J=C(mJ).max(8).refine(aJ,{message:`blocking: at most one list per arm mode`}),vJ=C(hJ).max(8).refine(aJ,{message:`secureOnArmOff: at most one list per arm mode`}),yJ=x({exitDelaySec:rJ,entryDelaySec:rJ,triggeredDurationSec:iJ,postTriggeredAction:oJ.optional(),announceArm:y().optional(),announceTargets:C(l().min(1)).max(16),nonBlocking:gJ.default([]),blocking:_J.default([]),secureOnArmOff:vJ.default([]),modeDelays:BOe.default([])}),bJ=x({id:l().min(1).max(64),name:l().min(1).max(64),isDefault:y()}),xJ=x({activeId:l().min(1),items:C(bJ).min(1)}),SJ=x({name:l().min(1).max(64),cloneFromId:l().min(1).max(64).optional()}),CJ=x({id:l().min(1).max(64),name:l().min(1).max(64)}),wJ=x({id:l().min(1).max(64)}),TJ=yJ.extend({nonBlocking:gJ,blocking:_J,secureOnArmOff:vJ,modeDelays:VOe,nonBlockingEdit:lJ,blockingEdit:uJ,secureOnArmEdit:dJ}).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=S([`muted`,`detection-off`,`offline`]),DJ=x({deviceId:n().int(),reason:EJ}),OJ=x({mode:vS,ruleCount:n().int().min(0),allDevices:y(),deviceIds:C(n().int()),allDevicesExcept:C(n().int()).default([]),skippedDevices:C(DJ).default([])}),HOe=x({deviceId:n().int(),name:l(),state:l(),blocking:y()}),UOe=x({deviceId:n().int(),name:l(),phase:S([`open`,`closed`])}),WOe=x({mode:vS,devices:C(HOe),unknown:C(n().int())}),GOe=x({ruleId:l(),ruleName:l(),deviceId:n().int(),name:l(),since:n(),dropped:n().int().min(0)}),KOe=x({state:_S,targetMode:vS.nullable(),availableModes:C(vS),openings:C(WOe),exclusions:C(UOe),bypassedInputs:C(GOe).default([])}),kJ=x({deviceId:n().int().nullable(),settings:yJ,profiles:xJ.optional(),coverage:C(OJ),live:KOe.optional()}),qOe=500,AJ=S([`open`,`closed`,`unknown`,`not-opening`]),jJ=x({deviceId:n().int().positive(),reading:AJ,state:l().nullable(),unknownWhy:S([`read-failed`,`unknown-word`]).nullable(),online:y().nullable(),controllable:y().default(!1)}),MJ=x({deviceIds:C(n().int().positive()).max(500)}),NJ=x({sensors:C(jJ),readAt:n().int().nonnegative()}),JOe=60,PJ=x({deviceId:n().int().nonnegative().optional(),seconds:n().min(0).max(60),profile:P.optional(),ruleId:l(),ruleName:l(),reason:S([`window`,`occupancy`])}),FJ=x({rulesLoaded:y(),asks:C(PJ).readonly()}),IJ={name:`notification-rules`,scope:`system`,mode:`singleton`,methods:{listRules:A(x({}),x({rules:C(Oq)}),{auth:`admin`}),getRule:A(x({ruleId:l()}),x({rule:Oq.nullable()}),{auth:`admin`}),createRule:A(x({rule:bq}),x({rule:Oq}),{kind:`mutation`,auth:`admin`,caller:`required`}),updateRule:A(Dq,x({rule:Oq}),{kind:`mutation`,auth:`admin`,caller:`required`}),deleteRule:A(x({ruleId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setRuleEnabled:A(x({ruleId:l(),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),listRuleTags:A(x({}),x({rules:C(Sq)}),{kind:`query`,auth:`admin`}),setRuleTags:A(x({kind:xq,ruleId:l(),tags:Eh}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getClipRetentionAsks:A(x({}),FJ,{auth:`admin`}),listDeviceMutes:A(x({}),x({mutedDeviceIds:C(n().int()).readonly()}),{auth:`admin`}),setDeviceMuted:A(x({deviceId:n().int(),muted:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),testRule:A(x({rule:bq,lookbackMinutes:n().int().min(1).max(1440).default(60)}),x({results:C(Pq)}),{kind:`mutation`,auth:`admin`}),previewStateSummary:A(x({rule:bq}),Nq,{kind:`mutation`,auth:`admin`,access:`view`}),getConditionCatalog:A(x({}),x({catalog:C(Gq),taxonomy:kK.optional()})),getTemplateCatalog:A(x({}),x({vars:C(Vq),defaults:C(Lq)})),previewTemplate:A(Uq,Wq,{kind:`mutation`,access:`view`}),getHistory:A(x({filter:Xq.default({limit:100})}),x({entries:C(Yq)}),{auth:`admin`}),getRuleLastRuns:A(x({}),Qq,{auth:`admin`}),resolveArtifactUrl:A(x({artifactId:l().min(1)}),x({url:l().nullable()}),{auth:`admin`}),listSnoozes:A(x({}),x({snoozes:C(tJ)}),{caller:`required`}),createSnooze:A(x({snooze:eJ}),x({snooze:tJ}),{kind:`mutation`,caller:`required`}),cancelSnooze:A(x({snoozeId:l()}),x({success:p(!0)}),{kind:`mutation`,caller:`required`}),getAlarmConfig:A(x({}),kJ,{auth:`admin`}),setAlarmConfig:A(x({patch:TJ}),kJ,{kind:`mutation`,auth:`admin`}),createAlarmProfile:A(SJ,kJ,{kind:`mutation`,auth:`admin`}),renameAlarmProfile:A(CJ,kJ,{kind:`mutation`,auth:`admin`}),deleteAlarmProfile:A(wJ,kJ,{kind:`mutation`,auth:`admin`}),activateAlarmProfile:A(wJ,kJ,{kind:`mutation`,auth:`admin`}),getAlarmSensors:A(MJ,NJ,{auth:`admin`})},vocabulary:{notOperatorFacing:`notification rules — authored on their own page`}},YOe=S([`min`,`low`,`normal`,`high`]),XOe=x({id:l().min(1),title:l().min(1),uri:r().optional(),destructive:y().optional()}),ZOe=x({image:y(),priority:y(),data:y(),actions:y(),recipients:y()}),LJ=x({lastSentAt:n(),lastError:l().nullable(),queueDepth:n().int().nonnegative().meta(N(`count`)),supports:ZOe}),QOe=x({deviceId:n().int().nonnegative(),title:l().optional(),body:l().min(1),image:l().optional(),priority:YOe.optional(),channel:l().optional(),recipients:C(l()).optional(),actions:C(XOe).optional(),data:m(l(),w()).optional()}),$Oe=x({notificationId:l(),acceptedAt:n()}),RJ={name:`notifier`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Notifier],methods:{send:A(QOe,$Oe,{kind:`mutation`,auth:`admin`,actions:[{id:`notifier.send`,label:F(`Send a notification`,`Invia una notifica`),phrase:F(`Send “{body}” through {device}`,`Invia «{body}» tramite {device}`),icon:`send`,openArgs:[{key:`title`,label:F(`Title`,`Titolo`),offer:{kind:`text`},optional:!0},{key:`body`,label:F(`Message`,`Messaggio`),offer:{kind:`text`}},{key:`priority`,label:F(`Priority`,`Priorità`),offer:{kind:`enum`,values:[{value:`min`,label:F(`Minimal`,`Minima`)},{value:`low`,label:F(`Low`,`Bassa`)},{value:`normal`,label:F(`Normal`,`Normale`)},{value:`high`,label:F(`High`,`Alta`)}]},optional:!0}]}]}),cancel:A(x({deviceId:n().int().nonnegative(),notificationId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`})},events:{onSent:{data:x({deviceId:n(),notificationId:l(),success:y(),error:l().nullable(),acceptedAt:n()}),notOperatorFacing:`a delivery receipt of a send this system made — not a fact about the world`}},status:{schema:LJ,kind:`command-driven`},runtimeState:LJ,durability:`session`,history:`none`,vocabulary:{noun:F(`Notifier`,`Notificatore`),order:2110}},zJ=x({value:n().nullable().meta(N(`device`)),lastFetchedAt:n()}),BJ={name:`numeric-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:zJ,kind:`push`},runtimeState:zJ,durability:`restored`,history:{fields:{value:{kind:`gauge`,minIntervalMs:3e4}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Sensor`,`Sensore`),order:5150,state:[{kind:`numeric`,field:`value`,quantity:F(`the reading`,`il valore`),label:F(`Reading`,`Valore`),icon:`gauge`}]}},VJ=x({integrationId:l(),displayName:l(),requestedScopes:C(Kh),allowedRedirectPrefixes:C(l()).min(1),allowedPrivateHostPaths:C(l()).optional(),requiresPkce:y().optional(),hubUrl:l().optional(),refreshTokenTtlSec:h([n().int().positive(),p(`never`)]).optional(),instances:C(x({id:l(),displayName:l()})).optional()}),HJ={name:`oauth-integration`,scope:`system`,mode:`collection`,internal:!0,methods:{getDescriptor:A(v(),VJ,{auth:`admin`})},vocabulary:{notOperatorFacing:M.IDENTITY}},UJ=S([`text`,`timestamp`,`watermark`]),WJ=S([`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`custom`]),GJ=x({id:l(),kind:UJ,enabled:y(),text:l().optional(),position:WJ.optional(),availablePositions:C(WJ).readonly(),readOnly:y().optional(),maxCharacters:n().int().positive().optional()}),KJ=x({overlays:C(GJ).readonly()}),qJ=x({enabled:y().optional(),text:l().optional(),position:WJ.optional()}).partial(),JJ={name:`osd`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{setOverlay:A(x({deviceId:n(),overlayId:l(),patch:qJ}),v(),{kind:`mutation`,auth:`admin`})},events:{onStatusChanged:{data:x({deviceId:n(),status:KJ}),notOperatorFacing:`an overlay setting changed — configuration, not a happening`}},status:{schema:KJ,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:F(`On-screen text`,`Testo in sovrimpressione`),order:3190}},YJ=1024,XJ=x({id:l().min(1).max(64),name:l().min(1).max(64),text:l().max(YJ).default(``)}),ZJ=i(`kind`,[x({kind:p(`none`)}),x({kind:p(`static`),text:l().max(YJ)}),x({kind:p(`template`),templateId:l().min(1).max(64)})]),QJ=x({enabled:y().default(!0),source:ZJ,schedule:HK.optional(),conditions:iq.optional()}),$J=x({slotId:l(),kind:UJ,readOnly:y(),cameraEnabled:y(),cameraText:l().optional(),binding:QJ.nullable()}),eY=S([`written`,`unchanged`,`gated`,`unreadable`,`disabled`,`unbound`,`failed`]),tY=x({slotId:l(),outcome:eY,text:l(),reason:l().optional()}),nY=x({ok:y(),text:l(),notes:C(l())}),rY={name:`osd-manager`,scope:`system`,mode:`singleton`,methods:{getDeviceOsd:A(x({deviceId:n().int()}),x({supported:y(),slots:C($J)}),{auth:`admin`}),getConditionSupport:A(x({}),x({supported:C(l()),catalog:C(Gq)}),{auth:`admin`}),setSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1),binding:QJ}),x({slot:$J,render:tY}),{kind:`mutation`,auth:`admin`}),clearSlotBinding:A(x({deviceId:n().int(),slotId:l().min(1)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setSlotCameraEnabled:A(x({deviceId:n().int(),slotId:l().min(1),enabled:y()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),copyDeviceConfiguration:A(x({sourceDeviceId:n().int(),targetDeviceId:n().int()}),x({copied:n().int().nonnegative(),skipped:n().int().nonnegative()}),{kind:`mutation`,auth:`admin`}),previewSlot:A(x({deviceId:n().int(),slotId:l().min(1),binding:QJ.optional()}),tY,{kind:`mutation`,auth:`admin`}),previewTemplate:A(x({deviceId:n().int(),text:l().max(YJ)}),nY,{kind:`mutation`,auth:`admin`}),renderDevice:A(x({deviceId:n().int()}),x({results:C(tY)}),{kind:`mutation`,auth:`admin`}),listTemplates:A(x({}),x({templates:C(XJ)}),{auth:`admin`}),upsertTemplate:A(x({template:XJ}),x({template:XJ}),{kind:`mutation`,auth:`admin`}),deleteTemplate:A(x({templateId:l().min(1).max(64)}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},iY=1e4,eke=4,tke=200,nke=S([`normal`,`offline`,`on_batteries`]),aY=n().int().min(4).max(200),oY=aY.meta(kme({quantity:`mass`,unit:`g`})),sY=x({foodLevel:n().nullable().meta(N(`none`)),bowlFood:n().nullable().meta(N(`mass`)),eating:y(),supportsMarkRefilled:y(),food1:n().nullable().meta(N(`none`)),food2:n().nullable().meta(N(`none`)),lowFood:y(),batteryPower:n().min(0).max(100).nullable().meta(N(`percentage`)),powerSource:S([`mains`,`battery`]).nullable(),desiccantLeftDays:n().nullable().meta(N(`duration`)),feeding:y(),status:nke.nullable(),error:l().nullable(),errorCode:n().nullable().meta(N(`none`)),isDualHopper:y(),childLock:y(),indicatorLight:y(),feedSound:y(),volume:n().meta(N(`none`)),lastFeedGrams:aY.nullable(),lastFeedHopper1:aY.nullable(),lastFeedHopper2:aY.nullable(),lastFetchedAt:n()}),cY={name:`pet-feeder`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFeeder],methods:{feed:A(x({deviceId:n().int().nonnegative(),grams:oY.optional(),hopper1:oY.optional(),hopper2:oY.optional()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feed`,label:F(`Feed`,`Dai da mangiare`),phrase:F(`Dispense {grams} from {device}`,`Eroga {grams} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:iY},openArgs:[{key:`grams`,label:F(`Grams`,`Grammi`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]},{id:`petFeeder.feedHoppers`,label:F(`Feed from both hoppers`,`Eroga da entrambi i serbatoi`),phrase:F(`Dispense {hopper1} and {hopper2} from {device}`,`Eroga {hopper1} e {hopper2} da {device}`),icon:`paw-print`,hold:{effects:[{field:`feeding`,value:!0}],holdMs:iY},openArgs:[{key:`hopper1`,label:F(`Hopper 1`,`Serbatoio 1`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0},{key:`hopper2`,label:F(`Hopper 2`,`Serbatoio 2`),offer:{kind:`number`,min:4,max:200,step:1,unit:`g`,quantity:`mass`},optional:!0}]}]}),cancelFeed:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.cancelFeed`,label:F(`Cancel feeding`,`Annulla l’erogazione`),phrase:F(`Cancel the feeding on {device}`,`Annulla l’erogazione di {device}`),icon:`circle-x`}]}),callPet:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.callPet`,label:F(`Call pet`,`Chiama l’animale`),phrase:F(`Call your pet with {device}`,`Chiama l’animale con {device}`),icon:`megaphone`}]}),playSound:A(x({deviceId:n().int().nonnegative(),soundId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.playSound`,label:F(`Play sound`,`Riproduci un suono`),phrase:F(`Play sound {soundId} on {device}`,`Riproduci il suono {soundId} su {device}`),icon:`volume-2`,openArgs:[{key:`soundId`,label:F(`Sound`,`Suono`),offer:{kind:`number`,min:0,step:1}}]}]}),resetDesiccant:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.resetDesiccant`,label:F(`Desiccant replaced`,`Essiccante sostituito`),phrase:F(`Mark the desiccant of {device} as replaced`,`Segna come sostituito l’essiccante di {device}`),icon:`refresh-cw`}]}),markFoodReplenished:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.foodReplenished`,label:F(`Food refilled`,`Cibo ricaricato`),phrase:F(`Mark {device} as refilled`,`Segna {device} come ricaricato`),icon:`package`}]}),setChildLock:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.childLockOn`,effect:{field:`childLock`,value:!0},label:F(`Child lock on`,`Blocco bambini attivo`),phrase:F(`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:F(`Child lock off`,`Blocco bambini spento`),phrase:F(`Turn off the child lock of {device}`,`Disattiva il blocco bambini di {device}`),icon:`lock-open`,args:{on:!1}}]}),setIndicatorLight:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.lightOn`,effect:{field:`indicatorLight`,value:!0},label:F(`Indicator light on`,`Spia accesa`),phrase:F(`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:F(`Indicator light off`,`Spia spenta`),phrase:F(`Turn off the indicator light of {device}`,`Spegni la spia di {device}`),icon:`lightbulb-off`,args:{on:!1}}]}),setFeedSound:A(x({deviceId:n().int().nonnegative(),on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.feedSoundOn`,effect:{field:`feedSound`,value:!0},label:F(`Feeding sound on`,`Suono di erogazione attivo`),phrase:F(`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:F(`Feeding sound off`,`Suono di erogazione spento`),phrase:F(`Turn off the feeding sound of {device}`,`Disattiva il suono di erogazione di {device}`),icon:`volume-x`,args:{on:!1}}]}),setVolume:A(x({deviceId:n().int().nonnegative(),level:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFeeder.volume`,effect:{field:`volume`,fromArg:`level`},label:F(`Set volume`,`Imposta il volume`),phrase:F(`Set the volume of {device} to {level}`,`Imposta il volume di {device} a {level}`),icon:`volume-2`,openArgs:[{key:`level`,label:F(`Volume`,`Volume`),offer:{kind:`number`,min:0,step:1}}]}]})},status:{schema:sY,kind:`poll`},runtimeState:sY,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:F(`Pet feeder`,`Distributore di cibo`),order:2030,state:[{kind:`boolean`,field:`lowFood`,label:F(`Food low`,`Cibo in esaurimento`),whenTrue:F(`When {device} runs low on food`,`Quando il cibo di {device} sta finendo`),whenFalse:F(`When {device} has enough food again`,`Quando {device} ha di nuovo cibo a sufficienza`),icon:`package`},{kind:`boolean`,field:`feeding`,label:F(`Feeding`,`In erogazione`),whenTrue:F(`When {device} starts feeding`,`Quando {device} inizia a erogare`),whenFalse:F(`When {device} finishes feeding`,`Quando {device} finisce di erogare`),icon:`paw-print`},{kind:`numeric`,field:`desiccantLeftDays`,quantity:F(`the desiccant life`,`la durata dell’essiccante`),label:F(`Desiccant`,`Essiccante`),unit:`d`,icon:`calendar-clock`}]}},lY=x({waterLevel:n().min(0).max(100).nullable().meta(N(`percentage`)),waterVolume:n().min(0).nullable().meta(N(`volume`)),empty:y().nullable(),pumpRunning:y().nullable(),error:l().nullable(),lastFetchedAt:n()}),uY=`water`;function rke(e){let t=e.waterLevel!==null||e.empty===null?null:e.empty?`empty`:`ok`;return{key:uY,label:`Water`,level:e.waterLevel,status:t,kind:`supply`,form:`tank`,lastResetAt:null,resettable:!1}}var ike=n().int().nonnegative(),dY={name:`pet-fountain`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],power:{kind:`field`,field:`pumpRunning`,set:`setPump`},methods:{setPump:A(x({deviceId:ike,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`petFountain.pumpOn`,effect:{field:`pumpRunning`,value:!0},label:F(`Pump on`,`Pompa accesa`),phrase:F(`Start the pump of {device}`,`Avvia la pompa di {device}`),icon:`play`,args:{on:!0}},{id:`petFountain.pumpOff`,effect:{field:`pumpRunning`,value:!1},label:F(`Pump off`,`Pompa spenta`),phrase:F(`Stop the pump of {device}`,`Ferma la pompa di {device}`),icon:`square`,args:{on:!1}}]})},status:{schema:lY,kind:`push`},runtimeState:lY,durability:`session`,history:{fields:{waterLevel:{kind:`gauge`,unit:`%`,deadband:1},waterVolume:{kind:`gauge`,unit:`L`}}},vocabulary:{noun:F(`Pet fountain`,`Fontana per animali`),order:2040,state:[{kind:`boolean`,field:`empty`,label:F(`Tank empty`,`Serbatoio vuoto`),whenTrue:F(`When the tank of {device} is empty`,`Quando il serbatoio di {device} è vuoto`),whenFalse:F(`When the tank of {device} is refilled`,`Quando il serbatoio di {device} viene riempito`),icon:`droplet`},{kind:`numeric`,field:`waterLevel`,quantity:F(`the water level`,`il livello dell’acqua`),label:F(`Water level`,`Livello dell’acqua`),unit:`%`,icon:`droplets`}]}},ake=S(va),oke=2,fY={min:1,max:8},pY=S([`intel-core-ultra`,`intel-n-series`,`apple-m-base`,`apple-m-pro`,`amd-phoenix`,`unknown`]),mY=S([`intel-npu`,`intel-igpu`,`amd-igpu`,`amd-npu`,`x86-cpu`,`arm-cpu`,`apple-ane`,`coral`]),hY=i(`kind`,[x({kind:p(`capacity`),sessions:n(),minSessions:n()}),x({kind:p(`tie-faster`),over:l(),recallDelta:n()}),x({kind:p(`stepped-down`),from:l(),to:l(),limitedBy:l()}),x({kind:p(`no-fit-lightest`),sessions:n(),minSessions:n()}),x({kind:p(`derived-latency`),modelId:l()}),x({kind:p(`cpu-device`)}),x({kind:p(`device-disabled`)}),x({kind:p(`device-unavailable`)}),x({kind:p(`node-offline`)}),x({kind:p(`no-hardware-facts`)}),x({kind:p(`no-measured-data`),hardwareClass:pY}),x({kind:p(`no-family-build`),format:ake}),x({kind:p(`kept-custom-pin`),modelId:l(),deviceKey:l()})]),gY=S([`custom-pin`]),_Y=i(`kind`,[x({kind:p(`table`)}),x({kind:p(`node-benchmark`),resultId:l(),measuredAtMs:n()}),x({kind:p(`estimated`),estimatedFrom:pY})]),vY=x({modelId:l(),p50Ms:n(),fps:n(),measured:y(),source:_Y.optional(),estimatedFrom:pY.optional(),capacitySessions:n(),personRecall:n()}),yY=x({deviceKey:l(),accelerator:mY.nullable(),enabled:y(),available:y(),chosen:vY.nullable(),kept:gY.optional(),reasons:C(hY).readonly()}),bY=x({nodeId:l(),reachable:y(),hardwareClass:pY.nullable(),cpuModel:l().nullable(),skipped:y(),acceleratorModelId:l().nullable(),devices:C(yY).readonly(),reasons:C(hY).readonly()}),xY=x({stepId:l(),before:l().nullable(),after:l().nullable()}),SY=x({nodeId:l(),deviceKey:l(),madeExplicit:y(),modelPins:C(xY).readonly(),thresholds:C(x({stepId:l(),keys:C(l()).readonly()})).readonly()}),CY=i(`kind`,[x({kind:p(`custom-pin-kept`),nodeId:l(),deviceKey:l(),modelId:l()}),x({kind:p(`custom-registry-unreadable`),error:l()})]),wY=x({headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(fY.min).max(fY.max).default(2)}),TY=x({planHash:l(),family:p(`yolov9`),headroom:n(),minSessionsPerDevice:n(),cameraFps:n(),generatedAt:n(),nodes:C(bY).readonly(),nodeChanges:C(SY).readonly(),warnings:C(CY).readonly()}),EY=x({planHash:l(),headroom:n().min(.3).max(.5).default(.4),minSessionsPerDevice:n().int().min(fY.min).max(fY.max).default(2)}),DY=x({phase:S([`download`,`node-models`,`redispatch`]),ok:y(),detail:l()}),OY=i(`kind`,[x({kind:p(`applied`),planHash:l(),phases:C(DY).readonly()}),x({kind:p(`aborted`),phases:C(DY).readonly()}),x({kind:p(`stale`),plan:TY}),x({kind:p(`refused`),reason:S([`apply-in-progress`])})]),kY=S([`least-loaded`,`share`]),AY=`share`,ske=`sessionPlacement`;function cke(e){let t=kY.safeParse(e);return t.success?t.data:AY}var jY=x({nodes:m(l(),n().positive()).default({}),devices:m(l(),m(l(),n().positive())).default({})}),MY=x({windowMs:n().int().min(6e4).max(1440*60*1e3).default(3600*1e3)}),NY=x({deviceKey:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable()}),PY=x({nodeId:l(),sessionsNow:n(),sessionsStarted:n(),observedShare:n().nullable(),peakSessions:n(),yieldsAway:n(),devices:C(NY).readonly()}),FY=x({deviceId:n(),deviceKey:l(),reason:S([`disabled`,`absent`])}),IY=x({policy:kY,windowMs:n(),observedForMs:n(),sessionsNow:n(),clusterPeakSessions:n(),nodes:C(PY).readonly(),stalePins:C(FY).readonly()}),LY=S([`hardware`,`benchmark`]),RY=S([`no-benchmark-results`,`partial-benchmark-results`]),zY=x({headroom:n().min(.3).max(.5).default(.4),source:LY.default(`hardware`)}),BY=x({deviceKey:l(),share:n(),modelId:l().nullable(),fps:n().nullable(),measured:y(),suggestedMaxSessions:n().nullable()}),VY=x({nodeId:l(),share:n().nullable(),capacitySessions:n(),devices:C(BY).readonly(),skippedReason:l().nullable(),capacitySource:LY.nullable(),capacityFallback:RY.nullable()}),HY=x({headroom:n(),source:LY,cameraFps:n(),minSessionsPerDevice:n(),nodes:C(VY).readonly()}),UY=S([`hardware`,`benchmark`,`manual`]),WY=`benchmark`;function GY(e){return e!==`manual`}var lke=.4,uke=`shareSource`;function dke(e){if(e===`auto`)return`hardware`;let t=UY.safeParse(e);return t.success?t.data:WY}var KY=x({source:UY}),fke=x({nodes:m(l(),n()),devices:m(l(),m(l(),n()))}),qY=x({deviceKey:l(),eligible:y(),configuredPct:n(),effectivePct:n()}),JY=x({nodeId:l(),eligible:y(),configuredPct:n(),effectivePct:n(),capacitySource:LY.nullable(),capacityFallback:RY.nullable(),devices:C(qY).readonly()}),YY=x({source:UY,policy:kY,autoPending:y(),computedAt:n().nullable(),trigger:l().nullable(),nodes:C(JY).readonly(),nodeWeights:m(l(),n()),deviceWeights:m(l(),m(l(),n()))}),XY=[`motion-without-detections`,`detections-under-floor`,`inference-too-slow`,`frames-shed`,`inference-device-unusable`],ZY=S(XY),QY=S([`info`,`warning`,`critical`]),$Y=i(`type`,[x({type:p(`camera`),deviceId:n()}),x({type:p(`node`),nodeId:l()}),x({type:p(`inference-device`),nodeId:l(),deviceKey:l()})]),eX=x({id:l(),kind:ZY,severity:QY,subject:$Y,what:l(),evidence:m(l(),n().nullable()),action:l()}),tX=x({source:l(),entries:n().nullable()}),nX=x({nodeId:l(),sessionsNow:n(),unusableDevices:C(l()).readonly(),devices:C(x({deviceKey:l(),sessionsNow:n(),usable:y()})).readonly()}),rX=x({deviceId:n(),nativeCropMissesSincePreviousTick:n().nullable()}),iX=x({generatedAt:n(),tickMs:n(),camerasSeen:n().nullable(),findings:C(eX).readonly(),cameraSignals:C(rX).readonly(),nodes:C(nX).readonly(),sources:C(tX).readonly(),notCovered:C(l()).readonly()}),aX=x({history:n().int().min(1).max(24).default(1)}),oX=x({latest:iX.nullable(),previous:C(iX).readonly()}),pke=x({engine:VU.optional(),steps:C(Ea).readonly(),audio:x({engine:VU.optional(),modelId:l().optional(),enabled:y(),settings:m(l(),w()).readonly().optional()}).nullable().optional()}),sX=x({modelId:l().optional(),settings:m(l(),w()).optional(),jumpDeviceKey:l().optional(),enabled:y().optional()}),cX=x({maxCameras:n().int().nonnegative().nullable().default(null),detectWeight:n().positive().optional(),detect:y().optional(),decode:y().optional(),audio:y().optional(),ingest:y().optional(),decodeBudgetMb:n().int().min(1024).max(65536).optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).optional(),reachableHost:l().optional(),color:fl.optional(),stepSettings:m(l(),m(l(),w()).readonly()).optional(),stepEnabled:m(l(),y()).optional(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),sX).optional()})).optional()}),mke=m(l(),m(l(),w()).readonly()),lX=S([`pipeline`,`onboard`,`none`]),hke=x({stepToggles:m(l(),y()).optional(),stepSettings:mke.optional()}),uX=x({deviceId:n(),agentNodeId:l(),pinned:y(),reason:S([`manual`,`capacity`,`hardware-affinity`,`failover`,`rebalance`]),assignedAt:n()}),dX=x({nodeId:l(),online:y(),load:$W,score:n(),decodeHwaccel:l().nullable()}),fX=x({totalAgents:n(),onlineAgents:n(),totalCameras:n(),attachedCameras:n(),activeCameras:n(),avgInferenceTimeMs:n(),queueDepth:n()}),pX=m(l(),l()),mX=x({ownerNodeId:l(),reachableHost:l().optional(),configIssue:l().optional()}),hX=x({camStreamId:l(),codec:l(),width:n(),height:n(),fps:n(),kind:l()}),gX=x({streams:C(hX).readonly()}),_X=x({detectionNodeId:l().nullable(),decoderNodeId:l().nullable(),audioNodeId:l().nullable(),sourceNodeId:l().nullable(),pinned:x({detection:y(),decoder:y(),audio:y()}),reasons:x({detection:l().optional(),decoder:l().optional(),audio:l().optional()})}),vX=x({profile:l(),status:l(),codec:l(),width:n(),height:n(),subscribers:n(),inFps:n().nullable()}),yX=x({profiles:C(vX).readonly(),webrtcSessions:n(),rtspRestream:y()}),bX=x({nodeId:l()}),xX=x({enabled:y(),fps:n()}),SX=S([`idle`,`installing`,`verifying`,`ready`,`failed`]),CX=x({state:SX,error:l().optional()}),wX=S([`idle`,`watching`,`active`]),TX=x({nodeId:l(),engine:x({backend:l(),device:l()}),phase:wX,configuredFps:n(),actualFps:n(),queueDepth:n(),avgInferenceMs:n(),provisioning:CX}),EX=x({nodeId:l(),enabled:y()}),DX=Mp,OX=x({mode:DX,active:y(),storageBytes:n()}),kX=S([`source`,`broker`,`detection`,`recording`,`switches`]),AX=S([`timeout`,`error`,`partial`]),jX=x({stage:kX,reason:AX,elapsedMs:n()}),MX=x({state:S([`idle`,`running`,`done`,`error`]),total:n().int().nonnegative(),completed:n().int().nonnegative(),currentDeviceId:n().int().nullable(),failed:C(n().int()).readonly(),mediaDropped:n().int().nonnegative(),tracks:n().int().nonnegative(),events:n().int().nonnegative(),startedAtMs:n().int().nullable(),finishedAtMs:n().int().nullable(),error:l().nullable()}),NX=x({deviceId:n(),assignment:_X,source:gX,broker:yX.nullable(),decoder:bX.nullable(),motion:xX.nullable(),detection:TX.nullable(),audio:EX.nullable(),recording:OX.nullable(),switchedOff:C(wd).readonly(),cameraSensors:yV.optional(),degraded:C(jX).readonly(),fetchedAt:n()}),PX=[`disabled`,`unavailable`,`cannot-host-camera-root`,`accelerator-preferred`,`root-switched-off`,`no-gpu-device`],FX=S(PX),gke=x({key:l(),backend:l(),device:l(),format:S(va),available:y(),presence:S([`present`,`absent`,`unknown`]).optional(),enabled:y(),weight:n(),maxSessions:n().nullable(),defaultModelId:l(),steps:m(l(),sX).optional(),exclusion:FX.nullable()}),IX=i(`kind`,[x({kind:p(`stored`),modelId:l()}),x({kind:p(`absent`),defaultModelId:l()}),x({kind:p(`unreadable`),reason:S(MV),error:l().optional()})]),_ke=x({nodeId:l(),reachable:y(),devices:C(gke).readonly()}),LX=S([`off`,`on`,`opt-in`]),RX=i(`kind`,[x({kind:p(`on`)}),x({kind:p(`off-cluster`)}),x({kind:p(`off-node`)}),x({kind:p(`off-device`)}),x({kind:p(`jump`),toDeviceKey:l()}),x({kind:p(`skip`),reason:S([`no-compatible-model`,`root-not-runnable-on-elected-device`])}),x({kind:p(`zone-driven`)}),x({kind:p(`supplied-by-root`),rootModelId:l()}),x({kind:p(`opt-in-unused`)})]),vke=x({deviceKey:l(),format:S(va),stepEnabled:y().nullable(),eligible:y(),cell:RX}),yke=x({nodeId:l(),reachable:y(),stepEnabled:y().nullable(),devices:C(vke).readonly()}),zX=x({steps:C(x({stepId:l(),name:l(),slot:l(),clusterMode:LX.nullable(),effectiveMode:LX,camerasEnabling:n().int().nonnegative(),camerasDisabling:n().int().nonnegative(),nodes:C(yke).readonly()})).readonly()}),BX=x({deviceId:n().int().nonnegative(),config:fV.nullable()}),VX=S([`unknown-camera`,`out-of-range`,`no-burst-producer`,`already-looked`]),HX=x({deviceId:n().int().nonnegative(),afterMs:n().finite(),reason:l()}),UX=x({scheduled:y(),dueInMs:n().optional(),refusedBecause:VX.optional()}),WX={name:`pipeline-orchestrator`,scope:`system`,mode:`singleton`,nodeIdMode:`data`,exposesDeviceSettings:!0,methods:{requestOccupancyLook:A(HX,UX,{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),assignPipeline:A(x({deviceId:n(),agentNodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignPipeline:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setPipelineDevicePin:A(x({deviceId:n(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPipelineDevicePin:A(x({deviceId:n()}),x({deviceKey:l().nullable()})),rebalance:A(v(),x({migrated:n(),skipped:C(x({deviceId:n(),targetNodeId:l(),reason:l()})).default([])}),{kind:`mutation`,auth:`admin`}),getPipelineAssignments:A(v(),C(uX).readonly()),getPipelineAssignment:A(x({deviceId:n()}),uX.nullable()),getAgentLoad:A(v(),C(dX).readonly()),getClusterModelChoice:A(x({stepId:l()}),IX),getGlobalMetrics:A(v(),fX),getCameraMetrics:A(x({deviceId:n()}),JU.nullable()),getCapabilityBindings:A(x({nodeId:l()}),pX),setCapabilityBinding:A(x({nodeId:l(),capName:l(),addonId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getIngestOwner:A(v(),mX),assignAudio:A(x({deviceId:n(),nodeId:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),unassignAudio:A(x({deviceId:n()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getAudioAssignment:A(x({deviceId:n()}),x({nodeId:l(),pinned:y(),assignedAt:n()}).nullable()),getAudioNodeLoad:A(v(),C(x({nodeId:l(),deviceCount:n()}))),getAudioAssignments:A(v(),C(x({deviceId:n(),nodeId:l(),pinned:y(),assignedAt:n()}))),getAgentSettings:A(x({agentNodeId:l()}),cX.nullable()),listAgentSettings:A(v(),C(x({nodeId:l(),settings:cX})).readonly()),removeAgentSettings:A(x({agentNodeId:l()}),x({success:y(),removed:y()}),{kind:`mutation`,auth:`admin`}),setAgentMaxCameras:A(x({agentNodeId:l(),maxCameras:n().int().nonnegative().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentCapabilities:A(x({agentNodeId:l(),detect:y().nullable().optional(),audio:y().nullable().optional(),ingest:y().nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentDecodeLimits:A(x({agentNodeId:l(),decodeBudgetMb:n().int().min(1024).max(65536).nullable().optional(),maxLiveDecodeWorkers:n().int().min(1).max(32).nullable().optional()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentReachableHost:A(x({agentNodeId:l(),reachableHost:l().nullable().optional(),color:fl.nullable().optional()}).refine(e=>e.reachableHost!==void 0||e.color!==void 0,{message:`reachableHost or color required`}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setAgentInferenceDevices:A(x({agentNodeId:l(),inferenceDevices:m(l(),x({enabled:y(),weight:n().positive().optional(),maxSessions:n().int().positive().optional(),steps:m(l(),sX).optional()}))}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepSettings:A(x({agentNodeId:l(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setClusterStepMode:A(x({stepId:l(),mode:LX.nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setNodeStepEnabled:A(x({agentNodeId:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setDeviceStepEnabled:A(x({agentNodeId:l(),deviceKey:l(),stepId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getStepSwitches:A(v(),zX),getNodeInferenceDevices:A(x({nodeId:l()}),_ke),forgetInferenceDevice:A(x({agentNodeId:l(),deviceKey:l()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resetNodePipelineDefaults:A(x({agentNodeId:l()}),x({success:p(!0),effectiveModelId:l().nullable()}),{kind:`mutation`,auth:`admin`}),planAutoTune:A(wY,TY,{auth:`admin`}),applyAutoTune:A(EY,OY,{kind:`mutation`,auth:`admin`}),setLoadBalancingShares:A(jY,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getPlacementStats:A(MY,IY,{auth:`admin`}),getHealthDigest:A(aX,oX,{auth:`admin`}),suggestShares:A(zY,HY,{auth:`admin`}),getEffectiveShares:A(v(),YY,{auth:`admin`}),setShareSource:A(KY,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkPreflight:A(rW,cW,{auth:`admin`}),startNodeBenchmark:A(rW,i(`kind`,[x({kind:p(`started`),runId:l()}),x({kind:p(`refused`),preflight:cW})]),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkStatus:A(v(),CW,{auth:`admin`}),abortNodeBenchmark:A(x({runId:l()}),x({aborted:y()}),{kind:`mutation`,auth:`admin`}),getNodeBenchmarkCandidates:A(x({nodeId:l()}),DW,{auth:`admin`}),listNodeBenchmarkResults:A(TW,C(EW).readonly(),{auth:`admin`}),deleteNodeBenchmarkResult:A(x({id:l()}),x({deleted:y()}),{kind:`mutation`,auth:`admin`}),getCameraSettings:A(x({deviceId:n()}),hke.nullable()),setCameraStepToggle:A(x({deviceId:n(),addonId:l(),enabled:y().nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),getCameraDetectionSource:A(x({deviceId:n()}),x({source:lX,explicit:y(),onboard:x({available:y(),geometry:S([`boxed`,`while-streaming`,`flag-only`,`unknown`])})})),setCameraDetectionSource:A(x({deviceId:n(),source:lX}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),setCameraStepSettings:A(x({deviceId:n(),addonId:l(),settings:m(l(),w()).nullable()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),resolvePipeline:A(x({deviceId:n(),agentNodeId:l().optional()}),pke),getCameraSwitches:A(x({deviceId:n()}),Ad,{role:`viewer`}),setCameraSwitch:A(x({deviceId:n(),switchId:wd,enabled:y()}),Ad,{kind:`mutation`,auth:`admin`}),getCameraStatus:A(x({deviceId:n()}),NX),getCameraStatuses:A(x({deviceIds:C(n()).optional()}),C(NX).readonly()),setCameraSensors:A(BX,x({success:p(!0)}),{kind:`mutation`,auth:`admin`}),reconcileFromDisk:A(v(),MX,{kind:`mutation`,auth:`admin`}),getReconcileFromDiskStatus:A(v(),MX,{auth:`admin`})},vocabulary:{notOperatorFacing:M.PIPELINE}},GX=x({id:l(),name:l(),sampleCount:n().int().nonnegative(),coverMediaId:n().int().optional(),coverBase64:l().optional()}),bke=x({id:l(),text:l(),score:n(),addedAt:n().int(),deviceId:n().int().optional(),base64:l().optional(),mediaId:n().int().optional(),keyFrameMediaId:n().int().optional(),plateBbox:AS.optional()}),KX=x({plateId:l(),deviceId:n().int(),trackId:l(),timestamp:n().int(),text:l(),score:n(),corrected:y(),recognizedVehicleId:l().optional(),vehicleName:l().optional(),assigned:y(),plateBbox:AS.optional(),keyFrameMediaId:n().int().optional(),base64:l().optional(),cropUrl:l().optional(),cropMissReason:l().optional()}),xke=x({mediaId:n().int(),kind:l(),url:l(),sizeBytes:n(),timestamp:n()}),Ske=x({plateIds:C(l()).readonly(),representativePlateId:l(),representativeText:l(),size:n().int(),cohesion:n()}),qX={name:`plate-gallery`,role:{feature:`plate-assignment`},scope:`system`,mode:`singleton`,methods:{listPlates:A(x({deviceId:n().int().optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}).optional(),C(KX).readonly()),getPlateByTrack:A(x({deviceId:n().int(),trackId:l()}),KX.nullable(),{role:`viewer`}),getPlateMedia:A(x({plateId:l()}),C(xke).readonly()),searchPlates:A(x({text:l().min(1),maxDistance:n().int().min(0).optional(),limit:n().int().positive().optional(),includeCrops:y().optional()}),C(KX).readonly()),suggestPlateClusters:A(x({maxDistance:n().int().min(0).optional(),minClusterSize:n().int().min(2).optional(),limit:n().int().positive().optional()}).optional(),C(Ske).readonly()),correctPlateText:A(x({plateId:l(),text:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deletePlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicles:A(x({includeCrops:y().optional()}).optional(),C(GX).readonly()),createVehicle:A(x({name:l().min(1)}),GX,{kind:`mutation`,auth:`admin`}),renameVehicle:A(x({id:l(),name:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),deleteVehicle:A(x({id:l()}),v(),{kind:`mutation`,auth:`admin`}),listVehicleSamples:A(x({vehicleId:l()}),C(bke).readonly()),removeVehicleSample:A(x({vehicleId:l(),sampleId:l()}),v(),{kind:`mutation`,auth:`admin`}),moveVehicleSample:A(x({sampleId:l().min(1),toVehicleId:l().min(1)}),v(),{kind:`mutation`,auth:`admin`}),assignPlate:A(x({plateId:l(),vehicleId:l()}),v(),{kind:`mutation`,auth:`admin`}),unassignPlate:A(x({plateId:l()}),v(),{kind:`mutation`,auth:`admin`}),assignPlates:A(x({plateIds:C(l()).min(1),vehicleId:l()}),x({assigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`}),unassignPlates:A(x({plateIds:C(l()).min(1)}),x({unassigned:n().int(),failed:C(l()).readonly()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:`the plate gallery — curated on its own page`}},JX={"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}}}},YX={"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}},XX=.5,Cke=2,wke=.05,Tke=24,Eke=750,Dke=64,ZX=2e3,Oke=12,QX=n().nullable().transform(e=>e!==null&&Number.isFinite(e)&&e>0?e:null),$X=l().nullable().transform(e=>e!==null&&e.trim()!==``?e:null),eZ=x({int8:QX,fp16:QX}),tZ=x({deviceKey:l(),fullDeviceName:$X,executionUnits:QX,clockMHz:QX,gops:eZ.nullable(),architecture:$X,npuName:$X,tops:QX,vendor:$X,webgpuArchitecture:$X,webgpuDevice:$X,computeUnits:QX}),kke=x({accelerators:C(tZ).nullable()}),nZ=[{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*ZX}},{hardwareClass:`amd-phoenix`,accelerator:`amd-igpu`,score:{metric:`cu`,value:12}}];function Ake(e){let t=kke.safeParse(e);return!t.success||t.data.accelerators===null?null:t.data.accelerators}function rZ(e){return e!==null&&e>0?e:null}function iZ(e){let t=[],n=rZ(e.gops?.int8??null);n!==null&&t.push({metric:`gops-int8`,value:n});let r=rZ(e.gops?.fp16??null);r!==null&&t.push({metric:`gops-fp16`,value:r});let i=rZ(e.executionUnits),a=rZ(e.clockMHz);i!==null&&a!==null&&t.push({metric:`eu-mhz`,value:i*a});let o=rZ(e.computeUnits);o!==null&&t.push({metric:`cu`,value:o});let s=rZ(e.tops);return s!==null&&t.push({metric:`tops`,value:s}),t}function aZ(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 oZ(e,t,n){for(let r of iZ(e))if(aZ(t,r,n)!==null)return r;return null}function sZ(e,t,n=nZ){return oZ(e,t,n)!==null}function cZ(e,t,n){if(t!==`unknown`)return e[t]?.[n]}function jke(e){return Math.round(e*10)/10}function Mke(e){return Math.min(2,Math.max(XX,e))}function Nke(e,t,n){let r={};for(let[i,a]of Object.entries(e))r[i]={p50Ms:jke(a.p50Ms/t),fps:Math.max(1,Math.round(a.fps*t)),measured:!1,estimatedFrom:n};return r}function lZ(e){let t=e.perf??JX,n=e.references??nZ,r=cZ(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:oZ(e.report,e.accelerator,n);if(i===null)return r===void 0?null:{column:r,estimatedFrom:null};let a=aZ(e.accelerator,i,n),o=a===null?void 0:cZ(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:Nke(o,Mke(s),a.hardwareClass),estimatedFrom:a.hardwareClass}}var uZ=S(va),Pke=S([`videotoolbox`,`cuda`,`nvdec`,`vaapi`,`qsv`,`d3d11va`,`dxva2`,`amf`,`vdpau`,`drm`,`coreml`,`tensorrt`,`openvino`,`directml`,`webgpu`,`none`]).nullable().optional(),Fke=x({preferred:C(l()).readonly(),rationale:l()}),dZ=S([`h264_videotoolbox`,`hevc_videotoolbox`,`h264_vaapi`,`hevc_vaapi`,`h264_nvenc`,`hevc_nvenc`,`h264_qsv`,`hevc_qsv`,`h264_amf`,`hevc_amf`,`libx264`,`libx265`]);x({encoders:C(x({encoder:dZ,codec:S([`H264`,`H265`]),family:S([`videotoolbox`,`vaapi`,`nvenc`,`qsv`,`amf`,`software`]),available:y(),reason:l().optional()})).readonly(),defaultH264:dZ,defaultH265:dZ,probedAt:n()}),x({methods:C(l()).readonly(),probedAt:n()});var Ike=S([`darwin`,`linux`,`win32`]),Lke=S([`arm64`,`x64`]),Rke=x({type:S([`nvidia`,`amd`,`intel`,`apple`]),name:l(),memoryMB:n().optional()}),zke=x({type:S([`apple-ane`,`intel-npu`,`amd-xdna`]),name:l().optional(),generation:S([`xdna1`,`xdna2`]).optional()}),fZ=S([`usb`,`pci`]),Bke=x({type:p(`coral-edgetpu`),bus:l().optional(),count:n().int().nonnegative().optional(),units:C(x({bus:fZ,count:n().int().nonnegative()})).readonly().optional(),unavailable:C(x({bus:fZ,count:n().int().nonnegative(),reason:S([`driver-missing`,`device-not-accessible`])})).readonly().optional()}),pZ=x({type:p(`nvidia`),name:l(),memoryMB:n().optional()}),Vke=i(`usable`,[pZ.extend({usable:p(!0)}),pZ.extend({usable:p(!1),reason:S([`no-cuda-execution-provider`])})]),mZ=x({platform:Ike,arch:Lke,cpuModel:l(),cpuCores:n(),totalRAM_MB:n(),availableRAM_MB:n(),gpu:Rke.nullable(),npu:zke.nullable(),coral:Bke.nullable().optional(),nvidia:Vke.nullable().optional(),accelerators:C(tZ).readonly().optional()}),hZ=x({runtime:p(`python`),backend:l(),format:S([`onnx`,`coreml`,`openvino`,`tflite`]),score:n(),reason:l(),available:y()}),gZ=x({key:l(),backend:l(),device:l(),format:uZ,runtime:p(`python`),score:n(),available:y()}),Hke=x({hardware:mZ,scores:C(hZ).readonly(),bestScore:hZ,pythonPath:l().nullable(),devices:C(gZ).readonly()}),Uke=x({modelId:l(),name:l(),minRAM_MB:n(),accuracyScore:n(),formats:C(l()).readonly()}),Wke=x({modelId:l(),runtime:p(`python`),backend:l(),format:uZ,reason:l()}),Gke=x({devices:C(gZ).readonly(),appeared:C(l()).readonly(),disappeared:C(l()).readonly(),usbBus:S([`observed`,`unobservable`]),decidedBy:S([`usb-ids`,`pci`,`delegate-fallback`,`none`])}),_Z={name:`platform-probe`,scope:`system`,mode:`singleton`,methods:{getCapabilities:A(v(),Hke),getHardware:A(v(),mZ),resolveInferenceConfig:A(x({requirements:C(Uke).readonly()}),Wke),resolveHwAccel:A(x({prefer:Pke}),Fke),rescanAccelerators:A(v(),Gke,{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.CLUSTER}},vZ=x({power:n().optional().meta(N(`power`,{label:`Power`})),deliveredPower:n().optional().meta(N(`power`,{label:`Delivered`})),energy:n().optional().meta(N(`energy`,{label:`Energy`})),voltage:n().optional().meta(N(`voltage`,{label:`Voltage`})),current:n().optional().meta(N(`current`,{label:`Current`})),apparentPower:n().optional().meta(N(`apparent-power`)),powerFactor:n().min(0).max(1).optional().meta(N(`ratio`)),lastFetchedAt:n()});function Kke(e){if(e.power===void 0)return;let t=e.power-(e.deliveredPower??0);return t<0?void 0:t}var yZ=[E.Sensor,E.Switch,E.Light,E.Fan,E.Climate,E.Humidifier,E.WaterHeater,E.MediaPlayer,E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.PetFeeder,E.Workload],qke=yZ.filter(e=>e!==E.Sensor);function bZ(e,t){return{id:e,cardinality:`scalar`,vocabulary:{cap:`power-meter`,stateField:e},deviceTypes:qke,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 Jke={version:1,targets:[bZ(`power`,`W`),bZ(`energy`,`kWh`),bZ(`voltage`,`V`),bZ(`current`,`A`)]},xZ={name:`power-meter`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:yZ,deviceConfig:{ui:{kind:`widget`,widgetId:`host/power-meter-line`,tab:`power`,placement:`hero`,label:`Power`,order:4}},methods:{},status:{schema:vZ,kind:`push`},runtimeState:vZ,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:Jke,vocabulary:{noun:F(`Power meter`,`Misuratore di energia`),order:5160,state:[{kind:`numeric`,field:`power`,quantity:F(`the power draw`,`il consumo`),label:F(`Power`,`Potenza`),unit:`W`,icon:`zap`},{kind:`numeric`,field:`energy`,quantity:F(`the energy used`,`l’energia consumata`),label:F(`Energy`,`Energia`),unit:`kWh`,icon:`zap`},{kind:`numeric`,field:`voltage`,quantity:F(`the voltage`,`la tensione`),label:F(`Voltage`,`Tensione`),unit:`V`,icon:`zap`},{kind:`numeric`,field:`current`,quantity:F(`the current`,`la corrente`),label:F(`Current`,`Corrente`),unit:`A`,icon:`zap`}]}},Yke=x({latitude:n().min(-90).max(90).meta(N(`angle`)),longitude:n().min(-180).max(180).meta(N(`angle`)),accuracyMeters:n().nonnegative().meta(N(`length`))}),SZ=x({state:l(),location:l().nullable(),gps:Yke.nullable(),lastChangedAt:n()}),CZ={name:`presence`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Presence],methods:{},status:{schema:SZ,kind:`push`},runtimeState:SZ,durability:`restored`,history:`none`,volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Presence`,`Presenza`),order:5170,state:[{kind:`value`,field:`state`,label:F(`Where`,`Posizione`),phrase:F(`When {device} is at {value}`,`Quando {device} è in {value}`),icon:`map-pin`}]}},wZ=x({pressure:n().nullable().meta(N(`pressure`,{precision:0})),lastFetchedAt:n()}),TZ={name:`pressure-sensor`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:wZ,kind:`push`},runtimeState:wZ,durability:`restored`,history:{fields:{pressure:{kind:`gauge`,unit:`hPa`,deadband:.1}}},volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Pressure`,`Pressione`),order:5180,state:[{kind:`numeric`,field:`pressure`,quantity:F(`the pressure`,`la pressione`),label:F(`Pressure`,`Pressione`),unit:`hPa`,icon:`gauge`}]}},EZ=i(`kind`,[TV,EV]),DZ=x({id:n(),enabled:y(),shape:EZ}),OZ=x({enabled:y(),regions:C(DZ).nullable(),audioEnabled:y().nullable(),lastFetchedAt:n()}),kZ=x({maxRegions:n(),supportedShapes:C(kV),polygonVertices:AV.optional(),supportsAudioMute:y()}),AZ=x({enabled:y().optional(),regions:C(DZ).optional()}),jZ={name:`privacy-mask`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/privacy-mask-grid`,tab:`image`,label:`Privacy Mask`}},methods:{getOptions:A(x({deviceId:n()}),kZ),setMask:A(x({deviceId:n(),patch:AZ}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.maskOn`,label:F(`Privacy mask on`,`Maschera privacy attiva`),phrase:F(`Cover the privacy zones of {device}`,`Oscura le zone private di {device}`),icon:`eye-off`,args:{patch:{enabled:!0}}},{id:`privacy.maskOff`,label:F(`Privacy mask off`,`Maschera privacy spenta`),phrase:F(`Uncover the privacy zones of {device}`,`Scopri le zone private di {device}`),icon:`eye`,args:{patch:{enabled:!1}}}]}),setAudioEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`privacy.micOn`,label:F(`Microphone on`,`Microfono attivo`),phrase:F(`Turn on the microphone of {device}`,`Attiva il microfono di {device}`),icon:`mic`,args:{enabled:!0}},{id:`privacy.micOff`,label:F(`Microphone off`,`Microfono spento`),phrase:F(`Turn off the microphone of {device}`,`Disattiva il microfono di {device}`),icon:`mic-off`,args:{enabled:!1}}]})},status:{schema:OZ,kind:`poll`},runtimeState:OZ,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`Privacy`,`Privacy`),order:3210,state:[{kind:`boolean`,field:`enabled`,label:F(`Privacy mask`,`Maschera privacy`),whenTrue:F(`When the privacy mask of {device} is turned on`,`Quando si attiva la maschera privacy di {device}`),whenFalse:F(`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:F(`Microphone`,`Microfono`),whenTrue:F(`When the microphone of {device} is turned on`,`Quando si attiva il microfono di {device}`),whenFalse:F(`When the microphone of {device} is turned off`,`Quando si disattiva il microfono di {device}`),icon:`mic`}]}};function Xke(e){return e.length===0?null:e.some(e=>e.audioEnabled)}var MZ=S([`home`,`day-mode`,`night-mode`,`day-night-auto`,`set-limits`,`save-limits`,`reboot`,`osd-menu`]),NZ=x({id:l(),name:l(),fn:MZ.nullable(),writable:y()}),PZ=x({pan:n().nullable(),tilt:n().nullable(),zoom:n().nullable()}),FZ=x({pan:n().optional(),tilt:n().optional(),zoom:n().optional(),speed:n().optional()}),IZ=PZ.extend({autofocus:y()}),LZ=x({hasPan:y(),hasTilt:y(),hasZoom:y(),supportsPresets:y(),maxPresets:n().optional(),hasAutofocus:y(),speedSteps:n().int().positive().nullable(),moveImpulseMs:n().int().positive().nullable()}),RZ=x({presetId:l().nullable(),source:S([`operator`,`firmware`,`native`,`none`])}),zZ=x({enabled:y(),seconds:n().int()}),BZ={name:`ptz`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-panel`,tab:`ptz`,topTab:!0,label:`PTZ`,order:0}},methods:{move:A(FZ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`a relative nudge from the live-view joystick; a fixed place is a preset`}),continuousMove:A(FZ.extend({deviceId:n()}),v(),{kind:`mutation`,notOperatorFacing:`joystick motion held until released — continuous, not a discrete step`}),goHome:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.goHome`,label:F(`PTZ go home`,`Torna alla posizione iniziale`),phrase:F(`Send {device} to its home position`,`Riporta {device} alla posizione iniziale`),icon:`house`}]}),getPresets:A(x({deviceId:n()}),C(NZ)),goToPreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,actions:[{id:`ptz.goToPreset`,label:F(`PTZ go to preset`,`Vai a un preset`),phrase:F(`Move {device} to {presetId}`,`Sposta {device} su {presetId}`),icon:`move`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),savePreset:A(x({deviceId:n(),presetId:l(),name:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.savePreset`,label:F(`Save PTZ preset here`,`Salva qui un preset`),phrase:F(`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:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}},{key:`name`,label:F(`Name`,`Nome`),offer:{kind:`text`}}]}]}),deletePreset:A(x({deviceId:n(),presetId:l()}),v(),{kind:`mutation`,auth:`admin`}),getOptions:A(x({deviceId:n()}),LZ),stop:A(x({deviceId:n()}),v(),{kind:`mutation`,actions:[{id:`ptz.stop`,label:F(`Stop moving`,`Ferma il movimento`),phrase:F(`Stop {device} moving`,`Ferma il movimento di {device}`),icon:`square`}]}),getHomePreset:A(x({deviceId:n()}),RZ),setHomePreset:A(x({deviceId:n(),presetId:l().nullable()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomePreset`,label:F(`Set PTZ home preset`,`Imposta il preset iniziale`),phrase:F(`Make {presetId} the home position of {device}`,`Rendi {presetId} la posizione iniziale di {device}`),icon:`house`,openArgs:[{key:`presetId`,label:F(`Preset`,`Preset`),offer:{kind:`dynamic`,from:`method`,method:`getPresets`,valueKey:`id`,labelKey:`name`}}]}]}),captureHomeHere:A(x({deviceId:n()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.captureHomeHere`,label:F(`Set PTZ home here`,`Imposta qui la posizione iniziale`),phrase:F(`Make where {device} points now its home position`,`Rendi la posizione attuale di {device} la sua posizione iniziale`),icon:`map-pin`}]}),getHomeReturn:A(x({deviceId:n()}),zZ.nullable()),setHomeReturn:A(x({deviceId:n(),enabled:y(),seconds:n().int().min(0).max(3600)}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`ptz.setHomeReturn`,label:F(`Set PTZ return home`,`Imposta il ritorno alla posizione iniziale`),phrase:F(`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:F(`Return home`,`Torna alla posizione iniziale`),offer:{kind:`boolean`}},{key:`seconds`,label:F(`Idle seconds`,`Secondi da fermo`),offer:{kind:`number`,min:0,max:3600,step:1,unit:`s`}}]}]}),getPosition:A(x({deviceId:n()}),PZ),setAutofocus:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autofocusOn`,label:F(`Autofocus on`,`Autofocus attivo`),phrase:F(`Turn on autofocus on {device}`,`Attiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!0}},{id:`ptz.autofocusOff`,label:F(`Autofocus off`,`Autofocus spento`),phrase:F(`Turn off autofocus on {device}`,`Disattiva l’autofocus su {device}`),icon:`focus`,args:{enabled:!1}}]})},status:{schema:IZ,kind:`command-driven`},vocabulary:{noun:F(`Pan / tilt / zoom`,`Brandeggio`),order:3220}},VZ=x({targetType:l().describe(`Vendor target string (people/vehicle/pet); empty = camera default`),stopDelaySeconds:n().int().min(0).max(300).meta(N(`duration`)),disappearDelaySeconds:n().int().min(0).max(300).meta(N(`duration`))}),HZ=x({value:l(),label:l()}),UZ=x({enabled:y(),lastChangedAt:n(),currentSettings:VZ.nullable(),supportedTargetTypes:C(HZ)}),WZ=UZ.extend({lastFetchedAt:n()}),GZ={name:`ptz-autotrack`,scope:`device`,deviceNative:!0,mode:`singleton`,kind:`wrapper`,defaultActive:!1,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/ptz-autotrack`,tab:`ptz`,topTab:!0,label:`Auto-Tracking`,order:5}},methods:{getStatus:A(x({deviceId:n()}),UZ),setEnabled:A(x({deviceId:n(),enabled:y()}),v(),{kind:`mutation`,actions:[{id:`ptz.autotrackOn`,label:F(`Autotrack on`,`Inseguimento attivo`),phrase:F(`Start autotracking on {device}`,`Attiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!0}},{id:`ptz.autotrackOff`,label:F(`Autotrack off`,`Inseguimento spento`),phrase:F(`Stop autotracking on {device}`,`Disattiva l’inseguimento automatico su {device}`),icon:`crosshair`,args:{enabled:!1}}]}),getSettings:A(x({deviceId:n()}),VZ.nullable()),setSettings:A(x({deviceId:n(),settings:VZ.partial()}),v(),{role:`admin`,kind:`mutation`,notOperatorFacing:`tracking tuning (target type, delays) — set once on the camera’s PTZ page`})},events:{onStatusChanged:{data:x({deviceId:n(),status:UZ}),notOperatorFacing:"the `enabled` state trigger phrases both edges of this change"}},status:{schema:UZ,kind:`command-driven`},runtimeState:WZ,durability:`session`,history:`none`,vocabulary:{noun:F(`Autotracking`,`Inseguimento automatico`),order:3230,state:[{kind:`boolean`,field:`enabled`,label:F(`Autotracking`,`Inseguimento automatico`),whenTrue:F(`When autotracking is turned on for {device}`,`Quando si attiva l’inseguimento automatico di {device}`),whenFalse:F(`When autotracking is turned off for {device}`,`Quando si disattiva l’inseguimento automatico di {device}`),icon:`crosshair`}]}},KZ=x({enabled:y().nullable(),onTime:n().min(0).nullable().meta(N(`duration`)),offTime:n().min(0).nullable().meta(N(`duration`)),lastFetchedAt:n()}),qZ=n().int().nonnegative(),JZ=n().int().min(0),YZ={name:`pump-cycle`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.PetFountain],methods:{setEnabled:A(x({deviceId:qZ,on:y()}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.on`,effect:{field:`enabled`,value:!0},label:F(`Pump cycle on`,`Ciclo pompa attivo`),phrase:F(`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:F(`Pump cycle off`,`Ciclo pompa spento`),phrase:F(`Run the pump of {device} continuously`,`Fai lavorare la pompa di {device} in continuo`),icon:`timer-off`,args:{on:!1}}]}),setOnMinutes:A(x({deviceId:qZ,minutes:JZ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.onMinutes`,label:F(`Set pump run time`,`Imposta il tempo di lavoro della pompa`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]}),setOffMinutes:A(x({deviceId:qZ,minutes:JZ}),v(),{kind:`mutation`,auth:`protected`,actions:[{id:`pumpCycle.offMinutes`,label:F(`Set pump rest time`,`Imposta il tempo di riposo della pompa`),phrase:F(`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:F(`Minutes`,`Minuti`),offer:{kind:`number`,min:0,step:1,unit:`min`}}]}]})},status:{schema:KZ,kind:`push`},runtimeState:KZ,durability:`session`,history:`none`,vocabulary:{noun:F(`Pump cycle`,`Ciclo della pompa`),order:2050,state:[{kind:`boolean`,field:`enabled`,label:F(`Pump cycle`,`Ciclo pompa`),whenTrue:F(`When {device} starts running its pump on a cycle`,`Quando {device} inizia a far lavorare la pompa a ciclo`),whenFalse:F(`When {device} runs its pump continuously`,`Quando {device} fa lavorare la pompa in continuo`),icon:`timer`}]}},XZ={name:`reboot`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera,E.Sensor,E.Switch,E.Gateway],methods:{reboot:A(x({deviceId:n().int().nonnegative()}),x({success:p(!0)}),{kind:`mutation`,auth:`admin`,actions:[{id:`reboot.reboot`,label:F(`Reboot device`,`Riavvia il dispositivo`),phrase:F(`Reboot {device}`,`Riavvia {device}`),icon:`refresh-cw`}]})},vocabulary:{noun:F(`Reboot`,`Riavvio`),order:3240}},ZZ=x({owner:l(),kind:Jr,title:l(),nameField:l(),fields:m(l(),w()),secretPaths:C(l()),rows:n().int().nonnegative()}),QZ=x({id:jB,name:l(),rev:n().int(),updatedAt:n(),data:MB}),$Z={owner:l().min(1),kind:Jr},eQ={name:`record-entries`,scope:`system`,mode:`singleton`,methods:{listEntryKinds:A(x({}),x({kinds:C(ZZ)}),{auth:`admin`}),listEntries:A(x({...$Z}),x({entries:C(QZ)}),{auth:`admin`}),putEntry:A(x({...$Z,id:jB.optional(),data:MB,ifRev:n().int().min(1).optional()}),x({id:l(),rev:n().int()}),{kind:`mutation`,auth:`admin`}),deleteEntry:A(x({...$Z,id:jB}),x({deleted:y()}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.INTERNAL}},Zke=`camstack`,Qke=`recorder`,tQ=x({profile:l(),startMs:n(),endMs:n()}),nQ=S([`read`,`unreadable`]),rQ=x({deviceId:n(),read:nQ,ranges:C(tQ),profilesWithFootage:C(l())}),iQ=x({deviceId:n(),read:nQ,days:C(n())}),aQ=x({deviceId:n(),localMasterPath:l().nullable(),playbackUrl:l().nullable(),playbackEndpoints:C(l())}),oQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),coverageAsOf:n().optional()}),sQ=x({source:l(),label:l(),addonId:l().optional(),availability:oQ}),cQ=x({transport:S([`archive`,`stream`,`realtime`]),coverage:S([`continuous`,`sparse`]),seek:S([`free`,`forward`,`segment`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly(),exclusive:y()}),lQ=i(`kind`,[x({kind:p(`hls`),manifest:aQ}),x({kind:p(`clip`),source:l(),clipId:l(),startsAtMs:n()}),x({kind:p(`none`),reason:l()})]),uQ={name:`recording`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listSources:A(x({deviceId:n()}),C(sQ).readonly(),{kind:`query`,auth:`protected`}),getAvailability:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:l().optional()}),rQ,{kind:`query`,auth:`protected`}),getDaysWithRecordings:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),iQ,{kind:`query`,auth:`protected`}),getPlayback:A(x({deviceId:n(),provider:l().min(1),fromMs:n(),toMs:n(),profile:P.optional()}),lQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:A(x({deviceId:n(),provider:l().min(1)}),cQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Recording`,`Registrazione`),order:3250}},dQ=x({deviceId:n(),enabled:y(),activeMode:Mp,nodeId:l(),storageBytes:n()}),$ke=200,fQ=x({deviceId:n(),read:S([`read`,`unreadable`]),ranges:C(tQ).readonly(),profilesWithFootage:C(l()).readonly()}),pQ=x({deviceId:n(),read:S([`read`,`unreadable`]),days:C(n()).readonly()}),mQ=x({deviceId:n(),usedBytes:n(),oldestMs:n().nullable().optional(),segments:n().optional(),residentBytes:n().optional(),residentOldestMs:n().nullable().optional()}),hQ=x({locationId:l().nullable(),locationIds:C(l()).optional(),root:l().optional(),usedBytes:n(),availableBytes:n().nullable(),totalBytes:n().nullable()}),gQ=x({nodeId:l(),totalUsedBytes:n(),devices:C(mQ),devicesRead:S([`archive`,`unavailable`]).optional(),complete:y().optional(),locations:C(hQ).optional()}),_Q=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l(),bytes:n(),files:n().int()}),vQ=S([`unassigned`,`target-not-writable`,`below-threshold`,`no-headroom`]),yQ=x({deviceId:n(),profile:l(),fromLocationId:l(),toLocationId:l().nullable(),bytes:n(),reason:vQ}),bQ=x({moves:C(_Q),skipped:C(yQ),bytesToMove:n(),jobIds:C(l())}),xQ=x({throttleMbps:n().min(1).max(1e3).optional(),minMoveGb:n().min(0).optional()}),eAe=x({deviceId:n().int(),profile:l(),locationId:l()}),tAe=x({deviceId:n().int(),locationId:l()}),nAe=x({assignments:C(eAe),pins:C(tAe),defaultLocations:m(l(),l())}),rAe=x({deviceId:n().int(),locationId:l().nullable()}),SQ=i(`kind`,[x({kind:p(`segment`),startMs:n(),durMs:n(),bytes:n()}),x({kind:p(`gap`),nearestEdgeMs:n().nullable(),prevEndMs:n().nullable().optional()})]),CQ=x({data:b(Uint8Array)}),wQ=x({data:b(Uint8Array),gopStartMs:n(),gopDurMs:n()}),TQ=i(`kind`,[x({kind:p(`ok`),data:b(Uint8Array),gopStartMs:n(),gopDurMs:n(),reachesRequestedEnd:y()}),x({kind:p(`spans-multiple-segments`),segmentEndMs:n()})]),EQ={name:`recording-archive`,scope:`system`,mode:`singleton`,exposesDeviceSettings:!0,status:{schema:dQ,kind:`command-driven`},methods:{getAvailabilityBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n()}),C(fQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getDaysWithRecordingsBatch:A(x({deviceIds:C(n()).min(1).max(200),fromMs:n(),toMs:n(),tzOffsetMinutes:n()}),C(pQ).readonly(),{role:`viewer`,kind:`query`,auth:`protected`}),getStorageUsage:A(x({}),gQ,{kind:`query`,auth:`admin`}),getDeviceConfig:A(x({deviceId:n()}),Hp,{role:`viewer`,kind:`query`,auth:`protected`}),locateSegment:A(x({deviceId:n(),profile:l(),epochMs:n()}),SQ,{kind:`query`,auth:`admin`}),readSegmentBytes:A(x({deviceId:n(),profile:l(),startMs:n()}),CQ,{kind:`query`,auth:`admin`}),readGopBytes:A(x({deviceId:n(),profile:l(),startMs:n(),epochMs:n()}),wQ,{kind:`query`,auth:`admin`}),readWindowBytes:A(x({deviceId:n(),profile:l(),startMs:n(),fromMs:n(),toMs:n()}),TQ,{kind:`query`,auth:`admin`}),setDeviceConfig:A(x({deviceId:n(),config:Hp}),Hp,{kind:`mutation`,auth:`admin`}),rescanStorage:A(x({deviceId:n()}),dQ,{kind:`mutation`,auth:`admin`}),pruneFootage:A(x({deviceId:n(),reason:Sp.optional()}),x({floorMs:n().nullable(),deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),deleteFootprint:A(x({deviceId:n(),fromMs:n().optional(),toMs:n().optional()}),x({deletedBuckets:n().int(),reclaimedBytes:n().int()}),{kind:`mutation`,auth:`admin`}),listOpsLog:A(wp,C(Cp).readonly(),{kind:`query`,auth:`admin`}),renderGif:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(2),postRollSec:n().min(0).max(30).default(5),maxWidth:n().int().min(120).max(1280).default(480),fps:n().int().min(1).max(15).default(5)}),x({gifBase64:l(),fromMs:n(),toMs:n()}),{kind:`mutation`,auth:`admin`}),renderClip:A(x({deviceId:n(),aroundMs:n(),preRollSec:n().min(0).max(30).default(3),postRollSec:n().min(0).max(30).default(7),maxWidth:n().int().min(160).max(1920).default(640)}),x({clipBase64:l(),mime:l(),fromMs:n(),toMs:n(),bytes:n().int()}),{kind:`mutation`,auth:`admin`}),pauseForStorageMigration:A(Xp,x({paused:p(!0)}),{kind:`mutation`,auth:`admin`}),resumeForStorageMigration:A(Xp,x({resumed:p(!0)}),{kind:`mutation`,auth:`admin`}),refreshStorageLocationsForMigration:A(Xp,x({refreshed:p(!0)}),{kind:`mutation`,auth:`admin`}),startStorageMigrationMove:A(Zp,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),getStorageMigrationMoveStatus:A(x({jobId:l()}),qp.nullable(),{auth:`admin`}),cancelStorageMigrationMove:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),relocateFootage:A(Yp,x({jobId:l()}),{kind:`mutation`,auth:`admin`}),listRelocateJobs:A(x({}),C(qp).readonly(),{kind:`query`,auth:`admin`}),getRelocateResidue:A(Cm,wm,{kind:`query`,auth:`admin`}),reconcileLedgerAgainstDisk:A(Tm,km,{kind:`mutation`,auth:`admin`}),cancelRelocateJob:A(x({jobId:l()}),x({cancelled:y()}),{kind:`mutation`,auth:`admin`}),planStorageRebalance:A(xQ,bQ,{kind:`query`,auth:`admin`}),startStorageRebalance:A(xQ,bQ,{kind:`mutation`,auth:`admin`}),getPlacement:A(x({}),nAe,{kind:`query`,auth:`admin`}),setDevicePlacement:A(rAe,x({ok:p(!0)}),{kind:`mutation`,auth:`admin`})},vocabulary:{notOperatorFacing:M.STORAGE}},iAe=24,aAe=3,oAe=S([`queue-full`,`camera-backoff`,`sleeping`,`camera-refused`,`no-keyframe`,`decode-failed`,`no-catalog-row`,`unsupported`,`unknown-device`,`uid-missing`]),sAe=S([`deferred`,`final`]),cAe=`x-camstack-reason`,lAe=500;function uAe(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 dAe=`x-camstack-reason-code`,fAe=`x-camstack-disposition`,pAe=`x-camstack-clip-transport`,DQ=x({id:l(),source:l(),kind:S([`motion`,`object`,`audio`,`native`]),timeRange:x({startMs:n(),endMs:n()}),labels:C(l()).max(3).optional(),thumbnail:l().optional(),stillAtMs:n().optional(),eventIds:C(l()).optional(),eventCount:n().int().nonnegative().optional(),holes:C(x({startMs:n(),endMs:n()})).optional(),thumbnailMint:l().optional(),thumbnailUnavailable:x({reason:S([`sleeping`,`camera-refused`,`no-keyframe`,`unsupported`])}).optional(),catalogAsOf:n().optional(),nativeTypes:C(l()).optional(),behaviours:C(l()).optional(),streams:x({sub:x({id:l(),bytes:n().optional()}).optional(),main:x({id:l(),bytes:n().optional()}).optional()}).optional(),supportSub:y().optional(),playable:y().optional(),unplayableReason:l().optional(),inProgress:y().optional()}),OQ=x({playbackUrl:l(),format:S([`hls`,`mp4`]).optional(),served:P.optional(),playbackEndpoints:C(l()).optional(),token:l().optional()}),kQ=S([`authorised`]),mAe=50*1024*1024,hAe=500*1024*1024,AQ=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative(),served:P,durationMs:n().positive().optional()}),jQ=x({ticket:ri,contentType:l(),name:l(),served:P,durationMs:n().positive().optional()}),MQ=S([`opus`,`pcmu`,`none`]),NQ=S([`not-requested`,`unsupported-ask`]),PQ=x({url:l().min(1),expiresAtMs:n(),transport:p(`forward-only`),served:P,servedAudio:MQ,audioReason:NQ.optional()}),FQ=[.25,.5,1,1.5,2,4,8],IQ=[.25,.5,1,1.5,2,4],LQ=[.25,.5,1],RQ=x({transport:S([`stream`,`file`]),seek:S([`forward`,`free`]),stepBack:y(),scrub:y(),rates:C(n().positive()).min(1).readonly()}),zQ=x({state:S([`ok`,`sleeping`,`unreachable`,`no-storage`,`index-empty`]),reason:l().optional(),catalogAsOf:n().optional()}),BQ=x({source:l(),label:l(),addonId:l().optional(),availability:zQ}),VQ={name:`videoclips`,scope:`device`,mode:`collection`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`widget`,widgetId:`host/clips-browser`,tab:`recording`,topTab:!0,label:`Clips`,order:100}},methods:{listClips:A(x({deviceId:n(),since:n(),until:n(),limit:n().int().positive().optional(),provider:l().min(1)}),C(DQ).readonly(),{kind:`query`,auth:`protected`}),listSources:A(x({deviceId:n()}),C(BQ).readonly(),{kind:`query`,auth:`protected`}),getClipPlayback:A(x({deviceId:n(),clipId:l(),profile:P.optional()}),OQ,{kind:`query`,auth:`protected`}),readClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:kQ.optional()}),AQ,{kind:`query`,auth:`protected`}),offerClipBytes:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),maxBytes:n().int().positive().optional(),wake:kQ.optional()}),jQ,{kind:`query`,auth:`protected`}),dialClipStream:j(x({deviceId:n(),clipId:l().min(1),provider:l().min(1),profile:P.optional(),audio:MQ.optional(),wake:kQ.optional()}),PQ,{kind:`query`,auth:`protected`}),getPlaybackOptions:j(x({deviceId:n(),provider:l().min(1)}),RQ,{kind:`query`,auth:`protected`})},vocabulary:{noun:F(`Video clips`,`Clip video`),order:3330}},gAe={stream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:IQ},realtimeStream:{transport:`stream`,seek:`forward`,stepBack:!1,scrub:!1,rates:LQ},file:{transport:`file`,seek:`free`,stepBack:!0,scrub:!0,rates:FQ}},HQ=n().min(.25).max(32),UQ=x({fromSec:n().nonnegative(),toSec:n().nonnegative()}).refine(e=>e.toSec>e.fromSec,{message:`dense range must have toSec > fromSec`}),_Ae=200,WQ=x({everyMs:n().int().positive(),ranges:C(UQ).min(1).max(200)}),GQ=x({everyMs:n().int().positive(),outputFps:n().int().min(1).max(60).optional(),dense:WQ.optional()}).superRefine((e,t)=>{e.dense!==void 0&&e.dense.everyMs>=e.everyMs&&t.addIssue({code:le.custom,message:`dense.everyMs must be strictly smaller than the base everyMs`,path:[`dense`,`everyMs`]})}),KQ=x({speed:HQ.optional(),timelapse:GQ.optional(),includeAudio:y(),maxLifeMs:n().int().positive(),deleteAfterDownload:y(),title:l().max(200).optional(),notifyTargetIds:C(l().min(1)).max(20).optional()}).superRefine((e,t)=>{e.speed!==void 0&&e.timelapse!==void 0&&t.addIssue({code:le.custom,message:`speed and timelapse are mutually exclusive`,path:[`timelapse`]})}),qQ=S([`queued`,`rendering`,`ready`,`failed`,`expired`,`deleted`]),JQ=x({kind:p(`footage`),deviceId:n(),profiles:C(l()).min(1),fromMs:n(),toMs:n()}),YQ=x({kind:p(`clip`),deviceId:n(),provider:l().min(1),source:l().min(1),sourceLabel:l().min(1),clipId:l().min(1),catalogWindow:x({sinceMs:n(),untilMs:n()}),profile:S([`high`,`mid`,`low`]),wake:kQ.optional()}),XQ=i(`kind`,[JQ,YQ]),ZQ=x({id:l(),deviceId:n(),profile:l(),fromMs:n(),toMs:n(),subject:XQ.optional(),options:KQ,state:qQ,progressPct:n().nullable(),fileBytes:n().nullable(),expiresAt:n(),deleteAfterDownload:y(),downloadedAt:n().nullable(),createdAt:n(),createdBy:l(),error:l().nullable()}),QQ=S([`catalog-miss`,`catalog-unreachable`,`no-file-for-window`,`clip-in-progress`,`unsupported-option`,`sleeping`,`camera-refused`,`fetch-failed`,`too-large-to-transfer`,`wake-expired`,`wake-timeout`]);function vAe(e,t){return t.length>0?`${e}: ${t}`:e}function yAe(e){if(e===null)return null;let t=e.split(`:`,1)[0]??``,n=QQ.safeParse(t.trim());return n.success?n.data:null}var $Q=x({url:l(),endpoints:C(l())}),bAe=50*1024*1024,e$=x({base64:l(),contentType:l(),name:l(),bytes:n().int().nonnegative()});function t$(e){return e.profiles!==void 0&&e.profiles.length>0?[...e.profiles]:typeof e.profile==`string`&&e.profile.length>0?[e.profile]:[]}var xAe=x({deviceId:n(),profile:l().optional(),profiles:C(l()).min(1).optional(),fromMs:n().optional(),toMs:n().optional(),subject:XQ.optional(),options:KQ}).superRefine((e,t)=>{if(e.subject?.kind===`clip`){e.subject.deviceId!==e.deviceId&&t.addIssue({code:le.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:le.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:le.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:le.custom,message:`a footage export needs fromMs and toMs`,path:[`fromMs`]}),(e.subject?.kind===`footage`?[...e.subject.profiles]:t$(e)).length<1&&t.addIssue({code:le.custom,message:`pass profiles[] (min 1) or legacy profile`,path:[`profiles`]})});function SAe(e){if(e.subject!==void 0)return e.subject;let t=t$(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 CAe(e){return e.subject===void 0?{kind:`footage`,deviceId:e.deviceId,profiles:[e.profile],fromMs:e.fromMs,toMs:e.toMs}:e.subject}var n$={name:`recording-export`,scope:`system`,mode:`singleton`,methods:{createExport:A(xAe,ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),listExports:A(x({deviceId:n().optional()}),C(ZQ),{role:`viewer`,kind:`query`,auth:`protected`}),getExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`query`,auth:`protected`}),cancelExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),deleteExport:A(x({exportId:l()}),ZQ,{role:`viewer`,kind:`mutation`,auth:`protected`}),getDownloadUrl:A(x({exportId:l()}),$Q,{role:`viewer`,kind:`query`,auth:`protected`}),readExportBytes:A(x({exportId:l()}),e$,{kind:`query`,auth:`protected`})},vocabulary:{notOperatorFacing:`recording exports — requested from the timeline, not an automation step`}},r$=S([`continuous`,`motion`,`person`,`vehicle`,`animal`,`lineCrossing`,`intrusion`,`loitering`,`alarmInput`]),i$=x({trigger:r$,day:n().int().min(0).max(6).meta(N(`none`)),startMinute:n().int().min(0).max(1439).meta(N(`none`)),endMinute:n().int().min(1).max(1440).meta(N(`none`))}),a$=x({id:l(),label:l().optional(),status:S([`ok`,`unformatted`,`error`,`offline`,`unknown`]),capacityMb:n().nullable(),freeMb:n().nullable(),writable:y().optional()}),o$=i(`kind`,[x({kind:p(`present`),volumes:C(a$)}),x({kind:p(`absent`),reason:l()}),x({kind:p(`unknown`),reason:l()})]),s$=x({id:l(),enabled:y(),isVideo:y(),codec:l().nullable(),resolution:l().nullable(),overwriteWhenFull:y().nullable()}),c$=x({storage:o$,tracks:C(s$),primaryTrackId:l().nullable(),enabled:y().nullable(),overwriteWhenFull:y().nullable(),preRecordSec:n().nullable().meta(N(`duration`)),postRecordSec:n().nullable().meta(N(`duration`)),segmentMinutes:n().nullable().meta(N(`none`)),windows:C(i$),unreadableWindows:n().meta(N(`count`)),recordingToNowhere:y(),lastFetchedAt:n()}),l$=x({min:n(),max:n(),step:n()}),u$=x({values:C(n()).min(1),sentinel:x({value:n(),meaning:S([`no-limit`,`disabled`])}).optional()}),d$=x({readable:y(),writable:y(),reason:l().optional()}),f$=x({support:d$,granularityMinutes:n(),triggers:C(r$),supportsOverlappingTriggers:y()}),p$=x({enabled:d$,overwriteWhenFull:d$,preRecordSec:d$,preRecordSecRange:l$.optional(),preRecordSecAllowed:u$.optional(),postRecordSec:d$,postRecordSecRange:l$.optional(),postRecordSecAllowed:u$.optional(),segmentMinutes:d$,segmentMinutesRange:l$.optional(),segmentMinutesAllowed:u$.optional(),schedule:f$}),m$=x({enabled:y().optional(),overwriteWhenFull:y().optional(),preRecordSec:n().optional(),postRecordSec:n().optional(),segmentMinutes:n().optional(),windows:C(i$).optional()}),h$={name:`recording-onboard`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],deviceConfig:{ui:{kind:`derived-form`,builderId:`recording-onboard`,tab:`recording`}},methods:{getOptions:A(x({deviceId:n()}),p$),setSettings:A(x({deviceId:n(),settings:m$}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`recordingOnboard.on`,label:F(`On-camera recording on`,`Registrazione a bordo attiva`),phrase:F(`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:F(`On-camera recording off`,`Registrazione a bordo spenta`),phrase:F(`Turn off recording to the card of {device}`,`Disattiva la registrazione sulla scheda di {device}`),icon:`hard-drive`,args:{settings:{enabled:!1}}}]})},status:{schema:c$,kind:`poll`},runtimeState:c$,durability:`restored`,history:`none`,volatileStateFields:[`lastFetchedAt`],vocabulary:{noun:F(`On-camera recording`,`Registrazione a bordo`),order:3260,state:[{kind:`boolean`,field:`recordingToNowhere`,label:F(`Recording to nowhere`,`Registra nel vuoto`),whenTrue:F(`When {device} is recording with no card to write to`,`Quando {device} registra senza una scheda su cui scrivere`),whenFalse:F(`When {device} has a card to record to again`,`Quando {device} ha di nuovo una scheda su cui registrare`),icon:`hard-drive`}]}},g$=x({active:y(),reason:l(),lastChangedAt:n()}),_$=g$.extend({lastFetchedAt:n()}),v$={name:`recording-signal`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Camera],methods:{getStatus:A(x({deviceId:n()}),g$)},status:{schema:g$,kind:`push`,empty:{active:!1,reason:`unknown`,lastChangedAt:0}},runtimeState:_$,durability:`session`,history:`none`,vocabulary:{noun:F(`Recording signal`,`Segnale di registrazione`),order:3270,state:[{kind:`boolean`,field:`active`,label:F(`Recording`,`In registrazione`),whenTrue:F(`When {device} starts recording`,`Quando {device} inizia a registrare`),whenFalse:F(`When {device} stops recording`,`Quando {device} smette di registrare`),icon:`circle-dot`}]}},y$=x({kind:p(`cap`),deviceId:n().int().nonnegative(),cap:l().min(1),method:l().min(1),args:m(l(),w()).optional(),argUnits:m(l(),l().min(1)).optional()}),b$=x({action:y$}),x$=x({key:l().refine(CE,{message:`a lowercase slug`}),name:l().min(1).max(60)}),wAe=200,TAe=100;function EAe(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=IE(a);e!==null&&s(e,`payload`)}for(let t of FE(a))bE(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 S$=x({index:n().int().nonnegative(),id:l().nullable(),name:l().nullable(),reason:l()}),C$=x({layoutTemplateId:l().min(1).nullable(),defaultTransmitterId:n().int().nonnegative().nullable().default(null),bindings:m(l(),b$),customButtons:C(x$).max(100),sources:C(NE).max(200).default([]),stepDelayMs:n().int().min(100).max(PE).default(500),refusedSources:C(S$).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)bE(e)?t.addIssue({code:`custom`,message:`"${e}" is a layout widget, not a command: it cannot be bound`,path:[`bindings`,e]}):EE(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=TE(e);n!==null&&!r.has(n)&&t.addIssue({code:`custom`,message:`${e} is bound but has no entry in customButtons`,path:[`bindings`,e]})}EAe(e,t)}),DAe=se({sources:C(w())}),OAe=x({id:l(),name:l()}).partial();function kAe(e){let t=DAe.safeParse(e);if(!t.success)return w$(C$.safeParse(e));let n=[],r=[];t.data.sources.forEach((e,t)=>{let i=NE.safeParse(e),a=i.success&&i.data.kind===`ir`?IE(i.data):null;if(i.success&&a===null){n.push(e);return}let o=OAe.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=w$(C$.safeParse({...t.data,sources:n}));return!i.success||r.length===0?i:{success:!0,data:{...i.data,refusedSources:r}}}function w$(e){return e.success?{success:!0,data:e.data}:{success:!1,issues:e.error.issues.length}}var AAe={layoutTemplateId:null,defaultTransmitterId:null,bindings:{},customButtons:[],sources:[],stepDelayMs:500},jAe=x({power:x({state:S([`on`,`off`]),at:n()}).nullable(),muted:x({value:y(),at:n()}).nullable(),source:x({name:l(),at:n()}).nullable().default(null)}),MAe={power:null,muted:null,source:null},NAe=24,PAe=50,T$=[`rect`,`rounded`,`round`,`pill`],E$=S(T$),D$=[`neutral`,`accent`,`danger`,`red`,`green`,`yellow`,`blue`],O$=S(D$),k$=[`none`,`panel`,`divider`,`dpad`,`rocker-v`,`rocker-h`,`keypad`],A$=S(k$),j$=x({id:l().min(1).max(40),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),role:DE,shape:E$.optional(),tone:O$.optional(),showLegend:y().optional(),groupId:l().min(1).max(40).optional()}),M$=x({id:l().min(1).max(40),componentId:l().min(1).max(80),frame:A$,row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),title:l().min(1).max(40).optional(),size:S([`compact`,`normal`]).optional(),hideTitle:y().optional()});function N$(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 P$(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 FAe(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&&N$(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`]),P$(n,e)||i(`button "${e.id}" lies outside its group "${n.id}"`,[`buttons`,t]);return}let a=n.find(t=>N$(t,e));a!==void 0&&i(`button "${e.id}" lies inside group "${a.id}" but is not a member`,[`buttons`,t])})}var F$=x({columns:n().int().min(1).max(24),rows:n().int().min(1).max(24),buttons:C(j$).max(200),groups:C(M$).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)}}),FAe(e,t)}),IAe=50,I$=x({role:DE,label:l().optional(),custom:y()}),L$=x({layoutTemplateId:l().nullable(),commands:C(I$),sources:C(NE)}),R$=[`no-remote`,`unbound-role`,`action-failed`,`unknown-source`,`unbound-step`,`undeclared-channel`,`press-timeout`,`no-transmitter`],z$=S(R$),B$=i(`status`,[x({status:p(`sent`),sends:n().int().min(1)}),x({status:p(`skipped`),reason:p(`already-in-state`)}),x({status:p(`refused`),reason:z$,detail:l().optional(),step:x({index:n().int().min(1),role:l()}).optional()})]),V$=[`play`,`pause`,`stop`,`next`,`previous`,`setMute`,`selectSource`,`playMedia`,`turnOn`,`turnOff`,`volumeUp`,`volumeDown`,`channelUp`,`channelDown`],H$=S(V$),U$=i(`status`,[...B$.options,x({status:p(`not-routed`)})]),W$=[`unknown-template`,`not-a-media-player`],G$=i(`status`,[x({status:p(`saved`)}),x({status:p(`refused`),reason:S(W$),detail:l()})]),K$=x({deviceId:n().int().nonnegative()}),LAe={version:1,targets:[{id:`remote`,cardinality:`config`,vocabulary:{cap:`remote`},deviceTypes:[E.MediaPlayer],apply:`add`,readMethod:`getConfig`,writeMethod:`setConfig`}]},q$={name:`remote`,scope:`system`,mode:`singleton`,methods:{getConfig:A(K$,C$,{auth:`admin`}),setConfig:A(K$.extend({config:C$}),G$,{kind:`mutation`,auth:`admin`}),listCommands:A(K$,L$,{auth:`protected`}),sendCommand:A(K$.extend({role:DE,repeat:n().int().min(1).max(50).default(1)}),B$,{kind:`mutation`,auth:`protected`}),getAssumedStatus:A(K$,HE.nullable(),{auth:`protected`}),sendMediaCommand:A(K$.extend({command:H$,muted:y().optional(),source:l().optional(),mediaType:l().optional(),mediaId:l().optional(),repeat:n().int().min(1).max(50).default(1)}),U$,{kind:`mutation`,auth:`protected`})},customize:LAe,vocabulary:{notOperatorFacing:`the per-device remote setup — authored in the Customize remote editor, sent through the remote UI`}},J$=[`power`,`navigation`,`volume`,`numbers`,`media`,`colour`,`apps`,`layout`],Y$=S(J$),RAe=40,zAe=/^[a-z0-9][a-z0-9_.-]*:[a-z0-9][a-z0-9_-]*$/,X$=x({idSuffix:l().regex(/^[a-z0-9][a-z0-9_-]{0,19}$/,{message:`a short lowercase slug`}),row:n().int().min(0).max(24),col:n().int().min(0).max(24),rowSpan:n().int().min(1).max(24),colSpan:n().int().min(1).max(24),role:DE,icon:l().min(1).max(60).optional(),label:l().min(1).max(40).optional(),shape:E$.optional(),tone:O$.optional(),showLegend:y().optional()}),Z$=x({id:l().max(80).regex(zAe,{message:`<namespace>:<name>, lowercase`}),name:l().min(1).max(60),nameI18n:x({en:l().min(1).max(60),it:l().min(1).max(60)}).optional(),icon:l().min(1).max(60),category:Y$,size:x({rows:n().int().min(1).max(24),cols:n().int().min(1).max(24)}),group:x({frame:A$,title:l().min(1).max(40).optional()}).nullable(),buttons:C(X$).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&&N$(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`]})}),Q$={name:`remote-layout-components`,scope:`system`,mode:`collection`,methods:{listComponents:A(x({}),C(Z$),{auth:`protected`})},vocabulary:{notOperatorFacing:`the palette of the remote template editor — read-only data, never actuated`}},$$=x({deviceId:n().int().nonnegative(),resetToSource:y().optional()}),e1={name:`resync`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Container,E.Workload,E.WeatherStation],methods:{resync:A($$,lA,{kind:`mutation`,auth:`admin`,notOperatorFacing:`device adoption — re-aligning a device with its source is an onboarding step, not an automation action`})},vocabulary:{noun:F(`Re-sync`,`Risincronizzazione`),order:3245}},BAe=5,VAe=2,t1=3e4,n1=18e4,r1={startDwellMs:t1,stopDwellMs:n1,minSamples:2},i1={[E.MediaPlayer]:{startDwellMs:1e4,stopDwellMs:1e4,minSamples:1}};function a1(e){return e!==void 0&&i1[e]!==void 0}function o1(e){return e===void 0?r1:i1[e]??r1}var HAe={running:null,since:null,source:`native`,phase:null,lastFetchedAt:null},s1=S([`native`,`assigned`]),c1=x({running:y().nullable(),since:n().nullable().meta(N(`none`)),source:s1.meta({label:`Source`}),phase:l().nullable(),lastFetchedAt:n().nullable()}),l1=x({deviceId:n(),since:n().nullable(),phase:l().nullable()}),UAe=Object.values(E),u1=[E.Washer,E.Dryer,E.Dishwasher,E.Vacuum,E.LawnMower,E.MediaPlayer,E.WaterHeater,E.Humidifier,E.Fan,E.Climate,E.PetFeeder],WAe={version:1,overridable:[{path:`running`,by:`running`}],targets:[{id:`running`,cardinality:`scalar`,vocabulary:{cap:`running-state`,stateField:`running`},deviceTypes:u1,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:t1,defaultStopDwellMs:n1,deviceTypeDefaults:i1,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}]},d1={name:`running-state`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:UAe,methods:{},events:{onStarted:{data:l1,trigger:{category:T.RunningStarted,label:F(`Started running`,`Ha iniziato a funzionare`),phrase:F(`When {device} starts running`,`Quando {device} inizia a funzionare`),icon:`play`}},onFinished:{data:l1,trigger:{category:T.RunningFinished,label:F(`Finished`,`Ha finito`),phrase:F(`When {device} finishes`,`Quando {device} finisce`),icon:`square`}}},status:{schema:c1,kind:`push`},runtimeState:c1,durability:`restored`,history:{fields:{running:{kind:`boolean`}}},volatileStateFields:[`lastFetchedAt`],customize:WAe,vocabulary:{noun:F(`Running`,`In funzione`),order:2120,state:[{kind:`boolean`,field:`running`,label:F(`Running`,`In funzione`),whenTrue:F(`When {device} starts`,`Quando {device} inizia`),whenFalse:F(`When {device} finishes`,`Quando {device} finisce`),icon:`play`}],overrides:{byType:{[E.Washer]:{state:{running:{whenTrue:F(`When the washing machine starts`,`Quando la lavatrice inizia`),whenFalse:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}},events:{onStarted:{phrase:F(`When the washing machine starts`,`Quando la lavatrice inizia`)},onFinished:{phrase:F(`When the washing machine has finished`,`Quando la lavatrice ha finito`)}}},[E.Dryer]:{state:{running:{whenTrue:F(`When the dryer starts`,`Quando l'asciugatrice inizia`),whenFalse:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}},events:{onStarted:{phrase:F(`When the dryer starts`,`Quando l'asciugatrice inizia`)},onFinished:{phrase:F(`When the dryer has finished`,`Quando l'asciugatrice ha finito`)}}},[E.Dishwasher]:{state:{running:{whenTrue:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`),whenFalse:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}},events:{onStarted:{phrase:F(`When the dishwasher starts`,`Quando la lavastoviglie inizia`)},onFinished:{phrase:F(`When the dishwasher has finished`,`Quando la lavastoviglie ha finito`)}}}}}}},f1=l(),GAe=[`day`,`ir`,`night`,`dawn`,`dusk`],p1=S([`skip`,`judge-anyway`]),KAe=`__diverged__`,m1=S([`matched`,`diverged`,`unknown`]),h1=S([`no-reference-for-condition`,`view-shifted`,`no-vision-profile`,`encoder-model-changed`,`no-snapshot`]),g1=x({embedding:C(n()),modelId:l(),condition:f1,capturedAt:n(),thumbnailMediaId:n().int().optional(),anchorEmbedding:C(n()).optional()}),_1=x({id:l(),label:l(),references:C(g1),textPrompts:C(l()).optional(),referenceCount:n(),currentlyMatched:y()}),v1=i(`mode`,[x({mode:p(`similarity`),threshold:n().min(0).max(1),hysteresisCount:n().int().positive()}),x({mode:p(`llm`),prompt:l(),profileId:l().optional(),hysteresisCount:n().int().positive()})]),qAe=60,JAe=120,YAe=60,y1=.85,b1=`skip`,x1=8e3,XAe=448,ZAe=!0,S1=x({enabled:y().default(!1),prompt:l().min(1).max(1e3),profileId:l().optional(),timeoutMs:n().int().min(1e3).max(2e4).default(x1),maxImagePx:n().int().min(64).max(2048).default(448),onTimeout:S([`flip`,`hold`]).default(`hold`)}),C1=x({id:l(),label:l(),roi:TV,enabled:y(),triggerMode:S([`periodic`,`on-motion`,`both`]),checkIntervalSec:n().optional(),check:v1,states:C(_1),currentStateId:l().nullable(),lastCheckedAt:n().nullable(),lastConfidence:n().nullable(),currentCondition:f1.nullable(),availability:S([`ok`,`unavailable`]),unavailableReason:l().nullable(),baselineStateId:l().nullable(),emit:S([`latched`,`live`]).default(`latched`),verdict:m1,latched:y(),armedAt:n(),divergedAt:n().nullable(),restoredAt:n().nullable(),quietSeconds:n().int().min(0).max(3600).default(60),minObservationSpacingSec:n().int().min(0).max(3600).default(120),confirm:S1.optional(),anchorThreshold:n().min(0).max(1).default(y1),autoRestore:y().default(!1),onUncoveredCondition:p1.default(b1),suspendedCondition:f1.nullable().default(null),unavailable:h1.nullable(),coveredConditions:C(f1)}),w1=x({monitors:C(C1),lastFetchedAt:n()}),T1=x({deviceId:n(),status:w1.nullable()}),E1={name:`scene-monitor`,role:{feature:`scenes`},scope:`device`,mode:`singleton`,kind:`wrapper`,defaultActive:!0,deviceTypes:[E.Camera],methods:{listScenes:A(x({deviceId:n()}),w1),listScenesBatch:A(x({deviceIds:C(n()).min(1).max(200)}),C(T1).readonly()),createScene:A(x({deviceId:n(),label:l(),roi:TV,check:v1,triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional()}),C1,{kind:`mutation`,auth:`admin`}),updateScene:A(x({deviceId:n(),monitorId:l(),patch:x({label:l().optional(),roi:TV.optional(),enabled:y().optional(),triggerMode:S([`periodic`,`on-motion`,`both`]).optional(),checkIntervalSec:n().optional(),check:v1.optional(),emit:S([`latched`,`live`]).optional(),quietSeconds:n().int().min(0).max(3600).optional(),minObservationSpacingSec:n().int().min(0).max(3600).optional(),anchorThreshold:n().min(0).max(1).optional(),autoRestore:y().optional(),onUncoveredCondition:p1.optional(),confirm:S1.nullable().optional()})}),v(),{kind:`mutation`,auth:`admin`}),deleteScene:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`}),captureReference:A(x({deviceId:n(),monitorId:l(),stateId:l().optional(),label:l().optional(),condition:f1.optional()}),x({stateId:l(),referenceCount:n()}),{kind:`mutation`,auth:`admin`}),deleteReference:A(x({deviceId:n(),monitorId:l(),stateId:l(),index:n()}),v(),{kind:`mutation`,auth:`admin`}),recheckNow:A(x({deviceId:n(),monitorId:l()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`sceneMonitor.recheck`,label:F(`Re-check a scene`,`Ricontrolla una scena`),phrase:F(`Re-check {monitorId} on {device} now`,`Ricontrolla subito {monitorId} su {device}`),icon:`scan-search`,openArgs:[{key:`monitorId`,label:F(`Scene`,`Scena`),offer:{kind:`dynamic`,from:`status`,field:`monitors`,valueKey:`id`,labelKey:`label`}}]}]}),resetScene:A(x({deviceId:n(),monitorId:l(),recapture:y().optional()}),v(),{kind:`mutation`,auth:`admin`})},status:{schema:w1,kind:`push`},runtimeState:w1,durability:`session`,history:`none`,vocabulary:{noun:F(`Scene watch`,`Controllo della scena`),order:3280,extraEvents:[{category:T.EnrichmentSceneStateChanged,label:F(`Scene changed`,`Scena cambiata`),phrase:F(`When a watched scene on {device} changes`,`Quando cambia una scena controllata su {device}`),icon:`scan-search`}]}},D1=x({schedulerId:l().min(1)}),O1={name:`schedulers`,scope:`system`,mode:`singleton`,methods:{list:A(x({}),C(Pv),{auth:`admin`}),get:A(D1,x({scheduler:Pv.nullable()}),{auth:`admin`}),create:A(x({scheduler:Nv}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),update:A(x({schedulerId:l().min(1),scheduler:Nv}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),delete:A(D1,v(),{kind:`mutation`,auth:`admin`}),setEnabled:A(x({schedulerId:l().min(1),profileId:l().min(1).optional(),enabled:y()}),x({scheduler:Pv}),{kind:`mutation`,auth:`admin`}),preview:A(x({schedulerId:l().min(1),date:l().regex(Bv).optional()}),Hv,{auth:`admin`}),conflicts:A(x({scheduler:Nv,schedulerId:l().min(1).optional()}),x({conflicts:C(Uv)}),{auth:`admin`}),getStatus:A(x({}),C(Gv),{auth:`admin`}),getTraces:A(D1,x({traces:C(ny)}),{auth:`admin`})},vocabulary:{notOperatorFacing:`time schedulers — authored on their own page, not device actions`}},k1=x({isRunning:y(),lastRunAt:n(),lastRunSuccess:y().nullable(),lastError:l().nullable(),lastChangedAt:n()}),A1={name:`script-runner`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Script],methods:{run:A(x({deviceId:n().int().nonnegative(),variables:m(l(),w()).optional()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.run`,label:F(`Run script`,`Esegui lo script`),phrase:F(`Run {device}`,`Esegui {device}`),icon:`scroll-text`,hold:{effects:[{field:`isRunning`,value:!0}],holdMs:iY}}]}),stop:A(x({deviceId:n().int().nonnegative()}),v(),{kind:`mutation`,auth:`admin`,actions:[{id:`script.stop`,effect:{field:`isRunning`,value:!1},label:F(`Stop script`,`Ferma lo script`),phrase:F(`Stop {device}`,`Ferma {device}`),icon:`square`}]})},status:{schema:k1,kind:`push`},runtimeState:k1,durability:`session`,history:`none`,vocabulary:{noun:F(`Script`,`Script`),order:2090,state:[{kind:`boolean`,field:`isRunning`,label:F(`Running`,`In esecuzione`),whenTrue:F(`When {device} starts running`,`Quando {device} parte`),whenFalse:F(`When {device} finishes`,`Quando {device} termina`),icon:`scroll-text`}]}},j1=S([`workspace`,`baked`,`data-root`]),M1=S([`idle`,`checking`,`staging`,`pending-restart`,`awaiting-confirmation`]),N1=S([`in-sync`,`behind-patch`,`behind-series`,`ahead`,`unknown`]),P1=x({state:N1,seedVersion:l().nullable(),contractVersion:l().nullable(),contractSource:S([`registry`,`running`]).nullable(),message:l()}),F1=S([`docker`,`electron`,`native`,`contradictory`,`unknown`]),I1=x({fact:S([`dockerenv-file`,`proc-1-cgroup`,`platform`,`electron-app-version-env`]),mode:S([`observed`,`declared`]),holds:y(),detail:l()}),L1=x({kind:F1,evidence:C(I1),currentVersion:l().nullable()}),R1=x({fromVersion:l(),toVersion:l().nullable(),atMs:n(),reason:l()}),z1=x({version:l(),update:x({available:y(),downloaded:y(),version:l().nullable(),checking:y(),error:l().nullable()}),stateAtMs:n(),stale:y()}),B1=S([`not-electron`,`no-app-state`,`app-state-stale`,`not-downloaded`]),V1=x({accepted:y(),reason:B1.nullable()}),H1=x({runnerId:l(),addonIds:C(l()),reason:l()}),U1=x({checkedAtMs:n(),expected:n(),running:n(),failed:C(l()),refused:C(H1),missing:C(l()),pending:C(l()).optional(),planKnown:y()}),W1=x({packageName:l(),runningVersion:l().nullable(),nodeRuntimeVersion:l().nullable(),activeVersion:l().nullable(),installedVersion:l().nullable().optional(),restartRequired:y().optional(),previousVersion:l().nullable(),seedVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),bootMode:j1,updateState:M1,pendingVersion:l().nullable(),rolledBack:R1.nullable(),stateFileCorrupt:y(),lastCheckedAtMs:n().nullable(),imageContract:P1.optional(),wrapper:L1.optional(),runners:U1.optional(),desktopApp:z1.optional()}),G1=x({packageName:l(),runningVersion:l().nullable(),latestVersion:l().nullable(),updateAvailable:y(),checkedAtMs:n(),error:l().nullable(),pendingVersion:l().nullable().optional(),restartRequired:y().optional()}),K1=S([`staged`,`restart-scheduled`,`already-current`,`refused`,`failed`]),q1=x({addonId:l(),reason:l(),remedy:l()}),J1=x({accepted:y(),targetVersion:l().nullable(),restarting:y(),message:l(),outcome:K1.optional(),reason:l().nullable().optional(),error:l().nullable().optional(),blockers:C(q1).optional(),unmet:C(au).optional(),requiredAddonUpdates:C(ou).optional()}),Y1=x({heapMb:n().int().nullable(),rssBudgetMb:n().int().nullable()}),QAe=x({heapMb:n().int().min(512).max(65536).nullable(),rssBudgetMb:n().int().min(512).max(65536).nullable().optional()}),$Ae=Y1.extend({restartRequired:y()}),X1={name:`server-management`,scope:`system`,mode:`singleton`,methods:{getServerPackageStatus:A(v(),W1,{auth:`admin`}),checkServerUpdate:A(v(),G1,{kind:`mutation`,auth:`admin`}),applyServerUpdate:A(x({version:l().optional(),acknowledgeRefusals:y().optional()}),J1,{kind:`mutation`,auth:`admin`,timeoutMs:16*6e4}),installDesktopUpdate:A(v(),V1,{kind:`mutation`,auth:`admin`}),rollbackServerUpdate:A(v(),J1,{kind:`mutation`,auth:`admin`}),restartServer:A(v(),J1,{kind:`mutation`,auth:`admin`}),getLaunchOverrides:A(v(),Y1,{auth:`admin`}),setLaunchOverrides:A(QAe,$Ae,{kind:`mutation`,auth:`admin`})},mount:{kind:`server-provided`},vocabulary:{notOperatorFacing:M.CLUSTER}},Z1={Seconds:`seconds`,Plays:`plays`},Q1={Camera:`camera`,Fallback:`fallback`},$1=x({min:n().positive(),max:n().positive(),step:n().positive()}),e0=x({allowedSeconds:C(n().positive()).nullable(),rangeSeconds:$1.nullable(),defaultSeconds:n().positive(),allowedPlays:C(n().int().positive()).nullable().default(null),rangePlays:$1.nullable().default(null),defaultPlays:n().int().positive().nullable().default(null),unit:S([Z1.Seconds,Z1.Plays]),secondsPerPlay:n().positive().nullable(),source:S([Q1.Camera,Q1.Fallback]),fetchedAt:n()}),t0=x({active:y(),activeUntil:n().nullable(),durationSeconds:n().nullable(),plays:n().int().positive().nullable().default(null),activeUntilEstimated:y().default(!1),lastTriggeredAt:n()}),n0=x({deviceId:n().int().nonnegative(),durationSeconds:n().positive().optional(),plays:n().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`]}),r0=t0.extend({lastFetchedAt:n()}),i0={name:`siren`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Siren],methods:{getOptions:A(x({deviceId:n().int().nonnegative()}),e0,{kind:`query`,auth:`protected`}),getPlayChoices:A(x({deviceId:n().int().nonnegative()}),C(n().int().positive()),{kind:`query`,auth:`protected`}),trigger:A(n0,t0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.trigger`,label:F(`Sound the siren`,`Fai suonare la sirena`),phrase:F(`Sound {device}`,`Fai suonare {device}`),icon:`siren`,args:{}},{id:`siren.triggerPlays`,label:F(`Sound the siren N times`,`Fai suonare la sirena N volte`),phrase:F(`Sound {device} {plays} times`,`Fai suonare {device} {plays} volte`),icon:`siren`,openArgs:[{key:`plays`,label:F(`Plays`,`Riproduzioni`),offer:{kind:`dynamic`,from:`method`,method:`getPlayChoices`,valueKind:`number`}}]}]}),stop:A(x({deviceId:n().int().nonnegative()}),t0,{kind:`mutation`,auth:`protected`,actions:[{id:`siren.stop`,label:F(`Silence the siren`,`Zittisci la sirena`),phrase:F(`Silence {device}`,`Zittisci {device}`),icon:`siren`,effect:{field:`active`,value:!1},args:{}}]})},events:{onSirenChanged:{data:x({deviceId:n(),active:y(),activeUntil:n().nullable()}),notOperatorFacing:"the `active` state trigger phrases both edges of this change"}},status:{schema:t0,kind:`command-driven`},runtimeState:r0,durability:`session`,history:`none`,vocabulary:{noun:F(`Siren`,`Sirena`),order:1170,state:[{kind:`boolean`,field:`active`,label:F(`Siren sounding`,`Sirena in funzione`),whenTrue:F(`When {device} starts sounding`,`Quando {device} inizia a suonare`),whenFalse:F(`When {device} falls silent`,`Quando {device} smette di suonare`),icon:`siren`}]}},a0=x({detected:y(),lastChangedAt:n()}),o0={name:`smoke`,scope:`device`,deviceNative:!0,mode:`singleton`,deviceTypes:[E.Sensor],methods:{},status:{schema:a0,kind:`push`},runtimeState:a0,durability:`restored`,history:{fields:{detected:{kind:`boolean`}}},volatileStateFields:[`lastChangedAt`],vocabulary:{noun:F(`Smoke detector`,`Rilevatore di fumo`),order:5190,state:[{kind:`boolean`,field:`detected`,label:F(`Detected`,`Rilevato`),whenTrue:F(`When {device} detects smoke`,`Quando {device} rileva fumo`),whenFalse:F(`When smoke clears on {device}`,`Quando il fumo su {device} si dirada`),icon:`alarm-smoke`}]}},eje=3,s0=5*1024*1024,c0=`<!--camstack-images-->`,l0=x({ticket:ri,mime:l().min(1),name:l().min(1),contentId:l().min(1),placement:S([`inline`,`attachment`]),deviceId:n().int().nonnegative().optional()}),u0=0;function d0(e){return u0+=1,`camstack_${e}_${u0.toString(36)}_${Date.now().toString(36)}`}function tje(e){return/^[\x20-\x7E]*$/.test(e)?e:`=?UTF-8?B?${Buffer.from(e,`utf8`).toString(`base64`)}?=`}function f0(e){return(Array.isArray(e)?e:[e]).join(`, `)}function nje(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function p0(e,t){let n=e.replace(/[\r\n"]/g,``).trim();return n.length>0?n:t}function rje(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 ije(e){return`<img src="cid:${nje(e.contentId)}" alt="">`}function aje(e,t){return e.replaceAll(c0,t.map(ije).join(``))}function m0(e){let t=[`From: ${e.from}`,`To: ${f0(e.to)}`];return e.cc!==void 0&&e.cc.length>0&&t.push(`Cc: ${f0(e.cc)}`),e.bcc!==void 0&&e.bcc.length>0&&t.push(`Bcc: ${f0(e.bcc)}`),e.replyTo!==void 0&&e.replyTo.length>0&&t.push(`Reply-To: ${e.replyTo}`),t.push(`Subject: ${tje(e.subject)}`),t.push(`MIME-Version: 1.0`),t}function h0(e,t){return[`--${e}`,`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function g0(e,t){return[`--${e}`,`Content-Type: text/html; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,t]}function _0(e,t){let n=p0(t.mime,`image/jpeg`),r=p0(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: <${p0(t.contentId,`image`)}>`),a.push(``,rje(t.bytes)),a}function v0(e,t,n){let r=d0(`alt`);return[`--${e}`,`Content-Type: multipart/alternative; boundary="${r}"`,``,...h0(r,t),...g0(r,n),`--${r}--`]}function oje(e,t){let n=m0(e);if(t!==void 0){let r=d0(`alt`);return n.push(`Content-Type: multipart/alternative; boundary="${r}"`,``),n.push(...h0(r,e.text),...g0(r,t),`--${r}--`),n}return n.push(`Content-Type: text/plain; charset="UTF-8"`,`Content-Transfer-Encoding: 8bit`,``,e.text),n}function sje(e,t,n){let r=d0(`mix`),i=m0(e);i.push(`Content-Type: multipart/mixed; boundary="${r}"`,``),t===void 0?i.push(...h0(r,e.text)):i.push(...v0(r,e.text,t));for(let e of n)i.push(..._0(r,e));return i.push(`--${r}--`),i}function cje(e,t,n,r){let i=d0(`rel`),a=m0(e);a.push(`Content-Type: multipart/related; boundary="${i}"; type="multipart/alternative"`,``,...v0(i,e.text,t));for(let e of n)a.push(..._0(i,e));for(let e of r)a.push(..._0(i,e));return a.push(`--${i}--`),a}function y0(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?aje(e.html,n):void 0;return i!==void 0&&n.length>0?cje(e,i,n,r).join(`\r
|
|
1112
1112
|
`):r.length>0||n.length>0?sje(e,i,r.length>0?r:n).join(`\r
|
|
1113
1113
|
`):oje(e,i).join(`\r
|