209 files

This commit is contained in:
Home Assistant Version Control committed 2026-10-07 13:11:05 +00:00
1 parent 4fef64cc2c
commit 983811cb93
209 files changed
+714 -26066

No files matched your search

@@ -1,5 +1,5 @@
/*! maintenance_supporter frontend 2.99.0 */
import{a as di,b as pi,c as hi,g as mi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-4APLU3YR.js";import{a as $}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-5MYBEQC2.js";import{a as ki,b as wi,c as $i,d as ue,e as ji,f as De}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-MGSZZ3YF.js";import{A as ve,B as Fi,C as Ui,D as Vi,E as Wi,F as Ki,M as Gi,P as Yi,a as st,b as jt,c as St,d as ae,e as Ht,f as pe,g as gi,h as _i,i as he,j as vi,k as bi,l as O,m as Zt,n as kt,o as zt,p as qt,q as ze,r as me,s as fe,t as zi,u as Pi,v as Li,w as Hi,x as Bi,y as Ni,z as qi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-XTTCEGMX.js";import{a as Di,b as Nt,d as Ai,e as _e,f as Ii}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-GWAP5R2S.js";import{a as ge}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-EKN6HBJN.js";import{a as ci,b as le,c as Et,d as ce,e as Jt,f as de}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-DRT62KZF.js";import{a as se,c as Lt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-SYPCMUXO.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZHMFEWT2.js";import{a as Pe,b as gt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-PL7JXZOW.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-TX2GMEMJ.js";import{a as Oi,b as Mi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-6BKNHM6I.js";import{c as Ci}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-WACUKJSI.js";import{a as A,b as Z,c as V}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-HFZZVTW7.js";import{c as yi,d as xi,e as Rt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-55ND3GKE.js";import{b as ui,i as fi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-MNPRUCF5.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-RUYEMIDM.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-SUOGXDNI.js";import{a as Me}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-JQXHX4U4.js";import{c as Si,d as Ae,e as Ti}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-PCR5FRSH.js";import{l as Xt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-RHKFQ4Q2.js";import{a as P,b as Ei,c as Ri,d as Ie}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-GM2CHGSG.js";import{A as ft,B as Ce,D as Tt,E as ai,F as oe,G as Bt,H as K,I as Kt,K as Y,L as F,M as Gt,O as U,P as ri,R as vt,S as oi,T as Yt,W as ni,X as li,Z as It,_ as Qt,a as _,b as B,ba as ne,c as o,d as G,f as h,h as N,i as Oe,j as Xe,k as Ze,l as R,m as f,n as re,o as ti,p as Mt,s,t as ei,u as ot,w as ii,x as si,y as xt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-3FGYBPXY.js";var Os=["assignee_pool","required_completion_fields","checklist","labels","mirror_todo_entities","next_event_titles","history","readings"],Cs=["checklist_progress"],Ms=["tasks","parts"],Ds=["manual_docs","battery_fleet_excluded"];function Le(l,p,t=[]){for(let e of p)l[e]===void 0&&(l[e]=[]);for(let e of t)l[e]===void 0&&(l[e]={})}function As(l){let p=l;Le(p,Ms),p.object&&typeof p.object=="object"&&Le(p.object,Ds);for(let t of p.tasks)Le(t,Os,Cs);return l}function te(l){for(let p of l)As(p);return l}function Is(l,p){if(p.objects)return p.objects;let t=p.delta||[],e=p.removed||[];if(!t.length&&!e.length)return null;let i=new Map(l.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()]}function Qi(l,p){return p.objects&&te(p.objects),p.delta&&te(p.delta),Is(l,p)}var He=["today","dashboard","calendar","settings"];var zs=168*3600*1e3;function Ji(){try{let l=Z(A.objectsCache);if(!l)return null;let p=JSON.parse(l);return p.v!==Oe||!Number.isFinite(p.at)||Date.now()-p.at>zs||!Array.isArray(p.objects)||p.objects.length===0?null:{objects:p.objects,stats:p.stats??null}}catch{return null}}function Be(l,p){if(!(!Array.isArray(l)||l.length===0))try{let t={v:Oe,at:Date.now(),objects:l,stats:p};V(A.objectsCache,JSON.stringify(t))}catch{}}var Ps={days:1,weeks:7,months:30.4368,years:365.25};function Ne(l,p){return!l||l<=0?0:l*(Ps[p||"days"]??1)}function be(l,p,t){let e=Ne(l,t);if(e<=0||p==null)return{pct:0,overflow:!1};let i=(e-p)/e*100;return{pct:Math.max(0,Math.min(100,i)),overflow:i>100}}function Xi(l,p,t,e,i,a){let r=[[t.manufacturer,l.manufacturer],[t.model,l.model],[t.serial,l.serial_number],[t.installed,l.installation_date?e(l.installation_date):null],[t.warranty,l.warranty_expiry?e(l.warranty_expiry):null]].filter(([,u])=>!!u),c=p.map(u=>{let d=t.scheduleLabel(u);return`<tr>
/*! maintenance_supporter frontend 2.100.0 */
import{a as hi,b as ui,c as gi,g as vi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-UEYKFHQZ.js";import{a as $}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-UO7KFJ6R.js";import{a as $i,b as ji,c as Si,d as ue,e as Ti,f as De}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZFJHBIVS.js";import{A as ve,B as Vi,C as Wi,D as Ki,E as Gi,F as Yi,M as Qi,P as Ji,a as st,b as jt,c as St,d as ae,e as Ht,f as pe,g as mi,h as fi,i as he,j as yi,k as xi,l as O,m as Zt,n as kt,o as zt,p as qt,q as ze,r as me,s as fe,t as Li,u as Hi,v as Bi,w as Ni,x as qi,y as Fi,z as Ui}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-BY3VP2I5.js";import{a as Ii,b as Nt,d as zi,e as _e,f as Pi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-FJSDFRAZ.js";import{a as ge}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-JFENKV7A.js";import{a as pi,b as le,c as Et,d as ce,e as Jt,f as de}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-GN3YV45M.js";import{a as se,c as Lt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-U7674FZW.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZXDIHJGM.js";import{a as Pe,b as gt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-GXXE2CW6.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-TX5O4PHL.js";import{a as Mi,b as Ai}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-HWRCQ6GH.js";import{c as Di}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-KW7DNTG7.js";import{a as A,b as Z,c as V}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-HFUWDHSL.js";import{c as ki,d as wi,e as Rt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-Q7CGGH4O.js";import{b as _i,i as bi}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-QGXKAHG5.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-PO272ATG.js";import"/maintenance_supporter_panelfiles/panel-chunks/chunk-IYMIR5HJ.js";import{a as Me}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-C6NCKN5O.js";import{c as Ei,d as Ae,e as Ri}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-QKL6SKIH.js";import{l as Xt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-M2CMCNR4.js";import{a as P,b as Oi,c as Ci,d as Ie}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-5USKKRUA.js";import{$ as Qt,A as ft,B as Ce,D as Tt,E as ri,F as oe,G as Bt,H as K,I as Kt,K as Y,L as U,M as Gt,O as q,P as oi,R as xt,S as ni,T as li,U as Yt,X as ci,Y as di,_ as It,a as _,b as B,c as o,ca as ne,d as G,f as h,h as N,i as Oe,j as Ze,k as ti,l as R,m as f,n as re,o as ei,p as Mt,s,t as ii,u as ot,w as si,x as ai,y as yt}from"/maintenance_supporter_panelfiles/panel-chunks/chunk-ZW2EWBUR.js";var Ms=["assignee_pool","required_completion_fields","checklist","labels","mirror_todo_entities","next_event_titles","history","readings"],Ds=["checklist_progress"],As=["tasks","parts"],Is=["manual_docs","battery_fleet_excluded"];function Le(l,p,t=[]){for(let e of p)l[e]===void 0&&(l[e]=[]);for(let e of t)l[e]===void 0&&(l[e]={})}function zs(l){let p=l;Le(p,As),p.object&&typeof p.object=="object"&&Le(p.object,Is);for(let t of p.tasks)Le(t,Ms,Ds);return l}function te(l){for(let p of l)zs(p);return l}function Ps(l,p){if(p.objects)return p.objects;let t=p.delta||[],e=p.removed||[];if(!t.length&&!e.length)return null;let i=new Map(l.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()]}function Xi(l,p){return p.objects&&te(p.objects),p.delta&&te(p.delta),Ps(l,p)}var He=["today","dashboard","calendar","settings"];var Ls=168*3600*1e3;function Zi(){try{let l=Z(A.objectsCache);if(!l)return null;let p=JSON.parse(l);return p.v!==Oe||!Number.isFinite(p.at)||Date.now()-p.at>Ls||!Array.isArray(p.objects)||p.objects.length===0?null:{objects:p.objects,stats:p.stats??null}}catch{return null}}function Be(l,p){if(!(!Array.isArray(l)||l.length===0))try{let t={v:Oe,at:Date.now(),objects:l,stats:p};V(A.objectsCache,JSON.stringify(t))}catch{}}var Hs={days:1,weeks:7,months:30.4368,years:365.25};function Ne(l,p){return!l||l<=0?0:l*(Hs[p||"days"]??1)}function be(l,p,t){let e=Ne(l,t);if(e<=0||p==null)return{pct:0,overflow:!1};let i=(e-p)/e*100;return{pct:Math.max(0,Math.min(100,i)),overflow:i>100}}function ts(l,p,t,e,i,a){let r=[[t.manufacturer,l.manufacturer],[t.model,l.model],[t.serial,l.serial_number],[t.installed,l.installation_date?e(l.installation_date):null],[t.warranty,l.warranty_expiry?e(l.warranty_expiry):null]].filter(([,u])=>!!u),c=p.map(u=>{let d=t.scheduleLabel(u);return`<tr>
<td>${$(u.name)}</td>
<td>${$(t.typeLabel(u.type))}</td>
<td>${$(t.statusLabel(u.status))}</td>
@@ -51,7 +51,7 @@ import{a as di,b as pi,c as hi,g as mi}from"/maintenance_supporter_panelfiles/pa
</table>
${l.notes?`<div class="notes"><strong>${$(t.notes)}:</strong>
${$(l.notes)}</div>`:""}
</body></html>`}var Ls=60;function qe(l,p=xt()){if(!l)return{kind:"none",days:null,date:null};let t=ai(p,l);return Number.isFinite(t)?t<0?{kind:"expired",days:t,date:l}:t<=Ls?{kind:"expiring",days:t,date:l}:{kind:"valid",days:t,date:l}:{kind:"none",days:null,date:null}}function Hs(l,p){let t=Date.parse(l);return Number.isNaN(t)?l.slice(0,10):p(si(t,ii()))}var L=l=>String(l??"").replace(/[&<>"']/g,p=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[p]);function Zi(l,p,t,e,i,a,r,c,n,u=[],d=null){let g=[[t.object,L(p)],[t.type,L(t.typeLabel(l.type))],[t.interval,L(i(l))],[t.nextDue,l.next_due?L(e(l.next_due)):"\u2014"],[t.lastDone,l.last_performed?L(e(l.last_performed)):L(t.never)]];l.priority&&l.priority!=="normal"&&g.push([t.priority,L(l.priority)]);let m=(l.checklist||[]).map(y=>`<li><span class="box"></span>${L(y)}</li>`).join(""),v=(y,E)=>y?`<figure class="qr"><img src="${y}" alt="" /><figcaption>${L(E)}</figcaption></figure>`:"";return`<!DOCTYPE html>
</body></html>`}var Bs=60;function qe(l,p=yt()){if(!l)return{kind:"none",days:null,date:null};let t=ri(p,l);return Number.isFinite(t)?t<0?{kind:"expired",days:t,date:l}:t<=Bs?{kind:"expiring",days:t,date:l}:{kind:"valid",days:t,date:l}:{kind:"none",days:null,date:null}}function Ns(l,p){let t=Date.parse(l);return Number.isNaN(t)?l.slice(0,10):p(ai(t,si()))}var L=l=>String(l??"").replace(/[&<>"']/g,p=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[p]);function es(l,p,t,e,i,a,r,c,n,u=[],d=null){let g=[[t.object,L(p)],[t.type,L(t.typeLabel(l.type))],[t.interval,L(i(l))],[t.nextDue,l.next_due?L(e(l.next_due)):"\u2014"],[t.lastDone,l.last_performed?L(e(l.last_performed)):L(t.never)]];l.priority&&l.priority!=="normal"&&g.push([t.priority,L(l.priority)]);let m=(l.checklist||[]).map(y=>`<li><span class="box"></span>${L(y)}</li>`).join(""),v=(y,E)=>y?`<figure class="qr"><img src="${y}" alt="" /><figcaption>${L(E)}</figcaption></figure>`:"";return`<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta name="color-scheme" content="light">
<title>${L(l.name)} \u2014 ${L(t.title)}</title>
<style>
@@ -131,8 +131,8 @@ ${$(l.notes)}</div>`:""}
}
} catch (e) { console.warn("excerpt inline render failed", e); }
<\/script>`:""}`:""}
<footer>${L(p)} \xB7 ${L(l.name)} \xB7 ${L(t.printedOn)} ${L(Hs(n,e))}</footer>
</body></html>`}var Dt=["manual","warranty","invoice","spare_parts","photo","other"],ye={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"};function nt(l){return l.title||l.filename||l.url||""}function Ft(l){return(l.tags||[]).find(p=>Dt.includes(p))??"other"}function ts(l){return(l.tags||[]).includes("photo")}function Ut(l){let p=(l??[]).filter(t=>!!t);return p.length?o`<span class="event-titles"> · ${p.join(", ")}</span>`:h}var es=B`
<footer>${L(p)} \xB7 ${L(l.name)} \xB7 ${L(t.printedOn)} ${L(Ns(n,e))}</footer>
</body></html>`}var Dt=["manual","warranty","invoice","spare_parts","photo","other"],ye={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"};function nt(l){return l.title||l.filename||l.url||""}function Ft(l){return(l.tags||[]).find(p=>Dt.includes(p))??"other"}function is(l){return(l.tags||[]).includes("photo")}function Ut(l){let p=(l??[]).filter(t=>!!t);return p.length?o`<span class="event-titles"> · ${p.join(", ")}</span>`:h}var ss=B`
/* #170: reference chips in front of list names. */
.task-name .ref-chip, .today-task .ref-chip, .object-card-name .ref-chip, .objects-table-name .ref-chip { margin-right: 6px; }
@@ -2292,7 +2292,7 @@ ${$(l.notes)}</div>`:""}
from { opacity: 0; transform: translateX(-50%) translateY(16px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
`;var xe=class{constructor(p){this._cache=new Map;this._pending=new Map;this.historyFallbackIds=new Set;this._hass=p}updateHass(p){this._hass=p}async getDetailStats(p,t,e=30){return this._getStats(p,e<=35?"hour":"day",e,t)}async getMiniStats(p,t){return this._getStats(p,"day",14,t)}async getBatchMiniStats(p){let t=new Map,e=[];for(let n of p){let u=`${n.entityId}:day:14`,d=this._cache.get(u);d&&Date.now()-d.fetchedAt<3e5?t.set(n.entityId,d.points):e.push(n)}if(e.length===0)return t;let i=e.filter(n=>n.isCounter).map(n=>n.entityId),a=e.filter(n=>!n.isCounter).map(n=>n.entityId),r=new Date(Date.now()-336*60*60*1e3).toISOString(),c=[];return i.length>0&&c.push(this._fetchBatch(i,"day",r,["state","sum","change"],!0,t)),a.length>0&&c.push(this._fetchBatch(a,"day",r,["mean","min","max"],!1,t)),await Promise.all(c),t}clearCache(){this._cache.clear(),this._pending.clear()}async _getStats(p,t,e,i){let a=`${p}:${t}:${e}`,r=this._cache.get(a);if(r&&Date.now()-r.fetchedAt<3e5)return r.points;if(this._pending.has(a))return this._pending.get(a);let c=this._fetchAndNormalize(p,t,e,i,a);this._pending.set(a,c);try{return await c}finally{this._pending.delete(a)}}async _fetchAndNormalize(p,t,e,i,a){let r=new Date(Date.now()-e*24*60*60*1e3).toISOString(),c=i?["state","sum","change"]:["mean","min","max"];try{let u=(await this._hass.connection.sendMessagePromise({type:"recorder/statistics_during_period",start_time:r,statistic_ids:[p],period:t,types:c}))[p]||[],d=this._normalizeRows(u,i);if(d.length<2){let g=await this._fetchHistoryFallback(p,r);g.length>=2?(d=g,this.historyFallbackIds.add(p)):this.historyFallbackIds.delete(p)}else this.historyFallbackIds.delete(p);return this._cache.set(a,{entityId:p,fetchedAt:Date.now(),period:t,points:d}),d}catch(n){return console.warn(`[maintenance-supporter] Failed to fetch statistics for ${p}:`,n),[]}}async _fetchHistoryFallback(p,t){try{let i=(await this._hass.connection.sendMessagePromise({type:"history/history_during_period",start_time:t,end_time:new Date().toISOString(),entity_ids:[p],minimal_response:!0,no_attributes:!0}))?.[p]||[];if(i.length>1e3){let c=Math.ceil(i.length/500);i=i.filter((n,u)=>u%c===0||u===i.length-1)}let a=[],r=null;for(let c of i){let n=c.s??c.state;if(n==null||n==="unknown"||n==="unavailable")continue;let u;if(n==="on"||n==="open"||n==="true")u=1;else if(n==="off"||n==="closed"||n==="false")u=0;else if(u=parseFloat(n),!Number.isFinite(u))continue;let d=c.lu??c.last_updated??c.last_changed,g=typeof d=="number"?d*1e3:d!=null?Date.parse(d):NaN;Number.isFinite(g)&&(r!=null&&r!==u&&a.push({ts:g,val:r}),a.push({ts:g,val:u}),r=u)}return a.sort((c,n)=>c.ts-n.ts),a.length&&r!=null&&a.push({ts:Date.now(),val:r}),a}catch(e){return console.warn(`[maintenance-supporter] History fallback failed for ${p}:`,e),[]}}async _fetchBatch(p,t,e,i,a,r){try{let c=await this._hass.connection.sendMessagePromise({type:"recorder/statistics_during_period",start_time:e,statistic_ids:p,period:t,types:i});for(let n of p){let u=c[n]||[],d=this._normalizeRows(u,a);r.set(n,d),this._cache.set(`${n}:${t}:14`,{entityId:n,fetchedAt:Date.now(),period:t,points:d})}}catch(c){console.warn("[maintenance-supporter] Batch statistics fetch failed:",c)}}_normalizeRows(p,t){let e=[];for(let i of p){let a=null;if(t?a=i.state??null:a=i.mean??null,a===null)continue;let r={ts:i.start,val:a};t||(i.min!=null&&(r.min=i.min),i.max!=null&&(r.max=i.max)),e.push(r)}return e.sort((i,a)=>i.ts-a.ts),e}};function wt(l,p){let t=l??0;return t<1024?`${t} B`:t<1024*1024?`${Y(t/1024,p,1)} KB`:`${Y(t/(1024*1024),p,1)} MB`}var ke=8,Fe=["newest","oldest","title","category"];function Ue(l){return Fe.includes(l??"")?l:"newest"}function is(l,p){let t=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),e=c=>nt(c).trim(),i=(c,n)=>t.compare(e(c),e(n)),a=c=>c.kind==="weblink"?Dt.length+1:Dt.indexOf(Ft(c)),r=[...l];switch(p){case"oldest":return r.sort((c,n)=>(c.added_at||"").localeCompare(n.added_at||""));case"title":return r.sort(i);case"category":return r.sort((c,n)=>a(c)-a(n)||i(c,n));default:return r.sort((c,n)=>(n.added_at||"").localeCompare(c.added_at||""))}}function we(l,p){let t=se(p);if(!t.length)return l;let e=[];for(let i of l){let a=Lt(t,[{text:i.title,weight:3},{text:i.filename,weight:2},{text:(i.tags||[]).join(" "),weight:2},{text:i.description,weight:2},{text:i.url,weight:1}]);a>0&&e.push({doc:i,score:a})}return e.sort((i,a)=>a.score-i.score).map(i=>i.doc)}var q=class extends N{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._filter="";this._loaded=!1;this._busy=!1;this._error="";this._hint="";this._addingLink=!1;this._linkUrl="";this._linkTitle="";this._category="manual";this._thumbs={};this._lightboxUrl="";this._editingId="";this._editTitle="";this._editCategory="manual";this._editDescription="";this._linkDescription="";this._sort=Ue(Z(A.docSort));this._dragOver=!1;this._loadedFor=null;this._loadSeq=0;this._localeReady=!1;this._singlePick=Oi()}_isImage(t){return t.kind==="file"&&(t.mime||"").starts Line truncated
`;var xe=class{constructor(p){this._cache=new Map;this._pending=new Map;this.historyFallbackIds=new Set;this._hass=p}updateHass(p){this._hass=p}async getDetailStats(p,t,e=30){return this._getStats(p,e<=35?"hour":"day",e,t)}async getMiniStats(p,t){return this._getStats(p,"day",14,t)}async getBatchMiniStats(p){let t=new Map,e=[];for(let n of p){let u=`${n.entityId}:day:14`,d=this._cache.get(u);d&&Date.now()-d.fetchedAt<3e5?t.set(n.entityId,d.points):e.push(n)}if(e.length===0)return t;let i=e.filter(n=>n.isCounter).map(n=>n.entityId),a=e.filter(n=>!n.isCounter).map(n=>n.entityId),r=new Date(Date.now()-336*60*60*1e3).toISOString(),c=[];return i.length>0&&c.push(this._fetchBatch(i,"day",r,["state","sum","change"],!0,t)),a.length>0&&c.push(this._fetchBatch(a,"day",r,["mean","min","max"],!1,t)),await Promise.all(c),t}clearCache(){this._cache.clear(),this._pending.clear()}async _getStats(p,t,e,i){let a=`${p}:${t}:${e}`,r=this._cache.get(a);if(r&&Date.now()-r.fetchedAt<3e5)return r.points;if(this._pending.has(a))return this._pending.get(a);let c=this._fetchAndNormalize(p,t,e,i,a);this._pending.set(a,c);try{return await c}finally{this._pending.delete(a)}}async _fetchAndNormalize(p,t,e,i,a){let r=new Date(Date.now()-e*24*60*60*1e3).toISOString(),c=i?["state","sum","change"]:["mean","min","max"];try{let u=(await this._hass.connection.sendMessagePromise({type:"recorder/statistics_during_period",start_time:r,statistic_ids:[p],period:t,types:c}))[p]||[],d=this._normalizeRows(u,i);if(d.length<2){let g=await this._fetchHistoryFallback(p,r);g.length>=2?(d=g,this.historyFallbackIds.add(p)):this.historyFallbackIds.delete(p)}else this.historyFallbackIds.delete(p);return this._cache.set(a,{entityId:p,fetchedAt:Date.now(),period:t,points:d}),d}catch(n){return console.warn(`[maintenance-supporter] Failed to fetch statistics for ${p}:`,n),[]}}async _fetchHistoryFallback(p,t){try{let i=(await this._hass.connection.sendMessagePromise({type:"history/history_during_period",start_time:t,end_time:new Date().toISOString(),entity_ids:[p],minimal_response:!0,no_attributes:!0}))?.[p]||[];if(i.length>1e3){let c=Math.ceil(i.length/500);i=i.filter((n,u)=>u%c===0||u===i.length-1)}let a=[],r=null;for(let c of i){let n=c.s??c.state;if(n==null||n==="unknown"||n==="unavailable")continue;let u;if(n==="on"||n==="open"||n==="true")u=1;else if(n==="off"||n==="closed"||n==="false")u=0;else if(u=parseFloat(n),!Number.isFinite(u))continue;let d=c.lu??c.last_updated??c.last_changed,g=typeof d=="number"?d*1e3:d!=null?Date.parse(d):NaN;Number.isFinite(g)&&(r!=null&&r!==u&&a.push({ts:g,val:r}),a.push({ts:g,val:u}),r=u)}return a.sort((c,n)=>c.ts-n.ts),a.length&&r!=null&&a.push({ts:Date.now(),val:r}),a}catch(e){return console.warn(`[maintenance-supporter] History fallback failed for ${p}:`,e),[]}}async _fetchBatch(p,t,e,i,a,r){try{let c=await this._hass.connection.sendMessagePromise({type:"recorder/statistics_during_period",start_time:e,statistic_ids:p,period:t,types:i});for(let n of p){let u=c[n]||[],d=this._normalizeRows(u,a);r.set(n,d),this._cache.set(`${n}:${t}:14`,{entityId:n,fetchedAt:Date.now(),period:t,points:d})}}catch(c){console.warn("[maintenance-supporter] Batch statistics fetch failed:",c)}}_normalizeRows(p,t){let e=[];for(let i of p){let a=null;if(t?a=i.state??null:a=i.mean??null,a===null)continue;let r={ts:i.start,val:a};t||(i.min!=null&&(r.min=i.min),i.max!=null&&(r.max=i.max)),e.push(r)}return e.sort((i,a)=>i.ts-a.ts),e}};function wt(l,p){let t=l??0;return t<1024?`${t} B`:t<1024*1024?`${Y(t/1024,p,1)} KB`:`${Y(t/(1024*1024),p,1)} MB`}var ke=8,Fe=["newest","oldest","title","category"];function Ue(l){return Fe.includes(l??"")?l:"newest"}function as(l,p){let t=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),e=c=>nt(c).trim(),i=(c,n)=>t.compare(e(c),e(n)),a=c=>c.kind==="weblink"?Dt.length+1:Dt.indexOf(Ft(c)),r=[...l];switch(p){case"oldest":return r.sort((c,n)=>(c.added_at||"").localeCompare(n.added_at||""));case"title":return r.sort(i);case"category":return r.sort((c,n)=>a(c)-a(n)||i(c,n));default:return r.sort((c,n)=>(n.added_at||"").localeCompare(c.added_at||""))}}function we(l,p){let t=se(p);if(!t.length)return l;let e=[];for(let i of l){let a=Lt(t,[{text:i.title,weight:3},{text:i.filename,weight:2},{text:(i.tags||[]).join(" "),weight:2},{text:i.description,weight:2},{text:i.url,weight:1}]);a>0&&e.push({doc:i,score:a})}return e.sort((i,a)=>a.score-i.score).map(i=>i.doc)}var F=class extends N{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._filter="";this._loaded=!1;this._busy=!1;this._error="";this._hint="";this._addingLink=!1;this._linkUrl="";this._linkTitle="";this._category="manual";this._thumbs={};this._lightboxUrl="";this._editingId="";this._editTitle="";this._editCategory="manual";this._editDescription="";this._linkDescription="";this._sort=Ue(Z(A.docSort));this._dragOver=!1;this._loadedFor=null;this._loadSeq=0;this._localeReady=!1;this._singlePick=Mi()}_isImage(t){return t.kind==="file"&&(t.mime||"").starts Line truncated
<div
class="doc-zone ${this._dragOver?"drag-over":""}"
@dragover=${this._onDragOver}
@@ -2382,7 +2382,7 @@ ${$(l.notes)}</div>`:""}
<input type="search" aria-label=${s("doc_search",t)} placeholder=${s("doc_search",t)}
.value=${this._filter} @input=${e=>this._filter=e.target.value} />
</div>`:h}
${this._loaded?this._docs.length===0?o`<div class="doc-empty">${s("documents_empty",t)}</div>`:(()=>{let e=this._filter.trim()?we(this._docs,this._filter):is(this._docs,this._sort);return e.length===0?o`<div class="doc-empty">${s("doc_search_none",t)}</div>`:o`<div class="doc-list">${e.map(i=>this._renderDoc(i,t))}</div>`})():o`<div class="doc-empty">${s("loading",t)}</div>`}
${this._loaded?this._docs.length===0?o`<div class="doc-empty">${s("documents_empty",t)}</div>`:(()=>{let e=this._filter.trim()?we(this._docs,this._filter):as(this._docs,this._sort);return e.length===0?o`<div class="doc-empty">${s("doc_search_none",t)}</div>`:o`<div class="doc-list">${e.map(i=>this._renderDoc(i,t))}</div>`})():o`<div class="doc-empty">${s("loading",t)}</div>`}
${this._lightboxUrl?o`<div class="lightbox" @click=${()=>this._lightboxUrl=""}>
<img class="lightbox-img" src=${this._lightboxUrl} @click=${e=>e.stopPropagation()} />
@@ -2471,7 +2471,7 @@ ${$(l.notes)}</div>`:""}
<ha-icon icon="mdi:close"></ha-icon>
</button>
</div>
`}};q.styles=[Mi,B`
`}};F.styles=[Ai,B`
:host { display: block; margin: 8px 0 4px; }
.doc-zone { position: relative; }
.doc-zone.drag-over {
@@ -2596,7 +2596,7 @@ ${$(l.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; }
`],_([R({attribute:!1})],q.prototype,"hass",2),_([R({attribute:!1})],q.prototype,"entryId",2),_([R({type:Boolean})],q.prototype,"canWrite",2),_([f()],q.prototype,"_docs",2),_([f()],q.prototype,"_filter",2),_([f()],q.prototype,"_loaded",2),_([f()],q.prototype,"_busy",2),_([f()],q.prototype,"_error",2),_([f()],q.prototype,"_hint",2),_([f()],q.prototype,"_addingLink",2),_([f()],q.prototype,"_linkUrl",2),_([f()],q.prototype,"_linkTitle",2),_([f()],q.prototype,"_category",2),_([f()],q.prototype,"_thumbs",2),_([f()],q.prototype,"_lightboxUrl",2),_([f()],q.prototype,"_editingId",2),_([f()],q.prototype,"_editTitle",2),_([f()],q.prototype,"_editCategory",2),_([f()],q.prototype,"_editDescription",2),_([f()],q.prototype,"_linkDescription",2),_([f()],q.prototype,"_sort",2),_([f()],q.prototype,"_dragOver",2);customElements.get("maintenance-documents-section")||customElements.define("maintenance-documents-section",q);var ct=class extends N{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._loaded=!1;this._busy=!1;this._error="";this._attachId="";this._filter="";this._loadedKey="";this._localeReady=!1}get _lang(){return K(this.hass)}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,ot(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(){let t=await P(this,{type:"maintenance_supporter/documents/list",entry_id:this.entryId},{onError:e=>{this._error=e}});this._loaded=!0,t!==void 0&&(this._docs=t?.documents||[],this._error="")}async _update(t){this._error="",await P(this,{type:"maintenance_supporter/documents/update",...t},{busy:e=>{this._busy=e},reload:()=>this._load(),onError:e=>{this._error=e}})}async _signed(t){await P(this,t,{onError:e=>{this._error=e}})}_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){await this._update({doc_id:t.id,[this._linkField]:e})}_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"){st(t.url)&&window.open(t.url,"_blank","noopener");return}let e=this._pageFor(t);await this._signed(()=>Et(this.hass,t.id,e?`#page=${e}`:""))}async _setPage(t,e){this.taskId&&await this._update({doc_id:t.id,task_pages:{[this.taskId]:e}})}async _download(t){await this._signed(()=>ce(this.hass,t.id,t.filename||t.title||"document"))}render(){if(!this._loaded||this._docs.length===0)return h;let t=this._lang,e=this._linked(),i=this._available();return o`
`],_([R({attribute:!1})],F.prototype,"hass",2),_([R({attribute:!1})],F.prototype,"entryId",2),_([R({type:Boolean})],F.prototype,"canWrite",2),_([f()],F.prototype,"_docs",2),_([f()],F.prototype,"_filter",2),_([f()],F.prototype,"_loaded",2),_([f()],F.prototype,"_busy",2),_([f()],F.prototype,"_error",2),_([f()],F.prototype,"_hint",2),_([f()],F.prototype,"_addingLink",2),_([f()],F.prototype,"_linkUrl",2),_([f()],F.prototype,"_linkTitle",2),_([f()],F.prototype,"_category",2),_([f()],F.prototype,"_thumbs",2),_([f()],F.prototype,"_lightboxUrl",2),_([f()],F.prototype,"_editingId",2),_([f()],F.prototype,"_editTitle",2),_([f()],F.prototype,"_editCategory",2),_([f()],F.prototype,"_editDescription",2),_([f()],F.prototype,"_linkDescription",2),_([f()],F.prototype,"_sort",2),_([f()],F.prototype,"_dragOver",2);customElements.get("maintenance-documents-section")||customElements.define("maintenance-documents-section",F);var ct=class extends N{constructor(){super(...arguments);this.canWrite=!1;this._docs=[];this._loaded=!1;this._busy=!1;this._error="";this._attachId="";this._filter="";this._loadedKey="";this._localeReady=!1}get _lang(){return K(this.hass)}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,ot(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(){let t=await P(this,{type:"maintenance_supporter/documents/list",entry_id:this.entryId},{onError:e=>{this._error=e}});this._loaded=!0,t!==void 0&&(this._docs=t?.documents||[],this._error="")}async _update(t){this._error="",await P(this,{type:"maintenance_supporter/documents/update",...t},{busy:e=>{this._busy=e},reload:()=>this._load(),onError:e=>{this._error=e}})}async _signed(t){await P(this,t,{onError:e=>{this._error=e}})}_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){await this._update({doc_id:t.id,[this._linkField]:e})}_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"){st(t.url)&&window.open(t.url,"_blank","noopener");return}let e=this._pageFor(t);await this._signed(()=>Et(this.hass,t.id,e?`#page=${e}`:""))}async _setPage(t,e){this.taskId&&await this._update({doc_id:t.id,task_pages:{[this.taskId]:e}})}async _download(t){await this._signed(()=>ce(this.hass,t.id,t.filename||t.title||"document"))}render(){if(!this._loaded||this._docs.length===0)return h;let t=this._lang,e=this._linked(),i=this._available();return o`
<div class="task-docs">
<h3><ha-icon icon="mdi:paperclip"></ha-icon> ${s("documents",t)} (${e.length})</h3>
${this._error?o`<div class="tdoc-error">${this._error}</div>`:h}
@@ -2718,7 +2718,7 @@ ${$(l.notes)}</div>`:""}
}
.tdoc-btn ha-icon { --mdc-icon-size: 18px; }
.tdoc-btn[disabled] { opacity: 0.5; pointer-events: none; }
`,_([R({attribute:!1})],ct.prototype,"hass",2),_([R({attribute:!1})],ct.prototype,"entryId",2),_([R({attribute:!1})],ct.prototype,"taskId",2),_([R({attribute:!1})],ct.prototype,"partId",2),_([R({type:Boolean})],ct.prototype,"canWrite",2),_([f()],ct.prototype,"_docs",2),_([f()],ct.prototype,"_loaded",2),_([f()],ct.prototype,"_busy",2),_([f()],ct.prototype,"_error",2),_([f()],ct.prototype,"_attachId",2),_([f()],ct.prototype,"_filter",2);customElements.get("maintenance-task-documents")||customElements.define("maintenance-task-documents",ct);var Bs={name:"",vendor:"",mpn:"",gtin:"",storage_location:"",product_url:"",unit:"",cost:"",stock:"",reorder_threshold:"",restock_quantity:"",package_size:"",auto_buy_task:!0,notes:""},lt=class extends N{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 K(this.hass)}connectedCallback(){super.connectedCallback(),ot(this._lang).then(()=>this.requestUpdate())}_notifyChanged(){this.dispatchEvent(new CustomEvent("parts-changed",{bubbles:!0,composed:!0}))}_send(t){return this._error="",P(this,t,{busy:e=>{this._busy=e},onError:e=>{this._error=e}})}_openAdd(){this._editing={...Bs}}_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):"",package_size:t.package_size!=null?String(t.package_size):"",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),package_size:e(t.package_size),auto_buy_task:t.auto_buy_task,notes:t.notes.trim()||null}}async _save(){let t=this._editing;if(this._busy||!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})!==void 0&&(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})!==void 0&&this._notifyChanged()}async _restock(t){if(this._busy)return;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!==void 0&&(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),r=this._docsFor===t.id;return o`
`,_([R({attribute:!1})],ct.prototype,"hass",2),_([R({attribute:!1})],ct.prototype,"entryId",2),_([R({attribute:!1})],ct.prototype,"taskId",2),_([R({attribute:!1})],ct.prototype,"partId",2),_([R({type:Boolean})],ct.prototype,"canWrite",2),_([f()],ct.prototype,"_docs",2),_([f()],ct.prototype,"_loaded",2),_([f()],ct.prototype,"_busy",2),_([f()],ct.prototype,"_error",2),_([f()],ct.prototype,"_attachId",2),_([f()],ct.prototype,"_filter",2);customElements.get("maintenance-task-documents")||customElements.define("maintenance-task-documents",ct);var qs={name:"",vendor:"",mpn:"",gtin:"",storage_location:"",product_url:"",unit:"",cost:"",stock:"",reorder_threshold:"",restock_quantity:"",package_size:"",auto_buy_task:!0,notes:""},lt=class extends N{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 K(this.hass)}connectedCallback(){super.connectedCallback(),ot(this._lang).then(()=>this.requestUpdate())}_notifyChanged(){this.dispatchEvent(new CustomEvent("parts-changed",{bubbles:!0,composed:!0}))}_send(t){return this._error="",P(this,t,{busy:e=>{this._busy=e},onError:e=>{this._error=e}})}_openAdd(){this._editing={...qs}}_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):"",package_size:t.package_size!=null?String(t.package_size):"",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),package_size:e(t.package_size),auto_buy_task:t.auto_buy_task,notes:t.notes.trim()||null}}async _save(){let t=this._editing;if(this._busy||!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})!==void 0&&(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})!==void 0&&this._notifyChanged()}async _restock(t){if(this._busy)return;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!==void 0&&(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),r=this._docsFor===t.id;return o`
<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">
@@ -2757,7 +2757,7 @@ ${$(l.notes)}</div>`:""}
<ha-icon-button
title=${s("part_restock",e)}
.disabled=${this._busy}
@click=${()=>{this._restockFor=t.id,this._restockInvalid=!1,this._restockQty=String(xi(t))}}
@click=${()=>{this._restockFor=t.id,this._restockInvalid=!1,this._restockQty=String(wi(t))}}
><ha-icon icon="mdi:plus-minus-variant"></ha-icon
></ha-icon-button>
`}
@@ -2831,14 +2831,14 @@ ${$(l.notes)}</div>`:""}
>
</div>
</div>
`}_inventoryValue(){let t=0,e=!1;for(let i of this.parts){let a=yi(i),r=typeof i.stock=="number"?i.stock:null;a!==null&&r!==null&&(t+=a*r,e=!0)}return e?t:null}render(){let t=this._lang;return!this.parts.length&&!this.canWrite?h:o`
`}_inventoryValue(){let t=0,e=!1;for(let i of this.parts){let a=ki(i),r=typeof i.stock=="number"?i.stock:null;a!==null&&r!==null&&(t+=a*r,e=!0)}return e?t:null}render(){let t=this._lang;return!this.parts.length&&!this.canWrite?h:o`
<div class="section-head">
<h3>
<ha-icon icon="mdi:package-variant"></ha-icon>
${s("parts_section",t)} (${this.parts.length})
${this._inventoryValue()!==null?o`<span class="inventory-value" title=${s("parts_inventory_value",t)}
>${s("parts_inventory_value",t)}:
${F(this._inventoryValue(),this.currencySymbol,t)}</span>`:h}
${U(this._inventoryValue(),this.currencySymbol,t)}</span>`:h}
</h3>
${this.canWrite&&!this._editing?o`<ha-button appearance="plain" @click=${()=>this._openAdd()}>
<ha-icon icon="mdi:plus"></ha-icon> ${s("part_add",t)}
@@ -3003,7 +3003,7 @@ ${$(l.notes)}</div>`:""}
font-size: 13px;
margin: 4px 0;
}
`,_([R({attribute:!1})],lt.prototype,"hass",2),_([R({attribute:!1})],lt.prototype,"entryId",2),_([R({attribute:!1})],lt.prototype,"parts",2),_([R({type:Boolean})],lt.prototype,"canWrite",2),_([R({attribute:!1})],lt.prototype,"currencySymbol",2),_([f()],lt.prototype,"_editing",2),_([f()],lt.prototype,"_busy",2),_([f()],lt.prototype,"_error",2),_([f()],lt.prototype,"_restockFor",2),_([f()],lt.prototype,"_restockQty",2),_([f()],lt.prototype,"_restockInvalid",2),_([f()],lt.prototype,"_docsFor",2);customElements.get("maintenance-parts-section")||customElements.define("maintenance-parts-section",lt);var $e={readings:!0,parts:!0,photos:!0,documents:!0,checklist:!0,notes:!0,costs:!0,person:!0,refs:!0,qr:!1,bare:!0,docDescriptions:!0};function Ns(l){return!!(l.notes&&l.notes.trim()||l.cost!=null||l.duration!=null||l.readings.length||l.parts.length||l.photoIds.length||l.checklist)}var qs=6;function ss(l,p,t,e,i,a,r,c={}){let n=c.options??{layout:"chronological",include:$e},u=n.include,d=c.data??{objectRef:null,tasks:[],photos:{},fmtNumber:T=>String(T)},g=p.filter(T=>T.type==="completed"&&(u.bare!==!1||Ns(T))),{totalCost:m}=ue(g),v=T=>u.refs&&d.objectRef&&T.taskRefNo!=null&&T.refNo!=null?`${d.objectRef}.${T.taskRefNo}-${T.refNo}`:null,y=T=>u.refs&&d.objectRef&&T.taskRefNo!=null?`${d.objectRef}.${T.taskRefNo}`:null,E=[[t.refNumber,u.refs&&d.objectRef?`#${d.objectRef}`:null],[t.manufacturer,l.manufacturer],[t.model,l.model],[t.serial,l.serial_number],[t.installed,l.installation_date?e(l.installation_date):null]].filter(([,T])=>T).map(([T,z])=>`<div class="meta-row"><span>${$(T)}</span><strong>${$(z)}</strong></div>`).join(""),w=T=>{let z=[];if(u.readings&&T.readings.length){let H=T.readings.map(I=>{let W=`${d.fmtNumber(I.value)}${I.unit?` ${$(I.unit)}`:""}`,Q=I.delta!=null?` <span class="delta">(${I.delta>=0?"+":"\u2212"}${d.fmtNumber(Math.abs(I.delta))})</span>`:"";return`${I.name?`${$(I.name)}: `:""}${W}${Q}`});z.push(`<div class="fact"><span class="k">${$(t.readings)}</span>${H.join(" \xB7 ")}</div>`)}if(u.parts&&T.parts.length&&z.push(`<div class="fact"><span class="k">${$(t.parts)}</span>${T.parts.map(H=>`${$(H.name)} \xD7 ${d.fmtNumber(H.quantity)}`).join(", ")}</div>`),u.checklist&&T.checklist&&z.push(`<div class="fact"><span class="k">${$(t.checklist)}</span>${T.checklist.done}/${T.checklist.total}</div>`),u.photos&&T.photoIds.length){let H=T.photoIds.slice(0,qs),I=H.map(Q=>{let J=d.photos[Q],S=J?.name||Q.slice(0,8);return J?.url?`<figure class="photo"><img src="${$(J.url)}" alt="" /><figcaption>${$(S)}</figcaption></figure>`:`<figure class="photo"><figcaption>${$(S)}</figcaption></figure>`}),W=T.photoIds.length>H.length?`<span class="more">+${T.photoIds.length-H.length}</span>`:"";z.push(`<div class="fact"><span class="k">${$(t.photos)}</span><div class="photos">${I.join("")}${W}</div></div>`)}return z.length?`<div class="details">${z.join("")}</div>`:""},j=T=>[u.notes?T.notes:null,u.person&&T.completedBy?`${t.completedBy}: ${T.completedBy}`:null].filter(Boolean).join(" \xB7 "),x=T=>u.costs?`<td class="num">${T.cost!=null?$(a(T.cost)):$(t.none)}</td>
`,_([R({attribute:!1})],lt.prototype,"hass",2),_([R({attribute:!1})],lt.prototype,"entryId",2),_([R({attribute:!1})],lt.prototype,"parts",2),_([R({type:Boolean})],lt.prototype,"canWrite",2),_([R({attribute:!1})],lt.prototype,"currencySymbol",2),_([f()],lt.prototype,"_editing",2),_([f()],lt.prototype,"_busy",2),_([f()],lt.prototype,"_error",2),_([f()],lt.prototype,"_restockFor",2),_([f()],lt.prototype,"_restockQty",2),_([f()],lt.prototype,"_restockInvalid",2),_([f()],lt.prototype,"_docsFor",2);customElements.get("maintenance-parts-section")||customElements.define("maintenance-parts-section",lt);var $e={readings:!0,parts:!0,photos:!0,documents:!0,checklist:!0,notes:!0,costs:!0,person:!0,refs:!0,qr:!1,bare:!0,docDescriptions:!0};function Fs(l){return!!(l.notes&&l.notes.trim()||l.cost!=null||l.duration!=null||l.readings.length||l.parts.length||l.photoIds.length||l.checklist)}var Us=6;function rs(l,p,t,e,i,a,r,c={}){let n=c.options??{layout:"chronological",include:$e},u=n.include,d=c.data??{objectRef:null,tasks:[],photos:{},fmtNumber:T=>String(T)},g=p.filter(T=>T.type==="completed"&&(u.bare!==!1||Fs(T))),{totalCost:m}=ue(g),v=T=>u.refs&&d.objectRef&&T.taskRefNo!=null&&T.refNo!=null?`${d.objectRef}.${T.taskRefNo}-${T.refNo}`:null,y=T=>u.refs&&d.objectRef&&T.taskRefNo!=null?`${d.objectRef}.${T.taskRefNo}`:null,E=[[t.refNumber,u.refs&&d.objectRef?`#${d.objectRef}`:null],[t.manufacturer,l.manufacturer],[t.model,l.model],[t.serial,l.serial_number],[t.installed,l.installation_date?e(l.installation_date):null]].filter(([,T])=>T).map(([T,z])=>`<div class="meta-row"><span>${$(T)}</span><strong>${$(z)}</strong></div>`).join(""),w=T=>{let z=[];if(u.readings&&T.readings.length){let H=T.readings.map(I=>{let W=`${d.fmtNumber(I.value)}${I.unit?` ${$(I.unit)}`:""}`,Q=I.delta!=null?` <span class="delta">(${I.delta>=0?"+":"\u2212"}${d.fmtNumber(Math.abs(I.delta))})</span>`:"";return`${I.name?`${$(I.name)}: `:""}${W}${Q}`});z.push(`<div class="fact"><span class="k">${$(t.readings)}</span>${H.join(" \xB7 ")}</div>`)}if(u.parts&&T.parts.length&&z.push(`<div class="fact"><span class="k">${$(t.parts)}</span>${T.parts.map(H=>`${$(H.name)} \xD7 ${d.fmtNumber(H.quantity)}`).join(", ")}</div>`),u.checklist&&T.checklist&&z.push(`<div class="fact"><span class="k">${$(t.checklist)}</span>${T.checklist.done}/${T.checklist.total}</div>`),u.photos&&T.photoIds.length){let H=T.photoIds.slice(0,Us),I=H.map(Q=>{let J=d.photos[Q],S=J?.name||Q.slice(0,8);return J?.url?`<figure class="photo"><img src="${$(J.url)}" alt="" /><figcaption>${$(S)}</figcaption></figure>`:`<figure class="photo"><figcaption>${$(S)}</figcaption></figure>`}),W=T.photoIds.length>H.length?`<span class="more">+${T.photoIds.length-H.length}</span>`:"";z.push(`<div class="fact"><span class="k">${$(t.photos)}</span><div class="photos">${I.join("")}${W}</div></div>`)}return z.length?`<div class="details">${z.join("")}</div>`:""},j=T=>[u.notes?T.notes:null,u.person&&T.completedBy?`${t.completedBy}: ${T.completedBy}`:null].filter(Boolean).join(" \xB7 "),x=T=>u.costs?`<td class="num">${T.cost!=null?$(a(T.cost)):$(t.none)}</td>
<td class="num">${T.duration!=null?$(i(T.duration)):$(t.none)}</td>`:"",M=T=>T?`<span class="ref">#${$(T)}</span>`:"",b=u.costs?5:3,D=T=>`<thead><tr>
<th>${$(t.colDate)}</th>
${T?`<th>${$(t.colTask)}</th>`:"<th></th>"}
@@ -3107,7 +3107,7 @@ ${E?`<div class="meta">${E}</div>`:""}
${pt}
${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</body>
</html>`}var Fs=60,tt=class extends N{constructor(){super(...arguments);this.entryId="";this.object=null;this.tasks=[];this.currencySymbol="\u20AC";this.userName=()=>null;this._full={};this._loading=!1;this._filterTask="";this._from="";this._to="";this._expanded=!1;this._printOpen=!1;this._printLayout="chronological";this._printInclude={...$e};this._printing=!1;this._loadedFor=null;this._loadedSignature="";this._loadSeq=0;this._localeReady=!1}connectedCallback(){super.connectedCallback();try{let t=JSON.parse(Z(A.printOptions)||"null");(t?.layout==="by_task"||t?.layout==="chronological")&&(this._printLayout=t.layout),t?.include&&typeof t.include=="object"&&(this._printInclude={...$e,...t.include})}catch{}}_savePrintOptions(){V(A.printOptions,JSON.stringify({layout:this._printLayout,include:this._printInclude}))}_toggleInclude(t,e){this._printInclude={...this._printInclude,[t]:e},this._savePrintOptions()}get _lang(){return K(this.hass)}updated(t){if(super.updated(t),!this._localeReady&&this.hass&&(this._localeReady=!0,ot(this._lang).then(()=>this.requestUpdate())),this.entryId&&this._loadedFor!==this.entryId)this._loadedFor=this.entryId,this._full={},this._filterTask="",this._from="",this._to="",this._loadedSignature=this._historySignature(),this._loadFullHistories();else if(this.entryId&&t.has("tasks")){let e=this._historySignature();e!==this._loadedSignature&&(this._loadedSignature=e,this._loadFullHistories())}}_historySignature(){return JSON.stringify(this.tasks.map(t=>[t.id,t.history_count??null,t.history??[]]))}async _loadFullHistories(){let t=this.entryId,e=this.tasks,i=++this._loadSeq;if(!e.length){this._full={},this._loading=!1;return}this._loading=!0;let a=await Promise.all(e.map(async r=>{try{let c=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history",entry_id:t,task_id:r.id});return[r.id,c.history??[]]}catch{return[r.id,r.history??[]]}}));this.entryId!==t||i!==this._loadSeq||(this._full=Object.fromEntries(a),this._loading=!1)}get _entries(){return wi(this.tasks.map(t=>({id:t.id,name:t.name,history:this._full[t.id]??t.history??[],ref_no:t.ref_no,reading_unit:t.reading_unit})))}get _capped(){return Object.values(this._full).some(t=>t.length>=ki)}_openTask(t){this.dispatchEvent(new CustomEvent("open-task",{detail:{taskId:t},bubbles:!0,composed:!0}))}async _bookletData(t){let e=this._printInclude,i=this._lang,a=[];if(e.documents||e.photos)try{a=(await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/list",entry_id:this.entryId})).documents||[]}catch{a=[]}let r=new Map;e.qr&&this._printLayout==="by_task"&&await Promise.all(this.tasks.map(async u=>{try{let d=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/qr/generate",entry_id:this.entryId,task_id:u.id,url_mode:"server",action:"view"});d.svg_data_uri&&r.set(u.id,d.svg_data_uri)}catch{}}));let c=this.tasks.map(u=>({id:u.id,name:u.name,ref:St(this.object,u),schedule:It(u,i)||null,documents:a.filter(d=>(d.task_ids||[]).includes(u.id)&&!ts(d)).map(d=>({title:nt(d),page:d.task_pages?.[u.id]??null,description:d.description||null})),qrDataUri:r.get(u.id)??null})),n={};if(e.photos){let u=[...new Set(t.filter(g=>g.type==="completed").flatMap(g=>g.photoIds))].slice(0,Fs),d=new Map(a.map(g=>[g.id,g]));await Promise.all(u.map(async g=>{let m=d.get(g),v=m&&nt(m)||g.slice(0,8);try{n[g]={name:v,url:new URL(await le(this.hass,g),window.location.origin).href}}catch{n[g]={name:v,url:null}}}))}return{tasks:c,photos:n}}async _print(t){let e=this._lang,i=this.object;if(!i||this._printing)return;let a=de();this._printing=!0;let r;try{r=await this._bookletData(t)}catch(d){throw a?.close(),d}finally{this._printing=!1}this._printOpen=!1;let c={title:s("service_record_title",e),generated:s("report_generated",e),manufacturer:s("manufacturer",e),model:s("model",e),serial:s("serial_number_label",e),installed:s("installed",e),colDate:s("date",e),colTask:s("task_name",e),colCost:s("cost",e),colDuration:s("duration",e),colNotes:s("notes_label",e),completedBy:s("completed_by",e),totalLabel:s("report_total_cost",e),entriesLabel:d=>`${d} ${s("service_record_entries",e)}`,capNote:s("object_history_cap_note",e),none:"\u2014",readings:s("print_inc_readings",e),parts:s("print_inc_parts",e),photos:s("print_inc_photos",e),documents:s("print_inc_documents",e),checklist:s("print_inc_checklist",e),refNumber:s("ref_number",e),scanHint:s("report_scan_hint",e),page:d=>s("search_page",e).replace("{page}",String(d))},n=t.map(d=>({...d,completedBy:d.completedBy?this.userName(d.completedBy):null,notes:d.notes?ge(d.notes,e):null})),u=ss(i,n,c,d=>d?U(d,e):"",d=>Yt(d,e),d=>F(d,this.currencySymbol,e),new Date().toISOString(),{capped:this._capped,options:{layout:this._printLayout,include:this._printInclude},data:{objectRef:jt(i),tasks:r.tasks,photos:r.photos,fmtNumber:d=>Y(d,e)}});Jt(u,a)}_renderPrintOptions(t){let e=this._lang,i=this._printInclude,a=(c,n,u=!1)=>o`
</html>`}var Vs=60,tt=class extends N{constructor(){super(...arguments);this.entryId="";this.object=null;this.tasks=[];this.currencySymbol="\u20AC";this.userName=()=>null;this._full={};this._loading=!1;this._filterTask="";this._from="";this._to="";this._expanded=!1;this._printOpen=!1;this._printLayout="chronological";this._printInclude={...$e};this._printing=!1;this._loadedFor=null;this._loadedSignature="";this._loadSeq=0;this._localeReady=!1}connectedCallback(){super.connectedCallback();try{let t=JSON.parse(Z(A.printOptions)||"null");(t?.layout==="by_task"||t?.layout==="chronological")&&(this._printLayout=t.layout),t?.include&&typeof t.include=="object"&&(this._printInclude={...$e,...t.include})}catch{}}_savePrintOptions(){V(A.printOptions,JSON.stringify({layout:this._printLayout,include:this._printInclude}))}_toggleInclude(t,e){this._printInclude={...this._printInclude,[t]:e},this._savePrintOptions()}get _lang(){return K(this.hass)}updated(t){if(super.updated(t),!this._localeReady&&this.hass&&(this._localeReady=!0,ot(this._lang).then(()=>this.requestUpdate())),this.entryId&&this._loadedFor!==this.entryId)this._loadedFor=this.entryId,this._full={},this._filterTask="",this._from="",this._to="",this._loadedSignature=this._historySignature(),this._loadFullHistories();else if(this.entryId&&t.has("tasks")){let e=this._historySignature();e!==this._loadedSignature&&(this._loadedSignature=e,this._loadFullHistories())}}_historySignature(){return JSON.stringify(this.tasks.map(t=>[t.id,t.history_count??null,t.history??[]]))}async _loadFullHistories(){let t=this.entryId,e=this.tasks,i=++this._loadSeq;if(!e.length){this._full={},this._loading=!1;return}this._loading=!0;let a=await Promise.all(e.map(async r=>{try{let c=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history",entry_id:t,task_id:r.id});return[r.id,c.history??[]]}catch{return[r.id,r.history??[]]}}));this.entryId!==t||i!==this._loadSeq||(this._full=Object.fromEntries(a),this._loading=!1)}get _entries(){return ji(this.tasks.map(t=>({id:t.id,name:t.name,history:this._full[t.id]??t.history??[],ref_no:t.ref_no,reading_unit:t.reading_unit})))}get _capped(){return Object.values(this._full).some(t=>t.length>=$i)}_openTask(t){this.dispatchEvent(new CustomEvent("open-task",{detail:{taskId:t},bubbles:!0,composed:!0}))}async _bookletData(t){let e=this._printInclude,i=this._lang,a=[];if(e.documents||e.photos)try{a=(await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/documents/list",entry_id:this.entryId})).documents||[]}catch{a=[]}let r=new Map;e.qr&&this._printLayout==="by_task"&&await Promise.all(this.tasks.map(async u=>{try{let d=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/qr/generate",entry_id:this.entryId,task_id:u.id,url_mode:"server",action:"view"});d.svg_data_uri&&r.set(u.id,d.svg_data_uri)}catch{}}));let c=this.tasks.map(u=>({id:u.id,name:u.name,ref:St(this.object,u),schedule:It(u,i)||null,documents:a.filter(d=>(d.task_ids||[]).includes(u.id)&&!is(d)).map(d=>({title:nt(d),page:d.task_pages?.[u.id]??null,description:d.description||null})),qrDataUri:r.get(u.id)??null})),n={};if(e.photos){let u=[...new Set(t.filter(g=>g.type==="completed").flatMap(g=>g.photoIds))].slice(0,Vs),d=new Map(a.map(g=>[g.id,g]));await Promise.all(u.map(async g=>{let m=d.get(g),v=m&&nt(m)||g.slice(0,8);try{n[g]={name:v,url:new URL(await le(this.hass,g),window.location.origin).href}}catch{n[g]={name:v,url:null}}}))}return{tasks:c,photos:n}}async _print(t){let e=this._lang,i=this.object;if(!i||this._printing)return;let a=de();this._printing=!0;let r;try{r=await this._bookletData(t)}catch(d){throw a?.close(),d}finally{this._printing=!1}this._printOpen=!1;let c={title:s("service_record_title",e),generated:s("report_generated",e),manufacturer:s("manufacturer",e),model:s("model",e),serial:s("serial_number_label",e),installed:s("installed",e),colDate:s("date",e),colTask:s("task_name",e),colCost:s("cost",e),colDuration:s("duration",e),colNotes:s("notes_label",e),completedBy:s("completed_by",e),totalLabel:s("report_total_cost",e),entriesLabel:d=>`${d} ${s("service_record_entries",e)}`,capNote:s("object_history_cap_note",e),none:"\u2014",readings:s("print_inc_readings",e),parts:s("print_inc_parts",e),photos:s("print_inc_photos",e),documents:s("print_inc_documents",e),checklist:s("print_inc_checklist",e),refNumber:s("ref_number",e),scanHint:s("report_scan_hint",e),page:d=>s("search_page",e).replace("{page}",String(d))},n=t.map(d=>({...d,completedBy:d.completedBy?this.userName(d.completedBy):null,notes:d.notes?ge(d.notes,e):null})),u=rs(i,n,c,d=>d?q(d,e):"",d=>Yt(d,e),d=>U(d,this.currencySymbol,e),new Date().toISOString(),{capped:this._capped,options:{layout:this._printLayout,include:this._printInclude},data:{objectRef:jt(i),tasks:r.tasks,photos:r.photos,fmtNumber:d=>Y(d,e)}});Jt(u,a)}_renderPrintOptions(t){let e=this._lang,i=this._printInclude,a=(c,n,u=!1)=>o`
<label class="opt ${u?"disabled":""}">
<input type="checkbox" .checked=${i[c]} ?disabled=${u}
@change=${d=>this._toggleInclude(c,d.target.checked)} />
@@ -3143,7 +3143,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${this._printing?s("loading",e):s("print_button",e)}
</ha-button>
</div>
</div>`}render(){let t=this._lang,e=this._entries;if(!e.length&&!this._loading)return h;let i=$i(e,{taskId:this._filterTask||null,from:this._from||null,to:this._to||null}),{completed:a,totalCost:r}=ue(i),c=this._expanded?i:i.slice(0,15);return o`
</div>`}render(){let t=this._lang,e=this._entries;if(!e.length&&!this._loading)return h;let i=Si(e,{taskId:this._filterTask||null,from:this._from||null,to:this._to||null}),{completed:a,totalCost:r}=ue(i),c=this._expanded?i:i.slice(0,15);return o`
<div class="section">
<h3>
${s("object_history_section",t)}
@@ -3185,13 +3185,13 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<div class="rows">
${c.map(n=>o`
<div class="row">
<span class="date" title=${ri(n.timestamp,t)}>${U(n.timestamp,t)}</span>
<span class="date" title=${oi(n.timestamp,t)}>${q(n.timestamp,t)}</span>
<span class="type type-${n.type}">${s(n.type,t)}</span>
<button class="task-link" @click=${()=>this._openTask(n.taskId)}>${n.taskName}${n.phaseName?` \xB7 ${n.phaseName}`:""}</button>
<span class="facts">
${n.cost!=null?o`<span>${F(n.cost,this.currencySymbol,t)}</span>`:h}
${n.partsCost!=null?o`<span class="parts-cost" title=${s(n.partsCounted?"history_parts_counted_hint":"history_parts_info_hint",t)}>${s(n.partsCounted?"history_parts_counted":"history_parts_info",t).replace("{amount}",F(n.partsCost,this.currencySymbol,t))}</span>`:h}
${n.purchaseCost!=null?o`<span class="parts-cost">${s("history_purchase_stock",t).replace("{amount}",F(n.purchaseCost,this.currencySymbol,t))}</span>`:h}
${n.cost!=null?o`<span>${U(n.cost,this.currencySymbol,t)}</span>`:h}
${n.partsCost!=null?o`<span class="parts-cost" title=${s(n.partsCounted?"history_parts_counted_hint":"history_parts_info_hint",t)}>${s(n.partsCounted?"history_parts_counted":"history_parts_info",t).replace("{amount}",U(n.partsCost,this.currencySymbol,t))}</span>`:h}
${n.purchaseCost!=null?o`<span class="parts-cost">${s("history_purchase_stock",t).replace("{amount}",U(n.purchaseCost,this.currencySymbol,t))}</span>`:h}
${n.duration!=null?o`<span>${Yt(n.duration,t)}</span>`:h}
</span>
${n.notes?o`<span class="notes" title=${ge(n.notes,t)}>${ge(n.notes,t)}</span>`:h}
@@ -3203,7 +3203,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</ha-button>`:h}
<div class="totals">
${a} ${s("service_record_entries",t)} · ${s("report_total_cost",t)}:
<strong>${F(r,this.currencySymbol,t)}</strong>
<strong>${U(r,this.currencySymbol,t)}</strong>
</div>
${this._capped?o`<p class="cap-note">${s("object_history_cap_note",t)}</p>`:h}
`}
@@ -3276,7 +3276,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
@media (max-width: 640px) {
.notes { padding-left: 0; }
}
`,_([R({attribute:!1})],tt.prototype,"hass",2),_([R()],tt.prototype,"entryId",2),_([R({attribute:!1})],tt.prototype,"object",2),_([R({attribute:!1})],tt.prototype,"tasks",2),_([R()],tt.prototype,"currencySymbol",2),_([R({attribute:!1})],tt.prototype,"userName",2),_([f()],tt.prototype,"_full",2),_([f()],tt.prototype,"_loading",2),_([f()],tt.prototype,"_filterTask",2),_([f()],tt.prototype,"_from",2),_([f()],tt.prototype,"_to",2),_([f()],tt.prototype,"_expanded",2),_([f()],tt.prototype,"_printOpen",2),_([f()],tt.prototype,"_printLayout",2),_([f()],tt.prototype,"_printInclude",2),_([f()],tt.prototype,"_printing",2);customElements.get("maintenance-object-history-section")||customElements.define("maintenance-object-history-section",tt);async function as(l,p,t,e){try{let i=await l.connection.sendMessagePromise({type:"maintenance_supporter/task/undo",entry_id:p,task_id:t});return{ok:!0,message:s(i?.action_ran?"undo_done_action_ran":"undo_done",e)}}catch(i){let a=i?.code;return a==="changed_since"?{ok:!1,message:s("undo_changed",e)}:a==="nothing_to_undo"?{ok:!1,message:s("undo_nothing",e)}:{ok:!1,message:s("action_error",e)}}}var dt=class dt extends N{constructor(){super(...arguments);this.flat=!1;this._ov=null;this._loading=!1;this._marking=!1;this._error="";this._history=null;this._rosterSort=dt._storedSort();this._typeFilter=null;this._recorded=[];this._access=Di;this._historyRequested=!1;this._localeReady=!1;this._markAll=async()=>{await this._mark(void 0)};this._repair=async()=>{await this._act({type:"maintenance_supporter/battery_fleet/setup",language:this._lang})};this._loadHistory=async t=>{let e=t.target.open;if(V(A.batteryRosterOpen,e?"1":"0"),!(!e||this._historyRequested)){this._historyRequested=!0;try{let i=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview_history"});this._history=i.series}catch{this._history=null}}}}get _lang(){return K(this.hass)}get _canWrite(){return Nt(this.hass?.user,this._access)}connectedCallback(){super.connectedCallback(),this.hass&&this._load()}updated(t){Bt(this,t),t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,ot(this._lang).then(()=>this.requestUpdate()),_e(this.hass).then(e=>{this._access=e.access}),this._ov===null&&!this._loading&&this._load())}async _load(){this._error="";let t=await P(this,{type:"maintenance_supporter/battery_fleet/overview"},{busy:e=>{this._loading=e},onError:e=>{this._error=e}});t!==void 0&&(this._ov=t)}async _act(t,e){this._marking||(this._error="",await P(this,t,{busy:i=>{this._marking=i},reload:async()=>{e?.(),await this._load()},onError:i=>{this._error=i}}))}async _mark(t){await this._act({type:"maintenance_supporter/battery_fleet/mark_replaced",...t?{entity_ids:t}:{}})}async _setExcluded(t,e){await this._act({type:"maintenance_supporter/battery_fleet/set_excluded",entity_id:t,excluded:e})}async _addBattery(t){let e=t.detail?.value;e&&await this._act({type:"maintenance_supporter/battery_fleet/set_included",entity_id:e,included:!0})}async _setTrackSelf(t){await this._setFleetOption("set_track_self_charging",t.target.checked)}async _setDueWithoutSensor(t){await this._setFleetOption("set_due_without_sensor",t.target.checked)}async _setFleetOption(t,e){await this._act({type:`maintenance_supporter/battery_fleet/${t}`,enabled:e})}_rosterOpen(){return Z(A.batteryRosterOpen)!=="0"}_predictedTitle(t,e){if(t.forecast_overdue)return s("battery_fleet_forecast_overdue",e);let i=this._predictedDate(t.days_until??0);if(t.predicted_source==="trend")return s("battery_fleet_predicted_trend",e).replace("{date}",i).replace("{confidence}",s("cal_confidence_"+(t.prediction_confidence||"medium"),e));if(t.lifetime_months!=null&&t.lifetime_source){let a=s("lifetime_source_"+t.lifetime_source,e).replace("{n}",String(t.lifetime_samples??0));return s("battery_fleet_predicted_typical",e).replace("{date}",i).replace("{months}",String(t.lifetime_months)).replace("{type}",t.battery_type).replace("{source}",a)}return s("battery_fleet_predicted_on",e).replace("{date}",i)}_sparkline(t){let e=this._history?.[t.entity_id];if(!e||e.points.length<2)return h;let i=110,a=24,r=2,c=e.points[0][0],n=e.points[e.points.length-1][0],u=Date.now()/1e3,d=t.status!=="low"&&t.predicted_source==="trend"&&t.days_until!=null?u+t.days_until*86400:null,g=Math.max(n,d??n),m=j=>g===c?r:r+(j-c)/(g-c)*(i-2*r),v=j=>r+(1-Math.min(100,Math.max(0,j))/100)*(a-2*r),y=e.points.map(([j,x])=>`${O(m(j))},${O(v(x))}`).join(" "),E=e.points[e.points.length-1][1],w=O(v(e.threshold));return o`<svg
`,_([R({attribute:!1})],tt.prototype,"hass",2),_([R()],tt.prototype,"entryId",2),_([R({attribute:!1})],tt.prototype,"object",2),_([R({attribute:!1})],tt.prototype,"tasks",2),_([R()],tt.prototype,"currencySymbol",2),_([R({attribute:!1})],tt.prototype,"userName",2),_([f()],tt.prototype,"_full",2),_([f()],tt.prototype,"_loading",2),_([f()],tt.prototype,"_filterTask",2),_([f()],tt.prototype,"_from",2),_([f()],tt.prototype,"_to",2),_([f()],tt.prototype,"_expanded",2),_([f()],tt.prototype,"_printOpen",2),_([f()],tt.prototype,"_printLayout",2),_([f()],tt.prototype,"_printInclude",2),_([f()],tt.prototype,"_printing",2);customElements.get("maintenance-object-history-section")||customElements.define("maintenance-object-history-section",tt);async function os(l,p,t,e){try{let i=await l.connection.sendMessagePromise({type:"maintenance_supporter/task/undo",entry_id:p,task_id:t});return{ok:!0,message:s(i?.action_ran?"undo_done_action_ran":"undo_done",e)}}catch(i){let a=i?.code;return a==="changed_since"?{ok:!1,message:s("undo_changed",e)}:a==="nothing_to_undo"?{ok:!1,message:s("undo_nothing",e)}:{ok:!1,message:s("action_error",e)}}}var dt=class dt extends N{constructor(){super(...arguments);this.flat=!1;this._ov=null;this._loading=!1;this._marking=!1;this._error="";this._history=null;this._rosterSort=dt._storedSort();this._typeFilter=null;this._recorded=[];this._access=Ii;this._historyRequested=!1;this._localeReady=!1;this._markAll=async()=>{await this._mark(void 0)};this._repair=async()=>{await this._act({type:"maintenance_supporter/battery_fleet/setup",language:this._lang})};this._loadHistory=async t=>{let e=t.target.open;if(V(A.batteryRosterOpen,e?"1":"0"),!(!e||this._historyRequested)){this._historyRequested=!0;try{let i=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/battery_fleet/overview_history"});this._history=i.series}catch{this._history=null}}}}get _lang(){return K(this.hass)}get _canWrite(){return Nt(this.hass?.user,this._access)}connectedCallback(){super.connectedCallback(),this.hass&&this._load()}updated(t){Bt(this,t),t.has("hass")&&this.hass&&!this._localeReady&&(this._localeReady=!0,ot(this._lang).then(()=>this.requestUpdate()),_e(this.hass).then(e=>{this._access=e.access}),this._ov===null&&!this._loading&&this._load())}async _load(){this._error="";let t=await P(this,{type:"maintenance_supporter/battery_fleet/overview"},{busy:e=>{this._loading=e},onError:e=>{this._error=e}});t!==void 0&&(this._ov=t)}async _act(t,e){this._marking||(this._error="",await P(this,t,{busy:i=>{this._marking=i},reload:async()=>{e?.(),await this._load()},onError:i=>{this._error=i}}))}async _mark(t){await this._act({type:"maintenance_supporter/battery_fleet/mark_replaced",...t?{entity_ids:t}:{}})}async _setExcluded(t,e){await this._act({type:"maintenance_supporter/battery_fleet/set_excluded",entity_id:t,excluded:e})}async _addBattery(t){let e=t.detail?.value;e&&await this._act({type:"maintenance_supporter/battery_fleet/set_included",entity_id:e,included:!0})}async _setTrackSelf(t){await this._setFleetOption("set_track_self_charging",t.target.checked)}async _setDueWithoutSensor(t){await this._setFleetOption("set_due_without_sensor",t.target.checked)}async _setFleetOption(t,e){await this._act({type:`maintenance_supporter/battery_fleet/${t}`,enabled:e})}_rosterOpen(){return Z(A.batteryRosterOpen)!=="0"}_predictedTitle(t,e){if(t.forecast_overdue)return s("battery_fleet_forecast_overdue",e);let i=this._predictedDate(t.days_until??0);if(t.predicted_source==="trend")return s("battery_fleet_predicted_trend",e).replace("{date}",i).replace("{confidence}",s("cal_confidence_"+(t.prediction_confidence||"medium"),e));if(t.lifetime_months!=null&&t.lifetime_source){let a=s("lifetime_source_"+t.lifetime_source,e).replace("{n}",String(t.lifetime_samples??0));return s("battery_fleet_predicted_typical",e).replace("{date}",i).replace("{months}",String(t.lifetime_months)).replace("{type}",t.battery_type).replace("{source}",a)}return s("battery_fleet_predicted_on",e).replace("{date}",i)}_sparkline(t){let e=this._history?.[t.entity_id];if(!e||e.points.length<2)return h;let i=110,a=24,r=2,c=e.points[0][0],n=e.points[e.points.length-1][0],u=Date.now()/1e3,d=t.status!=="low"&&t.predicted_source==="trend"&&t.days_until!=null?u+t.days_until*86400:null,g=Math.max(n,d??n),m=j=>g===c?r:r+(j-c)/(g-c)*(i-2*r),v=j=>r+(1-Math.min(100,Math.max(0,j))/100)*(a-2*r),y=e.points.map(([j,x])=>`${O(m(j))},${O(v(x))}`).join(" "),E=e.points[e.points.length-1][1],w=O(v(e.threshold));return o`<svg
class="bf-spark"
viewBox="0 0 ${i} ${a}"
role="img"
@@ -3292,7 +3292,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
x2=${O(m(d))}
y2=${w}
></line>`:h}
</svg>`}static _storedSort(){return Z(A.batteryRosterSort)==="name"?"name":"urgency"}_setSort(t){this._rosterSort=t,V(A.batteryRosterSort,t)}_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,r)=>i(a)-i(r)||a.device_name.localeCompare(r.device_name))}_predictedDate(t){return U(Tt(xt(),t),this._lang)}_fmtDate(t){return Number.isFinite(t)?U(new Date(t).toISOString(),this._lang):"\u2014"}_shoppingLine(t){return Object.entries(t).map(([e,i])=>o`<button
</svg>`}static _storedSort(){return Z(A.batteryRosterSort)==="name"?"name":"urgency"}_setSort(t){this._rosterSort=t,V(A.batteryRosterSort,t)}_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,r)=>i(a)-i(r)||a.device_name.localeCompare(r.device_name))}_predictedDate(t){return q(Tt(yt(),t),this._lang)}_fmtDate(t){return Number.isFinite(t)?q(new Date(t).toISOString(),this._lang):"\u2014"}_shoppingLine(t){return Object.entries(t).map(([e,i])=>o`<button
class="bf-type-chip ${this._typeFilter===e?"bf-type-chip-active":""}"
title=${s("battery_fleet_filter_type",this._lang)}
@click=${()=>this._toggleTypeFilter(e)}
@@ -3933,7 +3933,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
accent-color: var(--primary-color);
margin: 0;
}
`,_([R({attribute:!1})],dt.prototype,"hass",2),_([R({type:Boolean})],dt.prototype,"flat",2),_([f()],dt.prototype,"_ov",2),_([f()],dt.prototype,"_loading",2),_([f()],dt.prototype,"_marking",2),_([f()],dt.prototype,"_error",2),_([f()],dt.prototype,"_history",2),_([f()],dt.prototype,"_rosterSort",2),_([f()],dt.prototype,"_typeFilter",2),_([f()],dt.prototype,"_recorded",2),_([f()],dt.prototype,"_access",2);var Ve=dt;customElements.get("maintenance-battery-fleet-section")||customElements.define("maintenance-battery-fleet-section",Ve);var rs=5;function Us(l,p){let t=[];for(let e=0;e<p;e++)t.push(Tt(l,e));return t}function Vs(l){if(!l||l.length===0)return null;let p=l.map(t=>Rt(t)).filter(t=>t!==null&&t>=0);return p.length===0?null:p.reduce((t,e)=>t+e,0)/p.length}function Ws(l){let{windowStart:p,windowEnd:t,task:e,entryId:i,objectName:a}=l,r=[],c=(g,m)=>({date:g,entry_id:i,task_id:e.id,task_name:e.name,object_name:a,status:m&&(e.status==="overdue"||e.status==="triggered")?"ok":e.status,days_until_due:m?null:e.days_until_due??null,projected:m,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:Vs(e.history),adaptive_enabled:!!e.adaptive_config?.enabled,prediction_confidence:e.threshold_prediction_confidence??null}),n=Math.max(1,Math.round(Ne(e.interval_days,e.interval_unit)));if(e.status==="overdue"||e.status==="triggered"){if(r.push(c(p,!1)),e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=Tt(p,n),m=1;for(;g<=t&&m<rs;)r.push(c(g,!0)),m++,g=Tt(g,n)}return r}let u=e.next_due;if(typeof u!="string"||!u)return r;let d=u.slice(0,10);if(!/^\d{4}-\d{2}-\d{2}$/.test(d))return r;if(d>=p&&d<=t)r.push(c(d,!1));else if(d>t)return r;if(e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=Tt(d,n),m=r.length;for(;g<=t&&m<rs;)g>=p&&(r.push(c(g,!0)),m++),g=Tt(g,n)}return r}function os(l,p,t,e=null){let i=Us(p,t),a=i[0],r=i[i.length-1],c=[];for(let u of l){let d=u.object?.name||"",g=u.entry_id,m=u.tasks||[];for(let v of m){if(e&&v.responsible_user_id!==e||v.enabled===!1)continue;let y=Ws({windowStart:a,windowEnd:r,task:v,entryId:g,objectName:d});c.push(...y)}}let n=new Map;for(let u of i)n.set(u,[]);for(let u of c){let d=n.get(u.date);d&&d.push(u)}for(let[,u]of n)u.sort((d,g)=>{let m=Mt(d.status),v=Mt(g.status);if(m!==v)return m-v;if(d.projected!==g.projected)return d.projected?1:-1;let y=d.object_name.localeCompare(g.object_name);return y!==0?y:d.task_name.localeCompare(g.task_name)});return i.map(u=>({date:u,events:n.get(u)??[]}))}var Ks={completed:"ok",reset:"ok",skipped:"due_soon",missed:"overdue",triggered:"triggered",trigger_replaced:"triggered",trigger_removed:"ok"};function je(l,p){return`${l}/${p}`}function ns(l,p,t){let e=ls(p,t)[0],i=[];for(let a of l)for(let r of a.tasks||[]){let c=r.history||[],n=r.history_count??c.length;if(n<=c.length)continue;let u=c.map(m=>Ce(m?.timestamp)).filter(m=>!!m),d=u.length?u.reduce((m,v)=>m<v?m:v):"";if(d&&d<e)continue;let g=je(a.entry_id,r.id);i.push({entryId:a.entry_id,taskId:r.id,key:g,sig:`${g}:${n}:${Gs(JSON.stringify(c))}`})}return i}function Gs(l){let p=2166136261;for(let t=0;t<l.length;t++)p^=l.charCodeAt(t),p=Math.imul(p,16777619);return(p>>>0).toString(36)}function ls(l,p){let t=[];for(let e=p-1;e>=0;e--)t.push(Tt(l,-e));return t}function cs(l,p,t,e=null,i={}){let a=ls(p,t),r=a[0],c=a[a.length-1],n=new Map;for(let d of a)n.set(d,[]);for(let d of l){let g=d.object?.name||"",m=d.entry_id,v=d.tasks||[];for(let y of v){if(e&&y.responsible_user_id!==e)continue;let E=i[je(m,y.id)]??(y.history||[]);for(let w of E){if(typeof w?.timestamp!="string")continue;let j=Ce(w.timestamp);if(!j||j<r||j>c)continue;let x=n.get(j);if(!x)continue;let M=w.type??"completed";x.push({date:j,entry_id:m,task_id:y.id,task_name:y.name,object_name:g,status:Ks[M]??"ok",days_until_due:null,projected:!1,schedule_type:y.schedule_type,interval_days:y.interval_days??null,responsible_user_id:y.responsible_user_id??null,avg_cost:Rt(w),adaptive_enabled:!!y.adaptive_config?.enabled,prediction_confidence:null,history_timestamp:w.timestamp,history_type:M,history_cost:Rt(w),history_notes:typeof w.notes=="string"?w.notes:null,history_duration:typeof w.duration=="number"?w.duration:null})}}}let u={completed:0,reset:1,skipped:2,triggered:3,trigger_replaced:4};for(let[,d]of n)d.sort((g,m)=>{let v=u[g.history_type??""]??99,y=u[m.history_type??""]??99;if(v!==y)return v-y;let E=g.object_name.localeCompare(m.object_name);return E!==0?E:g.task_name.localeCompare(m.task_name)});return a.map(d=>({date:d,events:n.get(d)??[]}))}var ds=B`
`,_([R({attribute:!1})],dt.prototype,"hass",2),_([R({type:Boolean})],dt.prototype,"flat",2),_([f()],dt.prototype,"_ov",2),_([f()],dt.prototype,"_loading",2),_([f()],dt.prototype,"_marking",2),_([f()],dt.prototype,"_error",2),_([f()],dt.prototype,"_history",2),_([f()],dt.prototype,"_rosterSort",2),_([f()],dt.prototype,"_typeFilter",2),_([f()],dt.prototype,"_recorded",2),_([f()],dt.prototype,"_access",2);var Ve=dt;customElements.get("maintenance-battery-fleet-section")||customElements.define("maintenance-battery-fleet-section",Ve);var ns=5;function Ws(l,p){let t=[];for(let e=0;e<p;e++)t.push(Tt(l,e));return t}function Ks(l){if(!l||l.length===0)return null;let p=l.map(t=>Rt(t)).filter(t=>t!==null&&t>=0);return p.length===0?null:p.reduce((t,e)=>t+e,0)/p.length}function Gs(l){let{windowStart:p,windowEnd:t,task:e,entryId:i,objectName:a}=l,r=[],c=(g,m)=>({date:g,entry_id:i,task_id:e.id,task_name:e.name,object_name:a,status:m&&(e.status==="overdue"||e.status==="triggered")?"ok":e.status,days_until_due:m?null:e.days_until_due??null,projected:m,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:Ks(e.history),adaptive_enabled:!!e.adaptive_config?.enabled,prediction_confidence:e.threshold_prediction_confidence??null}),n=Math.max(1,Math.round(Ne(e.interval_days,e.interval_unit)));if(e.status==="overdue"||e.status==="triggered"){if(r.push(c(p,!1)),e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=Tt(p,n),m=1;for(;g<=t&&m<ns;)r.push(c(g,!0)),m++,g=Tt(g,n)}return r}let u=e.next_due;if(typeof u!="string"||!u)return r;let d=u.slice(0,10);if(!/^\d{4}-\d{2}-\d{2}$/.test(d))return r;if(d>=p&&d<=t)r.push(c(d,!1));else if(d>t)return r;if(e.schedule_type==="time_based"&&e.interval_days&&e.interval_days>0){let g=Tt(d,n),m=r.length;for(;g<=t&&m<ns;)g>=p&&(r.push(c(g,!0)),m++),g=Tt(g,n)}return r}function ls(l,p,t,e=null){let i=Ws(p,t),a=i[0],r=i[i.length-1],c=[];for(let u of l){let d=u.object?.name||"",g=u.entry_id,m=u.tasks||[];for(let v of m){if(e&&v.responsible_user_id!==e||v.enabled===!1)continue;let y=Gs({windowStart:a,windowEnd:r,task:v,entryId:g,objectName:d});c.push(...y)}}let n=new Map;for(let u of i)n.set(u,[]);for(let u of c){let d=n.get(u.date);d&&d.push(u)}for(let[,u]of n)u.sort((d,g)=>{let m=Mt(d.status),v=Mt(g.status);if(m!==v)return m-v;if(d.projected!==g.projected)return d.projected?1:-1;let y=d.object_name.localeCompare(g.object_name);return y!==0?y:d.task_name.localeCompare(g.task_name)});return i.map(u=>({date:u,events:n.get(u)??[]}))}var Ys={completed:"ok",reset:"ok",skipped:"due_soon",missed:"overdue",triggered:"triggered",trigger_replaced:"triggered",trigger_removed:"ok"};function je(l,p){return`${l}/${p}`}function cs(l,p,t){let e=ds(p,t)[0],i=[];for(let a of l)for(let r of a.tasks||[]){let c=r.history||[],n=r.history_count??c.length;if(n<=c.length)continue;let u=c.map(m=>Ce(m?.timestamp)).filter(m=>!!m),d=u.length?u.reduce((m,v)=>m<v?m:v):"";if(d&&d<e)continue;let g=je(a.entry_id,r.id);i.push({entryId:a.entry_id,taskId:r.id,key:g,sig:`${g}:${n}:${Qs(JSON.stringify(c))}`})}return i}function Qs(l){let p=2166136261;for(let t=0;t<l.length;t++)p^=l.charCodeAt(t),p=Math.imul(p,16777619);return(p>>>0).toString(36)}function ds(l,p){let t=[];for(let e=p-1;e>=0;e--)t.push(Tt(l,-e));return t}function ps(l,p,t,e=null,i={}){let a=ds(p,t),r=a[0],c=a[a.length-1],n=new Map;for(let d of a)n.set(d,[]);for(let d of l){let g=d.object?.name||"",m=d.entry_id,v=d.tasks||[];for(let y of v){if(e&&y.responsible_user_id!==e)continue;let E=i[je(m,y.id)]??(y.history||[]);for(let w of E){if(typeof w?.timestamp!="string")continue;let j=Ce(w.timestamp);if(!j||j<r||j>c)continue;let x=n.get(j);if(!x)continue;let M=w.type??"completed";x.push({date:j,entry_id:m,task_id:y.id,task_name:y.name,object_name:g,status:Ys[M]??"ok",days_until_due:null,projected:!1,schedule_type:y.schedule_type,interval_days:y.interval_days??null,responsible_user_id:y.responsible_user_id??null,avg_cost:Rt(w),adaptive_enabled:!!y.adaptive_config?.enabled,prediction_confidence:null,history_timestamp:w.timestamp,history_type:M,history_cost:Rt(w),history_notes:typeof w.notes=="string"?w.notes:null,history_duration:typeof w.duration=="number"?w.duration:null})}}}let u={completed:0,reset:1,skipped:2,triggered:3,trigger_replaced:4};for(let[,d]of n)d.sort((g,m)=>{let v=u[g.history_type??""]??99,y=u[m.history_type??""]??99;if(v!==y)return v-y;let E=g.object_name.localeCompare(m.object_name);return E!==0?E:g.task_name.localeCompare(m.task_name)});return a.map(d=>({date:d,events:n.get(d)??[]}))}var hs=B`
.cal-controls {
display: flex;
gap: 12px;
@@ -4130,7 +4130,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
.cal-pill-day { font-size: 17px; }
.cal-user-filter { margin-left: 0; width: 100%; }
}
`;function ps(l){let p=window;p.customCards=p.customCards||[],p.customCards.some(t=>t.type===l.type)||p.customCards.push(l)}function hs(l,p,t=e=>import(e)){let e=window,i;try{let d=new URL(p);i=d.origin+d.pathname}catch{return}let a=`__msCardHeal:${l[0]}:${i}`;if(e[a])return;e[a]=!0;let r=0,c=0,n=!1,u=()=>{if(r+=1,l.some(g=>!customElements.get(g))&&c<3&&!n){c+=1,n=!0;try{let g=new URL(p);g.searchParams.set("heal",`${Date.now()}`),t(g.href).catch(()=>{}).finally(()=>{n=!1})}catch{return}}r<20&&window.setTimeout(u,r<8?500:2e3)};window.setTimeout(u,250)}var ut=class extends N{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._pastHistory={};this._pastHistorySig="";this._pastSeq=0;this._dataLoaded=!1;this._lastConnection=null;this._onHistorySaved=t=>{let e=t.detail;!e?.entry_id||!e.task_id||!(je(e.entry_id,e.task_id)in this._pastHistory)||(this._pastHistorySig="",this._loadPastHistories())}}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},this._windowDays=t.window_days&&[7,14,30,365].includes(t.window_days)?t.window_days:30,this._pastDays=t.past_days&&[30,90].includes(t.past_days)?t.past_days:0,this._userFilter=typeof t.user_filter=="string"?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:[]}else this._objectFilter="",this._configuredObjects=[]}getCardSize(){return 6}get _lang(){return K(this.hass)}connectedCallback(){super.connectedCallback(),window.addEventListener("history-entry-saved",this._onHistorySaved)}disconnectedCallback(){if(super.disconnectedCallback(),window.removeEventListener("history-entry-saved",this._onHistorySaved),this._unsub){try{this._unsub()}catch{}this._unsub=null}this._dataLoaded=!1,this._lastConnection=null}updated(t){if(super.updated(t),Bt(this,t),this.hass&&this._pastDays>0&&(t.has("_objects")||t.has("_pastDays"))&&this._loadPastHistories(),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,Kt(this._stats.budget)}catch{}}async _loadPastHistories(){let t=ns(this._objects,xt(),this._pastDays||30),e=t.map(r=>r.sig).join("|");if(e===this._pastHistorySig)return;this._pastHistorySig=e;let i=++this._pastSeq,a=await Promise.all(t.map(async r=>{try{let c=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history",entry_id:r.entryId,task_id:r.taskId});return[r.key,c.history??[]]}catch{return null}}));i===this._pastSeq&&(this._pastHistory=Object.fromEntries(a.filter(r=>r!==null)))}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._openHistoryEntry(t);return}this._openTask(t)}_openTask(t){Yi(t.entry_id,t.task_id)||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}))}async _openHistoryEntry(t){try{let e=await _e(this.hass);if(!Nt(this.hass?.user,e.access)){this._openTask(t);return}}catch{}try{let e=await Pi(this.hass,t.entry_id,t.task_id,t.history_timestamp);if(!e||Gi(e))return}catch{}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}))}render(){if(!this.hass)return h;let t=this._lang,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.title,r=null;this._userFilter&&(r=this._userFilter==="current_user"?this.hass?.user?.id??null:this._userFilter);let c=b=>{let D=b.toLowerCase();return this._objects.find(pt=>pt.entry_id===b||pt.object.name.toLowerCase()===D)?.entry_id??null},n=new Set(this._configuredObjects.map(c).filter(b=>b!==null)),u=n.size?this._objects.filter(b=>n.has(b.entry_id)):this Line truncated
`;function us(l){let p=window;p.customCards=p.customCards||[],p.customCards.some(t=>t.type===l.type)||p.customCards.push(l)}function gs(l,p,t=e=>import(e)){let e=window,i;try{let d=new URL(p);i=d.origin+d.pathname}catch{return}let a=`__msCardHeal:${l[0]}:${i}`;if(e[a])return;e[a]=!0;let r=0,c=0,n=!1,u=()=>{if(r+=1,l.some(g=>!customElements.get(g))&&c<3&&!n){c+=1,n=!0;try{let g=new URL(p);g.searchParams.set("heal",`${Date.now()}`),t(g.href).catch(()=>{}).finally(()=>{n=!1})}catch{return}}r<20&&window.setTimeout(u,r<8?500:2e3)};window.setTimeout(u,250)}var ut=class extends N{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._pastHistory={};this._pastHistorySig="";this._pastSeq=0;this._dataLoaded=!1;this._lastConnection=null;this._onHistorySaved=t=>{let e=t.detail;!e?.entry_id||!e.task_id||!(je(e.entry_id,e.task_id)in this._pastHistory)||(this._pastHistorySig="",this._loadPastHistories())}}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},this._windowDays=t.window_days&&[7,14,30,365].includes(t.window_days)?t.window_days:30,this._pastDays=t.past_days&&[30,90].includes(t.past_days)?t.past_days:0,this._userFilter=typeof t.user_filter=="string"?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:[]}else this._objectFilter="",this._configuredObjects=[]}getCardSize(){return 6}get _lang(){return K(this.hass)}connectedCallback(){super.connectedCallback(),window.addEventListener("history-entry-saved",this._onHistorySaved)}disconnectedCallback(){if(super.disconnectedCallback(),window.removeEventListener("history-entry-saved",this._onHistorySaved),this._unsub){try{this._unsub()}catch{}this._unsub=null}this._dataLoaded=!1,this._lastConnection=null}updated(t){if(super.updated(t),Bt(this,t),this.hass&&this._pastDays>0&&(t.has("_objects")||t.has("_pastDays"))&&this._loadPastHistories(),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,Kt(this._stats.budget)}catch{}}async _loadPastHistories(){let t=cs(this._objects,yt(),this._pastDays||30),e=t.map(r=>r.sig).join("|");if(e===this._pastHistorySig)return;this._pastHistorySig=e;let i=++this._pastSeq,a=await Promise.all(t.map(async r=>{try{let c=await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/history",entry_id:r.entryId,task_id:r.taskId});return[r.key,c.history??[]]}catch{return null}}));i===this._pastSeq&&(this._pastHistory=Object.fromEntries(a.filter(r=>r!==null)))}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._openHistoryEntry(t);return}this._openTask(t)}_openTask(t){Ji(t.entry_id,t.task_id)||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}))}async _openHistoryEntry(t){try{let e=await _e(this.hass);if(!Nt(this.hass?.user,e.access)){this._openTask(t);return}}catch{}try{let e=await Hi(this.hass,t.entry_id,t.task_id,t.history_timestamp);if(!e||Qi(e))return}catch{}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}))}render(){if(!this.hass)return h;let t=this._lang,e=this._config.show_window_chips!==!1,i=this._config.show_user_filter!==!1,a=this._config.title,r=null;this._userFilter&&(r=this._userFilter==="current_user"?this.hass?.user?.id??null:this._userFilter);let c=b=>{let D=b.toLowerCase();return this._objects.find(pt=>pt.entry_id===b||pt.object.name.toLowerCase()===D)?.entry_id??null},n=new Set(this._configuredObjects.map(c).filter(b=>b!==null)),u=n.size?this._objects.filter(b=>n.has(b.entry_id)):this Line truncated
title="${s("cal_source_sensor",t)}" icon="mdi:trending-up"></ha-icon>`:o`<ha-icon class="cal-event-icon cal-source-time"
title="${b.adaptive_enabled?s("cal_source_time_adaptive",t):s("cal_source_time",t)}"
icon="${b.adaptive_enabled?"mdi:clock-time-four-outline":"mdi:clock-outline"}"></ha-icon>`,I=z&&b.prediction_confidence&&b.status!=="triggered"&&!b.projected?o`<span class="cal-event-prediction cal-conf-${b.prediction_confidence}">
@@ -4145,9 +4145,9 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${I}
${T}
</div>
${b.avg_cost!=null&&b.avg_cost!==0?o`<span class="cal-event-cost">${F(b.avg_cost,W,t)}</span>`:h}
${b.avg_cost!=null&&b.avg_cost!==0?o`<span class="cal-event-cost">${U(b.avg_cost,W,t)}</span>`:h}
</div>
`},M=b=>{let[D,at,pt]=b.date.split("-").map(Number),T=new Date(D,at-1,pt),z=b.date===v,H=ni(T,t,"short"),I=li(T,t,"long");return o`
`},M=b=>{let[D,at,pt]=b.date.split("-").map(Number),T=new Date(D,at-1,pt),z=b.date===v,H=ci(T,t,"short"),I=di(T,t,"long");return o`
<div class="cal-day-row">
<div class="cal-day-pill ${z?"cal-today":""}">
<span class="cal-pill-weekday">${H}</span>
@@ -4206,10 +4206,10 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${j.length===0&&w?o`<div class="cal-empty">${s("cal_no_events",t)}</div>`:j.map(M)}
</div>
</ha-card>
`}};ut.styles=[ne,ds,B`
`}};ut.styles=[ne,hs,B`
:host { display: block; }
ha-card { padding: 0; overflow: hidden; }
`],_([R({attribute:!1})],ut.prototype,"hass",2),_([f()],ut.prototype,"_config",2),_([f()],ut.prototype,"_objects",2),_([f()],ut.prototype,"_stats",2),_([f()],ut.prototype,"_windowDays",2),_([f()],ut.prototype,"_pastDays",2),_([f()],ut.prototype,"_userFilter",2),_([f()],ut.prototype,"_objectFilter",2),_([f()],ut.prototype,"_unsub",2),_([f()],ut.prototype,"_pastHistory",2);var Ys=[{value:7,key:"cal_editor_window_week"},{value:14,key:"cal_editor_window_fortnight"},{value:30,key:"cal_editor_window_month"},{value:365,key:"cal_editor_window_year"}],Qs=[{value:30,key:"cal_editor_window_past_30"},{value:90,key:"cal_editor_window_past_90"}],Vt=class extends N{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"}}get _lang(){return K(this.hass)}setConfig(t){this._config={...t}}updated(){let t=this._lang;t&&!ei(t)&&ot(t).then(()=>this.requestUpdate())}_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._emit(i)}_windowChanged(t){let e={...this._config};t.startsWith("past-")?(e.past_days=Number(t.slice(5)),delete e.window_days):(e.window_days=Number(t),delete e.past_days),this._emit(e)}_emit(t){this._config=t,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:t},bubbles:!0,composed:!0}))}render(){let t=this._lang,e=this._config.past_days?`past-${this._config.past_days}`:`${this._config.window_days??30}`,i=this._config.show_window_chips!==!1,a=this._config.show_user_filter!==!1,r=this._config.user_filter??"",c=this._config.title??"";return o`
`],_([R({attribute:!1})],ut.prototype,"hass",2),_([f()],ut.prototype,"_config",2),_([f()],ut.prototype,"_objects",2),_([f()],ut.prototype,"_stats",2),_([f()],ut.prototype,"_windowDays",2),_([f()],ut.prototype,"_pastDays",2),_([f()],ut.prototype,"_userFilter",2),_([f()],ut.prototype,"_objectFilter",2),_([f()],ut.prototype,"_unsub",2),_([f()],ut.prototype,"_pastHistory",2);var Js=[{value:7,key:"cal_editor_window_week"},{value:14,key:"cal_editor_window_fortnight"},{value:30,key:"cal_editor_window_month"},{value:365,key:"cal_editor_window_year"}],Xs=[{value:30,key:"cal_editor_window_past_30"},{value:90,key:"cal_editor_window_past_90"}],Vt=class extends N{constructor(){super(...arguments);this._config={type:"custom:maintenance-supporter-calendar-card"}}get _lang(){return K(this.hass)}setConfig(t){this._config={...t}}updated(){let t=this._lang;t&&!ii(t)&&ot(t).then(()=>this.requestUpdate())}_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._emit(i)}_windowChanged(t){let e={...this._config};t.startsWith("past-")?(e.past_days=Number(t.slice(5)),delete e.window_days):(e.window_days=Number(t),delete e.past_days),this._emit(e)}_emit(t){this._config=t,this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:t},bubbles:!0,composed:!0}))}render(){let t=this._lang,e=this._config.past_days?`past-${this._config.past_days}`:`${this._config.window_days??30}`,i=this._config.show_window_chips!==!1,a=this._config.show_user_filter!==!1,r=this._config.user_filter??"",c=this._config.title??"";return o`
<div class="editor">
<div class="row">
<label for="title">${s("card_title",t)}</label>
@@ -4226,8 +4226,8 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
id="window"
@change=${n=>this._windowChanged(n.target.value)}
>
${Ys.map(n=>o`<option value="${n.value}" ?selected=${`${n.value}`===e}>${s(n.key,t)}</option>`)}
${Qs.map(n=>o`<option value="past-${n.value}" ?selected=${`past-${n.value}`===e}>${s(n.key,t)}</option>`)}
${Js.map(n=>o`<option value="${n.value}" ?selected=${`${n.value}`===e}>${s(n.key,t)}</option>`)}
${Xs.map(n=>o`<option value="past-${n.value}" ?selected=${`past-${n.value}`===e}>${s(n.key,t)}</option>`)}
</select>
</div>
<div class="row toggle">
@@ -4296,7 +4296,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
font-size: 12px;
color: var(--secondary-text-color, #666);
}
`,_([R({attribute:!1})],Vt.prototype,"hass",2),_([f()],Vt.prototype,"_config",2);customElements.get("maintenance-supporter-calendar-card")||customElements.define("maintenance-supporter-calendar-card",ut);customElements.get("maintenance-supporter-calendar-card-editor")||customElements.define("maintenance-supporter-calendar-card-editor",Vt);hs(["maintenance-supporter-calendar-card"],import.meta.url);ps({type:"maintenance-supporter-calendar-card",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 _t=class extends N{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;this._searchSeq=0}get _lang(){return K(this.hass)}updated(t){super.updated(t),t.has("hass")&&this.hass&&!this._initiallyLoaded&&(this._initiallyLoaded=!0,this._load(),ot(this._lang).then(()=>this.requestUpdate()))}async _load(){let t=await P(this,{type:"maintenance_supporter/documents/storage"},{busy:e=>{this._busy=e},onError:e=>{this._error=e}});this._loaded=!0,t!==void 0&&(this._summary=t,this._error="")}_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(),e=++this._searchSeq;if(!t){this._results=[];return}let i="",a=await P(this,{type:"maintenance_supporter/documents/search",query:t},{onError:r=>{i=r}});if(e===this._searchSeq){if(a===void 0){this._error=i,this._results=[];return}this._results=a?.results||[]}}async _openResult(t){if(t.kind==="weblink"){st(t.url)&&window.open(t.url,"_blank","noopener");return}await P(this,()=>Et(this.hass,t.id),{onError:e=>{this._error=e}})}_renderResult(t,e){return o`
`,_([R({attribute:!1})],Vt.prototype,"hass",2),_([f()],Vt.prototype,"_config",2);customElements.get("maintenance-supporter-calendar-card")||customElements.define("maintenance-supporter-calendar-card",ut);customElements.get("maintenance-supporter-calendar-card-editor")||customElements.define("maintenance-supporter-calendar-card-editor",Vt);gs(["maintenance-supporter-calendar-card"],import.meta.url);us({type:"maintenance-supporter-calendar-card",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 _t=class extends N{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;this._searchSeq=0}get _lang(){return K(this.hass)}updated(t){super.updated(t),t.has("hass")&&this.hass&&!this._initiallyLoaded&&(this._initiallyLoaded=!0,this._load(),ot(this._lang).then(()=>this.requestUpdate()))}async _load(){let t=await P(this,{type:"maintenance_supporter/documents/storage"},{busy:e=>{this._busy=e},onError:e=>{this._error=e}});this._loaded=!0,t!==void 0&&(this._summary=t,this._error="")}_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(),e=++this._searchSeq;if(!t){this._results=[];return}let i="",a=await P(this,{type:"maintenance_supporter/documents/search",query:t},{onError:r=>{i=r}});if(e===this._searchSeq){if(a===void 0){this._error=i,this._results=[];return}this._results=a?.results||[]}}async _openResult(t){if(t.kind==="weblink"){st(t.url)&&window.open(t.url,"_blank","noopener");return}await P(this,()=>Et(this.hass,t.id),{onError:e=>{this._error=e}})}_renderResult(t,e){return o`
<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">
@@ -4468,14 +4468,14 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
.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; }
`,_([R({attribute:!1})],_t.prototype,"hass",2),_([R({attribute:!1})],_t.prototype,"objects",2),_([f()],_t.prototype,"_summary",2),_([f()],_t.prototype,"_loaded",2),_([f()],_t.prototype,"_busy",2),_([f()],_t.prototype,"_error",2),_([f()],_t.prototype,"_query",2),_([f()],_t.prototype,"_results",2),_([f()],_t.prototype,"_expanded",2);customElements.get("maintenance-storage-section-card")||customElements.define("maintenance-storage-section-card",_t);var Js=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"],bt=class extends N{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();t!==null&&await this._send(t)!==void 0&&(this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved")))};this._clearAll=async()=>{await this._send({})!==void 0&&(this._values=new Array(12).fill(""),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved")))}}get _lang(){return K(this.hass)}open(t,e,i){if(this._entryId=t,this._taskId=e,this._values=new Array(12).fill(""),i)for(let[a,r]of Object.entries(i)){let c=parseInt(a,10);c>=1&&c<=12&&typeof r=="number"&&(this._values[c-1]=r.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<Xt[0]||a>Xt[1])return this._error=s("seasonal_override_range",this._lang),null;t[e+1]=a}return t}_send(t){return this._error="",P(this,{type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:t},{busy:e=>{this._loading=e},fallbackKey:"save_error",onError:e=>{this._error=e}})}render(){if(!this._open)return o``;let t=this._lang;return o`
`,_([R({attribute:!1})],_t.prototype,"hass",2),_([R({attribute:!1})],_t.prototype,"objects",2),_([f()],_t.prototype,"_summary",2),_([f()],_t.prototype,"_loaded",2),_([f()],_t.prototype,"_busy",2),_([f()],_t.prototype,"_error",2),_([f()],_t.prototype,"_query",2),_([f()],_t.prototype,"_results",2),_([f()],_t.prototype,"_expanded",2);customElements.get("maintenance-storage-section-card")||customElements.define("maintenance-storage-section-card",_t);var Zs=["month_jan","month_feb","month_mar","month_apr","month_may","month_jun","month_jul","month_aug","month_sep","month_oct","month_nov","month_dec"],vt=class extends N{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();t!==null&&await this._send(t)!==void 0&&(this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved")))};this._clearAll=async()=>{await this._send({})!==void 0&&(this._values=new Array(12).fill(""),this._open=!1,this.dispatchEvent(new CustomEvent("overrides-saved")))}}get _lang(){return K(this.hass)}open(t,e,i){if(this._entryId=t,this._taskId=e,this._values=new Array(12).fill(""),i)for(let[a,r]of Object.entries(i)){let c=parseInt(a,10);c>=1&&c<=12&&typeof r=="number"&&(this._values[c-1]=r.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<Xt[0]||a>Xt[1])return this._error=s("seasonal_override_range",this._lang),null;t[e+1]=a}return t}_send(t){return this._error="",P(this,{type:"maintenance_supporter/task/seasonal_overrides",entry_id:this._entryId,task_id:this._taskId,overrides:t},{busy:e=>{this._loading=e},fallbackKey:"save_error",onError:e=>{this._error=e}})}render(){if(!this._open)return o``;let t=this._lang;return o`
<ha-dialog open @closed=${this._close}>
<div class="dialog-title">${s("seasonal_overrides_title",t)}</div>
<div class="content">
<p class="hint">${s("seasonal_overrides_hint",t)}</p>
${this._error?o`<div class="error">${this._error}</div>`:h}
<div class="months">
${Js.map((e,i)=>o`
${Zs.map((e,i)=>o`
<label class="month">
<span class="mn">${s(e,t)}</span>
<input type="number" step="0.1" min=${Xt[0]} max=${Xt[1]}
@@ -4499,7 +4499,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</ha-button>
</div>
</ha-dialog>
`}};bt.styles=B`
`}};vt.styles=B`
.dialog-title { font-size: 18px; font-weight: 500; padding-bottom: 12px; }
.content {
min-width: 320px;
@@ -4545,7 +4545,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
padding-top: 16px;
}
.spacer { flex: 1; }
`,_([R({attribute:!1})],bt.prototype,"hass",2),_([f()],bt.prototype,"_open",2),_([f()],bt.prototype,"_loading",2),_([f()],bt.prototype,"_error",2),_([f()],bt.prototype,"_entryId",2),_([f()],bt.prototype,"_taskId",2),_([f()],bt.prototype,"_values",2);customElements.get("maintenance-seasonal-overrides-dialog")||customElements.define("maintenance-seasonal-overrides-dialog",bt);var mt=class extends N{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._error="";let e=this._buildTaskRefs();await P(this,this._groupId?{type:"maintenance_supporter/group/update",group_id:this._groupId,name:t,description:this._description,task_refs:e}:{type:"maintenance_supporter/group/create",name:t,description:this._description,task_refs:e},{busy:a=>{this._loading=a},fallbackKey:"save_error",onError:a=>{this._error=a}})!==void 0&&(this._open=!1,this.dispatchEvent(new CustomEvent("group-saved")))}}get _lang(){return K(this.hass)}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 o``;let t=this._lang,e=this._groupId?s("edit_group",t):s("new_group",t);return o`
`,_([R({attribute:!1})],vt.prototype,"hass",2),_([f()],vt.prototype,"_open",2),_([f()],vt.prototype,"_loading",2),_([f()],vt.prototype,"_error",2),_([f()],vt.prototype,"_entryId",2),_([f()],vt.prototype,"_taskId",2),_([f()],vt.prototype,"_values",2);customElements.get("maintenance-seasonal-overrides-dialog")||customElements.define("maintenance-seasonal-overrides-dialog",vt);var mt=class extends N{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._error="";let e=this._buildTaskRefs();await P(this,this._groupId?{type:"maintenance_supporter/group/update",group_id:this._groupId,name:t,description:this._description,task_refs:e}:{type:"maintenance_supporter/group/create",name:t,description:this._description,task_refs:e},{busy:a=>{this._loading=a},fallbackKey:"save_error",onError:a=>{this._error=a}})!==void 0&&(this._open=!1,this.dispatchEvent(new CustomEvent("group-saved")))}}get _lang(){return K(this.hass)}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 o``;let t=this._lang,e=this._groupId?s("edit_group",t):s("new_group",t);return o`
<ha-dialog open @closed=${this._close}>
<div class="dialog-title">${e}</div>
<div class="content">
@@ -4786,29 +4786,29 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
gap: 8px;
padding-top: 8px;
}
`,_([R({attribute:!1})],$t.prototype,"hass",2),_([f()],$t.prototype,"_open",2),_([f()],$t.prototype,"_busy",2),_([f()],$t.prototype,"_error",2),_([f()],$t.prototype,"_name",2),_([f()],$t.prototype,"_views",2);customElements.get("maintenance-saved-views-dialog")||customElements.define("maintenance-saved-views-dialog",$t);var Xs=60,Zs=20,us=30,ta={approaching:"\u2197",stable:"\u2192",easing:"\u2198"};function We(l,p){let t=l.trigger_config,e=gt(t);if(!t||!e||l.battery_fleet_task)return null;let i,a=t.type||"threshold";if(a==="threshold")if(t.trigger_above!=null)i=1;else if(t.trigger_below!=null)i=-1;else return null;else if(a==="counter"||a==="runtime"||a==="state_change")i=1;else return null;let r=p.get(e)||[],c=a==="runtime"||a==="state_change",n=r.length>=2?r.map(E=>({ts:E.ts,val:E.val})):c?[]:(l.history||[]).filter(E=>E.trigger_value!=null).map(E=>({ts:ft(E.timestamp),val:E.trigger_value}));if(l.trigger_current_value!=null&&(n=[...n,{ts:Date.now(),val:l.trigger_current_value}]),n.length<2)return null;n.sort((E,w)=>E.ts-w.ts);let u=n.map(E=>E.val),d=Math.max(...u)-Math.min(...u),g=u[u.length-1]-u[0],m=t.trigger_delta_mode&&l.trigger_baseline_value!=null&&t.trigger_target_value!=null?l.trigger_baseline_value+t.trigger_target_value:t.trigger_target_value,v=a==="threshold"?t.trigger_above??t.trigger_below:a==="counter"?m:a==="runtime"?t.trigger_runtime_hours:t.trigger_target_changes,y=typeof v=="number"?Math.max(Math.abs(v-u[0]),d):d;return y===0||Math.abs(g)<y*(typeof v=="number"?.05:.15)?"stable":Math.sign(g)===i?"approaching":"easing"}function Ke(l){return l>0?Math.ceil(l):Math.trunc(l)||0}function Ge(l,p){let t=l.trigger_config??null;if(!t)return h;let e=t.type||"threshold",i=l.trigger_entity_info?.unit_of_measurement??"",a=0,r="";if(e==="threshold"){let u=l.trigger_current_value??null;if(u==null)return h;let d=t.trigger_above,g=t.trigger_below;if(d!=null&&g!=null){let m=(d+g)/2,v=Math.abs(d-g)/2||1;a=Math.min(100,Math.max(0,Math.abs(u-m)/v*100));let y=Math.abs(u-d)<=Math.abs(u-g)?d:g;r=`${Y(u,p?.lang,1)} / ${Y(y,p?.lang)} ${i}`}else if(d!=null){let m=l.trigger_entity_info?.min,v=d>0?0:m!=null&&m<d?m:d<0?2*d:-100,y=d-v||1;a=Math.min(100,Math.max(0,(u-v)/y*100)),r=`${Y(u,p?.lang,1)} / ${Y(d,p?.lang)} ${i}`}else if(g!=null){let m=l.trigger_entity_info?.max,v=m!=null&&m>g?m:g>0?g*2:g<0?0:100,y=v-g||1;a=Math.min(100,Math.max(0,(v-u)/y*100)),r=`${Y(u,p?.lang,1)} / ${Y(g,p?.lang)} ${i}`}else if(t.trigger_equals!=null||t.trigger_not_equals!=null){let m=t.trigger_equals!=null?`= ${t.trigger_equals}`:`\u2260 ${t.trigger_not_equals}`;r=`${Y(u,p?.lang,1)} (${m}${i?` ${i}`:""})`,a=l.trigger_active?100:0}else return h}else if(e==="counter"){let u=t.trigger_target_value||1,d;if(t.trigger_delta_mode?(d=l.trigger_current_delta??null,d==null&&l.trigger_baseline_value!=null&&l.trigger_current_value!=null&&(d=l.trigger_current_value-l.trigger_baseline_value)):d=l.trigger_current_value??null,d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,1)} / ${Y(u,p?.lang)} ${i}`}else if(e==="state_change"){let u=t.trigger_target_changes||1,d=l.trigger_current_value??null;if(d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,0)} / ${Y(u,p?.lang,0)}`}else if(e==="runtime"){let u=t.trigger_runtime_hours||100,d=l.trigger_current_value??null;if(d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,1)}h / ${Y(u,p?.lang)}h`}else if(e==="due_date"){let u=l.trigger_current_value??null;if(u==null)return h;let d=t.trigger_days_before??0;a=u<=d?100:Math.max(0,100-(u-d)/30*100),r=vt(Ke(u),p?.lang)}else if(e==="compound"){let u=t.compound_logic||t.operator||"AND",d=t.conditions?.length||0;r=`${u} (${d})`,a=l.trigger_active?100:0}else return h;if(l.battery_fleet_task&&e==="threshold"&&l.trigger_current_value!=null){let u=Math.round(l.trigger_current_value),d=t.trigger_above??0;a=u>d?100:d>0?Math.max(0,u/(d+1)*100):0,r=s("battery_fleet_progress",p?.lang??"en").replace("{n}",Y(u,p?.lang,0))}let c=a>=100,n=a>90?"var(--error-color, #f44336)":a>70?"var(--warning-color, #ff9800)":"var(--primary-color)";return o`
`,_([R({attribute:!1})],$t.prototype,"hass",2),_([f()],$t.prototype,"_open",2),_([f()],$t.prototype,"_busy",2),_([f()],$t.prototype,"_error",2),_([f()],$t.prototype,"_name",2),_([f()],$t.prototype,"_views",2);customElements.get("maintenance-saved-views-dialog")||customElements.define("maintenance-saved-views-dialog",$t);var ta=60,ea=20,_s=30,ia={approaching:"\u2197",stable:"\u2192",easing:"\u2198"};function We(l,p){let t=l.trigger_config,e=gt(t);if(!t||!e||l.battery_fleet_task)return null;let i,a=t.type||"threshold";if(a==="threshold")if(t.trigger_above!=null)i=1;else if(t.trigger_below!=null)i=-1;else return null;else if(a==="counter"||a==="runtime"||a==="state_change")i=1;else return null;let r=p.get(e)||[],c=a==="runtime"||a==="state_change",n=r.length>=2?r.map(E=>({ts:E.ts,val:E.val})):c?[]:(l.history||[]).filter(E=>E.trigger_value!=null).map(E=>({ts:ft(E.timestamp),val:E.trigger_value}));if(l.trigger_current_value!=null&&(n=[...n,{ts:Date.now(),val:l.trigger_current_value}]),n.length<2)return null;n.sort((E,w)=>E.ts-w.ts);let u=n.map(E=>E.val),d=Math.max(...u)-Math.min(...u),g=u[u.length-1]-u[0],m=t.trigger_delta_mode&&l.trigger_baseline_value!=null&&t.trigger_target_value!=null?l.trigger_baseline_value+t.trigger_target_value:t.trigger_target_value,v=a==="threshold"?t.trigger_above??t.trigger_below:a==="counter"?m:a==="runtime"?t.trigger_runtime_hours:t.trigger_target_changes,y=typeof v=="number"?Math.max(Math.abs(v-u[0]),d):d;return y===0||Math.abs(g)<y*(typeof v=="number"?.05:.15)?"stable":Math.sign(g)===i?"approaching":"easing"}function Ke(l){return l>0?Math.ceil(l):Math.trunc(l)||0}function Ge(l,p){let t=l.trigger_config??null;if(!t)return h;let e=t.type||"threshold",i=l.trigger_entity_info?.unit_of_measurement??"",a=0,r="";if(e==="threshold"){let u=l.trigger_current_value??null;if(u==null)return h;let d=t.trigger_above,g=t.trigger_below;if(d!=null&&g!=null){let m=(d+g)/2,v=Math.abs(d-g)/2||1;a=Math.min(100,Math.max(0,Math.abs(u-m)/v*100));let y=Math.abs(u-d)<=Math.abs(u-g)?d:g;r=`${Y(u,p?.lang,1)} / ${Y(y,p?.lang)} ${i}`}else if(d!=null){let m=l.trigger_entity_info?.min,v=d>0?0:m!=null&&m<d?m:d<0?2*d:-100,y=d-v||1;a=Math.min(100,Math.max(0,(u-v)/y*100)),r=`${Y(u,p?.lang,1)} / ${Y(d,p?.lang)} ${i}`}else if(g!=null){let m=l.trigger_entity_info?.max,v=m!=null&&m>g?m:g>0?g*2:g<0?0:100,y=v-g||1;a=Math.min(100,Math.max(0,(v-u)/y*100)),r=`${Y(u,p?.lang,1)} / ${Y(g,p?.lang)} ${i}`}else if(t.trigger_equals!=null||t.trigger_not_equals!=null){let m=t.trigger_equals!=null?`= ${t.trigger_equals}`:`\u2260 ${t.trigger_not_equals}`;r=`${Y(u,p?.lang,1)} (${m}${i?` ${i}`:""})`,a=l.trigger_active?100:0}else return h}else if(e==="counter"){let u=t.trigger_target_value||1,d;if(t.trigger_delta_mode?(d=l.trigger_current_delta??null,d==null&&l.trigger_baseline_value!=null&&l.trigger_current_value!=null&&(d=l.trigger_current_value-l.trigger_baseline_value)):d=l.trigger_current_value??null,d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,1)} / ${Y(u,p?.lang)} ${i}`}else if(e==="state_change"){let u=t.trigger_target_changes||1,d=l.trigger_current_value??null;if(d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,0)} / ${Y(u,p?.lang,0)}`}else if(e==="runtime"){let u=t.trigger_runtime_hours||100,d=l.trigger_current_value??null;if(d==null)return h;a=Math.min(100,Math.max(0,d/u*100)),r=`${Y(d,p?.lang,1)}h / ${Y(u,p?.lang)}h`}else if(e==="due_date"){let u=l.trigger_current_value??null;if(u==null)return h;let d=t.trigger_days_before??0;a=u<=d?100:Math.max(0,100-(u-d)/30*100),r=xt(Ke(u),p?.lang)}else if(e==="compound"){let u=t.compound_logic||t.operator||"AND",d=t.conditions?.length||0;r=`${u} (${d})`,a=l.trigger_active?100:0}else return h;if(l.battery_fleet_task&&e==="threshold"&&l.trigger_current_value!=null){let u=Math.round(l.trigger_current_value),d=t.trigger_above??0;a=u>d?100:d>0?Math.max(0,u/(d+1)*100):0,r=s("battery_fleet_progress",p?.lang??"en").replace("{n}",Y(u,p?.lang,0))}let c=a>=100,n=a>90?"var(--error-color, #f44336)":a>70?"var(--warning-color, #ff9800)":"var(--primary-color)";return o`
<div class="trigger-progress">
<div class="trigger-progress-bar">
<div class="trigger-progress-fill${c?" overflow":""}" style="width:${a}%;background:${n}"></div>
</div>
<span class="trigger-progress-label">${r}${p?.trend?o` <i class="trend-arrow trend-${p.trend}" title="${s(`trend_${p.trend}`,p.lang??"en")}" aria-label="${s(`trend_${p.trend}`,p.lang??"en")}">${ta[p.trend]}</i>`:h}</span>
<span class="trigger-progress-label">${r}${p?.trend?o` <i class="trend-arrow trend-${p.trend}" title="${s(`trend_${p.trend}`,p.lang??"en")}" aria-label="${s(`trend_${p.trend}`,p.lang??"en")}">${ia[p.trend]}</i>`:h}</span>
</div>
`}function Ye(l,p,t){let e=gt(l.trigger_config);if(!e||l.battery_fleet_task)return h;let i=p.get(e)||[],a=[];if(i.length>=2)a=i.map(b=>({ts:b.ts,val:b.val}));else{if(!l.history)return h;for(let b of l.history)b.trigger_value!=null&&a.push({ts:ft(b.timestamp),val:b.trigger_value})}if(l.trigger_current_value!=null&&a.push({ts:Date.now(),val:l.trigger_current_value}),a.length<2)return h;a.sort((b,D)=>b.ts-D.ts);let r=Xs,c=Zs,n=a.map(b=>b.val),u=Math.min(...n),d=Math.max(...n),g=d-u||1;u-=g*.1,d+=g*.1;let m=a[0].ts,y=a[a.length-1].ts-m||1,E=b=>(b-m)/y*r,w=b=>2+(1-(b-u)/(d-u))*(c-4),j=a;if(j.length>us){let b=Math.ceil(j.length/us);j=j.filter((D,at)=>at%b===0||at===j.length-1)}let x=j.map(b=>`${O(E(b.ts))},${O(w(b.val))}`).join(" "),M=l.trigger_active?"var(--error-color, #f44336)":"var(--primary-color)";return o`
`}function Ye(l,p,t){let e=gt(l.trigger_config);if(!e||l.battery_fleet_task)return h;let i=p.get(e)||[],a=[];if(i.length>=2)a=i.map(b=>({ts:b.ts,val:b.val}));else{if(!l.history)return h;for(let b of l.history)b.trigger_value!=null&&a.push({ts:ft(b.timestamp),val:b.trigger_value})}if(l.trigger_current_value!=null&&a.push({ts:Date.now(),val:l.trigger_current_value}),a.length<2)return h;a.sort((b,D)=>b.ts-D.ts);let r=ta,c=ea,n=a.map(b=>b.val),u=Math.min(...n),d=Math.max(...n),g=d-u||1;u-=g*.1,d+=g*.1;let m=a[0].ts,y=a[a.length-1].ts-m||1,E=b=>(b-m)/y*r,w=b=>2+(1-(b-u)/(d-u))*(c-4),j=a;if(j.length>_s){let b=Math.ceil(j.length/_s);j=j.filter((D,at)=>at%b===0||at===j.length-1)}let x=j.map(b=>`${O(E(b.ts))},${O(w(b.val))}`).join(" "),M=l.trigger_active?"var(--error-color, #f44336)":"var(--primary-color)";return o`
<svg class="mini-sparkline" viewBox="0 0 ${r} ${c}" preserveAspectRatio="none" role="img" aria-label="${s("chart_mini_sparkline",t)}">
<polyline points="${x}" fill="none" stroke="${M}" stroke-width="1.5" stroke-linejoin="round" />
</svg>
`}function gs(l,p){let t=p;if(l.days_until_due==null||!l.interval_days||l.interval_days<=0)return h;let{pct:e,overflow:i}=be(l.interval_days,l.days_until_due,l.interval_unit),a="var(--success-color, #4caf50)";return l.status==="overdue"?a="var(--error-color, #f44336)":l.status==="due_soon"&&(a="var(--warning-color, #ff9800)"),o`
`}function Qe(l,p,t,e="due-text"){if(l==null){let i=ni(p,t);if(i)return o`<span class="${e} last-done" title="${s("last_performed",t)}: ${q(p,t)}">${i}</span>`}return o`<span class="${e}">${xt(l,t)}</span>`}function ms(l,p){let t=p;if(l.days_until_due==null||!l.interval_days||l.interval_days<=0)return h;let{pct:e,overflow:i}=be(l.interval_days,l.days_until_due,l.interval_unit),a="var(--success-color, #4caf50)";return l.status==="overdue"?a="var(--error-color, #f44336)":l.status==="due_soon"&&(a="var(--warning-color, #ff9800)"),o`
<div class="days-progress">
<div class="days-progress-labels">
<span>${l.last_performed?`${s("last_performed",t)}: ${U(l.last_performed,t)}`:""}</span>
<span>${l.next_due?`${s("next_due",t)}: ${U(l.next_due,t)}`:""}</span>
<span>${l.last_performed?`${s("last_performed",t)}: ${q(l.last_performed,t)}`:""}</span>
<span>${l.next_due?`${s("next_due",t)}: ${q(l.next_due,t)}`:""}</span>
</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">${vt(l.days_until_due,t)}</div>
<div class="days-progress-text">${xt(l.days_until_due,t)}</div>
</div>
`}var Se=210,yt=46,Ot=14,Ct=12,_s=14,ea=20+_s,ia=[{days:7,key:"chart_range_7d"},{days:30,key:"chart_range_30d"},{days:90,key:"chart_range_90d"},{days:365,key:"chart_range_1y"}],et=class extends N{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,r)=>a.ts-r.ts),i=this.lang;return o`
`}var Se=210,bt=46,Ot=14,Ct=12,fs=14,sa=20+fs,aa=[{days:7,key:"chart_range_7d"},{days:30,key:"chart_range_30d"},{days:90,key:"chart_range_90d"},{days:365,key:"chart_range_1y"}],et=class extends N{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,r)=>a.ts-r.ts),i=this.lang;return o`
<div class="chart-wrap">
${this.showRange?o`<div class="range-chips" role="group">
${this.showOutlierToggle?o`<button
@@ -4817,7 +4817,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
title=${s("hide_outliers",i)}
@click=${()=>this._toggleOutliers()}
><ha-icon icon="mdi:filter-variant"></ha-icon></button>`:h}
${ia.map(a=>o`<button
${aa.map(a=>o`<button
class="range-chip ${this.rangeDays===a.days?"active":""}"
?disabled=${this.busy}
@click=${()=>this._emitRange(a.days)}
@@ -4827,7 +4827,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<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-yt-Ot,r=Se-ea,c=r-Ct,n=1/0,u=-1/0;for(let S of e)n=Math.min(n,S.min??S.val),u=Math.max(u,S.max??S.val);this.thresholdAbove!=null&&(n=Math.min(n,this.thresholdAbove),u=Math.max(u,this.thresholdAbove)),this.thresholdBelow!=null&&(n=Math.min(n,this.thresholdBelow),u=Math.max(u,this.thresholdBelow)),this.targetValue!=null&&(n=Math.min(n,this.targetValue),u=Math.max(u,this.targetValue)),this.forceZero&&(n=Math.min(n,0));let d=(u-n||1)*.06,g=this.forceZero&&n>=0?0:n-d,{ticks:m,niceMin:v,niceMax:y}=Zt(g,u+d,4);this.forceZero&&n>=0&&v<0&&(v=0,m=m.filter(S=>S>=0));let E=e[0].ts,w=this.projection&&this.projection.length===2?this.projection[1].ts:null,j=w!=null?Math.max(e[e.length-1].ts,w):e[e.length-1].ts,x=j-E||1,M=me(E,j),b=S=>yt+(S-E)/x*a,D=S=>Ct+(1-(S-v)/(y-v||1))*c,at=e.map(S=>`${O(b(S.ts))},${O(D(S.val))}`).join(" "),pt=`M${O(b(e[0].ts))},${r} `+e.map(S=>`L${O(b(S.ts))},${O(D(S.val))}`).join(" ")+` L${O(b(e[e.length-1].ts))},${r} Z`,T="",z=e.filter(S=>S.min!=null&&S.max!=null);if(z.length>=2){let S=z.map(rt=>`${O(b(rt.ts))},${O(D(rt.max))}`),X=[...z].reverse().map(rt=>`${O(b(rt.ts))},${O(D(rt.min))}`);T=`M${S[0]} `+S.slice(1).map(rt=>`L${rt}`).join(" ")+` L${X.join(" L")} Z`}let H=[];if(this.thresholdBelow!=null){let S=D(this.thresholdBelow);H.push({y:S,h:Math.max(0,r-S),lineY:S,label:`\u25BC ${kt(this.thresholdBelow,i)}`,labelY:Math.min(r-4,S+13)})}if(this.thresholdAbove!=null){let S=D(this.thresholdAbove);H.push({y:Ct,h:Math.max(0,S-Ct),lineY:S,label:`\u25B2 ${kt(this.thresholdAbove,i)}`,labelY:Math.max(Ct+11,S-5)})}let I=e[e.length-1],W=(this.events||[]).filter(S=>S.ts>=E&&S.ts<=j),Q=fe(E,j,Math.max(2,Math.min(5,Math.floor(a/110)+1))),J=this._hover;return o`
`}_renderSvg(t,e){let i=this.lang,a=t-bt-Ot,r=Se-sa,c=r-Ct,n=1/0,u=-1/0;for(let S of e)n=Math.min(n,S.min??S.val),u=Math.max(u,S.max??S.val);this.thresholdAbove!=null&&(n=Math.min(n,this.thresholdAbove),u=Math.max(u,this.thresholdAbove)),this.thresholdBelow!=null&&(n=Math.min(n,this.thresholdBelow),u=Math.max(u,this.thresholdBelow)),this.targetValue!=null&&(n=Math.min(n,this.targetValue),u=Math.max(u,this.targetValue)),this.forceZero&&(n=Math.min(n,0));let d=(u-n||1)*.06,g=this.forceZero&&n>=0?0:n-d,{ticks:m,niceMin:v,niceMax:y}=Zt(g,u+d,4);this.forceZero&&n>=0&&v<0&&(v=0,m=m.filter(S=>S>=0));let E=e[0].ts,w=this.projection&&this.projection.length===2?this.projection[1].ts:null,j=w!=null?Math.max(e[e.length-1].ts,w):e[e.length-1].ts,x=j-E||1,M=me(E,j),b=S=>bt+(S-E)/x*a,D=S=>Ct+(1-(S-v)/(y-v||1))*c,at=e.map(S=>`${O(b(S.ts))},${O(D(S.val))}`).join(" "),pt=`M${O(b(e[0].ts))},${r} `+e.map(S=>`L${O(b(S.ts))},${O(D(S.val))}`).join(" ")+` L${O(b(e[e.length-1].ts))},${r} Z`,T="",z=e.filter(S=>S.min!=null&&S.max!=null);if(z.length>=2){let S=z.map(rt=>`${O(b(rt.ts))},${O(D(rt.max))}`),X=[...z].reverse().map(rt=>`${O(b(rt.ts))},${O(D(rt.min))}`);T=`M${S[0]} `+S.slice(1).map(rt=>`L${rt}`).join(" ")+` L${X.join(" L")} Z`}let H=[];if(this.thresholdBelow!=null){let S=D(this.thresholdBelow);H.push({y:S,h:Math.max(0,r-S),lineY:S,label:`\u25BC ${kt(this.thresholdBelow,i)}`,labelY:Math.min(r-4,S+13)})}if(this.thresholdAbove!=null){let S=D(this.thresholdAbove);H.push({y:Ct,h:Math.max(0,S-Ct),lineY:S,label:`\u25B2 ${kt(this.thresholdAbove,i)}`,labelY:Math.max(Ct+11,S-5)})}let I=e[e.length-1],W=(this.events||[]).filter(S=>S.ts>=E&&S.ts<=j),Q=fe(E,j,Math.max(2,Math.min(5,Math.floor(a/110)+1))),J=this._hover;return o`
<div class="svg-holder">
<svg
class="chart-svg"
@@ -4841,8 +4841,8 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
@pointerleave=${()=>this._hover=null}
>
<defs>
<clipPath id="plot"><rect x="${yt}" y="${Ct}" width="${a}" height="${c}" /></clipPath>
${H.length?G`<clipPath id="danger">${H.map(S=>G`<rect x="${yt}" y="${O(S.y)}" width="${a}" height="${O(S.h)}" />`)}</clipPath>`:h}
<clipPath id="plot"><rect x="${bt}" y="${Ct}" width="${a}" height="${c}" /></clipPath>
${H.length?G`<clipPath id="danger">${H.map(S=>G`<rect x="${bt}" y="${O(S.y)}" width="${a}" height="${O(S.h)}" />`)}</clipPath>`:h}
<!-- Diagonal hatch so the danger zone reads without relying on the
red tint alone (dark-theme contrast + colour-blind support). -->
<pattern id="dangerHatch" patternUnits="userSpaceOnUse" width="7" height="7" patternTransform="rotate(45)">
@@ -4852,11 +4852,11 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</defs>
${m.map(S=>{let X=D(S);return X<Ct-1||X>r+1?h:G`
<line x1="${yt}" y1="${O(X)}" x2="${t-Ot}" y2="${O(X)}"
<line x1="${bt}" y1="${O(X)}" x2="${t-Ot}" y2="${O(X)}"
stroke="var(--divider-color)" stroke-width="1" opacity="0.6" />
<text x="${yt-7}" y="${O(X+3.5)}" text-anchor="end" class="tick-label">${kt(S,i)}</text>`})}
<text x="${bt-7}" y="${O(X+3.5)}" text-anchor="end" class="tick-label">${kt(S,i)}</text>`})}
${H.map(S=>G`<rect x="${yt}" y="${O(S.y)}" width="${a}" height="${O(S.h)}"
${H.map(S=>G`<rect x="${bt}" y="${O(S.y)}" width="${a}" height="${O(S.h)}"
fill="url(#dangerHatch)" />`)}
${T?G`<path d="${T}" fill="var(--primary-color)" opacity="0.08" clip-path="url(#plot)" />`:h}
@@ -4867,11 +4867,11 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
stroke-linejoin="round" stroke-linecap="round" clip-path="url(#danger)" />`:h}
${H.map(S=>G`
<line x1="${yt}" y1="${O(S.lineY)}" x2="${t-Ot}" y2="${O(S.lineY)}"
<line x1="${bt}" y1="${O(S.lineY)}" x2="${t-Ot}" y2="${O(S.lineY)}"
stroke="var(--error-color, #f44336)" stroke-width="1.5" stroke-dasharray="6,4" />
<text x="${t-Ot-4}" y="${O(S.labelY)}" text-anchor="end" class="zone-label">${S.label}</text>`)}
${this.targetValue!=null?G`<line x1="${yt}" y1="${O(D(this.targetValue))}" x2="${t-Ot}" y2="${O(D(this.targetValue))}"
${this.targetValue!=null?G`<line x1="${bt}" y1="${O(D(this.targetValue))}" x2="${t-Ot}" y2="${O(D(this.targetValue))}"
stroke="var(--error-color, #f44336)" stroke-width="1.5" stroke-dasharray="6,4" />
<text x="${t-Ot-4}" y="${O(D(this.targetValue)-5)}" text-anchor="end" class="zone-label">◆ ${kt(this.targetValue,i)} ${this.unit}</text>`:h}
@@ -4881,11 +4881,11 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${Q.map((S,X)=>{let rt=b(S),At=X===0?"start":X===Q.length-1?"end":"middle";return G`<text x="${O(rt)}" y="${Se-5}" text-anchor="${At}" class="tick-label">${qt(S,i,M)}</text>`})}
<line x1="${yt}" y1="${r}" x2="${t-Ot}" y2="${r}" stroke="var(--divider-color)" stroke-width="1" />
<line x1="${bt}" y1="${r}" x2="${t-Ot}" y2="${r}" stroke="var(--divider-color)" stroke-width="1" />
${W.map(S=>{let X=b(S.ts),rt=S.type==="completed"?"var(--success-color, #4caf50)":S.type==="skipped"?"var(--warning-color, #ff9800)":"var(--info-color, #2196f3)";return G`
<line x1="${O(X)}" y1="${Ct}" x2="${O(X)}" y2="${r}" stroke="${rt}" stroke-width="1" opacity="0.14" />
<rect x="${O(X-1.5)}" y="${r+3}" width="3" height="${_s-6}" rx="1.5" fill="${rt}">
<rect x="${O(X-1.5)}" y="${r+3}" width="3" height="${fs-6}" rx="1.5" fill="${rt}">
<title>${ze(S.ts,i)}</title>
</rect>`})}
@@ -4907,7 +4907,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
</div>`:h}
</div>
`}_onPointer(t,e,i,a,r){let n=t.currentTarget.getBoundingClientRect(),u=(t.clientX-n.left)/n.width*r;if(u<yt-8||u>r-Ot+8){this._hover=null;return}let d=e[0],g=1/0;for(let m of e){let v=Math.abs(i(m.ts)-u);v<g&&(g=v,d=m)}this._hover={x:i(d.ts),y:a(d.val),p:d}}};et.styles=B`
`}_onPointer(t,e,i,a,r){let n=t.currentTarget.getBoundingClientRect(),u=(t.clientX-n.left)/n.width*r;if(u<bt-8||u>r-Ot+8){this._hover=null;return}let d=e[0],g=1/0;for(let m of e){let v=Math.abs(i(m.ts)-u);v<g&&(g=v,d=m)}this._hover={x:i(d.ts),y:a(d.val),p:d}}};et.styles=B`
:host { display: block; width: 100%; }
.chart-wrap { position: relative; }
.range-chips { display: flex; gap: 4px; justify-content: flex-end; margin-bottom: 2px; }
@@ -4942,7 +4942,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
.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; }
`,_([R({attribute:!1})],et.prototype,"points",2),_([R({attribute:!1})],et.prototype,"events",2),_([R()],et.prototype,"unit",2),_([R()],et.prototype,"lang",2),_([R({attribute:!1})],et.prototype,"thresholdAbove",2),_([R({attribute:!1})],et.prototype,"thresholdBelow",2),_([R({attribute:!1})],et.prototype,"targetValue",2),_([R({type:Boolean})],et.prototype,"forceZero",2),_([R({attribute:!1})],et.prototype,"projection",2),_([R({attribute:!1})],et.prototype,"rangeDays",2),_([R({type:Boolean})],et.prototype,"showRange",2),_([R({type:Boolean})],et.prototype,"busy",2),_([R({type:Boolean})],et.prototype,"hideOutliers",2),_([R({type:Boolean})],et.prototype,"showOutlierToggle",2),_([f()],et.prototype,"_width",2),_([f()],et.prototype,"_hover",2);customElements.get("maintenance-trigger-chart")||customElements.define("maintenance-trigger-chart",et);function ms(l){let p=(l??"").trim().toLowerCase();return p==="on"||p==="open"||p==="true"?1:p==="off"||p==="closed"||p==="false"?0:null}function sa(l,p,t){if(l.length<2)return null;let e=t.now??Date.now(),i=Math.max(0,p.trigger_for_minutes??0)*6e4,a=p.trigger_from_state?ms(p.trigger_from_state):null,r=p.trigger_to_state?ms(p.trigger_to_state):null;if(p.trigger_from_state&&a===null||p.trigger_to_state&&r===null)return null;let c=[...l].sort((x,M)=>x.ts-M.ts),n=[];for(let x of c){let M=n[n.length-1];(!M||M.level!==x.val)&&n.push({start:x.ts,level:x.val})}let u=x=>(x+1<n.length?n[x+1].start:e)-n[x].start>=i,d=(x,M,b)=>{let D=x[x.length-1];D&&D.val!==b&&x.push({ts:M,val:D.val}),x.push({ts:M,val:b})};if((p.trigger_target_changes??1)===1&&r!==null){let x=[];n.forEach((b,D)=>d(x,b.start,b.level===r&&u(D)?1:0));let M=x[x.length-1]?.val??0;return x.push({ts:e,val:M}),{points:x,mode:"alarm"}}let m=t.since??n[0].start,v=0,y=[];for(let x=1;x<n.length;x++){let M=n[x-1],b=n[x];a!==null&&M.level!==a||r!==null&&b.level!==r||!u(x)||b.start<m||(v+=1,y.push(b.start))}let E=Math.max(0,(t.current??v)-v),w=[{ts:Math.max(m,n[0].start),val:E}],j=E;for(let x of y)j+=1,d(w,x,j);return w.push({ts:e,val:j}),{points:w,mode:"count"}}function aa(l){if(l.length<4)return l;let p=l.map(u=>u.val).sort((u,d)=>u-d),t=u=>{let d=(p.length-1)*u,g=Math.floor(d),m=Math.ceil(d);return p[g]+(p[m]-p[g])*(d-g)},e=t(.25),i=t(.75),a=i-e;if(a===0)return l;let r=e-1.5*a,c=i+1.5*a,n=l.filter(u=>u.val>=r&&u.val<=c);return n.length>=2?n:l}function fs(l,p){let t=l.trigger_config;if(!t)return h;let e=p.lang,i=l.trigger_entity_info,a=l.trigger_entity_infos,r=gt(t)||"",c=i?.friendly_name||r||"\u2014",n=Pe(t),u=i?.unit_of_measurement||"",d=l.trigger_current_value,g=t.type||"threshold",m=n.length>1,v=ra(l,u,p);return o`
`,_([R({attribute:!1})],et.prototype,"points",2),_([R({attribute:!1})],et.prototype,"events",2),_([R()],et.prototype,"unit",2),_([R()],et.prototype,"lang",2),_([R({attribute:!1})],et.prototype,"thresholdAbove",2),_([R({attribute:!1})],et.prototype,"thresholdBelow",2),_([R({attribute:!1})],et.prototype,"targetValue",2),_([R({type:Boolean})],et.prototype,"forceZero",2),_([R({attribute:!1})],et.prototype,"projection",2),_([R({attribute:!1})],et.prototype,"rangeDays",2),_([R({type:Boolean})],et.prototype,"showRange",2),_([R({type:Boolean})],et.prototype,"busy",2),_([R({type:Boolean})],et.prototype,"hideOutliers",2),_([R({type:Boolean})],et.prototype,"showOutlierToggle",2),_([f()],et.prototype,"_width",2),_([f()],et.prototype,"_hover",2);customElements.get("maintenance-trigger-chart")||customElements.define("maintenance-trigger-chart",et);function vs(l){let p=(l??"").trim().toLowerCase();return p==="on"||p==="open"||p==="true"?1:p==="off"||p==="closed"||p==="false"?0:null}function ra(l,p,t){if(l.length<2)return null;let e=t.now??Date.now(),i=Math.max(0,p.trigger_for_minutes??0)*6e4,a=p.trigger_from_state?vs(p.trigger_from_state):null,r=p.trigger_to_state?vs(p.trigger_to_state):null;if(p.trigger_from_state&&a===null||p.trigger_to_state&&r===null)return null;let c=[...l].sort((x,M)=>x.ts-M.ts),n=[];for(let x of c){let M=n[n.length-1];(!M||M.level!==x.val)&&n.push({start:x.ts,level:x.val})}let u=x=>(x+1<n.length?n[x+1].start:e)-n[x].start>=i,d=(x,M,b)=>{let D=x[x.length-1];D&&D.val!==b&&x.push({ts:M,val:D.val}),x.push({ts:M,val:b})};if((p.trigger_target_changes??1)===1&&r!==null){let x=[];n.forEach((b,D)=>d(x,b.start,b.level===r&&u(D)?1:0));let M=x[x.length-1]?.val??0;return x.push({ts:e,val:M}),{points:x,mode:"alarm"}}let m=t.since??n[0].start,v=0,y=[];for(let x=1;x<n.length;x++){let M=n[x-1],b=n[x];a!==null&&M.level!==a||r!==null&&b.level!==r||!u(x)||b.start<m||(v+=1,y.push(b.start))}let E=Math.max(0,(t.current??v)-v),w=[{ts:Math.max(m,n[0].start),val:E}],j=E;for(let x of y)j+=1,d(w,x,j);return w.push({ts:e,val:j}),{points:w,mode:"count"}}function oa(l){if(l.length<4)return l;let p=l.map(u=>u.val).sort((u,d)=>u-d),t=u=>{let d=(p.length-1)*u,g=Math.floor(d),m=Math.ceil(d);return p[g]+(p[m]-p[g])*(d-g)},e=t(.25),i=t(.75),a=i-e;if(a===0)return l;let r=e-1.5*a,c=i+1.5*a,n=l.filter(u=>u.val>=r&&u.val<=c);return n.length>=2?n:l}function bs(l,p){let t=l.trigger_config;if(!t)return h;let e=p.lang,i=l.trigger_entity_info,a=l.trigger_entity_infos,r=gt(t)||"",c=i?.friendly_name||r||"\u2014",n=Pe(t),u=i?.unit_of_measurement||"",d=l.trigger_current_value,g=t.type||"threshold",m=n.length>1,v=na(l,u,p);return o`
<h3>${s("trigger",e)}</h3>
<div class="trigger-card">
<div class="trigger-header">
@@ -4961,9 +4961,9 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</span>
</div>
${v?oa(v,e):d!=null?o`
${v?la(v,e):d!=null?o`
<div class="trigger-value-row">
<span class="trigger-current ${l.trigger_active?"active":""}">${g==="due_date"&&typeof d=="number"?vt(Ke(d),e):typeof d=="number"?zt(d,"",e):d}</span>
<span class="trigger-current ${l.trigger_active?"active":""}">${g==="due_date"&&typeof d=="number"?xt(Ke(d),e):typeof d=="number"?zt(d,"",e):d}</span>
${u?o`<span class="trigger-unit">${u}</span>`:h}
</div>
`:h}
@@ -5001,9 +5001,9 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
`:h}
${na(l,u,p)}
${ca(l,u,p)}
</div>
`}function ra(l,p,t){let e=l.trigger_config,i=l.trigger_current_value;if(!e||i==null)return null;switch(e.type||"threshold"){case"counter":{let a=e.trigger_target_value;if(a==null||a<=0)return null;if(!e.trigger_delta_mode)return{progress:Math.max(0,i),target:a,unit:p,meter:null};let r=vs(l,bs(l,t));return{progress:Math.max(0,i-(r?.value??i)),target:a,unit:p,meter:i}}case"state_change":{let a=e.trigger_target_changes;return a==null||a<=0?null:{progress:Math.max(0,i),target:a,unit:"",meter:null}}case"runtime":{let a=e.trigger_runtime_hours;return a==null||a<=0?null:{progress:Math.max(0,i),target:a,unit:"h",meter:null}}}return null}function vs(l,p){if(l.trigger_baseline_value!=null)return{value:l.trigger_baseline_value,ts:Te(l)};if(!p.length)return null;let t=Te(l);if(t==null)return{value:p[0].val,ts:null};let e=p[0],i=Math.abs(p[0].ts-t);for(let a of p){let r=Math.abs(a.ts-t);r<i&&(e=a,i=r)}return{value:e.val,ts:t}}function Te(l){let p=[...l.history].filter(t=>t.type==="completed"||t.type==="reset").sort((t,e)=>ft(e.timestamp)-ft(t.timestamp))[0];return p?ft(p.timestamp):null}function oa(l,p){let t=Math.min(999,Math.round(l.progress/l.target*100)),e=t>=100?"over":t>=75?"near":"ok";return o`
`}function na(l,p,t){let e=l.trigger_config,i=l.trigger_current_value;if(!e||i==null)return null;switch(e.type||"threshold"){case"counter":{let a=e.trigger_target_value;if(a==null||a<=0)return null;if(!e.trigger_delta_mode)return{progress:Math.max(0,i),target:a,unit:p,meter:null};let r=ys(l,xs(l,t));return{progress:Math.max(0,i-(r?.value??i)),target:a,unit:p,meter:i}}case"state_change":{let a=e.trigger_target_changes;return a==null||a<=0?null:{progress:Math.max(0,i),target:a,unit:"",meter:null}}case"runtime":{let a=e.trigger_runtime_hours;return a==null||a<=0?null:{progress:Math.max(0,i),target:a,unit:"h",meter:null}}}return null}function ys(l,p){if(l.trigger_baseline_value!=null)return{value:l.trigger_baseline_value,ts:Te(l)};if(!p.length)return null;let t=Te(l);if(t==null)return{value:p[0].val,ts:null};let e=p[0],i=Math.abs(p[0].ts-t);for(let a of p){let r=Math.abs(a.ts-t);r<i&&(e=a,i=r)}return{value:e.val,ts:t}}function Te(l){let p=[...l.history].filter(t=>t.type==="completed"||t.type==="reset").sort((t,e)=>ft(e.timestamp)-ft(t.timestamp))[0];return p?ft(p.timestamp):null}function la(l,p){let t=Math.min(999,Math.round(l.progress/l.target*100)),e=t>=100?"over":t>=75?"near":"ok";return o`
<div class="counter-progress">
<div class="counter-progress-nums">
<span class="counter-progress-main">${zt(l.progress,"",p)}<span class="counter-progress-target"> / ${zt(l.target,l.unit,p)}</span></span>
@@ -5016,7 +5016,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${s("chart_since_service",p)}${l.meter!=null?o` · ${s("current",p)}: ${zt(l.meter,l.unit,p)}`:h}
</div>
</div>
`}function bs(l,p){let t=l.trigger_config;if(!t)return[];let e=t.type||"threshold",i=gt(t)||"",a=e==="runtime"?[]:p.detailStatsData.get(i)||[],r=p.isCounterEntity(t),c=[];if(a.length>=2)for(let u of a){let d={ts:u.ts,val:u.val};!r&&u.min!=null&&u.max!=null&&(d.min=u.min,d.max=u.max),c.push(d)}else for(let u of l.history)u.trigger_value!=null&&c.push({ts:ft(u.timestamp),val:u.trigger_value});let n=!!i&&!!p.historyFallbackIds?.has(i)&&a.length>=2;return l.trigger_current_value!=null&&!n&&c.push({ts:Date.now(),val:l.trigger_current_value}),c.sort((u,d)=>u.ts-d.ts),c}function na(l,p,t){let e=l.trigger_config;if(!e)return h;let i=e.type||"threshold",a=gt(e)||"";if(i==="due_date")return h;let r=bs(l,t),c=null;i==="state_change"&&a&&t.historyFallbackIds?.has(a)&&(c=sa(r,e,{since:Te(l),current:l.trigger_current_value??null}),c&&(r=c.points)),i==="runtime"&&e.trigger_runtime_hours&&l.trigger_current_value!=null&&(r=[{ts:Te(l)??r[0]?.ts??Date.now()-864e5,val:0},{ts:Date.now(),val:Math.max(0,l.trigger_current_value)}]),t.hideOutliers&&(r=aa(r));let n=r.length<2&&!!a&&t.hasStatsService&&!t.detailStatsData.has(a);if(r.length<2&&!n)return h;let u=!!a&&t.detailStatsData.has(a)&&(t.detailStatsData.get(a)?.length??0)<2,d=Date.now()-t.rangeDays*864e5,g=r.filter(x=>x.ts>=d);g.length>=2&&(r=g);let m=null,v=!1;if(i==="counter"&&e.trigger_target_value!=null&&r.length){if(e.trigger_delta_mode){let x=vs(l,r);if(x){if(x.ts!=null){let M=r.filter(b=>b.ts>=x.ts);M.length>=2&&(r=M)}r=r.map(M=>({...M,val:Math.max(0,M.val-x.value)}))}}m=e.trigger_target_value,v=!0}else i==="state_change"&&e.trigger_target_changes&&c?.mode!=="alarm"?(m=e.trigger_target_changes,v=!0):i==="runtime"&&e.trigger_runtime_hours&&(m=e.trigger_runtime_hours,v=!0);let y=null,E=l.degradation_rate,w=E!=null&&(e.trigger_below!=null&&e.trigger_above==null&&E>0||e.trigger_above!=null&&e.trigger_below==null&&E<0);if(m==null&&E!=null&&!w&&(l.degradation_trend!=="stable"||l.days_until_threshold!=null)&&l.degradation_trend!=="insufficient_data"&&r.length>=2){let x=r[r.length-1];y=[x,{ts:x.ts+30*864e5,val:x.val+E*30}]}let j=l.history.filter(x=>["completed","skipped","reset"].includes(x.type)).map(x=>({ts:ft(x.timestamp),type:x.type}));return o`
`}function xs(l,p){let t=l.trigger_config;if(!t)return[];let e=t.type||"threshold",i=gt(t)||"",a=e==="runtime"?[]:p.detailStatsData.get(i)||[],r=p.isCounterEntity(t),c=[];if(a.length>=2)for(let u of a){let d={ts:u.ts,val:u.val};!r&&u.min!=null&&u.max!=null&&(d.min=u.min,d.max=u.max),c.push(d)}else for(let u of l.history)u.trigger_value!=null&&c.push({ts:ft(u.timestamp),val:u.trigger_value});let n=!!i&&!!p.historyFallbackIds?.has(i)&&a.length>=2;return l.trigger_current_value!=null&&!n&&c.push({ts:Date.now(),val:l.trigger_current_value}),c.sort((u,d)=>u.ts-d.ts),c}function ca(l,p,t){let e=l.trigger_config;if(!e)return h;let i=e.type||"threshold",a=gt(e)||"";if(i==="due_date")return h;let r=xs(l,t),c=null;i==="state_change"&&a&&t.historyFallbackIds?.has(a)&&(c=ra(r,e,{since:Te(l),current:l.trigger_current_value??null}),c&&(r=c.points)),i==="runtime"&&e.trigger_runtime_hours&&l.trigger_current_value!=null&&(r=[{ts:Te(l)??r[0]?.ts??Date.now()-864e5,val:0},{ts:Date.now(),val:Math.max(0,l.trigger_current_value)}]),t.hideOutliers&&(r=oa(r));let n=r.length<2&&!!a&&t.hasStatsService&&!t.detailStatsData.has(a);if(r.length<2&&!n)return h;let u=!!a&&t.detailStatsData.has(a)&&(t.detailStatsData.get(a)?.length??0)<2,d=Date.now()-t.rangeDays*864e5,g=r.filter(x=>x.ts>=d);g.length>=2&&(r=g);let m=null,v=!1;if(i==="counter"&&e.trigger_target_value!=null&&r.length){if(e.trigger_delta_mode){let x=ys(l,r);if(x){if(x.ts!=null){let M=r.filter(b=>b.ts>=x.ts);M.length>=2&&(r=M)}r=r.map(M=>({...M,val:Math.max(0,M.val-x.value)}))}}m=e.trigger_target_value,v=!0}else i==="state_change"&&e.trigger_target_changes&&c?.mode!=="alarm"?(m=e.trigger_target_changes,v=!0):i==="runtime"&&e.trigger_runtime_hours&&(m=e.trigger_runtime_hours,v=!0);let y=null,E=l.degradation_rate,w=E!=null&&(e.trigger_below!=null&&e.trigger_above==null&&E>0||e.trigger_above!=null&&e.trigger_below==null&&E<0);if(m==null&&E!=null&&!w&&(l.degradation_trend!=="stable"||l.days_until_threshold!=null)&&l.degradation_trend!=="insufficient_data"&&r.length>=2){let x=r[r.length-1];y=[x,{ts:x.ts+30*864e5,val:x.val+E*30}]}let j=l.history.filter(x=>["completed","skipped","reset"].includes(x.type)).map(x=>({ts:ft(x.timestamp),type:x.type}));return o`
<maintenance-trigger-chart
.points=${n?[]:r}
.events=${j}
@@ -5040,7 +5040,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<ha-icon icon="mdi:information-outline"></ha-icon>
${s("chart_no_stats",t.lang)}
</div>`:h}
`}var la=200,ee=10,ca=22;function ys(l,p,t,e,i){let a=l.history.filter(n=>n.type==="completed"&&(Rt(n)!=null||n.duration!=null));if(a.length<2)return h;let r=a.some(n=>(Rt(n)??0)!==0),c=a.some(n=>(n.duration??0)>0);return!r&&!c?h:o`
`}var da=200,ee=10,pa=22;function ks(l,p,t,e,i){let a=l.history.filter(n=>n.type==="completed"&&(Rt(n)!=null||n.duration!=null));if(a.length<2)return h;let r=a.some(n=>(Rt(n)??0)!==0),c=a.some(n=>(n.duration??0)>0);return!r&&!c?h:o`
<div class="cost-duration-card">
<div class="card-header">
<h3>${s("cost_duration_chart",p)}</h3>
@@ -5062,9 +5062,9 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</button>`:h}
</div>
</div>
${da(l,p,t,i)}
${ha(l,p,t,i)}
</div>
`}function da(l,p,t,e){let i=l.history.filter(C=>C.type==="completed"&&(Rt(C)!=null||C.duration!=null)).map(C=>({ts:ft(C.timestamp),cost:Rt(C)??0,duration:C.duration??0})).sort((C,it)=>C.ts-it.ts);if(i.length<2)return h;let a=i.some(C=>C.cost!==0),r=i.some(C=>C.cost<0),c=i.some(C=>C.duration>0);if(!a&&!c)return h;let n=t!=="duration"&&a,u=t!=="cost"&&c,d=n||!u&&a,g=u||!n&&c,m=640,v=la,y=d?44:12,E=g?44:12,w=m-y-E,j=v-ca,x=j-ee,M=i[0].ts,b=i[i.length-1].ts,D=(b-M||864e5)*.05,at=M-D,pt=b+D,T=me(M,b),z=C=>y+(C-at)/(pt-at)*w,H=Math.min(0,...i.map(C=>C.cost)),I=Math.max(0,...i.map(C=>C.cost)),W=Zt(H,I>H?I:H+1,3),Q=Zt(0,Math.max(...i.map(C=>C.duration))||1,3),J=W.niceMax-W.niceMin||1,S=C=>ee+(1-(C-W.niceMin)/J)*x,X=C=>ee+(1-C/(Q.niceMax||1))*x,rt=i.length>1?Math.min(...i.slice(1).map((C,it)=>z(C.ts)-z(i[it].ts))):w,At=Math.max(6,Math.min(22,rt*.55)),ht=fe(M,b,Math.max(2,Math.min(4,i.length)));return o`
`}function ha(l,p,t,e){let i=l.history.filter(C=>C.type==="completed"&&(Rt(C)!=null||C.duration!=null)).map(C=>({ts:ft(C.timestamp),cost:Rt(C)??0,duration:C.duration??0})).sort((C,it)=>C.ts-it.ts);if(i.length<2)return h;let a=i.some(C=>C.cost!==0),r=i.some(C=>C.cost<0),c=i.some(C=>C.duration>0);if(!a&&!c)return h;let n=t!=="duration"&&a,u=t!=="cost"&&c,d=n||!u&&a,g=u||!n&&c,m=640,v=da,y=d?44:12,E=g?44:12,w=m-y-E,j=v-pa,x=j-ee,M=i[0].ts,b=i[i.length-1].ts,D=(b-M||864e5)*.05,at=M-D,pt=b+D,T=me(M,b),z=C=>y+(C-at)/(pt-at)*w,H=Math.min(0,...i.map(C=>C.cost)),I=Math.max(0,...i.map(C=>C.cost)),W=Zt(H,I>H?I:H+1,3),Q=Zt(0,Math.max(...i.map(C=>C.duration))||1,3),J=W.niceMax-W.niceMin||1,S=C=>ee+(1-(C-W.niceMin)/J)*x,X=C=>ee+(1-C/(Q.niceMax||1))*x,rt=i.length>1?Math.min(...i.slice(1).map((C,it)=>z(C.ts)-z(i[it].ts))):w,At=Math.max(6,Math.min(22,rt*.55)),ht=fe(M,b,Math.max(2,Math.min(4,i.length)));return o`
<div class="sparkline-container">
<svg class="history-chart" viewBox="0 0 ${m} ${v}" preserveAspectRatio="xMidYMid meet" role="img" aria-label="${s("chart_history",p)}">
${d?W.ticks.map(C=>{let it=S(C);return it<ee-1||it>j+1?h:G`
@@ -5078,14 +5078,14 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${d?i.filter(C=>C.cost!==0).map(C=>{let it=S(Math.max(C.cost,0)),Wt=C.cost<0;return G`
<rect class="${Wt?"credit-bar":"cost-bar"}" x="${O(z(C.ts)-At/2)}" y="${O(it)}" width="${O(At)}" height="${O(S(Math.min(C.cost,0))-it)}"
fill="${Wt?"var(--success-color, #43a047)":"var(--primary-color)"}" opacity="0.6" rx="2">
<title>${qt(C.ts,p,!0)}: ${Wt?`${s("cost_kind_credit",p)} `:""}${F(Math.abs(C.cost),e,p)}${C.duration?` \xB7 ${C.duration}m`:""}</title>
<title>${qt(C.ts,p,!0)}: ${Wt?`${s("cost_kind_credit",p)} `:""}${U(Math.abs(C.cost),e,p)}${C.duration?` \xB7 ${C.duration}m`:""}</title>
</rect>`}):h}
${g?G`
<polyline points="${i.map(C=>`${O(z(C.ts))},${O(X(C.duration))}`).join(" ")}"
fill="none" stroke="var(--accent-color, #ff9800)" stroke-width="2" stroke-linejoin="round" />
${i.map(C=>G`
<circle cx="${O(z(C.ts))}" cy="${O(X(C.duration))}" r="3.5" fill="var(--accent-color, #ff9800)">
<title>${qt(C.ts,p,!0)}: ${C.duration}m${C.cost?` \xB7 ${F(C.cost,e,p)}`:""}</title>
<title>${qt(C.ts,p,!0)}: ${C.duration}m${C.cost?` \xB7 ${U(C.cost,e,p)}`:""}</title>
</circle>
`)}
`:h}
@@ -5099,12 +5099,12 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${d&&r?o`<span class="legend-item"><span class="legend-swatch" style="background:var(--success-color, #43a047);opacity:0.6"></span>${s("cost_kind_credit",p)}</span>`:h}
${g?o`<span class="legend-item"><span class="legend-swatch" style="background:var(--accent-color, #ff9800)"></span>${s("duration",p)}</span>`:h}
</div>
`}function Qe(l,p,t){if(!l.responsible_user_id)return h;let e=t?.(l.responsible_user_id)??null;if(e)return o`<span class="user-badge">${Si(e)}${e.name}</span>`;let i=p(l.responsible_user_id);return i?o`
`}function Je(l,p,t){if(!l.responsible_user_id)return h;let e=t?.(l.responsible_user_id)??null;if(e)return o`<span class="user-badge">${Ei(e)}${e.name}</span>`;let i=p(l.responsible_user_id);return i?o`
<span class="user-badge">
<ha-icon icon="mdi:account"></ha-icon>
${i}
</span>
`:h}function pa(l,p){let t=p.lang,e=p.isOperator;return o`
`:h}function ua(l,p){let t=p.lang,e=p.isOperator;return o`
<div class="task-header">
<div class="task-header-title">
<span class="task-name-breadcrumb" @click=${()=>p.showTaskView()}>${l.name}${Ut(l.next_event_titles)}</span>
@@ -5113,12 +5113,12 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<span class="object-name-breadcrumb" @click=${()=>p.showObject()}>${p.objectName}</span>
${ve(l,t,"chip")}
${l.paused&&l.paused_until?o`<span class="postponed-badge paused-until" title="${s("task_paused",t)}">
<ha-icon icon="mdi:pause-circle-outline"></ha-icon>${s("paused_until_label",t)} ${U(l.paused_until,t)}
<ha-icon icon="mdi:pause-circle-outline"></ha-icon>${s("paused_until_label",t)} ${q(l.paused_until,t)}
</span>`:h}
${l.due_override?o`<span class="postponed-badge" title="${s("postponed_to",t)}">
<ha-icon icon="mdi:calendar-arrow-right"></ha-icon>${U(l.due_override,t)}
<ha-icon icon="mdi:calendar-arrow-right"></ha-icon>${q(l.due_override,t)}
</span>`:h}
${Qe(l,p.getUserName,p.getPerson)}
${Je(l,p.getUserName,p.getPerson)}
${l.notify_enabled===!1?o`<span class="nfc-badge muted-badge" title="${s("no_notifications",t)}"><ha-icon icon="mdi:bell-off-outline"></ha-icon></span>`:h}
${l.mirror_todo_entities?.length?o`<span class="nfc-badge mirror-badge" title="${s("task_mirror_todo",t)}: ${l.mirror_todo_entities.map(i=>String(p.hass?.states?.[i]?.attributes?.friendly_name??i)).join(", ")}"><ha-icon icon="mdi:clipboard-list-outline"></ha-icon></span>`:h}
${l.nfc_tag_id?o`<span class="nfc-badge" title="${s("nfc_tag_id",t)}: ${l.nfc_tag_id}"><ha-icon icon="mdi:nfc-variant"></ha-icon> NFC</span>`:e?h:o`<span class="nfc-badge unlinked" title="${s("nfc_link_hint",t)}"
@@ -5165,7 +5165,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
</div>
</div>
`}function ha(l){let p=l.lang;return o`
`}function ga(l){let p=l.lang;return o`
<div class="tab-bar">
<div class="tab ${l.activeTab==="overview"?"active":""}" @click=${()=>l.setActiveTab("overview")}>
${s("overview",p)}
@@ -5174,7 +5174,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${s("history",p)}
</div>
</div>
`}function xs(l,p,t,e){let i=e.collapsedSections.has(l);return o`
`}function ws(l,p,t,e){let i=e.collapsedSections.has(l);return o`
<div class="collapsible ${i?"collapsed":""}">
<button class="collapsible-head" @click=${()=>e.toggleSection(l)}
aria-expanded=${i?"false":"true"}>
@@ -5183,7 +5183,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</button>
${i?h:o`<div class="collapsible-body">${t}</div>`}
</div>
`}function ua(l,p){if(!_i(l))return h;let t=p.lang,e=l.phase_sequence,i=gi(l.phase_cursor,e.length),a=new Map;for(let r=l.history.length-1;r>=0;r--){let c=l.history[r];c.phase_id&&c.type==="completed"&&!a.has(c.phase_id)&&a.set(c.phase_id,c.timestamp)}return o`
`}function _a(l,p){if(!fi(l))return h;let t=p.lang,e=l.phase_sequence,i=mi(l.phase_cursor,e.length),a=new Map;for(let r=l.history.length-1;r>=0;r--){let c=l.history[r];c.phase_id&&c.type==="completed"&&!a.has(c.phase_id)&&a.set(c.phase_id,c.timestamp)}return o`
<div class="phases-card">
<div class="phases-card-header">
<ha-icon icon="mdi:rotate-right"></ha-icon>
@@ -5195,12 +5195,12 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
title=${c===i?s("phase_current",t):s("phase_set",t)}
@click=${()=>{c!==i&&p.setPhaseCursor(c)}}>
<span class="phase-step-name">${c+1}. ${n}</span>
${u?o`<span class="phase-step-last">${U(u,t)}</span>`:h}
${u?o`<span class="phase-step-last">${q(u,t)}</span>`:h}
</div>
`})}
</div>
</div>
`}function ga(l,p){if(!p.features.checklists)return h;let t=he(l)?.checklist??(l.checklist||[]);if(t.length===0)return h;let e=p.lang,i=l.checklist_progress||{},a=t.filter(r=>i[r]).length;return o`
`}function ma(l,p){if(!p.features.checklists)return h;let t=he(l)?.checklist??(l.checklist||[]);if(t.length===0)return h;let e=p.lang,i=l.checklist_progress||{},a=t.filter(r=>i[r]).length;return o`
<div class="checklist-preview-card">
<div class="checklist-preview-header">
<ha-icon icon="mdi:format-list-checks"></ha-icon>
@@ -5221,7 +5221,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
`)}
</ol>
</div>
`}function _a(l,p){let t=st(l.documentation_url)?l.documentation_url:null,e=st(p.objectDocUrl)?p.objectDocUrl:null,i=e?null:(p.objectManualDocs||[])[0];if(!l.notes&&!t&&!e&&!i)return h;let a=p.lang;return o`
`}function fa(l,p){let t=st(l.documentation_url)?l.documentation_url:null,e=st(p.objectDocUrl)?p.objectDocUrl:null,i=e?null:(p.objectManualDocs||[])[0];if(!l.notes&&!t&&!e&&!i)return h;let a=p.lang;return o`
<div class="task-meta-card">
${l.notes?o`
<div class="task-meta-row">
@@ -5249,11 +5249,11 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
`:h}
</div>
`}function ma(l,p){let t=p.lang,e=l.average_cost!==void 0?l.average_cost??0:l.times_performed>0?l.total_cost/l.times_performed:0,i=l.days_until_due!==null&&l.days_until_due!==void 0?l.days_until_due<0?"overdue":l.days_until_due<=l.warning_days?"warning":"":"";return o`
`}function va(l,p){let t=p.lang,e=l.average_cost!==void 0?l.average_cost??0:l.times_performed>0?l.total_cost/l.times_performed:0,i=l.days_until_due!==null&&l.days_until_due!==void 0?l.days_until_due<0?"overdue":l.days_until_due<=l.warning_days?"warning":"":"";return o`
<div class="kpi-bar">
<div class="kpi-card">
<div class="kpi-label">${s("next_due",t)}</div>
<div class="kpi-value">${l.next_due?U(l.next_due,t):"\u2014"}</div>
<div class="kpi-value">${l.next_due?q(l.next_due,t):"\u2014"}</div>
${p.features.schedule_time&&l.schedule_time?o`<div class="kpi-subtext">${s("at_time",t)} ${l.schedule_time}</div>`:h}
</div>
<div class="kpi-card ${i}">
@@ -5273,21 +5273,21 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
<div class="kpi-card">
<div class="kpi-label">${s("last_performed",t)}</div>
<div class="kpi-value">${l.last_performed?U(l.last_performed,t):"\u2014"}</div>
<div class="kpi-value">${l.last_performed?q(l.last_performed,t):"\u2014"}</div>
</div>
<div class="kpi-card">
<div class="kpi-label">${s("avg_cost",t)}</div>
<div class="kpi-value">${F(e,p.currencySymbol,t)}</div>
<div class="kpi-value">${U(e,p.currencySymbol,t)}</div>
</div>
<div class="kpi-card">
<div class="kpi-label">${s("avg_duration",t)}</div>
<div class="kpi-value">${l.average_duration?Yt(Math.round(l.average_duration),t):"\u2014"}</div>
</div>
</div>
`}function fa(l,p){let t=p.lang;if(!p.features.adaptive||!l.suggested_interval||l.suggested_interval===l.interval_days)return h;if(p.suggestionDismissed)return h;let e=l.suggested_interval;return o`
`}function ba(l,p){let t=p.lang;if(!p.features.adaptive||!l.suggested_interval||l.suggested_interval===l.interval_days)return h;if(p.suggestionDismissed)return h;let e=l.suggested_interval;return o`
<div class="recommendation-card">
<h4>${s("suggested_interval",t)}</h4>
${Vi(l.interval_days,e,l.interval_confidence||"medium",t)}
${Ki(l.interval_days,e,l.interval_confidence||"medium",t)}
<div class="recommendation-actions">
${p.isOperator?h:o`<ha-button appearance="filled" class="apply-suggestion"
@click=${()=>p.applySuggestion(e)}>
@@ -5303,49 +5303,49 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</ha-button>
</div>
</div>
`}function va(l,p){let t=p.lang,e=Hi(l.history).slice(0,3);return e.length===0?h:o`
`}function ya(l,p){let t=p.lang,e=Ni(l.history).slice(0,3);return e.length===0?h:o`
<div class="recent-activities">
<h3>${s("recent_activities",t)}</h3>
${e.map(i=>qi(i,p.history,{compact:!0,showEdit:!1}))}
${e.map(i=>Ui(i,p.history,{compact:!0,showEdit:!1}))}
<div class="activity-show-all">
<ha-button appearance="plain" @click=${()=>p.setActiveTab("history")}>${s("show_all",t)} →</ha-button>
</div>
</div>
`}function ba(l,p){let t=p.lang,e=p.features.adaptive&&l.suggested_interval&&l.suggested_interval!==l.interval_days,i=p.features.seasonal&&l.seasonal_factor&&l.seasonal_factor!==1,a=e||i,r=p.features.adaptive&&l.interval_analysis?.weibull_beta!=null&&l.interval_analysis?.weibull_eta!=null,c=p.features.seasonal&&(l.seasonal_factors?.length===12||l.interval_analysis?.seasonal_factors?.length===12);return o`
`}function xa(l,p){let t=p.lang,e=p.features.adaptive&&l.suggested_interval&&l.suggested_interval!==l.interval_days,i=p.features.seasonal&&l.seasonal_factor&&l.seasonal_factor!==1,a=e||i,r=p.features.adaptive&&l.interval_analysis?.weibull_beta!=null&&l.interval_analysis?.weibull_eta!=null,c=p.features.seasonal&&(l.seasonal_factors?.length===12||l.interval_analysis?.seasonal_factors?.length===12);return o`
<div class="tab-content overview-tab">
${l.battery_fleet_task?o`<maintenance-battery-fleet-section .hass=${p.hass}></maintenance-battery-fleet-section>`:h}
${ma(l,p)}
${_a(l,p)}
${va(l,p)}
${fa(l,p)}
${l.battery_fleet_task?h:o`
${gs(l,p.lang)}
${fs(l,p.sparkline)}
${Ui(l,t,p.features)}
${ms(l,p.lang)}
${bs(l,p.sparkline)}
${Wi(l,t,p.features)}
`}
<div class="two-column-layout ${a?"":"single-column"}">
${a?o`
<div class="left-column">
${fa(l,p)}
${Wi(l,t,p.features)}
${ba(l,p)}
${Gi(l,t,p.features)}
</div>
`:h}
<div class="right-column">
${ys(l,t,p.costDurationToggle,n=>p.setCostDurationToggle(n),p.currencySymbol)}
${ks(l,t,p.costDurationToggle,n=>p.setCostDurationToggle(n),p.currencySymbol)}
</div>
</div>
${r?xs("weibull","weibull_reliability_curve",Fi(l,t),p):h}
${c?xs("seasonal","seasonal_chart_title",o`
${Ki(l,t)}
${r?ws("weibull","weibull_reliability_curve",Vi(l,t),p):h}
${c?ws("seasonal","seasonal_chart_title",o`
${Yi(l,t)}
<div class="seasonal-actions">
<ha-button appearance="plain" @click=${()=>p.openSeasonalOverrides(l)}>
${s("edit_seasonal_overrides",t)}
</ha-button>
</div>
`,p):h}
${ua(l,p)}
${ga(l,p)}
${va(l,p)}
${_a(l,p)}
${ma(l,p)}
${ya(l,p)}
</div>
`}function ya(l,p){return o`
`}function ka(l,p){return o`
<div class="tab-content history-tab">
<div class="history-add-past">
<ha-button appearance="plain" class="history-add-past-btn" @click=${()=>p.openComplete(l)}>
@@ -5353,14 +5353,14 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${s("history_add_past",p.lang)}
</ha-button>
</div>
${Bi(l,p.history)}
${Ni(l,p.history)}
${qi(l,p.history)}
${Fi(l,p.history)}
</div>
`}function xa(l,p){switch(p.activeTab){case"overview":return ba(l,p);case"history":return ya(l,p);default:return h}}function ks(l,p){return o`
`}function wa(l,p){switch(p.activeTab){case"overview":return xa(l,p);case"history":return ka(l,p);default:return h}}function $s(l,p){return o`
<div class="detail-section">
${pa(l,p)}
${ha(p)}
${xa(l,p)}
${ua(l,p)}
${ga(p)}
${wa(l,p)}
<maintenance-task-documents
.hass=${p.hass}
.entryId=${p.entryId}
@@ -5368,9 +5368,9 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
.canWrite=${!p.isOperator}
></maintenance-task-documents>
</div>
`}var ie=class extends N{createRenderRoot(){return this}render(){return!this.task||!this.ctx?h:o`${ks(this.task,this.ctx)}`}};_([R({attribute:!1})],ie.prototype,"task",2),_([R({attribute:!1})],ie.prototype,"ctx",2);customElements.get("maintenance-task-detail-view")||customElements.define("maintenance-task-detail-view",ie);function ws(l){if(l.total<=0)return{start:0,end:0,padTop:0,padBottom:0};let p=l.overscan??12,t=Math.max(1,l.step??6),e=Math.max(1,l.rowHeight),i=Math.floor((l.scrollTop-l.listTop)/e),a=Math.ceil(l.viewportHeight/e)+1,r=Math.max(0,i-p);r=Math.floor(r/t)*t;let c=Math.min(l.total,Math.max(i,0)+a+p);return c=Math.min(l.total,Math.ceil(c/t)*t),r>=c&&(r=Math.min(r,Math.max(0,l.total-1)),c=Math.min(l.total,r+Math.max(a,1))),{start:r,end:c,padTop:r*e,padBottom:(l.total-c)*e}}var Ee={mode:"top",marginTop:0,lastScrollTop:0};function $s(l,p){return l==="top"?8:p.viewH-p.paneH-8}function js(l){let p=l.scrollTop+8-l.layoutTop,t=Math.max(0,l.listH-l.paneH);return{mode:"top",marginTop:p>t?Math.max(0,p):0,lastScrollTop:l.scrollTop}}function Ss(l,p){let t=p.scrollTop,e=p.scrollTop>l.lastScrollTop?"down":p.scrollTop<l.lastScrollTop?"up":"none",i=Math.max(0,p.listH-p.paneH),a=p.paneH+16<=p.viewH||p.listH<=p.paneH,{mode:r,marginTop:c}=l;if(a&&(r="top"),r==="top"&&c>0&&e==="up")c=Math.max(0,Math.min(c,p.scrollTop+8-p.layoutTop)),c<=i&&(c=0);else if(!a&&e==="down"&&r==="top"){let n=p.renderedTop-p.layoutTop;n<=i&&(r="bottom",c=Math.max(0,n))}else!a&&e==="up"&&r==="bottom"&&(c=Math.min(Math.max(0,p.renderedTop-p.layoutTop),i),p.scrollTop+8<=p.layoutTop+c&&(r="top",c=0));return{mode:r,marginTop:c,lastScrollTop:t}}var Re=2,ja=250,Pt={objects:6,tasks:10,parts:6,documents:8,history:6},Sa="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z",Je=["due_date","object","type","task_name","area","assigned_user","group"],Ts=["none","area","group","user","object"],Es=ti,Rs=["tasks","documents","parts","history"],k=class extends N{constructor(){super(...arguments);this.narrow=!1;this.tight=!1;this.split=!1;this._tightObserver=null;this.panel={};this.embedded=!1;this.presets={};this._presetsApplied=!1;this._mountPath=null;this._objects=[];this._stats=null;this._view="overview";this._allParts=null;this._selectedEntryId=null;this._selectedTaskId=null;this._selectedAreaId=null;this._filterStatus="";this._filterUser=null;this._filterLabel=null;this._filterPlace="";this._filterPriority="";this._savedViews=[];this._activeViewId="";this._unsub=null;this._chartRangeDays=(()=>{try{let t=parseInt(Z(A.chartRange)||"",10);return[7,30,90,365].includes(t)?t:30}catch{return 30}})();this._hideOutliers=(()=>{try{return Z(A.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,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1,places:!1};this._adminPanelUserIds=[];this._operatorWriteEnabled=!1;this._defaultWarningDays=7;this._rowActionStyle="buttons_compact";this._refsInLists=!1;this._partsCostMode="purchase";this._rowActionNotice=!1;this._actionLoading=!1;this._moreMenuOpen=!1;this._objMenuOpen=!1;this._toastMessage="";this._toastKind="error";this._toastUndo=null;this._toastActionLabel="";this._filtersOpen=!1;this._newMenuOpen=!1;this._gsSetupsCount=0;this._gsAdoptCount=0;this._gsLoaded=!1;this._resetOffersLoaded=!1;this._resetOffersCount=0;this._batteryFleetSetupAvailable=!1;this._staleBundle=!1;this._staleChecked=!1;this._toastTimer=null;this._dismissedSuggestions=new Set;this._overviewTab=(()=>{try{let t=Z(A.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=pi;this._showArchived=!1;this._bulkMode=!1;this._bulkSelected=new Set;this._objBulkMode=!1;this._objBulkSelected=new Set;this._bulkMenuOpen=!1;this._virtStart=0;this._virtEnd=0;this._virtRowHeight=53;this._virtTotalRows=0;this._virtScrollAttached=!1;this._virtRaf=0;this._stickyState=Ee;this._stickySelectPending=!1;this._stickyRaf=0;this._stickyAttached=!1;this._stickyObserver=null;this._collapsedGroups=new Set;this._collapsedSections=(()=>{try{return new Set(JSON.parse(Z(A.collapsedSections)||"[]"))}catch{return new Set}})();this._objectSectionsCollapsed=(()=>{try{let t=JSON.parse(Z(A.objectSections)||"[]");return new Set((Array.isArray(t)?t:[]).filter(e=>Rs.includes(e)))}catch{return new Set}})();this._objectSectionOverride=null;this._paletteOpen=!1;this._paletteQuery="";this._paletteActive=0;this._searchRemote=null;this._searchTimer=nul Line truncated
`}var ie=class extends N{createRenderRoot(){return this}render(){return!this.task||!this.ctx?h:o`${$s(this.task,this.ctx)}`}};_([R({attribute:!1})],ie.prototype,"task",2),_([R({attribute:!1})],ie.prototype,"ctx",2);customElements.get("maintenance-task-detail-view")||customElements.define("maintenance-task-detail-view",ie);function js(l){if(l.total<=0)return{start:0,end:0,padTop:0,padBottom:0};let p=l.overscan??12,t=Math.max(1,l.step??6),e=Math.max(1,l.rowHeight),i=Math.floor((l.scrollTop-l.listTop)/e),a=Math.ceil(l.viewportHeight/e)+1,r=Math.max(0,i-p);r=Math.floor(r/t)*t;let c=Math.min(l.total,Math.max(i,0)+a+p);return c=Math.min(l.total,Math.ceil(c/t)*t),r>=c&&(r=Math.min(r,Math.max(0,l.total-1)),c=Math.min(l.total,r+Math.max(a,1))),{start:r,end:c,padTop:r*e,padBottom:(l.total-c)*e}}var Ee={mode:"top",marginTop:0,lastScrollTop:0};function Ss(l,p){return l==="top"?8:p.viewH-p.paneH-8}function Ts(l){let p=l.scrollTop+8-l.layoutTop,t=Math.max(0,l.listH-l.paneH);return{mode:"top",marginTop:p>t?Math.max(0,p):0,lastScrollTop:l.scrollTop}}function Es(l,p){let t=p.scrollTop,e=p.scrollTop>l.lastScrollTop?"down":p.scrollTop<l.lastScrollTop?"up":"none",i=Math.max(0,p.listH-p.paneH),a=p.paneH+16<=p.viewH||p.listH<=p.paneH,{mode:r,marginTop:c}=l;if(a&&(r="top"),r==="top"&&c>0&&e==="up")c=Math.max(0,Math.min(c,p.scrollTop+8-p.layoutTop)),c<=i&&(c=0);else if(!a&&e==="down"&&r==="top"){let n=p.renderedTop-p.layoutTop;n<=i&&(r="bottom",c=Math.max(0,n))}else!a&&e==="up"&&r==="bottom"&&(c=Math.min(Math.max(0,p.renderedTop-p.layoutTop),i),p.scrollTop+8<=p.layoutTop+c&&(r="top",c=0));return{mode:r,marginTop:c,lastScrollTop:t}}var Re=2,Ta=250,Pt={objects:6,tasks:10,parts:6,documents:8,history:6},Ea="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z",Xe=["due_date","object","type","task_name","area","assigned_user","group"],Rs=["none","area","group","user","object"],Os=ei,Cs=["tasks","documents","parts","history"],k=class extends N{constructor(){super(...arguments);this.narrow=!1;this.tight=!1;this.split=!1;this._tightObserver=null;this.panel={};this.embedded=!1;this.presets={};this._presetsApplied=!1;this._mountPath=null;this._objects=[];this._stats=null;this._view="overview";this._allParts=null;this._selectedEntryId=null;this._selectedTaskId=null;this._selectedAreaId=null;this._filterStatus="";this._filterUser=null;this._filterLabel=null;this._filterPlace="";this._filterPriority="";this._savedViews=[];this._activeViewId="";this._unsub=null;this._chartRangeDays=(()=>{try{let t=parseInt(Z(A.chartRange)||"",10);return[7,30,90,365].includes(t)?t:30}catch{return 30}})();this._hideOutliers=(()=>{try{return Z(A.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,seasonal:!1,environmental:!1,budget:!1,groups:!1,checklists:!1,schedule_time:!1,completion_actions:!1,places:!1};this._adminPanelUserIds=[];this._operatorWriteEnabled=!1;this._defaultWarningDays=7;this._rowActionStyle="buttons_compact";this._refsInLists=!1;this._partsCostMode="purchase";this._rowActionNotice=!1;this._actionLoading=!1;this._moreMenuOpen=!1;this._objMenuOpen=!1;this._toastMessage="";this._toastKind="error";this._toastUndo=null;this._toastActionLabel="";this._filtersOpen=!1;this._newMenuOpen=!1;this._gsSetupsCount=0;this._gsAdoptCount=0;this._gsLoaded=!1;this._resetOffersLoaded=!1;this._resetOffersCount=0;this._batteryFleetSetupAvailable=!1;this._staleBundle=!1;this._staleChecked=!1;this._toastTimer=null;this._dismissedSuggestions=new Set;this._overviewTab=(()=>{try{let t=Z(A.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=ui;this._showArchived=!1;this._bulkMode=!1;this._bulkSelected=new Set;this._objBulkMode=!1;this._objBulkSelected=new Set;this._bulkMenuOpen=!1;this._virtStart=0;this._virtEnd=0;this._virtRowHeight=53;this._virtTotalRows=0;this._virtScrollAttached=!1;this._virtRaf=0;this._stickyState=Ee;this._stickySelectPending=!1;this._stickyRaf=0;this._stickyAttached=!1;this._stickyObserver=null;this._collapsedGroups=new Set;this._collapsedSections=(()=>{try{return new Set(JSON.parse(Z(A.collapsedSections)||"[]"))}catch{return new Set}})();this._objectSectionsCollapsed=(()=>{try{let t=JSON.parse(Z(A.objectSections)||"[]");return new Set((Array.isArray(t)?t:[]).filter(e=>Cs.includes(e)))}catch{return new Set}})();this._objectSectionOverride=null;this._paletteOpen=!1;this._paletteQuery="";this._paletteActive=0;this._searchRemote=null;this._searchTimer=nul Line truncated
<a href="#" class="object-lineage-link" @click=${a=>{a.preventDefault(),this._showObject(i.entry_id)}}
>${i.object.name}</a></p>`:h}_showObject(t,e=null){this._pushPanelState("object",t),this._view="object",this._selectedEntryId=t,this._selectedTaskId=null,this._objectSectionOverride=e,e?this._scrollToObjectSection(e):this._scrollContentToTop()}_scrollToObjectSection(t){this.updateComplete.then(()=>requestAnimationFrame(()=>{let e=this.shadowRoot?.querySelector(`.obj-section[data-section="${t}"]`);e?e.scrollIntoView({block:"start",behavior:"smooth"}):this._scrollContentToTop()}))}_toggleObjectSection(t){let e=new Set(this._objectSectionsCollapsed);this._objectSectionOverride===t||!e.has(t)?e.add(t):e.delete(t),this._objectSectionOverride===t&&(this._objectSectionOverride=null),this._objectSectionsCollapsed=e,V(A.objectSections,JSON.stringify([...e]))}_splitActive(){return this.split&&!this.narrow&&!this.tight&&this._view==="overview"&&this._overviewTab==="dashboard"&&!this._bulkMode}_detailOpen(){return(this._view==="task"||this._splitActive())&&!!this._selectedEntryId&&!!this._selectedTaskId}_showFullTaskPage(t,e){this._view!=="task"&&(this._pushPanelState("task",t,e),this._view="task",this._selectedEntryId=t,this._selectedTaskId=e,this._scrollContentToTop())}_showTask(t,e){if(this._splitActive()){this._selectedEntryId=t,this._selectedTaskId=e,this._activeTab="overview",this._historyFilter=null,this._historySearch="",this._resetStickyPane(),this._fetchFullHistory(t,e);let r=this._getTask(t,e),c=gt(r?.trigger_config);r&&c&&this._fetchDetailStats(c,this._isCounterEntity(r.trigger_config));return}this._pushPanelState("task",t,e),this._view="task",this._selectedEntryId=t,this._selectedTaskId=e,this._activeTab="overview",this._historyFilter=null,this._historySearch="",this._scrollContentToTop(),this._fetchFullHistory(t,e);let i=this._getTask(t,e),a=gt(i?.trigger_config);i&&a&&this._fetchDetailStats(a,this._isCounterEntity(i.trigger_config))}_countText(t,e,i,a,r=this._lang){return a===1?s(e,r):s(t,r).replace(`{${i}}`,String(a))}_showToast(t,e="error"){this._toastTimer&&clearTimeout(this._toastTimer),this._toastKind=e,this._toastUndo=null,this._toastActionLabel="",this._toastMessage=t,this._toastTimer=setTimeout(()=>{this._toastMessage="",this._toastTimer=null},4e3)}_showActionToast(t,e,i){this._showUndoToast(t,i),this._toastActionLabel=e}_showUndoToast(t,e){this._toastTimer&&clearTimeout(this._toastTimer),this._toastKind="info",this._toastActionLabel="",this._toastMessage=t,this._toastUndo=e,this._toastTimer=setTimeout(()=>{this._toastMessage="",this._toastUndo=null,this._toastTimer=null},7e3)}_runToastUndo(){let t=this._toastUndo;this._toastTimer&&clearTimeout(this._toastTimer),this._toastMessage="",this._toastUndo=null,this._toastTimer=null,t?.()}_openPalette(){this._paletteQuery="",this._paletteActive=0,this._paletteOpen=!0,this._searchRemote=null,this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".palette-input")?.focus()})}_closePalette(){this._paletteOpen=!1,this._paletteQuery="",this._searchRemote=null,this._searchTimer&&(clearTimeout(this._searchTimer),this._searchTimer=null)}_onPaletteInput(t){this._paletteQuery=t,this._paletteActive=0,this._searchTimer&&clearTimeout(this._searchTimer);let e=t.trim();if(e.length<Re){this._searchRemote=null;return}this._searchTimer=setTimeout(()=>{this._searchTimer=null;let i=++this._searchSeq;this.hass.connection.sendMessagePromise({type:"maintenance_supporter/search",query:e,limit:Pt.documents}).then(a=>{i!==this._searchSeq||!this._paletteOpen||(this._searchRemote={query:e,documents:a.documents||[],history:a.history||[]})}).catch(()=>{i!==this._searchSeq||!this._paletteOpen||(this._searchRemote={query:e,documents:[],history:[]})})},ja)}get _paletteResults(){let t=this._lang,e=this._paletteQuery.trim();if(e.length<Re&&!ae(e))return[];let i=se(e);if(!i.length)return[];let a=[],r=[],c=[],n=ae(e);if(n){for(let m of this._objects){let v=m.object;if(v.ref_no!==n.object)continue;let y=jt(v),E=(w,j)=>w?[j,s("archived",t)].filter(Boolean).join(" \xB7 "):j;n.task==null&&a.push({kind:"object",entryId:m.entry_id,label:v.name||"",sub:E(v.archived,s("object",t)),score:1e3,icon:"mdi:package-variant-closed",ref:y});for(let w of m.tasks)n.task!=null&&w.ref_no!==n.task||r.push({kind:"task",entryId:m.entry_id,taskId:w.id,label:w.name||"",sub:E(w.archived||v.archived,v.name||""),score:n.task==null?900:1e3,icon:"mdi:clipboard-check-outline",ref:St(v,w)})}if(a.length||r.length){let m=this._searchRemote&&this._searchRemote.query===e?this._searchRemote:null,v=[...a,...r.slice(0,Pt.tasks)];for(let y of m?.history.slice(0,1)??[])v.push({kind:"history",entryId:y.entry_id,taskId:y.task_id,label:y.task_name||"",sub:[y.object_name,y.timestamp?U(y.timestamp,t):""].filter(Boolean).join(" \xB7 "),snippet:y.snippet||"",score:y.score,icon:"mdi:note-text-outline",ref:y.ref??null});return v}}for(let m of this._objects){let v=m.object;if(v.archived)continue;let y=v.name||"",E=Lt(i,[{text:y,weight:3},{text:v.manufacturer,weight:2},{text:v.model,weight:2},{text:v.serial_number,weight:2},{tLine truncated
>${i.object.name}</a></p>`:h}_showObject(t,e=null){this._pushPanelState("object",t),this._view="object",this._selectedEntryId=t,this._selectedTaskId=null,this._objectSectionOverride=e,e?this._scrollToObjectSection(e):this._scrollContentToTop()}_scrollToObjectSection(t){this.updateComplete.then(()=>requestAnimationFrame(()=>{let e=this.shadowRoot?.querySelector(`.obj-section[data-section="${t}"]`);e?e.scrollIntoView({block:"start",behavior:"smooth"}):this._scrollContentToTop()}))}_toggleObjectSection(t){let e=new Set(this._objectSectionsCollapsed);this._objectSectionOverride===t||!e.has(t)?e.add(t):e.delete(t),this._objectSectionOverride===t&&(this._objectSectionOverride=null),this._objectSectionsCollapsed=e,V(A.objectSections,JSON.stringify([...e]))}_splitActive(){return this.split&&!this.narrow&&!this.tight&&this._view==="overview"&&this._overviewTab==="dashboard"&&!this._bulkMode}_detailOpen(){return(this._view==="task"||this._splitActive())&&!!this._selectedEntryId&&!!this._selectedTaskId}_showFullTaskPage(t,e){this._view!=="task"&&(this._pushPanelState("task",t,e),this._view="task",this._selectedEntryId=t,this._selectedTaskId=e,this._scrollContentToTop())}_showTask(t,e){if(this._splitActive()){this._selectedEntryId=t,this._selectedTaskId=e,this._activeTab="overview",this._historyFilter=null,this._historySearch="",this._resetStickyPane(),this._fetchFullHistory(t,e);let r=this._getTask(t,e),c=gt(r?.trigger_config);r&&c&&this._fetchDetailStats(c,this._isCounterEntity(r.trigger_config));return}this._pushPanelState("task",t,e),this._view="task",this._selectedEntryId=t,this._selectedTaskId=e,this._activeTab="overview",this._historyFilter=null,this._historySearch="",this._scrollContentToTop(),this._fetchFullHistory(t,e);let i=this._getTask(t,e),a=gt(i?.trigger_config);i&&a&&this._fetchDetailStats(a,this._isCounterEntity(i.trigger_config))}_countText(t,e,i,a,r=this._lang){return a===1?s(e,r):s(t,r).replace(`{${i}}`,String(a))}_showToast(t,e="error"){this._toastTimer&&clearTimeout(this._toastTimer),this._toastKind=e,this._toastUndo=null,this._toastActionLabel="",this._toastMessage=t,this._toastTimer=setTimeout(()=>{this._toastMessage="",this._toastTimer=null},4e3)}_showActionToast(t,e,i){this._showUndoToast(t,i),this._toastActionLabel=e}_showUndoToast(t,e){this._toastTimer&&clearTimeout(this._toastTimer),this._toastKind="info",this._toastActionLabel="",this._toastMessage=t,this._toastUndo=e,this._toastTimer=setTimeout(()=>{this._toastMessage="",this._toastUndo=null,this._toastTimer=null},7e3)}_runToastUndo(){let t=this._toastUndo;this._toastTimer&&clearTimeout(this._toastTimer),this._toastMessage="",this._toastUndo=null,this._toastTimer=null,t?.()}_openPalette(){this._paletteQuery="",this._paletteActive=0,this._paletteOpen=!0,this._searchRemote=null,this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".palette-input")?.focus()})}_closePalette(){this._paletteOpen=!1,this._paletteQuery="",this._searchRemote=null,this._searchTimer&&(clearTimeout(this._searchTimer),this._searchTimer=null)}_onPaletteInput(t){this._paletteQuery=t,this._paletteActive=0,this._searchTimer&&clearTimeout(this._searchTimer);let e=t.trim();if(e.length<Re){this._searchRemote=null;return}this._searchTimer=setTimeout(()=>{this._searchTimer=null;let i=++this._searchSeq;this.hass.connection.sendMessagePromise({type:"maintenance_supporter/search",query:e,limit:Pt.documents}).then(a=>{i!==this._searchSeq||!this._paletteOpen||(this._searchRemote={query:e,documents:a.documents||[],history:a.history||[]})}).catch(()=>{i!==this._searchSeq||!this._paletteOpen||(this._searchRemote={query:e,documents:[],history:[]})})},Ta)}get _paletteResults(){let t=this._lang,e=this._paletteQuery.trim();if(e.length<Re&&!ae(e))return[];let i=se(e);if(!i.length)return[];let a=[],r=[],c=[],n=ae(e);if(n){for(let m of this._objects){let v=m.object;if(v.ref_no!==n.object)continue;let y=jt(v),E=(w,j)=>w?[j,s("archived",t)].filter(Boolean).join(" \xB7 "):j;n.task==null&&a.push({kind:"object",entryId:m.entry_id,label:v.name||"",sub:E(v.archived,s("object",t)),score:1e3,icon:"mdi:package-variant-closed",ref:y});for(let w of m.tasks)n.task!=null&&w.ref_no!==n.task||r.push({kind:"task",entryId:m.entry_id,taskId:w.id,label:w.name||"",sub:E(w.archived||v.archived,v.name||""),score:n.task==null?900:1e3,icon:"mdi:clipboard-check-outline",ref:St(v,w)})}if(a.length||r.length){let m=this._searchRemote&&this._searchRemote.query===e?this._searchRemote:null,v=[...a,...r.slice(0,Pt.tasks)];for(let y of m?.history.slice(0,1)??[])v.push({kind:"history",entryId:y.entry_id,taskId:y.task_id,label:y.task_name||"",sub:[y.object_name,y.timestamp?q(y.timestamp,t):""].filter(Boolean).join(" \xB7 "),snippet:y.snippet||"",score:y.score,icon:"mdi:note-text-outline",ref:y.ref??null});return v}}for(let m of this._objects){let v=m.object;if(v.archived)continue;let y=v.name||"",E=Lt(i,[{text:y,weight:3},{text:v.manufacturer,weight:2},{text:v.model,weight:2},{text:v.serial_number,weight:2},{tLine truncated
<div class="palette-backdrop" @click=${()=>this._closePalette()}>
<div class="palette" role="dialog" aria-label=${s("search_open",t)} @click=${n=>n.stopPropagation()}>
<input
@@ -5410,7 +5410,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<span class="template-card-name">${t.name}</span>
<span class="template-card-count">${t.tasks.length===1?s("templates_task_count_one",i):s("templates_task_count",i).replace("{n}",String(t.tasks.length))}</span>
${e&&t.reasons?.length?o`<span class="template-card-reasons">
${t.reasons.map(r=>o`<span class="template-card-reason">${mi(r,i,a)}</span>`)}
${t.reasons.map(r=>o`<span class="template-card-reason">${vi(r,i,a)}</span>`)}
</span>`:h}
${t.set_up?o`<span class="template-card-setup"><ha-icon icon="mdi:check-circle-outline"></ha-icon>${s("templates_set_up",i)}</span>`:h}
</button>
@@ -5448,7 +5448,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
</div>
</div>
`}_bulkKey(t){return`${t.entry_id}:${t.task_id}`}_toggleBulkMode(){this._bulkMode=!this._bulkMode,this._bulkMenuOpen=!1,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 _runBulkItems(t,e,i,a,r){if(t.length===0)return;this._actionLoading=!0;let{done:c,failed:n}=await Ei(this,t,e);this._actionLoading=!1,a(),await this._loadData();let u=Ie(i(c.length),n,this._lang);r&&c.length>0?this._showUndoToast(u,()=>r(c)):this._showToast(u,n.length>0?"error":"info")}_runBulk(t,e,i,a){return this._runBulkItems(t.filter(r=>this._bulkSelected.has(this._bulkKey(r))),e,i,()=>{this._bulkSelected=new Set,this._bulkMode=!1},a)}async _bulkMove(t){let e=this._objects.filter(c=>!c.object.archived_at).sort((c,n)=>(c.object.name||"").localeCompare(n.object.name||""));if(!e.length||this._bulkSelected.size===0)return;let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("move_task_title",this._lang),message:s("bulk_move_message",this._lang),confirmText:s("move_task_title",this._lang),inputLabel:s("move_task_target",this._lang),inputValue:e[0].entry_id,options:e.map(c=>({value:c.entry_id,label:c.object.name||c.entry_id}))});if(!a?.confirmed||!a.value)return;let r=a.value;await this._runBulk(t.filter(c=>c.entry_id!==r),c=>({type:"maintenance_supporter/task/move",entry_id:c.entry_id,task_id:c.task_id,target_entry_id:r}),c=>s("bulk_moved",this._lang).replace("{n}",String(c)))}_toggleObjBulkMode(){this._objBulkMode=!this._objBulkMode,this._objBulkMode||(this._objBulkSelected=new Set)}_toggleObjBulk(t){let e=new Set(this._objBulkSelected);e.has(t)?e.delete(t):e.add(t),this._objBulkSelected=e}_objBulkSelectAll(t){let e=t.map(a=>a.entry_id),i=e.length>0&&e.every(a=>this._objBulkSelected.has(a));this._objBulkSelected=i?new Set:new Set(e)}_runObjBulk(t,e,i,a={}){return this._runBulkItems([...this._objBulkSelected],r=>({type:t,entry_id:r,...a}),e,()=>{this._objBulkSelected=new Set,this._objBulkMode=!1},i?r=>{i(r)}:void 0)}async _objBulkDelete(){let t=this._objBulkSelected.size;t===0||!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("bulk_delete_objects_confirm",this._lang).replace("{n}",String(t)),confirmText:s("delete",this._lang),danger:!0})||await this._runObjBulk("maintenance_supporter/object/delete",a=>s("bulk_objects_deleted",this._lang).replace("{n}",String(a)))}async _objBulkArea(){let t=[...this._objBulkSelected];if(t.length===0)return;let e=Object.values(this.hass?.areas||{}).sort((c,n)=>c.name.localeCompare(n.name)),a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("area",this._lang),message:s("bulk_n_selected",this._lang).replace("{n}",String(t.length)),confirmText:s("save",this._lang),inputLabel:s("area",this._lang),inputValue:"",options:[{value:"",label:s("no_area",this._lang)},...e.map(c=>({value:c.area_id,label:c.name}))]});if(!a?.confirmed)return;let r=new Map(t.map(c=>[c,this._getObject(c)?.object.area_id??null]));this._runObjBulk("maintenance_supporter/object/update",c=>s("bulk_objects_area",this._lang).replace("{n}",String(c)),async c=>{for(let n of c)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/update",entry_id:n,area_id:r.get(n)??null})}catch{}await this._loadData()},{area_id:a.value||null})}_objBulkArchive(){this._runObjBulk("maintenance_supporter/object/archive",t=>s("bulk_objects_archived",this._lang).replace("{n}",String(t)),async t=>{for(let e of t)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/unarchive",entry_id:e})}catch{}await this._loadData()})}_renderObjBulkBar(t,e){let i=this._objBulkSelected.size,a=t.length>0&&t.every(r=>this._objBulkSelected.has(r.entry_id));return o`
`}_bulkKey(t){return`${t.entry_id}:${t.task_id}`}_toggleBulkMode(){this._bulkMode=!this._bulkMode,this._bulkMenuOpen=!1,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 _runBulkItems(t,e,i,a,r){if(t.length===0)return;this._actionLoading=!0;let{done:c,failed:n}=await Oi(this,t,e);this._actionLoading=!1,a(),await this._loadData();let u=Ie(i(c.length),n,this._lang);r&&c.length>0?this._showUndoToast(u,()=>r(c)):this._showToast(u,n.length>0?"error":"info")}_runBulk(t,e,i,a){return this._runBulkItems(t.filter(r=>this._bulkSelected.has(this._bulkKey(r))),e,i,()=>{this._bulkSelected=new Set,this._bulkMode=!1},a)}async _bulkMove(t){let e=this._objects.filter(c=>!c.object.archived_at).sort((c,n)=>(c.object.name||"").localeCompare(n.object.name||""));if(!e.length||this._bulkSelected.size===0)return;let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("move_task_title",this._lang),message:s("bulk_move_message",this._lang),confirmText:s("move_task_title",this._lang),inputLabel:s("move_task_target",this._lang),inputValue:e[0].entry_id,options:e.map(c=>({value:c.entry_id,label:c.object.name||c.entry_id}))});if(!a?.confirmed||!a.value)return;let r=a.value;await this._runBulk(t.filter(c=>c.entry_id!==r),c=>({type:"maintenance_supporter/task/move",entry_id:c.entry_id,task_id:c.task_id,target_entry_id:r}),c=>s("bulk_moved",this._lang).replace("{n}",String(c)))}_toggleObjBulkMode(){this._objBulkMode=!this._objBulkMode,this._objBulkMode||(this._objBulkSelected=new Set)}_toggleObjBulk(t){let e=new Set(this._objBulkSelected);e.has(t)?e.delete(t):e.add(t),this._objBulkSelected=e}_objBulkSelectAll(t){let e=t.map(a=>a.entry_id),i=e.length>0&&e.every(a=>this._objBulkSelected.has(a));this._objBulkSelected=i?new Set:new Set(e)}_runObjBulk(t,e,i,a={}){return this._runBulkItems([...this._objBulkSelected],r=>({type:t,entry_id:r,...a}),e,()=>{this._objBulkSelected=new Set,this._objBulkMode=!1},i?r=>{i(r)}:void 0)}async _objBulkDelete(){let t=this._objBulkSelected.size;t===0||!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("bulk_delete_objects_confirm",this._lang).replace("{n}",String(t)),confirmText:s("delete",this._lang),danger:!0})||await this._runObjBulk("maintenance_supporter/object/delete",a=>s("bulk_objects_deleted",this._lang).replace("{n}",String(a)))}async _objBulkArea(){let t=[...this._objBulkSelected];if(t.length===0)return;let e=Object.values(this.hass?.areas||{}).sort((c,n)=>c.name.localeCompare(n.name)),a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("area",this._lang),message:s("bulk_n_selected",this._lang).replace("{n}",String(t.length)),confirmText:s("save",this._lang),inputLabel:s("area",this._lang),inputValue:"",options:[{value:"",label:s("no_area",this._lang)},...e.map(c=>({value:c.area_id,label:c.name}))]});if(!a?.confirmed)return;let r=new Map(t.map(c=>[c,this._getObject(c)?.object.area_id??null]));this._runObjBulk("maintenance_supporter/object/update",c=>s("bulk_objects_area",this._lang).replace("{n}",String(c)),async c=>{for(let n of c)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/update",entry_id:n,area_id:r.get(n)??null})}catch{}await this._loadData()},{area_id:a.value||null})}_objBulkArchive(){this._runObjBulk("maintenance_supporter/object/archive",t=>s("bulk_objects_archived",this._lang).replace("{n}",String(t)),async t=>{for(let e of t)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/object/unarchive",entry_id:e})}catch{}await this._loadData()})}_renderObjBulkBar(t,e){let i=this._objBulkSelected.size,a=t.length>0&&t.every(r=>this._objBulkSelected.has(r.entry_id));return o`
<div class="bulk-bar obj-bulk-bar">
<label class="bulk-selectall">
<input type="checkbox" .checked=${a} @change=${()=>this._objBulkSelectAll(t)} />
@@ -5467,7 +5467,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</ha-button>
</span>
</div>
`}_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){this._runBulk(t,e=>({type:"maintenance_supporter/task/archive",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_archived",this._lang).replace("{n}",String(e)),async e=>{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 _bulkEdit(t,e){let i=e.filter(n=>this._bulkSelected.has(this._bulkKey(n)));if(i.length===0)return;let a=await this._ui("maintenance-bulk-edit-dialog"),r=this._userService?await this._userService.getUsers():[],c=await a?.open(t,i,r);c&&await this._sendBulkUpdate(i.map(n=>({entry_id:n.entry_id,task_id:n.task_id})),c)}async _sendBulkUpdate(t,e){let i=await P(this,{type:"maintenance_supporter/tasks/update_many",items:t,...e?{changes:e}:{}},{busy:n=>{this._actionLoading=n},onError:n=>this._showToast(n,"error")});if(!i)return;let a=e===null;a||(this._bulkSelected=new Set,this._bulkMode=!1),await this._loadData();let r=Ri(i.failed,this._lang),c=Ie(s("bulk_updated",this._lang).replace("{n}",String(i.updated.length)),r,this._lang);!a&&i.previous.length>0?this._showUndoToast(c,()=>{this._sendBulkUpdate(i.previous,null)}):this._showToast(c,r.length>0?"error":"info")}async _bulkPause(t){let e=t.filter(r=>this._bulkSelected.has(this._bulkKey(r))&&r.status!=="paused");if(e.length===0)return;let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("pause_task",this._lang),message:s("pause_task_prompt",this._lang),confirmText:s("pause_task",this._lang),inputLabel:s("pause_until_label",this._lang),inputType:"date"});a?.confirmed&&this._runBulk(e,r=>({type:"maintenance_supporter/task/pause",entry_id:r.entry_id,task_id:r.task_id,...a.value?{until:a.value}:{}}),r=>s("bulk_paused",this._lang).replace("{n}",String(r)),async r=>{for(let c of r)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/resume",entry_id:c.entry_id,task_id:c.task_id})}catch{}await this._loadData()})}_bulkResume(t){this._runBulk(t.filter(e=>e.status==="paused"),e=>({type:"maintenance_supporter/task/resume",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_resumed",this._lang).replace("{n}",String(e)))}async _runAction(t,e){let i=await P(this,t,{busy:a=>{this._actionLoading=a},reload:()=>this._loadData(),successToast:e?.successToast,onSuccess:a=>this._showToast(a,"info"),onError:a=>this._showToast(a)});return i===void 0?null:i??{}}async _deleteObject(t){if(!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("delete_object_confirm",this._lang),confirmText:s("delete",this._lang),danger:!0}))return;await this._runAction({type:"maintenance_supporter/object/delete",entry_id:t})&&this._showOverview()}_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=>It(c,i),none:"\u2014",statusLabel:c=>s(c,i),typeLabel:c=>s(c,i)},r=Xi(e.object,e.tasks,a,c=>c?U(c,i):"",c=>F(c,this._currencySymbol,i),new Date().toISOString());Jt(r)}async _duplicateObject(t){let e=await this._runAction({type:"maintenance_supporter/object/duplicate",entry_id:t},{successToast:s("object_duplicated",this._lang)});e?.entry_id&&this._showObject(e.entry_id)}async _deleteTask(t,e){if(!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("delete_task_confirm",this._lang),confirmText:s("delete",this._lang),danger:!0}))return;await this._runAction({type:"maintenance_supporter/task/delete",entry_id:t,task_id:e})&&this._showObject(t)}async _duplicateTask(t,e){this._moreMenuOpen=!1;let i=await this._runAction({type:"maintenance_supporter/task/duplicate",entry_id:t,task_id:e},{successToast:s("task_duplicated",this._lang)});i?.task_id&&this._showTask(t,i.task_id)}async _moveTask(t,e){this._moreMenuOpen=!1;let i=this._objects.filter(n=>n.entry_id!==t&&!n.object.archived_at).sort((n,u)=>(n.object.name||"").localeCompare(u.object.name||""));if(!i.length)return;let r=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("move_task_title",this._lang),message:s("move_task_message",this._lang),confirmText:s("move_task_title",this._lang),inputLabel:s("move_task_target",this Line truncated
`}_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){this._runBulk(t,e=>({type:"maintenance_supporter/task/archive",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_archived",this._lang).replace("{n}",String(e)),async e=>{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 _bulkEdit(t,e){let i=e.filter(n=>this._bulkSelected.has(this._bulkKey(n)));if(i.length===0)return;let a=await this._ui("maintenance-bulk-edit-dialog"),r=this._userService?await this._userService.getUsers():[],c=await a?.open(t,i,r);c&&await this._sendBulkUpdate(i.map(n=>({entry_id:n.entry_id,task_id:n.task_id})),c)}async _sendBulkUpdate(t,e){let i=await P(this,{type:"maintenance_supporter/tasks/update_many",items:t,...e?{changes:e}:{}},{busy:n=>{this._actionLoading=n},onError:n=>this._showToast(n,"error")});if(!i)return;let a=e===null;a||(this._bulkSelected=new Set,this._bulkMode=!1),await this._loadData();let r=Ci(i.failed,this._lang),c=Ie(s("bulk_updated",this._lang).replace("{n}",String(i.updated.length)),r,this._lang);!a&&i.previous.length>0?this._showUndoToast(c,()=>{this._sendBulkUpdate(i.previous,null)}):this._showToast(c,r.length>0?"error":"info")}async _bulkPause(t){let e=t.filter(r=>this._bulkSelected.has(this._bulkKey(r))&&r.status!=="paused");if(e.length===0)return;let a=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("pause_task",this._lang),message:s("pause_task_prompt",this._lang),confirmText:s("pause_task",this._lang),inputLabel:s("pause_until_label",this._lang),inputType:"date"});a?.confirmed&&this._runBulk(e,r=>({type:"maintenance_supporter/task/pause",entry_id:r.entry_id,task_id:r.task_id,...a.value?{until:a.value}:{}}),r=>s("bulk_paused",this._lang).replace("{n}",String(r)),async r=>{for(let c of r)try{await this.hass.connection.sendMessagePromise({type:"maintenance_supporter/task/resume",entry_id:c.entry_id,task_id:c.task_id})}catch{}await this._loadData()})}_bulkResume(t){this._runBulk(t.filter(e=>e.status==="paused"),e=>({type:"maintenance_supporter/task/resume",entry_id:e.entry_id,task_id:e.task_id}),e=>s("bulk_resumed",this._lang).replace("{n}",String(e)))}async _runAction(t,e){let i=await P(this,t,{busy:a=>{this._actionLoading=a},reload:()=>this._loadData(),successToast:e?.successToast,onSuccess:a=>this._showToast(a,"info"),onError:a=>this._showToast(a)});return i===void 0?null:i??{}}async _deleteObject(t){if(!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("delete_object_confirm",this._lang),confirmText:s("delete",this._lang),danger:!0}))return;await this._runAction({type:"maintenance_supporter/object/delete",entry_id:t})&&this._showOverview()}_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=>It(c,i),none:"\u2014",statusLabel:c=>s(c,i),typeLabel:c=>s(c,i)},r=ts(e.object,e.tasks,a,c=>c?q(c,i):"",c=>U(c,this._currencySymbol,i),new Date().toISOString());Jt(r)}async _duplicateObject(t){let e=await this._runAction({type:"maintenance_supporter/object/duplicate",entry_id:t},{successToast:s("object_duplicated",this._lang)});e?.entry_id&&this._showObject(e.entry_id)}async _deleteTask(t,e){if(!await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete",this._lang),message:s("delete_task_confirm",this._lang),confirmText:s("delete",this._lang),danger:!0}))return;await this._runAction({type:"maintenance_supporter/task/delete",entry_id:t,task_id:e})&&this._showObject(t)}async _duplicateTask(t,e){this._moreMenuOpen=!1;let i=await this._runAction({type:"maintenance_supporter/task/duplicate",entry_id:t,task_id:e},{successToast:s("task_duplicated",this._lang)});i?.task_id&&this._showTask(t,i.task_id)}async _moveTask(t,e){this._moreMenuOpen=!1;let i=this._objects.filter(n=>n.entry_id!==t&&!n.object.archived_at).sort((n,u)=>(n.object.name||"").localeCompare(u.object.name||""));if(!i.length)return;let r=await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.prompt({title:s("move_task_title",this._lang),message:s("move_task_message",this._lang),confirmText:s("move_task_title",this._lang),inputLabel:s("move_task_target",this Line truncated
<div class="panel">
${this._staleBundle?o`
<div class="update-banner" role="status">
@@ -5559,7 +5559,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${this._renderTemplateGallery()}
`}_renderSearchButton(t){let e=this._lang;return o`<ha-icon-button
class=${t}
.path=${Sa}
.path=${Ea}
.label=${s("search_open",e)}
title=${s("search_open",e)}
@click=${()=>this._openPalette()}
@@ -5669,7 +5669,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<div class="today-main">
<div class="today-task">${this._listRef(c.entry_id,c.task_id)}${c.task_name}${Ut(c.next_event_titles)}</div>
<div class="today-object">
<span class="today-object-text">${c.object_name} · ${vt(c.days_until_due,a)}</span>
<span class="today-object-text">${c.object_name} · ${xt(c.days_until_due,a)}</span>
${Ae(r(c),"today-person")}
</div>
</div>
@@ -5719,7 +5719,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
@change=${d=>{this._filterStatus=d.target.value,this._activeViewId=""}}
>
<option value="">${s("all",i)}</option>
${Es.map(d=>o`<option value=${d} ?selected=${this._filterStatus===d}>${s(d,i)}</option>`)}
${Os.map(d=>o`<option value=${d} ?selected=${this._filterStatus===d}>${s(d,i)}</option>`)}
</select>
</label>
<label class="filter-field">
@@ -5931,7 +5931,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
`})}
</div>
`}_toggleGroup(t){let e=new Set(this._collapsedGroups);e.has(t)?e.delete(t):e.add(t),this._collapsedGroups=e}_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}",U(e,i))}_renderWarrantyMeta(t,e){let i=qe(t);return o`<p class="meta">${s("warranty",e)}:
`}_toggleGroup(t){let e=new Set(this._collapsedGroups);e.has(t)?e.delete(t):e.add(t),this._collapsedGroups=e}_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}",q(e,i))}_renderWarrantyMeta(t,e){let i=qe(t);return o`<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(d=>d.object.archived).length,r=d=>{let g=1/0;for(let m of d.tasks){let v=m.days_until_due;v!=null&&v<g&&(g=v)}return g},c=this._objects.filter(d=>this._showArchived||!d.object.archived);this._objectSortMode==="alphabetical"?c.sort((d,g)=>d.object.name.localeCompare(g.object.name)):this._objectSortMode==="task_count"?c.sort((d,g)=>g.tasks.length-d.tasks.length||d.object.name.localeCompare(g.object.name)):c.sort((d,g)=>r(d)-r(g)||d.object.name.localeCompare(g.object.name));let n=()=>{let d=new Map;for(let g of c){let m=g.object.area_id,v=m?this.hass?.areas?.[m]?.name||s("unassigned",t):s("no_area",t);d.has(v)||d.set(v,[]),d.get(v).push(g)}return new Map([...d.entries()].sort(([g],[m])=>g.localeCompare(m)))},u=d=>{let g=d.tasks.some(m=>m.status==="overdue"||m.status==="triggered");return o`
<div class="object-card${g?" object-card-overdue":""}${this._objBulkMode?" selectable":""}${this._objBulkMode&&this._objBulkSelected.has(d.entry_id)?" bulk-selected":""}"
@click=${()=>this._objBulkMode?this._toggleObjBulk(d.entry_id):this._showObject(d.entry_id)}>
@@ -5941,7 +5941,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${g?o`<span class="overdue-dot" title="${s("has_overdue",t)}"></span>`:h}
<div class="object-card-header">
<span class="object-card-name">${this._objRef(d.object)}${d.object.name}</span>
${d.object.paused?o`<span class="paused-badge" title="${s("object_paused_badge",t)}${d.object.paused_until?` \u2014 ${U(d.object.paused_until,t)}`:""}">
${d.object.paused?o`<span class="paused-badge" title="${s("object_paused_badge",t)}${d.object.paused_until?` \u2014 ${q(d.object.paused_until,t)}`:""}">
<ha-icon icon="mdi:pause-circle-outline"></ha-icon>
</span>`:h}
${d.object.document_count?o`<span class="doc-badge" title="${d.object.document_count} ${s("documents",t)}">
@@ -6085,7 +6085,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
<td>${a.object_name||"\u2014"}</td>
<td>${a.stock!==null?Gt(a.stock,a.unit,t):"\u2014"}</td>
<td>${a.reorder_threshold??"\u2014"}</td>
<td>${a.cost!=null?a.package_size?`${F(a.cost,i,t)} / ${Gt(a.package_size,a.unit??void 0,t)}`:F(a.cost,i,t):"\u2014"}</td>
<td>${a.cost!=null?a.package_size?`${U(a.cost,i,t)} / ${Gt(a.package_size,a.unit??void 0,t)}`:U(a.cost,i,t):"\u2014"}</td>
<td>${a.storage_location||"\u2014"}</td>
<td>
${a.consumers.length===0?"\u2014":a.consumers.map(r=>o`
@@ -6139,14 +6139,14 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
@open-object=${e=>this._showObject(e.detail.entryId)}
@open-task=${e=>this._showTask(e.detail.entryId,e.detail.taskId)}
></maintenance-area-view>
`}_exportPartsCsv(){let t=this._allParts||[],e=c=>{let n=c==null?"":String(c);return/[",\n;]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},a=[["name","object","stock","unit","reorder_threshold","unit_cost","storage_location","vendor","used_by"].join(",")];for(let c of t)a.push([e(c.name),e(c.object_name),e(c.stock),e(c.unit),e(c.reorder_threshold),e(c.cost),e(c.storage_location),e(c.vendor),e(c.consumers.map(n=>`${n.object_name??""}/${n.task_name??n.task_id}\xD7${n.quantity}`).join(" | "))].join(","));let r=xt();Me(a.join(`
`),`maintenance_parts_${r}.csv`,"text/csv;charset=utf-8")}async _exportObjectsCsv(){let t=await P(this,{type:"maintenance_supporter/objects/csv"},{onError:i=>this._showToast(i)});if(!t)return;let e=xt();Me(t.csv,`maintenance_objects_${e}.csv`,"text/csv;charset=utf-8")}_renderObjectsTable(t){let e=this._lang,i=this._objectsTableColumns;return o`
`}_exportPartsCsv(){let t=this._allParts||[],e=c=>{let n=c==null?"":String(c);return/[",\n;]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},a=[["name","object","stock","unit","reorder_threshold","unit_cost","storage_location","vendor","used_by"].join(",")];for(let c of t)a.push([e(c.name),e(c.object_name),e(c.stock),e(c.unit),e(c.reorder_threshold),e(c.cost),e(c.storage_location),e(c.vendor),e(c.consumers.map(n=>`${n.object_name??""}/${n.task_name??n.task_id}\xD7${n.quantity}`).join(" | "))].join(","));let r=yt();Me(a.join(`
`),`maintenance_parts_${r}.csv`,"text/csv;charset=utf-8")}async _exportObjectsCsv(){let t=await P(this,{type:"maintenance_supporter/objects/csv"},{onError:i=>this._showToast(i)});if(!t)return;let e=yt();Me(t.csv,`maintenance_objects_${e}.csv`,"text/csv;charset=utf-8")}_renderObjectsTable(t){let e=this._lang,i=this._objectsTableColumns;return o`
<div class="objects-table-wrap">
<table class="objects-table">
<thead>
<tr>
${this._objBulkMode?o`<th class="oc-bulk"></th>`:h}
${i.map(a=>{let r=di.find(n=>n.key===a),c=r&&r.key!=="actions"?s(r.labelKey,e):"";return o`<th class="oc-${a}">${c}</th>`})}
${i.map(a=>{let r=hi.find(n=>n.key===a),c=r&&r.key!=="actions"?s(r.labelKey,e):"";return o`<th class="oc-${a}">${c}</th>`})}
</tr>
</thead>
<tbody>
@@ -6166,7 +6166,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${a.document_count?o`<span class="doc-badge" title="${a.document_count} ${s("documents",i)}">
<ha-icon icon="mdi:paperclip"></ha-icon>${a.document_count}
</span>`:h}
</td>`;case"manufacturer":return o`<td class="oc-manufacturer">${a.manufacturer||"\u2014"}</td>`;case"model":return o`<td class="oc-model">${a.model||"\u2014"}</td>`;case"serial_number":return o`<td class="oc-serial_number">${a.serial_number||"\u2014"}</td>`;case"installation_date":return o`<td class="oc-installation_date">${a.installation_date?U(a.installation_date,i):"\u2014"}</td>`;case"warranty_expiry":return o`<td class="oc-warranty_expiry">${this._renderWarrantyCell(a.warranty_expiry,i)}</td>`;case"area_id":{let r=a.area_id?this.hass?.areas?.[a.area_id]?.name||a.area_id:"\u2014";return o`<td class="oc-area_id">${r}</td>`}case"documentation_url":{let r=(a.manual_docs||[])[0];return o`<td class="oc-documentation_url">${st(a.documentation_url)?o`<a href=${a.documentation_url} target="_blank" rel="noopener noreferrer"
</td>`;case"manufacturer":return o`<td class="oc-manufacturer">${a.manufacturer||"\u2014"}</td>`;case"model":return o`<td class="oc-model">${a.model||"\u2014"}</td>`;case"serial_number":return o`<td class="oc-serial_number">${a.serial_number||"\u2014"}</td>`;case"installation_date":return o`<td class="oc-installation_date">${a.installation_date?q(a.installation_date,i):"\u2014"}</td>`;case"warranty_expiry":return o`<td class="oc-warranty_expiry">${this._renderWarrantyCell(a.warranty_expiry,i)}</td>`;case"area_id":{let r=a.area_id?this.hass?.areas?.[a.area_id]?.name||a.area_id:"\u2014";return o`<td class="oc-area_id">${r}</td>`}case"documentation_url":{let r=(a.manual_docs||[])[0];return o`<td class="oc-documentation_url">${st(a.documentation_url)?o`<a href=${a.documentation_url} target="_blank" rel="noopener noreferrer"
@click=${c=>c.stopPropagation()}><ha-icon icon="mdi:file-document-outline"></ha-icon></a>`:r?o`<a href="#" title=${r.title}
@click=${c=>{c.preventDefault(),c.stopPropagation(),this._openManualDoc(r)}}
><ha-icon icon="mdi:file-document-outline"></ha-icon></a>`:"\u2014"}</td>`}case"notes":return o`<td class="oc-notes" title=${a.notes||""}>${a.notes||"\u2014"}</td>`;case"task_count":return o`<td class="oc-task_count">${e.tasks.length}</td>`;case"ref_no":return o`<td class="oc-ref_no">${jt(a)?`#${jt(a)}`:"\u2014"}</td>`;case"actions":return o`<td class="oc-actions">
@@ -6206,15 +6206,15 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
`}
</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){await this.shadowRoot.querySelector("maintenance-confirm-dialog")?.confirm({title:s("delete_group",this._lang),message:s("delete_group_confirm",this._lang).replace("{name}",e),confirmText:s("delete",this._lang),danger:!0})&&await this._runAction({type:"maintenance_supporter/group/delete",group_id:t})}_renderBudgetTiles(){let t=this._budget;if(!t)return h;let e=this._lang,i=this._currencySymbol,a=(r,c,n)=>{if(n!==null){let u=Math.min(100,Math.max(0,c/n*100)),d=u>=100?"var(--error-color, #f44336)":u>=t.alert_threshold_pct?"var(--warning-color, #ff9800)":"var(--success-color, #4caf50)";return o`
<div class="stat-item budget-tile" title="${r}: ${F(c,i,e)} / ${F(n,i,e)}">
<span class="stat-value budget-tile-value">${F(c,i,e)}</span>
<span class="budget-tile-max">/ ${F(n,i,e)}</span>
<div class="stat-item budget-tile" title="${r}: ${U(c,i,e)} / ${U(n,i,e)}">
<span class="stat-value budget-tile-value">${U(c,i,e)}</span>
<span class="budget-tile-max">/ ${U(n,i,e)}</span>
<div class="budget-tile-bar"><div style="width:${u}%; background:${d}"></div></div>
<span class="stat-label">${r}</span>
</div>
`}return o`
<div class="stat-item budget-tile" title="${r}: ${F(c,i,e)}">
<span class="stat-value budget-tile-value">${F(c,i,e)}</span>
<div class="stat-item budget-tile" title="${r}: ${U(c,i,e)}">
<span class="stat-value budget-tile-value">${U(c,i,e)}</span>
<span class="stat-label">${r}</span>
</div>
`};return o`
@@ -6255,14 +6255,14 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</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">${vt(t.days_until_due,e)}</span>
${Qe(t.days_until_due,t.last_performed,e)}
${i?o`<div class="days-bar"><div class="days-bar-fill${c?" overflow":""}" style="width:${a}%;background:${r}"></div></div>`:h}
${t.trigger_config?Ge(t,{trend:We(t,this._miniStatsData),lang:e}):!i&&t.trigger_active?o`<span style="color:var(--maint-triggered-color);font-weight:600">⚡</span>`:h}
${Ye(t,this._miniStatsData,this._lang)}
</span>
${this._renderRowActions(e,()=>this._openCompleteDialogForRow(t),()=>this._promptSkipTask(t.entry_id,t.task_id),t.allow_skip)}
</div>
`}_actionStyle(){return this._rowActionStyle}async _dismissRowActionNotice(t){let e={row_action_notice_pending:!1};t&&(e.row_action_style="icons"),await P(this,{type:"maintenance_supporter/global/update",settings:e},{onError:a=>this._showToast(a)})!==void 0&&(this._rowActionNotice=!1,t&&(this._rowActionStyle="icons"),Ii())}_renderRowActions(t,e,i,a=!0){let r=this._actionStyle();return r==="buttons"||r==="buttons_compact"?r==="buttons_compact"&&(this.narrow||this.tight)?o`
`}_actionStyle(){return this._rowActionStyle}async _dismissRowActionNotice(t){let e={row_action_notice_pending:!1};t&&(e.row_action_style="icons"),await P(this,{type:"maintenance_supporter/global/update",settings:e},{onError:a=>this._showToast(a)})!==void 0&&(this._rowActionNotice=!1,t&&(this._rowActionStyle="icons"),Pi())}_renderRowActions(t,e,i,a=!0){let r=this._actionStyle();return r==="buttons"||r==="buttons_compact"?r==="buttons_compact"&&(this.narrow||this.tight)?o`
<span class="row-actions as-buttons compact">
<ha-button size="small" appearance="accent" variant="success" title="${s("complete",t)}" aria-label="${s("complete",t)}" @click=${n=>{n.stopPropagation(),e()}}>
<ha-icon icon="mdi:check"></ha-icon>
@@ -6321,7 +6321,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
</div>
${e.paused?o`<p class="meta paused-meta">
<ha-icon icon="mdi:pause-circle-outline"></ha-icon>
${s("object_paused_badge",i)}${e.paused_until?o` — ${s("paused_until_label",i)} ${U(e.paused_until,i)}`:h}
${s("object_paused_badge",i)}${e.paused_until?o` — ${s("paused_until_label",i)} ${q(e.paused_until,i)}`:h}
</p>`:h}
${e.manufacturer||e.model?o`<p class="meta">${[e.manufacturer,e.model].filter(Boolean).join(" ")}</p>`:h}
${e.serial_number?o`<p class="meta">${s("serial_number_label",i)}: ${e.serial_number}</p>`:h}
@@ -6341,7 +6341,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${e.manual_docs.slice(0,3).map((n,u)=>o`${u>0?" \xB7 ":""}<a href="#"
@click=${d=>{d.preventDefault(),this._openManualDoc(n)}}>${n.title}</a>`)}${e.manual_docs.length>3?o` … +${e.manual_docs.length-3}`:h}
</p>`:h}
${e.installation_date?o`<p class="meta">${s("installed",i)}: ${U(e.installation_date,i)}</p>`:h}
${e.installation_date?o`<p class="meta">${s("installed",i)}: ${q(e.installation_date,i)}</p>`:h}
${e.warranty_expiry?this._renderWarrantyMeta(e.warranty_expiry,i):h}
${e.notes?o`<div class="object-notes">
<div class="object-notes-label">${s("object_notes_label",i)}</div>
@@ -6370,10 +6370,10 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
${n.document_count?o`<span class="doc-badge" title="${n.document_count} ${s("documents",i)}"><ha-icon icon="mdi:paperclip"></ha-icon>${n.document_count}</span>`:h}
</span>
<span class="cell task-name" @click=${()=>this._showTask(t.entry_id,n.id)}>${this._listRef(t.entry_id,n.id)}${n.name}${Ut(n.next_event_titles)}</span>
<span class="task-sub${n.responsible_user_id?"":" task-sub-empty"}">${Qe(n,u=>this._userService?.getUserName(u)??null,u=>this._userService?.getPerson(u)??null)}</span>
<span class="task-sub${n.responsible_user_id?"":" task-sub-empty"}">${Je(n,u=>this._userService?.getUserName(u)??null,u=>this._userService?.getPerson(u)??null)}</span>
<span class="cell type">${s(n.type,i)}</span>
<span class="due-cell" @click=${()=>this._showTask(t.entry_id,n.id)}>
<span class="due-text">${vt(n.days_until_due,i)}</span>
${Qe(n.days_until_due,n.last_performed,i)}
${n.trigger_config?Ge(n,{trend:We(n,this._miniStatsData),lang:i}):h}
${Ye(n,this._miniStatsData,this._lang)}
</span>
@@ -6474,7 +6474,7 @@ ${c.capped?`<p class="cap-note">${$(t.capNote)}</p>`:""}
`)}
</div>
</div>
`}_toggleObjMenu(){this._togglePopup(()=>this._objMenuOpen,t=>{this._objMenuOpen=t})}_closeObjMenu(){this._objMenuOpen=!1}_toggleMoreMenu(){this._togglePopup(()=>this._moreMenuOpen,t=>{this._moreMenuOpen=t})}_closeMoreMenu(){this._moreMenuOpen=!1}get _sparklineCtx(){return{lang:this._lang,detailStatsData:this._detailStatsData,hasStatsService:!!this._statsService,historyFallbackIds:this._statsService?.historyFallbackIds,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{V(A.collapsedSections,JSON.stringify([...e]))}catch{}}_historyCtx(){let t=this._selectedEntryId&&this._selectedTaskId?this._getObject(this._selectedEntryId)?.tasks.find(r=>r.id===this._selectedTaskId):void 0,e=this._fullHistory,i=e&&e.entryId===this._selectedEntryId&&e.taskId===this._selectedTaskId&&e.entries.length>(t?.history||[]).length?e.entries:t?.history||[],a=i.filter(r=>r.reading_value!=null).sort((r,c)=>r.timestamp.localeCompare(c.timestamp));return{lang:this._lang,hass:this.hass,filter:this._historyFilter,search:this._historySearch,currencySymbol:this._currencySymbol,setFilter:r=>{this._historyFilter=r},setSearch:r=>{this._historySearch=r},openEdit:this._isOperator?void 0:r=>this._openHistoryEdit(r),readingUnit:t?.reading_unit??null,taskRef:St(this._selectedEntryId?this._getObject(this._selectedEntryId)?.object:null,t),phaseNames:Object.fromEntries(Object.entries(t?.phases||{}).map(([r,c])=>[r,c.name])),readingDelta:r=>{let c=a.findIndex(n=>n.timestamp===r.timestamp);return c<=0?null:r.reading_value-a[c-1].reading_value},readingSlotDelta:(r,c)=>fi(i,r,c)}}_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||"",taskRef:St(i?.object,i?.tasks.find(a=>a.id===e)),objectDocUrl:i?.object?.documentation_url??null,objectManualDocs:i?.object?.manual_docs??[],openManualDoc:a=>this._openManualDoc(a),setChecklistItem:(a,r)=>this._setChecklistItem(t,e,a,r),setPhaseCursor:a=>{this._runAction({type:"maintenance_supporter/task/set_phase",entry_id:t,task_id:e,cursor:a})},isOperator:this._isOperator,actionLoading:this._actionLoading,moreMenuOpen:this._moreMenuOpen,activeTab:this._activeTab,features:this._features,currencySymbol:this._currencySymbol,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,getPerson:a=>this._userService?.getPerson(a)??null,setActiveTab:a=>{this._activeTab=a},toggleSection:a=>this._toggleSection(a),setCostDurationToggle:a=>{this._costDurationToggle=a},showTaskView:()=>this._showFullTaskPage(t,e),showObject:()=>this._showObject(t),toggleMoreMenu:()=>this._toggleMoreMenu(),closeMoreMenu:()=>this._closeMoreMenu(),openEdit:a=>{this._ui("maintenance-task-dialog").then(r=>r?.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),togglePause:a=>this._togglePauseTask(t,e,a),openQr:a=>this._openQrForTask(t,e,i?.object.name||"",a),duplicateTask:()=>this._duplicateTask(t,e),moveTask:()=>this._moveTask(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 h;let t=this._getTask(this._selectedEntryId,this._selectedTaskId);if(!t)return o`<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 o`<maintenance-task-detail-view
`}_toggleObjMenu(){this._togglePopup(()=>this._objMenuOpen,t=>{this._objMenuOpen=t})}_closeObjMenu(){this._objMenuOpen=!1}_toggleMoreMenu(){this._togglePopup(()=>this._moreMenuOpen,t=>{this._moreMenuOpen=t})}_closeMoreMenu(){this._moreMenuOpen=!1}get _sparklineCtx(){return{lang:this._lang,detailStatsData:this._detailStatsData,hasStatsService:!!this._statsService,historyFallbackIds:this._statsService?.historyFallbackIds,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{V(A.collapsedSections,JSON.stringify([...e]))}catch{}}_historyCtx(){let t=this._selectedEntryId&&this._selectedTaskId?this._getObject(this._selectedEntryId)?.tasks.find(r=>r.id===this._selectedTaskId):void 0,e=this._fullHistory,i=e&&e.entryId===this._selectedEntryId&&e.taskId===this._selectedTaskId&&e.entries.length>(t?.history||[]).length?e.entries:t?.history||[],a=i.filter(r=>r.reading_value!=null).sort((r,c)=>r.timestamp.localeCompare(c.timestamp));return{lang:this._lang,hass:this.hass,filter:this._historyFilter,search:this._historySearch,currencySymbol:this._currencySymbol,setFilter:r=>{this._historyFilter=r},setSearch:r=>{this._historySearch=r},openEdit:this._isOperator?void 0:r=>this._openHistoryEdit(r),readingUnit:t?.reading_unit??null,taskRef:St(this._selectedEntryId?this._getObject(this._selectedEntryId)?.object:null,t),phaseNames:Object.fromEntries(Object.entries(t?.phases||{}).map(([r,c])=>[r,c.name])),readingDelta:r=>{let c=a.findIndex(n=>n.timestamp===r.timestamp);return c<=0?null:r.reading_value-a[c-1].reading_value},readingSlotDelta:(r,c)=>bi(i,r,c)}}_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||"",taskRef:St(i?.object,i?.tasks.find(a=>a.id===e)),objectDocUrl:i?.object?.documentation_url??null,objectManualDocs:i?.object?.manual_docs??[],openManualDoc:a=>this._openManualDoc(a),setChecklistItem:(a,r)=>this._setChecklistItem(t,e,a,r),setPhaseCursor:a=>{this._runAction({type:"maintenance_supporter/task/set_phase",entry_id:t,task_id:e,cursor:a})},isOperator:this._isOperator,actionLoading:this._actionLoading,moreMenuOpen:this._moreMenuOpen,activeTab:this._activeTab,features:this._features,currencySymbol:this._currencySymbol,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,getPerson:a=>this._userService?.getPerson(a)??null,setActiveTab:a=>{this._activeTab=a},toggleSection:a=>this._toggleSection(a),setCostDurationToggle:a=>{this._costDurationToggle=a},showTaskView:()=>this._showFullTaskPage(t,e),showObject:()=>this._showObject(t),toggleMoreMenu:()=>this._toggleMoreMenu(),closeMoreMenu:()=>this._closeMoreMenu(),openEdit:a=>{this._ui("maintenance-task-dialog").then(r=>r?.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),togglePause:a=>this._togglePauseTask(t,e,a),openQr:a=>this._openQrForTask(t,e,i?.object.name||"",a),duplicateTask:()=>this._duplicateTask(t,e),moveTask:()=>this._moveTask(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 h;let t=this._getTask(this._selectedEntryId,this._selectedTaskId);if(!t)return o`<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 o`<maintenance-task-detail-view
.task=${i}
.ctx=${this._taskDetailCtx()}
></maintenance-task-detail-view>`}_openHistoryEdit(t){if(!this._selectedEntryId||!this._selectedTaskId)return;let e=this._getTask(this._selectedEntryId,this._selectedTaskId),i=zi(this._selectedEntryId,this._selectedTaskId,t,e);this.shadowRoot?.querySelector("maintenance-history-edit-dialog")?.openEdit(i)}};k.styles=[ne,es],_([R({attribute:!1})],k.prototype,"hass",2),_([R({type:Boolean,reflect:!0})],k.prototype,"narrow",2),_([R({type:Boolean,reflect:!0})],k.prototype,"tight",2),_([R({type:Boolean,reflect:!0})],k.prototype,"split",2),_([R({attribute:!1})],k.prototype,"panel",2),_([R({type:Boolean,reflect:!0})],k.prototype,"embedded",2),_([R({attribute:!1})],k.prototype,"presets",2),_([f()],k.prototype,"_objects",2),_([f()],k.prototype,"_stats",2),_([f()],k.prototype,"_view",2),_([f()],k.prototype,"_allParts",2),_([f()],k.prototype,"_selectedEntryId",2),_([f()],k.prototype,"_selectedTaskId",2),_([f()],k.prototype,"_selectedAreaId",2),_([f()],k.prototype,"_filterStatus",2),_([f()],k.prototype,"_filterUser",2),_([f()],k.prototype,"_filterLabel",2),_([f()],k.prototype,"_filterPlace",2),_([f()],k.prototype,"_filterPriority",2),_([f()],k.prototype,"_savedViews",2),_([f()],k.prototype,"_activeViewId",2),_([f()],k.prototype,"_unsub",2),_([f()],k.prototype,"_chartRangeDays",2),_([f()],k.prototype,"_hideOutliers",2),_([f()],k.prototype,"_historyFilter",2),_([f()],k.prototype,"_budget",2),_([f()],k.prototype,"_groups",2),_([f()],k.prototype,"_detailStatsData",2),_([f()],k.prototype,"_miniStatsData",2),_([f()],k.prototype,"_features",2),_([f()],k.prototype,"_adminPanelUserIds",2),_([f()],k.prototype,"_operatorWriteEnabled",2),_([f()],k.prototype,"_defaultWarningDays",2),_([f()],k.prototype,"_rowActionStyle",2),_([f()],k.prototype,"_refsInLists",2),_([f()],k.prototype,"_partsCostMode",2),_([f()],k.prototype,"_rowActionNotice",2),_([f()],k.prototype,"_actionLoading",2),_([f()],k.prototype,"_moreMenuOpen",2),_([f()],k.prototype,"_objMenuOpen",2),_([f()],k.prototype,"_toastMessage",2),_([f()],k.prototype,"_toastKind",2),_([f()],k.prototype,"_toastUndo",2),_([f()],k.prototype,"_toastActionLabel",2),_([f()],k.prototype,"_filtersOpen",2),_([f()],k.prototype,"_newMenuOpen",2),_([f()],k.prototype,"_gsSetupsCount",2),_([f()],k.prototype,"_gsAdoptCount",2),_([f()],k.prototype,"_resetOffersCount",2),_([f()],k.prototype,"_batteryFleetSetupAvailable",2),_([f()],k.prototype,"_staleBundle",2),_([f()],k.prototype,"_overviewTab",2),_([f()],k.prototype,"_activeTab",2),_([f()],k.prototype,"_costDurationToggle",2),_([f()],k.prototype,"_historySearch",2),_([f()],k.prototype,"_sortMode",2),_([f()],k.prototype,"_objectSortMode",2),_([f()],k.prototype,"_groupByMode",2),_([f()],k.prototype,"_objectViewMode",2),_([f()],k.prototype,"_objectsTableColumns",2),_([f()],k.prototype,"_showArchived",2),_([f()],k.prototype,"_bulkMode",2),_([f()],k.prototype,"_bulkSelected",2),_([f()],k.prototype,"_objBulkMode",2),_([f()],k.prototype,"_objBulkSelected",2),_([f()],k.prototype,"_bulkMenuOpen",2),_([f()],k.prototype,"_virtStart",2),_([f()],k.prototype,"_virtEnd",2),_([f()],k.prototype,"_collapsedGroups",2),_([f()],k.prototype,"_collapsedSections",2),_([f()],k.prototype,"_objectSectionsCollapsed",2),_([f()],k.prototype,"_objectSectionOverride",2),_([f()],k.prototype,"_paletteOpen",2),_([f()],k.prototype,"_paletteQuery",2),_([f()],k.prototype,"_paletteActive",2),_([f()],k.prototype,"_searchRemote",2),_([f()],k.prototype,"_templateGalleryOpen",2),_([f()],k.prototype,"_templates",2),_([f()],k.prototype,"_homeProfile",2),_([f()],k.prototype,"_templateCategories",2),_([f()],k.prototype,"_templateBusy",2),_([f()],k.prototype,"_fullHistory",2),k=_([Ze("maintenance-supporter-panel")],k);export{k as MaintenanceSupporterPanel};
></maintenance-task-detail-view>`}_openHistoryEdit(t){if(!this._selectedEntryId||!this._selectedTaskId)return;let e=this._getTask(this._selectedEntryId,this._selectedTaskId),i=Li(this._selectedEntryId,this._selectedTaskId,t,e);this.shadowRoot?.querySelector("maintenance-history-edit-dialog")?.openEdit(i)}};k.styles=[ne,ss],_([R({attribute:!1})],k.prototype,"hass",2),_([R({type:Boolean,reflect:!0})],k.prototype,"narrow",2),_([R({type:Boolean,reflect:!0})],k.prototype,"tight",2),_([R({type:Boolean,reflect:!0})],k.prototype,"split",2),_([R({attribute:!1})],k.prototype,"panel",2),_([R({type:Boolean,reflect:!0})],k.prototype,"embedded",2),_([R({attribute:!1})],k.prototype,"presets",2),_([f()],k.prototype,"_objects",2),_([f()],k.prototype,"_stats",2),_([f()],k.prototype,"_view",2),_([f()],k.prototype,"_allParts",2),_([f()],k.prototype,"_selectedEntryId",2),_([f()],k.prototype,"_selectedTaskId",2),_([f()],k.prototype,"_selectedAreaId",2),_([f()],k.prototype,"_filterStatus",2),_([f()],k.prototype,"_filterUser",2),_([f()],k.prototype,"_filterLabel",2),_([f()],k.prototype,"_filterPlace",2),_([f()],k.prototype,"_filterPriority",2),_([f()],k.prototype,"_savedViews",2),_([f()],k.prototype,"_activeViewId",2),_([f()],k.prototype,"_unsub",2),_([f()],k.prototype,"_chartRangeDays",2),_([f()],k.prototype,"_hideOutliers",2),_([f()],k.prototype,"_historyFilter",2),_([f()],k.prototype,"_budget",2),_([f()],k.prototype,"_groups",2),_([f()],k.prototype,"_detailStatsData",2),_([f()],k.prototype,"_miniStatsData",2),_([f()],k.prototype,"_features",2),_([f()],k.prototype,"_adminPanelUserIds",2),_([f()],k.prototype,"_operatorWriteEnabled",2),_([f()],k.prototype,"_defaultWarningDays",2),_([f()],k.prototype,"_rowActionStyle",2),_([f()],k.prototype,"_refsInLists",2),_([f()],k.prototype,"_partsCostMode",2),_([f()],k.prototype,"_rowActionNotice",2),_([f()],k.prototype,"_actionLoading",2),_([f()],k.prototype,"_moreMenuOpen",2),_([f()],k.prototype,"_objMenuOpen",2),_([f()],k.prototype,"_toastMessage",2),_([f()],k.prototype,"_toastKind",2),_([f()],k.prototype,"_toastUndo",2),_([f()],k.prototype,"_toastActionLabel",2),_([f()],k.prototype,"_filtersOpen",2),_([f()],k.prototype,"_newMenuOpen",2),_([f()],k.prototype,"_gsSetupsCount",2),_([f()],k.prototype,"_gsAdoptCount",2),_([f()],k.prototype,"_resetOffersCount",2),_([f()],k.prototype,"_batteryFleetSetupAvailable",2),_([f()],k.prototype,"_staleBundle",2),_([f()],k.prototype,"_overviewTab",2),_([f()],k.prototype,"_activeTab",2),_([f()],k.prototype,"_costDurationToggle",2),_([f()],k.prototype,"_historySearch",2),_([f()],k.prototype,"_sortMode",2),_([f()],k.prototype,"_objectSortMode",2),_([f()],k.prototype,"_groupByMode",2),_([f()],k.prototype,"_objectViewMode",2),_([f()],k.prototype,"_objectsTableColumns",2),_([f()],k.prototype,"_showArchived",2),_([f()],k.prototype,"_bulkMode",2),_([f()],k.prototype,"_bulkSelected",2),_([f()],k.prototype,"_objBulkMode",2),_([f()],k.prototype,"_objBulkSelected",2),_([f()],k.prototype,"_bulkMenuOpen",2),_([f()],k.prototype,"_virtStart",2),_([f()],k.prototype,"_virtEnd",2),_([f()],k.prototype,"_collapsedGroups",2),_([f()],k.prototype,"_collapsedSections",2),_([f()],k.prototype,"_objectSectionsCollapsed",2),_([f()],k.prototype,"_objectSectionOverride",2),_([f()],k.prototype,"_paletteOpen",2),_([f()],k.prototype,"_paletteQuery",2),_([f()],k.prototype,"_paletteActive",2),_([f()],k.prototype,"_searchRemote",2),_([f()],k.prototype,"_templateGalleryOpen",2),_([f()],k.prototype,"_templates",2),_([f()],k.prototype,"_homeProfile",2),_([f()],k.prototype,"_templateCategories",2),_([f()],k.prototype,"_templateBusy",2),_([f()],k.prototype,"_fullHistory",2),k=_([ti("maintenance-supporter-panel")],k);export{k as MaintenanceSupporterPanel};