import{r as o,d as i,B as t,h as n}from"./p-03169580.js";import{s as e}from"./p-29293869.js";import"./p-59c95c5f.js";import"./p-1930048e.js";function l(o){const i={amountDeducted:(o===null||o===void 0?void 0:o.amountDeducted)||0,amountOwed:(o===null||o===void 0?void 0:o.amountOwed)||0,amountPaid:(o===null||o===void 0?void 0:o.amountPaid)||0,general:0,levels:{},sites:{}};for(const t of(o===null||o===void 0?void 0:o.services)||[]){i.general=i.general+((t===null||t===void 0?void 0:t.total)||0)}for(const t of(o===null||o===void 0?void 0:o.sites)||[]){if(!i.sites[t===null||t===void 0?void 0:t.id])i.sites[t.id]=0;if(!i.levels[(t===null||t===void 0?void 0:t.level)||0])i.levels[(t===null||t===void 0?void 0:t.level)||0]=0;for(const t of o.sites||[]){for(const o of(t===null||t===void 0?void 0:t.services)||[]){i.sites[t.id]=i.sites[t.id]+((o===null||o===void 0?void 0:o.total)||0);i.levels[(t===null||t===void 0?void 0:t.level)||0]=i.levels[(t===null||t===void 0?void 0:t.level)||0]+((o===null||o===void 0?void 0:o.total)||0)}}}return i}const s="app-scope ion-infinite-scroll-content{display:none}";let d=class{constructor(t){o(this,t);this.fireenjinTrigger=i(this,"fireenjinTrigger",7);this.fireenjinFetch=i(this,"fireenjinFetch",7);this.floodteamOpenModal=i(this,"floodteamOpenModal",7)}async fetchJob(){if(!this.jobId)return;this.fireenjinFetch.emit({endpoint:"findJob",params:{id:this.jobId,withPayments:false,withUsers:true,withSites:true,withPayModel:true,withPhotos:true,withEfiles:true,withPayables:false,withReadings:true}})}async componentDidLoad(){if(!(t===null||t===void 0?void 0:t.isBrowser))return;this.fireenjinTrigger.emit({name:"subscribe",payload:{collection:"jobs",id:this.jobId,callback:()=>{this.fetchJob()}}});this.fetchJob()}disconnectedCallback(){e.job=null;e.site=null;this.fireenjinTrigger.emit({name:"unsubscribe",payload:{collection:"jobs",id:this.jobId}})}render(){return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",{back:`/jobs/${this.jobId}`},n("ion-text",null,"Scope"),n("ion-buttons",{slot:"end"},n("ion-button",{fill:"outline",size:"small",onClick:()=>this.floodteamOpenModal.emit({component:"modal-render-template",componentProps:{templateId:"tA7FCnTudK0Sd887IeuU",headerTitle:"Invoice",data:{job:e.job,totals:l(e.job)}}})},"Preview Invoice"))),n("floodteam-form-scope",{jobId:this.jobId})),n("floodteam-navigation-footer",null)]}};d.style=s;export{d as app_scope};
//# sourceMappingURL=p-b2a62cfd.entry.js.map