import{r as t,d as i,h as s}from"./p-9b6cc562.js";import{t as o}from"./p-a4d32aeb.js";import{s as e}from"./p-889c70e7.js";import"./p-24c4a299.js";import"./p-8cd54418.js";import"./p-e5527167.js";import"./p-95e9f2f6.js";import"./p-86bd3473.js";import"./p-65879f9e.js";import"./p-60cf0cc2.js";const n=class{constructor(s){t(this,s),this.fireenjinSubmit=i(this,"fireenjinSubmit",7),this.floodteamCloseModal=i(this,"floodteamCloseModal",7),this.jobId=void 0,this.templateId=void 0,this.headerTitle="E-sign",this.job=void 0,this.loading=!1,this.signed=!1,this.isLoaded=!1}onModalPresent(){this.isLoaded=!0}async onChange(t){var i;if("signature"===(null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.name)){if((await t.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 t.target.toDataURL(),templateId:this.templateId}})}}async onSuccess(t){var i,s;"signContract"===(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.endpoint)?(this.presentToast(),this.loading=!1,this.signed=!0,this.floodteamCloseModal.emit()):"findJob"===(null===(s=t.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(t){console.log(t)}}),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:t=>this.templateEl=t,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:t=>this.signaturePadEl=t})]}};export{n as modal_esign}