import{r as i,d as l,B as o,h as e}from"./p-03169580.js";import{t as n}from"./p-c5cf028c.js";import{s as t}from"./p-ac5f2e11.js";import"./p-4cb16df5.js";import"./p-7cbdb4ea.js";import"./p-59c95c5f.js";import"./p-c9699503.js";import"./p-bd8b186e.js";import"./p-795b799a.js";import"./p-3a8e6af1.js";const a=".modal-send-email-wrapper{--min-width:300px}modal-send-email ion-item-divider{--padding-start:0px}modal-send-email fireenjin-avatar{margin-left:16px}modal-send-email h5,modal-send-email p{display:block;--ion-color-step-600:#666666;font-size:0.9em}modal-send-email ion-button{display:table;margin-left:0px;margin:0 auto}";let d=class{constructor(o){i(this,o);this.floodteamCloseModal=l(this,"floodteamCloseModal",7);this.to=[];this.from="info@thefloodteam.com";this.attachments=[];this.users=[];this.hideTemplateSelect=false}onChange(i){var l;if(((l=i===null||i===void 0?void 0:i.target)===null||l===void 0?void 0:l.name)==="templateId"){this.templateId=i.target.value}}async onSuccess(i){var l;if(((l=i.detail)===null||l===void 0?void 0:l.endpoint)==="sendTemplateEmail"){const i=document.querySelector("ion-modal.modal-send-email-wrapper");if(i===null||i===void 0?void 0:i.dismiss){await i.dismiss();this.presentToast()}}}async presentToast(){const i=await n.create({message:"Your emails are on their way.",duration:2e3});i.present()}onBeforeSubmit(i){return{templateId:(i===null||i===void 0?void 0:i.templateId)?i.templateId:this.templateId?this.templateId:null,attachments:this.attachments,from:(i===null||i===void 0?void 0:i.from)?i.from:this.from?this.from:"info@thefloodteam.com",emails:(i===null||i===void 0?void 0:i.to)?i.to:this.to?this.to:[],filters:this.filters?this.filters:null}}componentWillLoad(){if(!(o===null||o===void 0?void 0:o.isBrowser))return}render(){return[e("ion-header",null,e("ion-toolbar",null,e("ion-title",null,"Send Email"),e("ion-buttons",{slot:"end"},e("ion-button",{onClick:()=>this.formEl.submit(),color:"primary",fill:"solid"},"Send"),e("ion-button",{onClick:()=>this.floodteamCloseModal.emit(),style:{"--color":"var(--ion-text-color)","--color-hover":"var(--ion-color-danger"}},e("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),e("ion-content",{style:{"--background":"var(--ion-color-base)"}},e("fireenjin-form",{ref:i=>this.formEl=i,endpoint:"sendTemplateEmail",disableEnterButton:true,hideControls:true,beforeSubmit:this.onBeforeSubmit.bind(this)},e("ion-grid",null,e("ion-row",null,e("ion-col",{size:"12",sizeMd:"7"},!this.hideTemplateSelect&&e("fireenjin-select",{ref:i=>this.templateSelectEl=i,name:"templateId",label:"Template",labelPosition:"stacked",placeholder:"Select Message Template",value:this.templateId,options:((t===null||t===void 0?void 0:t.templates)||[]).filter((i=>!(i===null||i===void 0?void 0:i.partial)&&(i===null||i===void 0?void 0:i.type)==="email"&&(!this.templateFilter||this.templateFilter(i)))).map((i=>({label:i===null||i===void 0?void 0:i.subject,value:i===null||i===void 0?void 0:i.id})))}),e("fireenjin-select-tags",{name:"to",label:"Send To",labelPosition:"stacked",placeholder:"Add Emails",allowAdding:true,value:this.to,options:(this.users||[]).map((i=>({label:(i===null||i===void 0?void 0:i.email)||`${i===null||i===void 0?void 0:i.firstName} ${i===null||i===void 0?void 0:i.lastName} has no Email on File.`,value:i===null||i===void 0?void 0:i.email,disabled:!(i===null||i===void 0?void 0:i.email)})))})),e("ion-col",{size:"12",sizeMd:"5"},this.templateId&&e("floodteam-template",{id:"email-preview",zoom:.3,templateId:this.templateId,data:this.payload||{job:(t===null||t===void 0?void 0:t.job)||null}}))),e("ion-row",null,e("ion-col",null,e("fireenjin-chip-bar",null,(this.attachments||[]).map((i=>{var l,o,n,t,a,d;return e("ion-chip",null,e("ion-icon",{name:"document",class:"ft-icon-style"}),e("ion-label",null,decodeURI(((d=(a=(t=(n=(o=(l=i===null||i===void 0?void 0:i.split)===null||l===void 0?void 0:l.call(i,"/"))===null||o===void 0?void 0:o.pop)===null||n===void 0?void 0:n.call(o))===null||t===void 0?void 0:t.split)===null||a===void 0?void 0:a.call(t,"?"))===null||d===void 0?void 0:d[0])||"No File Name")))})))))),e("ion-accordion-group",null,e("ion-accordion",null,e("ion-item",{slot:"header"},e("ion-label",null,"Advanced")),e("ion-grid",{slot:"content"},e("ion-row",null,e("ion-col",null,e("fireenjin-input",{name:"subject",label:"Subject",labelPosition:"stacked",placeholder:"Email Subject",value:this.subject}))),e("ion-row",null,e("ion-col",null,e("fireenjin-input",{name:"from",label:"Email From",labelPosition:"stacked",placeholder:"Email Address to Send From",value:this.from})),e("ion-col",null,e("fireenjin-input",{name:"replyTo",label:"Reply To",labelPosition:"stacked",placeholder:"Email Address to Reply",value:this.replyTo}))))))))]}};d.style=a;export{d as modal_send_email};
//# sourceMappingURL=p-a3381f25.entry.js.map