diff --git a/custom_components/omni_pca/frontend/src/omni-panel-programs.ts b/custom_components/omni_pca/frontend/src/omni-panel-programs.ts
index 6b82bb6..b8cdee9 100644
--- a/custom_components/omni_pca/frontend/src/omni-panel-programs.ts
+++ b/custom_components/omni_pca/frontend/src/omni-panel-programs.ts
@@ -14,11 +14,14 @@ import { renderTokens } from "./token-renderer.js";
import {
COMMAND_OPTIONS,
CommandOption,
+ CondFamily,
DAY_BITS,
+ DecodedCondition,
DecodedEvent,
EventCategory,
FIXED_EVENTS,
Hass,
+ MISC_CONDITIONALS,
MONTH_NAMES,
NamedObject,
ObjectListResponse,
@@ -29,8 +32,11 @@ import {
ProgramFields,
ProgramListResponse,
ProgramRow,
+ SECURITY_MODE_NAMES,
commandOptionFor,
+ decodeCondition,
decodeEventId,
+ encodeCondition,
encodeEventId,
eventIdFromFields,
packEventIdIntoFields,
@@ -874,13 +880,7 @@ export class OmniPanelPrograms extends LitElement {
${this._renderTriggerSection(draft)}
${this._renderActionSection(draft)}
- ${draft.cond || draft.cond2 ? html`
-
- Inline conditions:
- this program carries up to two inline AND-IF conditions on
- the source record. They're preserved on save but editing
- condition fields is not yet supported.
-
` : ""}
+ ${this._renderConditionsSection(draft)}
@@ -1180,6 +1180,204 @@ export class OmniPanelPrograms extends LitElement {
`;
}
+ private _renderConditionsSection(draft: ProgramFields): TemplateResult {
+ return html`
+
+ Inline AND-IF conditions
+ ${this._renderConditionSlot(
+ "First condition", draft.cond ?? 0,
+ (v) => this._patchDraft({ cond: v }),
+ )}
+ ${this._renderConditionSlot(
+ "Second condition", draft.cond2 ?? 0,
+ (v) => this._patchDraft({ cond2: v }),
+ )}
+
+ `;
+ }
+
+ private _renderConditionSlot(
+ label: string, raw: number, onChange: (newCond: number) => void,
+ ): TemplateResult {
+ const decoded = decodeCondition(raw);
+ const setFamily = (family: CondFamily) => {
+ // Seed sensible defaults when switching family so the sub-fields
+ // immediately encode to a non-degenerate value.
+ const firstZone = this._objects?.zones?.[0]?.index ?? 1;
+ const firstUnit = this._objects?.units?.[0]?.index ?? 1;
+ const firstArea = this._objects?.areas?.[0]?.index ?? 1;
+ let next: DecodedCondition;
+ switch (family) {
+ case "none": next = { family: "none" }; break;
+ case "misc": next = { family: "misc", misc: 1 }; break; // NEVER
+ case "zone": next = { family: "zone", index: firstZone, active: false }; break;
+ case "unit": next = { family: "unit", index: firstUnit, active: true }; break;
+ case "time": next = { family: "time", index: 1, active: true }; break;
+ case "sec": next = { family: "sec", index: firstArea, mode: 0 }; break;
+ }
+ onChange(encodeCondition(next));
+ };
+ return html`
+
+
+ ${label}
+
+ setFamily((e.target as HTMLSelectElement).value as CondFamily)}>
+ (none)
+ Zone state
+ Unit state
+ Area in security mode
+ Time clock
+ Misc (light, AC power, …)
+
+
+ ${this._renderConditionSubfields(decoded, onChange)}
+
+ `;
+ }
+
+ private _renderConditionSubfields(
+ decoded: DecodedCondition, onChange: (newCond: number) => void,
+ ): TemplateResult {
+ if (decoded.family === "none") return html``;
+ if (decoded.family === "zone") {
+ const zones = this._bucketWithPreserve(
+ this._objects?.zones ?? null, "zone", decoded.index ?? 0,
+ );
+ return html`
+
+ Zone
+ {
+ const idx = parseInt((e.target as HTMLSelectElement).value, 10);
+ onChange(encodeCondition({ ...decoded, index: idx }));
+ }}>
+ ${zones.map((z) => html`
+
+ #${z.index} ${z.name}
+
+ `)}
+
+
+
+ Is
+ {
+ const active = (e.target as HTMLSelectElement).value === "1";
+ onChange(encodeCondition({ ...decoded, active }));
+ }}>
+ secure
+ not ready
+
+ `;
+ }
+ if (decoded.family === "unit") {
+ const units = this._bucketWithPreserve(
+ this._objects?.units ?? null, "unit", decoded.index ?? 0,
+ );
+ return html`
+
+ Unit
+ {
+ const idx = parseInt((e.target as HTMLSelectElement).value, 10);
+ onChange(encodeCondition({ ...decoded, index: idx }));
+ }}>
+ ${units.map((u) => html`
+
+ #${u.index} ${u.name}
+
+ `)}
+
+
+
+ Is
+ {
+ const active = (e.target as HTMLSelectElement).value === "1";
+ onChange(encodeCondition({ ...decoded, active }));
+ }}>
+ ON
+ OFF
+
+ `;
+ }
+ if (decoded.family === "sec") {
+ const areas = this._bucketWithPreserve(
+ this._objects?.areas ?? null, "area", decoded.index ?? 0,
+ );
+ return html`
+
+ Area
+ {
+ const idx = parseInt((e.target as HTMLSelectElement).value, 10);
+ onChange(encodeCondition({ ...decoded, index: idx }));
+ }}>
+ ${areas.map((a) => html`
+
+ #${a.index} ${a.name}
+
+ `)}
+
+
+
+ Mode
+ {
+ const mode = parseInt((e.target as HTMLSelectElement).value, 10);
+ onChange(encodeCondition({ ...decoded, mode }));
+ }}>
+ ${SECURITY_MODE_NAMES.map((m) => html`
+
+ ${m.label}
+
+ `)}
+
+ `;
+ }
+ if (decoded.family === "time") {
+ return html`
+
+ Time clock # (1..3)
+ {
+ const idx = parseInt((e.target as HTMLInputElement).value, 10);
+ if (Number.isFinite(idx)) {
+ onChange(encodeCondition({ ...decoded, index: idx }));
+ }
+ }}
+ />
+
+
+ Is
+ {
+ const active = (e.target as HTMLSelectElement).value === "1";
+ onChange(encodeCondition({ ...decoded, active }));
+ }}>
+ enabled
+ disabled
+
+ `;
+ }
+ // misc
+ return html`
+
+ Condition
+ {
+ const misc = parseInt((e.target as HTMLSelectElement).value, 10);
+ onChange(encodeCondition({ family: "misc", misc }));
+ }}>
+ ${MISC_CONDITIONALS.map((m) => html`
+
+ ${m.label}
+
+ `)}
+
+ `;
+ }
+
// -- styles -----------------------------------------------------------
static styles = css`
@@ -1515,6 +1713,17 @@ export class OmniPanelPrograms extends LitElement {
font-size: 0.82rem;
color: var(--secondary-text-color, #666);
}
+ .cond-slot {
+ padding: 8px 10px;
+ margin-top: 6px;
+ background: var(--secondary-background-color, #f5f5f5);
+ border-radius: 4px;
+ }
+ .cond-slot:first-of-type { margin-top: 0; }
+ .cond-family-label {
+ font-weight: 600;
+ color: var(--primary-text-color, #000);
+ }
`;
}
diff --git a/custom_components/omni_pca/frontend/src/types.ts b/custom_components/omni_pca/frontend/src/types.ts
index df922ef..2a76d76 100644
--- a/custom_components/omni_pca/frontend/src/types.ts
+++ b/custom_components/omni_pca/frontend/src/types.ts
@@ -280,6 +280,135 @@ export const MONTH_NAMES = [
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
];
+
+// --------------------------------------------------------------------------
+// Compact-form AND-IF condition encode/decode for the inline-conditions
+// editor (TIMED/EVENT/YEARLY cond + cond2 fields).
+//
+// Mirrors clsText.GetConditionalText (clsText.cs:2224-2274) and the
+// Python _emit_traditional_cond in program_renderer.py. Bit layout:
+//
+// family = (cond >> 8) & 0xFC
+// selector bit = (cond & 0x0200) — meaning depends on family
+//
+// family 0x00 OTHER — cond & 0x0F = enuMiscConditional (NONE=0,
+// NEVER=1, LIGHT=2, DARK=3, ...)
+// family 0x04 ZONE — low 8 bits = zone index; selector bit
+// 0=secure, 1=not ready
+// family 0x08 CTRL — low 9 bits = unit index; selector bit
+// 0=OFF, 1=ON
+// family 0x0C TIME — low 8 bits = time-clock index; selector bit
+// 0=disabled, 1=enabled
+// family >= 0x10 SEC — (cond >> 8) & 0x0F = area, (cond >> 12) & 0x07 = mode
+//
+// cond == 0 means "no condition" (NONE).
+// --------------------------------------------------------------------------
+
+
+export type CondFamily =
+ | "none" // cond = 0 — no inline condition
+ | "misc" // OTHER family (NEVER, LIGHT, DARK, PHONE_*, AC_POWER_*, …)
+ | "zone" // ZONE family — zone + secure/not-ready
+ | "unit" // CTRL family — unit + on/off
+ | "time" // TIME family — time-clock + enabled/disabled
+ | "sec"; // SEC family — area + security mode
+
+export interface DecodedCondition {
+ family: CondFamily;
+ /** misc-conditional index (0..15) — used when family == "misc". */
+ misc?: number;
+ /** Zone / unit / time-clock / area index — used by the named families. */
+ index?: number;
+ /** Selector bit: zone "not ready", unit "on", time-clock "enabled". */
+ active?: boolean;
+ /** SEC family security mode (0..7). */
+ mode?: number;
+}
+
+// MiscConditional enum (matches omni_pca.programs.MiscConditional).
+// Each entry: { value, label }. NONE renders as "always" and NEVER as
+// "never" — both common authoring patterns.
+export const MISC_CONDITIONALS: ReadonlyArray<{ value: number; label: string }> = [
+ { value: 0, label: "always" },
+ { value: 1, label: "never" },
+ { value: 2, label: "it is light outside" },
+ { value: 3, label: "it is dark outside" },
+ { value: 4, label: "phone line is dead" },
+ { value: 5, label: "phone is ringing" },
+ { value: 6, label: "phone is off hook" },
+ { value: 7, label: "phone is on hook" },
+ { value: 8, label: "AC power is off" },
+ { value: 9, label: "AC power is on" },
+ { value: 10, label: "battery is low" },
+ { value: 11, label: "battery is OK" },
+ { value: 12, label: "energy cost is low" },
+ { value: 13, label: "energy cost is mid" },
+ { value: 14, label: "energy cost is high" },
+ { value: 15, label: "energy cost is critical" },
+];
+
+// Security modes for the SEC family (matches enuSecurityMode order).
+export const SECURITY_MODE_NAMES: ReadonlyArray<{ value: number; label: string }> = [
+ { value: 0, label: "Off (disarmed)" },
+ { value: 1, label: "Day" },
+ { value: 2, label: "Night" },
+ { value: 3, label: "Away" },
+ { value: 4, label: "Vacation" },
+ { value: 5, label: "Day Instant" },
+ { value: 6, label: "Night Delayed" },
+];
+
+export function decodeCondition(cond: number): DecodedCondition {
+ if (cond === 0) return { family: "none" };
+ const family = (cond >> 8) & 0xFC;
+ const active = (cond & 0x0200) !== 0;
+ if (family === 0x00) {
+ return { family: "misc", misc: cond & 0x0F };
+ }
+ if (family === 0x04) {
+ return { family: "zone", index: cond & 0xFF, active };
+ }
+ if (family === 0x08) {
+ return { family: "unit", index: cond & 0x01FF, active };
+ }
+ if (family === 0x0C) {
+ return { family: "time", index: cond & 0xFF, active };
+ }
+ // SEC family (family >= 0x10): area in high nibble of upper byte,
+ // mode in top nibble.
+ return {
+ family: "sec",
+ index: (cond >> 8) & 0x0F,
+ mode: (cond >> 12) & 0x07,
+ };
+}
+
+export function encodeCondition(c: DecodedCondition): number {
+ switch (c.family) {
+ case "none":
+ return 0;
+ case "misc":
+ return (c.misc ?? 0) & 0x0F; // family 0x00, low nibble = misc
+ case "zone": {
+ const idx = (c.index ?? 0) & 0xFF;
+ return 0x0400 | (c.active ? 0x0200 : 0) | idx;
+ }
+ case "unit": {
+ const idx = (c.index ?? 0) & 0x01FF;
+ return 0x0800 | (c.active ? 0x0200 : 0) | idx;
+ }
+ case "time": {
+ const idx = (c.index ?? 0) & 0xFF;
+ return 0x0C00 | (c.active ? 0x0200 : 0) | idx;
+ }
+ case "sec": {
+ const area = (c.index ?? 1) & 0x0F;
+ const mode = (c.mode ?? 0) & 0x07;
+ return (mode << 12) | (area << 8);
+ }
+ }
+}
+
/** HA's hass object — minimal surface we use. */
export interface Hass {
connection: {
diff --git a/custom_components/omni_pca/www/panel.js b/custom_components/omni_pca/www/panel.js
index 5a1d8e3..c93d846 100644
--- a/custom_components/omni_pca/www/panel.js
+++ b/custom_components/omni_pca/www/panel.js
@@ -1,7 +1,7 @@
// omni_pca side panel — generated by frontend/build.mjs. Edit src/, not this file.
-var Ie=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var h=(n,t,e,r)=>{for(var i=r>1?void 0:r?ze(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(t,e,i):o(i))||i);return r&&i&&Ie(t,e,i),i};var H=globalThis,j=H.ShadowRoot&&(H.ShadyCSS===void 0||H.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),he=new WeakMap,F=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(j&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=he.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&he.set(e,t))}return t}toString(){return this.cssText}},ue=n=>new F(typeof n=="string"?n:n+"",void 0,V),W=(n,...t)=>{let e=n.length===1?n[0]:t.reduce((r,i,s)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+n[s+1],n[0]);return new F(e,n,V)},ge=(n,t)=>{if(j)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=H.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,n.appendChild(r)}},G=j?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return ue(e)})(n):n;var{is:Ne,defineProperty:Le,getOwnPropertyDescriptor:Oe,getOwnPropertyNames:He,getOwnPropertySymbols:je,getPrototypeOf:Ue}=Object,U=globalThis,fe=U.trustedTypes,Be=fe?fe.emptyScript:"",Ye=U.reactiveElementPolyfillSupport,R=(n,t)=>n,P={toAttribute(n,t){switch(t){case Boolean:n=n?Be:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},B=(n,t)=>!Ne(n,t),me={attribute:!0,type:String,converter:P,reflect:!1,useDefault:!1,hasChanged:B};Symbol.metadata??=Symbol("metadata"),U.litPropertyMetadata??=new WeakMap;var v=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=me){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&Le(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){let{get:i,set:s}=Oe(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){let c=i?.call(this);s?.call(this,o),this.requestUpdate(t,c,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??me}static _$Ei(){if(this.hasOwnProperty(R("elementProperties")))return;let t=Ue(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(R("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(R("properties"))){let e=this.properties,r=[...He(e),...je(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let i of r)e.unshift(G(i))}else t!==void 0&&e.push(G(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ge(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let s=(r.converter?.toAttribute!==void 0?r.converter:P).toAttribute(e,r.type);this._$Em=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(t,e){let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let s=r.getPropertyOptions(i),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:P;this._$Em=i;let c=o.fromAttribute(e,s.type);this[i]=c??this._$Ej?.get(i)??c,this._$Em=null}}requestUpdate(t,e,r,i=!1,s){if(t!==void 0){let o=this.constructor;if(i===!1&&(s=this[t]),r??=o.getPropertyOptions(t),!((r.hasChanged??B)(s,e)||r.useDefault&&r.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:i,wrapped:s},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),s!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,s]of r){let{wrapped:o}=s,c=this[i];o!==!0||this._$AL.has(i)||c===void 0||this.C(i,void 0,s,c)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[R("elementProperties")]=new Map,v[R("finalized")]=new Map,Ye?.({ReactiveElement:v}),(U.reactiveElementVersions??=[]).push("2.1.2");var te=globalThis,_e=n=>n,Y=te.trustedTypes,ve=Y?Y.createPolicy("lit-html",{createHTML:n=>n}):void 0,ke="$lit$",y=`lit$${Math.random().toFixed(9).slice(2)}$`,we="?"+y,qe=`<${we}>`,k=document,M=()=>k.createComment(""),I=n=>n===null||typeof n!="object"&&typeof n!="function",re=Array.isArray,Ve=n=>re(n)||typeof n?.[Symbol.iterator]=="function",Z=`[
-\f\r]`,D=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,be=/-->/g,ye=/>/g,x=RegExp(`>|${Z}(?:([^\\s"'>=/]+)(${Z}*=${Z}*(?:[^
-\f\r"'\`<>=]|("|')|))|$)`,"g"),$e=/'/g,xe=/"/g,Se=/^(?:script|style|textarea|title)$/i,ie=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),a=ie(1),ot=ie(2),at=ie(3),w=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Ee=new WeakMap,E=k.createTreeWalker(k,129);function Ae(n,t){if(!re(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ve!==void 0?ve.createHTML(t):t}var We=(n,t)=>{let e=n.length-1,r=[],i,s=t===2?"":t===3?"":"",o=D;for(let c=0;c"?(o=i??D,p=-1):m[1]===void 0?p=-2:(p=o.lastIndex-m[2].length,g=m[1],o=m[3]===void 0?x:m[3]==='"'?xe:$e):o===xe||o===$e?o=x:o===be||o===ye?o=D:(o=x,i=void 0);let b=o===x&&n[c+1].startsWith("/>")?" ":"";s+=o===D?l+qe:p>=0?(r.push(g),l.slice(0,p)+ke+l.slice(p)+y+b):l+y+(p===-2?c:b)}return[Ae(n,s+(n[e]||">")+(t===2?" ":t===3?"":"")),r]},z=class n{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let s=0,o=0,c=t.length-1,l=this.parts,[g,m]=We(t,e);if(this.el=n.createElement(g,r),E.currentNode=this.el.content,e===2||e===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=E.nextNode())!==null&&l.length0){i.textContent=Y?Y.emptyScript:"";for(let b=0;b<_;b++)i.append(p[b],M()),E.nextNode(),l.push({type:2,index:++s});i.append(p[_],M())}}}else if(i.nodeType===8)if(i.data===we)l.push({type:2,index:s});else{let p=-1;for(;(p=i.data.indexOf(y,p+1))!==-1;)l.push({type:7,index:s}),p+=y.length-1}s++}}static createElement(t,e){let r=k.createElement("template");return r.innerHTML=t,r}};function S(n,t,e=n,r){if(t===w)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl,s=I(t)?void 0:t._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(n),i._$AT(n,e,r)),r!==void 0?(e._$Co??=[])[r]=i:e._$Cl=i),i!==void 0&&(t=S(n,i._$AS(n,t.values),i,r)),t}var K=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??k).importNode(e,!0);E.currentNode=i;let s=E.nextNode(),o=0,c=0,l=r[0];for(;l!==void 0;){if(o===l.index){let g;l.type===2?g=new N(s,s.nextSibling,this,t):l.type===1?g=new l.ctor(s,l.name,l.strings,this,t):l.type===6&&(g=new ee(s,this,t)),this._$AV.push(g),l=r[++c]}o!==l?.index&&(s=E.nextNode(),o++)}return E.currentNode=k,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},N=class n{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=S(this,t,e),I(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==w&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ve(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==f&&I(this._$AH)?this._$AA.nextSibling.data=t:this.T(k.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=z.createElement(Ae(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new K(i,this),o=s.u(this.options);s.p(e),this.T(o),this._$AH=s}}_$AC(t){let e=Ee.get(t.strings);return e===void 0&&Ee.set(t.strings,e=new z(t)),e}k(t){re(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let s of t)i===e.length?e.push(r=new n(this.O(M()),this.O(M()),this,this.options)):r=e[i],r._$AI(s),i++;i2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=f}_$AI(t,e=this,r,i){let s=this.strings,o=!1;if(s===void 0)t=S(this,t,e,0),o=!I(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else{let c=t,l,g;for(t=s[0],l=0;l{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let s=e?.renderBefore??null;r._$litPart$=i=new N(t.insertBefore(M(),s),s,void 0,e??{})}return i._$AI(n),i};var ne=globalThis,$=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Te(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return w}};$._$litElement$=!0,$.finalized=!0,ne.litElementHydrateSupport?.({LitElement:$});var Ze=ne.litElementPolyfillSupport;Ze?.({LitElement:$});(ne.litElementVersions??=[]).push("4.2.2");var Ce=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};var Ke={attribute:!0,type:String,converter:P,reflect:!1,hasChanged:B},Je=(n=Ke,t,e)=>{let{kind:r,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),r==="setter"&&((n=Object.create(n)).wrapped=!0),s.set(e.name,n),r==="accessor"){let{name:o}=e;return{set(c){let l=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,l,n,!0,c)},init(c){return c!==void 0&&this.C(o,void 0,n,c),c}}}if(r==="setter"){let{name:o}=e;return function(c){let l=this[o];t.call(this,c),this.requestUpdate(o,l,n,!0,c)}}throw Error("Unsupported decorator location: "+r)};function L(n){return(t,e)=>typeof e=="object"?Je(n,t,e):((r,i,s)=>{let o=i.hasOwnProperty(s);return i.constructor.createProperty(s,r),o?Object.getOwnPropertyDescriptor(i,s):void 0})(n,t,e)}function u(n){return L({...n,state:!0,attribute:!1})}function se(n,t){return a`${n.map(e=>Xe(e,t))}`}function Xe(n,t){switch(n.k){case"newline":return a` `;case"indent":return a`${n.t} `;case"keyword":return a`${n.t} `;case"operator":return a`${n.t} `;case"value":return a`${n.t} `;case"ref":{let e=t&&n.ek&&typeof n.ei=="number"?()=>t(n.ek,n.ei):void 0;return a`{for(var i=r>1?void 0:r?He(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(r?o(t,e,i):o(i))||i);return r&&i&&Oe(t,e,i),i};var j=globalThis,U=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,W=Symbol(),he=new WeakMap,R=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==W)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(U&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=he.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&he.set(e,t))}return t}toString(){return this.cssText}},me=n=>new R(typeof n=="string"?n:n+"",void 0,W),Z=(n,...t)=>{let e=n.length===1?n[0]:t.reduce((r,i,s)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+n[s+1],n[0]);return new R(e,n,W)},fe=(n,t)=>{if(U)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=j.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,n.appendChild(r)}},G=U?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return me(e)})(n):n;var{is:je,defineProperty:Ue,getOwnPropertyDescriptor:Be,getOwnPropertyNames:Ye,getOwnPropertySymbols:qe,getPrototypeOf:Ve}=Object,B=globalThis,ge=B.trustedTypes,We=ge?ge.emptyScript:"",Ze=B.reactiveElementPolyfillSupport,M=(n,t)=>n,D={toAttribute(n,t){switch(t){case Boolean:n=n?We:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Y=(n,t)=>!je(n,t),_e={attribute:!0,type:String,converter:D,reflect:!1,useDefault:!1,hasChanged:Y};Symbol.metadata??=Symbol("metadata"),B.litPropertyMetadata??=new WeakMap;var b=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=_e){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&Ue(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){let{get:i,set:s}=Be(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){let c=i?.call(this);s?.call(this,o),this.requestUpdate(t,c,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??_e}static _$Ei(){if(this.hasOwnProperty(M("elementProperties")))return;let t=Ve(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(M("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(M("properties"))){let e=this.properties,r=[...Ye(e),...qe(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let i of r)e.unshift(G(i))}else t!==void 0&&e.push(G(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return fe(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let s=(r.converter?.toAttribute!==void 0?r.converter:D).toAttribute(e,r.type);this._$Em=t,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(t,e){let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let s=r.getPropertyOptions(i),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:D;this._$Em=i;let c=o.fromAttribute(e,s.type);this[i]=c??this._$Ej?.get(i)??c,this._$Em=null}}requestUpdate(t,e,r,i=!1,s){if(t!==void 0){let o=this.constructor;if(i===!1&&(s=this[t]),r??=o.getPropertyOptions(t),!((r.hasChanged??Y)(s,e)||r.useDefault&&r.reflect&&s===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:i,wrapped:s},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),s!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,s]of r){let{wrapped:o}=s,c=this[i];o!==!0||this._$AL.has(i)||c===void 0||this.C(i,void 0,s,c)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[M("elementProperties")]=new Map,b[M("finalized")]=new Map,Ze?.({ReactiveElement:b}),(B.reactiveElementVersions??=[]).push("2.1.2");var re=globalThis,ve=n=>n,q=re.trustedTypes,be=q?q.createPolicy("lit-html",{createHTML:n=>n}):void 0,Se="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,we="?"+$,Ge=`<${we}>`,S=document,P=()=>S.createComment(""),z=n=>n===null||typeof n!="object"&&typeof n!="function",ie=Array.isArray,Ke=n=>ie(n)||typeof n?.[Symbol.iterator]=="function",K=`[
+\f\r]`,I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ye=/-->/g,$e=/>/g,E=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
+\f\r"'\`<>=]|("|')|))|$)`,"g"),xe=/'/g,Ee=/"/g,Te=/^(?:script|style|textarea|title)$/i,ne=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),a=ne(1),dt=ne(2),pt=ne(3),w=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),ke=new WeakMap,k=S.createTreeWalker(S,129);function Ae(n,t){if(!ie(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return be!==void 0?be.createHTML(t):t}var Je=(n,t)=>{let e=n.length-1,r=[],i,s=t===2?"":t===3?"":"",o=I;for(let c=0;c"?(o=i??I,d=-1):f[1]===void 0?d=-2:(d=o.lastIndex-f[2].length,h=f[1],o=f[3]===void 0?E:f[3]==='"'?Ee:xe):o===Ee||o===xe?o=E:o===ye||o===$e?o=I:(o=E,i=void 0);let y=o===E&&n[c+1].startsWith("/>")?" ":"";s+=o===I?l+Ge:d>=0?(r.push(h),l.slice(0,d)+Se+l.slice(d)+$+y):l+$+(d===-2?c:y)}return[Ae(n,s+(n[e]||">")+(t===2?" ":t===3?"":"")),r]},N=class n{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let s=0,o=0,c=t.length-1,l=this.parts,[h,f]=Je(t,e);if(this.el=n.createElement(h,r),k.currentNode=this.el.content,e===2||e===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=k.nextNode())!==null&&l.length0){i.textContent=q?q.emptyScript:"";for(let y=0;y2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=g}_$AI(t,e=this,r,i){let s=this.strings,o=!1;if(s===void 0)t=T(this,t,e,0),o=!z(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else{let c=t,l,h;for(t=s[0],l=0;l{let r=e?.renderBefore??t,i=r._$litPart$;if(i===void 0){let s=e?.renderBefore??null;r._$litPart$=i=new L(t.insertBefore(P(),s),s,void 0,e??{})}return i._$AI(n),i};var se=globalThis,x=class extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Ce(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return w}};x._$litElement$=!0,x.finalized=!0,se.litElementHydrateSupport?.({LitElement:x});var Qe=se.litElementPolyfillSupport;Qe?.({LitElement:x});(se.litElementVersions??=[]).push("4.2.2");var Fe=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};var et={attribute:!0,type:String,converter:D,reflect:!1,hasChanged:Y},tt=(n=et,t,e)=>{let{kind:r,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),r==="setter"&&((n=Object.create(n)).wrapped=!0),s.set(e.name,n),r==="accessor"){let{name:o}=e;return{set(c){let l=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,l,n,!0,c)},init(c){return c!==void 0&&this.C(o,void 0,n,c),c}}}if(r==="setter"){let{name:o}=e;return function(c){let l=this[o];t.call(this,c),this.requestUpdate(o,l,n,!0,c)}}throw Error("Unsupported decorator location: "+r)};function O(n){return(t,e)=>typeof e=="object"?tt(n,t,e):((r,i,s)=>{let o=i.hasOwnProperty(s);return i.constructor.createProperty(s,r),o?Object.getOwnPropertyDescriptor(i,s):void 0})(n,t,e)}function m(n){return O({...n,state:!0,attribute:!1})}function oe(n,t){return a`${n.map(e=>rt(e,t))}`}function rt(n,t){switch(n.k){case"newline":return a` `;case"indent":return a`${n.t} `;case"keyword":return a`${n.t} `;case"operator":return a`${n.t} `;case"value":return a`${n.t} `;case"ref":{let e=t&&n.ek&&typeof n.ei=="number"?()=>t(n.ek,n.ei):void 0;return a`
${n.t}
${n.s?a`${n.s} `:""}
- `}default:return a`${n.t} `}}var oe=[{value:0,label:"Turn OFF unit",ref_kind:"unit"},{value:1,label:"Turn ON unit",ref_kind:"unit"},{value:2,label:"All OFF",ref_kind:null},{value:3,label:"All ON",ref_kind:null},{value:4,label:"Bypass zone",ref_kind:"zone"},{value:5,label:"Restore zone",ref_kind:"zone"},{value:7,label:"Execute button",ref_kind:"button"},{value:9,label:"Set unit level %",ref_kind:"unit"},{value:48,label:"Disarm area",ref_kind:"area"},{value:49,label:"Arm area Day",ref_kind:"area"},{value:50,label:"Arm area Night",ref_kind:"area"},{value:51,label:"Arm area Away",ref_kind:"area"},{value:52,label:"Arm area Vacation",ref_kind:"area"}];function ae(n){return oe.find(t=>t.value===n)}var Fe=[{bit:2,label:"Mon"},{bit:4,label:"Tue"},{bit:8,label:"Wed"},{bit:16,label:"Thu"},{bit:32,label:"Fri"},{bit:64,label:"Sat"},{bit:128,label:"Sun"}],le=1,ce=2,de=3;var pe=[{id:768,label:"Phone line dead"},{id:769,label:"Phone ringing"},{id:770,label:"Phone off hook"},{id:771,label:"Phone on hook"},{id:772,label:"AC power lost"},{id:773,label:"AC power restored"}];function T(n){if(pe.some(t=>t.id===n))return{category:"fixed",fixedId:n};if(!(n&65280))return{category:"button",button:n&255};if((n&64512)===1024){let t=n&1023;return{category:"zone",zone:Math.floor(t/4)+1,zoneState:t%4}}if((n&64512)===2048){let t=n&1023;return{category:"unit",unit:Math.floor(t/2)+1,unitOn:(t&1)===1}}return{category:"raw",raw:n}}function Re(n){switch(n.category){case"button":return(n.button??1)&255;case"zone":{let t=(n.zone??1)-1,e=(n.zoneState??0)&3;return 1024|t*4+e&1023}case"unit":{let t=(n.unit??1)-1,e=n.unitOn?1:0;return 2048|t*2+e&1023}case"fixed":return n.fixedId??768;case"raw":default:return n.raw??0}}function C(n){return(n.month??0)<<8|(n.day??0)}function Pe(n,t){return{...n,month:t>>8&255,day:t&255}}var De=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var Me=new Set(["TIMED","EVENT","YEARLY"]),Qe=["TIMED","EVENT","YEARLY","WHEN","AT","EVERY","REMARK"],et=5e3,d=class extends ${constructor(){super(...arguments);this.narrow=!1;this._entryId=null;this._rows=[];this._total=0;this._filteredTotal=0;this._loading=!1;this._error=null;this._activeTriggerTypes=new Set;this._referenceFilter=null;this._searchTerm="";this._selectedSlot=null;this._detail=null;this._detailLoading=!1;this._fireFeedback=null;this._writeFeedback=null;this._cloneTargetSlot="";this._showCloneInput=!1;this._confirmingClear=!1;this._editingDraft=null;this._objects=null;this._refreshTimer=null}connectedCallback(){super.connectedCallback(),this._discoverEntry(),this._entryId&&(this._loadList(),this._startRefreshTimer())}disconnectedCallback(){super.disconnectedCallback(),this._stopRefreshTimer()}updated(e){e.has("hass")&&this._entryId===null&&(this._discoverEntry(),this._entryId&&(this._loadList(),this._startRefreshTimer()))}_discoverEntry(){this.hass?.connection&&this._discoverViaList()}async _discoverViaList(){try{let r=(await this.hass.connection.sendMessagePromise({type:"config_entries/get"})).filter(s=>s.domain==="omni_pca");if(r.length===0){this._error="No Omni panel configured. Add one via Settings \u2192 Devices & Services.";return}let i=r.find(s=>s.state==="loaded");this._entryId=(i??r[0]).entry_id,this._error=null,this._loadList(),this._startRefreshTimer()}catch(e){this._error=`Could not discover panels: ${e instanceof Error?e.message:String(e)}`}}async _loadList(){if(this._entryId){this._loading=!0,this._error=null;try{let e={type:"omni_pca/programs/list",entry_id:this._entryId};this._activeTriggerTypes.size>0&&(e.trigger_types=[...this._activeTriggerTypes]),this._referenceFilter&&(e.references_entity=this._referenceFilter),this._searchTerm&&(e.search=this._searchTerm);let r=await this.hass.connection.sendMessagePromise(e);this._rows=r.programs,this._total=r.total,this._filteredTotal=r.filtered_total}catch(e){this._error=e instanceof Error?e.message:String(e)}finally{this._loading=!1}}}async _loadDetail(e){if(this._entryId){this._detailLoading=!0,this._detail=null;try{this._detail=await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/get",entry_id:this._entryId,slot:e})}catch(r){this._error=r instanceof Error?r.message:String(r)}finally{this._detailLoading=!1}}}async _fireProgram(e){if(this._entryId){this._fireFeedback="firing\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/fire",entry_id:this._entryId,slot:e}),this._fireFeedback=`fired slot ${e}`}catch(r){this._fireFeedback=`error: ${r instanceof Error?r.message:r}`}setTimeout(()=>{this._fireFeedback=null},4e3)}}async _clearProgram(e){if(this._entryId){this._writeFeedback="clearing\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/clear",entry_id:this._entryId,slot:e}),this._writeFeedback=`cleared slot ${e}`,this._confirmingClear=!1,this._selectedSlot=null,this._detail=null,await this._loadList()}catch(r){let i=r instanceof Error?r.message:String(r);this._writeFeedback=`error: ${i}`}setTimeout(()=>{this._writeFeedback=null},4e3)}}async _cloneProgram(e){if(!this._entryId)return;let r=this._cloneTargetSlot.trim(),i=parseInt(r,10);if(!Number.isFinite(i)||i<1||i>1500){this._writeFeedback="target slot must be 1..1500",setTimeout(()=>{this._writeFeedback=null},4e3);return}if(i===e){this._writeFeedback="target must differ from source",setTimeout(()=>{this._writeFeedback=null},4e3);return}this._writeFeedback="cloning\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/clone",entry_id:this._entryId,source_slot:e,target_slot:i}),this._writeFeedback=`cloned to slot ${i}`,this._showCloneInput=!1,this._cloneTargetSlot="",this._selectedSlot=i,await this._loadList(),await this._loadDetail(i)}catch(s){let o=s instanceof Error?s.message:String(s);this._writeFeedback=`error: ${o}`}setTimeout(()=>{this._writeFeedback=null},4e3)}_onCloneTargetInput(e){this._cloneTargetSlot=e.target.value}async _ensureObjectsLoaded(){if(!(this._objects!==null||!this._entryId))try{this._objects=await this.hass.connection.sendMessagePromise({type:"omni_pca/objects/list",entry_id:this._entryId})}catch(e){let r=e instanceof Error?e.message:String(e);console.warn("omni_pca: objects/list failed",r)}}async _beginEdit(){if(!this._detail||this._detail.kind!=="compact"||!Me.has(this._detail.trigger_type)||(await this._ensureObjectsLoaded(),!this._entryId))return;let e=this._detail.fields??this._defaultFieldsForType(this._detail.trigger_type);e!==null&&(this._editingDraft={...e},this._stopRefreshTimer())}_defaultFieldsForType(e){let r=this._objects?.units?.[0]?.index??1;if(e==="TIMED")return{prog_type:le,cmd:1,par:0,pr2:r,hour:6,minute:0,days:62,cond:0,cond2:0,month:0,day:0};if(e==="EVENT"){let i=this._objects?.buttons?.[0]?.index??1;return{prog_type:ce,cmd:1,par:0,pr2:r,month:0,day:i&255,hour:0,minute:0,days:0,cond:0,cond2:0}}return e==="YEARLY"?{prog_type:de,cmd:1,par:0,pr2:r,month:1,day:1,hour:0,minute:0,days:0,cond:0,cond2:0}:null}async _saveDraft(){if(!(!this._editingDraft||!this._detail||!this._entryId)){this._writeFeedback="saving\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/write",entry_id:this._entryId,slot:this._detail.slot,program:this._editingDraft}),this._writeFeedback=`saved slot ${this._detail.slot}`,this._editingDraft=null,this._startRefreshTimer(),await this._loadList(),await this._loadDetail(this._detail.slot)}catch(e){let r=e instanceof Error?e.message:String(e);this._writeFeedback=`error: ${r}`}setTimeout(()=>{this._writeFeedback=null},4e3)}}_cancelEdit(){this._editingDraft=null,this._startRefreshTimer()}_patchDraft(e){this._editingDraft&&(this._editingDraft={...this._editingDraft,...e})}_toggleDayBit(e){if(!this._editingDraft)return;let i=(this._editingDraft.days??0)^e;this._patchDraft({days:i})}_onCommandChange(e){let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=ae(r),s=this._editingDraft?.pr2??0;if(i?.ref_kind&&this._objects){let o=this._pickBucket(i.ref_kind);o&&o.length>0&&!o.some(c=>c.index===s)&&(s=o[0].index)}else i?.ref_kind||(s=0);this._patchDraft({cmd:r,pr2:s})}_pickBucket(e){if(!this._objects)return null;switch(e){case"zone":return this._objects.zones;case"unit":return this._objects.units;case"area":return this._objects.areas;case"button":return this._objects.buttons;default:return null}}_bucketWithPreserve(e,r,i){let s=e??[];return i===0||s.some(o=>o.index===i)?s:[{index:i,name:`(undiscovered ${r} ${i} \u2014 preserve original)`},...s]}_onObjectChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchDraft({pr2:r})}_onHourChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=23&&this._patchDraft({hour:r})}_onMinuteChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=59&&this._patchDraft({minute:r})}_onParChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=255&&this._patchDraft({par:r})}_onMonthChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=1&&r<=12&&this._patchDraft({month:r})}_onDayChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=1&&r<=31&&this._patchDraft({day:r})}_patchEvent(e){if(!this._editingDraft)return;let r=Re(e);this._editingDraft=Pe(this._editingDraft,r)}_onEventCategoryChange(e){let r=e.target.value;if(r==="button"){let i=this._objects?.buttons?.[0]?.index??1;this._patchEvent({category:"button",button:i})}else if(r==="zone"){let i=this._objects?.zones?.[0]?.index??1;this._patchEvent({category:"zone",zone:i,zoneState:1})}else if(r==="unit"){let i=this._objects?.units?.[0]?.index??1;this._patchEvent({category:"unit",unit:i,unitOn:!0})}else r==="fixed"&&this._patchEvent({category:"fixed",fixedId:772})}_onEventButtonChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchEvent({category:"button",button:r})}_onEventZoneChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=T(C(this._editingDraft));this._patchEvent({category:"zone",zone:r,zoneState:i.zoneState??1})}_onEventZoneStateChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=T(C(this._editingDraft));this._patchEvent({category:"zone",zone:i.zone??1,zoneState:r})}_onEventUnitChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=T(C(this._editingDraft));this._patchEvent({category:"unit",unit:r,unitOn:i.unitOn??!0})}_onEventUnitOnChange(e){if(!this._editingDraft)return;let r=e.target.value==="1",i=T(C(this._editingDraft));this._patchEvent({category:"unit",unit:i.unit??1,unitOn:r})}_onEventFixedChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchEvent({category:"fixed",fixedId:r})}_startRefreshTimer(){this._refreshTimer===null&&(this._refreshTimer=window.setInterval(()=>{this._loadList(),this._selectedSlot!==null&&this._loadDetail(this._selectedSlot)},et))}_stopRefreshTimer(){this._refreshTimer!==null&&(window.clearInterval(this._refreshTimer),this._refreshTimer=null)}_toggleTriggerFilter(e){let r=new Set(this._activeTriggerTypes);r.has(e)?r.delete(e):r.add(e),this._activeTriggerTypes=r,this._loadList()}_onSearchInput(e){this._searchTerm=e.target.value,this._loadList()}_clearReferenceFilter(){this._referenceFilter=null,this._loadList()}_onRowClick(e){this._selectedSlot=e,this._loadDetail(e)}_onRefClick(e,r){this._referenceFilter=`${e}:${r}`,this._selectedSlot=null,this._detail=null,this._loadList()}_closeDetail(){this._selectedSlot=null,this._detail=null}render(){return a`
+ `}default:return a`${n.t} `}}var ae=[{value:0,label:"Turn OFF unit",ref_kind:"unit"},{value:1,label:"Turn ON unit",ref_kind:"unit"},{value:2,label:"All OFF",ref_kind:null},{value:3,label:"All ON",ref_kind:null},{value:4,label:"Bypass zone",ref_kind:"zone"},{value:5,label:"Restore zone",ref_kind:"zone"},{value:7,label:"Execute button",ref_kind:"button"},{value:9,label:"Set unit level %",ref_kind:"unit"},{value:48,label:"Disarm area",ref_kind:"area"},{value:49,label:"Arm area Day",ref_kind:"area"},{value:50,label:"Arm area Night",ref_kind:"area"},{value:51,label:"Arm area Away",ref_kind:"area"},{value:52,label:"Arm area Vacation",ref_kind:"area"}];function le(n){return ae.find(t=>t.value===n)}var Re=[{bit:2,label:"Mon"},{bit:4,label:"Tue"},{bit:8,label:"Wed"},{bit:16,label:"Thu"},{bit:32,label:"Fri"},{bit:64,label:"Sat"},{bit:128,label:"Sun"}],ce=1,de=2,pe=3;var ue=[{id:768,label:"Phone line dead"},{id:769,label:"Phone ringing"},{id:770,label:"Phone off hook"},{id:771,label:"Phone on hook"},{id:772,label:"AC power lost"},{id:773,label:"AC power restored"}];function C(n){if(ue.some(t=>t.id===n))return{category:"fixed",fixedId:n};if(!(n&65280))return{category:"button",button:n&255};if((n&64512)===1024){let t=n&1023;return{category:"zone",zone:Math.floor(t/4)+1,zoneState:t%4}}if((n&64512)===2048){let t=n&1023;return{category:"unit",unit:Math.floor(t/2)+1,unitOn:(t&1)===1}}return{category:"raw",raw:n}}function Me(n){switch(n.category){case"button":return(n.button??1)&255;case"zone":{let t=(n.zone??1)-1,e=(n.zoneState??0)&3;return 1024|t*4+e&1023}case"unit":{let t=(n.unit??1)-1,e=n.unitOn?1:0;return 2048|t*2+e&1023}case"fixed":return n.fixedId??768;case"raw":default:return n.raw??0}}function F(n){return(n.month??0)<<8|(n.day??0)}function De(n,t){return{...n,month:t>>8&255,day:t&255}}var Ie=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Pe=[{value:0,label:"always"},{value:1,label:"never"},{value:2,label:"it is light outside"},{value:3,label:"it is dark outside"},{value:4,label:"phone line is dead"},{value:5,label:"phone is ringing"},{value:6,label:"phone is off hook"},{value:7,label:"phone is on hook"},{value:8,label:"AC power is off"},{value:9,label:"AC power is on"},{value:10,label:"battery is low"},{value:11,label:"battery is OK"},{value:12,label:"energy cost is low"},{value:13,label:"energy cost is mid"},{value:14,label:"energy cost is high"},{value:15,label:"energy cost is critical"}],ze=[{value:0,label:"Off (disarmed)"},{value:1,label:"Day"},{value:2,label:"Night"},{value:3,label:"Away"},{value:4,label:"Vacation"},{value:5,label:"Day Instant"},{value:6,label:"Night Delayed"}];function Ne(n){if(n===0)return{family:"none"};let t=n>>8&252,e=(n&512)!==0;return t===0?{family:"misc",misc:n&15}:t===4?{family:"zone",index:n&255,active:e}:t===8?{family:"unit",index:n&511,active:e}:t===12?{family:"time",index:n&255,active:e}:{family:"sec",index:n>>8&15,mode:n>>12&7}}function _(n){switch(n.family){case"none":return 0;case"misc":return(n.misc??0)&15;case"zone":{let t=(n.index??0)&255;return 1024|(n.active?512:0)|t}case"unit":{let t=(n.index??0)&511;return 2048|(n.active?512:0)|t}case"time":{let t=(n.index??0)&255;return 3072|(n.active?512:0)|t}case"sec":{let t=(n.index??1)&15;return((n.mode??0)&7)<<12|t<<8}}}var Le=new Set(["TIMED","EVENT","YEARLY"]),it=["TIMED","EVENT","YEARLY","WHEN","AT","EVERY","REMARK"],nt=5e3,p=class extends x{constructor(){super(...arguments);this.narrow=!1;this._entryId=null;this._rows=[];this._total=0;this._filteredTotal=0;this._loading=!1;this._error=null;this._activeTriggerTypes=new Set;this._referenceFilter=null;this._searchTerm="";this._selectedSlot=null;this._detail=null;this._detailLoading=!1;this._fireFeedback=null;this._writeFeedback=null;this._cloneTargetSlot="";this._showCloneInput=!1;this._confirmingClear=!1;this._editingDraft=null;this._objects=null;this._refreshTimer=null}connectedCallback(){super.connectedCallback(),this._discoverEntry(),this._entryId&&(this._loadList(),this._startRefreshTimer())}disconnectedCallback(){super.disconnectedCallback(),this._stopRefreshTimer()}updated(e){e.has("hass")&&this._entryId===null&&(this._discoverEntry(),this._entryId&&(this._loadList(),this._startRefreshTimer()))}_discoverEntry(){this.hass?.connection&&this._discoverViaList()}async _discoverViaList(){try{let r=(await this.hass.connection.sendMessagePromise({type:"config_entries/get"})).filter(s=>s.domain==="omni_pca");if(r.length===0){this._error="No Omni panel configured. Add one via Settings \u2192 Devices & Services.";return}let i=r.find(s=>s.state==="loaded");this._entryId=(i??r[0]).entry_id,this._error=null,this._loadList(),this._startRefreshTimer()}catch(e){this._error=`Could not discover panels: ${e instanceof Error?e.message:String(e)}`}}async _loadList(){if(this._entryId){this._loading=!0,this._error=null;try{let e={type:"omni_pca/programs/list",entry_id:this._entryId};this._activeTriggerTypes.size>0&&(e.trigger_types=[...this._activeTriggerTypes]),this._referenceFilter&&(e.references_entity=this._referenceFilter),this._searchTerm&&(e.search=this._searchTerm);let r=await this.hass.connection.sendMessagePromise(e);this._rows=r.programs,this._total=r.total,this._filteredTotal=r.filtered_total}catch(e){this._error=e instanceof Error?e.message:String(e)}finally{this._loading=!1}}}async _loadDetail(e){if(this._entryId){this._detailLoading=!0,this._detail=null;try{this._detail=await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/get",entry_id:this._entryId,slot:e})}catch(r){this._error=r instanceof Error?r.message:String(r)}finally{this._detailLoading=!1}}}async _fireProgram(e){if(this._entryId){this._fireFeedback="firing\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/fire",entry_id:this._entryId,slot:e}),this._fireFeedback=`fired slot ${e}`}catch(r){this._fireFeedback=`error: ${r instanceof Error?r.message:r}`}setTimeout(()=>{this._fireFeedback=null},4e3)}}async _clearProgram(e){if(this._entryId){this._writeFeedback="clearing\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/clear",entry_id:this._entryId,slot:e}),this._writeFeedback=`cleared slot ${e}`,this._confirmingClear=!1,this._selectedSlot=null,this._detail=null,await this._loadList()}catch(r){let i=r instanceof Error?r.message:String(r);this._writeFeedback=`error: ${i}`}setTimeout(()=>{this._writeFeedback=null},4e3)}}async _cloneProgram(e){if(!this._entryId)return;let r=this._cloneTargetSlot.trim(),i=parseInt(r,10);if(!Number.isFinite(i)||i<1||i>1500){this._writeFeedback="target slot must be 1..1500",setTimeout(()=>{this._writeFeedback=null},4e3);return}if(i===e){this._writeFeedback="target must differ from source",setTimeout(()=>{this._writeFeedback=null},4e3);return}this._writeFeedback="cloning\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/clone",entry_id:this._entryId,source_slot:e,target_slot:i}),this._writeFeedback=`cloned to slot ${i}`,this._showCloneInput=!1,this._cloneTargetSlot="",this._selectedSlot=i,await this._loadList(),await this._loadDetail(i)}catch(s){let o=s instanceof Error?s.message:String(s);this._writeFeedback=`error: ${o}`}setTimeout(()=>{this._writeFeedback=null},4e3)}_onCloneTargetInput(e){this._cloneTargetSlot=e.target.value}async _ensureObjectsLoaded(){if(!(this._objects!==null||!this._entryId))try{this._objects=await this.hass.connection.sendMessagePromise({type:"omni_pca/objects/list",entry_id:this._entryId})}catch(e){let r=e instanceof Error?e.message:String(e);console.warn("omni_pca: objects/list failed",r)}}async _beginEdit(){if(!this._detail||this._detail.kind!=="compact"||!Le.has(this._detail.trigger_type)||(await this._ensureObjectsLoaded(),!this._entryId))return;let e=this._detail.fields??this._defaultFieldsForType(this._detail.trigger_type);e!==null&&(this._editingDraft={...e},this._stopRefreshTimer())}_defaultFieldsForType(e){let r=this._objects?.units?.[0]?.index??1;if(e==="TIMED")return{prog_type:ce,cmd:1,par:0,pr2:r,hour:6,minute:0,days:62,cond:0,cond2:0,month:0,day:0};if(e==="EVENT"){let i=this._objects?.buttons?.[0]?.index??1;return{prog_type:de,cmd:1,par:0,pr2:r,month:0,day:i&255,hour:0,minute:0,days:0,cond:0,cond2:0}}return e==="YEARLY"?{prog_type:pe,cmd:1,par:0,pr2:r,month:1,day:1,hour:0,minute:0,days:0,cond:0,cond2:0}:null}async _saveDraft(){if(!(!this._editingDraft||!this._detail||!this._entryId)){this._writeFeedback="saving\u2026";try{await this.hass.connection.sendMessagePromise({type:"omni_pca/programs/write",entry_id:this._entryId,slot:this._detail.slot,program:this._editingDraft}),this._writeFeedback=`saved slot ${this._detail.slot}`,this._editingDraft=null,this._startRefreshTimer(),await this._loadList(),await this._loadDetail(this._detail.slot)}catch(e){let r=e instanceof Error?e.message:String(e);this._writeFeedback=`error: ${r}`}setTimeout(()=>{this._writeFeedback=null},4e3)}}_cancelEdit(){this._editingDraft=null,this._startRefreshTimer()}_patchDraft(e){this._editingDraft&&(this._editingDraft={...this._editingDraft,...e})}_toggleDayBit(e){if(!this._editingDraft)return;let i=(this._editingDraft.days??0)^e;this._patchDraft({days:i})}_onCommandChange(e){let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=le(r),s=this._editingDraft?.pr2??0;if(i?.ref_kind&&this._objects){let o=this._pickBucket(i.ref_kind);o&&o.length>0&&!o.some(c=>c.index===s)&&(s=o[0].index)}else i?.ref_kind||(s=0);this._patchDraft({cmd:r,pr2:s})}_pickBucket(e){if(!this._objects)return null;switch(e){case"zone":return this._objects.zones;case"unit":return this._objects.units;case"area":return this._objects.areas;case"button":return this._objects.buttons;default:return null}}_bucketWithPreserve(e,r,i){let s=e??[];return i===0||s.some(o=>o.index===i)?s:[{index:i,name:`(undiscovered ${r} ${i} \u2014 preserve original)`},...s]}_onObjectChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchDraft({pr2:r})}_onHourChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=23&&this._patchDraft({hour:r})}_onMinuteChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=59&&this._patchDraft({minute:r})}_onParChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=0&&r<=255&&this._patchDraft({par:r})}_onMonthChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=1&&r<=12&&this._patchDraft({month:r})}_onDayChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&r>=1&&r<=31&&this._patchDraft({day:r})}_patchEvent(e){if(!this._editingDraft)return;let r=Me(e);this._editingDraft=De(this._editingDraft,r)}_onEventCategoryChange(e){let r=e.target.value;if(r==="button"){let i=this._objects?.buttons?.[0]?.index??1;this._patchEvent({category:"button",button:i})}else if(r==="zone"){let i=this._objects?.zones?.[0]?.index??1;this._patchEvent({category:"zone",zone:i,zoneState:1})}else if(r==="unit"){let i=this._objects?.units?.[0]?.index??1;this._patchEvent({category:"unit",unit:i,unitOn:!0})}else r==="fixed"&&this._patchEvent({category:"fixed",fixedId:772})}_onEventButtonChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchEvent({category:"button",button:r})}_onEventZoneChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=C(F(this._editingDraft));this._patchEvent({category:"zone",zone:r,zoneState:i.zoneState??1})}_onEventZoneStateChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=C(F(this._editingDraft));this._patchEvent({category:"zone",zone:i.zone??1,zoneState:r})}_onEventUnitChange(e){if(!this._editingDraft)return;let r=parseInt(e.target.value,10);if(!Number.isFinite(r))return;let i=C(F(this._editingDraft));this._patchEvent({category:"unit",unit:r,unitOn:i.unitOn??!0})}_onEventUnitOnChange(e){if(!this._editingDraft)return;let r=e.target.value==="1",i=C(F(this._editingDraft));this._patchEvent({category:"unit",unit:i.unit??1,unitOn:r})}_onEventFixedChange(e){let r=parseInt(e.target.value,10);Number.isFinite(r)&&this._patchEvent({category:"fixed",fixedId:r})}_startRefreshTimer(){this._refreshTimer===null&&(this._refreshTimer=window.setInterval(()=>{this._loadList(),this._selectedSlot!==null&&this._loadDetail(this._selectedSlot)},nt))}_stopRefreshTimer(){this._refreshTimer!==null&&(window.clearInterval(this._refreshTimer),this._refreshTimer=null)}_toggleTriggerFilter(e){let r=new Set(this._activeTriggerTypes);r.has(e)?r.delete(e):r.add(e),this._activeTriggerTypes=r,this._loadList()}_onSearchInput(e){this._searchTerm=e.target.value,this._loadList()}_clearReferenceFilter(){this._referenceFilter=null,this._loadList()}_onRowClick(e){this._selectedSlot=e,this._loadDetail(e)}_onRefClick(e,r){this._referenceFilter=`${e}:${r}`,this._selectedSlot=null,this._detail=null,this._loadList()}_closeDetail(){this._selectedSlot=null,this._detail=null}render(){return a`