import{r as t,d as i,B as s,h as e}from"./p-03169580.js";import{t as o}from"./p-3bc4f2ce.js";import{s as n}from"./p-02c5cd3a.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";import"./p-59c95c5f.js";import"./p-c9699503.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-3a8e6af1.js";let a=class{constructor(s){t(this,s);this.fireenjinSubmit=i(this,"fireenjinSubmit",7);this.floodteamCloseModal=i(this,"floodteamCloseModal",7);this.headerTitle="E-sign";this.loading=false;this.signed=false;this.isLoaded=false}onModalPresent(){this.isLoaded=true}async onChange(t){var i;if(((i=t===null||t===void 0?void 0:t.target)===null||i===void 0?void 0:i.name)==="signature"){const i=await t.target.toDataURL();if(i.length<=10){alert("Signature is required to submit!");return}this.loading=true;this.fireenjinSubmit.emit({endpoint:"signContract",data:{jobId:this.jobId,signature:await t.target.toDataURL(),templateId:this.templateId}})}}async onSuccess(t){var i,s;if(((i=t===null||t===void 0?void 0:t.detail)===null||i===void 0?void 0:i.endpoint)==="signContract"){this.presentToast();this.loading=false;this.signed=true;this.floodteamCloseModal.emit()}else if(((s=t.detail)===null||s===void 0?void 0:s.endpoint)==="findJob"){this.loading=false}}async presentToast(){const t=await o.create({message:`File(s) added successfully to Efile!`,duration:2e3});t.present()}componentDidLoad(){if(!(s===null||s===void 0?void 0:s.isBrowser))return;try{this.templateEl.querySelector("fireenjin-render-template").shadowRoot.querySelector(".contract-header").remove();this.templateEl.querySelector("fireenjin-render-template").shadowRoot.querySelector(".contract-footer").remove()}catch(t){console.log(t)}}render(){return[e("ion-header",null,e("ion-toolbar",null,e("ion-title",null,this.headerTitle),e("ion-buttons",{slot:"end"},e("ion-button",{onClick:()=>this.floodteamCloseModal.emit()},e("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),e("ion-content",{class:{"ion-padding":true,"is-loading":this.loading}},this.signed?e("div",{style:{width:"90%",maxWidth:"500px",margin:"0 auto"}},e("ion-icon",{name:"checkmark-circle",color:"success",style:{height:"150px",width:"150px",display:"block",margin:"30px auto"}}),e("h1",null,"Signature Submitted!"),e("p",null,"Thank you for your time, you can now close this browser tab.")):e("div",null,e("floodteam-template",{ref:t=>this.templateEl=t,class:"fullscreen",templateId:this.templateId,data:{timestamp:(new Date).toISOString(),job:this.job,user:n===null||n===void 0?void 0:n.profile}}))),this.isLoaded&&e("floodteam-signature-pad",{class:{"is-loading":this.loading},ref:t=>this.signaturePadEl=t})]}};export{a as modal_esign};
//# sourceMappingURL=p-00cd3a6e.entry.js.map