2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
import{_ as e}from"../../../../fc-bits.js?ver=3.1.8";import{P as t,aH as a,aI as i,j as s,h as l,i as o,ay as n,aO as r,k as c,W as d,aJ as m,E as u,Z as _,bk as p,bl as h,aD as g,aA as f,g as b,o as v,c as w,_ as y,T as k,a6 as $,G as C,z as S,aP as E,aE as V,aF as T,ax as P,az as x,aT as F}from"../../../../vendor-element-plus.js?ver=3.1.8";import{aQ as q,W as A,Y as j,a5 as L,ab as M,a6 as z,X as D,aa as B,a8 as R,Z as H,b2 as I,ax as N,a9 as O,bW as U,a0 as W,J as Y,az as J,ac as Z}from"../../../../vendor.js?ver=3.1.8";import{P as K}from"../../../../PaginationBar.js?ver=3.1.8";import{D as Q}from"../../../../DataTable.js?ver=3.1.8";import{F as G}from"../../../../FloatingBulkActionShell.js?ver=3.1.8";import{C as X}from"../../../../Confirm.js?ver=3.1.8";import{O as ee}from"../../../../_OptionSelector.js?ver=3.1.8";import{B as te}from"../../../../Badge.js?ver=3.1.8";import{_ as ae,I as ie,a as se,T as le}from"../../../../fc-bits-ui.js?ver=3.1.8";import{S as oe}from"../../../../_StepPicker.js?ver=3.1.8";import{E as ne}from"../../../../EmailComposer.js?ver=3.1.8";import{M as re}from"../../../../_MailerConfig.js?ver=3.1.8";import"../../../../BlockComposer.js?ver=3.1.8";import"../../../../input-popover-dropdown.js?ver=3.1.8";import"../../../../_FormBuilder2.js?ver=3.1.8";import"../../../../PhotoWidget.js?ver=3.1.8";import"../../../../data_config.js?ver=3.1.8";import"../../../../_AjaxSelector.js?ver=3.1.8";import"../../../../_VerifiedEmailInput.js?ver=3.1.8";import"../../../../EmailPreview.js?ver=3.1.8";import"../../../../PreviewIframeBuilder.js?ver=3.1.8";import"../../../../TestEmail.js?ver=3.1.8";import"../../../../CampaignSubjectLines.js?ver=3.1.8";import"../../../../_MergeCodes.js?ver=3.1.8";import"../../../../BuiltinTemplateDrawer.js?ver=3.1.8";import"../../../../PromoCard.js?ver=3.1.8";const ce={class:"fcrm_table_header_inner_left_title"},de={class:"fcrm_contact_popover_header"},me={class:"fcrm_contact_popover_body fcrm_popover_email_section"},ue={key:0},_e=["title"],pe={key:0},he=["title"],ge={key:2},fe=["aria-label"],be={class:"el-popover__reference"},ve={class:"icon"};const we=ae({name:"ProfileEmailSequence",components:{Icons:ie,Badge:te,Confirm:X,PaginationBar:K,DataTable:Q,OptionSelector:ee,MoreFilled:t},props:["subscriber_id"],data:()=>({sequences:[],loading:!1,removing:!1,pagination:{total:0,per_page:10,current_page:1},selected_sequence:"",doing_action:!1}),methods:{fetch(){this.loading=!0,this.$get(`sequences/subscriber/${this.subscriber_id}/sequences`,{per_page:this.pagination.per_page,page:this.pagination.current_page}).then(e=>{this.sequences=e.sequence_trackers.data,this.pagination.total=e.sequence_trackers.total}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},removeFromSequence(e,t){this.removing=!0,this.$del(`sequences/${e}/subscribers`,{tracker_ids:[t]}).then(e=>{this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.removing=!1})},addToSequence(){this.selected_sequence?(this.doing_action=!0,this.$post("subscribers/do-bulk-action",{action_name:"add_to_email_sequence",new_status:this.selected_sequence,subscriber_ids:[this.subscriber_id]}).then(e=>{var t;null==(t=this.$refs.popover)||t.hide(),this.selected_sequence="",this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.doing_action=!1})):this.$notify.warning({title:this.$t("Warning"),message:this.$t("Please select an email sequence"),offset:19})}},mounted(){this.fetch()}},[["render",function(e,t,d,m,u,_){const p=c,h=q("option-selector"),g=r,f=i,b=q("Badge"),v=q("Icons"),w=q("confirm"),y=o,k=l,$=s,C=a,S=q("pagination-bar"),E=q("data-table"),V=n;return A(),j(E,{wrapper_border:!0,"has-selection":!1,class:"fcrm_mb_24"},{"header-left":L(()=>[H("h3",ce,B(e.$t("Email Sequences")),1)]),"header-actions":L(()=>[M(g,{ref:"popover",placement:"left",width:"350","hide-after":0,trigger:"click","popper-class":"fcrm_contact_popover"},{reference:L(()=>[M(p,{size:"small"},{default:L(()=>[O(B(e.$t("Add Sequence")),1)],void 0,!0),_:1})]),default:L(()=>[H("div",de,[H("h3",null,B(e.$t("Select Sequence")),1)]),H("div",me,[M(h,{modelValue:u.selected_sequence,"onUpdate:modelValue":t[0]||(t[0]=e=>u.selected_sequence=e),field:{option_key:"email_sequences",clearable:!0,size:"small",placeholder:e.$t("Select Email Sequence"),teleported:!1}},null,8,["modelValue","field"]),M(p,{onClick:_.addToSequence,loading:u.doing_action,type:"primary"},{default:L(()=>[O(B(e.$t("Add To Sequence")),1)],void 0,!0),_:1},8,["onClick","loading"])])],void 0,!0),_:1},512)]),table:L(()=>[z((A(),j(C,{"empty-text":e.$t("No Data Available"),stripe:"",border:"",data:u.sequences,style:{width:"100%"}},{default:L(()=>[M(f,{label:e.$t("Sequence")},{default:L(e=>[e.row.sequence?(A(),D("span",ue,B(e.row.sequence.title),1)):R("",!0)]),_:1},8,["label"]),M(f,{label:e.$t("Started At")},{default:L(t=>[H("span",{title:t.row.created_at},B(e.$nsHumanDiffTime(t.row.created_at)),9,_e)]),_:1},8,["label"]),M(f,{label:e.$t("Next Email")},{default:L(t=>[t.row.next_sequence?(A(),D("span",pe,B(t.row.next_sequence.title),1)):R("",!0),"active"==t.row.status?(A(),D("span",{key:1,title:t.row.next_execution_time}," - ("+B(e.$nsHumanDiffTime(t.row.next_execution_time))+") ",9,he)):(A(),D("span",ge," -- "))]),_:1},8,["label"]),M(f,{width:"160",label:e.$t("Status")},{default:L(e=>[M(b,{type:e.row.status},null,8,["type"])]),_:1},8,["label"]),M(f,{width:"60",align:"center"},{default:L(a=>[M($,{trigger:"click"},{dropdown:L(()=>[M(k,null,{default:L(()=>[M(y,{class:"fcrm_danger_action"},{default:L(()=>[z((A(),D("div",null,[M(w,{onYes:e=>_.removeFromSequence(a.row.campaign_id,a.row.id)},{reference:L(()=>[H("span",be,[H("span",ve,[M(v,{"icon-name":"delete"})]),O(" "+B(e.$t("Delete")),1)])]),_:1},8,["onYes"])])),[[V,u.removing]])],void 0,!0),_:2},1024)],void 0,!0),_:2},1024)]),default:L(()=>[H("span",{class:"el-dropdown-link cursor_pointer",role:"button",tabindex:"0","aria-label":e.$t("More actions"),onKeydown:[t[1]||(t[1]=I(e=>e.currentTarget.click(),["enter"])),t[2]||(t[2]=I(N(e=>e.currentTarget.click(),["prevent"]),["space"]))]},[M(v,{"icon-name":"more_actions"})],40,fe)],void 0,!0),_:2},1024)]),_:1})],void 0,!0),_:1},8,["empty-text","data"])),[[V,u.loading]])]),pagination:L(()=>[M(S,{pagination:u.pagination,onFetch:_.fetch},null,8,["pagination","onFetch"])]),_:1})}]]),ye=U(()=>e(()=>import("../../Funnels/parts/_LazyIndividualProgress.js?ver=3.1.8"),[],import.meta.url)),ke={class:"fcrm_table_header_inner_left_title"},$e={class:"fcrm_contact_popover_header"},Ce={class:"fcrm_contact_popover_body fcrm_popover_email_section"},Se=["title"],Ee={key:0},Ve={class:"icon"},Te=["title"],Pe=["aria-label"],xe={class:"el-popover__reference"},Fe={class:"icon"},qe={class:"el-popover__reference"},Ae={class:"icon"},je={class:"el-popover__reference"},Le={class:"icon"},Me={class:"el-popover__reference"},ze={class:"icon"};const De=ae({name:"ProfileAutomations",props:["subscriber_id"],components:{Icons:ie,Badge:te,Confirm:X,PaginationBar:K,DataTable:Q,OptionSelector:ee,LazyIndividualProgress:ye,StepPicker:oe,InfoFilled:d},data:()=>({automations:[],loading:!1,deleting:!1,pagination:{total:0,per_page:10,current_page:1},updating:!1,select_job:{action_name:"add_to_automation",selected_options:[]},selected_sequence:"",doing_action:!1,stepPickerRow:null}),methods:{fetch(){this.loading=!0,this.$get(`funnels/subscriber/${this.subscriber_id}/automations`,{per_page:this.pagination.per_page,page:this.pagination.current_page}).then(e=>{this.automations=e.automations.data,this.pagination.total=e.automations.total}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},removeFromFunnel(e,t){this.deleting=!0,this.$del(`funnels/${e}/subscribers`,{subscriber_ids:[t]}).then(e=>{this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.deleting=!1})},changeFunnelSubscriptionStatus(e,t,a){this.updating=!0,this.$put(`funnels/${e}/subscribers/${t}/status`,{status:a}).then(e=>{this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.updating=!1})},openStepPicker(e){this.stepPickerRow=e},addToAutomation(){this.selected_sequence?(this.doing_action=!0,this.$post("subscribers/do-bulk-action",{action_name:"add_to_automation",new_status:this.selected_sequence,subscriber_ids:[this.subscriber_id]}).then(e=>{this.visiblePop=!1,this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.doing_action=!1})):this.$notify.warning({title:this.$t("Warning"),message:this.$t("Please select an automation funnel"),offset:19})}},mounted(){this.fetch()}},[["render",function(e,t,d,_,p,h){const g=c,f=q("option-selector"),b=r,v=q("lazy-individual-progress"),w=i,y=q("Icons"),k=q("Badge"),$=q("InfoFilled"),C=u,S=m,E=o,V=q("confirm"),T=l,P=s,x=a,F=q("step-picker"),U=q("pagination-bar"),W=q("data-table"),Y=n;return A(),j(W,{wrapper_border:!0,"has-selection":!1},{"header-left":L(()=>[H("h3",ke,B(e.$t("Automations")),1)]),"header-actions":L(()=>[M(b,{ref:"popover",placement:"left",width:"350","hide-after":0,trigger:"click","popper-class":"fcrm_contact_popover"},{reference:L(()=>[M(g,{size:"small"},{default:L(()=>[O(B(e.$t("Add Automation")),1)],void 0,!0),_:1})]),default:L(()=>[H("div",$e,[H("h3",null,B(e.$t("Select Automation")),1)]),H("div",Ce,[M(f,{modelValue:p.selected_sequence,"onUpdate:modelValue":t[0]||(t[0]=e=>p.selected_sequence=e),field:{option_key:"automation_funnels",clearable:!0,size:"small",placeholder:e.$t("Select Automation Funnel"),teleported:!1}},null,8,["modelValue","field"]),M(g,{onClick:h.addToAutomation,loading:p.doing_action,type:"primary"},{default:L(()=>[O(B(e.$t("Add To Automation")),1)],void 0,!0),_:1},8,["onClick","loading"])])],void 0,!0),_:1},512)]),table:L(()=>[z((A(),j(x,{"empty-text":e.$t("No Data Available"),stripe:"",border:"",data:p.automations,style:{width:"100%"}},{default:L(()=>[M(w,{label:e.$t("Sequence")},{default:L(e=>[e.row.funnel?(A(),j(v,{key:0,funnel:e.row.funnel,subscriber_id:d.subscriber_id},null,8,["funnel","subscriber_id"])):R("",!0)]),_:1},8,["label"]),M(w,{label:e.$t("Started At")},{default:L(t=>[H("span",{title:t.row.created_at},B(e.$nsHumanDiffTime(t.row.created_at)),9,Se)]),_:1},8,["label"]),M(w,{label:e.$t("Next Step")},{default:L(t=>[t.row.next_sequence_item&&"completed"!=t.row.status?(A(),D("span",Ee,B(t.row.next_sequence_item.title),1)):(A(),j(k,{key:1,type:"completed",plain:!0},{icon:L(()=>[H("span",Ve,[M(y,{"icon-name":"checkFill"})])]),_:1})),"active"==t.row.status?(A(),D("span",{key:2,title:t.row.next_execution_time}," - ("+B(e.$nsHumanDiffTime(t.row.next_execution_time))+") ",9,Te)):R("",!0)]),_:1},8,["label"]),M(w,{width:"160",label:e.$t("Status")},{default:L(e=>[M(k,{type:e.row.status},null,8,["type"])]),_:1},8,["label"]),M(w,{width:"60",align:"center","class-name":"fcrm_table_actions_cell"},{default:L(a=>["fcrm_manual_attach"==a.row.source_trigger_name?(A(),j(S,{key:0,class:"item",effect:"dark",content:e.$t("ProfileAutomations.Contact_Added_manually_to_Automation"),placement:"top-start"},{default:L(()=>[M(C,null,{default:L(()=>[M($)],void 0,!0),_:1})],void 0,!0),_:1},8,["content"])):R("",!0),M(P,{trigger:"click"},{dropdown:L(()=>[M(T,null,{default:L(()=>["active"==a.row.status||"waiting"==a.row.status?(A(),j(E,{key:0,onClick:e=>h.openStepPicker(a.row)},{default:L(()=>[H("span",xe,[H("span",Fe,[M(y,{"icon-name":"play"})]),O(" "+B(e.$t("Advance Step")),1)])],void 0,!0),_:1},8,["onClick"])):R("",!0),"cancelled"==a.row.status?(A(),j(E,{key:1,onClick:e=>h.changeFunnelSubscriptionStatus(a.row.funnel_id,a.row.subscriber_id,"active")},{default:L(()=>[H("span",qe,[H("span",Ae,[M(y,{"icon-name":"play"})]),O(" "+B(e.$t("Resume")),1)])],void 0,!0),_:1},8,["onClick"])):R("",!0),"active"==a.row.status?(A(),j(E,{key:2,onClick:e=>h.changeFunnelSubscriptionStatus(a.row.funnel_id,a.row.subscriber_id,"cancelled")},{default:L(()=>[H("span",je,[H("span",Le,[M(y,{"icon-name":"close"})]),O(" "+B(e.$t("Cancel")),1)])],void 0,!0),_:1},8,["onClick"])):R("",!0),M(E,{class:"fcrm_danger_action"},{default:L(()=>[M(V,{onYes:e=>h.removeFromFunnel(a.row.funnel_id,a.row.subscriber_id)},{reference:L(()=>[H("span",Me,[H("span",ze,[M(y,{"icon-name":"delete"})]),O(" "+B(e.$t("Delete")),1)])]),_:1},8,["onYes"])],void 0,!0),_:2},1024)],void 0,!0),_:2},1024)]),default:L(()=>[H("span",{class:"el-dropdown-link cursor_pointer",role:"button",tabindex:"0","aria-label":e.$t("More actions"),onKeydown:[t[1]||(t[1]=I(e=>e.currentTarget.click(),["enter"])),t[2]||(t[2]=I(N(e=>e.currentTarget.click(),["prevent"]),["space"]))]},[M(y,{"icon-name":"more_actions"})],40,Pe)],void 0,!0),_:2},1024)]),_:1})],void 0,!0),_:1},8,["empty-text","data"])),[[Y,p.loading]]),p.stepPickerRow?(A(),j(F,{key:0,"funnel-subscriber":p.stepPickerRow,"funnel-id":p.stepPickerRow.funnel_id,onClose:t[3]||(t[3]=e=>p.stepPickerRow=null),onAdvanced:t[4]||(t[4]=e=>{p.stepPickerRow=null,h.fetch()})},null,8,["funnel-subscriber","funnel-id"])):R("",!0)]),pagination:L(()=>[M(U,{pagination:p.pagination,onFetch:h.fetch},null,8,["pagination","onFetch"])]),_:1})}]]),Be={ref:"wrapper"},Re={ref:"ifr",frameborder:"0",sandbox:"allow-same-origin",style:{width:"100%",height:"400px"}};const He={class:"fc_smtp_log_viewer"},Ie={class:"fc_smtp_email_dialog_view"},Ne={class:"fc_smtp_email_log_items"},Oe={class:"item_header"},Ue={class:"item_content"},We={style:{"text-transform":"capitalize","margin-right":"10px"}},Ye={class:"item_header"},Je={class:"item_content"},Ze={class:"item_header"},Ke={class:"item_content"},Qe={class:"item_header"},Ge={class:"item_content"},Xe={key:0},et={class:"item_header"},tt={class:"item_content"},at={class:"item_header"},it={class:"item_content"},st={key:1},lt={class:"item_header"},ot={class:"item_content"},nt={style:{color:"var(--fc-secondary-text)"}},rt={style:{"white-space":"break-spaces","overflow-wrap":"anywhere"}},ct={style:{color:"var(--fc-secondary-text)"}},dt={key:0},mt={style:{color:"var(--fc-secondary-text)"}};const ut={class:"fc_smtp_email_logs_table"},_t=["onClick"],pt={key:0,style:{color:"var(--fc-error)"}};const ht=ae({name:"SMTPEmailLogs",components:{LogViewer:ae({name:"LogViewer",components:{SMTPEmailbodyContainer:ae({name:"SMTPEmailbodyContainer",components:{FullScreen:_},props:["content"],data:()=>({}),methods:{setBody(e){e||(e=" "),this.$nextTick(()=>{const t=this.$refs.ifr;(t.contentDocument||t.contentWindow.document).body.innerHTML=e})},fullScreen(){const e=document,t=this.$refs.wrapper;(e.fullscreenEnabled||e.webkitFullscreenEnabled||e.mozFullScreenEnabled||e.msFullscreenEnabled)&&(t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.msRequestFullscreen&&t.msRequestFullscreen())}},watch:{content:{immediate:!0,handler:"setBody"}}},[["render",function(e,t,a,i,s,l){const o=q("FullScreen"),n=u,r=c;return A(),D("div",Be,[H("iframe",Re,null,512),M(r,{size:"small",type:"primary",ref:"fullscreen",onClick:l.fullScreen},{default:L(()=>[M(n,null,{default:L(()=>[M(o)],void 0,!0),_:1}),O(" "+B(e.$t("Enter Full Screen")),1)],void 0),_:1},8,["onClick"])],512)}]])},props:["logViewerProps"],emits:["closeLogViewer"],data:()=>({activeName:"email_body"}),computed:{log(){if(!this.logViewerProps.log)return;const e={...this.logViewerProps.log};return e.headers||(e.headers={}),e.response||(e.response={}),e.extra||(e.extra={}),e}},methods:{getAttachments:e=>e&&e.attachments?Array.isArray(e.attachments)?[...e.attachments]:[e.attachments]:[],getAttachmentName(e){if(e&&e[0])return(e=e[0].replace(/\\/g,"/")).split("/").pop()},sanitize(e){return this.$sanitize(e)},handleCloseLogViewer(){this.$emit("closeLogViewer")}}},[["render",function(e,t,a,i,s,l){const o=q("SMTPEmailbodyContainer"),n=h,r=f,c=g,d=p,m=b;return A(),D("div",He,[l.log?(A(),j(m,{key:0,"append-to-body":!0,title:e.$t("Email Log"),modelValue:a.logViewerProps.dialogVisible,"onUpdate:modelValue":t[1]||(t[1]=e=>a.logViewerProps.dialogVisible=e),class:"fc_smtp_email_dialog",onClose:l.handleCloseLogViewer},{default:L(()=>[H("div",Ie,[H("ul",Ne,[H("li",null,[H("div",Oe,B(e.$t("Status"))+":",1),H("div",Ue,[H("span",{class:W({success:"sent"==l.log.status,resent:"resent"==l.log.status,fail:"failed"==l.log.status})},[H("span",We,B(l.log.status),1)],2)])]),H("li",null,[H("div",Ye,B(e.$t("Date-Time"))+":",1),H("div",Je,B(l.log.created_at),1)]),H("li",null,[H("div",Ze,B(e.$t("From"))+":",1),H("div",Ke,B(l.log.from),1)]),H("li",null,[H("div",Qe,B(e.$t("To"))+":",1),H("div",Ge,B(l.log.to),1)]),l.log.resent_count>0?(A(),D("li",Xe,[H("div",et,B(e.$t("Resent Count"))+":",1),H("div",tt,B(l.log.resent_count),1)])):R("",!0),H("li",null,[H("div",at,B(e.$t("Subject"))+":",1),H("div",it,B(l.log.subject),1)]),l.log.extra&&l.log.extra.provider?(A(),D("li",st,[H("div",lt,B(e.$t("Mailer"))+":",1),H("div",ot,B(l.log.extra.provider),1)])):R("",!0)]),M(d,{modelValue:s.activeName,"onUpdate:modelValue":t[0]||(t[0]=e=>s.activeName=e),style:{"margin-top":"10px"}},{default:L(()=>[M(n,{name:"email_body"},{title:L(()=>[H("strong",nt,B(e.$t("Email Body"))+" (sanitized)",1)]),default:L(()=>[t[2]||(t[2]=H("hr",{class:"log-border"},null,-1)),M(o,{content:l.sanitize(l.log.body)},null,8,["content"])],void 0,!0),_:1}),H("p",null,[H("strong",null,B(e.$t("Server Response")),1)]),M(c,null,{default:L(()=>[M(r,null,{default:L(()=>[H("pre",rt,B(l.log.response),1)],void 0,!0),_:1})],void 0,!0),_:1}),t[4]||(t[4]=H("hr",null,null,-1)),M(n,{name:"tech_info"},{title:L(()=>[H("strong",ct,B(e.$t("Email Headers")),1)]),default:L(()=>[H("div",null,[H("pre",null,B(l.log.headers),1),l.log.extra.custom_headers?(A(),D("pre",dt,B(l.log.extra.custom_headers),1)):R("",!0)])],void 0,!0),_:1}),M(n,{name:"attachments"},{title:L(()=>[H("strong",mt,B(e.$t("Attachments"))+" ("+B(l.getAttachments(l.log).length)+") ",1)]),default:L(()=>[t[3]||(t[3]=H("hr",{class:"log-border"},null,-1)),(A(!0),D(Y,null,J(l.getAttachments(l.log),(e,t)=>(A(),D("div",{key:t,style:{margin:"5px 0 10px 0"}}," ("+B(t+1)+") "+B(l.getAttachmentName(e)),1))),128))],void 0,!0),_:1})],void 0,!0),_:1},8,["modelValue"])])],void 0),_:1},8,["title","modelValue","onClose"])):R("",!0)])}]]),View:v},props:["emails"],data:()=>({loading:!1,logViewerProps:{log:null,dialogVisible:!1}}),methods:{tableRowClassName:({row:e})=>"row_type_"+e.status,handleView(e){this.logViewerProps.log=e,this.logViewerProps.dialogVisible=!0},closeLogViewer(){this.logViewerProps.log=null,this.logViewerProps.dialogVisible=!1}}},[["render",function(e,t,s,l,o,r){const d=i,m=q("View"),_=u,p=c,h=a,g=q("log-viewer"),f=n;return A(),D("div",ut,[z((A(),j(h,{stripe:"",data:s.emails,style:{width:"100%"},"row-class-name":r.tableRowClassName},{default:L(()=>[M(d,{label:e.$t("Subject")},{default:L(t=>[H("span",{style:{cursor:"pointer"},onClick:e=>r.handleView(t.row)},B(t.row.subject),9,_t),t.row.extra&&"Simulator"==t.row.extra.provider?(A(),D("span",pt," - "+B(e.$t("Simulated")),1)):R("",!0)]),_:1},8,["label"]),M(d,{label:e.$t("Status"),width:"120",align:"center"},{default:L(e=>[O(B(e.row.status),1)]),_:1},8,["label"]),M(d,{prop:"created_at",label:e.$t("Date-Time"),width:"200px"},{default:L(t=>[O(B(e.$nsHumanDiffTime(t.row.created_at)),1)]),_:1},8,["label"]),M(d,{label:e.$t("Actions"),width:"100px",align:"right"},{default:L(e=>[M(p,{onClick:t=>r.handleView(e.row)},{default:L(()=>[M(_,null,{default:L(()=>[M(m)],void 0,!0),_:1})],void 0,!0),_:1},8,["onClick"])]),_:1},8,["label"])],void 0),_:1},8,["data","row-class-name"])),[[f,o.loading]]),M(g,{logViewerProps:o.logViewerProps,onCloseLogViewer:r.closeLogViewer},null,8,["logViewerProps","onCloseLogViewer"])])}]]),gt=U(()=>e(()=>import("../../Email/Campaigns/_components/EmailPreview.js?ver=3.1.8"),[],import.meta.url)),ft={class:"fcrm_profile_emails_wrapper"},bt={class:"fcrm_table_header_inner_left_title"},vt={class:"fcrm_sorting_action_wrap"},wt={class:"icon"},yt={class:"d-flex gap-4 flex-wrap items-start"},kt=["onClick"],$t=["title"],Ct=["title"],St=["aria-label"],Et={class:"el-popover__reference"},Vt={class:"icon"},Tt={class:"el-popover__reference"},Pt={class:"icon"},xt={class:"fcrm_bulk_action_bar"},Ft={class:"fcrm_bulk_action_left"},qt={class:"fc_bulk_selection_count"},At={class:"icon"},jt={key:0},Lt={key:1},Mt={key:0,class:"fc_block_white"},zt={class:"fc_checkbox_note"},Dt={class:"dialog-footer fcrm_profile_email_drawer_footer"};const Bt=ae({name:"ProfileEmails",props:["subscriber_id","subscriber"],components:{Badge:te,SMTPEmailLogs:ht,PaginationBar:K,DataTable:Q,FloatingBulkActionShell:G,EmailPreview:gt,EmailSequences:we,ProfileAutomations:De,EmailComposer:ne,Confirm:X,MailerConfig:re,Sort:S,View:v,RefreshRight:C,Delete:$,Location:k,FolderOpened:y,MoreFilled:t,Close:w,Icons:ie},data:()=>({direction:"rtl",emailTab:"crm",loading:!1,emails:[],smtpEmailLogs:[],pagination:{total:0,per_page:10,current_page:1},preview:{id:null,isVisible:!1},sendEmailModal:!1,custom_email:{},resending:!1,selections:[],deleting:!1,loadingCustomEmailSettings:!1,sending_custom_email:!1,emailFilter:"all",is_transactional:"no",current_mode:"system"===le.getCurrentTheme()?le.getSystemTheme():le.getCurrentTheme()}),watch:{is_transactional(){this.syncTransactionalFooterState()}},methods:{syncTransactionalFooterState(){this.custom_email&&Object.keys(this.custom_email).length&&(this.custom_email.settings||(this.custom_email.settings={}),this.custom_email.settings.footer_settings||(this.custom_email.settings.footer_settings={}),this.custom_email.settings.is_transactional=this.is_transactional,"yes"===this.is_transactional&&(this.custom_email.settings.footer_settings.disable_footer="yes"))},fetch(){this.loading=!0,this.$get(`subscribers/${this.subscriber_id}/emails`,{per_page:this.pagination.per_page,page:this.pagination.current_page,filter:this.emailFilter,tab:this.emailTab}).then(e=>{var t;this.emails=e.emails.data,"fluentsmtp"===this.emailTab&&(this.smtpEmailLogs=this.formatLogs(null==(t=null==e?void 0:e.emails)?void 0:t.data)),this.pagination.total=e.emails.total}).catch(e=>{console.log(e)}).finally(()=>{this.loading=!1})},resendEmail(e){if(!this.has_campaign_pro)return this.$notify.error(this.$t("_Ca_Please_utptutf")),!1;this.resending=!0,this.$post(`campaigns-pro/${e.campaign_id}/resend-emails`,{email_ids:[e.id]}).then(e=>{this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.resending=!1})},previewEmail(e){this.preview.id=e,this.preview.isVisible=!0},sendCustomEmail(){this.sending_custom_email=!0,this.custom_email.settings||(this.custom_email.settings={}),this.custom_email.settings.is_transactional=this.is_transactional,this.syncTransactionalFooterState(),this.$post(`subscribers/${this.subscriber_id}/emails/send`,{campaign:this.custom_email}).then(e=>{this.$notify.success(e.message),this.fireCloseEmailComposer(),this.sendEmailModal=!1,this.custom_email={},this.fetch()}).catch(e=>{console.log(e)}).finally(()=>{this.sending_custom_email=!1})},handleSelectionChange(e){this.selections=e},clearProfileEmailSelection(){this.$refs.profileEmailsTable&&this.$refs.profileEmailsTable.clearSelection(),this.selections=[]},deleteSelected(){this.deleting=!0;const e=this.selections.map(e=>e.id);this.$del(`subscribers/${this.subscriber_id}/emails`,{email_ids:e}).then(e=>{this.selections=[],this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.deleting=!1})},openCustomEmailModal(){if(this.loadingCustomEmailSettings=!0,this.custom_email.email_body="",this.is_transactional="no",this.sendEmailModal=!0,window.fc_subscriber_email_mock)return this.custom_email=JSON.parse(JSON.stringify(window.fc_subscriber_email_mock)),this.custom_email.settings.mailer_settings?this.custom_email.settings.mailer_settings.is_custom="no":this.custom_email.settings.mailer_settings={from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",is_custom:"no"},this.is_transactional=this.custom_email.settings&&this.custom_email.settings.is_transactional?this.custom_email.settings.is_transactional:"no",this.syncTransactionalFooterState(),void(this.loadingCustomEmailSettings=!1);this.$get(`subscribers/${this.subscriber_id}/emails/template-mock`).then(e=>{const t=e.email_mock;t.settings.mailer_settings||(t.settings.mailer_settings={from_name:"",from_email:"",reply_to_name:"",reply_to_email:"",is_custom:"no"}),window.fc_subscriber_email_mock=t,this.custom_email=t,this.is_transactional=this.custom_email.settings&&this.custom_email.settings.is_transactional?this.custom_email.settings.is_transactional:"no",this.syncTransactionalFooterState()}).catch(e=>{console.log(e)}).finally(()=>{this.loadingCustomEmailSettings=!1})},fireCloseEmailComposer(e=!1){this.unmountBlockEditor(),e&&e()},formatLogs(e){return jQuery.each(e,(t,a)=>{e[t]=this.formatLog(a)}),e},formatLog(e){return e.to=this.formatAddresses(e.to),e},formatAddresses(e){if(!e)return"";if(this.isEmptyValue(e))return"";if("string"==typeof e)return e;const t=[];return jQuery.each(e,(e,a)=>{a.name?t[e]=this.escapeHtml(`${a.name} <${a.email}>`):t[e]=this.escapeHtml(a.email)}),t.join(", ")},escapeHtml(e){if(!e)return e;const t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,e=>t[e])},onThemeChanged(e){var t;this.current_mode=(null==(t=e.detail)?void 0:t.effective)||("system"===le.getCurrentTheme()?le.getSystemTheme():le.getCurrentTheme())}},mounted(){window.addEventListener(se,this.onThemeChanged),window.fcAdmin&&window.fcAdmin.is_rtl&&(this.direction="ltr"),this.fetch(),this.doAction("fluent_crm_profile_emails_mounted",this)},beforeUnmount(){window.removeEventListener(se,this.onThemeChanged)}},[["render",function(e,t,d,m,_,p){const h=E,g=c,f=T,b=V,v=r,w=q("Icons"),y=i,k=q("Location"),$=u,C=q("FolderOpened"),S=q("Badge"),U=o,W=l,J=s,K=a,Q=q("SMTPEmailLogs"),G=q("pagination-bar"),X=q("data-table"),ee=q("Close"),te=q("confirm"),ae=q("floating-bulk-action-shell"),ie=q("email-sequences"),se=q("profile-automations"),le=q("email-preview"),oe=q("mailer-config"),ne=x,re=P,ce=q("email-composer"),de=F,me=n;return A(),D("div",ft,[M(X,{wrapper_border:!0,"has-selection":!1,class:"fcrm_mb_24"},{"header-left":L(()=>[H("h3",bt,B(e.$t("Pro_Emails_fdcaa")),1)]),"header-actions":L(()=>[e.appVars.has_fluentsmtp?(A(),j(h,{key:0,size:"small",modelValue:_.emailTab,"onUpdate:modelValue":t[0]||(t[0]=e=>_.emailTab=e),"active-text":e.$t("FluentSMTP Logs"),"active-value":"fluentsmtp","inactive-value":"crm",onChange:p.fetch},null,8,["modelValue","active-text","onChange"])):R("",!0),e.hasPermission("fcrm_manage_contacts")&&"crm"===_.emailTab?(A(),j(v,{key:1,title:e.$t("Filter"),width:240,placement:"bottom","popper-class":"fcrm_sort_popover",trigger:"click"},{reference:L(()=>[M(g,{title:e.$t("Sort"),class:"only-icon-btn small",size:"small"},{default:L(()=>[...t[10]||(t[10]=[H("span",{class:"icon"},[H("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[H("path",{d:"M16.75 4V5.5H16L12.25 11.125V17.5H7.75V11.125L4 5.5H3.25V4H16.75ZM5.803 5.5L9.25 10.6705V16H10.75V10.6705L14.197 5.5H5.803Z",fill:"var(--fc-secondary-text)"})])],-1)])],void 0,!0),_:1},8,["title"])]),default:L(()=>[H("div",vt,[M(b,{modelValue:_.emailFilter,"onUpdate:modelValue":t[1]||(t[1]=e=>_.emailFilter=e),class:"fc_filter_emails",size:"small",onChange:p.fetch},{default:L(()=>[M(f,{value:"all"},{default:L(()=>[O(B(e.$t("All")),1)],void 0,!0),_:1}),M(f,{value:"open"},{default:L(()=>[O(B(e.$t("Opened")),1)],void 0,!0),_:1}),M(f,{value:"click"},{default:L(()=>[O(B(e.$t("Clicked")),1)],void 0,!0),_:1}),M(f,{value:"unopened"},{default:L(()=>[O(B(e.$t("Unopened")),1)],void 0,!0),_:1})],void 0,!0),_:1},8,["modelValue","onChange"])])],void 0,!0),_:1},8,["title"])):R("",!0),e.has_campaign_pro&&e.hasPermission("fcrm_manage_contacts")&&"crm"==_.emailTab?(A(),j(g,{key:2,disabled:!("subscribed"==d.subscriber.status||"transactional"==d.subscriber.status),onClick:t[2]||(t[2]=e=>p.openCustomEmailModal()),size:"small"},{default:L(()=>[H("span",wt,[M(w,{"icon-name":"send-mail"})]),O(" "+B(e.$t("Send Email")),1)],void 0,!0),_:1},8,["disabled"])):R("",!0)]),table:L(()=>["crm"===_.emailTab?z((A(),j(K,{key:0,ref:"profileEmailsTable","empty-text":e.$t("No Data Available"),stripe:"",border:"",data:_.emails,style:{width:"100%"},onSelectionChange:p.handleSelectionChange},{default:L(()=>[M(y,{type:"selection",width:"55"}),M(y,{label:e.$t("Subject")},{default:L(t=>[H("div",yt,[H("span",{class:"cursor_pointer",style:{"margin-right":"8px"},onClick:e=>p.previewEmail(t.row.id)},B(t.row.email_subject),9,kt),H("span",{title:e.$t("Total Clicks"),class:"fcrm_badge"},[M($,null,{default:L(()=>[M(k)],void 0,!0),_:1}),O(" "+B(t.row.click_counter||0),1)],8,$t),z(H("span",{title:e.$t("Email opened"),class:"fcrm_badge",style:{"min-height":"20px"}},[M($,{class:"icon"},{default:L(()=>[M(C)],void 0,!0),_:1})],8,Ct),[[Z,t.row.click_counter||1==t.row.is_open]])])]),_:1},8,["label"]),M(y,{width:"190",label:e.$t("Date")},{default:L(e=>[O(B(e.row.scheduled_at),1)]),_:1},8,["label"]),M(y,{width:"120",label:e.$t("Status"),align:"center"},{default:L(e=>[M(S,{type:e.row.status},null,8,["type"])]),_:1},8,["label"]),M(y,{width:"60",align:"center"},{default:L(a=>[M(J,{trigger:"click"},{dropdown:L(()=>[M(W,null,{default:L(()=>[M(U,{onClick:e=>p.previewEmail(a.row.id)},{default:L(()=>[H("span",Et,[H("span",Vt,[M(w,{"icon-name":"eye"})]),O(" "+B(e.$t("Preview")),1)])],void 0,!0),_:1},8,["onClick"]),"sent"!==a.row.status&&"failed"!==a.row.status||!a.row.campaign_id?R("",!0):(A(),j(U,{key:0,onClick:e=>p.resendEmail(a.row)},{default:L(()=>[H("span",Tt,[H("span",Pt,[M(w,{"icon-name":"resend-email"})]),O(" "+B(e.$t("Resend")),1)])],void 0,!0),_:1},8,["onClick"]))],void 0,!0),_:2},1024)]),default:L(()=>[H("span",{class:"el-dropdown-link cursor_pointer",role:"button",tabindex:"0","aria-label":e.$t("More actions"),onKeydown:[t[3]||(t[3]=I(e=>e.currentTarget.click(),["enter"])),t[4]||(t[4]=I(N(e=>e.currentTarget.click(),["prevent"]),["space"]))]},[M(w,{"icon-name":"more_actions"})],40,St)],void 0,!0),_:2},1024)]),_:1})],void 0,!0),_:1},8,["empty-text","data","onSelectionChange"])),[[me,_.loading||_.resending]]):"fluentsmtp"===_.emailTab?z((A(),j(Q,{key:1,emails:_.smtpEmailLogs},null,8,["emails"])),[[me,_.loading||_.resending]]):R("",!0)]),pagination:L(()=>[M(G,{pagination:_.pagination,onFetch:p.fetch},null,8,["pagination","onFetch"])]),_:1}),M(ae,{visible:!!_.selections.length,"theme-mode":_.current_mode,"custom-layout":!0},{default:L(()=>[H("div",xt,[H("div",Ft,[M(g,{link:"","aria-label":e.$t("Deselect"),onClick:p.clearProfileEmailSelection},{default:L(()=>[M($,null,{default:L(()=>[M(ee)],void 0,!0),_:1})],void 0,!0),_:1},8,["aria-label","onClick"]),H("span",qt,[H("strong",null,B(_.selections.length),1),O(" "+B(e.$t("selected")),1)]),t[11]||(t[11]=H("div",{class:"fcrm_bulk_divider"},null,-1)),M(te,{onYes:t[5]||(t[5]=e=>p.deleteSelected()),placement:"top-start"},{reference:L(()=>[z((A(),j(g,{type:"danger",size:"small",plain:""},{default:L(()=>[H("span",At,[M(w,{"icon-name":"delete"})]),O(" "+B(e.$t("Delete")),1)],void 0,!0),_:1})),[[me,_.deleting]])]),_:1})])])],void 0),_:1},8,["visible","theme-mode"]),e.has_campaign_pro?(A(),D(Y,{key:0},[M(ie,{subscriber_id:d.subscriber_id},null,8,["subscriber_id"]),M(se,{subscriber_id:d.subscriber_id},null,8,["subscriber_id"])],64)):R("",!0),M(le,{preview:_.preview},null,8,["preview"]),M(de,{direction:_.direction,class:"fc_funnel_block_modal fcrm_profile_email_drawer",modelValue:_.sendEmailModal,"onUpdate:modelValue":t[9]||(t[9]=e=>_.sendEmailModal=e),size:"80%","append-to-body":!0,"destroy-on-close":!0,"close-on-click-modal":!1,"before-close":p.fireCloseEmailComposer,title:e.$t("Send Custom Email")},{default:L(()=>[_.loadingCustomEmailSettings?(A(),D("div",jt,[H("h3",null,B(e.$t("Loading Settings...")),1)])):(A(),D("div",Lt,[_.sendEmailModal?(A(),D("div",Mt,[M(ce,{enable_test:!0,disable_fixed:!0,disable_gutenberg_autosave:!0,hide_gutenberg_save_button:!0,class:"fc_into_modal",campaign:_.custom_email,label_align:"top"},{after_block_composer:L(()=>[_.loadingCustomEmailSettings?R("",!0):(A(),j(re,{key:0,style:{"margin-bottom":"20px"},class:"fc_t_10","label-position":"top"},{default:L(()=>[M(oe,{mailer_settings:_.custom_email.settings.mailer_settings},null,8,["mailer_settings"]),M(ne,{class:"fc_t_10","true-value":"yes","false-value":"no",modelValue:_.is_transactional,"onUpdate:modelValue":t[6]||(t[6]=e=>_.is_transactional=e)},{default:L(()=>[O(B(e.$t("Mark_Transactional"))+" ",1),H("span",zt,"("+B(e.$t("transaction_checkbox_note"))+")",1)],void 0,!0),_:1},8,["modelValue"])],void 0,!0),_:1}))]),_:1},8,["campaign"])])):R("",!0)])),H("div",Dt,[M(g,{size:"small",onClick:t[7]||(t[7]=e=>{p.fireCloseEmailComposer(),_.sendEmailModal=!1})},{default:L(()=>[O(B(e.$t("Cancel")),1)],void 0,!0),_:1}),z((A(),j(g,{size:"small",type:"primary",onClick:t[8]||(t[8]=e=>p.sendCustomEmail())},{default:L(()=>[O(B(e.$t("Send Email")),1)],void 0,!0),_:1})),[[me,_.sending_custom_email]])])],void 0),_:1},8,["direction","modelValue","before-close","title"])])}]]);export{Bt as default};
|