117 files

This commit is contained in:
Home Assistant Version Control committed 2026-08-08 10:38:07 +00:00
1 parent c31830deeb
commit ca54a47de7
119 files changed
+9737 -623

No files matched your search

@@ -1,5 +1,5 @@
/*! maintenance_supporter frontend 2.53.0 */
import"/maintenance_supporter_panelfiles/panel-chunks/chunk-6CM3ZIHM.js";import{b as Nt,c as oe}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-3FYWLAW5.js";import{a as E}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-MEKM6THN.js";import{a as se,b as ae,c as ne,d as re,e as Ct}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-JBZVB6GP.js";import{a as le}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-URNT5464.js";import{a as _,b as D,c as r,d as P,f as d,g as L,h as ee,i as T,j as m,k as jt,l as Mt,m as ut,n as s,o as St,p as q,q as Et,r as Y,s as Dt,t as _t,v as xt,w as mt,x as ie,y as Lt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-4MVSRJ3Y.js";function it(n){return!!n&&/^https?:\/\//i.test(n)}function ce(n,o){if(o.objects)return o.objects;let t=o.delta||[],e=o.removed||[];if(!t.length&&!e.length)return null;let i=new Map(n.map(a=>[a.entry_id,a]));for(let a of t)i.set(a.entry_id,a);for(let a of e)i.delete(a);return[...i.values()]}var At="2.53.0";function de(n,o=At){return!n||!o||o==="dev"?!1:n!==o}var F={overviewTab:"msp-overview-tab",collapsedSections:"msp-collapsed-sections",chartRange:"msp-chart-range",chartHideOutliers:"msp-chart-hide-outliers",taskSort:"maintenance_supporter_sort",objectSort:"maintenance_supporter_object_sort",groupBy:"maintenance_supporter_groupby",objectView:"maintenance_supporter_object_view",objectsCache:"msp-objects-cache"};var He=168*3600*1e3;function pe(){try{let n=localStorage.getItem(F.objectsCache);if(!n)return null;let o=JSON.parse(n);return o.v!==At||!Number.isFinite(o.at)||Date.now()-o.at>He||!Array.isArray(o.objects)||o.objects.length===0?null:{objects:o.objects,stats:o.stats??null}}catch{return null}}function Wt(n,o){if(!(!Array.isArray(n)||n.length===0))try{let t={v:At,at:Date.now(),objects:n,stats:o};localStorage.setItem(F.objectsCache,JSON.stringify(t))}catch{}}var Fe=["assignee_pool","required_completion_fields","checklist","labels","history"],Be=["checklist_progress"],Ve=["tasks","parts"],Ue=["manual_docs","battery_fleet_excluded"];function qt(n,o,t=[]){for(let e of o)n[e]===void 0&&(n[e]=[]);for(let e of t)n[e]===void 0&&(n[e]={})}function Ne(n){let o=n;qt(o,Ve),o.object&&typeof o.object=="object"&&qt(o.object,Ue);for(let t of o.tasks)qt(t,Fe,Be);return n}function Rt(n){for(let o of n)Ne(o);return n}var We={days:1,weeks:7,months:30.4368,years:365.25};function Yt(n,o){return!n||n<=0?0:n*(We[o||"days"]??1)}function Ot(n,o,t){let e=Yt(n,t);if(e<=0||o==null)return{pct:0,overflow:!1};let i=(e-o)/e*100;return{pct:Math.max(0,Math.min(100,i)),overflow:i>100}}function A(n){return String(n??"").replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o])}function he(n,o,t,e,i,a){let l=[[t.manufacturer,n.manufacturer],[t.model,n.model],[t.serial,n.serial_number],[t.installed,n.installation_date?e(n.installation_date):null],[t.warranty,n.warranty_expiry?e(n.warranty_expiry):null]].filter(([,p])=>!!p),h=o.map(p=>{let u=t.scheduleLabel(p);return`<tr>
/*! maintenance_supporter frontend 2.54.0 */
import"/maintenance_supporter_panelfiles/panel-chunks/chunk-AEF5ZY4E.js";import{b as Ut,c as oe}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-KH7UXWPC.js";import{a as E}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WZ6RLKNK.js";import{a as se,b as ae,c as ne,d as re,e as Ct}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-NSBT2PED.js";import{a as le}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-A7WM72WE.js";import{a as g,b as D,c as r,d as P,f as d,g as L,h as ee,i as T,j as m,k as jt,l as St,m as ut,n as s,o as Mt,p as q,q as Et,r as Y,s as Dt,t as gt,v as xt,w as mt,x as ie,y as Lt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-C2ERU424.js";function it(n){return!!n&&/^https?:\/\//i.test(n)}function ce(n,o){if(o.objects)return o.objects;let t=o.delta||[],e=o.removed||[];if(!t.length&&!e.length)return null;let i=new Map(n.map(a=>[a.entry_id,a]));for(let a of t)i.set(a.entry_id,a);for(let a of e)i.delete(a);return[...i.values()]}var At="2.54.0";function de(n,o=At){return!n||!o||o==="dev"?!1:n!==o}var F={overviewTab:"msp-overview-tab",collapsedSections:"msp-collapsed-sections",chartRange:"msp-chart-range",chartHideOutliers:"msp-chart-hide-outliers",taskSort:"maintenance_supporter_sort",objectSort:"maintenance_supporter_object_sort",groupBy:"maintenance_supporter_groupby",objectView:"maintenance_supporter_object_view",objectsCache:"msp-objects-cache",gettingStartedDismissed:"msp-gs-dismissed"};var He=168*3600*1e3;function pe(){try{let n=localStorage.getItem(F.objectsCache);if(!n)return null;let o=JSON.parse(n);return o.v!==At||!Number.isFinite(o.at)||Date.now()-o.at>He||!Array.isArray(o.objects)||o.objects.length===0?null:{objects:o.objects,stats:o.stats??null}}catch{return null}}function Wt(n,o){if(!(!Array.isArray(n)||n.length===0))try{let t={v:At,at:Date.now(),objects:n,stats:o};localStorage.setItem(F.objectsCache,JSON.stringify(t))}catch{}}var Fe=["assignee_pool","required_completion_fields","checklist","labels","history"],Be=["checklist_progress"],Ve=["tasks","parts"],Ne=["manual_docs","battery_fleet_excluded"];function qt(n,o,t=[]){for(let e of o)n[e]===void 0&&(n[e]=[]);for(let e of t)n[e]===void 0&&(n[e]={})}function Ue(n){let o=n;qt(o,Ve),o.object&&typeof o.object=="object"&&qt(o.object,Ne);for(let t of o.tasks)qt(t,Fe,Be);return n}function Rt(n){for(let o of n)Ue(o);return n}var We={days:1,weeks:7,months:30.4368,years:365.25};function Yt(n,o){return!n||n<=0?0:n*(We[o||"days"]??1)}function Ot(n,o,t){let e=Yt(n,t);if(e<=0||o==null)return{pct:0,overflow:!1};let i=(e-o)/e*100;return{pct:Math.max(0,Math.min(100,i)),overflow:i>100}}function A(n){return String(n??"").replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o])}function he(n,o,t,e,i,a){let l=[[t.manufacturer,n.manufacturer],[t.model,n.model],[t.serial,n.serial_number],[t.installed,n.installation_date?e(n.installation_date):null],[t.warranty,n.warranty_expiry?e(n.warranty_expiry):null]].filter(([,p])=>!!p),h=o.map(p=>{let u=t.scheduleLabel(p);return`<tr>
<td>${A(p.name)}</td>
<td>${A(t.typeLabel(p.type))}</td>
<td>${A(t.statusLabel(p.status))}</td>
@@ -51,7 +51,7 @@ import"/maintenance_supporter_panelfiles/panel-chunks/chunk-6CM3ZIHM.js";import{
</table>
${n.notes?`<div class="notes"><strong>${A(t.notes)}:</strong>
${A(n.notes)}</div>`:""}
</body></html>`}function Kt(n,o=new Date){if(!n)return{kind:"none",days:null,date:null};let t=new Date(`${n}T00:00:00`);if(isNaN(t.getTime()))return{kind:"none",days:null,date:null};let e=Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()),i=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),a=Math.round((i-e)/864e5);return a<0?{kind:"expired",days:a,date:n}:a<=60?{kind:"expiring",days:a,date:n}:{kind:"valid",days:a,date:n}}var z=n=>String(n??"").replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o]);function ue(n,o,t,e,i,a,l,h,c,p=[]){let u=[[t.object,z(o)],[t.type,z(t.typeLabel(n.type))],[t.interval,z(i(n))],[t.nextDue,n.next_due?z(e(n.next_due)):"\u2014"],[t.lastDone,n.last_performed?z(e(n.last_performed)):z(t.never)]];n.priority&&n.priority!=="normal"&&u.push([t.priority,z(n.priority)]);let g=(n.checklist||[]).map(b=>`<li><span class="box"></span>${z(b)}</li>`).join(""),v=(b,x)=>b?`<figure class="qr"><img src="${b}" alt="" /><figcaption>${z(x)}</figcaption></figure>`:"";return`<!DOCTYPE html>
</body></html>`}function Kt(n,o=new Date){if(!n)return{kind:"none",days:null,date:null};let t=new Date(`${n}T00:00:00`);if(isNaN(t.getTime()))return{kind:"none",days:null,date:null};let e=Date.UTC(o.getFullYear(),o.getMonth(),o.getDate()),i=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),a=Math.round((i-e)/864e5);return a<0?{kind:"expired",days:a,date:n}:a<=60?{kind:"expiring",days:a,date:n}:{kind:"valid",days:a,date:n}}var z=n=>String(n??"").replace(/[&<>"']/g,o=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[o]);function ue(n,o,t,e,i,a,l,h,c,p=[]){let u=[[t.object,z(o)],[t.type,z(t.typeLabel(n.type))],[t.interval,z(i(n))],[t.nextDue,n.next_due?z(e(n.next_due)):"\u2014"],[t.lastDone,n.last_performed?z(e(n.last_performed)):z(t.never)]];n.priority&&n.priority!=="normal"&&u.push([t.priority,z(n.priority)]);let _=(n.checklist||[]).map(b=>`<li><span class="box"></span>${z(b)}</li>`).join(""),v=(b,x)=>b?`<figure class="qr"><img src="${b}" alt="" /><figcaption>${z(x)}</figcaption></figure>`:"";return`<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta name="color-scheme" content="light">
<title>${z(n.name)} \u2014 ${z(t.title)}</title>
<style>
@@ -103,7 +103,7 @@ ${A(n.notes)}</div>`:""}
<table class="meta">
${u.map(([b,x])=>`<tr><td>${z(b)}</td><td>${x}</td></tr>`).join("")}
</table>
${g?`<h2>${z(t.checklist)}</h2><ul class="check">${g}</ul>`:""}
${_?`<h2>${z(t.checklist)}</h2><ul class="check">${_}</ul>`:""}
${p.length?`<h2>${z(t.parts)}</h2><ul class="check">${p.map(b=>`<li><span class="box"></span>${z(b)}</li>`).join("")}</ul>`:""}
${n.notes?`<h2>${z(t.notes)}</h2><div class="notes">${z(n.notes)}</div>`:""}
${h?`<h2>${z(t.manualExcerpt)}</h2>
@@ -131,7 +131,7 @@ ${A(n.notes)}</div>`:""}
} catch (e) { console.warn("excerpt inline render failed", e); }
<\/script>`:""}`:""}
<footer>${z(o)} \xB7 ${z(n.name)} \xB7 ${z(t.printedOn)} ${z(c.slice(0,10))}</footer>
</body></html>`}var _e=D`
</body></html>`}var ge=D`
:host {
display: block;
height: 100%;
@@ -184,10 +184,9 @@ ${A(n.notes)}</div>`:""}
gap: 8px;
}
/* Narrow-viewport disclosure (UX 2026-07): the collapsed classes are only
/* Narrow-viewport disclosure (UX 2026-07): the collapsed class is only
ever set when the host is narrow — desktop always renders inline. */
.filter-bar.collapsed,
.actions-bar.collapsed {
.filter-bar.collapsed {
display: none;
}
@@ -197,29 +196,64 @@ ${A(n.notes)}</div>`:""}
padding: 8px 0 0;
}
.mobile-controls .mobile-toggle {
.mobile-controls .mobile-toggle,
.mobile-controls .new-menu-wrapper {
flex: 1;
}
.mobile-controls .new-menu-wrapper .new-menu-button {
width: 100%;
}
.mobile-controls .mobile-toggle.active {
--ha-button-background: var(--primary-color);
}
.actions-bar {
/* #125: the one "New" menu that replaced the six-button actions bar. */
.new-menu-wrapper {
position: relative;
margin-left: auto;
}
.new-menu-popup {
right: 0;
left: auto;
min-width: 256px;
}
.new-menu-popup .popup-menu-item {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 4px 0 8px;
/* Left-aligned on purpose: flex-end mimicked the pre-v2.37 look (buttons
trailing the filter row), but on wide desktops it strands the primary
"new task" action at the far right of an otherwise empty row. */
justify-content: flex-start;
align-items: center;
gap: 10px;
}
.new-menu-popup .popup-menu-item ha-icon {
--mdc-icon-size: 18px;
color: var(--secondary-text-color);
}
:host([narrow]) .new-menu-popup { right: 0; left: auto; }
:host([narrow]) .actions-bar {
flex-direction: column;
align-items: stretch;
/* #125: getting-started chips — visibly temporary onboarding hints. */
.gs-chips-wrap { margin: 2px 0 12px; }
.gs-chips-label {
font-size: 11px;
color: var(--secondary-text-color);
text-transform: uppercase;
letter-spacing: 0.6px;
margin-bottom: 7px;
}
.gs-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.gs-chip {
display: flex;
align-items: center;
gap: 9px;
background: var(--secondary-background-color);
border: 1px dashed var(--divider-color);
border-radius: 16px;
padding: 7px 8px 7px 13px;
font-size: 12.5px;
cursor: pointer;
}
.gs-chip ha-icon { --mdc-icon-size: 16px; color: var(--primary-color); }
.gs-chip-x { display: inline-flex; padding: 0 3px; }
.gs-chip-x ha-icon { --mdc-icon-size: 14px; color: var(--secondary-text-color); }
.filter-field {
display: flex;
@@ -1925,7 +1959,7 @@ ${A(n.notes)}</div>`:""}
.icon-btn.danger { color: var(--error-color, #f44336); }
.icon-btn[disabled] { opacity: 0.4; pointer-events: none; }
.icon-btn ha-icon { --mdc-icon-size: 20px; }
`,_([T({attribute:!1})],B.prototype,"hass",2),_([T({attribute:!1})],B.prototype,"entryId",2),_([T({type:Boolean})],B.prototype,"canWrite",2),_([m()],B.prototype,"_docs",2),_([m()],B.prototype,"_loaded",2),_([m()],B.prototype,"_busy",2),_([m()],B.prototype,"_error",2),_([m()],B.prototype,"_hint",2),_([m()],B.prototype,"_addingLink",2),_([m()],B.prototype,"_linkUrl",2),_([m()],B.prototype,"_linkTitle",2),_([m()],B.prototype,"_category",2),_([m()],B.prototype,"_thumbs",2),_([m()],B.prototype,"_lightboxUrl",2),_([m()],B.prototype,"_editingId",2),_([m()],B.prototype,"_editTitle",2),_([m()],B.prototype,"_editCategory",2),_([m()],B.prototype,"_dragOver",2);customElements.get("maintenance-documents-section")||customElements.define("maintenance-documents-section",B);var Ye=["manual","warranty","invoice","spare_parts","photo","other"],Ke={manual:"mdi:book-open-variant",warranty:"mdi:shield-check",invoice:"mdi:receipt-text-outline",spare_parts:"mdi:cog-outline",photo:"mdi:image-outline",other:"mdi:file-document-outline"},Q=class extends L{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._loaded=!1;this._busy=!1;this._error="";this._attachId="";this._loadedKey="";this._localeReady=!1}get _lang(){return this.hass?.language||"en"}get _refId(){return this.partId||this.taskId||""}get _linkField(){return this.partId?"part_ids":"task_ids"}updated(t){super.updated(t),this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()));let e=`${this.entryId}|${this._refId}`;this.hass&&this.entryId&&this._refId&&this._loadedKey!==e&&(this._loadedKey=e,this._load())}async _load(){try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/list",entry_id:this.entryId});this._docs=t.documents||[],this._loaded=!0,this._error=""}catch(t){this._error=E(t,this._lang),this._loaded=!0}}_links(t){return t[this._linkField]||[]}_linked(){return this._docs.filter(t=>this._links(t).includes(this._refId))}_available(){return this._docs.filter(t=>!this._links(t).includes(this._refId))}async _setLinks(t,e){this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/update",doc_id:t.id,[this._linkField]:e}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._busy=!1}}_link(){let t=this._docs.find(e=>e.id===this._attachId);t&&(this._attachId="",this._setLinks(t,[...this._links(t),this._refId]))}_unlink(t){this._setLinks(t,this._links(t).filter(e=>e!==this._refId))}_isPdf(t){return t.mime==="application/pdf"||(t.filename||"").toLowerCase().endsWith(".pdf")}_pageFor(t){return this._isPdf(t)&&this.taskId?t.task_pages?.[this.taskId]:void 0}async _open(t){if(t.kind==="weblink"){window.open(t.url,"_blank","noopener");return}let e=this._pageFor(t),i=e?`#page=${e}`:"",a=window.open("about:blank","_blank");try{let l=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:300});a&&(a.location.href=new URL(l.path+i,window.location.origin).href)}catch(l){a&&a.close(),this._error=E(l,this._lang)}}async _setPage(t,e){if(this.taskId){this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/update",doc_id:t.id,task_pages:{[this.taskId]:e}}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._busy=!1}}}async _download(t){try{let e=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:30});Ct(e.path,t.filename||t.title||"document")}catch(e){this._error=E(e,this._lang)}}render(){if(!this._loaded||this._docs.length===0)return d;let t=this._lang,e=this._linked(),i=this._available();return r`
`,g([T({attribute:!1})],B.prototype,"hass",2),g([T({attribute:!1})],B.prototype,"entryId",2),g([T({type:Boolean})],B.prototype,"canWrite",2),g([m()],B.prototype,"_docs",2),g([m()],B.prototype,"_loaded",2),g([m()],B.prototype,"_busy",2),g([m()],B.prototype,"_error",2),g([m()],B.prototype,"_hint",2),g([m()],B.prototype,"_addingLink",2),g([m()],B.prototype,"_linkUrl",2),g([m()],B.prototype,"_linkTitle",2),g([m()],B.prototype,"_category",2),g([m()],B.prototype,"_thumbs",2),g([m()],B.prototype,"_lightboxUrl",2),g([m()],B.prototype,"_editingId",2),g([m()],B.prototype,"_editTitle",2),g([m()],B.prototype,"_editCategory",2),g([m()],B.prototype,"_dragOver",2);customElements.get("maintenance-documents-section")||customElements.define("maintenance-documents-section",B);var Ye=["manual","warranty","invoice","spare_parts","photo","other"],Ke={manual:"mdi:book-open-variant",warranty:"mdi:shield-check",invoice:"mdi:receipt-text-outline",spare_parts:"mdi:cog-outline",photo:"mdi:image-outline",other:"mdi:file-document-outline"},Q=class extends L{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._loaded=!1;this._busy=!1;this._error="";this._attachId="";this._loadedKey="";this._localeReady=!1}get _lang(){return this.hass?.language||"en"}get _refId(){return this.partId||this.taskId||""}get _linkField(){return this.partId?"part_ids":"task_ids"}updated(t){super.updated(t),this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()));let e=`${this.entryId}|${this._refId}`;this.hass&&this.entryId&&this._refId&&this._loadedKey!==e&&(this._loadedKey=e,this._load())}async _load(){try{let t=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/list",entry_id:this.entryId});this._docs=t.documents||[],this._loaded=!0,this._error=""}catch(t){this._error=E(t,this._lang),this._loaded=!0}}_links(t){return t[this._linkField]||[]}_linked(){return this._docs.filter(t=>this._links(t).includes(this._refId))}_available(){return this._docs.filter(t=>!this._links(t).includes(this._refId))}async _setLinks(t,e){this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/update",doc_id:t.id,[this._linkField]:e}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._busy=!1}}_link(){let t=this._docs.find(e=>e.id===this._attachId);t&&(this._attachId="",this._setLinks(t,[...this._links(t),this._refId]))}_unlink(t){this._setLinks(t,this._links(t).filter(e=>e!==this._refId))}_isPdf(t){return t.mime==="application/pdf"||(t.filename||"").toLowerCase().endsWith(".pdf")}_pageFor(t){return this._isPdf(t)&&this.taskId?t.task_pages?.[this.taskId]:void 0}async _open(t){if(t.kind==="weblink"){window.open(t.url,"_blank","noopener");return}let e=this._pageFor(t),i=e?`#page=${e}`:"",a=window.open("about:blank","_blank");try{let l=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:300});a&&(a.location.href=new URL(l.path+i,window.location.origin).href)}catch(l){a&&a.close(),this._error=E(l,this._lang)}}async _setPage(t,e){if(this.taskId){this._busy=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/update",doc_id:t.id,task_pages:{[this.taskId]:e}}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._busy=!1}}}async _download(t){try{let e=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:30});Ct(e.path,t.filename||t.title||"document")}catch(e){this._error=E(e,this._lang)}}render(){if(!this._loaded||this._docs.length===0)return d;let t=this._lang,e=this._linked(),i=this._available();return r`
<div class="task-docs">
<h3><ha-icon icon="mdi:paperclip"></ha-icon> ${s("documents",t)} (${e.length})</h3>
${this._error?r`<div class="tdoc-error">${this._error}</div>`:d}
@@ -2032,7 +2066,7 @@ ${A(n.notes)}</div>`:""}
}
.tdoc-btn ha-icon { --mdc-icon-size: 18px; }
.tdoc-btn[disabled] { opacity: 0.5; pointer-events: none; }
`,_([T({attribute:!1})],Q.prototype,"hass",2),_([T({attribute:!1})],Q.prototype,"entryId",2),_([T({attribute:!1})],Q.prototype,"taskId",2),_([T({attribute:!1})],Q.prototype,"partId",2),_([T({type:Boolean})],Q.prototype,"canWrite",2),_([m()],Q.prototype,"_docs",2),_([m()],Q.prototype,"_loaded",2),_([m()],Q.prototype,"_busy",2),_([m()],Q.prototype,"_error",2),_([m()],Q.prototype,"_attachId",2);customElements.get("maintenance-task-documents")||customElements.define("maintenance-task-documents",Q);var Ge={name:"",vendor:"",mpn:"",gtin:"",storage_location:"",product_url:"",unit:"",cost:"",stock:"",reorder_threshold:"",restock_quantity:"",auto_buy_task:!0,notes:""},K=class extends L{constructor(){super(...arguments);this.parts=[];this.canWrite=!1;this.currencySymbol="\u20AC";this._editing=null;this._busy=!1;this._error="";this._restockFor=null;this._restockQty="";this._restockInvalid=!1;this._docsFor=null}get _lang(){return this.hass?.locale?.language||this.hass?.language||"en"}connectedCallback(){super.connectedCallback(),q(this._lang).then(()=>this.requestUpdate())}_notifyChanged(){this.dispatchEvent(new CustomEvent("parts-changed",{bubbles:!0,composed:!0}))}async _send(t){this._busy=!0,this._error="";try{return await this.hass.connection.sendMessagePromise(t)}catch(e){return this._error=E(e,this._lang),null}finally{this._busy=!1}}_openAdd(){this._editing={...Ge}}_openEdit(t){this._editing={id:t.id,name:t.name,vendor:t.vendor||"",mpn:t.mpn||"",gtin:t.gtin||"",storage_location:t.storage_location||"",product_url:t.product_url||"",unit:t.unit||"",cost:t.cost!=null?String(t.cost):"",stock:t.stock!=null?String(t.stock):"",reorder_threshold:t.reorder_threshold!=null?String(t.reorder_threshold):"",restock_quantity:t.restock_quantity!=null?String(t.restock_quantity):"",auto_buy_task:!!t.auto_buy_task,notes:t.notes||""}}_formValue(t){let e=i=>i.trim()===""?null:Number(i);return{entry_id:this.entryId,name:t.name.trim(),vendor:t.vendor.trim()||null,mpn:t.mpn.trim()||null,gtin:t.gtin.trim()||null,storage_location:t.storage_location.trim()||null,product_url:t.product_url.trim()||null,unit:t.unit.trim()||null,cost:e(t.cost),stock:e(t.stock),reorder_threshold:e(t.reorder_threshold),restock_quantity:e(t.restock_quantity),auto_buy_task:t.auto_buy_task,notes:t.notes.trim()||null}}async _save(){let t=this._editing;if(!t||!t.name.trim())return;let e=this._formValue(t),i=t.id?"maintenance_supporter/part/update":"maintenance_supporter/part/create";await this._send(t.id?{type:i,part_id:t.id,...e}:{type:i,...e})!==null&&(this._editing=null,this._notifyChanged())}async _delete(t){if(!window.confirm(s("part_delete_confirm",this._lang).replace("{name}",t.name)))return;await this._send({type:"maintenance_supporter/part/delete",entry_id:this.entryId,part_id:t.id})!==null&&this._notifyChanged()}async _restock(t){let e=parseFloat(this._restockQty);if(!Number.isFinite(e)||e===0){this._restockInvalid=!0;return}this._restockInvalid=!1;let i=await this._send({type:"maintenance_supporter/part/restock",entry_id:this.entryId,part_id:t.id,delta:e});this._restockFor=null,i!==null&&(t.stock=i.stock,this.requestUpdate(),this._notifyChanged())}_identLine(t){return[t.vendor,t.mpn?`MPN: ${t.mpn}`:"",t.gtin?`GTIN: ${t.gtin}`:""].filter(Boolean).join(" \xB7 ")}_renderRow(t){let e=this._lang,i=t.stock!==null&&t.stock!==void 0,a=this._identLine(t),l=this._docsFor===t.id;return r`
`,g([T({attribute:!1})],Q.prototype,"hass",2),g([T({attribute:!1})],Q.prototype,"entryId",2),g([T({attribute:!1})],Q.prototype,"taskId",2),g([T({attribute:!1})],Q.prototype,"partId",2),g([T({type:Boolean})],Q.prototype,"canWrite",2),g([m()],Q.prototype,"_docs",2),g([m()],Q.prototype,"_loaded",2),g([m()],Q.prototype,"_busy",2),g([m()],Q.prototype,"_error",2),g([m()],Q.prototype,"_attachId",2);customElements.get("maintenance-task-documents")||customElements.define("maintenance-task-documents",Q);var Ge={name:"",vendor:"",mpn:"",gtin:"",storage_location:"",product_url:"",unit:"",cost:"",stock:"",reorder_threshold:"",restock_quantity:"",auto_buy_task:!0,notes:""},K=class extends L{constructor(){super(...arguments);this.parts=[];this.canWrite=!1;this.currencySymbol="\u20AC";this._editing=null;this._busy=!1;this._error="";this._restockFor=null;this._restockQty="";this._restockInvalid=!1;this._docsFor=null}get _lang(){return this.hass?.locale?.language||this.hass?.language||"en"}connectedCallback(){super.connectedCallback(),q(this._lang).then(()=>this.requestUpdate())}_notifyChanged(){this.dispatchEvent(new CustomEvent("parts-changed",{bubbles:!0,composed:!0}))}async _send(t){this._busy=!0,this._error="";try{return await this.hass.connection.sendMessagePromise(t)}catch(e){return this._error=E(e,this._lang),null}finally{this._busy=!1}}_openAdd(){this._editing={...Ge}}_openEdit(t){this._editing={id:t.id,name:t.name,vendor:t.vendor||"",mpn:t.mpn||"",gtin:t.gtin||"",storage_location:t.storage_location||"",product_url:t.product_url||"",unit:t.unit||"",cost:t.cost!=null?String(t.cost):"",stock:t.stock!=null?String(t.stock):"",reorder_threshold:t.reorder_threshold!=null?String(t.reorder_threshold):"",restock_quantity:t.restock_quantity!=null?String(t.restock_quantity):"",auto_buy_task:!!t.auto_buy_task,notes:t.notes||""}}_formValue(t){let e=i=>i.trim()===""?null:Number(i);return{entry_id:this.entryId,name:t.name.trim(),vendor:t.vendor.trim()||null,mpn:t.mpn.trim()||null,gtin:t.gtin.trim()||null,storage_location:t.storage_location.trim()||null,product_url:t.product_url.trim()||null,unit:t.unit.trim()||null,cost:e(t.cost),stock:e(t.stock),reorder_threshold:e(t.reorder_threshold),restock_quantity:e(t.restock_quantity),auto_buy_task:t.auto_buy_task,notes:t.notes.trim()||null}}async _save(){let t=this._editing;if(!t||!t.name.trim())return;let e=this._formValue(t),i=t.id?"maintenance_supporter/part/update":"maintenance_supporter/part/create";await this._send(t.id?{type:i,part_id:t.id,...e}:{type:i,...e})!==null&&(this._editing=null,this._notifyChanged())}async _delete(t){if(!window.confirm(s("part_delete_confirm",this._lang).replace("{name}",t.name)))return;await this._send({type:"maintenance_supporter/part/delete",entry_id:this.entryId,part_id:t.id})!==null&&this._notifyChanged()}async _restock(t){let e=parseFloat(this._restockQty);if(!Number.isFinite(e)||e===0){this._restockInvalid=!0;return}this._restockInvalid=!1;let i=await this._send({type:"maintenance_supporter/part/restock",entry_id:this.entryId,part_id:t.id,delta:e});this._restockFor=null,i!==null&&(t.stock=i.stock,this.requestUpdate(),this._notifyChanged())}_identLine(t){return[t.vendor,t.mpn?`MPN: ${t.mpn}`:"",t.gtin?`GTIN: ${t.gtin}`:""].filter(Boolean).join(" \xB7 ")}_renderRow(t){let e=this._lang,i=t.stock!==null&&t.stock!==void 0,a=this._identLine(t),l=this._docsFor===t.id;return r`
<div class="part-row ${t.is_low?"low":""}">
<ha-icon class="part-icon" icon=${t.is_low?"mdi:cart-arrow-down":"mdi:package-variant-closed"}></ha-icon>
<div class="part-main">
@@ -2277,21 +2311,21 @@ ${A(n.notes)}</div>`:""}
font-size: 13px;
margin: 4px 0;
}
`,_([T({attribute:!1})],K.prototype,"hass",2),_([T({attribute:!1})],K.prototype,"entryId",2),_([T({attribute:!1})],K.prototype,"parts",2),_([T({type:Boolean})],K.prototype,"canWrite",2),_([T({attribute:!1})],K.prototype,"currencySymbol",2),_([m()],K.prototype,"_editing",2),_([m()],K.prototype,"_busy",2),_([m()],K.prototype,"_error",2),_([m()],K.prototype,"_restockFor",2),_([m()],K.prototype,"_restockQty",2),_([m()],K.prototype,"_restockInvalid",2),_([m()],K.prototype,"_docsFor",2);customElements.define("maintenance-parts-section",K);var G=class G extends L{constructor(){super(...arguments);this._ov=null;this._loading=!1;this._marking=!1;this._error="";this._history=null;this._rosterSort=G._storedSort();this._typeFilter=null;this._recorded=[];this._historyRequested=!1;this._localeReady=!1;this._markAll=async()=>{await this._mark(void 0)};this._repair=async()=>{if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/setup",language:this._lang}),await this._load()}catch(t){this._error=E(t,this._lang)}finally{this._marking=!1}}};this._loadHistory=async t=>{if(!(!t.target.open||this._historyRequested)){this._historyRequested=!0;try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview_history"});this._history=e.series}catch{this._history=null}}}}get _lang(){return this.hass?.language||"en"}connectedCallback(){super.connectedCallback(),this.hass&&this._load()}updated(t){t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()),this._ov===null&&!this._loading&&this._load())}async _load(){this._loading=!0,this._error="";try{this._ov=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview"})}catch(t){this._error=E(t,this._lang)}finally{this._loading=!1}}async _mark(t){if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/mark_replaced",...t?{entity_ids:t}:{}}),await this._load()}catch(e){this._error=E(e,this._lang)}finally{this._marking=!1}}}async _setExcluded(t,e){if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/set_excluded",entity_id:t,excluded:e}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._marking=!1}}}_sparkline(t){let e=this._history?.[t.entity_id];if(!e||e.points.length<2)return d;let i=110,a=24,l=2,h=e.points[0][0],c=e.points[e.points.length-1][0],p=Date.now()/1e3,u=t.status!=="low"&&t.predicted_source==="trend"&&t.days_until!=null?p+t.days_until*86400:null,g=Math.max(c,u??c),v=S=>g===h?l:l+(S-h)/(g-h)*(i-2*l),b=S=>l+(1-Math.min(100,Math.max(0,S))/100)*(a-2*l),x=e.points.map(([S,I])=>`${v(S).toFixed(1)},${b(I).toFixed(1)}`).join(" "),f=e.points[e.points.length-1][1],M=b(e.threshold).toFixed(1);return r`<svg
`,g([T({attribute:!1})],K.prototype,"hass",2),g([T({attribute:!1})],K.prototype,"entryId",2),g([T({attribute:!1})],K.prototype,"parts",2),g([T({type:Boolean})],K.prototype,"canWrite",2),g([T({attribute:!1})],K.prototype,"currencySymbol",2),g([m()],K.prototype,"_editing",2),g([m()],K.prototype,"_busy",2),g([m()],K.prototype,"_error",2),g([m()],K.prototype,"_restockFor",2),g([m()],K.prototype,"_restockQty",2),g([m()],K.prototype,"_restockInvalid",2),g([m()],K.prototype,"_docsFor",2);customElements.define("maintenance-parts-section",K);var G=class G extends L{constructor(){super(...arguments);this._ov=null;this._loading=!1;this._marking=!1;this._error="";this._history=null;this._rosterSort=G._storedSort();this._typeFilter=null;this._recorded=[];this._historyRequested=!1;this._localeReady=!1;this._markAll=async()=>{await this._mark(void 0)};this._repair=async()=>{if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/setup",language:this._lang}),await this._load()}catch(t){this._error=E(t,this._lang)}finally{this._marking=!1}}};this._loadHistory=async t=>{if(!(!t.target.open||this._historyRequested)){this._historyRequested=!0;try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview_history"});this._history=e.series}catch{this._history=null}}}}get _lang(){return this.hass?.language||"en"}connectedCallback(){super.connectedCallback(),this.hass&&this._load()}updated(t){t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()),this._ov===null&&!this._loading&&this._load())}async _load(){this._loading=!0,this._error="";try{this._ov=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview"})}catch(t){this._error=E(t,this._lang)}finally{this._loading=!1}}async _mark(t){if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/mark_replaced",...t?{entity_ids:t}:{}}),await this._load()}catch(e){this._error=E(e,this._lang)}finally{this._marking=!1}}}async _setExcluded(t,e){if(!this._marking){this._marking=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/set_excluded",entity_id:t,excluded:e}),await this._load()}catch(i){this._error=E(i,this._lang)}finally{this._marking=!1}}}_sparkline(t){let e=this._history?.[t.entity_id];if(!e||e.points.length<2)return d;let i=110,a=24,l=2,h=e.points[0][0],c=e.points[e.points.length-1][0],p=Date.now()/1e3,u=t.status!=="low"&&t.predicted_source==="trend"&&t.days_until!=null?p+t.days_until*86400:null,_=Math.max(c,u??c),v=M=>_===h?l:l+(M-h)/(_-h)*(i-2*l),b=M=>l+(1-Math.min(100,Math.max(0,M))/100)*(a-2*l),x=e.points.map(([M,I])=>`${v(M).toFixed(1)},${b(I).toFixed(1)}`).join(" "),f=e.points[e.points.length-1][1],S=b(e.threshold).toFixed(1);return r`<svg
class="bf-spark"
viewBox="0 0 ${i} ${a}"
role="img"
aria-label=${s("battery_fleet_sparkline_hint",this._lang)}
>
<title>${s("battery_fleet_sparkline_hint",this._lang)}</title>
<line class="bf-spark-th" x1="0" y1=${M} x2=${i} y2=${M}></line>
<line class="bf-spark-th" x1="0" y1=${S} x2=${i} y2=${S}></line>
<polyline class="bf-spark-line" points=${x}></polyline>
${u!==null?r`<line
class="bf-spark-proj"
x1=${v(c).toFixed(1)}
y1=${b(f).toFixed(1)}
x2=${v(u).toFixed(1)}
y2=${M}
y2=${S}
></line>`:d}
</svg>`}static _storedSort(){try{return localStorage.getItem(G._SORT_KEY)==="name"?"name":"urgency"}catch{return"urgency"}}_setSort(t){this._rosterSort=t;try{localStorage.setItem(G._SORT_KEY,t)}catch{}}_sortedRoster(t){let e=this._typeFilter===null?t:t.filter(a=>a.battery_type===this._typeFilter);if(this._rosterSort==="name")return e;let i=a=>a.status==="low"?-1e3+(a.level??101)/101:a.days_until??1/0;return[...e].sort((a,l)=>i(a)-i(l)||a.device_name.localeCompare(l.device_name))}_predictedDate(t){return this._fmtDate(Date.now()+t*864e5)}_fmtDate(t){return new Intl.DateTimeFormat(this._lang,{day:"numeric",month:"numeric",year:"numeric"}).format(new Date(t))}_shoppingLine(t){return Object.entries(t).map(([e,i])=>r`<button
class="bf-type-chip ${this._typeFilter===e?"bf-type-chip-active":""}"
@@ -2731,7 +2765,7 @@ ${A(n.notes)}</div>`:""}
border-radius: 10px;
padding: 1px 4px 1px 10px;
}
`,_([T({attribute:!1})],G.prototype,"hass",2),_([m()],G.prototype,"_ov",2),_([m()],G.prototype,"_loading",2),_([m()],G.prototype,"_marking",2),_([m()],G.prototype,"_error",2),_([m()],G.prototype,"_history",2),_([m()],G.prototype,"_rosterSort",2),_([m()],G.prototype,"_typeFilter",2),_([m()],G.prototype,"_recorded",2);var Gt=G;customElements.get("maintenance-battery-fleet-section")||customElements.define("maintenance-battery-fleet-section",Gt);var ge=5;function $t(n){let o=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),e=String(n.getDate()).padStart(2,"0");return`${o}-${t}-${e}`}function Ze(n,o){let t=[];for(let e=0;e<o;e++){let i=new Date(n);i.setDate(i.getDate()+e),i.setHours(0,0,0,0),t.push($t(i))}return t}function It(n,o){let[t,e,i]=n.split("-").map(Number),a=new Date(t,e-1,i);return a.setDate(a.getDate()+o),$t(a)}function Qe(n){if(!n||n.length===0)return null;let o=n.map(t=>t.cost).filter(t=>typeof t=="number");return o.length===0?null:o.reduce((t,e)=>t+e,0)/o.length}function Xe(n){let{windowStart:o,windowEnd:t,task:e,entryId:i,objectName:a}=n,l=[],h=(g,v)=>({date:g,entry_id:i,task_id:e.id,task_name:e.name,object_name:a,status:v&&(e.status==="overdue"||e.status==="triggered")?"ok":e.status,days_until_due:v?null:e.days_until_due??null,projected:v,schedule_type:e.schedule_type,interval_days:e.interval_days??null,interval_unit:e.interval_unit??null,responsible_user_id:e.responsible_user_id??null,avg_cost:Qe(e.history),adaptive_enabled:!!e.adaptive_config?.enabled,prediction_confidence:e.threshold_prediction_confidence??null}),c=Math.max(1,Math.round(Yt(e.interval_days,e.interval_unit)));if(e.status==="overdue"||e.status==="triggered"){if(l.push(h(o,!1)),e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=It(o,c),v=1;for(;g<=t&&v<ge;)l.push(h(g,!0)),v++,g=It(g,c)}return l}let p=e.next_due;if(typeof p!="string"||!p)return l;let u=p.slice(0,10);if(u>=o&&u<=t)l.push(h(u,!1));else if(u>t)return l;if(e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=It(u,c),v=l.length;for(;g<=t&&v<ge;)g>=o&&(l.push(h(g,!0)),v++),g=It(g,c)}return l}var me={overdue:0,triggered:1,due_soon:2,ok:3};function ve(n,o,t,e=null){let i=Ze(o,t),a=i[0],l=i[i.length-1],h=[];for(let p of n){let u=p.object?.name||"",g=p.entry_id,v=p.tasks||[];for(let b of v){if(e&&b.responsible_user_id!==e||b.enabled===!1)continue;let x=Xe({windowStart:a,windowEnd:l,task:b,entryId:g,objectName:u});h.push(...x)}}let c=new Map;for(let p of i)c.set(p,[]);for(let p of h){let u=c.get(p.date);u&&u.push(p)}for(let[,p]of c)p.sort((u,g)=>{let v=me[u.status]??99,b=me[g.status]??99;if(v!==b)return v-b;if(u.projected!==g.projected)return u.projected?1:-1;let x=u.object_name.localeCompare(g.object_name);return x!==0?x:u.task_name.localeCompare(g.task_name)});return i.map(p=>({date:p,events:c.get(p)??[]}))}var Je={completed:"ok",reset:"ok",skipped:"due_soon",triggered:"triggered",trigger_replaced:"triggered",trigger_removed:"ok"};function ti(n,o){let t=[];for(let e=o-1;e>=0;e--){let i=new Date(n);i.setDate(i.getDate()-e),i.setHours(0,0,0,0),t.push($t(i))}return t}function be(n,o,t,e=null){let i=ti(o,t),a=i[0],l=i[i.length-1],h=new Map;for(let p of i)h.set(p,[]);for(let p of n){let u=p.object?.name||"",g=p.entry_id,v=p.tasks||[];for(let b of v){if(e&&b.responsible_user_id!==e)continue;let x=b.history||[];for(let f of x){if(typeof f?.timestamp!="string")continue;let M=f.timestamp.slice(0,10);if(M<a||M>l)continue;let S=h.get(M);if(!S)continue;let I=f.type??"completed";S.push({date:M,entry_id:g,task_id:b.id,task_name:b.name,object_name:u,status:Je[I]??"ok",days_until_due:null,projected:!1,schedule_type:b.schedule_type,interval_days:b.interval_days??null,responsible_user_id:b.responsible_user_id??null,avg_cost:typeof f.cost=="number"?f.cost:null,adaptive_enabled:!!b.adaptive_config?.enabled,prediction_confidence:null,history_timestamp:f.timestamp,history_type:I,history_cost:typeof f.cost=="number"?f.cost:null,history_notes:typeof f.notes=="string"?f.notes:null,history_duration:typeof f.duration=="number"?f.duration:null})}}}let c={completed:0,reset:1,skipped:2,triggered:3,trigger_replaced:4};for(let[,p]of h)p.sort((u,g)=>{let v=c[u.history_type??""]??99,b=c[g.history_type??""]??99;if(v!==b)return v-b;let x=u.object_name.localeCompare(g.object_name);return x!==0?x:u.task_name.localeCompare(g.task_name)});return i.map(p=>({date:p,events:h.get(p)??[]}))}var fe=D`
`,g([T({attribute:!1})],G.prototype,"hass",2),g([m()],G.prototype,"_ov",2),g([m()],G.prototype,"_loading",2),g([m()],G.prototype,"_marking",2),g([m()],G.prototype,"_error",2),g([m()],G.prototype,"_history",2),g([m()],G.prototype,"_rosterSort",2),g([m()],G.prototype,"_typeFilter",2),g([m()],G.prototype,"_recorded",2);var Gt=G;customElements.get("maintenance-battery-fleet-section")||customElements.define("maintenance-battery-fleet-section",Gt);var _e=5;function $t(n){let o=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),e=String(n.getDate()).padStart(2,"0");return`${o}-${t}-${e}`}function Ze(n,o){let t=[];for(let e=0;e<o;e++){let i=new Date(n);i.setDate(i.getDate()+e),i.setHours(0,0,0,0),t.push($t(i))}return t}function It(n,o){let[t,e,i]=n.split("-").map(Number),a=new Date(t,e-1,i);return a.setDate(a.getDate()+o),$t(a)}function Qe(n){if(!n||n.length===0)return null;let o=n.map(t=>t.cost).filter(t=>typeof t=="number");return o.length===0?null:o.reduce((t,e)=>t+e,0)/o.length}function Xe(n){let{windowStart:o,windowEnd:t,task:e,entryId:i,objectName:a}=n,l=[],h=(_,v)=>({date:_,entry_id:i,task_id:e.id,task_name:e.name,object_name:a,status:v&&(e.status==="overdue"||e.status==="triggered")?"ok":e.status,days_until_due:v?null:e.days_until_due??null,projected:v,schedule_type:e.schedule_type,interval_days:e.interval_days??null,interval_unit:e.interval_unit??null,responsible_user_id:e.responsible_user_id??null,avg_cost:Qe(e.history),adaptive_enabled:!!e.adaptive_config?.enabled,prediction_confidence:e.threshold_prediction_confidence??null}),c=Math.max(1,Math.round(Yt(e.interval_days,e.interval_unit)));if(e.status==="overdue"||e.status==="triggered"){if(l.push(h(o,!1)),e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let _=It(o,c),v=1;for(;_<=t&&v<_e;)l.push(h(_,!0)),v++,_=It(_,c)}return l}let p=e.next_due;if(typeof p!="string"||!p)return l;let u=p.slice(0,10);if(u>=o&&u<=t)l.push(h(u,!1));else if(u>t)return l;if(e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let _=It(u,c),v=l.length;for(;_<=t&&v<_e;)_>=o&&(l.push(h(_,!0)),v++),_=It(_,c)}return l}var me={overdue:0,triggered:1,due_soon:2,ok:3};function ve(n,o,t,e=null){let i=Ze(o,t),a=i[0],l=i[i.length-1],h=[];for(let p of n){let u=p.object?.name||"",_=p.entry_id,v=p.tasks||[];for(let b of v){if(e&&b.responsible_user_id!==e||b.enabled===!1)continue;let x=Xe({windowStart:a,windowEnd:l,task:b,entryId:_,objectName:u});h.push(...x)}}let c=new Map;for(let p of i)c.set(p,[]);for(let p of h){let u=c.get(p.date);u&&u.push(p)}for(let[,p]of c)p.sort((u,_)=>{let v=me[u.status]??99,b=me[_.status]??99;if(v!==b)return v-b;if(u.projected!==_.projected)return u.projected?1:-1;let x=u.object_name.localeCompare(_.object_name);return x!==0?x:u.task_name.localeCompare(_.task_name)});return i.map(p=>({date:p,events:c.get(p)??[]}))}var Je={completed:"ok",reset:"ok",skipped:"due_soon",triggered:"triggered",trigger_replaced:"triggered",trigger_removed:"ok"};function ti(n,o){let t=[];for(let e=o-1;e>=0;e--){let i=new Date(n);i.setDate(i.getDate()-e),i.setHours(0,0,0,0),t.push($t(i))}return t}function be(n,o,t,e=null){let i=ti(o,t),a=i[0],l=i[i.length-1],h=new Map;for(let p of i)h.set(p,[]);for(let p of n){let u=p.object?.name||"",_=p.entry_id,v=p.tasks||[];for(let b of v){if(e&&b.responsible_user_id!==e)continue;let x=b.history||[];for(let f of x){if(typeof f?.timestamp!="string")continue;let S=f.timestamp.slice(0,10);if(S<a||S>l)continue;let M=h.get(S);if(!M)continue;let I=f.type??"completed";M.push({date:S,entry_id:_,task_id:b.id,task_name:b.name,object_name:u,status:Je[I]??"ok",days_until_due:null,projected:!1,schedule_type:b.schedule_type,interval_days:b.interval_days??null,responsible_user_id:b.responsible_user_id??null,avg_cost:typeof f.cost=="number"?f.cost:null,adaptive_enabled:!!b.adaptive_config?.enabled,prediction_confidence:null,history_timestamp:f.timestamp,history_type:I,history_cost:typeof f.cost=="number"?f.cost:null,history_notes:typeof f.notes=="string"?f.notes:null,history_duration:typeof f.duration=="number"?f.duration:null})}}}let c={completed:0,reset:1,skipped:2,triggered:3,trigger_replaced:4};for(let[,p]of h)p.sort((u,_)=>{let v=c[u.history_type??""]??99,b=c[_.history_type??""]??99;if(v!==b)return v-b;let x=u.object_name.localeCompare(_.object_name);return x!==0?x:u.task_name.localeCompare(_.task_name)});return i.map(p=>({date:p,events:h.get(p)??[]}))}var fe=D`
.cal-controls {
display: flex;
gap: 12px;
@@ -2928,24 +2962,24 @@ ${A(n.notes)}</div>`:""}
.cal-pill-day { font-size: 17px; }
.cal-user-filter { margin-left: 0; width: 100%; }
}
`;var X=class extends L{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"};this._objects=[];this._stats=null;this._windowDays=30;this._pastDays=0;this._userFilter="";this._objectFilter="";this._configuredObjects=[];this._unsub=null;this._dataLoaded=!1;this._lastConnection=null}static getConfigElement(){return document.createElement("maintenance-supporter-calendar-card-editor")}static getStubConfig(){return{type:"custom:maintenance-supporter-calendar-card",window_days:30,show_window_chips:!0,show_user_filter:!0}}setConfig(t){if(this._config={...t},t.past_days&&[30,90].includes(t.past_days)?this._pastDays=t.past_days:t.window_days&&[7,14,30,365].includes(t.window_days)&&(this._windowDays=t.window_days,this._pastDays=0),typeof t.user_filter=="string"&&(this._userFilter=t.user_filter),typeof t.object_filter=="string")this._objectFilter=t.object_filter,this._configuredObjects=[];else if(Array.isArray(t.object_filter)){let e=t.object_filter.filter(i=>typeof i=="string"&&i!=="");this._objectFilter=e.length===1?e[0]:"",this._configuredObjects=e.length>1?e:[]}}getCardSize(){return 6}get _lang(){return this.hass?.language||"en"}disconnectedCallback(){if(super.disconnectedCallback(),this._unsub){try{this._unsub()}catch{}this._unsub=null}this._dataLoaded=!1,this._lastConnection=null}updated(t){super.updated(t),t.has("hass")&&Et(this.hass?.locale);let e=this.hass?.language;if(e&&!St(e)&&q(e).then(()=>this.requestUpdate()),t.has("hass")&&this.hass){if(!this._dataLoaded)this._dataLoaded=!0,this._lastConnection=this.hass.connection,this._loadData(),this._subscribe();else if(this.hass.connection!==this._lastConnection){if(this._lastConnection=this.hass.connection,this._unsub){try{this._unsub()}catch{}this._unsub=null}this._subscribe(),this._loadData()}}}async _loadData(){try{let[t,e]=await Promise.all([this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects"}),this.hass.connection.sendMessagePromise({type:"maintenance_supporter/statistics"})]);this._objects=t.objects,this._stats=e}catch{}}async _subscribe(){try{let t=await this.hass.connection.subscribeMessage(e=>{let i=e;this._objects=i.objects},{type:"maintenance_supporter/subscribe"});if(!this.isConnected){t();return}this._unsub=t}catch{}}_onEventClick(t){if(t.history_timestamp){this.dispatchEvent(new CustomEvent("ll-custom",{detail:{type:"maintenance-supporter:edit-history",entry_id:t.entry_id,task_id:t.task_id,original_timestamp:t.history_timestamp},bubbles:!0,composed:!0}));return}this.dispatchEvent(new CustomEvent("ll-custom",{detail:{type:"maintenance-supporter:open-task",entry_id:t.entry_id,task_id:t.task_id},bubbles:!0,composed:!0}))}render(){if(!this.hass)return d;let t=this._lang,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.title,l=null;this._userFilter&&(l=this._userFilter==="current_user"?this.hass?.user?.id??null:this._userFilter);let h=y=>{let N=y.toLowerCase();return this._objects.find(H=>H.entry_id===y||H.object.name.toLowerCase()===N)?.entry_id??null},c=new Set(this._configuredObjects.map(h).filter(y=>y!==null)),p=c.size?this._objects.filter(y=>c.has(y.entry_id)):this._objects,u=this._config.show_object_filter!==!1&&p.length>1,g=this._objectFilter?h(this._objectFilter):null,v=g&&p.some(y=>y.entry_id===g)?p.filter(y=>y.entry_id===g):p,b=new Date;b.setHours(0,0,0,0);let x=this._pastDays>0,f=x?be(v,b,this._pastDays,l):ve(v,b,this._windowDays,l),M=$t(b),S=this._windowDays===365||x,I=S?f.filter(y=>y.events.length>0):f,R=y=>{let N=`cal-status-${y.status}`,W=y.projected?"cal-event-projected":"",H=y.status==="overdue"&&y.days_until_due!=null?` (${_t(y.days_until_due,t)})`:"",O=y.projected&&y.interval_days?r`<span class="cal-event-recur">${y.interval_unit&&y.interval_unit!=="days"?`${y.interval_days} ${s("unit_"+y.interval_unit,t)}`:s("cal_every_n_days",t).replace("{n}",String(y.interval_days))}</span>`:d,Z=y.schedule_type==="sensor_based",st=Z?r`<ha-icon class="cal-event-icon cal-source-sensor"
`;var X=class extends L{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"};this._objects=[];this._stats=null;this._windowDays=30;this._pastDays=0;this._userFilter="";this._objectFilter="";this._configuredObjects=[];this._unsub=null;this._dataLoaded=!1;this._lastConnection=null}static getConfigElement(){return document.createElement("maintenance-supporter-calendar-card-editor")}static getStubConfig(){return{type:"custom:maintenance-supporter-calendar-card",window_days:30,show_window_chips:!0,show_user_filter:!0}}setConfig(t){if(this._config={...t},t.past_days&&[30,90].includes(t.past_days)?this._pastDays=t.past_days:t.window_days&&[7,14,30,365].includes(t.window_days)&&(this._windowDays=t.window_days,this._pastDays=0),typeof t.user_filter=="string"&&(this._userFilter=t.user_filter),typeof t.object_filter=="string")this._objectFilter=t.object_filter,this._configuredObjects=[];else if(Array.isArray(t.object_filter)){let e=t.object_filter.filter(i=>typeof i=="string"&&i!=="");this._objectFilter=e.length===1?e[0]:"",this._configuredObjects=e.length>1?e:[]}}getCardSize(){return 6}get _lang(){return this.hass?.language||"en"}disconnectedCallback(){if(super.disconnectedCallback(),this._unsub){try{this._unsub()}catch{}this._unsub=null}this._dataLoaded=!1,this._lastConnection=null}updated(t){super.updated(t),t.has("hass")&&Et(this.hass?.locale);let e=this.hass?.language;if(e&&!Mt(e)&&q(e).then(()=>this.requestUpdate()),t.has("hass")&&this.hass){if(!this._dataLoaded)this._dataLoaded=!0,this._lastConnection=this.hass.connection,this._loadData(),this._subscribe();else if(this.hass.connection!==this._lastConnection){if(this._lastConnection=this.hass.connection,this._unsub){try{this._unsub()}catch{}this._unsub=null}this._subscribe(),this._loadData()}}}async _loadData(){try{let[t,e]=await Promise.all([this.hass.connection.sendMessagePromise({type:"maintenance_supporter/objects"}),this.hass.connection.sendMessagePromise({type:"maintenance_supporter/statistics"})]);this._objects=t.objects,this._stats=e}catch{}}async _subscribe(){try{let t=await this.hass.connection.subscribeMessage(e=>{let i=e;this._objects=i.objects},{type:"maintenance_supporter/subscribe"});if(!this.isConnected){t();return}this._unsub=t}catch{}}_onEventClick(t){if(t.history_timestamp){this.dispatchEvent(new CustomEvent("ll-custom",{detail:{type:"maintenance-supporter:edit-history",entry_id:t.entry_id,task_id:t.task_id,original_timestamp:t.history_timestamp},bubbles:!0,composed:!0}));return}this.dispatchEvent(new CustomEvent("ll-custom",{detail:{type:"maintenance-supporter:open-task",entry_id:t.entry_id,task_id:t.task_id},bubbles:!0,composed:!0}))}render(){if(!this.hass)return d;let t=this._lang,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.title,l=null;this._userFilter&&(l=this._userFilter==="current_user"?this.hass?.user?.id??null:this._userFilter);let h=y=>{let U=y.toLowerCase();return this._objects.find(H=>H.entry_id===y||H.object.name.toLowerCase()===U)?.entry_id??null},c=new Set(this._configuredObjects.map(h).filter(y=>y!==null)),p=c.size?this._objects.filter(y=>c.has(y.entry_id)):this._objects,u=this._config.show_object_filter!==!1&&p.length>1,_=this._objectFilter?h(this._objectFilter):null,v=_&&p.some(y=>y.entry_id===_)?p.filter(y=>y.entry_id===_):p,b=new Date;b.setHours(0,0,0,0);let x=this._pastDays>0,f=x?be(v,b,this._pastDays,l):ve(v,b,this._windowDays,l),S=$t(b),M=this._windowDays===365||x,I=M?f.filter(y=>y.events.length>0):f,R=y=>{let U=`cal-status-${y.status}`,W=y.projected?"cal-event-projected":"",H=y.status==="overdue"&&y.days_until_due!=null?` (${gt(y.days_until_due,t)})`:"",O=y.projected&&y.interval_days?r`<span class="cal-event-recur">${y.interval_unit&&y.interval_unit!=="days"?`${y.interval_days} ${s("unit_"+y.interval_unit,t)}`:s("cal_every_n_days",t).replace("{n}",String(y.interval_days))}</span>`:d,Z=y.schedule_type==="sensor_based",st=Z?r`<ha-icon class="cal-event-icon cal-source-sensor"
title="${s("cal_source_sensor",t)}" icon="mdi:trending-up"></ha-icon>`:r`<ha-icon class="cal-event-icon cal-source-time"
title="${y.adaptive_enabled?s("cal_source_time_adaptive",t):s("cal_source_time",t)}"
icon="${y.adaptive_enabled?"mdi:clock-time-four-outline":"mdi:clock-outline"}"></ha-icon>`,rt=Z&&y.prediction_confidence&&y.status!=="triggered"&&!y.projected?r`<span class="cal-event-prediction cal-conf-${y.prediction_confidence}">
${s("cal_predicted",t)} · ${s(`cal_confidence_${y.prediction_confidence}`,t)}
</span>`:d,U=this._stats?.budget?.currency_symbol||ut,w=y.history_type?s(y.history_type,t):s(y.status,t);return r`
</span>`:d,N=this._stats?.budget?.currency_symbol||ut,w=y.history_type?s(y.history_type,t):s(y.status,t);return r`
<div class="cal-event ${W}"
@click=${()=>this._onEventClick(y)}>
${st}
<span class="cal-status-pill ${N}">${w}</span>
<span class="cal-status-pill ${U}">${w}</span>
<div class="cal-event-body">
<div class="cal-event-title">${y.object_name} · ${y.task_name}${H}</div>
${rt}
${O}
</div>
${y.avg_cost!=null&&y.avg_cost>0?r`<span class="cal-event-cost">${y.avg_cost.toFixed(0)} ${U}</span>`:d}
${y.avg_cost!=null&&y.avg_cost>0?r`<span class="cal-event-cost">${y.avg_cost.toFixed(0)} ${N}</span>`:d}
</div>
`},j=y=>{let[N,W,H]=y.date.split("-").map(Number),O=new Date(N,W-1,H),Z=y.date===M,st=O.toLocaleDateString(t,{weekday:"short"}),rt=O.toLocaleDateString(t,{month:"long"});return r`
`},j=y=>{let[U,W,H]=y.date.split("-").map(Number),O=new Date(U,W-1,H),Z=y.date===S,st=O.toLocaleDateString(t,{weekday:"short"}),rt=O.toLocaleDateString(t,{month:"long"});return r`
<div class="cal-day-row">
<div class="cal-day-pill ${Z?"cal-today":""}">
<span class="cal-pill-weekday">${st}</span>
@@ -2992,22 +3026,22 @@ ${A(n.notes)}</div>`:""}
`:d}
${u?r`
<select class="cal-user-filter"
.value=${g??""}
.value=${_??""}
@change=${y=>{this._objectFilter=y.target.value}}>
<option value="">${s("all_objects",t)}</option>
${[...p].sort((y,N)=>y.object.name.localeCompare(N.object.name)).map(y=>r`<option value=${y.entry_id} ?selected=${y.entry_id===g}>${y.object.name}</option>`)}
${[...p].sort((y,U)=>y.object.name.localeCompare(U.object.name)).map(y=>r`<option value=${y.entry_id} ?selected=${y.entry_id===_}>${y.object.name}</option>`)}
</select>
`:d}
</div>
`:d}
<div class="cal-rolling">
${I.length===0&&S?r`<div class="cal-empty">${s("cal_no_events",t)}</div>`:I.map(j)}
${I.length===0&&M?r`<div class="cal-empty">${s("cal_no_events",t)}</div>`:I.map(j)}
</div>
</ha-card>
`}};X.styles=[Lt,fe,D`
:host { display: block; }
ha-card { padding: 0; overflow: hidden; }
`],_([T({attribute:!1})],X.prototype,"hass",2),_([m()],X.prototype,"_config",2),_([m()],X.prototype,"_objects",2),_([m()],X.prototype,"_stats",2),_([m()],X.prototype,"_windowDays",2),_([m()],X.prototype,"_pastDays",2),_([m()],X.prototype,"_userFilter",2),_([m()],X.prototype,"_objectFilter",2),_([m()],X.prototype,"_unsub",2);var ei=[{value:7,label:"Week (7 days)"},{value:14,label:"Fortnight (14 days)"},{value:30,label:"Month (30 days, default)"},{value:365,label:"Year (365 days, empty days collapsed)"}],bt=class extends L{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"}}setConfig(t){this._config={...t}}_valueChanged(t,e){let i={...this._config,[t]:e};t==="show_window_chips"&&e===!0&&delete i.show_window_chips,t==="show_user_filter"&&e===!0&&delete i.show_user_filter,t==="show_object_filter"&&e===!0&&delete i.show_object_filter,t==="title"&&(!e||typeof e=="string"&&e.trim()==="")&&delete i.title,t==="user_filter"&&e===""&&delete i.user_filter,this._config=i,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:i},bubbles:!0,composed:!0}))}render(){let t=this._config.window_days??30,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.user_filter??"",l=this._config.title??"";return r`
`],g([T({attribute:!1})],X.prototype,"hass",2),g([m()],X.prototype,"_config",2),g([m()],X.prototype,"_objects",2),g([m()],X.prototype,"_stats",2),g([m()],X.prototype,"_windowDays",2),g([m()],X.prototype,"_pastDays",2),g([m()],X.prototype,"_userFilter",2),g([m()],X.prototype,"_objectFilter",2),g([m()],X.prototype,"_unsub",2);var ei=[{value:7,label:"Week (7 days)"},{value:14,label:"Fortnight (14 days)"},{value:30,label:"Month (30 days, default)"},{value:365,label:"Year (365 days, empty days collapsed)"}],bt=class extends L{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"}}setConfig(t){this._config={...t}}_valueChanged(t,e){let i={...this._config,[t]:e};t==="show_window_chips"&&e===!0&&delete i.show_window_chips,t==="show_user_filter"&&e===!0&&delete i.show_user_filter,t==="show_object_filter"&&e===!0&&delete i.show_object_filter,t==="title"&&(!e||typeof e=="string"&&e.trim()==="")&&delete i.title,t==="user_filter"&&e===""&&delete i.user_filter,this._config=i,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:i},bubbles:!0,composed:!0}))}render(){let t=this._config.window_days??30,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.user_filter??"",l=this._config.title??"";return r`
<div class="editor">
<div class="row">
<label for="title">Title (optional)</label>
@@ -3099,7 +3133,7 @@ ${A(n.notes)}</div>`:""}
font-size: 12px;
color: var(--secondary-text-color, #666);
}
`,_([T({attribute:!1})],bt.prototype,"hass",2),_([m()],bt.prototype,"_config",2);customElements.get("maintenance-supporter-calendar-card")||customElements.define("maintenance-supporter-calendar-card",X);customElements.get("maintenance-supporter-calendar-card-editor")||customElements.define("maintenance-supporter-calendar-card-editor",bt);var Ht=window;Ht.customCards=Ht.customCards||[];var ye="maintenance-supporter-calendar-card",ii=Ht.customCards.some(n=>n.type===ye);ii||Ht.customCards.push({type:ye,name:"Maintenance Supporter \u2014 Calendar",description:"Rolling calendar of maintenance tasks with 7/14/30/365 day windows, source icons, and prediction-confidence pills.",preview:!0});var dt=class extends L{constructor(){super(...arguments);this._open=!1;this._saving=!1;this._error="";this._draft=null;this._originalSnapshot=null}get _lang(){return this.hass?.language||"en"}openEdit(t){this._draft={...t},this._originalSnapshot={...t},this._error="",this._open=!0}close(){this._open=!1,this._error="",this._draft=null,this._originalSnapshot=null}_set(t,e){this._draft&&(this._draft={...this._draft,[t]:e})}async _save(){if(!(!this._draft||!this._originalSnapshot)){this._saving=!0,this._error="";try{let t={type:"maintenance_supporter/task/history/update",entry_id:this._draft.entry_id,task_id:this._draft.task_id,original_timestamp:this._originalSnapshot.original_timestamp};if(this._draft.timestamp!==this._originalSnapshot.timestamp&&(t.timestamp=this._draft.timestamp),this._draft.notes!==this._originalSnapshot.notes&&(t.notes=this._draft.notes),this._draft.cost!==this._originalSnapshot.cost&&(t.cost=this._draft.cost),this._draft.duration!==this._originalSnapshot.duration&&(t.duration=this._draft.duration),this._draft.completed_by!==this._originalSnapshot.completed_by&&(t.completed_by=this._draft.completed_by),Object.keys(t).filter(i=>!["type","entry_id","task_id","original_timestamp"].includes(i)).length===0){this.close();return}await this.hass.connection.sendMessagePromise(t),this.dispatchEvent(new CustomEvent("history-entry-saved",{detail:{entry_id:this._draft.entry_id,task_id:this._draft.task_id,new_timestamp:this._draft.timestamp},bubbles:!0,composed:!0})),this.close()}catch(t){this._error=E(t,this._lang)}finally{this._saving=!1}}}render(){if(!this._open||!this._draft)return d;let t=this._lang,e=this._draft;return r`
`,g([T({attribute:!1})],bt.prototype,"hass",2),g([m()],bt.prototype,"_config",2);customElements.get("maintenance-supporter-calendar-card")||customElements.define("maintenance-supporter-calendar-card",X);customElements.get("maintenance-supporter-calendar-card-editor")||customElements.define("maintenance-supporter-calendar-card-editor",bt);var Ht=window;Ht.customCards=Ht.customCards||[];var ye="maintenance-supporter-calendar-card",ii=Ht.customCards.some(n=>n.type===ye);ii||Ht.customCards.push({type:ye,name:"Maintenance Supporter \u2014 Calendar",description:"Rolling calendar of maintenance tasks with 7/14/30/365 day windows, source icons, and prediction-confidence pills.",preview:!0});var dt=class extends L{constructor(){super(...arguments);this._open=!1;this._saving=!1;this._error="";this._draft=null;this._originalSnapshot=null}get _lang(){return this.hass?.language||"en"}openEdit(t){this._draft={...t},this._originalSnapshot={...t},this._error="",this._open=!0}close(){this._open=!1,this._error="",this._draft=null,this._originalSnapshot=null}_set(t,e){this._draft&&(this._draft={...this._draft,[t]:e})}async _save(){if(!(!this._draft||!this._originalSnapshot)){this._saving=!0,this._error="";try{let t={type:"maintenance_supporter/task/history/update",entry_id:this._draft.entry_id,task_id:this._draft.task_id,original_timestamp:this._originalSnapshot.original_timestamp};if(this._draft.timestamp!==this._originalSnapshot.timestamp&&(t.timestamp=this._draft.timestamp),this._draft.notes!==this._originalSnapshot.notes&&(t.notes=this._draft.notes),this._draft.cost!==this._originalSnapshot.cost&&(t.cost=this._draft.cost),this._draft.duration!==this._originalSnapshot.duration&&(t.duration=this._draft.duration),this._draft.completed_by!==this._originalSnapshot.completed_by&&(t.completed_by=this._draft.completed_by),Object.keys(t).filter(i=>!["type","entry_id","task_id","original_timestamp"].includes(i)).length===0){this.close();return}await this.hass.connection.sendMessagePromise(t),this.dispatchEvent(new CustomEvent("history-entry-saved",{detail:{entry_id:this._draft.entry_id,task_id:this._draft.task_id,new_timestamp:this._draft.timestamp},bubbles:!0,composed:!0})),this.close()}catch(t){this._error=E(t,this._lang)}finally{this._saving=!1}}}render(){if(!this._open||!this._draft)return d;let t=this._lang,e=this._draft;return r`
<div class="backdrop" @click=${this.close}></div>
<div class="dialog" role="dialog" aria-modal="true">
<h2>${s("history_edit_title",t)||"Edit history entry"}</h2>
@@ -3206,7 +3240,7 @@ ${A(n.notes)}</div>`:""}
background: rgba(211,47,47,0.1);
border-radius: 6px;
}
`,_([T({attribute:!1})],dt.prototype,"hass",2),_([m()],dt.prototype,"_open",2),_([m()],dt.prototype,"_saving",2),_([m()],dt.prototype,"_error",2),_([m()],dt.prototype,"_draft",2);customElements.get("maintenance-history-edit-dialog")||customElements.define("maintenance-history-edit-dialog",dt);var J=class extends L{constructor(){super(...arguments);this._open=!1;this._title="";this._message="";this._confirmText="";this._danger=!1;this._inputLabel="";this._inputType="";this._inputValue="";this._resolve=null;this._promptResolve=null}confirm(t){return this._title=t.title,this._message=t.message,this._confirmText=t.confirmText||"OK",this._danger=t.danger||!1,this._inputLabel="",this._inputType="",this._inputValue="",this._open=!0,new Promise(e=>{this._resolve=e,this._promptResolve=null})}prompt(t){return this._title=t.title,this._message=t.message,this._confirmText=t.confirmText||"OK",this._danger=t.danger||!1,this._inputLabel=t.inputLabel||"",this._inputType=t.inputType||"text",this._inputValue=t.inputValue||"",this._open=!0,new Promise(e=>{this._promptResolve=e,this._resolve=null})}_cancel(){this._open=!1,this._promptResolve&&(this._promptResolve({confirmed:!1,value:""}),this._promptResolve=null),this._resolve?.(!1),this._resolve=null}_confirmAction(){this._open=!1,this._promptResolve&&(this._promptResolve({confirmed:!0,value:this._inputValue}),this._promptResolve=null),this._resolve?.(!0),this._resolve=null}render(){if(!this._open)return d;let t=this.hass?.language||"en";return r`
`,g([T({attribute:!1})],dt.prototype,"hass",2),g([m()],dt.prototype,"_open",2),g([m()],dt.prototype,"_saving",2),g([m()],dt.prototype,"_error",2),g([m()],dt.prototype,"_draft",2);customElements.get("maintenance-history-edit-dialog")||customElements.define("maintenance-history-edit-dialog",dt);var J=class extends L{constructor(){super(...arguments);this._open=!1;this._title="";this._message="";this._confirmText="";this._danger=!1;this._inputLabel="";this._inputType="";this._inputValue="";this._resolve=null;this._promptResolve=null}confirm(t){return this._title=t.title,this._message=t.message,this._confirmText=t.confirmText||"OK",this._danger=t.danger||!1,this._inputLabel="",this._inputType="",this._inputValue="",this._open=!0,new Promise(e=>{this._resolve=e,this._promptResolve=null})}prompt(t){return this._title=t.title,this._message=t.message,this._confirmText=t.confirmText||"OK",this._danger=t.danger||!1,this._inputLabel=t.inputLabel||"",this._inputType=t.inputType||"text",this._inputValue=t.inputValue||"",this._open=!0,new Promise(e=>{this._promptResolve=e,this._resolve=null})}_cancel(){this._open=!1,this._promptResolve&&(this._promptResolve({confirmed:!1,value:""}),this._promptResolve=null),this._resolve?.(!1),this._resolve=null}_confirmAction(){this._open=!1,this._promptResolve&&(this._promptResolve({confirmed:!0,value:this._inputValue}),this._promptResolve=null),this._resolve?.(!0),this._resolve=null}render(){if(!this._open)return d;let t=this.hass?.language||"en";return r`
<ha-dialog open @closed=${this._cancel}>
<div class="dialog-title">${this._title}</div>
<div class="content">
@@ -3267,7 +3301,7 @@ ${A(n.notes)}</div>`:""}
ha-button.danger {
--mdc-theme-primary: var(--error-color, #f44336);
}
`],_([T({attribute:!1})],J.prototype,"hass",2),_([m()],J.prototype,"_open",2),_([m()],J.prototype,"_title",2),_([m()],J.prototype,"_message",2),_([m()],J.prototype,"_confirmText",2),_([m()],J.prototype,"_danger",2),_([m()],J.prototype,"_inputLabel",2),_([m()],J.prototype,"_inputType",2),_([m()],J.prototype,"_inputValue",2);customElements.get("maintenance-confirm-dialog")||customElements.define("maintenance-confirm-dialog",J);var tt=class extends L{constructor(){super(...arguments);this.objects=[];this._summary=null;this._loaded=!1;this._busy=!1;this._error="";this._query="";this._results=[];this._expanded=!1;this._initiallyLoaded=!1;this._searchTimer=0}get _lang(){return this.hass?.language||"en"}updated(t){super.updated(t),t.has("hass")&&this.hass&&!this._initiallyLoaded&&(this._initiallyLoaded=!0,this._load(),q(this._lang).then(()=>this.requestUpdate()))}async _load(){this._busy=!0;try{this._summary=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/storage"}),this._error=""}catch(t){this._error=E(t,this._lang)}finally{this._loaded=!0,this._busy=!1}}_nameFor(t){return this.objects.find(i=>i.object?.id===t)?.object?.name||t.slice(0,8)}_entryFor(t){return this.objects.find(e=>e.object?.id===t)?.entry_id}_toggle(){this._expanded=!this._expanded}_openObject(t){this.dispatchEvent(new CustomEvent("open-object",{detail:{entry_id:t},bubbles:!0,composed:!0}))}_onSearch(t){this._query=t.target.value,clearTimeout(this._searchTimer),this._searchTimer=window.setTimeout(()=>{this._doSearch()},250)}async _doSearch(){let t=this._query.trim();if(!t){this._results=[];return}try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/search",query:t});this._results=e.results||[]}catch(e){this._error=E(e,this._lang),this._results=[]}}async _openResult(t){if(t.kind==="weblink"){window.open(t.url,"_blank","noopener");return}let e=window.open("about:blank","_blank");try{let i=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:300});e&&(e.location.href=new URL(i.path,window.location.origin).href)}catch(i){e&&e.close(),this._error=E(i,this._lang)}}_renderResult(t,e){return r`
`],g([T({attribute:!1})],J.prototype,"hass",2),g([m()],J.prototype,"_open",2),g([m()],J.prototype,"_title",2),g([m()],J.prototype,"_message",2),g([m()],J.prototype,"_confirmText",2),g([m()],J.prototype,"_danger",2),g([m()],J.prototype,"_inputLabel",2),g([m()],J.prototype,"_inputType",2),g([m()],J.prototype,"_inputValue",2);customElements.get("maintenance-confirm-dialog")||customElements.define("maintenance-confirm-dialog",J);var tt=class extends L{constructor(){super(...arguments);this.objects=[];this._summary=null;this._loaded=!1;this._busy=!1;this._error="";this._query="";this._results=[];this._expanded=!1;this._initiallyLoaded=!1;this._searchTimer=0}get _lang(){return this.hass?.language||"en"}updated(t){super.updated(t),t.has("hass")&&this.hass&&!this._initiallyLoaded&&(this._initiallyLoaded=!0,this._load(),q(this._lang).then(()=>this.requestUpdate()))}async _load(){this._busy=!0;try{this._summary=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/storage"}),this._error=""}catch(t){this._error=E(t,this._lang)}finally{this._loaded=!0,this._busy=!1}}_nameFor(t){return this.objects.find(i=>i.object?.id===t)?.object?.name||t.slice(0,8)}_entryFor(t){return this.objects.find(e=>e.object?.id===t)?.entry_id}_toggle(){this._expanded=!this._expanded}_openObject(t){this.dispatchEvent(new CustomEvent("open-object",{detail:{entry_id:t},bubbles:!0,composed:!0}))}_onSearch(t){this._query=t.target.value,clearTimeout(this._searchTimer),this._searchTimer=window.setTimeout(()=>{this._doSearch()},250)}async _doSearch(){let t=this._query.trim();if(!t){this._results=[];return}try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/search",query:t});this._results=e.results||[]}catch(e){this._error=E(e,this._lang),this._results=[]}}async _openResult(t){if(t.kind==="weblink"){window.open(t.url,"_blank","noopener");return}let e=window.open("about:blank","_blank");try{let i=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${t.id}`,expires:300});e&&(e.location.href=new URL(i.path,window.location.origin).href)}catch(i){e&&e.close(),this._error=E(i,this._lang)}}_renderResult(t,e){return r`
<div class="obj-row result-row" title=${s("doc_open",e)} @click=${()=>this._openResult(t)}>
<ha-icon icon=${t.kind==="weblink"?"mdi:link-variant":"mdi:file-document-outline"}></ha-icon>
<div class="result-info">
@@ -3425,7 +3459,7 @@ ${A(n.notes)}</div>`:""}
.icon-btn:hover { background: var(--secondary-background-color, rgba(0,0,0,0.06)); }
.icon-btn[disabled] { opacity: 0.4; pointer-events: none; }
.error { color: var(--error-color, #f44336); font-size: 13px; margin-top: 6px; }
`,_([T({attribute:!1})],tt.prototype,"hass",2),_([T({attribute:!1})],tt.prototype,"objects",2),_([m()],tt.prototype,"_summary",2),_([m()],tt.prototype,"_loaded",2),_([m()],tt.prototype,"_busy",2),_([m()],tt.prototype,"_error",2),_([m()],tt.prototype,"_query",2),_([m()],tt.prototype,"_results",2),_([m()],tt.prototype,"_expanded",2);customElements.get("maintenance-storage-section-card")||customElements.define("maintenance-storage-section-card",tt);var si=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"],at=class extends L{constructor(){super(...arguments);this._open=!1;this._loading=!1;this._error="";this._entryId="";this._taskId="";this._values=new Array(12).fill("");this._save=async()=>{let t=this._buildOverrides();if(t!==null){this._loading=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:t}),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved"))}catch(e){this._error=E(e,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}};this._clearAll=async()=>{this._loading=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:{}}),this._values=new Array(12).fill(""),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved"))}catch(t){this._error=E(t,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}}get _lang(){return this.hass?.language??navigator.language.split("-")[0]??"en"}open(t,e,i){if(this._entryId=t,this._taskId=e,this._values=new Array(12).fill(""),i)for(let[a,l]of Object.entries(i)){let h=parseInt(a,10);h>=1&&h<=12&&typeof l=="number"&&(this._values[h-1]=l.toString())}this._error="",this._open=!0}_close(){this._open=!1}_buildOverrides(){let t={};for(let e=0;e<12;e++){let i=this._values[e].trim();if(!i)continue;let a=parseFloat(i);if(Number.isNaN(a))return this._error=`${s("month_"+["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"][e],this._lang)}: ${s("seasonal_override_invalid",this._lang)}`,null;if(a<.1||a>5)return this._error=s("seasonal_override_range",this._lang),null;t[e+1]=a}return t}render(){if(!this._open)return r``;let t=this._lang;return r`
`,g([T({attribute:!1})],tt.prototype,"hass",2),g([T({attribute:!1})],tt.prototype,"objects",2),g([m()],tt.prototype,"_summary",2),g([m()],tt.prototype,"_loaded",2),g([m()],tt.prototype,"_busy",2),g([m()],tt.prototype,"_error",2),g([m()],tt.prototype,"_query",2),g([m()],tt.prototype,"_results",2),g([m()],tt.prototype,"_expanded",2);customElements.get("maintenance-storage-section-card")||customElements.define("maintenance-storage-section-card",tt);var si=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"],at=class extends L{constructor(){super(...arguments);this._open=!1;this._loading=!1;this._error="";this._entryId="";this._taskId="";this._values=new Array(12).fill("");this._save=async()=>{let t=this._buildOverrides();if(t!==null){this._loading=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:t}),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved"))}catch(e){this._error=E(e,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}};this._clearAll=async()=>{this._loading=!0,this._error="";try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:{}}),this._values=new Array(12).fill(""),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved"))}catch(t){this._error=E(t,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}}get _lang(){return this.hass?.language??navigator.language.split("-")[0]??"en"}open(t,e,i){if(this._entryId=t,this._taskId=e,this._values=new Array(12).fill(""),i)for(let[a,l]of Object.entries(i)){let h=parseInt(a,10);h>=1&&h<=12&&typeof l=="number"&&(this._values[h-1]=l.toString())}this._error="",this._open=!0}_close(){this._open=!1}_buildOverrides(){let t={};for(let e=0;e<12;e++){let i=this._values[e].trim();if(!i)continue;let a=parseFloat(i);if(Number.isNaN(a))return this._error=`${s("month_"+["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"][e],this._lang)}: ${s("seasonal_override_invalid",this._lang)}`,null;if(a<.1||a>5)return this._error=s("seasonal_override_range",this._lang),null;t[e+1]=a}return t}render(){if(!this._open)return r``;let t=this._lang;return r`
<ha-dialog open @closed=${this._close} heading="${s("seasonal_overrides_title",t)}">
<div class="content">
<p class="hint">${s("seasonal_overrides_hint",t)}</p>
@@ -3500,7 +3534,7 @@ ${A(n.notes)}</div>`:""}
padding-top: 16px;
}
.spacer { flex: 1; }
`,_([T({attribute:!1})],at.prototype,"hass",2),_([m()],at.prototype,"_open",2),_([m()],at.prototype,"_loading",2),_([m()],at.prototype,"_error",2),_([m()],at.prototype,"_entryId",2),_([m()],at.prototype,"_taskId",2),_([m()],at.prototype,"_values",2);customElements.get("maintenance-seasonal-overrides-dialog")||customElements.define("maintenance-seasonal-overrides-dialog",at);var et=class extends L{constructor(){super(...arguments);this.objects=[];this._open=!1;this._loading=!1;this._error="";this._groupId=null;this._name="";this._description="";this._selected=new Set;this._toggleTask=(t,e)=>{let i=`${t}:${e}`,a=new Set(this._selected);a.has(i)?a.delete(i):a.add(i),this._selected=a};this._save=async()=>{let t=this._name.trim();if(!t){this._error=s("group_name_required",this._lang);return}this._loading=!0,this._error="";try{let e=this._buildTaskRefs();this._groupId?await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/update",group_id:this._groupId,name:t,description:this._description,task_refs:e}):await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/create",name:t,description:this._description,task_refs:e}),this._open=!1,this.dispatchEvent(new CustomEvent("group-saved"))}catch(e){this._error=E(e,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}}get _lang(){return this.hass?.language??navigator.language.split("-")[0]??"en"}openCreate(){this._reset(),this._open=!0}openEdit(t,e){this._reset(),this._groupId=t,this._name=e.name,this._description=e.description||"",this._selected=new Set(e.task_refs.map(i=>`${i.entry_id}:${i.task_id}`)),this._open=!0}_reset(){this._groupId=null,this._name="",this._description="",this._selected=new Set,this._error=""}_close(){this._open=!1}_buildTaskRefs(){return[...this._selected].map(t=>{let[e,i]=t.split(":",2);return{entry_id:e,task_id:i}})}render(){if(!this._open)return r``;let t=this._lang,e=this._groupId?s("edit_group",t):s("new_group",t);return r`
`,g([T({attribute:!1})],at.prototype,"hass",2),g([m()],at.prototype,"_open",2),g([m()],at.prototype,"_loading",2),g([m()],at.prototype,"_error",2),g([m()],at.prototype,"_entryId",2),g([m()],at.prototype,"_taskId",2),g([m()],at.prototype,"_values",2);customElements.get("maintenance-seasonal-overrides-dialog")||customElements.define("maintenance-seasonal-overrides-dialog",at);var et=class extends L{constructor(){super(...arguments);this.objects=[];this._open=!1;this._loading=!1;this._error="";this._groupId=null;this._name="";this._description="";this._selected=new Set;this._toggleTask=(t,e)=>{let i=`${t}:${e}`,a=new Set(this._selected);a.has(i)?a.delete(i):a.add(i),this._selected=a};this._save=async()=>{let t=this._name.trim();if(!t){this._error=s("group_name_required",this._lang);return}this._loading=!0,this._error="";try{let e=this._buildTaskRefs();this._groupId?await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/update",group_id:this._groupId,name:t,description:this._description,task_refs:e}):await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/create",name:t,description:this._description,task_refs:e}),this._open=!1,this.dispatchEvent(new CustomEvent("group-saved"))}catch(e){this._error=E(e,this._lang,s("save_error",this._lang))}finally{this._loading=!1}}}get _lang(){return this.hass?.language??navigator.language.split("-")[0]??"en"}openCreate(){this._reset(),this._open=!0}openEdit(t,e){this._reset(),this._groupId=t,this._name=e.name,this._description=e.description||"",this._selected=new Set(e.task_refs.map(i=>`${i.entry_id}:${i.task_id}`)),this._open=!0}_reset(){this._groupId=null,this._name="",this._description="",this._selected=new Set,this._error=""}_close(){this._open=!1}_buildTaskRefs(){return[...this._selected].map(t=>{let[e,i]=t.split(":",2);return{entry_id:e,task_id:i}})}render(){if(!this._open)return r``;let t=this._lang,e=this._groupId?s("edit_group",t):s("new_group",t);return r`
<ha-dialog open @closed=${this._close} heading="${e}">
<div class="content">
${this._error?r`<div class="error">${this._error}</div>`:d}
@@ -3611,7 +3645,7 @@ ${A(n.notes)}</div>`:""}
gap: 8px;
padding-top: 16px;
}
`,_([T({attribute:!1})],et.prototype,"hass",2),_([T({attribute:!1})],et.prototype,"objects",2),_([m()],et.prototype,"_open",2),_([m()],et.prototype,"_loading",2),_([m()],et.prototype,"_error",2),_([m()],et.prototype,"_groupId",2),_([m()],et.prototype,"_name",2),_([m()],et.prototype,"_description",2),_([m()],et.prototype,"_selected",2);customElements.get("maintenance-group-dialog")||customElements.define("maintenance-group-dialog",et);var lt=class extends L{constructor(){super(...arguments);this._open=!1;this._busy=!1;this._error="";this._name="";this._views=[];this._filters=null;this._localeReady=!1;this._save=async()=>{let t=this._name.trim();if(!(!t||this._busy||!this._filters)){this._busy=!0,this._error="";try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/views/save",name:t,filters:this._filters});this._name="",this._emitChanged(e.views||[])}catch(e){this._error=E(e,this._lang)}finally{this._busy=!1}}};this._delete=async t=>{if(!this._busy){this._busy=!0,this._error="";try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/views/delete",view_id:t});this._emitChanged(e.views||[])}catch(e){this._error=E(e,this._lang)}finally{this._busy=!1}}}}get _lang(){return this.hass?.language||"en"}updated(t){t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()))}async open(t,e){this._open=!0,this._error="",this._name="",this._filters=t,this._views=e}_close(){this._open=!1}_emitChanged(t){this._views=t,this.dispatchEvent(new CustomEvent("saved-views-changed",{bubbles:!0,composed:!0,detail:{views:t}}))}render(){if(!this._open)return r``;let t=this._lang;return r`
`,g([T({attribute:!1})],et.prototype,"hass",2),g([T({attribute:!1})],et.prototype,"objects",2),g([m()],et.prototype,"_open",2),g([m()],et.prototype,"_loading",2),g([m()],et.prototype,"_error",2),g([m()],et.prototype,"_groupId",2),g([m()],et.prototype,"_name",2),g([m()],et.prototype,"_description",2),g([m()],et.prototype,"_selected",2);customElements.get("maintenance-group-dialog")||customElements.define("maintenance-group-dialog",et);var lt=class extends L{constructor(){super(...arguments);this._open=!1;this._busy=!1;this._error="";this._name="";this._views=[];this._filters=null;this._localeReady=!1;this._save=async()=>{let t=this._name.trim();if(!(!t||this._busy||!this._filters)){this._busy=!0,this._error="";try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/views/save",name:t,filters:this._filters});this._name="",this._emitChanged(e.views||[])}catch(e){this._error=E(e,this._lang)}finally{this._busy=!1}}};this._delete=async t=>{if(!this._busy){this._busy=!0,this._error="";try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/views/delete",view_id:t});this._emitChanged(e.views||[])}catch(e){this._error=E(e,this._lang)}finally{this._busy=!1}}}}get _lang(){return this.hass?.language||"en"}updated(t){t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,q(this._lang).then(()=>this.requestUpdate()))}async open(t,e){this._open=!0,this._error="",this._name="",this._filters=t,this._views=e}_close(){this._open=!1}_emitChanged(t){this._views=t,this.dispatchEvent(new CustomEvent("saved-views-changed",{bubbles:!0,composed:!0,detail:{views:t}}))}render(){if(!this._open)return r``;let t=this._lang;return r`
<div class="overlay" @click=${this._close}>
<div class="card" @click=${e=>e.stopPropagation()}>
<div class="title">${s("views_dialog_title",t)}</div>
@@ -3739,14 +3773,14 @@ ${A(n.notes)}</div>`:""}
gap: 8px;
padding-top: 8px;
}
`,_([T({attribute:!1})],lt.prototype,"hass",2),_([m()],lt.prototype,"_open",2),_([m()],lt.prototype,"_busy",2),_([m()],lt.prototype,"_error",2),_([m()],lt.prototype,"_name",2),_([m()],lt.prototype,"_views",2);customElements.get("maintenance-saved-views-dialog")||customElements.define("maintenance-saved-views-dialog",lt);var ai=60,ni=20,xe=30;function Zt(n){let o=n.trigger_config??null;if(!o)return d;let t=o.type||"threshold",e=n.trigger_entity_info?.unit_of_measurement??"",i=0,a="";if(t==="threshold"){let c=n.trigger_current_value??null;if(c==null)return d;let p=o.trigger_above,u=o.trigger_below;if(p!=null){let g=u??0,v=p-g||1;i=Math.min(100,Math.max(0,(c-g)/v*100)),a=`${c.toFixed(1)} / ${p} ${e}`}else if(u!=null){let v=n.trigger_entity_info?.max??(u*2||100),b=v-u||1;i=Math.min(100,Math.max(0,(v-c)/b*100)),a=`${c.toFixed(1)} / ${u} ${e}`}else return d}else if(t==="counter"){let c=o.trigger_target_value||1,p;if(o.trigger_delta_mode?(p=n.trigger_current_delta??null,p==null&&n.trigger_baseline_value!=null&&n.trigger_current_value!=null&&(p=n.trigger_current_value-n.trigger_baseline_value)):p=n.trigger_current_value??null,p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${p.toFixed(1)} / ${c} ${e}`}else if(t==="state_change"){let c=o.trigger_target_changes||1,p=n.trigger_current_value??null;if(p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${Math.round(p)} / ${c}`}else if(t==="runtime"){let c=o.trigger_runtime_hours||100,p=n.trigger_current_value??null;if(p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${p.toFixed(1)}h / ${c}h`}else if(t==="compound"){let c=o.compound_logic||o.operator||"AND",p=o.conditions?.length||0;a=`${c} (${p})`,i=n.trigger_active?100:0}else return d;let l=i>=100,h=i>90?"var(--error-color, #f44336)":i>70?"var(--warning-color, #ff9800)":"var(--primary-color)";return r`
`,g([T({attribute:!1})],lt.prototype,"hass",2),g([m()],lt.prototype,"_open",2),g([m()],lt.prototype,"_busy",2),g([m()],lt.prototype,"_error",2),g([m()],lt.prototype,"_name",2),g([m()],lt.prototype,"_views",2);customElements.get("maintenance-saved-views-dialog")||customElements.define("maintenance-saved-views-dialog",lt);var ai=60,ni=20,xe=30;function Zt(n){let o=n.trigger_config??null;if(!o)return d;let t=o.type||"threshold",e=n.trigger_entity_info?.unit_of_measurement??"",i=0,a="";if(t==="threshold"){let c=n.trigger_current_value??null;if(c==null)return d;let p=o.trigger_above,u=o.trigger_below;if(p!=null){let _=u??0,v=p-_||1;i=Math.min(100,Math.max(0,(c-_)/v*100)),a=`${c.toFixed(1)} / ${p} ${e}`}else if(u!=null){let v=n.trigger_entity_info?.max??(u*2||100),b=v-u||1;i=Math.min(100,Math.max(0,(v-c)/b*100)),a=`${c.toFixed(1)} / ${u} ${e}`}else return d}else if(t==="counter"){let c=o.trigger_target_value||1,p;if(o.trigger_delta_mode?(p=n.trigger_current_delta??null,p==null&&n.trigger_baseline_value!=null&&n.trigger_current_value!=null&&(p=n.trigger_current_value-n.trigger_baseline_value)):p=n.trigger_current_value??null,p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${p.toFixed(1)} / ${c} ${e}`}else if(t==="state_change"){let c=o.trigger_target_changes||1,p=n.trigger_current_value??null;if(p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${Math.round(p)} / ${c}`}else if(t==="runtime"){let c=o.trigger_runtime_hours||100,p=n.trigger_current_value??null;if(p==null)return d;i=Math.min(100,Math.max(0,p/c*100)),a=`${p.toFixed(1)}h / ${c}h`}else if(t==="compound"){let c=o.compound_logic||o.operator||"AND",p=o.conditions?.length||0;a=`${c} (${p})`,i=n.trigger_active?100:0}else return d;let l=i>=100,h=i>90?"var(--error-color, #f44336)":i>70?"var(--warning-color, #ff9800)":"var(--primary-color)";return r`
<div class="trigger-progress">
<div class="trigger-progress-bar">
<div class="trigger-progress-fill${l?" overflow":""}" style="width:${i}%;background:${h}"></div>
</div>
<span class="trigger-progress-label">${a}</span>
</div>
`}function Qt(n,o,t){if(!n.trigger_config?.entity_id)return d;let e=n.trigger_config.entity_id,i=o.get(e)||[],a=[];if(i.length>=2)a=i.map(j=>({ts:j.ts,val:j.val}));else{if(!n.history)return d;for(let j of n.history)j.trigger_value!=null&&a.push({ts:new Date(j.timestamp).getTime(),val:j.trigger_value})}if(n.trigger_current_value!=null&&a.push({ts:Date.now(),val:n.trigger_current_value}),a.length<2)return d;a.sort((j,y)=>j.ts-y.ts);let l=ai,h=ni,c=a.map(j=>j.val),p=Math.min(...c),u=Math.max(...c),g=u-p||1;p-=g*.1,u+=g*.1;let v=a[0].ts,x=a[a.length-1].ts-v||1,f=j=>(j-v)/x*l,M=j=>2+(1-(j-p)/(u-p))*(h-4),S=a;if(S.length>xe){let j=Math.ceil(S.length/xe);S=S.filter((y,N)=>N%j===0||N===S.length-1)}let I=S.map(j=>`${f(j.ts).toFixed(1)},${M(j.val).toFixed(1)}`).join(" "),R=n.trigger_active?"var(--error-color, #f44336)":"var(--primary-color)";return r`
`}function Qt(n,o,t){if(!n.trigger_config?.entity_id)return d;let e=n.trigger_config.entity_id,i=o.get(e)||[],a=[];if(i.length>=2)a=i.map(j=>({ts:j.ts,val:j.val}));else{if(!n.history)return d;for(let j of n.history)j.trigger_value!=null&&a.push({ts:new Date(j.timestamp).getTime(),val:j.trigger_value})}if(n.trigger_current_value!=null&&a.push({ts:Date.now(),val:n.trigger_current_value}),a.length<2)return d;a.sort((j,y)=>j.ts-y.ts);let l=ai,h=ni,c=a.map(j=>j.val),p=Math.min(...c),u=Math.max(...c),_=u-p||1;p-=_*.1,u+=_*.1;let v=a[0].ts,x=a[a.length-1].ts-v||1,f=j=>(j-v)/x*l,S=j=>2+(1-(j-p)/(u-p))*(h-4),M=a;if(M.length>xe){let j=Math.ceil(M.length/xe);M=M.filter((y,U)=>U%j===0||U===M.length-1)}let I=M.map(j=>`${f(j.ts).toFixed(1)},${S(j.val).toFixed(1)}`).join(" "),R=n.trigger_active?"var(--error-color, #f44336)":"var(--primary-color)";return r`
<svg class="mini-sparkline" viewBox="0 0 ${l} ${h}" preserveAspectRatio="none" role="img" aria-label="${s("chart_mini_sparkline",t)}">
<polyline points="${I}" fill="none" stroke="${R}" stroke-width="1.5" stroke-linejoin="round" />
</svg>
@@ -3759,7 +3793,7 @@ ${A(n.notes)}</div>`:""}
<div class="days-progress-bar" role="progressbar" aria-valuenow="${Math.round(e)}" aria-valuemin="0" aria-valuemax="100" aria-label="${s("days_progress",t)}">
<div class="days-progress-fill${i?" overflow":""}" style="width:${e}%;background:${a}"></div>
</div>
<div class="days-progress-text">${_t(n.days_until_due,t)}</div>
<div class="days-progress-text">${gt(n.days_until_due,t)}</div>
</div>
`}function wt(n,o,t=4){if(!isFinite(n)||!isFinite(o))return{ticks:[],niceMin:0,niceMax:1};if(n===o){let p=Math.abs(n)*.1||1;n-=p,o+=p}let e=o-n,i=Math.pow(10,Math.floor(Math.log10(e/Math.max(1,t)))),a=i;for(let p of[1,2,5,10])if(a=i*p,e/a<=t+.5)break;let l=Math.floor(n/a)*a,h=Math.ceil(o/a)*a,c=[];for(let p=l;p<=h+a*1e-6;p+=a)c.push(Math.abs(p)<a*1e-9?0:p);return{ticks:c,niceMin:l,niceMax:h}}function ct(n){let o=Math.abs(n);return o>=1e6?ft((n/1e6).toFixed(o>=1e7?0:1))+"M":o>=1e4?ft((n/1e3).toFixed(0))+"k":o>=1e3?ft((n/1e3).toFixed(1))+"k":o>=100?n.toFixed(0):o>=10||o>=1?ft(n.toFixed(1)):o===0?"0":ft(n.toFixed(2))}function ft(n){return n.replace(/\.0+$/,"").replace(/(\.\d*[1-9])0+$/,"$1")}function vt(n,o,t){let e=n.toLocaleString(t,{maximumFractionDigits:Math.abs(n)>=100?0:1});return o?`${e} ${o}`:e}function yt(n,o,t){let e=new Date(n),i=t?{month:"short",day:"numeric",year:"2-digit"}:{month:"short",day:"numeric"};return e.toLocaleDateString(o,i)}function Xt(n,o){return new Date(n).toLocaleDateString(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Ft(n,o){return new Date(n).getFullYear()!==new Date(o).getFullYear()}function Bt(n,o,t){if(t<2||o<=n)return[n,o];let e=[];for(let i=0;i<t;i++)e.push(n+(o-n)*i/(t-1));return e}var Vt=210,nt=46,pt=14,ht=12,we=14,ri=20+we,oi=[{days:7,key:"chart_range_7d"},{days:30,key:"chart_range_30d"},{days:90,key:"chart_range_90d"},{days:365,key:"chart_range_1y"}],V=class extends L{constructor(){super(...arguments);this.points=[];this.events=[];this.unit="";this.lang="en";this.thresholdAbove=null;this.thresholdBelow=null;this.targetValue=null;this.forceZero=!1;this.projection=null;this.rangeDays=30;this.showRange=!0;this.busy=!1;this.hideOutliers=!1;this.showOutlierToggle=!0;this._width=0;this._hover=null;this._ro=null}connectedCallback(){super.connectedCallback(),this._ro=new ResizeObserver(t=>{let e=Math.floor(t[0]?.contentRect?.width||0);e&&Math.abs(e-this._width)>2&&(this._width=e)}),this._ro.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this._ro?.disconnect(),this._ro=null}_emitRange(t){t!==this.rangeDays&&this.dispatchEvent(new CustomEvent("range-change",{detail:{days:t},bubbles:!0,composed:!0}))}_toggleOutliers(){this.dispatchEvent(new CustomEvent("outlier-toggle",{detail:{hide:!this.hideOutliers},bubbles:!0,composed:!0}))}render(){let t=this._width||320,e=[...this.points].sort((a,l)=>a.ts-l.ts),i=this.lang;return r`
<div class="chart-wrap">
@@ -3780,7 +3814,7 @@ ${A(n.notes)}</div>`:""}
<ha-icon icon="mdi:chart-line"></ha-icon> ${s("loading_chart",i)}
</div>`:this._renderSvg(t,e)}
</div>
`}_renderSvg(t,e){let i=this.lang,a=t-nt-pt,l=Vt-ri,h=l-ht,c=1/0,p=-1/0;for(let w of e)c=Math.min(c,w.min??w.val),p=Math.max(p,w.max??w.val);this.thresholdAbove!=null&&(c=Math.min(c,this.thresholdAbove),p=Math.max(p,this.thresholdAbove)),this.thresholdBelow!=null&&(c=Math.min(c,this.thresholdBelow),p=Math.max(p,this.thresholdBelow)),this.targetValue!=null&&(c=Math.min(c,this.targetValue),p=Math.max(p,this.targetValue)),this.forceZero&&(c=Math.min(c,0));let u=(p-c||1)*.06,g=this.forceZero&&c>=0?0:c-u,{ticks:v,niceMin:b,niceMax:x}=wt(g,p+u,4);this.forceZero&&c>=0&&b<0&&(b=0,v=v.filter(w=>w>=0));let f=e[0].ts,M=e[e.length-1].ts,S=M-f||1,I=Ft(f,M),R=w=>nt+(w-f)/S*a,j=w=>ht+(1-(w-b)/(x-b||1))*h,y=e.map(w=>`${R(w.ts).toFixed(1)},${j(w.val).toFixed(1)}`).join(" "),N=`M${R(e[0].ts).toFixed(1)},${l} `+e.map(w=>`L${R(w.ts).toFixed(1)},${j(w.val).toFixed(1)}`).join(" ")+` L${R(e[e.length-1].ts).toFixed(1)},${l} Z`,W="",H=e.filter(w=>w.min!=null&&w.max!=null);if(H.length>=2){let w=H.map(C=>`${R(C.ts).toFixed(1)},${j(C.max).toFixed(1)}`),$=[...H].reverse().map(C=>`${R(C.ts).toFixed(1)},${j(C.min).toFixed(1)}`);W=`M${w[0]} `+w.slice(1).map(C=>`L${C}`).join(" ")+` L${$.join(" L")} Z`}let O=[];if(this.thresholdBelow!=null){let w=j(this.thresholdBelow);O.push({y:w,h:Math.max(0,l-w),lineY:w,label:`\u25BC ${ct(this.thresholdBelow)}`,labelY:Math.min(l-4,w+13)})}if(this.thresholdAbove!=null){let w=j(this.thresholdAbove);O.push({y:ht,h:Math.max(0,w-ht),lineY:w,label:`\u25B2 ${ct(this.thresholdAbove)}`,labelY:Math.max(ht+11,w-5)})}let Z=e[e.length-1],st=(this.events||[]).filter(w=>w.ts>=f&&w.ts<=M),rt=Bt(f,M,Math.max(2,Math.min(5,Math.floor(a/110)+1))),U=this._hover;return r`
`}_renderSvg(t,e){let i=this.lang,a=t-nt-pt,l=Vt-ri,h=l-ht,c=1/0,p=-1/0;for(let w of e)c=Math.min(c,w.min??w.val),p=Math.max(p,w.max??w.val);this.thresholdAbove!=null&&(c=Math.min(c,this.thresholdAbove),p=Math.max(p,this.thresholdAbove)),this.thresholdBelow!=null&&(c=Math.min(c,this.thresholdBelow),p=Math.max(p,this.thresholdBelow)),this.targetValue!=null&&(c=Math.min(c,this.targetValue),p=Math.max(p,this.targetValue)),this.forceZero&&(c=Math.min(c,0));let u=(p-c||1)*.06,_=this.forceZero&&c>=0?0:c-u,{ticks:v,niceMin:b,niceMax:x}=wt(_,p+u,4);this.forceZero&&c>=0&&b<0&&(b=0,v=v.filter(w=>w>=0));let f=e[0].ts,S=e[e.length-1].ts,M=S-f||1,I=Ft(f,S),R=w=>nt+(w-f)/M*a,j=w=>ht+(1-(w-b)/(x-b||1))*h,y=e.map(w=>`${R(w.ts).toFixed(1)},${j(w.val).toFixed(1)}`).join(" "),U=`M${R(e[0].ts).toFixed(1)},${l} `+e.map(w=>`L${R(w.ts).toFixed(1)},${j(w.val).toFixed(1)}`).join(" ")+` L${R(e[e.length-1].ts).toFixed(1)},${l} Z`,W="",H=e.filter(w=>w.min!=null&&w.max!=null);if(H.length>=2){let w=H.map(C=>`${R(C.ts).toFixed(1)},${j(C.max).toFixed(1)}`),$=[...H].reverse().map(C=>`${R(C.ts).toFixed(1)},${j(C.min).toFixed(1)}`);W=`M${w[0]} `+w.slice(1).map(C=>`L${C}`).join(" ")+` L${$.join(" L")} Z`}let O=[];if(this.thresholdBelow!=null){let w=j(this.thresholdBelow);O.push({y:w,h:Math.max(0,l-w),lineY:w,label:`\u25BC ${ct(this.thresholdBelow)}`,labelY:Math.min(l-4,w+13)})}if(this.thresholdAbove!=null){let w=j(this.thresholdAbove);O.push({y:ht,h:Math.max(0,w-ht),lineY:w,label:`\u25B2 ${ct(this.thresholdAbove)}`,labelY:Math.max(ht+11,w-5)})}let Z=e[e.length-1],st=(this.events||[]).filter(w=>w.ts>=f&&w.ts<=S),rt=Bt(f,S,Math.max(2,Math.min(5,Math.floor(a/110)+1))),N=this._hover;return r`
<div class="svg-holder">
<svg
class="chart-svg"
@@ -3813,7 +3847,7 @@ ${A(n.notes)}</div>`:""}
fill="url(#dangerHatch)" />`)}
${W?P`<path d="${W}" fill="var(--primary-color)" opacity="0.08" clip-path="url(#plot)" />`:d}
<path d="${N}" fill="var(--primary-color)" opacity="0.10" clip-path="url(#plot)" />
<path d="${U}" fill="var(--primary-color)" opacity="0.10" clip-path="url(#plot)" />
<polyline points="${y}" fill="none" stroke="var(--primary-color)" stroke-width="2"
stroke-linejoin="round" stroke-linecap="round" clip-path="url(#plot)" />
${O.length?P`<polyline points="${y}" fill="none" stroke="var(--error-color, #f44336)" stroke-width="2"
@@ -3832,7 +3866,7 @@ ${A(n.notes)}</div>`:""}
x2="${Math.min(R(this.projection[1].ts),t-pt).toFixed(1)}" y2="${j(Math.max(b,Math.min(x,this.projection[1].val))).toFixed(1)}"
stroke="var(--warning-color, #ff9800)" stroke-width="1.5" stroke-dasharray="4,3" opacity="0.8" />`:d}
${rt.map((w,$)=>{let C=R(w),Ut=$===0?"start":$===rt.length-1?"end":"middle";return P`<text x="${C.toFixed(1)}" y="${Vt-5}" text-anchor="${Ut}" class="tick-label">${yt(w,i,I)}</text>`})}
${rt.map((w,$)=>{let C=R(w),Nt=$===0?"start":$===rt.length-1?"end":"middle";return P`<text x="${C.toFixed(1)}" y="${Vt-5}" text-anchor="${Nt}" class="tick-label">${yt(w,i,I)}</text>`})}
<line x1="${nt}" y1="${l}" x2="${t-pt}" y2="${l}" stroke="var(--divider-color)" stroke-width="1" />
@@ -3842,25 +3876,25 @@ ${A(n.notes)}</div>`:""}
<title>${Xt(w.ts,i)}</title>
</rect>`})}
${U?P`
<line x1="${U.x.toFixed(1)}" y1="${ht}" x2="${U.x.toFixed(1)}" y2="${l}"
${N?P`
<line x1="${N.x.toFixed(1)}" y1="${ht}" x2="${N.x.toFixed(1)}" y2="${l}"
stroke="var(--secondary-text-color)" stroke-width="1" stroke-dasharray="3,3" opacity="0.7" />
<circle cx="${U.x.toFixed(1)}" cy="${U.y.toFixed(1)}" r="4.5" fill="var(--primary-color)"
<circle cx="${N.x.toFixed(1)}" cy="${N.y.toFixed(1)}" r="4.5" fill="var(--primary-color)"
stroke="var(--card-background-color, #fff)" stroke-width="2" />`:P`<circle cx="${R(Z.ts).toFixed(1)}" cy="${j(Z.val).toFixed(1)}" r="4" fill="var(--primary-color)"
stroke="var(--card-background-color, #fff)" stroke-width="1.5" />`}
</svg>
${U?r`<div
${N?r`<div
class="hover-chip"
style="left:${Math.min(Math.max(U.x,70),t-70)}px"
style="left:${Math.min(Math.max(N.x,70),t-70)}px"
>
<div class="hover-date">${Xt(U.p.ts,i)}</div>
<div class="hover-date">${Xt(N.p.ts,i)}</div>
<div class="hover-val">
${vt(U.p.val,this.unit,i)}
${U.p.min!=null&&U.p.max!=null?r`<span class="hover-range">(${ct(U.p.min)}–${ct(U.p.max)})</span>`:d}
${vt(N.p.val,this.unit,i)}
${N.p.min!=null&&N.p.max!=null?r`<span class="hover-range">(${ct(N.p.min)}–${ct(N.p.max)})</span>`:d}
</div>
</div>`:d}
</div>
`}_onPointer(t,e,i,a,l){let c=t.currentTarget.getBoundingClientRect(),p=(t.clientX-c.left)/c.width*l;if(p<nt-8||p>l-pt+8){this._hover=null;return}let u=e[0],g=1/0;for(let v of e){let b=Math.abs(i(v.ts)-p);b<g&&(g=b,u=v)}this._hover={x:i(u.ts),y:a(u.val),p:u}}};V.styles=D`
`}_onPointer(t,e,i,a,l){let c=t.currentTarget.getBoundingClientRect(),p=(t.clientX-c.left)/c.width*l;if(p<nt-8||p>l-pt+8){this._hover=null;return}let u=e[0],_=1/0;for(let v of e){let b=Math.abs(i(v.ts)-p);b<_&&(_=b,u=v)}this._hover={x:i(u.ts),y:a(u.val),p:u}}};V.styles=D`
:host { display: block; width: 100%; }
.chart-wrap { position: relative; }
.range-chips { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 2px; }
@@ -3895,7 +3929,7 @@ ${A(n.notes)}</div>`:""}
.hover-date { font-size: 10.5px; color: var(--secondary-text-color); }
.hover-val { font-size: 12.5px; font-weight: 600; color: var(--primary-text-color); }
.hover-range { font-weight: 400; color: var(--secondary-text-color); font-size: 11px; }
`,_([T({attribute:!1})],V.prototype,"points",2),_([T({attribute:!1})],V.prototype,"events",2),_([T()],V.prototype,"unit",2),_([T()],V.prototype,"lang",2),_([T({attribute:!1})],V.prototype,"thresholdAbove",2),_([T({attribute:!1})],V.prototype,"thresholdBelow",2),_([T({attribute:!1})],V.prototype,"targetValue",2),_([T({type:Boolean})],V.prototype,"forceZero",2),_([T({attribute:!1})],V.prototype,"projection",2),_([T({attribute:!1})],V.prototype,"rangeDays",2),_([T({type:Boolean})],V.prototype,"showRange",2),_([T({type:Boolean})],V.prototype,"busy",2),_([T({type:Boolean})],V.prototype,"hideOutliers",2),_([T({type:Boolean})],V.prototype,"showOutlierToggle",2),_([m()],V.prototype,"_width",2),_([m()],V.prototype,"_hover",2);customElements.get("maintenance-trigger-chart")||customElements.define("maintenance-trigger-chart",V);function li(n){if(n.length<4)return n;let o=n.map(p=>p.val).sort((p,u)=>p-u),t=p=>{let u=(o.length-1)*p,g=Math.floor(u),v=Math.ceil(u);return o[g]+(o[v]-o[g])*(u-g)},e=t(.25),i=t(.75),a=i-e;if(a===0)return n;let l=e-1.5*a,h=i+1.5*a,c=n.filter(p=>p.val>=l&&p.val<=h);return c.length>=2?c:n}function ke(n,o){let t=n.trigger_config;if(!t)return d;let e=o.lang,i=n.trigger_entity_info,a=n.trigger_entity_infos,l=i?.friendly_name||t.entity_id||"\u2014",h=t.entity_id||"",c=t.entity_ids||(h?[h]:[]),p=i?.unit_of_measurement||"",u=n.trigger_current_value,g=t.type||"threshold",v=c.length>1,b=ci(n,p,o);return r`
`,g([T({attribute:!1})],V.prototype,"points",2),g([T({attribute:!1})],V.prototype,"events",2),g([T()],V.prototype,"unit",2),g([T()],V.prototype,"lang",2),g([T({attribute:!1})],V.prototype,"thresholdAbove",2),g([T({attribute:!1})],V.prototype,"thresholdBelow",2),g([T({attribute:!1})],V.prototype,"targetValue",2),g([T({type:Boolean})],V.prototype,"forceZero",2),g([T({attribute:!1})],V.prototype,"projection",2),g([T({attribute:!1})],V.prototype,"rangeDays",2),g([T({type:Boolean})],V.prototype,"showRange",2),g([T({type:Boolean})],V.prototype,"busy",2),g([T({type:Boolean})],V.prototype,"hideOutliers",2),g([T({type:Boolean})],V.prototype,"showOutlierToggle",2),g([m()],V.prototype,"_width",2),g([m()],V.prototype,"_hover",2);customElements.get("maintenance-trigger-chart")||customElements.define("maintenance-trigger-chart",V);function li(n){if(n.length<4)return n;let o=n.map(p=>p.val).sort((p,u)=>p-u),t=p=>{let u=(o.length-1)*p,_=Math.floor(u),v=Math.ceil(u);return o[_]+(o[v]-o[_])*(u-_)},e=t(.25),i=t(.75),a=i-e;if(a===0)return n;let l=e-1.5*a,h=i+1.5*a,c=n.filter(p=>p.val>=l&&p.val<=h);return c.length>=2?c:n}function ke(n,o){let t=n.trigger_config;if(!t)return d;let e=o.lang,i=n.trigger_entity_info,a=n.trigger_entity_infos,l=i?.friendly_name||t.entity_id||"\u2014",h=t.entity_id||"",c=t.entity_ids||(h?[h]:[]),p=i?.unit_of_measurement||"",u=n.trigger_current_value,_=t.type||"threshold",v=c.length>1,b=ci(n,p,o);return r`
<h3>${s("trigger",e)}</h3>
<div class="trigger-card">
<div class="trigger-header">
@@ -3903,7 +3937,7 @@ ${A(n.notes)}</div>`:""}
<div>
${v?r`
<div class="trigger-entity-name">${c.length} ${s("entities",e)} (${t.entity_logic||"any"})</div>
<div class="trigger-entity-id">${c.map((x,f)=>r`${f>0?", ":""}<span class="entity-link" @click=${M=>mt(M,x)}>${x}</span>`)}${t.attribute?` \u2192 ${t.attribute}`:""}</div>
<div class="trigger-entity-id">${c.map((x,f)=>r`${f>0?", ":""}<span class="entity-link" @click=${S=>mt(S,x)}>${x}</span>`)}${t.attribute?` \u2192 ${t.attribute}`:""}</div>
`:r`
<div class="trigger-entity-name">${l}</div>
<div class="trigger-entity-id">${h?r`<span class="entity-link" @click=${x=>mt(x,h)}>${h}</span>`:""}${t.attribute?` \u2192 ${t.attribute}`:""}</div>
@@ -3922,21 +3956,21 @@ ${A(n.notes)}</div>`:""}
`:d}
<div class="trigger-limits">
${g==="threshold"?r`
${_==="threshold"?r`
${t.trigger_above!=null?r`<span class="trigger-limit-item"><span class="dot warn" aria-hidden="true"></span> ${s("threshold_above",e)}: ${t.trigger_above} ${p}</span>`:d}
${t.trigger_below!=null?r`<span class="trigger-limit-item"><span class="dot warn" aria-hidden="true"></span> ${s("threshold_below",e)}: ${t.trigger_below} ${p}</span>`:d}
${t.trigger_for_minutes?r`<span class="trigger-limit-item"><span class="dot range" aria-hidden="true"></span> ${s("for_minutes",e)}: ${t.trigger_for_minutes}</span>`:d}
`:d}
${g==="state_change"?r`
${_==="state_change"?r`
${t.trigger_target_changes!=null?r`<span class="trigger-limit-item"><span class="dot warn" aria-hidden="true"></span> ${s("target_changes",e)}: ${t.trigger_target_changes}</span>`:d}
`:d}
${g==="runtime"?r`
${_==="runtime"?r`
${t.trigger_runtime_hours!=null?r`<span class="trigger-limit-item"><span class="dot warn" aria-hidden="true"></span> ${s("runtime_hours",e)}: ${t.trigger_runtime_hours}h</span>`:d}
`:d}
${g==="compound"?r`
${_==="compound"?r`
<span class="trigger-limit-item"><span class="dot warn" aria-hidden="true"></span> ${s("compound_logic",e)}: ${t.compound_logic||t.operator||"AND"}</span>
${(t.conditions||[]).map((x,f)=>r`
<span class="trigger-limit-item"><span class="dot range" aria-hidden="true"></span> ${f+1}. ${s(x.type||"unknown",e)}: ${x.entity_id?r`<span class="entity-link" @click=${M=>mt(M,x.entity_id)}>${x.entity_id}</span>`:""}</span>
<span class="trigger-limit-item"><span class="dot range" aria-hidden="true"></span> ${f+1}. ${s(x.type||"unknown",e)}: ${x.entity_id?r`<span class="entity-link" @click=${S=>mt(S,x.entity_id)}>${x.entity_id}</span>`:""}</span>
`)}
`:d}
</div>
@@ -3964,7 +3998,7 @@ ${A(n.notes)}</div>`:""}
${s("chart_since_service",o)}${n.meter!=null?r` · ${s("current",o)}: ${vt(n.meter,n.unit,o)}`:d}
</div>
</div>
`}function je(n,o){let t=n.trigger_config;if(!t)return[];let e=t.type||"threshold",i=t.entity_id||"",a=e==="runtime"?[]:o.detailStatsData.get(i)||[],l=o.isCounterEntity(t),h=[];if(a.length>=2)for(let c of a){let p={ts:c.ts,val:c.val};!l&&c.min!=null&&c.max!=null&&(p.min=c.min,p.max=c.max),h.push(p)}else for(let c of n.history)c.trigger_value!=null&&h.push({ts:new Date(c.timestamp).getTime(),val:c.trigger_value});return n.trigger_current_value!=null&&h.push({ts:Date.now(),val:n.trigger_current_value}),h.sort((c,p)=>c.ts-p.ts),h}function pi(n,o,t){let e=n.trigger_config;if(!e)return d;let i=e.type||"threshold",a=e.entity_id||"",l=je(n,t);i==="runtime"&&e.trigger_runtime_hours&&n.trigger_current_value!=null&&(l=[{ts:Jt(n)??l[0]?.ts??Date.now()-864e5,val:0},{ts:Date.now(),val:Math.max(0,n.trigger_current_value)}]),t.hideOutliers&&(l=li(l));let h=l.length<2&&!!a&&t.hasStatsService&&!t.detailStatsData.has(a);if(l.length<2&&!h)return d;let c=!!a&&t.detailStatsData.has(a)&&(t.detailStatsData.get(a)?.length??0)<2,p=Date.now()-t.rangeDays*864e5,u=l.filter(f=>f.ts>=p);u.length>=2&&(l=u);let g=null,v=!1;if(i==="counter"&&e.trigger_target_value!=null&&l.length){let f=Te(n,l);if(f){if(f.ts!=null){let M=l.filter(S=>S.ts>=f.ts);M.length>=2&&(l=M)}l=l.map(M=>({...M,val:Math.max(0,M.val-f.value)}))}g=e.trigger_target_value,v=!0}else i==="state_change"&&e.trigger_target_changes?(g=e.trigger_target_changes,v=!0):i==="runtime"&&e.trigger_runtime_hours&&(g=e.trigger_runtime_hours,v=!0);let b=null;if(g==null&&n.degradation_rate!=null&&(n.degradation_trend!=="stable"||n.days_until_threshold!=null)&&n.degradation_trend!=="insufficient_data"&&l.length>=2){let f=l[l.length-1];b=[f,{ts:f.ts+30*864e5,val:f.val+n.degradation_rate*30}]}let x=n.history.filter(f=>["completed","skipped","reset"].includes(f.type)).map(f=>({ts:new Date(f.timestamp).getTime(),type:f.type}));return r`
`}function je(n,o){let t=n.trigger_config;if(!t)return[];let e=t.type||"threshold",i=t.entity_id||"",a=e==="runtime"?[]:o.detailStatsData.get(i)||[],l=o.isCounterEntity(t),h=[];if(a.length>=2)for(let c of a){let p={ts:c.ts,val:c.val};!l&&c.min!=null&&c.max!=null&&(p.min=c.min,p.max=c.max),h.push(p)}else for(let c of n.history)c.trigger_value!=null&&h.push({ts:new Date(c.timestamp).getTime(),val:c.trigger_value});return n.trigger_current_value!=null&&h.push({ts:Date.now(),val:n.trigger_current_value}),h.sort((c,p)=>c.ts-p.ts),h}function pi(n,o,t){let e=n.trigger_config;if(!e)return d;let i=e.type||"threshold",a=e.entity_id||"",l=je(n,t);i==="runtime"&&e.trigger_runtime_hours&&n.trigger_current_value!=null&&(l=[{ts:Jt(n)??l[0]?.ts??Date.now()-864e5,val:0},{ts:Date.now(),val:Math.max(0,n.trigger_current_value)}]),t.hideOutliers&&(l=li(l));let h=l.length<2&&!!a&&t.hasStatsService&&!t.detailStatsData.has(a);if(l.length<2&&!h)return d;let c=!!a&&t.detailStatsData.has(a)&&(t.detailStatsData.get(a)?.length??0)<2,p=Date.now()-t.rangeDays*864e5,u=l.filter(f=>f.ts>=p);u.length>=2&&(l=u);let _=null,v=!1;if(i==="counter"&&e.trigger_target_value!=null&&l.length){let f=Te(n,l);if(f){if(f.ts!=null){let S=l.filter(M=>M.ts>=f.ts);S.length>=2&&(l=S)}l=l.map(S=>({...S,val:Math.max(0,S.val-f.value)}))}_=e.trigger_target_value,v=!0}else i==="state_change"&&e.trigger_target_changes?(_=e.trigger_target_changes,v=!0):i==="runtime"&&e.trigger_runtime_hours&&(_=e.trigger_runtime_hours,v=!0);let b=null;if(_==null&&n.degradation_rate!=null&&(n.degradation_trend!=="stable"||n.days_until_threshold!=null)&&n.degradation_trend!=="insufficient_data"&&l.length>=2){let f=l[l.length-1];b=[f,{ts:f.ts+30*864e5,val:f.val+n.degradation_rate*30}]}let x=n.history.filter(f=>["completed","skipped","reset"].includes(f.type)).map(f=>({ts:new Date(f.timestamp).getTime(),type:f.type}));return r`
<maintenance-trigger-chart
.points=${h?[]:l}
.events=${x}
@@ -3972,7 +4006,7 @@ ${A(n.notes)}</div>`:""}
.lang=${t.lang}
.thresholdAbove=${i==="threshold"?e.trigger_above??null:null}
.thresholdBelow=${i==="threshold"?e.trigger_below??null:null}
.targetValue=${g}
.targetValue=${_}
.forceZero=${v}
.projection=${b}
.rangeDays=${t.rangeDays}
@@ -3985,7 +4019,7 @@ ${A(n.notes)}</div>`:""}
<ha-icon icon="mdi:information-outline"></ha-icon>
${s("chart_no_stats",t.lang)}
</div>`:d}
`}function Me(n,o,t){let e=n.degradation_trend!=null&&n.degradation_trend!=="insufficient_data",i=n.days_until_threshold!=null,a=n.environmental_factor!=null&&n.environmental_factor!==1;if(!e&&!i&&!a)return d;let l=n.degradation_trend==="rising"?"M16,6L18.29,8.29L13.41,13.17L9.41,9.17L2,16.59L3.41,18L9.41,12L13.41,16L19.71,9.71L22,12V6H16Z":n.degradation_trend==="falling"?"M16,18L18.29,15.71L13.41,10.83L9.41,14.83L2,7.41L3.41,6L9.41,12L13.41,8L19.71,14.29L22,12V18H16Z":"M22,12L18,8V11H3V13H18V16L22,12Z";return r`
`}function Se(n,o,t){let e=n.degradation_trend!=null&&n.degradation_trend!=="insufficient_data",i=n.days_until_threshold!=null,a=n.environmental_factor!=null&&n.environmental_factor!==1;if(!e&&!i&&!a)return d;let l=n.degradation_trend==="rising"?"M16,6L18.29,8.29L13.41,13.17L9.41,9.17L2,16.59L3.41,18L9.41,12L13.41,16L19.71,9.71L22,12V6H16Z":n.degradation_trend==="falling"?"M16,18L18.29,15.71L13.41,10.83L9.41,14.83L2,7.41L3.41,6L9.41,12L13.41,8L19.71,14.29L22,12V18H16Z":"M22,12L18,8V11H3V13H18V16L22,12Z";return r`
<div class="prediction-section">
${n.sensor_prediction_urgency?r`
<div class="prediction-urgency-banner">
@@ -4025,7 +4059,7 @@ ${A(n.notes)}</div>`:""}
`:d}
</div>
</div>
`}function Se(n,o){let t=n.interval_analysis,e=t?.weibull_beta,i=t?.weibull_eta;if(e==null||i==null||i<=0)return d;let a=n.interval_days??0,l=n.suggested_interval??a;return r`
`}function Me(n,o){let t=n.interval_analysis,e=t?.weibull_beta,i=t?.weibull_eta;if(e==null||i==null||i<=0)return d;let a=n.interval_days??0,l=n.suggested_interval??a;return r`
<div class="weibull-section">
<div class="weibull-title">
<ha-svg-icon aria-hidden="true" path="M3,14L3.5,14.07L8.07,9.5C7.89,8.85 8.06,8.11 8.59,7.59C9.37,6.8 10.63,6.8 11.41,7.59C11.94,8.11 12.11,8.85 11.93,9.5L14.5,12.07L15,12C15.18,12 15.35,12 15.5,12.07L19.07,8.5C19,8.35 19,8.18 19,8A2,2 0 0,1 21,6A2,2 0 0,1 23,8A2,2 0 0,1 21,10C20.82,10 20.65,10 20.5,9.93L16.93,13.5C17,13.65 17,13.82 17,14A2,2 0 0,1 15,16A2,2 0 0,1 13,14L13.07,13.5L10.5,10.93C10.18,11 9.82,11 9.5,10.93L4.93,15.5L5,16A2,2 0 0,1 3,18A2,2 0 0,1 1,16A2,2 0 0,1 3,14Z"></ha-svg-icon>
@@ -4033,15 +4067,15 @@ ${A(n.notes)}</div>`:""}
${hi(e,o)}
</div>
${ui(e,i,a,l,o)}
${_i(t,o)}
${t?.confidence_interval_low!=null?gi(t,n,o):d}
${gi(t,o)}
${t?.confidence_interval_low!=null?_i(t,n,o):d}
</div>
`}function hi(n,o){let t,e,i;return n<.8?(t="early_failures",e="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z",i="beta_early_failures"):n<=1.2?(t="random_failures",e="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,17H11V15H13V17M13,13H11V7H13V13Z",i="beta_random_failures"):n<=3.5?(t="wear_out",e="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12H12V6Z",i="beta_wear_out"):(t="highly_predictable",e="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M11,16.5L18,9.5L16.59,8.09L11,13.67L7.91,10.59L6.5,12L11,16.5Z",i="beta_highly_predictable"),r`
<span class="beta-badge ${t}">
<ha-svg-icon path="${e}"></ha-svg-icon>
${s(i,o)} (\u03B2=${n.toFixed(2)})
</span>
`}function ui(n,o,t,e,i){let b=Math.max(t,e,o,1)*1.3,x=50,f=[];for(let H=0;H<=x;H++){let O=H/x*b,Z=1-Math.exp(-Math.pow(O/o,n)),st=32+O/b*260,rt=136-Z*128;f.push([st,rt])}let M=f.map(([H,O])=>`${H.toFixed(1)},${O.toFixed(1)}`).join(" "),S="M32,136 "+f.map(([H,O])=>`L${H.toFixed(1)},${O.toFixed(1)}`).join(" ")+` L${f[x][0].toFixed(1)},136 Z`,I=32+t/b*260,R=1-Math.exp(-Math.pow(t/o,n)),j=136-R*128,y=((1-R)*100).toFixed(0),N=32+e/b*260,W=[0,.25,.5,.75,1];return r`
`}function ui(n,o,t,e,i){let b=Math.max(t,e,o,1)*1.3,x=50,f=[];for(let H=0;H<=x;H++){let O=H/x*b,Z=1-Math.exp(-Math.pow(O/o,n)),st=32+O/b*260,rt=136-Z*128;f.push([st,rt])}let S=f.map(([H,O])=>`${H.toFixed(1)},${O.toFixed(1)}`).join(" "),M="M32,136 "+f.map(([H,O])=>`L${H.toFixed(1)},${O.toFixed(1)}`).join(" ")+` L${f[x][0].toFixed(1)},136 Z`,I=32+t/b*260,R=1-Math.exp(-Math.pow(t/o,n)),j=136-R*128,y=((1-R)*100).toFixed(0),U=32+e/b*260,W=[0,.25,.5,.75,1];return r`
<div class="weibull-chart">
<svg viewBox="0 0 ${300} ${160}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_weibull",i)}">
${W.map(H=>{let O=136-H*128;return P`
@@ -4055,8 +4089,8 @@ ${A(n.notes)}</div>`:""}
<text x="${324/2}" y="${156}" fill="var(--secondary-text-color)" font-size="8" text-anchor="middle">${Math.round(b/2)}</text>
<text x="${292}" y="${156}" fill="var(--secondary-text-color)" font-size="8" text-anchor="middle">${Math.round(b)}</text>
<path d="${S}" fill="var(--primary-color, #03a9f4)" opacity="0.08" />
<polyline points="${M}" fill="none"
<path d="${M}" fill="var(--primary-color, #03a9f4)" opacity="0.08" />
<polyline points="${S}" fill="none"
stroke="var(--primary-color, #03a9f4)" stroke-width="2" />
${t>0?P`
@@ -4069,7 +4103,7 @@ ${A(n.notes)}</div>`:""}
`:d}
${e>0&&e!==t?P`
<line x1="${N.toFixed(1)}" y1="${8}" x2="${N.toFixed(1)}" y2="${136 .toFixed(1)}"
<line x1="${U.toFixed(1)}" y1="${8}" x2="${U.toFixed(1)}" y2="${136 .toFixed(1)}"
stroke="var(--success-color, #4caf50)" stroke-width="1.5" stroke-dasharray="4,3" />
`:d}
@@ -4084,7 +4118,7 @@ ${A(n.notes)}</div>`:""}
${t>0?r`<span class="legend-item"><span class="legend-swatch" style="background:var(--primary-color, #03a9f4); opacity:0.5"></span> ${s("current_interval_marker",i)}</span>`:d}
${e>0&&e!==t?r`<span class="legend-item"><span class="legend-swatch" style="background:var(--success-color, #4caf50)"></span> ${s("recommended_marker",i)}</span>`:d}
</div>
`}function _i(n,o){return r`
`}function gi(n,o){return r`
<div class="weibull-info-row">
<div class="weibull-info-item">
<span>${s("characteristic_life",o)}</span>
@@ -4097,13 +4131,13 @@ ${A(n.notes)}</div>`:""}
</div>
`:d}
</div>
`}function gi(n,o,t){let e=n.confidence_interval_low,i=n.confidence_interval_high,a=o.suggested_interval??o.interval_days??0,l=o.interval_days??0,h=Math.max(0,e-5),p=i+5-h,u=(e-h)/p*100,g=(i-e)/p*100,v=(a-h)/p*100,b=l>0?(l-h)/p*100:-1;return r`
`}function _i(n,o,t){let e=n.confidence_interval_low,i=n.confidence_interval_high,a=o.suggested_interval??o.interval_days??0,l=o.interval_days??0,h=Math.max(0,e-5),p=i+5-h,u=(e-h)/p*100,_=(i-e)/p*100,v=(a-h)/p*100,b=l>0?(l-h)/p*100:-1;return r`
<div class="confidence-range">
<div class="confidence-range-title">
${s("confidence_interval",t)}: ${a} ${s("days",t)} (${e}\u2013${i})
</div>
<div class="confidence-bar">
<div class="confidence-fill" style="left:${u.toFixed(1)}%;width:${g.toFixed(1)}%"></div>
<div class="confidence-fill" style="left:${u.toFixed(1)}%;width:${_.toFixed(1)}%"></div>
${b>=0?r`<div class="confidence-marker current" style="left:${b.toFixed(1)}%"></div>`:d}
<div class="confidence-marker recommended" style="left:${v.toFixed(1)}%"></div>
</div>
@@ -4147,7 +4181,7 @@ ${A(n.notes)}</div>`:""}
<span class="legend-item"><span class="dot high"></span> ${s("longer",o)||"L\xE4nger"}</span>
</div>
</div>
`}function Ce(n,o){return mi(n,o)}function mi(n,o){let t=n.seasonal_factors??n.interval_analysis?.seasonal_factors;if(!t||t.length!==12)return d;let e=n.interval_analysis?.seasonal_reason,i=new Date().getMonth(),a=300,l=100,h=8,p=l-h-4,u=Math.max(...t,1.5),g=a/12,v=g*.65,b=h+p-1/u*p;return r`
`}function Ce(n,o){return mi(n,o)}function mi(n,o){let t=n.seasonal_factors??n.interval_analysis?.seasonal_factors;if(!t||t.length!==12)return d;let e=n.interval_analysis?.seasonal_reason,i=new Date().getMonth(),a=300,l=100,h=8,p=l-h-4,u=Math.max(...t,1.5),_=a/12,v=_*.65,b=h+p-1/u*p;return r`
<div class="seasonal-chart">
<div class="seasonal-chart-title">
<ha-svg-icon aria-hidden="true" path="M17.75 4.09L15.22 6.03L16.13 9.09L13.5 7.28L10.87 9.09L11.78 6.03L9.25 4.09L12.44 4L13.5 1L14.56 4L17.75 4.09M21.25 11L19.61 12.25L20.2 14.23L18.5 13.06L16.8 14.23L17.39 12.25L15.75 11L17.81 10.95L18.5 9L19.19 10.95L21.25 11M18.97 15.95C19.8 15.87 20.69 17.05 20.16 17.8C19.84 18.25 19.5 18.67 19.08 19.07C15.17 23 8.84 23 4.94 19.07C1.03 15.17 1.03 8.83 4.94 4.93C5.34 4.53 5.76 4.17 6.21 3.85C6.96 3.32 8.14 4.21 8.06 5.04C7.79 7.9 8.75 10.87 10.95 13.06C13.14 15.26 16.1 16.22 18.97 15.95Z"></ha-svg-icon>
@@ -4157,9 +4191,9 @@ ${A(n.notes)}</div>`:""}
<svg viewBox="0 0 ${a} ${l}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_seasonal",o)}">
<line x1="0" y1="${b.toFixed(1)}" x2="${a}" y2="${b.toFixed(1)}"
stroke="var(--divider-color)" stroke-width="1" stroke-dasharray="4,3" />
${t.map((x,f)=>{let M=x/u*p,S=f*g+(g-v)/2,I=h+p-M,R=f===i,j=x<1?"var(--success-color, #4caf50)":x>1?"var(--warning-color, #ff9800)":"var(--secondary-text-color)";return P`
<rect x="${S.toFixed(1)}" y="${I.toFixed(1)}"
width="${v.toFixed(1)}" height="${M.toFixed(1)}"
${t.map((x,f)=>{let S=x/u*p,M=f*_+(_-v)/2,I=h+p-S,R=f===i,j=x<1?"var(--success-color, #4caf50)":x>1?"var(--warning-color, #ff9800)":"var(--secondary-text-color)";return P`
<rect x="${M.toFixed(1)}" y="${I.toFixed(1)}"
width="${v.toFixed(1)}" height="${S.toFixed(1)}"
fill="${j}" opacity="${R?1:.5}" rx="2" />
`})}
</svg>
@@ -4191,16 +4225,16 @@ ${A(n.notes)}</div>`:""}
</div>
${fi(n,o,t)}
</div>
`}function fi(n,o,t){let e=n.history.filter($=>$.type==="completed"&&($.cost!=null||$.duration!=null)).map($=>({ts:new Date($.timestamp).getTime(),cost:$.cost??0,duration:$.duration??0})).sort(($,C)=>$.ts-C.ts);if(e.length<2)return d;let i=e.some($=>$.cost>0),a=e.some($=>$.duration>0);if(!i&&!a)return d;let l=t!=="duration"&&i,h=t!=="cost"&&a,c=l||!h&&i,p=h||!l&&a,u=640,g=vi,v=c?44:12,b=p?44:12,x=u-v-b,f=g-bi,M=f-kt,S=e[0].ts,I=e[e.length-1].ts,R=(I-S||864e5)*.05,j=S-R,y=I+R,N=Ft(S,I),W=$=>v+($-j)/(y-j)*x,H=wt(0,Math.max(...e.map($=>$.cost))||1,3),O=wt(0,Math.max(...e.map($=>$.duration))||1,3),Z=$=>kt+(1-$/(H.niceMax||1))*M,st=$=>kt+(1-$/(O.niceMax||1))*M,rt=e.length>1?Math.min(...e.slice(1).map(($,C)=>W($.ts)-W(e[C].ts))):x,U=Math.max(6,Math.min(22,rt*.55)),w=Bt(S,I,Math.max(2,Math.min(4,e.length)));return r`
`}function fi(n,o,t){let e=n.history.filter($=>$.type==="completed"&&($.cost!=null||$.duration!=null)).map($=>({ts:new Date($.timestamp).getTime(),cost:$.cost??0,duration:$.duration??0})).sort(($,C)=>$.ts-C.ts);if(e.length<2)return d;let i=e.some($=>$.cost>0),a=e.some($=>$.duration>0);if(!i&&!a)return d;let l=t!=="duration"&&i,h=t!=="cost"&&a,c=l||!h&&i,p=h||!l&&a,u=640,_=vi,v=c?44:12,b=p?44:12,x=u-v-b,f=_-bi,S=f-kt,M=e[0].ts,I=e[e.length-1].ts,R=(I-M||864e5)*.05,j=M-R,y=I+R,U=Ft(M,I),W=$=>v+($-j)/(y-j)*x,H=wt(0,Math.max(...e.map($=>$.cost))||1,3),O=wt(0,Math.max(...e.map($=>$.duration))||1,3),Z=$=>kt+(1-$/(H.niceMax||1))*S,st=$=>kt+(1-$/(O.niceMax||1))*S,rt=e.length>1?Math.min(...e.slice(1).map(($,C)=>W($.ts)-W(e[C].ts))):x,N=Math.max(6,Math.min(22,rt*.55)),w=Bt(M,I,Math.max(2,Math.min(4,e.length)));return r`
<div class="sparkline-container">
<svg class="history-chart" viewBox="0 0 ${u} ${g}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_history",o)}">
<svg class="history-chart" viewBox="0 0 ${u} ${_}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_history",o)}">
${c?H.ticks.map($=>{let C=Z($);return C<kt-1||C>f+1?d:P`
<line x1="${v}" y1="${C.toFixed(1)}" x2="${u-b}" y2="${C.toFixed(1)}" stroke="var(--divider-color)" stroke-width="1" opacity="0.55" />
<text x="${v-6}" y="${(C+3.5).toFixed(1)}" text-anchor="end" fill="var(--primary-color)" font-size="10.5">${ct($)}€</text>`}):d}
${p?O.ticks.map($=>{let C=st($);return C<kt-1||C>f+1?d:P`<text x="${u-b+6}" y="${(C+3.5).toFixed(1)}" text-anchor="start" fill="var(--accent-color, #ff9800)" font-size="10.5">${ct($)}m</text>`}):d}
${c?e.filter($=>$.cost>0).map($=>P`
<rect x="${(W($.ts)-U/2).toFixed(1)}" y="${Z($.cost).toFixed(1)}" width="${U.toFixed(1)}" height="${(f-Z($.cost)).toFixed(1)}"
<rect x="${(W($.ts)-N/2).toFixed(1)}" y="${Z($.cost).toFixed(1)}" width="${N.toFixed(1)}" height="${(f-Z($.cost)).toFixed(1)}"
fill="var(--primary-color)" opacity="0.6" rx="2">
<title>${yt($.ts,o,!0)}: ${$.cost.toLocaleString(o)}€${$.duration?` \xB7 ${$.duration}m`:""}</title>
</rect>
@@ -4216,18 +4250,18 @@ ${A(n.notes)}</div>`:""}
`:d}
<line x1="${v}" y1="${f}" x2="${u-b}" y2="${f}" stroke="var(--divider-color)" stroke-width="1" />
${w.map(($,C)=>{let Ut=C===0?"start":C===w.length-1?"end":"middle";return P`<text x="${W($).toFixed(1)}" y="${g-6}" text-anchor="${Ut}" fill="var(--secondary-text-color)" font-size="10">${yt($,o,N)}</text>`})}
${w.map(($,C)=>{let Nt=C===0?"start":C===w.length-1?"end":"middle";return P`<text x="${W($).toFixed(1)}" y="${_-6}" text-anchor="${Nt}" fill="var(--secondary-text-color)" font-size="10">${yt($,o,U)}</text>`})}
</svg>
</div>
<div class="chart-legend">
${c?r`<span class="legend-item"><span class="legend-swatch" style="background:var(--primary-color);opacity:0.6"></span>${s("cost",o)}</span>`:d}
${p?r`<span class="legend-item"><span class="legend-swatch" style="background:var(--accent-color, #ff9800)"></span>${s("duration",o)}</span>`:d}
</div>
`}var gt=class extends L{constructor(){super(...arguments);this.docId="";this._url="";this._failed=!1;this._signedFor=""}updated(){this.hass&&this.docId&&this._signedFor!==this.docId&&(this._signedFor=this.docId,this._url="",this._failed=!1,this._sign())}async _sign(){try{let t=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${this.docId}`,expires:300});this._url=t.path}catch{this._failed=!0}}render(){return this._failed||!this.docId?d:this._url?r`
`}var _t=class extends L{constructor(){super(...arguments);this.docId="";this._url="";this._failed=!1;this._signedFor=""}updated(){this.hass&&this.docId&&this._signedFor!==this.docId&&(this._signedFor=this.docId,this._url="",this._failed=!1,this._sign())}async _sign(){try{let t=await this.hass.connection.sendMessagePromise({type:"auth/sign_path",path:`/api/maintenance_supporter/document/${this.docId}`,expires:300});this._url=t.path}catch{this._failed=!0}}render(){return this._failed||!this.docId?d:this._url?r`
<a href=${this._url} target="_blank" rel="noopener" class="wrap">
<img src=${this._url} alt="" loading="lazy"
@error=${()=>this._failed=!0} />
</a>`:r`<div class="ph"></div>`}};gt.styles=D`
</a>`:r`<div class="ph"></div>`}};_t.styles=D`
.wrap { display: inline-block; margin-top: 4px; }
img {
max-width: 96px;
@@ -4243,7 +4277,7 @@ ${A(n.notes)}</div>`:""}
background: var(--secondary-background-color, rgba(0,0,0,0.06));
margin-top: 4px;
}
`,_([T({attribute:!1})],gt.prototype,"hass",2),_([T()],gt.prototype,"docId",2),_([m()],gt.prototype,"_url",2),_([m()],gt.prototype,"_failed",2);customElements.get("maintenance-history-photo")||customElements.define("maintenance-history-photo",gt);var yi=["completed","skipped","missed","reset","triggered"];function Re(n,o){let t=o.lang;return r`
`,g([T({attribute:!1})],_t.prototype,"hass",2),g([T()],_t.prototype,"docId",2),g([m()],_t.prototype,"_url",2),g([m()],_t.prototype,"_failed",2);customElements.get("maintenance-history-photo")||customElements.define("maintenance-history-photo",_t);var yi=["completed","skipped","missed","reset","triggered"];function Re(n,o){let t=o.lang;return r`
<div class="history-filters-new">
<div class="filter-chips">
${yi.map(e=>{let i=n.history.filter(a=>a.type===e).length;return i===0?d:r`
@@ -4265,7 +4299,7 @@ ${A(n.notes)}</div>`:""}
`}function xi(n,o){let t=o.lang,e=["completed","reset","skipped"].includes(n.type);return r`
<div class="history-entry">
<div class="history-icon ${n.type}">
<ha-icon .icon=${Mt[n.type]||"mdi:circle"}></ha-icon>
<ha-icon .icon=${St[n.type]||"mdi:circle"}></ha-icon>
</div>
<div class="history-content">
<div class="history-row">
@@ -4437,7 +4471,7 @@ ${A(n.notes)}</div>`:""}
<div class="kpi-value">${n.average_duration?n.average_duration.toFixed(0):"\u2014"} min</div>
</div>
</div>
`}function Mi(n,o){let t=o.lang;if(!o.features.adaptive||!n.suggested_interval||n.suggested_interval===n.interval_days)return d;if(o.suggestionDismissed)return d;let e=n.suggested_interval;return r`
`}function Si(n,o){let t=o.lang;if(!o.features.adaptive||!n.suggested_interval||n.suggested_interval===n.interval_days)return d;if(o.suggestionDismissed)return d;let e=n.suggested_interval;return r`
<div class="recommendation-card">
<h4>${s("suggested_interval",t)}</h4>
${Ee(n.interval_days,e,n.interval_confidence||"medium",t)}
@@ -4456,7 +4490,7 @@ ${A(n.notes)}</div>`:""}
</ha-button>
</div>
</div>
`}function Si(n,o){let t=o.lang,e=n.history.slice(-3).reverse();if(e.length===0)return d;let i=a=>{switch(a){case"completed":return"\u2713";case"triggered":return"\u2297";case"skipped":return"\u21B7";case"reset":return"\u21BA";default:return"\xB7"}};return r`
`}function Mi(n,o){let t=o.lang,e=n.history.slice(-3).reverse();if(e.length===0)return d;let i=a=>{switch(a){case"completed":return"\u2713";case"triggered":return"\u2297";case"skipped":return"\u21B7";case"reset":return"\u21BA";default:return"\xB7"}};return r`
<div class="recent-activities">
<h3>${s("recent_activities",t)}</h3>
${e.map(a=>r`
@@ -4480,12 +4514,12 @@ ${A(n.notes)}</div>`:""}
${n.battery_fleet_task?d:r`
${$e(n,o.lang)}
${ke(n,o.sparkline)}
${Me(n,t,o.features)}
${Se(n,t,o.features)}
`}
<div class="two-column-layout ${a?"":"single-column"}">
${a?r`
<div class="left-column">
${Mi(n,o)}
${Si(n,o)}
${Le(n,t,o.features)}
</div>
`:d}
@@ -4493,7 +4527,7 @@ ${A(n.notes)}</div>`:""}
${Ae(n,t,o.costDurationToggle,c=>o.setCostDurationToggle(c))}
</div>
</div>
${l?Pe("weibull","weibull_reliability_curve",Se(n,t),o):d}
${l?Pe("weibull","weibull_reliability_curve",Me(n,t),o):d}
${h?Pe("seasonal","seasonal_chart_title",r`
${Ce(n,t)}
<div class="seasonal-actions">
@@ -4503,7 +4537,7 @@ ${A(n.notes)}</div>`:""}
</div>
`,o):d}
${ki(n,o)}
${Si(n,o)}
${Mi(n,o)}
</div>
`}function Di(n,o){return r`
<div class="tab-content history-tab">
@@ -4522,7 +4556,7 @@ ${A(n.notes)}</div>`:""}
.canWrite=${!o.isOperator}
></maintenance-task-documents>
</div>
`}var Tt=class extends L{createRenderRoot(){return this}render(){return!this.task||!this.ctx?d:r`${ze(this.task,this.ctx)}`}};_([T({attribute:!1})],Tt.prototype,"task",2),_([T({attribute:!1})],Tt.prototype,"ctx",2);customElements.get("maintenance-task-detail-view")||customElements.define("maintenance-task-detail-view",Tt);function Ie(n){if(n.total<=0)return{start:0,end:0,padTop:0,padBottom:0};let o=n.overscan??12,t=Math.max(1,n.step??6),e=Math.max(1,n.rowHeight),i=Math.floor((n.scrollTop-n.listTop)/e),a=Math.ceil(n.viewportHeight/e)+1,l=Math.max(0,i-o);l=Math.floor(l/t)*t;let h=Math.min(n.total,Math.max(i,0)+a+o);return h=Math.min(n.total,Math.ceil(h/t)*t),l>=h&&(l=Math.min(l,Math.max(0,n.total-1)),h=Math.min(n.total,l+Math.max(a,1))),{start:l,end:h,padTop:l*e,padBottom:(n.total-h)*e}}var k=class extends L{constructor(){super(...arguments);this.narrow=!1;this.panel={};this._objects=[];this._stats=null;this._view="overview";this._selectedEntryId=null;this._selectedTaskId=null;this._filterStatus="";this._filterUser=null;this._filterLabel=null;this._savedViews=[];this._activeViewId="";this._unsub=null;this._chartRangeDays=(()=>{try{let t=parseInt(localStorage.getItem(F.chartRange)||"",10);return[7,30,90,365].includes(t)?t:30}catch{return 30}})();this._hideOutliers=(()=>{try{return localStorage.getItem(F.chartHideOutliers)==="1"}catch{return!1}})();this._historyFilter=null;this._budget=null;this._groups={};this._detailStatsData=new Map;this._miniStatsData=new Map;this._features={adaptive:!1,predictions:!1,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1};this._adminPanelUserIds=[];this._operatorWriteEnabled=!1;this._defaultWarningDays=7;this._actionLoading=!1;this._moreMenuOpen=!1;this._objMenuOpen=!1;this._toastMessage="";this._toastUndo=null;this._toastActionLabel="";this._filtersOpen=!1;this._actionsMenuOpen=!1;this._batteryFleetSetupAvailable=!1;this._staleBundle=!1;this._staleChecked=!1;this._toastTimer=null;this._dismissedSuggestions=new Set;this._overviewTab=(()=>{try{let t=localStorage.getItem(F.overviewTab);return t==="today"||t==="calendar"?t:"dashboard"}catch{return"dashboard"}})();this._activeTab="overview";this._costDurationToggle="both";this._historySearch="";this._sortMode="due_date";this._objectSortMode="alphabetical";this._groupByMode="none";this._objectViewMode="cards";this._objectsTableColumns=ae;this._showArchived=!1;this._bulkMode=!1;this._bulkSelected=new Set;this._virtStart=0;this._virtEnd=0;this._virtRowHeight=53;this._virtTotalRows=0;this._virtScrollAttached=!1;this._virtRaf=0;this._collapsedSections=(()=>{try{return new Set(JSON.parse(localStorage.getItem(F.collapsedSections)||"[]"))}catch{return new Set}})();this._paletteOpen=!1;this._paletteQuery="";this._paletteActive=0;this._templateGalleryOpen=!1;this._templates=[];this._templateCategories={};this._templateBusy=!1;this._statsService=null;this._userService=null;this._dataLoaded=!1;this._lastConnection=null;this._popstateHandler=t=>this._onPopState(t);this._lazyUi=null;this._onVirtualScroll=()=>{this._virtRaf||(this._virtRaf=requestAnimationFrame(()=>{this._virtRaf=0,this._updateVirtualWindow()}))};this._deepLinkHandled=!1;this._paletteKeydown=t=>{if(t.key==="/"&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&!this._paletteOpen){let i=t.composedPath()[0];if(i instanceof HTMLElement&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable))return;t.preventDefault(),this._openPalette();return}if(!this._paletteOpen)return;let e=this._paletteResults;if(t.key==="Escape")t.preventDefault(),this._closePalette();else if(t.key==="ArrowDown")t.preventDefault(),this._paletteActive=Math.min(this._paletteActive+1,e.length-1);else if(t.key==="ArrowUp")t.preventDefault(),this._paletteActive=Math.max(this._paletteActive-1,0);else if(t.key==="Enter"){t.preventDefault();let i=e[this._paletteActive];i&&this._selectPaletteResult(i)}};this._onDialogEvent=async()=>{try{await this._loadData()}catch{}};this._onCalendarLlCustom=t=>{let e=t.detail;e?.type==="maintenance-supporter:open-task"&&e.entry_id&&e.task_id&&(t.stopPropagation(),this._showTask(e.entry_id,e.task_id))};this._fullHistory=null;this._onHistoryEntrySaved=async()=>{await this._loadData()}}get _lang(){return this.hass?.language||"en"}get _isOperator(){let t=this.hass?.user;return t?t.is_admin?!1:!(this._operatorWriteEnabled&&this._adminPanelUserIds.includes(t.id)):!0}_ensureLazyUi(){return this._lazyUi||(this._lazyUi=Promise.all([import("/maintenance_supporter_panelfiles/panel-chunks/object-dialog-IU7V7TDN.js"),import("/maintenance_supporter_panelfiles/panel-chunks/task-dialog-5VUS7JEH.js"),import("/maintenance_supporter_panelfiles/panel-chunks/complete-dialog-KGRPNNX2.js"),import("/maintenance_supporter_panelfiles/panel-chunks/qr-dialog-U2M7KFS3.js"),import("/maintenance_supporter_panelfiles/panel-chunks/adopt-problem-sensors-dialog-EEQGF7EF.js"),import("/maintenance_supporter_panelfiles/panel-chunks/suggested-setups- Line truncated
`}var Tt=class extends L{createRenderRoot(){return this}render(){return!this.task||!this.ctx?d:r`${ze(this.task,this.ctx)}`}};g([T({attribute:!1})],Tt.prototype,"task",2),g([T({attribute:!1})],Tt.prototype,"ctx",2);customElements.get("maintenance-task-detail-view")||customElements.define("maintenance-task-detail-view",Tt);function Ie(n){if(n.total<=0)return{start:0,end:0,padTop:0,padBottom:0};let o=n.overscan??12,t=Math.max(1,n.step??6),e=Math.max(1,n.rowHeight),i=Math.floor((n.scrollTop-n.listTop)/e),a=Math.ceil(n.viewportHeight/e)+1,l=Math.max(0,i-o);l=Math.floor(l/t)*t;let h=Math.min(n.total,Math.max(i,0)+a+o);return h=Math.min(n.total,Math.ceil(h/t)*t),l>=h&&(l=Math.min(l,Math.max(0,n.total-1)),h=Math.min(n.total,l+Math.max(a,1))),{start:l,end:h,padTop:l*e,padBottom:(n.total-h)*e}}var k=class extends L{constructor(){super(...arguments);this.narrow=!1;this.panel={};this._objects=[];this._stats=null;this._view="overview";this._selectedEntryId=null;this._selectedTaskId=null;this._filterStatus="";this._filterUser=null;this._filterLabel=null;this._savedViews=[];this._activeViewId="";this._unsub=null;this._chartRangeDays=(()=>{try{let t=parseInt(localStorage.getItem(F.chartRange)||"",10);return[7,30,90,365].includes(t)?t:30}catch{return 30}})();this._hideOutliers=(()=>{try{return localStorage.getItem(F.chartHideOutliers)==="1"}catch{return!1}})();this._historyFilter=null;this._budget=null;this._groups={};this._detailStatsData=new Map;this._miniStatsData=new Map;this._features={adaptive:!1,predictions:!1,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1};this._adminPanelUserIds=[];this._operatorWriteEnabled=!1;this._defaultWarningDays=7;this._actionLoading=!1;this._moreMenuOpen=!1;this._objMenuOpen=!1;this._toastMessage="";this._toastUndo=null;this._toastActionLabel="";this._filtersOpen=!1;this._newMenuOpen=!1;this._gsSetupsCount=0;this._gsAdoptCount=0;this._gsLoaded=!1;this._batteryFleetSetupAvailable=!1;this._staleBundle=!1;this._staleChecked=!1;this._toastTimer=null;this._dismissedSuggestions=new Set;this._overviewTab=(()=>{try{let t=localStorage.getItem(F.overviewTab);return t==="today"||t==="calendar"?t:"dashboard"}catch{return"dashboard"}})();this._activeTab="overview";this._costDurationToggle="both";this._historySearch="";this._sortMode="due_date";this._objectSortMode="alphabetical";this._groupByMode="none";this._objectViewMode="cards";this._objectsTableColumns=ae;this._showArchived=!1;this._bulkMode=!1;this._bulkSelected=new Set;this._virtStart=0;this._virtEnd=0;this._virtRowHeight=53;this._virtTotalRows=0;this._virtScrollAttached=!1;this._virtRaf=0;this._collapsedSections=(()=>{try{return new Set(JSON.parse(localStorage.getItem(F.collapsedSections)||"[]"))}catch{return new Set}})();this._paletteOpen=!1;this._paletteQuery="";this._paletteActive=0;this._templateGalleryOpen=!1;this._templates=[];this._templateCategories={};this._templateBusy=!1;this._statsService=null;this._userService=null;this._dataLoaded=!1;this._lastConnection=null;this._popstateHandler=t=>this._onPopState(t);this._lazyUi=null;this._onVirtualScroll=()=>{this._virtRaf||(this._virtRaf=requestAnimationFrame(()=>{this._virtRaf=0,this._updateVirtualWindow()}))};this._deepLinkHandled=!1;this._paletteKeydown=t=>{if(t.key==="/"&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&!this._paletteOpen){let i=t.composedPath()[0];if(i instanceof HTMLElement&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable))return;t.preventDefault(),this._openPalette();return}if(!this._paletteOpen)return;let e=this._paletteResults;if(t.key==="Escape")t.preventDefault(),this._closePalette();else if(t.key==="ArrowDown")t.preventDefault(),this._paletteActive=Math.min(this._paletteActive+1,e.length-1);else if(t.key==="ArrowUp")t.preventDefault(),this._paletteActive=Math.max(this._paletteActive-1,0);else if(t.key==="Enter"){t.preventDefault();let i=e[this._paletteActive];i&&this._selectPaletteResult(i)}};this._onDialogEvent=async()=>{try{await this._loadData()}catch{}};this._onCalendarLlCustom=t=>{let e=t.detail;e?.type==="maintenance-supporter:open-task"&&e.entry_id&&e.task_id&&(t.stopPropagation(),this._showTask(e.entry_id,e.task_id))};this._fullHistory=null;this._onHistoryEntrySaved=async()=>{await this._loadData()}}get _lang(){return this.hass?.language||"en"}get _isOperator(){let t=this.hass?.user;return t?t.is_admin?!1:!(this._operatorWriteEnabled&&this._adminPanelUserIds.includes(t.id)):!0}_ensureLazyUi(){return this._lazyUi||(this._lazyUi=Promise.all([import("/maintenance_supporter_panelfiles/panel-chunks/object-dialog-MJEKQGZX.js"),import("/maintenance_supporter_panelfiles/panel-chunks/task-dialog-5FAYDEJA.js"),import("/maintenance_supporter_panelfiles/panel-chunks/complete-dialog-IWH3ZTRB.js"),import("/maintenance_supporter_panelfiles/panel-chunks/qr-dialog-7BZLBCBJ.js"),import("/maintenance_supporter_panelfiles/panel-chunks/adopt-problem-sensors-dialog-NKSR5P67.js"),import("/mainte Line truncated
<div class="palette-backdrop" @click=${()=>this._closePalette()}>
<div class="palette" @click=${i=>i.stopPropagation()}>
<input
@@ -4575,7 +4609,7 @@ ${A(n.notes)}</div>`:""}
</div>
</div>
</div>
`}_bulkKey(t){return`${t.entry_id}:${t.task_id}`}_toggleBulkMode(){this._bulkMode=!this._bulkMode,this._bulkMode||(this._bulkSelected=new Set)}_toggleBulkRow(t){let e=this._bulkKey(t),i=new Set(this._bulkSelected);i.has(e)?i.delete(e):i.add(e),this._bulkSelected=i}_bulkSelectAll(t){let e=t.map(a=>this._bulkKey(a)),i=e.every(a=>this._bulkSelected.has(a));this._bulkSelected=i?new Set:new Set(e)}async _runBulk(t,e,i,a){let l=t.filter(c=>this._bulkSelected.has(this._bulkKey(c)));if(l.length===0)return;this._actionLoading=!0;let h=0;for(let c of l)try{await this.hass.connection.sendMessagePromise(e(c)),h++}catch{}this._actionLoading=!1,this._bulkSelected=new Set,this._bulkMode=!1,await this._loadData(),a&&h>0?this._showUndoToast(i(h),a):this._showToast(i(h))}_bulkComplete(t){this._runBulk(t,e=>({type:"maintenance_supporter/task/complete",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_completed",this._lang).replace("{n}",String(e)))}_bulkArchive(t){let e=t.filter(i=>this._bulkSelected.has(this._bulkKey(i))).map(i=>({entry_id:i.entry_id,task_id:i.task_id}));this._runBulk(t,i=>({type:"maintenance_supporter/task/archive",entry_id:i.entry_id,task_id:i.task_id}),i=>s("bulk_archived",this._lang).replace("{n}",String(i)),async()=>{for(let i of e)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/unarchive",entry_id:i.entry_id,task_id:i.task_id})}catch{}await this._loadData()})}async _deleteObject(t){if(await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("confirm_delete_object",this._lang),confirmText:s("delete",this._lang),danger:!0}))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/delete",entry_id:t}),this._showOverview(),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}_printObjectReport(t){let e=this._getObject(t);if(!e)return;let i=this._lang,a={title:s("report_title",i),generated:s("report_generated",i),manufacturer:s("manufacturer",i),model:s("model",i),serial:s("serial_number_label",i),installed:s("installed",i),warranty:s("warranty",i),area:s("area",i),notes:s("report_notes",i),tasksHeading:s("tasks",i),colTask:s("task_name",i),colType:s("report_col_type",i),colStatus:s("report_col_status",i),colSchedule:s("report_col_schedule",i),colLastDone:s("last_performed",i),colNextDue:s("next_due",i),colCost:s("cost",i),colTimes:s("report_times_done",i),totalCost:s("report_total_cost",i),scheduleLabel:c=>xt(c,i),none:"\u2014",statusLabel:c=>s(c,i),typeLabel:c=>s(c,i)},l=he(e.object,e.tasks,a,c=>c?Y(c,i):"",this._budget?.currency_symbol||ut,new Date().toISOString()),h=URL.createObjectURL(new Blob([l],{type:"text/html"}));window.open(h,"_blank"),setTimeout(()=>URL.revokeObjectURL(h),6e4)}async _duplicateObject(t){this._actionLoading=!0;try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/duplicate",entry_id:t});await this._loadData(),this._showToast(s("object_duplicated",this._lang)),e?.entry_id&&this._showObject(e.entry_id)}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _deleteTask(t,e){if(await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("confirm_delete_task",this._lang),confirmText:s("delete",this._lang),danger:!0}))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/delete",entry_id:t,task_id:e}),this._showObject(t),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}async _duplicateTask(t,e){this._moreMenuOpen=!1,this._actionLoading=!0;try{let i=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/duplicate",entry_id:t,task_id:e});await this._loadData(),this._showToast(s("task_duplicated",this._lang)),i?.task_id&&this._showTask(t,i.task_id)}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _toggleArchiveTask(t,e,i){this._actionLoading=!0;try{await this.hass.connection.sendMessagePromise({type:i?"maintenance_supporter/task/unarchive":"maintenance_supporter/task/archive",entry_id:t,task_id:e}),await this._loadData(),i||this._showUndoToast(s("task_archived",this._lang),()=>this._toggleArchiveTask(t,e,!0))}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _toggleArchiveObject(t,e){try{await this.hass.connection.sendMessagePromise({type:e?"maintenance_supporter/object/unarchive":"maintenance_supporter/object/archive",entry_id:t}),await this._loadData(),e||this._showUndoToast(s("object_archived",this._lang),()=>this._toggleArchiveObject(t,!0))}catch{this._showToast(s("action_error",this._lang))}}async _togglePauseObject(t,e){if(!e){let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("pause_object",this._lang),message:s("pause_until_prompt",this._lang),confirmText:s("pause_object",this._lang),inputLabel:s("pause_until_ Line truncated
`}_bulkKey(t){return`${t.entry_id}:${t.task_id}`}_toggleBulkMode(){this._bulkMode=!this._bulkMode,this._bulkMode||(this._bulkSelected=new Set)}_toggleBulkRow(t){let e=this._bulkKey(t),i=new Set(this._bulkSelected);i.has(e)?i.delete(e):i.add(e),this._bulkSelected=i}_bulkSelectAll(t){let e=t.map(a=>this._bulkKey(a)),i=e.every(a=>this._bulkSelected.has(a));this._bulkSelected=i?new Set:new Set(e)}async _runBulk(t,e,i,a){let l=t.filter(c=>this._bulkSelected.has(this._bulkKey(c)));if(l.length===0)return;this._actionLoading=!0;let h=0;for(let c of l)try{await this.hass.connection.sendMessagePromise(e(c)),h++}catch{}this._actionLoading=!1,this._bulkSelected=new Set,this._bulkMode=!1,await this._loadData(),a&&h>0?this._showUndoToast(i(h),a):this._showToast(i(h))}_bulkComplete(t){this._runBulk(t,e=>({type:"maintenance_supporter/task/complete",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_completed",this._lang).replace("{n}",String(e)))}_bulkArchive(t){let e=t.filter(i=>this._bulkSelected.has(this._bulkKey(i))).map(i=>({entry_id:i.entry_id,task_id:i.task_id}));this._runBulk(t,i=>({type:"maintenance_supporter/task/archive",entry_id:i.entry_id,task_id:i.task_id}),i=>s("bulk_archived",this._lang).replace("{n}",String(i)),async()=>{for(let i of e)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/unarchive",entry_id:i.entry_id,task_id:i.task_id})}catch{}await this._loadData()})}async _deleteObject(t){if(await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("confirm_delete_object",this._lang),confirmText:s("delete",this._lang),danger:!0}))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/delete",entry_id:t}),this._showOverview(),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}_printObjectReport(t){let e=this._getObject(t);if(!e)return;let i=this._lang,a={title:s("report_title",i),generated:s("report_generated",i),manufacturer:s("manufacturer",i),model:s("model",i),serial:s("serial_number_label",i),installed:s("installed",i),warranty:s("warranty",i),area:s("area",i),notes:s("report_notes",i),tasksHeading:s("tasks",i),colTask:s("task_name",i),colType:s("report_col_type",i),colStatus:s("report_col_status",i),colSchedule:s("report_col_schedule",i),colLastDone:s("last_performed",i),colNextDue:s("next_due",i),colCost:s("cost",i),colTimes:s("report_times_done",i),totalCost:s("report_total_cost",i),scheduleLabel:c=>xt(c,i),none:"\u2014",statusLabel:c=>s(c,i),typeLabel:c=>s(c,i)},l=he(e.object,e.tasks,a,c=>c?Y(c,i):"",this._budget?.currency_symbol||ut,new Date().toISOString()),h=URL.createObjectURL(new Blob([l],{type:"text/html"}));window.open(h,"_blank"),setTimeout(()=>URL.revokeObjectURL(h),6e4)}async _duplicateObject(t){this._actionLoading=!0;try{let e=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/duplicate",entry_id:t});await this._loadData(),this._showToast(s("object_duplicated",this._lang)),e?.entry_id&&this._showObject(e.entry_id)}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _deleteTask(t,e){if(await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("confirm_delete_task",this._lang),confirmText:s("delete",this._lang),danger:!0}))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/delete",entry_id:t,task_id:e}),this._showObject(t),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}async _duplicateTask(t,e){this._moreMenuOpen=!1,this._actionLoading=!0;try{let i=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/duplicate",entry_id:t,task_id:e});await this._loadData(),this._showToast(s("task_duplicated",this._lang)),i?.task_id&&this._showTask(t,i.task_id)}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _toggleArchiveTask(t,e,i){this._actionLoading=!0;try{await this.hass.connection.sendMessagePromise({type:i?"maintenance_supporter/task/unarchive":"maintenance_supporter/task/archive",entry_id:t,task_id:e}),await this._loadData(),i||this._showUndoToast(s("task_archived",this._lang),()=>this._toggleArchiveTask(t,e,!0))}catch{this._showToast(s("action_error",this._lang))}finally{this._actionLoading=!1}}async _toggleArchiveObject(t,e){try{await this.hass.connection.sendMessagePromise({type:e?"maintenance_supporter/object/unarchive":"maintenance_supporter/object/archive",entry_id:t}),await this._loadData(),e||this._showUndoToast(s("object_archived",this._lang),()=>this._toggleArchiveObject(t,!0))}catch{this._showToast(s("action_error",this._lang))}}async _togglePauseObject(t,e){if(!e){let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("pause_object",this._lang),message:s("pause_until_prompt",this._lang),confirmText:s("pause_object",this._lang),inputLabel:s("pause_until_ Line truncated
<div class="panel">
${this._staleBundle?r`
<div class="update-banner" role="status">
@@ -4693,6 +4727,7 @@ ${A(n.notes)}</div>`:""}
<span class="stat-value" style="color: #ff5722">${i.triggered}</span>
<span class="stat-label">${s("triggered",t)}</span>
</div>
${this._features.budget?this._renderBudgetTiles():d}
</div>
`:d}
<div class="tab-bar">
@@ -4727,7 +4762,7 @@ ${A(n.notes)}</div>`:""}
.budget=${this._budget}
@settings-changed=${this._onSettingsChanged}
></maintenance-settings-view>`}
`}_statusBadge(t,e,i){let a=this._lang,l=t?"archived":e?"done":i,h=t?"archived":e?"completed":i,c=t?s("archived",a):e?s("completed",a):s(i,a);return r`<span class="status-badge ${l}"><ha-icon icon="${Mt[h]||"mdi:circle-medium"}"></ha-icon>${c}</span>`}_setOverviewTab(t){this._overviewTab=t;try{localStorage.setItem(F.overviewTab,t)}catch{}this._scrollContentToTop()}_renderToday(){let t=this._lang,e=this._taskRows,i=p=>`${p.entry_id}:${p.task_id}`,a=e.filter(p=>p.status==="overdue"||p.trigger_active),l=new Set(a.map(i)),h=e.filter(p=>!l.has(i(p))&&p.days_until_due===0);h.forEach(p=>l.add(i(p)));let c=e.filter(p=>!l.has(i(p))&&p.days_until_due!=null&&p.days_until_due>0&&p.days_until_due<=7);return a.length+h.length+c.length===0?r`
`}_statusBadge(t,e,i){let a=this._lang,l=t?"archived":e?"done":i,h=t?"archived":e?"completed":i,c=t?s("archived",a):e?s("completed",a):s(i,a);return r`<span class="status-badge ${l}"><ha-icon icon="${St[h]||"mdi:circle-medium"}"></ha-icon>${c}</span>`}_setOverviewTab(t){this._overviewTab=t;try{localStorage.setItem(F.overviewTab,t)}catch{}this._scrollContentToTop()}_renderToday(){let t=this._lang,e=this._taskRows,i=p=>`${p.entry_id}:${p.task_id}`,a=e.filter(p=>p.status==="overdue"||p.trigger_active),l=new Set(a.map(i)),h=e.filter(p=>!l.has(i(p))&&p.days_until_due===0);h.forEach(p=>l.add(i(p)));let c=e.filter(p=>!l.has(i(p))&&p.days_until_due!=null&&p.days_until_due>0&&p.days_until_due<=7);return a.length+h.length+c.length===0?r`
<div class="today-empty">
<ha-icon icon="mdi:check-circle-outline"></ha-icon>
<p>${s("today_all_caught_up",t)}</p>
@@ -4748,7 +4783,7 @@ ${A(n.notes)}</div>`:""}
<span class="today-dot ${l.trigger_active?"triggered":l.status}"></span>
<div class="today-main">
<div class="today-task">${l.task_name}</div>
<div class="today-object">${l.object_name} · ${_t(l.days_until_due,a)}</div>
<div class="today-object">${l.object_name} · ${gt(l.days_until_due,a)}</div>
</div>
<mwc-icon-button class="btn-complete" title="${s("complete",a)}"
@click=${h=>{h.stopPropagation(),this._openCompleteDialogForRow(l)}}>
@@ -4758,7 +4793,6 @@ ${A(n.notes)}</div>`:""}
`)}
</div>
`}_renderDashboard(){let t=this._stats,e=this._taskRows,i=this._lang,a=this._isOperator,l=this._objects.reduce((c,p)=>c+p.tasks.filter(u=>u.archived).length,0),h=(this._filterStatus?1:0)+(this._filterUser?1:0)+(this._filterLabel?1:0)+(this._activeViewId?1:0);return r`
${this._features.budget?this._renderBudgetBar():d}
${this.narrow?r`
<div class="mobile-controls">
@@ -4769,15 +4803,7 @@ ${A(n.notes)}</div>`:""}
<ha-icon icon="mdi:filter-variant"></ha-icon>
${s("filter_label",i)}${h>0?` (${h})`:""}
</ha-button>
${a?d:r`
<ha-button
class="mobile-toggle ${this._actionsMenuOpen?"active":""}"
@click=${()=>{this._actionsMenuOpen=!this._actionsMenuOpen}}
>
<ha-icon icon="mdi:plus"></ha-icon>
${s("add",i)}
</ha-button>
`}
${a?d:this._renderNewMenu(i)}
</div>
`:d}
@@ -4881,39 +4907,10 @@ ${A(n.notes)}</div>`:""}
${this._bulkMode?s("cancel",i):s("bulk_select",i)}
</ha-button>
`:d}
${!a&&!this.narrow?this._renderNewMenu(i):d}
</div>
${a?d:r`
<div
class="actions-bar ${this.narrow&&!this._actionsMenuOpen?"collapsed":""}"
@click=${()=>{this.narrow&&(this._actionsMenuOpen=!1)}}
>
<ha-button
@click=${()=>this._ui("maintenance-task-dialog").then(c=>c?.openCreate("",this._objects))}
>
${s("new_task",i)}
</ha-button>
<ha-button
@click=${()=>this._ui("maintenance-object-dialog").then(c=>c?.openCreate())}
>
${s("new_object",i)}
</ha-button>
<ha-button @click=${()=>this._openTemplateGallery()}>
<ha-icon icon="mdi:view-grid-plus-outline"></ha-icon> ${s("templates_from",i)}
</ha-button>
<ha-button @click=${()=>this._openAdoptProblemSensors()}>
<ha-icon icon="mdi:alert-circle-check-outline"></ha-icon> ${s("adopt_problem_button",i)}
</ha-button>
<ha-button @click=${()=>this._openSuggestedSetups()}>
<ha-icon icon="mdi:auto-fix"></ha-icon> ${s("setups_button",i)}
</ha-button>
${this._batteryFleetSetupAvailable?r`
<ha-button @click=${()=>this._setupBatteryFleet()}>
<ha-icon icon="mdi:battery-sync"></ha-icon> ${s("battery_fleet_setup_button",i)}
</ha-button>
`:d}
</div>
`}
${a?d:this._renderGettingStartedChips(i)}
${e.length===0?r`
<div class="empty-state">
@@ -4996,9 +4993,9 @@ ${A(n.notes)}</div>`:""}
</details>
`)}
`}_warrantyLabel(t,e,i){return t.kind==="expired"?s("warranty_expired",i):t.kind==="expiring"?s("warranty_expires_in",i).replace("{days}",String(t.days??0)):s("warranty_valid_until",i).replace("{date}",Y(e,i))}_renderWarrantyMeta(t,e){let i=Kt(t);return r`<p class="meta">${s("warranty",e)}:
<span class="warranty-chip warranty-${i.kind}">${this._warrantyLabel(i,t,e)}</span></p>`}_renderAllObjects(){let t=this._lang,e=this._isOperator,i=this._objectViewMode==="table"&&!this.narrow,a=this._objects.filter(u=>u.object.archived).length,l=u=>{let g=1/0;for(let v of u.tasks){let b=v.days_until_due;b!=null&&b<g&&(g=b)}return g},h=this._objects.filter(u=>this._showArchived||!u.object.archived);this._objectSortMode==="alphabetical"?h.sort((u,g)=>u.object.name.localeCompare(g.object.name)):this._objectSortMode==="task_count"?h.sort((u,g)=>g.tasks.length-u.tasks.length||u.object.name.localeCompare(g.object.name)):h.sort((u,g)=>l(u)-l(g)||u.object.name.localeCompare(g.object.name));let c=()=>{let u=new Map;for(let g of h){let v=g.object.area_id,b=v?this.hass?.areas?.[v]?.name||s("unassigned",t):s("no_area",t);u.has(b)||u.set(b,[]),u.get(b).push(g)}return new Map([...u.entries()].sort(([g],[v])=>g.localeCompare(v)))},p=u=>{let g=u.tasks.some(v=>v.status==="overdue"||v.status==="triggered");return r`
<div class="object-card${g?" object-card-overdue":""}" @click=${()=>this._showObject(u.entry_id)}>
${g?r`<span class="overdue-dot" title="${s("has_overdue",t)}"></span>`:d}
<span class="warranty-chip warranty-${i.kind}">${this._warrantyLabel(i,t,e)}</span></p>`}_renderAllObjects(){let t=this._lang,e=this._isOperator,i=this._objectViewMode==="table"&&!this.narrow,a=this._objects.filter(u=>u.object.archived).length,l=u=>{let _=1/0;for(let v of u.tasks){let b=v.days_until_due;b!=null&&b<_&&(_=b)}return _},h=this._objects.filter(u=>this._showArchived||!u.object.archived);this._objectSortMode==="alphabetical"?h.sort((u,_)=>u.object.name.localeCompare(_.object.name)):this._objectSortMode==="task_count"?h.sort((u,_)=>_.tasks.length-u.tasks.length||u.object.name.localeCompare(_.object.name)):h.sort((u,_)=>l(u)-l(_)||u.object.name.localeCompare(_.object.name));let c=()=>{let u=new Map;for(let _ of h){let v=_.object.area_id,b=v?this.hass?.areas?.[v]?.name||s("unassigned",t):s("no_area",t);u.has(b)||u.set(b,[]),u.get(b).push(_)}return new Map([...u.entries()].sort(([_],[v])=>_.localeCompare(v)))},p=u=>{let _=u.tasks.some(v=>v.status==="overdue"||v.status==="triggered");return r`
<div class="object-card${_?" object-card-overdue":""}" @click=${()=>this._showObject(u.entry_id)}>
${_?r`<span class="overdue-dot" title="${s("has_overdue",t)}"></span>`:d}
<div class="object-card-header">
<span class="object-card-name">${u.object.name}</span>
${u.object.paused?r`<span class="paused-badge" title="${s("object_paused_badge",t)}${u.object.paused_until?` \u2014 ${u.object.paused_until}`:""}">
@@ -5078,14 +5075,14 @@ ${A(n.notes)}</div>`:""}
`:d}
</div>
${i?this._renderObjectsTable(h):this._groupByMode==="area"?r`
${[...c().entries()].map(([u,g])=>r`
${[...c().entries()].map(([u,_])=>r`
<details class="group-section" open>
<summary class="group-section-header">
<ha-icon icon="mdi:map-marker-outline"></ha-icon>
<span>${u}</span>
<span class="group-section-count">(${g.length})</span>
<span class="group-section-count">(${_.length})</span>
</summary>
<div class="objects-grid">${g.map(p)}</div>
<div class="objects-grid">${_.map(p)}</div>
</details>
`)}
`:r`<div class="objects-grid">${h.map(p)}</div>`}
@@ -5150,33 +5147,25 @@ ${A(n.notes)}</div>`:""}
</div>
`}
</div>
`}_openGroupCreate(){this.shadowRoot.querySelector("maintenance-group-dialog")?.openCreate()}_openGroupEdit(t){let e=this._groups[t];e&&this.shadowRoot.querySelector("maintenance-group-dialog")?.openEdit(t,e)}async _deleteGroup(t,e){let i=this.shadowRoot.querySelector("maintenance-confirm-dialog");if(i?await i.confirm({title:s("delete_group",this._lang),message:s("delete_group_confirm",this._lang).replace("{name}",e),confirmText:s("delete",this._lang)}):confirm(`${s("delete_group_confirm",this._lang).replace("{name}",e)}`))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/delete",group_id:t}),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}_renderBudgetBar(){let t=this._budget;if(!t)return d;let e=this._lang,i=t.currency_symbol||ut,a=[];t.monthly_budget>0&&a.push({label:s("budget_monthly",e),spent:t.monthly_spent,budget:t.monthly_budget}),t.yearly_budget>0&&a.push({label:s("budget_yearly",e),spent:t.yearly_spent,budget:t.yearly_budget});let l=[];return t.monthly_budget>0||l.push({label:s("budget_monthly",e),spent:t.monthly_spent||0}),t.yearly_budget>0||l.push({label:s("budget_yearly",e),spent:t.yearly_spent||0}),r`
<div class="budget-bars">
${a.map(h=>{let c=Math.min(100,Math.max(0,h.spent/h.budget*100)),p=c>=100?"var(--error-color, #f44336)":c>=t.alert_threshold_pct?"var(--warning-color, #ff9800)":"var(--success-color, #4caf50)";return r`
<div class="budget-item">
<div class="budget-label">
<span>${h.label}</span>
<span>${h.spent.toFixed(2)} / ${h.budget.toFixed(2)} ${i}</span>
</div>
<div class="budget-bar">
<div class="budget-bar-fill" style="width:${c}%; background:${p}"></div>
</div>
</div>
`})}
${l.map(h=>r`
<div class="budget-item budget-spent-only">
<div class="budget-label">
<span>${h.label}</span>
<span>${h.spent.toFixed(2)} ${i}</span>
</div>
</div>
`)}
</div>
`}_renderOverviewRow(t){let e=this._lang,i=t.schedule_type==="time_based"&&t.interval_days&&t.interval_days>0,a=0,l=jt.ok,h=!1;if(i&&t.days_until_due!==null){let v=Ot(t.interval_days,t.days_until_due,t.interval_unit);a=v.pct,h=v.overflow,t.status==="overdue"?l=jt.overdue:t.status==="due_soon"&&(l=jt.due_soon)}let c=t.area_id?this.hass?.areas?.[t.area_id]?.name:null,p=t.responsible_user_id?this._userService?.getUserName(t.responsible_user_id):null,u=t.group_names.length>0||c||p,g=this._bulkMode&&this._bulkSelected.has(this._bulkKey(t));return r`
<div class="task-row${t.enabled?"":" task-disabled"}${g?" bulk-selected":""}">
`}_openGroupCreate(){this.shadowRoot.querySelector("maintenance-group-dialog")?.openCreate()}_openGroupEdit(t){let e=this._groups[t];e&&this.shadowRoot.querySelector("maintenance-group-dialog")?.openEdit(t,e)}async _deleteGroup(t,e){let i=this.shadowRoot.querySelector("maintenance-confirm-dialog");if(i?await i.confirm({title:s("delete_group",this._lang),message:s("delete_group_confirm",this._lang).replace("{name}",e),confirmText:s("delete",this._lang)}):confirm(`${s("delete_group_confirm",this._lang).replace("{name}",e)}`))try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/group/delete",group_id:t}),await this._loadData()}catch{this._showToast(s("action_error",this._lang))}}_renderBudgetTiles(){let t=this._budget;if(!t)return d;let e=this._lang,i=t.currency_symbol||ut,a=(l,h,c)=>{if(c!==null){let p=Math.min(100,Math.max(0,h/c*100)),u=p>=100?"var(--error-color, #f44336)":p>=t.alert_threshold_pct?"var(--warning-color, #ff9800)":"var(--success-color, #4caf50)";return r`
<div class="stat-item budget-tile" title="${l}: ${h.toFixed(2)} / ${c.toFixed(2)} ${i}">
<span class="stat-value budget-tile-value">${h.toFixed(2)} / ${c.toFixed(0)} ${i}</span>
<div class="budget-tile-bar"><div style="width:${p}%; background:${u}"></div></div>
<span class="stat-label">${l}</span>
</div>
`}return r`
<div class="stat-item budget-tile" title="${l}: ${h.toFixed(2)} ${i}">
<span class="stat-value budget-tile-value">${h.toFixed(2)} ${i}</span>
<span class="stat-label">${l}</span>
</div>
`};return r`
${a(s("budget_monthly",e),t.monthly_spent||0,t.monthly_budget>0?t.monthly_budget:null)}
${a(s("budget_yearly",e),t.yearly_spent||0,t.yearly_budget>0?t.yearly_budget:null)}
`}_renderOverviewRow(t){let e=this._lang,i=t.schedule_type==="time_based"&&t.interval_days&&t.interval_days>0,a=0,l=jt.ok,h=!1;if(i&&t.days_until_due!==null){let v=Ot(t.interval_days,t.days_until_due,t.interval_unit);a=v.pct,h=v.overflow,t.status==="overdue"?l=jt.overdue:t.status==="due_soon"&&(l=jt.due_soon)}let c=t.area_id?this.hass?.areas?.[t.area_id]?.name:null,p=t.responsible_user_id?this._userService?.getUserName(t.responsible_user_id):null,u=t.group_names.length>0||c||p,_=this._bulkMode&&this._bulkSelected.has(this._bulkKey(t));return r`
<div class="task-row${t.enabled?"":" task-disabled"}${_?" bulk-selected":""}">
${this._bulkMode?r`
<label class="cell bulk-check" @click=${v=>v.stopPropagation()}>
<input type="checkbox" .checked=${g} @change=${()=>this._toggleBulkRow(t)} />
<input type="checkbox" .checked=${_} @change=${()=>this._toggleBulkRow(t)} />
</label>
`:d}
<span class="cell-badges">
@@ -5208,7 +5197,7 @@ ${A(n.notes)}</div>`:""}
</span>
<span class="cell type">${s(t.type,e)}</span>
<span class="due-cell" @click=${()=>this._showTask(t.entry_id,t.task_id)}>
<span class="due-text">${_t(t.days_until_due,e)}</span>
<span class="due-text">${gt(t.days_until_due,e)}</span>
${i?r`<div class="days-bar"><div class="days-bar-fill${h?" overflow":""}" style="width:${a}%;background:${l}"></div></div>`:d}
${t.trigger_config?Zt(t):!i&&t.trigger_active?r`<span style="color:var(--maint-triggered-color);font-weight:600">⚡</span>`:d}
${Qt(t,this._miniStatsData,this._lang)}
@@ -5295,7 +5284,7 @@ ${A(n.notes)}</div>`:""}
<span class="task-sub${c.responsible_user_id?"":" task-sub-empty"}">${te(c,p=>this._userService?.getUserName(p)??null)}</span>
<span class="cell type">${s(c.type,i)}</span>
<span class="due-cell" @click=${()=>this._showTask(t.entry_id,c.id)}>
<span class="due-text">${_t(c.days_until_due,i)}</span>
<span class="due-text">${gt(c.days_until_due,i)}</span>
${c.trigger_config?Zt(c):d}
${Qt(c,this._miniStatsData,this._lang)}
</span>
@@ -5325,7 +5314,56 @@ ${A(n.notes)}</div>`:""}
@parts-changed=${()=>this._loadData()}
></maintenance-parts-section>
</div>
`}_renderNewMenu(t){return r`
<div class="new-menu-wrapper">
<ha-button appearance="filled" class="new-menu-button"
@click=${e=>{e.stopPropagation(),this._toggleNewMenu()}}>
<ha-icon icon="mdi:plus"></ha-icon> ${s("new_menu",t)}
<ha-icon icon="mdi:menu-down"></ha-icon>
</ha-button>
${this._newMenuOpen?r`
<div class="popup-menu new-menu-popup" @click=${e=>e.stopPropagation()}>
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._ui("maintenance-task-dialog").then(e=>e?.openCreate("",this._objects))}}>
<ha-icon icon="mdi:clipboard-plus-outline"></ha-icon> ${s("new_task",t)}
</div>
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._ui("maintenance-object-dialog").then(e=>e?.openCreate())}}>
<ha-icon icon="mdi:package-variant-closed-plus"></ha-icon> ${s("new_object",t).replace(/^\+\s*/,"")}
</div>
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._openTemplateGallery()}}>
<ha-icon icon="mdi:view-grid-plus-outline"></ha-icon> ${s("templates_from",t)}
</div>
<div class="popup-menu-divider"></div>
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._openAdoptProblemSensors()}}>
<ha-icon icon="mdi:alert-circle-check-outline"></ha-icon> ${s("adopt_problem_button",t)}
</div>
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._openSuggestedSetups()}}>
<ha-icon icon="mdi:auto-fix"></ha-icon> ${s("setups_button",t)}
</div>
${this._batteryFleetSetupAvailable?r`
<div class="popup-menu-item" @click=${()=>{this._closeNewMenu(),this._setupBatteryFleet()}}>
<ha-icon icon="mdi:battery-sync"></ha-icon> ${s("battery_fleet_setup_button",t)}
</div>
`:d}
</div>
`:d}
</div>
`}_toggleNewMenu(){this._newMenuOpen=!this._newMenuOpen,this._newMenuOpen&&setTimeout(()=>{let t=()=>{this._newMenuOpen=!1,document.removeEventListener("click",t)};document.addEventListener("click",t)},0)}_closeNewMenu(){this._newMenuOpen=!1}_isYoungInstall(){let t=this._objects.filter(i=>!i.object?.battery_fleet),e=t.reduce((i,a)=>i+a.tasks.length,0);return t.length<3&&e<8}_gsDismissed(){try{return new Set(JSON.parse(localStorage.getItem(F.gettingStartedDismissed)||"[]"))}catch{return new Set}}_dismissGettingStarted(t){let e=this._gsDismissed();e.add(t);try{localStorage.setItem(F.gettingStartedDismissed,JSON.stringify([...e]))}catch{}this.requestUpdate()}_maybeLoadGettingStarted(){this._gsLoaded||!this._isYoungInstall()||(this._gsLoaded=!0,this.hass.connection.sendMessagePromise({type:"maintenance_supporter/integration_setups/discover"}).then(t=>{this._gsSetupsCount=(t.setups||[]).length}).catch(()=>{this._gsSetupsCount=0}),this.hass.connection.sendMessagePromise({type:"maintenance_supporter/problem_sensors/discover"}).then(t=>{this._gsAdoptCount=(t.sensors||[]).length}).catch(()=>{this._gsAdoptCount=0}))}_renderGettingStartedChips(t){let e=this._gsDismissed(),i=this._isYoungInstall(),a=[];return i&&this._gsSetupsCount>0&&!e.has("setups")&&a.push({id:"setups",icon:"mdi:auto-fix",text:s("gs_setups_chip",t).replace("{n}",String(this._gsSetupsCount)),run:()=>this._openSuggestedSetups()}),i&&this._gsAdoptCount>0&&!e.has("adopt")&&a.push({id:"adopt",icon:"mdi:alert-circle-check-outline",text:s("gs_adopt_chip",t).replace("{n}",String(this._gsAdoptCount)),run:()=>this._openAdoptProblemSensors()}),this._batteryFleetSetupAvailable&&!e.has("fleet")&&a.push({id:"fleet",icon:"mdi:battery-sync",text:s("gs_fleet_chip",t),run:()=>this._setupBatteryFleet()}),a.length===0?d:r`
<div class="gs-chips-wrap">
<div class="gs-chips-label">${s("gs_label",t)}</div>
<div class="gs-chips">
${a.map(l=>r`
<div class="gs-chip" @click=${()=>l.run()}>
<ha-icon icon="${l.icon}"></ha-icon>
<span>${l.text}</span>
<span class="gs-chip-x" title="${s("dismiss",t)}"
@click=${h=>{h.stopPropagation(),this._dismissGettingStarted(l.id)}}>
<ha-icon icon="mdi:close"></ha-icon>
</span>
</div>
`)}
</div>
</div>
`}_toggleObjMenu(){this._objMenuOpen=!this._objMenuOpen,this._objMenuOpen&&setTimeout(()=>{let t=()=>{this._objMenuOpen=!1,document.removeEventListener("click",t)};document.addEventListener("click",t)},0)}_closeObjMenu(){this._objMenuOpen=!1}_toggleMoreMenu(){if(this._moreMenuOpen=!this._moreMenuOpen,this._moreMenuOpen){let t=()=>{this._moreMenuOpen=!1,document.removeEventListener("click",t)};setTimeout(()=>document.addEventListener("click",t,{once:!0}),0)}}_closeMoreMenu(){this._moreMenuOpen=!1}get _sparklineCtx(){return{lang:this._lang,detailStatsData:this._detailStatsData,hasStatsService:!!this._statsService,isCounterEntity:t=>this._isCounterEntity(t),rangeDays:this._chartRangeDays,setRangeDays:t=>this._setChartRange(t),hideOutliers:this._hideOutliers,setHideOutliers:t=>this._setHideOutliers(t)}}_toggleSection(t){let e=new Set(this._collapsedSections);e.has(t)?e.delete(t):e.add(t),this._collapsedSections=e;try{localStorage.setItem(F.collapsedSections,JSON.stringify([...e]))}catch{}}_historyCtx(){let t=this._selectedEntryId&&this._selectedTaskId?this._getObject(this._selectedEntryId)?.tasks.find(l=>l.id===this._selectedTaskId):void 0,e=this._fullHistory,a=(e&&e.entryId===this._selectedEntryId&&e.taskId===this._selectedTaskId&&e.entries.length>(t?.history||[]).length?e.entries:t?.history||[]).filter(l=>l.reading_value!=null).sort((l,h)=>l.timestamp.localeCompare(h.timestamp));return{lang:this._lang,hass:this.hass,filter:this._historyFilter,search:this._historySearch,currencySymbol:this._budget?.currency_symbol||ut,setFilter:l=>{this._historyFilter=l},setSearch:l=>{this._historySearch=l},openEdit:l=>this._openHistoryEdit(l),readingUnit:t?.reading_unit??null,readingDelta:l=>{let h=a.findIndex(c=>c.timestamp===l.timestamp);return h<=0?null:l.reading_value-a[h-1].reading_value}}}_taskDetailCtx(){let t=this._selectedEntryId,e=this._selectedTaskId,i=this._getObject(t);return{lang:this._lang,hass:this.hass,entryId:t,taskId:e,objectName:i?.object.name||"",objectDocUrl:i?.object?.documentation_url??null,objectManualDocs:i?.object?.manual_docs??[],openManualDoc:a=>this._openManualDoc(a),setChecklistItem:(a,l)=>this._setChecklistItem(t,e,a,l),isOperator:this._isOperator,actionLoading:this._actionLoading,moreMenuOpen:this._moreMenuOpen,activeTab:this._activeTab,features:this._features,currencySymbol:this._budget?.currency_symbol||ut,collapsedSections:this._collapsedSections,costDurationToggle:this._costDurationToggle,suggestionDismissed:this._dismissedSuggestions.has(`${t}_${e}`),sparkline:this._sparklineCtx,history:this._historyCtx(),getUserName:a=>this._userService?.getUserName(a)??null,setActiveTab:a=>{this._activeTab=a},toggleSection:a=>this._toggleSection(a),setCostDurationToggle:a=>{this._costDurationToggle=a},showTaskView:()=>{this._view="task"},showObject:()=>this._showObject(t),toggleMoreMenu:()=>this._toggleMoreMenu(),closeMoreMenu:()=>this._closeMoreMenu(),openEdit:a=>{this._ui("maintenance-task-dialog").then(l=>l?.openEdit(t,a))},openComplete:a=>this._openCompleteDialog(t,e,a.name,this._features.checklists?a.checklist:void 0,this._features.adaptive&&!!a.adaptive_config?.enabled),promptSkip:()=>this._promptSkipTask(t,e),toggleArchive:a=>this._toggleArchiveTask(t,e,a),openQr:a=>this._openQrForTask(t,e,i?.object.name||"",a),duplicateTask:()=>this._duplicateTask(t,e),promptReset:()=>this._promptResetTask(t,e),promptPostpone:()=>this._promptPostponeTask(t,e),snoozeTask:()=>this._snoozeTask(t,e),printWorksheet:()=>this._printTaskWorksheet(t,e),deleteTask:()=>this._deleteTask(t,e),applySuggestion:a=>this._applySuggestion(t,e,a),reanalyze:()=>this._reanalyzeInterval(t,e),dismissSuggestion:()=>this._dismissSuggestion(t,e),openSeasonalOverrides:a=>this._openSeasonalOverrides(a)}}async _fetchFullHistory(t,e){try{let i=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history",entry_id:t,task_id:e});this._selectedEntryId===t&&this._selectedTaskId===e&&(this._fullHistory={entryId:t,taskId:e,entries:i.history||[]})}catch{this._fullHistory=null}}_renderTaskDetail(){if(!this._selectedEntryId||!this._selectedTaskId)return d;let t=this._getTask(this._selectedEntryId,this._selectedTaskId);if(!t)return r`<p>Task not found.</p>`;let e=this._fullHistory,i=e&&e.entryId===this._selectedEntryId&&e.taskId===this._selectedTaskId&&e.entries.length>(t.history||[]).length?{...t,history:e.entries}:t;return r`<maintenance-task-detail-view
.task=${i}
.ctx=${this._taskDetailCtx()}
></maintenance-task-detail-view>`}_openHistoryEdit(t){if(!this._selectedEntryId||!this._selectedTaskId)return;let e={entry_id:this._selectedEntryId,task_id:this._selectedTaskId,original_timestamp:t.timestamp,type:t.type,timestamp:t.timestamp,notes:t.notes??null,cost:t.cost??null,duration:t.duration??null,completed_by:t.completed_by??null};this.shadowRoot?.querySelector("maintenance-history-edit-dialog")?.openEdit(e)}};k.styles=[Lt,_e],_([T({attribute:!1})],k.prototype,"hass",2),_([T({type:Boolean,reflect:!0})],k.prototype,"narrow",2),_([T({attribute:!1})],k.prototype,"panel",2),_([m()],k.prototype,"_objects",2),_([m()],k.prototype,"_stats",2),_([m()],k.prototype,"_view",2),_([m()],k.prototype,"_selectedEntryId",2),_([m()],k.prototype,"_selectedTaskId",2),_([m()],k.prototype,"_filterStatus",2),_([m()],k.prototype,"_filterUser",2),_([m()],k.prototype,"_filterLabel",2),_([m()],k.prototype,"_savedViews",2),_([m()],k.prototype,"_activeViewId",2),_([m()],k.prototype,"_unsub",2),_([m()],k.prototype,"_chartRangeDays",2),_([m()],k.prototype,"_hideOutliers",2),_([m()],k.prototype,"_historyFilter",2),_([m()],k.prototype,"_budget",2),_([m()],k.prototype,"_groups",2),_([m()],k.prototype,"_detailStatsData",2),_([m()],k.prototype,"_miniStatsData",2),_([m()],k.prototype,"_features",2),_([m()],k.prototype,"_adminPanelUserIds",2),_([m()],k.prototype,"_operatorWriteEnabled",2),_([m()],k.prototype,"_defaultWarningDays",2),_([m()],k.prototype,"_actionLoading",2),_([m()],k.prototype,"_moreMenuOpen",2),_([m()],k.prototype,"_objMenuOpen",2),_([m()],k.prototype,"_toastMessage",2),_([m()],k.prototype,"_toastUndo",2),_([m()],k.prototype,"_toastActionLabel",2),_([m()],k.prototype,"_filtersOpen",2),_([m()],k.prototype,"_actionsMenuOpen",2),_([m()],k.prototype,"_batteryFleetSetupAvailable",2),_([m()],k.prototype,"_staleBundle",2),_([m()],k.prototype,"_overviewTab",2),_([m()],k.prototype,"_activeTab",2),_([m()],k.prototype,"_costDurationToggle",2),_([m()],k.prototype,"_historySearch",2),_([m()],k.prototype,"_sortMode",2),_([m()],k.prototype,"_objectSortMode",2),_([m()],k.prototype,"_groupByMode",2),_([m()],k.prototype,"_objectViewMode",2),_([m()],k.prototype,"_objectsTableColumns",2),_([m()],k.prototype,"_showArchived",2),_([m()],k.prototype,"_bulkMode",2),_([m()],k.prototype,"_bulkSelected",2),_([m()],k.prototype,"_virtStart",2),_([m()],k.prototype,"_virtEnd",2),_([m()],k.prototype,"_collapsedSections",2),_([m()],k.prototype,"_paletteOpen",2),_([m()],k.prototype,"_paletteQuery",2),_([m()],k.prototype,"_paletteActive",2),_([m()],k.prototype,"_templateGalleryOpen",2),_([m()],k.prototype,"_templates",2),_([m()],k.prototype,"_templateCategories",2),_([m()],k.prototype,"_templateBusy",2),_([m()],k.prototype,"_fullHistory",2),k=_([ee("maintenance-supporter-panel")],k);export{k as MaintenanceSupporterPanel};
></maintenance-task-detail-view>`}_openHistoryEdit(t){if(!this._selectedEntryId||!this._selectedTaskId)return;let e={entry_id:this._selectedEntryId,task_id:this._selectedTaskId,original_timestamp:t.timestamp,type:t.type,timestamp:t.timestamp,notes:t.notes??null,cost:t.cost??null,duration:t.duration??null,completed_by:t.completed_by??null};this.shadowRoot?.querySelector("maintenance-history-edit-dialog")?.openEdit(e)}};k.styles=[Lt,ge],g([T({attribute:!1})],k.prototype,"hass",2),g([T({type:Boolean,reflect:!0})],k.prototype,"narrow",2),g([T({attribute:!1})],k.prototype,"panel",2),g([m()],k.prototype,"_objects",2),g([m()],k.prototype,"_stats",2),g([m()],k.prototype,"_view",2),g([m()],k.prototype,"_selectedEntryId",2),g([m()],k.prototype,"_selectedTaskId",2),g([m()],k.prototype,"_filterStatus",2),g([m()],k.prototype,"_filterUser",2),g([m()],k.prototype,"_filterLabel",2),g([m()],k.prototype,"_savedViews",2),g([m()],k.prototype,"_activeViewId",2),g([m()],k.prototype,"_unsub",2),g([m()],k.prototype,"_chartRangeDays",2),g([m()],k.prototype,"_hideOutliers",2),g([m()],k.prototype,"_historyFilter",2),g([m()],k.prototype,"_budget",2),g([m()],k.prototype,"_groups",2),g([m()],k.prototype,"_detailStatsData",2),g([m()],k.prototype,"_miniStatsData",2),g([m()],k.prototype,"_features",2),g([m()],k.prototype,"_adminPanelUserIds",2),g([m()],k.prototype,"_operatorWriteEnabled",2),g([m()],k.prototype,"_defaultWarningDays",2),g([m()],k.prototype,"_actionLoading",2),g([m()],k.prototype,"_moreMenuOpen",2),g([m()],k.prototype,"_objMenuOpen",2),g([m()],k.prototype,"_toastMessage",2),g([m()],k.prototype,"_toastUndo",2),g([m()],k.prototype,"_toastActionLabel",2),g([m()],k.prototype,"_filtersOpen",2),g([m()],k.prototype,"_newMenuOpen",2),g([m()],k.prototype,"_gsSetupsCount",2),g([m()],k.prototype,"_gsAdoptCount",2),g([m()],k.prototype,"_batteryFleetSetupAvailable",2),g([m()],k.prototype,"_staleBundle",2),g([m()],k.prototype,"_overviewTab",2),g([m()],k.prototype,"_activeTab",2),g([m()],k.prototype,"_costDurationToggle",2),g([m()],k.prototype,"_historySearch",2),g([m()],k.prototype,"_sortMode",2),g([m()],k.prototype,"_objectSortMode",2),g([m()],k.prototype,"_groupByMode",2),g([m()],k.prototype,"_objectViewMode",2),g([m()],k.prototype,"_objectsTableColumns",2),g([m()],k.prototype,"_showArchived",2),g([m()],k.prototype,"_bulkMode",2),g([m()],k.prototype,"_bulkSelected",2),g([m()],k.prototype,"_virtStart",2),g([m()],k.prototype,"_virtEnd",2),g([m()],k.prototype,"_collapsedSections",2),g([m()],k.prototype,"_paletteOpen",2),g([m()],k.prototype,"_paletteQuery",2),g([m()],k.prototype,"_paletteActive",2),g([m()],k.prototype,"_templateGalleryOpen",2),g([m()],k.prototype,"_templates",2),g([m()],k.prototype,"_templateCategories",2),g([m()],k.prototype,"_templateBusy",2),g([m()],k.prototype,"_fullHistory",2),k=g([ee("maintenance-supporter-panel")],k);export{k as MaintenanceSupporterPanel};