import{r as i,d as t,h as s,B as o}from"./p-03169580.js";import{t as e}from"./p-c5cf028c.js";import{g as l}from"./p-e9a3b467.js";import{s as a}from"./p-46225039.js";import"./p-4cb16df5.js";import"./p-7cbdb4ea.js";import"./p-bd8b186e.js";import"./p-795b799a.js";import"./p-3a8e6af1.js";import"./p-59c95c5f.js";import"./p-c9699503.js";const n="";let d=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=false;this.signed=false}async onChange(i){var t;if(((t=i===null||i===void 0?void 0:i.target)===null||t===void 0?void 0:t.name)==="signature"){const t=await i.target.toDataURL();if(t.length<=10){alert("Signature is required to submit!");return}this.loading=true;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,l;if(((t=i===null||i===void 0?void 0:i.detail)===null||t===void 0?void 0:t.endpoint)==="signContract"){this.presentToast();this.loading=false;this.signed=true}else if(((s=i.detail)===null||s===void 0?void 0:s.endpoint)==="findJob"){this.loading=false}else if(((o=i.detail)===null||o===void 0?void 0:o.endpoint)==="findTemplate"){this.template=((l=(e=i.detail)===null||e===void 0?void 0:e.data)===null||l===void 0?void 0:l.template)?i.detail.data.template:null}}async fetchJob(){if(!this.jobId)return;this.fireenjinFetch.emit({endpoint:"findJob",params:{id:this.jobId,withPayments:false,withUsers:true,withSites:false,withPayModel:false,withPhotos:false,withEfiles:false,withPayables:false,withReadings:false}})}async presentToast(){const i=await e.create({message:`File(s) added successfully to Efile!`,duration:2e3});i.present()}componentDidLoad(){{this.fetchJob();setTimeout((()=>{this.forceResize.emit({})}),1e3)}}render(){var i,t,e;return[s("ion-content",{class:"ion-padding"},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",{class:{"is-loading":this.loading}},(o===null||o===void 0?void 0:o.isBrowser)&&s("fireenjin-render-template",{template:(t=(i=a===null||a===void 0?void 0:a.templates)===null||i===void 0?void 0:i.find)===null||t===void 0?void 0:t.call(i,(i=>(i===null||i===void 0?void 0:i.id)===this.templateId)),partials:((e=a===null||a===void 0?void 0:a.templates)===null||e===void 0?void 0:e.length)?a.templates.filter((i=>!!(i===null||i===void 0?void 0:i.partial))).map((i=>({html:(i===null||i===void 0?void 0:i.html)||"",id:(i===null||i===void 0?void 0:i.id)||null}))):[],data:{timestamp:(new Date).toISOString(),job:a===null||a===void 0?void 0:a.job,user:a===null||a===void 0?void 0:a.profile},helpers:l()}),s("floodteam-signature-pad",{ref:i=>this.signaturePadEl=i,style:{margin:"0 auto",display:"block"}}))),s("floodteam-navigation-footer",null)]}};d.style=n;export{d as app_sign};
//# sourceMappingURL=p-40e9cc79.entry.js.map