import{r as i,e as t,h as s}from"./p-a89095f5.js";import{t as o}from"./p-3e7f0e42.js";import{s as e}from"./p-188ef7e9.js";import"./p-29ec504c.js";import"./p-8cd54418.js";import"./p-d7f93824.js";import"./p-2a0c7fc9.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";const n=class{constructor(s){i(this,s),this.fireenjinSubmit=t(this,"fireenjinSubmit",7),this.floodteamCloseModal=t(this,"floodteamCloseModal",7),this.jobId=void 0,this.efileId=void 0,this.templateId=void 0,this.headerTitle="E-sign",this.job=void 0,this.userSignId=void 0,this.loading=!1,this.signed=!1,this.isLoaded=!1}onModalPresent(){this.isLoaded=!0}async onChange(i){var t,s;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:{efileId:this.efileId,jobId:this.jobId,user:this.userSignId,signatures:[{data:await i.target.toDataURL(),userId:this.userSignId||(null===(s=null==e?void 0:e.session)||void 0===s?void 0:s.uid)}],templateId:this.templateId}})}}async onSuccess(i){var t,s;"signContract"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint)?(this.presentToast(),this.loading=!1,this.signed=!0,this.floodteamCloseModal.emit()):"findJob"===(null===(s=i.detail)||void 0===s?void 0:s.endpoint)&&(this.loading=!1)}async presentToast(){(await o.create({message:"File(s) added successfully to Efile!",duration:2e3})).present()}render(){return setTimeout((()=>{try{this.templateEl.querySelector(".contract-header").remove(),this.templateEl.querySelector(".contract-footer").remove()}catch(i){console.log(i)}}),1e3),[s("ion-header",null,s("ion-toolbar",null,s("ion-title",null,this.headerTitle),s("ion-buttons",{slot:"end"},s("ion-button",{onClick:()=>this.floodteamCloseModal.emit()},s("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),s("ion-content",{class:{"ion-padding":!0,"is-loading":this.loading}},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",null,s("floodteam-template",{ref:i=>this.templateEl=i,class:"fullscreen",templateId:this.templateId,data:{timestamp:(new Date).toISOString(),job:this.job,user:null==e?void 0:e.profile}}))),this.isLoaded&&s("floodteam-signature-pad",{class:{"is-loading":this.loading},ref:i=>this.signaturePadEl=i})]}};export{n as modal_esign}