${n("history_edit_title",e)}
${w(l.name)}
-${w(t.title)} \xB7 ${w(t.generated)}: ${w(e(a))}
- ${r.length?``:""} -${w(t.tasksHeading)} (${p.length})
+${$(l.name)}
+${$(t.title)} \xB7 ${$(t.generated)}: ${$(e(a))}
+ ${r.length?``:""} +${$(t.tasksHeading)} (${p.length})
| ${w(t.colTask)} | ${w(t.colType)} | ${w(t.colStatus)} | -${w(t.colSchedule)} | ${w(t.colLastDone)} | ${w(t.colNextDue)} | -${w(t.colTimes)} | ${w(t.colCost)} | +${$(t.colTask)} | ${$(t.colType)} | ${$(t.colStatus)} | +${$(t.colSchedule)} | ${$(t.colLastDone)} | ${$(t.colNextDue)} | +${$(t.colTimes)} | ${$(t.colCost)} |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ${w(t.none)} | |||||||||||||||
| ${w(t.totalCost)} | ${w(i(n))} | ||||||||||||||
| ${$(t.none)} | |||||||||||||||
| ${$(t.totalCost)} | ${$(i(n))} | ||||||||||||||
${w(t.title)} \u2014 ${w(l.name)}
-${w(t.generated)} ${w(e(r))} \xB7 ${w(t.entriesLabel(g.length))}
-${C?``:""} +${$(t.title)} \u2014 ${$(l.name)}
+${$(t.generated)} ${$(e(r))} \xB7 ${$(t.entriesLabel(g.length))}
+${E?``:""} ${pt} -${c.capped?`${w(t.capNote)}
`:""} +${c.capped?`${$(t.capNote)}
`:""} -`}var Ns=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={...we};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={...we,...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 xi(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>=yi)}_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:jt(this.object,u),schedule:At(u,i)||null,documents:a.filter(d=>(d.task_ids||[]).includes(u.id)&&!Xi(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,Ns),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 ne(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=ce();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?ue(d.notes,e):null})),u=es(i,n,c,d=>d?U(d,e):"",d=>Gt(d,e),d=>F(d,this.currencySymbol,e),new Date().toISOString(),{capped:this._capped,options:{layout:this._printLayout,include:this._printInclude},data:{objectRef:$t(i),tasks:r.tasks,photos:r.photos,fmtNumber:d=>Y(d,e)}});Qt(u,a)}_renderPrintOptions(t){let e=this._lang,i=this._printInclude,a=(c,n,u=!1)=>o` +