import{r as i,d as o,h as l}from"./p-03169580.js";import{j as d,l as t}from"./p-c2fbed0d.js";import"./p-80de33dc.js";const v=".popover-site-service{--min-width:300px;--offset-y:-50px}popover-site-service ion-accordion-group{background:var(--background-color) !important;--ion-item-background:var(--background-color);--background:var(--background-color);background-color:var(--background-color) !important}popover-site-service ion-list ion-item{--ion-item-background:transparent}popover-site-service fireenjin-input ion-label{font-size:12px !important}";let n=class{constructor(l){i(this,l);this.fireenjinFetch=o(this,"fireenjinFetch",7);this.service={};this.scopeToServiceMap={};this.sites=[]}async onSuccess(i){var o;if(["editScopeService","addScopeService","deleteScopeService"].includes((o=i===null||i===void 0?void 0:i.detail)===null||o===void 0?void 0:o.endpoint)){this.accordionEl.requestAccordionToggle(null,false)}}getAutoFillValue(i,o,l={},v){var n,e,s,r,u,c,a;let h=v;try{h=((e=(n=this.scopeToServiceMap)===null||n===void 0?void 0:n[i])===null||e===void 0?void 0:e[o])||((r=(s=this.service)===null||s===void 0?void 0:s.autofill)===null||r===void 0?void 0:r[o])&&((u=d===null||d===void 0?void 0:t.apply)===null||u===void 0?void 0:u.call(d,(a=(c=this.service)===null||c===void 0?void 0:c.autofill)===null||a===void 0?void 0:a[o],l||{}))||v}catch(i){console.log(`Error applying json logic to ${o}: `,this.service.id,i)}return h}render(){var i,o,d,t,v,n,e,s,r,u,c,a,h,p;const m=((d=(o=(i=this.service)===null||i===void 0?void 0:i.tab)===null||o===void 0?void 0:o.toLowerCase)===null||d===void 0?void 0:d.call(o))==="general";const $={service:this.service,job:this.job};return[l("ion-content",null,l("ion-item-divider",null,((t=this.service)===null||t===void 0?void 0:t.name)||"No Name Given"),l("ion-accordion-group",{ref:i=>this.accordionEl=i,value:this.currentExpanded},m?l("floodteam-form-site-service",{isGeneral:true,serviceId:(v=this.service)===null||v===void 0?void 0:v.id,jobId:this.jobId,siteServiceId:((s=(n=this.scopeToServiceMap)===null||n===void 0?void 0:n[`${this.jobId}-${(e=this.service)===null||e===void 0?void 0:e.id}`])===null||s===void 0?void 0:s.id)||null,amount:this.getAutoFillValue(`${this.jobId}-${(r=this.service)===null||r===void 0?void 0:r.id}`,"amount",$,0),price:this.getAutoFillValue(`${this.jobId}-${(u=this.service)===null||u===void 0?void 0:u.id}`,"price",$,(a=(c=this.service)===null||c===void 0?void 0:c.prices)===null||a===void 0?void 0:a.default),quantity:this.getAutoFillValue(`${this.jobId}-${(h=this.service)===null||h===void 0?void 0:h.id}`,"quantity",$,1),unit:(p=this.service)===null||p===void 0?void 0:p.unit}):(this.sites||[]).sort(((i,o)=>(i===null||i===void 0?void 0:i.name)>(o===null||o===void 0?void 0:o.name)?1:-1)).map((i=>{var o,d,t,v,n,e,s,r,u,c;return l("floodteam-form-site-service",{siteId:i===null||i===void 0?void 0:i.id,jobId:this.jobId,serviceId:(o=this.service)===null||o===void 0?void 0:o.id,siteServiceId:((v=(d=this.scopeToServiceMap)===null||d===void 0?void 0:d[`${i===null||i===void 0?void 0:i.id}-${(t=this.service)===null||t===void 0?void 0:t.id}`])===null||v===void 0?void 0:v.id)||null,amount:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(n=this.service)===null||n===void 0?void 0:n.id}`,"amount",{...$,site:i},0),price:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(e=this.service)===null||e===void 0?void 0:e.id}`,"price",{...$,site:i},(r=(s=this.service)===null||s===void 0?void 0:s.prices)===null||r===void 0?void 0:r.default),quantity:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(u=this.service)===null||u===void 0?void 0:u.id}`,"quantity",{...$,site:i},1),name:i===null||i===void 0?void 0:i.name,unit:(c=this.service)===null||c===void 0?void 0:c.unit})}))))]}};n.style=v;export{n as popover_site_service};
//# sourceMappingURL=p-10495039.entry.js.map