import{r as i,d as e,B as l,h as o}from"./p-03169580.js";import{t as n}from"./p-5a032a89.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";const t=".fireenjin-mx-modal-send-email-wrapper{--min-width:300px}fireenjin-mx-modal-send-email ion-item-divider{--padding-start:0px}fireenjin-mx-modal-send-email fireenjin-avatar{margin-left:16px}fireenjin-mx-modal-send-email h5,fireenjin-mx-modal-send-email p{display:block;--ion-color-step-600:#666666;font-size:0.9em}fireenjin-mx-modal-send-email ion-button{display:table;margin-left:0px;margin:0 auto}fireenjin-mx-modal-send-email fireenjin-render-template#email-preview{color:#000000;display:block;margin:auto;border:1px solid var(--ion-color-light-shade);background-color:#ffffff;zoom:0.75;overflow:auto;width:100%;min-height:300px;max-height:300px}";let a=class{constructor(l){i(this,l);this.fireenjinTrigger=e(this,"fireenjinTrigger",7);this.to=[];this.attachments=[];this.users=[];this.hideTemplateSelect=false;this.zoom=.45}onChange(i){var e;if(((e=i===null||i===void 0?void 0:i.target)===null||e===void 0?void 0:e.name)==="templateId"){this.templateId=i.target.value}}async onSuccess(i){var e;if(((e=i.detail)===null||e===void 0?void 0:e.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,text:this.text,html:this.html,subject:this.subject,attachments:this.attachments,from:(i===null||i===void 0?void 0:i.from)||this.from,emails:(i===null||i===void 0?void 0:i.to)?i.to:this.to?this.to:[],filters:this.filters?this.filters:null}}componentWillLoad(){if(!(l===null||l===void 0?void 0:l.isBrowser))return}render(){return[o("ion-header",null,o("ion-toolbar",null,o("ion-title",null,"Send Email"),o("ion-buttons",{slot:"end"},o("ion-button",{onClick:()=>this.formEl.submit()},o("ion-icon",{slot:"icon-only",name:"send"})),o("ion-button",{onClick:i=>this.fireenjinTrigger.emit({event:i,name:"closeModal"})},o("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),o("ion-content",{style:{"--background":"var(--ion-color-base)"}},o("fireenjin-form",{ref:i=>this.formEl=i,endpoint:"sendTemplateEmail",disableEnterButton:true,hideControls:true,beforeSubmit:this.onBeforeSubmit.bind(this)},o("ion-grid",null,o("ion-row",null,o("ion-col",{size:"12",sizeMd:"7"},!this.hideTemplateSelect&&o("fireenjin-select",{ref:i=>this.templateSelectEl=i,name:"templateId",label:"Template",labelPosition:"stacked",placeholder:"Select Message Template",value:this.templateId,options:(this.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}))),interface:"action-sheet"}),o("fireenjin-input",{name:"subject",label:"Subject",labelPosition:"stacked",placeholder:"Email Subject",value:this.subject}),o("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)})))}),o("fireenjin-chip-bar",null,(this.attachments||[]).map((i=>{var e,l,n,t,a,s;return o("ion-chip",null,o("ion-icon",{name:"document",class:"ft-icon-style"}),o("ion-label",null,decodeURI(((s=(a=(t=(n=(l=(e=i===null||i===void 0?void 0:i.split)===null||e===void 0?void 0:e.call(i,"/"))===null||l===void 0?void 0:l.pop)===null||n===void 0?void 0:n.call(l))===null||t===void 0?void 0:t.split)===null||a===void 0?void 0:a.call(t,"?"))===null||s===void 0?void 0:s[0])||"No File Name")))})))),o("ion-col",{size:"12",sizeMd:"5",class:"ion-no-padding"},this.template&&o("fireenjin-render-template",{id:"email-preview",template:this.template,data:this.payload||{},helpers:this.helpers||{},partials:this.partials||[],zoom:this.zoom||.45})))),o("ion-accordion-group",null,o("ion-accordion",null,o("ion-item",{slot:"header",style:{"--background":"transparent"}},o("ion-label",null,"Advanced")),o("ion-grid",{slot:"content"},o("ion-row",null,o("ion-col",null,o("fireenjin-input",{name:"from",label:"Email From",labelPosition:"stacked",placeholder:"Email Address to Send From",value:this.from})),o("ion-col",null,o("fireenjin-input",{name:"replyTo",label:"Reply To",labelPosition:"stacked",placeholder:"Email Address to Reply",value:this.replyTo}))))))))]}};a.style=t;export{a as fireenjin_mx_modal_send_email};
//# sourceMappingURL=p-5b9f2bfc.entry.js.map