import{r as i,d as t,h as e}from"./p-846bd001.js";import{f as o}from"./p-98c700d1.js";import{f as l}from"./p-cf4a3445.js";const s=class{constructor(e){i(this,e),this.fireenjinSubmit=t(this,"fireenjinSubmit",7),this.siteId=void 0,this.name=void 0,this.serviceId=void 0,this.jobId=void 0,this.unit=void 0,this.siteServiceId=void 0,this.isGeneral=!1,this.site=void 0,this.amount=0,this.quantity=1,this.price=0,this.notes=void 0,this.showNotes=!1}onSuccess(i){var t,e,o,l,s;"deleteScopeService"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint)?(this.amount=0,this.quantity=1,this.siteServiceId=null):"addScopeService"===(null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.endpoint)&&(this.siteServiceId=null===(s=null===(l=null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.data)||void 0===l?void 0:l.addScopeService)||void 0===s?void 0:s.id)}onReset(i){this.fireenjinSubmit.emit({endpoint:"deleteScopeService",event:i,data:{id:this.siteServiceId,siteId:this.siteId,jobId:this.jobId}})}render(){var i,t,s,n;return e("ion-accordion",{value:`${this.isGeneral?this.jobId:this.siteId}-${this.serviceId}`},e("ion-item",{slot:"header",style:{"--background":"var(--background-color)"}},e("ion-label",null,e("h2",null,this.name||(this.isGeneral?"General Service":"No Site Name")),this.siteServiceId?e("ion-text",{color:"primary"},e("b",null,this.amount||0," ",(null==this?void 0:this.unit)||"")," ","x ",e("b",null,this.quantity||1," Qty")," x"," ",e("b",null,l(this.price||0))):e("p",null,"Click to Add")),e("ion-text",{color:"success",slot:"end"},this.siteServiceId&&e("small",null,l(parseFloat(this.amount||0)*parseFloat(this.quantity||1)*parseFloat(this.price||0))))),e("fireenjin-form",{slot:"content",disableLoader:!0,name:`siteService-${this.siteId}-${this.serviceId}`,resetButton:"Remove",resetButtonColor:"danger",disableReset:!0,endpoint:this.siteServiceId?"editScopeService":"addScopeService",beforeSubmit:async i=>{const t={jobId:this.jobId,siteId:this.siteId,...this.siteServiceId?{id:this.siteServiceId}:{serviceId:this.serviceId},price:parseFloat((null==i?void 0:i.price)||this.price||0),quantity:parseFloat((null==i?void 0:i.quantity)||this.quantity||1),amount:parseFloat((null==i?void 0:i.amount)||this.amount||1),notes:i.notes||this.notes||null};if(null==i?void 0:i.price)try{t.price=parseFloat((null==i?void 0:i.price)||0)}catch(i){console.log("Error setting price: ",i)}return t}},e("ion-grid",{class:"ion-no-padding"},e("ion-row",{class:"ion-no-padding"},e("ion-col",{size:"6",sizeXs:"4"},e("fireenjin-input",{type:"number",name:"amount",value:this.amount||0,label:"Amount",labelPosition:"stacked",min:"0",step:"0.01"})),e("ion-col",{size:"6",sizeXs:"4"},e("fireenjin-input",{type:"number",name:"quantity",value:this.quantity||1,label:"Quantity",labelPosition:"stacked",min:"1"})),e("ion-col",{size:"12",sizeXs:"4"},e("fireenjin-input",{type:"number",name:"price",value:this.price||0,label:"Price",labelPosition:"stacked",step:"0.01",min:"0"}))),e("ion-row",null,e("ion-col",null,e("fireenjin-chip-bar",null,e("ion-button",{shape:"round",fill:"clear",size:"small",color:"primary",onClick:()=>this.showNotes=!this.showNotes},e("ion-icon",{name:"chatbox"})),[{label:"Affected Sqft",value:Math.round(100*(null===(i=this.site)||void 0===i?void 0:i.affectedAreaTotalSqft))/100},{label:"Affected CuSqft",value:Math.round(100*(null===(t=this.site)||void 0===t?void 0:t.affectedAreaTotalCuft))/100},{label:"Total Sqft",value:Math.round(100*(null===(s=this.site)||void 0===s?void 0:s.areaTotalSqft))/100},{label:"Total CuSqft",value:Math.round(100*(null===(n=this.site)||void 0===n?void 0:n.areaTotalCuft))/100}].filter((i=>(null==i?void 0:i.value)>0)).map((i=>e("ion-chip",{onClick:()=>this.amount=(null==i?void 0:i.value)||0},(null==i?void 0:i.label)||""," - ",o((null==i?void 0:i.value)||0))))))),e("ion-row",{style:{display:this.showNotes?"block":"none"}},e("ion-col",null,e("fireenjin-input",{name:"notes",placeholder:"Service Notes",maxlength:200,value:this.notes}))))))}};export{s as floodteam_form_site_service}