import{r as i,d as t,h as s}from"./p-f8363b1b.js";import{t as o}from"./p-510e3bc9.js";import{s as e}from"./p-c78d1e1b.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-5717491f.js";import"./p-de14d315.js";const a=class{constructor(s){i(this,s),this.fireenjinFetch=t(this,"fireenjinFetch",7),this.fireenjinSubmit=t(this,"fireenjinSubmit",7),this.forceResize=t(this,"forceResize",7),this.loading=!1,this.signed=!1}async onChange(i){var t;if("signature"===(null===(t=null==i?void 0:i.target)||void 0===t?void 0:t.name)){if((await i.target.toDataURL()).length<=10)return void alert("Signature is required to submit!");this.loading=!0,this.fireenjinSubmit.emit({endpoint:"signContract",data:{jobId:this.jobId,signature:await i.target.toDataURL(),templateId:this.templateId}})}}async onSuccess(i){var t,s,o,e;"signContract"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint)?(this.presentToast(),this.loading=!1,this.signed=!0):"findTemplate"===(null===(s=i.detail)||void 0===s?void 0:s.endpoint)&&(this.template=(null===(e=null===(o=i.detail)||void 0===o?void 0:o.data)||void 0===e?void 0:e.template)?i.detail.data.template:null)}async fetchJob(){this.jobId&&this.fireenjinFetch.emit({endpoint:"findJob",params:{id:this.jobId,withPayments:!1,withUsers:!0,withSites:!1,withPayModel:!1,withPhotos:!1,withEfiles:!1,withPayables:!1,withReadings:!1}})}async presentToast(){(await o.create({message:"File(s) added successfully to Efile!",duration:2e3})).present()}componentDidLoad(){this.fetchJob(),setTimeout((()=>{this.forceResize.emit({})}),1e3)}render(){var i;return[s("ion-content",{class:"ion-padding"},s("floodteam-title-bar",{back:(null===(i=null==e?void 0:e.session)||void 0===i?void 0:i.uid)?`/jobs/${this.jobId}`:"/"},"E-Sign"),this.signed?s("div",{style:{width:"90%",maxWidth:"500px",margin:"0 auto"}},s("ion-icon",{name:"checkmark-circle",color:"success",style:{height:"150px",width:"150px",display:"block",margin:"30px auto"}}),s("h1",null,"Signature Submitted!"),s("p",null,"Thank you for your time, you can now close this browser tab.")):s("div",{style:{position:"relative"},class:{"is-loading":this.loading}},s("floodteam-template",{style:{padding:"60px 2em"},disablePositioning:!0,templateId:this.templateId,data:{timestamp:(new Date).toISOString(),job:e.job,user:null==e?void 0:e.profile}}),s("floodteam-signature-pad",{ref:i=>this.signaturePadEl=i}))),s("floodteam-navigation-footer",null)]}};a.style="";export{a as app_sign}