import{e,aF as t,aJ as i,aE as s,B as o,E as a,k as l,b0 as n,a$ as r,g as d,aK as c,aL as m,aS as p,c as _,Z as h,o as g,r as u,D as f,P as y,_ as b,bb as v,L as w,h as E,i as S,aO as T,ay as k,j as x,b9 as $,aH as C,aI as D}from"./vendor-element-plus.js?ver=3.1.0";import{p as F}from"./input-popover-dropdown.js?ver=3.1.0";import{r as L,c as O,o as I,a as P,L as R,d as B,P as j,n as V,b as A,w as N,Q as U,as as H,O as z,e as M,F as G,K as q,M as W,aB as Y}from"./vendor.js?ver=3.1.0";import{_ as J,I as K}from"./fc-bits-ui.js?ver=3.1.0";import{W as Z,F as Q,a as X}from"./_FormBuilder2.js?ver=3.1.0";import{i as ee}from"./data_config.js?ver=3.1.0";import{E as te}from"./EmailPreview.js?ver=3.1.0";import{P as ie}from"./PaginationBar.js?ver=3.1.0";import{M as se}from"./_MergeCodes.js?ver=3.1.0";import{B as oe,a as ae}from"./BuiltinTemplateDrawer.js?ver=3.1.0";import{S as le}from"./fc-bits.js?ver=3.1.0";import{P as ne}from"./PromoCard.js?ver=3.1.0";const re={class:"fc_raw_body"};const de=J({name:"RawtextEditor",props:["modelValue","editor_design","hide_smart_codes"],emits:["update:modelValue"],components:{popover:F},data(){return{content:this.modelValue||"",editorShortcodes:window.fcAdmin.globalSmartCodes,cursorPos:this.value?this.value.length:0}},watch:{content(){this.$emit("update:modelValue",this.content)}},methods:{handleCommand(e){var t=this.content.slice(0,this.cursorPos),i=this.content.slice(this.cursorPos,this.content.length);this.content=t+e+i,this.cursorPos+=e.length},updateCursorPos(e){var t=jQuery(".wp_editor_raw_html textarea").prop("selectionStart");this.cursorPos=t}},mounted(){jQuery(".wp_editor_raw_html textarea").on("click",e=>{this.updateCursorPos(e)})},created(){window.fcAdmin.extendedSmartCodes&&(this.editorShortcodes=[...this.editorShortcodes,...window.fcAdmin.extendedSmartCodes]),window.fcrm_funnel_context_codes&&(this.editorShortcodes=[...this.editorShortcodes,...window.fcrm_funnel_context_codes])}},[["render",function(t,i,s,o,a,l){const n=L("popover"),r=e;return I(),O("div",re,[s.hide_smart_codes?R("",!0):(I(),P(n,{key:0,class:"popover-wrapper",data:a.editorShortcodes,onCommand:l.handleCommand},null,8,["data","onCommand"])),B(r,{type:"textarea",rows:30,class:"wp_editor_raw_html",placeholder:t.$t("Raw_Please_PHoyE"),onKeyup:l.updateCursorPos,modelValue:a.content,"onUpdate:modelValue":i[0]||(i[0]=e=>a.content=e)},null,8,["placeholder","onKeyup","modelValue"])])}]]),ce={key:1,style:{"max-width":"800px",margin:"50px auto"},class:"fc_classic_editor_fallback"};const me=J({name:"FCBlockEditor",props:["modelValue","design_template"],emits:["changed","update:modelValue"],components:{WpEditor:Z},data(){return{content:this.modelValue||"\x3c!-- wp:paragraph --\x3e

"+this.$t("Start Writing Here")+"

\x3c!-- /wp:paragraph --\x3e",has_block_editor:"function"==typeof window.fluentCrmBootEmailEditor,editorShortcodes:window.fcAdmin.globalSmartCodes}},methods:{init(){this.has_block_editor&&window.fluentCrmBootEmailEditor(this.content,this.handleChange)},handleChange(e){this.$emit("update:modelValue",e),this.$emit("changed")}},mounted(){this.init(),jQuery(".block-editor-block-inspector__no-blocks").html('
'+this.$t("Tips")+":"+this.$t("Please")+' '+this.$t("read the doc for advanced usage")+"
")}},[["render",function(e,t,i,s,o,a){const l=L("wp-editor");return o.has_block_editor?(I(),O("div",{key:0,id:"fluentcrm_block_editor_x",class:V(["fc_block_editor","fc_skin_"+i.design_template])},j(e.$t("Loading Editor...")),3)):(I(),O("div",ce,[B(l,{editorShortcodes:o.editorShortcodes,modelValue:o.content,"onUpdate:modelValue":t[0]||(t[0]=e=>o.content=e),onChange:a.handleChange},null,8,["editorShortcodes","modelValue","onChange"]),A("p",null,j(e.$t("using_old_wordpress_version")),1)]))}]]),pe={class:"icon"},_e=["src","alt"],he={class:"fcrm_image_radio_label"};const ge=J({name:"InputRadioImage",components:{Icons:K},props:["field","modelValue","boxWidth","boxHeight","tooltip_prefix"],emits:["change","update:modelValue"],data(){return{model:this.modelValue,width:this.boxWidth||120,height:this.boxHeight||120}},watch:{model(e){this.$emit("update:modelValue",e),this.$emit("change",e)}}},[["render",function(e,o,a,l,n,r){const d=L("Icons"),c=i,m=t,p=s;return I(),P(p,{class:"fc_image_radio_tooltips fcrm_image_radio_tooltips",modelValue:n.model,"onUpdate:modelValue":o[0]||(o[0]=e=>n.model=e)},{default:N(()=>[(I(!0),O(U,null,H(a.field.options,(t,i)=>(I(),P(m,{key:i,value:t.id},{default:N(()=>[B(c,{content:a.tooltip_prefix?a.tooltip_prefix+t.label:t.label,placement:"top"},{default:N(()=>[A("div",{class:V([n.model==t.id?"fc_image_active fcrm_image_active":"","fc_image_box fcrm_image_box"])},[A("span",pe,[B(d,{"icon-name":"circleFilled"})]),A("img",{src:t.image,alt:e.$t("Layout")},null,8,_e)],2)],void 0,!0),_:2},1032,["content"]),A("div",he,j(t.label),1)],void 0,!0),_:2},1032,["value"]))),128))],void 0),_:1},8,["modelValue"])}]]),ue={style:{display:"inline-block"},class:"fc_style_editor"},fe={style:{"margin-top":"20px"},class:"fc_2col_form_wrapper"},ye={style:{"margin-top":"20px"}},be={class:"dialog-footer text-align-right"};const ve=J({name:"EmailStyleEditor",props:{template_config:{type:Object,required:!0},footer_settings:{type:Object,default:()=>({})}},components:{FormBuilder:Q,Setting:o},emits:["save"],data:()=>({showBodyConfig:!1,email_font_families:ee,activeTab:"global"}),computed:{email_footer_fields(){return{custom_footer:{type:"input-radio",label:this.$t("Email Footer Type"),options:[{id:"no",label:this.$t("Use Global Email Footer")},{id:"yes",label:this.$t("Use Custom Email Footer")}]},footer_content:{type:"wp-editor",placeholder:this.$t("Custom Email Footer Text"),label:this.$t("Custom Email Footer Text"),help:this.$t("This email footer text will be used to this email only"),inline_help:this.$t("You should provide your business address")+" {{crm.business_address}} "+this.$t("and manage subscription/unsubscribe url is mandatory")+"
"+this.$t("Smartcode:")+" {{crm.business_name}}, {{crm.business_address}}, ##crm.manage_subscription_url##, ##crm.unsubscribe_url## "+this.$t("will be replaced with dynamic values."),dependency:{depends_on:"custom_footer",operator:"=",value:"yes"}}}},settingsFields(){if(this.isEmptyValue(this.template_config))return{};const e=[];Object.entries(this.email_font_families).forEach(([t,i])=>{e.push({id:i,label:t})});const t={body_bg_color:{label:this.$t("Body Background Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},content_width:{label:this.$t("Content Max Width (PX)"),inline_help:this.$t("Gut_Suggesting_vB6t8"),type:"input-number",min:400,step:10},content_padding:{label:this.$t("Content Padding Left/Right"),type:"input-number",min:0,step:1},content_bg_color:{label:this.$t("Content Background Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},text_color:{label:this.$t("Default Content Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},heading_color:{label:this.$t("Default Headings Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},footer_text_color:{label:this.$t("Footer Text Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},link_color:{label:this.$t("Default Link Color"),type:"input-color",colorFormat:"hex",showAlpha:!1},content_font_family:{label:this.$t("Content Font Family"),type:"input-option",options:e},headings_font_family:{label:this.$t("Headings Font Family"),type:"input-option",options:e},disable_footer:{type:"inline-checkbox",true_label:"yes",false_label:"no",checkbox_label:this.$t("Disable Default Email Footer"),inline_help:this.$t("email_will_be_sent_without_footer_contents")}},i=Object.keys(this.template_config),s={};return Object.entries(t).forEach(([e,t])=>{-1!==i.indexOf(e)&&(s[e]=t)}),s}},watch:{template_config:{deep:!0,handler(){this.generateStyles()}}},methods:{open(){this.showBodyConfig=!0},triggerUpdate(){this.$post("templates/set-global-style",{config:this.template_config}).then(e=>{console.log(e)}).catch(e=>{console.log(e)}),this.$emit("save"),this.showBodyConfig=!1},generateStyles(){let e="";const t=this.template_config;if(this.isEmptyValue(t)){const e=document.getElementById("fc_mail_config_style");return void(e&&(e.innerHTML=""))}const i=".fluentcrm_visual_editor .fc_visual_body .fce-block-editor ";e+=`${i} .block-editor-writing-flow { background-color: ${t.body_bg_color}; }`,e+=`${i} .fc_editor_body { background-color: ${t.content_bg_color}; color: ${t.text_color}; max-width: ${t.content_width}px; font-family: ${t.content_font_family} !important; }`,e+=`.fc_skin_plain .fc_editor_body,.fc_skin_classic .fc_editor_body,.fc_skin_simple .fc_editor_body {padding-left: ${t.content_padding}px !important;padding-right: ${t.content_padding}px !important; }`,e+=`${i} .fc_editor_body p,\n ${i} .fc_editor_body li, ol { color: inherit; font-size: inherit; }`,e+=`${i} .fc_editor_body h1,\n ${i} .fc_editor_body h2,\n ${i} .fc_editor_body h3,\n ${i} .fc_editor_body h4 { color: ${t.headings_color}; font-family: ${t.headings_font_family} !important; }\n ${i} .fc_editor_body a { color: ${t.link_color}; }`;const s=document.getElementById("fc_mail_config_style");s&&(s.innerHTML='")}},mounted(){this.generateStyles(),this.footer_settings||(this.footer_settings={custom_footer:"no",footer_content:""}),(!this.footer_settings.footer_content||this.footer_settings.footer_content.length<10)&&(this.footer_settings.footer_content=window.fcAdmin.global_email_footer)}},[["render",function(e,t,i,s,o,c){const m=L("Setting"),p=a,_=l,h=L("form-builder"),g=r,u=n,f=d;return I(),O("span",ue,[e.isEmptyValue(i.template_config)?R("",!0):(I(),P(_,{key:0,onClick:t[0]||(t[0]=e=>o.showBodyConfig=!0),size:"small",type:"info"},{default:N(()=>[B(p,null,{default:N(()=>[B(m)],void 0,!0),_:1})],void 0),_:1})),B(f,{"close-on-click-modal":!1,title:e.$t("Email Styling Settings & Footer Settings"),modelValue:o.showBodyConfig,"onUpdate:modelValue":t[3]||(t[3]=e=>o.showBodyConfig=e),"append-to-body":!0,width:"60%"},{footer:N(()=>[A("span",be,[B(_,{onClick:t[2]||(t[2]=e=>c.triggerUpdate())},{default:N(()=>[z(j(e.$t("Update Settings")),1)],void 0,!0),_:1})])]),default:N(()=>[o.showBodyConfig?(I(),P(u,{key:0,modelValue:o.activeTab,"onUpdate:modelValue":t[1]||(t[1]=e=>o.activeTab=e),class:"fc_settings_popup"},{default:N(()=>[B(g,{label:e.$t("Global Settings"),name:"global"},{default:N(()=>[A("div",fe,[o.showBodyConfig?(I(),P(h,{key:0,formData:i.template_config,fields:c.settingsFields},null,8,["formData","fields"])):R("",!0)])],void 0,!0),_:1},8,["label"]),B(g,{label:e.$t("Footer Settings"),name:"email_footer"},{default:N(()=>[A("div",ye,[A("p",null,j(e.$t("Customize_Email_Footer_Sec")),1),B(h,{formData:i.footer_settings,fields:c.email_footer_fields},null,8,["formData","fields"])])],void 0,!0),_:1},8,["label"])],void 0,!0),_:1},8,["modelValue"])):R("",!0)],void 0),_:1},8,["title","modelValue"]),t[4]||(t[4]=A("div",{id:"fc_mail_config_style"},null,-1))])}]]),we={name:"AiEmailBodyGenerator",props:{disabled:Boolean,context:{type:Object,default:()=>({})}},emits:["insert"],data:()=>({visible:!1,generating:!1,error:"",form:{prompt:"",tone:"friendly",length:"medium"}}),methods:{generate(){this.form.prompt.trim()?(this.generating=!0,this.error="",this.$post("ai/generate-email-body",{...this.form,context:this.context}).then(e=>{this.insertGeneratedBody(e||{})}).catch(e=>{this.error=this.getErrorMessage(e)}).finally(()=>{this.generating=!1})):this.error=this.$t("Please describe the email you want to generate.")},insertGeneratedBody(e){const t=e.subject_suggestions||[];this.$emit("insert",{email_body:e.email_body||"",subject:t[0]||"",preview_text:e.preview_text||""}),this.visible=!1,this.error=""},getErrorMessage(e){return e&&e.message?e.message:e&&e.data&&e.data.message?e.data.message:this.$t("Could not generate email body. Please try again.")}}},Ee={class:"fcrm_ai_email_generator"},Se={class:"fcrm_ai_email_generator_dialog_header"},Te={class:"fcrm_ai_email_generator_form"},ke={class:"fcrm_ai_email_generator_grid"},xe={class:"fcrm_ai_email_generator_footer"};const $e=J(we,[["render",function(t,i,s,o,a,n){const r=l,_=e,h=m,g=c,u=p,f=d;return I(),O("span",Ee,[B(r,{size:"small",class:"fcrm_ai_email_generator_trigger",disabled:s.disabled,onClick:i[0]||(i[0]=e=>a.visible=!0)},{default:N(()=>[i[6]||(i[6]=A("span",{class:"fcrm_ai_email_generator_icon","aria-hidden":"true"},[A("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[A("path",{d:"M8.75 1.25L9.80875 4.44125L13 5.5L9.80875 6.55875L8.75 9.75L7.69125 6.55875L4.5 5.5L7.69125 4.44125L8.75 1.25Z",fill:"currentColor"}),A("path",{d:"M3.75 8.25L4.39125 10.1088L6.25 10.75L4.39125 11.3912L3.75 13.25L3.10875 11.3912L1.25 10.75L3.10875 10.1088L3.75 8.25Z",fill:"currentColor"}),A("path",{d:"M12 9.5L12.4288 10.8212L13.75 11.25L12.4288 11.6788L12 13L11.5712 11.6788L10.25 11.25L11.5712 10.8212L12 9.5Z",fill:"currentColor"})])],-1)),z(" "+j(t.$t("Generate with AI")),1)],void 0),_:1},8,["disabled"]),B(f,{modelValue:a.visible,"onUpdate:modelValue":i[5]||(i[5]=e=>a.visible=e),"append-to-body":!0,"close-on-click-modal":!1,width:"520px",class:"fcrm_ai_email_generator_dialog"},{header:N(()=>[A("div",Se,[i[7]||(i[7]=A("div",{class:"fcrm_ai_email_generator_dialog_icon"},[A("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[A("path",{d:"M8.75 1.25L9.80875 4.44125L13 5.5L9.80875 6.55875L8.75 9.75L7.69125 6.55875L4.5 5.5L7.69125 4.44125L8.75 1.25Z",fill:"currentColor"}),A("path",{d:"M3.75 8.25L4.39125 10.1088L6.25 10.75L4.39125 11.3912L3.75 13.25L3.10875 11.3912L1.25 10.75L3.10875 10.1088L3.75 8.25Z",fill:"currentColor"})])],-1)),A("div",null,[A("h3",null,j(t.$t("Generate Email Body with AI")),1),A("p",null,j(t.$t("Describe the email you want and AI will write it into the editor.")),1)])])]),footer:N(()=>[A("div",xe,[B(r,{onClick:i[4]||(i[4]=e=>a.visible=!1)},{default:N(()=>[z(j(t.$t("Cancel")),1)],void 0,!0),_:1}),B(r,{type:"primary",loading:a.generating,disabled:!a.form.prompt.trim(),onClick:n.generate},{default:N(()=>[z(j(t.$t("Write with AI")),1)],void 0,!0),_:1},8,["loading","disabled","onClick"])])]),default:N(()=>[A("div",Te,[A("label",null,j(t.$t("What should this email be about?")),1),B(_,{type:"textarea",rows:5,modelValue:a.form.prompt,"onUpdate:modelValue":i[1]||(i[1]=e=>a.form.prompt=e),placeholder:t.$t("Example: Announce our new course and invite subscribers to join before Friday.")},null,8,["modelValue","placeholder"]),A("div",ke,[A("div",null,[A("label",null,j(t.$t("Tone")),1),B(g,{modelValue:a.form.tone,"onUpdate:modelValue":i[2]||(i[2]=e=>a.form.tone=e),class:"w-100"},{default:N(()=>[B(h,{label:t.$t("Friendly"),value:"friendly"},null,8,["label"]),B(h,{label:t.$t("Professional"),value:"professional"},null,8,["label"]),B(h,{label:t.$t("Casual"),value:"casual"},null,8,["label"]),B(h,{label:t.$t("Persuasive"),value:"persuasive"},null,8,["label"]),B(h,{label:t.$t("Educational"),value:"educational"},null,8,["label"])],void 0,!0),_:1},8,["modelValue"])]),A("div",null,[A("label",null,j(t.$t("Length")),1),B(g,{modelValue:a.form.length,"onUpdate:modelValue":i[3]||(i[3]=e=>a.form.length=e),class:"w-100"},{default:N(()=>[B(h,{label:t.$t("Short"),value:"short"},null,8,["label"]),B(h,{label:t.$t("Medium"),value:"medium"},null,8,["label"]),B(h,{label:t.$t("Long"),value:"long"},null,8,["label"])],void 0,!0),_:1},8,["modelValue"])])]),a.error?(I(),P(u,{key:0,type:"error",closable:!1,title:a.error,"show-icon":""},null,8,["title"])):R("",!0)])],void 0),_:1},8,["modelValue"])])}]]),Ce={class:"fcrm_editor_loader_blocks_preview"},De={key:0,class:"fcrm_editor_loader_blocks_title"};const Fe={name:"NewEditorFrame",components:{EditorLoader:J({name:"EditorLoader",props:{loaderText:{type:String,default:"Loading..."}}},[["render",function(e,t,i,s,o,a){return I(),O("div",Ce,[t[0]||(t[0]=M('
',1)),i.loaderText?(I(),O("div",De,j(i.loaderText),1)):R("",!0)])}]])},emits:["update:modelValue","titleUpdated","featuredMediaUpdated","useAlternateEditor","contentUpdated","editorNext","editorBack","editorFullscreenToggle","layoutChange","openEmailPreview","openTemplatePicker","openSaveTemplate","editorSaveDraft","styleConfigChange","footerSettingsUpdated","editorRecoveryNotice"],props:{editorPath:{type:String,default:"/editor"},modelValue:{type:String,default:""},fallback_content:{type:String,default:""},editorParams:{type:Object,default:()=>({})},frameHeight:{type:String,default:"500px"},documentTitle:{type:String,default:""},templateConfig:{type:Object,default:()=>({})},footerSettings:{type:Object,default:()=>null},extra_tags:{type:Array,default:()=>[]}},data:()=>({editorData:{content:""},editorFrame:null,editorOrigin:null,lastUpdate:"No updates yet",dataSent:!1,isFailing:!1,iframeReady:!1,pendingDataSend:!1,editorReadyReceived:!1,lastLayoutSent:"",sendRetryCount:0}),computed:{notLoading(){return!this.dataSent&&this.isFailing}},mounted(){setTimeout(()=>{this.editorReadyReceived||(this.isFailing=!0)},3e4),this.editorData.content=this.modelValue,this.modelValue||(this.fallback_content?this.editorData.content=this.fallback_content:this.editorData.content="\x3c!-- wp:paragraph --\x3e

\x3c!-- /wp:paragraph --\x3e"),this.editorData.title=this.documentTitle,this.createEditorIframe(),window.addEventListener("message",this.handleEditorMessage),document.body.classList.add("fcm_custom_editor_open")},watch:{modelValue(e){e!==this.editorData.content&&(this.editorData.content=e||"",this.editorReadyReceived&&this.sendDataToEditor())},fallback_content(e){!this.modelValue&&e&&e!==this.editorData.content&&(this.editorData.content=e,this.editorReadyReceived&&this.sendDataToEditor())},documentTitle(e){e!==this.editorData.title&&(this.editorData.title=e||"",this.editorReadyReceived&&this.sendDataToEditor())},editorParams:{deep:!0,handler(e,t){const i=e&&e.design_template?e.design_template:"",s=t&&t.design_template?t.design_template:"";i&&i!==s&&this.syncLayout(i)}},templateConfig:{deep:!0,handler(e){this.editorReadyReceived&&e&&this.syncStyleConfig(e)}},footerSettings:{deep:!0,handler(e){this.editorReadyReceived&&this.syncFooterSettings(e)}}},beforeUnmount(){window.removeEventListener("message",this.handleEditorMessage),this.editorFrame&&(this.editorFrame.onload=null,this.$refs.iframeContainer.removeChild(this.editorFrame),this.editorFrame=null),document.body.classList.remove("fcm_custom_editor_open")},methods:{makeSerializable(e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch(t){}try{return JSON.parse(JSON.stringify(e))}catch(t){return null}},postMessageToEditor(e){if(!this.iframeReady||!this.editorFrame||!this.editorFrame.contentWindow)return!1;try{const t=this.makeSerializable(e);return t?(this.editorFrame.contentWindow.postMessage(t,this.editorOrigin||"*"),!0):(console.error("Error posting message to editor: payload is not serializable"),!1)}catch(t){return console.error("Error posting message to editor:",t),!1}},syncLayout(e){if(!e||e===this.lastLayoutSent)return;const t={action:"LAYOUT_SYNC",design_template:e};this.postMessageToEditor(t)&&(this.lastLayoutSent=e)},syncStyleConfig(e){e&&"object"==typeof e&&this.postMessageToEditor({action:"STYLE_CONFIG_SYNC",template_config:JSON.parse(JSON.stringify(e))})},syncFooterSettings(e){this.postMessageToEditor({action:"FOOTER_SETTINGS_SYNC",footer_settings:JSON.parse(JSON.stringify(e||null))})},createEditorIframe(){const e=new URL(this.editorPath,window.location.origin);this.editorOrigin=e.origin,this.editorFrame=document.createElement("iframe");let t=this.appVars.crm_editor_frame;if(this.editorParams){t+="&"+new URLSearchParams(this.editorParams).toString()}try{this.editorOrigin=new URL(t,window.location.origin).origin}catch(i){this.editorOrigin=window.location.origin}this.editorFrame.src=t,this.editorFrame.style.width="100%",this.editorFrame.style.height=this.frameHeight,this.editorFrame.onload=()=>{console.log("Iframe loaded successfully"),this.iframeReady=!0,this.pendingDataSend&&(this.pendingDataSend=!1,setTimeout(()=>{this.sendDataToEditor()},1e3)),setTimeout(()=>{!this.editorReadyReceived&&this.iframeReady&&(console.log("Forcing data send after iframe load timeout"),this.sendDataToEditor())},5e3)},this.$refs.iframeContainer.appendChild(this.editorFrame)},editorFailed(){this.$emit("useAlternateEditor")},sendDataToEditor(){if(!this.iframeReady||!this.editorFrame||!this.editorFrame.contentWindow)return console.log("Iframe not ready yet, marking for pending send"),void(this.pendingDataSend=!0);try{let e=this.editorData;e.templateConfig=this.templateConfig,e.footerSettings=this.footerSettings,this.extra_tags&&(e.extra_tags=this.extra_tags);const t=JSON.parse(JSON.stringify(e));if(!this.postMessageToEditor({type:"UPDATE_EDITOR",data:t}))return this.sendRetryCount++,void(this.sendRetryCount<10?(console.warn("postMessageToEditor returned false, retrying ("+this.sendRetryCount+"/10)..."),setTimeout(()=>{this.sendDataToEditor()},500)):(console.error("postMessageToEditor failed after 10 retries"),this.isFailing=!0));this.sendRetryCount=0;const i=this.editorParams&&this.editorParams.design_template?this.editorParams.design_template:"";i&&this.syncLayout(i),setTimeout(()=>{this.dataSent=!0},500)}catch(e){this.sendRetryCount++,this.sendRetryCount<10?(console.error("Error sending data to editor, retrying ("+this.sendRetryCount+"/10):",e),setTimeout(()=>{this.sendDataToEditor()},1e3)):(console.error("Error sending data to editor after 10 retries:",e),this.isFailing=!0)}setTimeout(()=>{var e;let t=null==(e=document.getElementById("wpbody"))?void 0:e.clientHeight;t&&document.documentElement.style.setProperty("--fcm-root-app-height",t+"px")},1500)},handleEditorMessage(e){var t;if(!(null==(t=this.editorFrame)?void 0:t.contentWindow)||e.source!==this.editorFrame.contentWindow)return;const{action:i,content:s}=e.data;if("EDITOR_UPDATED"===i)this.dataSent&&s?(this.editorData.content=s,this.$emit("update:modelValue",s),this.$emit("contentUpdated",s)):console.log("Received EDITOR_UPDATED but data not sent yet or content is empty, ignoring");else if("TITLE_UPDATED"===i)this.editorData.title=s,this.$emit("titleUpdated",s);else if("FEATURED_MEDIA_UPDATED"===i)this.$emit("featuredMediaUpdated",s);else if("EDITOR_NEXT"===i)this.$emit("editorNext");else if("EDITOR_BACK"===i)this.$emit("editorBack");else if("EDITOR_FULLSCREEN_TOGGLE"===i){const t=!(!e.data||!Object.prototype.hasOwnProperty.call(e.data,"enabled"));this.$emit("editorFullscreenToggle",t?!!e.data.enabled:null)}else"EDITOR_LAYOUT_CHANGE"===i&&e.data&&e.data.design_template?this.$emit("layoutChange",e.data.design_template):"EDITOR_OPEN_EMAIL_PREVIEW"===i?this.$emit("openEmailPreview"):"EDITOR_OPEN_TEMPLATES"===i?this.$emit("openTemplatePicker"):"EDITOR_OPEN_SAVE_TEMPLATE"===i?this.$emit("openSaveTemplate"):"EDITOR_SAVE_DRAFT"===i?this.$emit("editorSaveDraft"):"EDITOR_STYLE_CONFIG_CHANGE"===i&&e.data&&e.data.template_config?this.$emit("styleConfigChange",e.data.template_config):"EDITOR_READY"===i?(this.editorReadyReceived=!0,this.isFailing=!1,this.sendDataToEditor()):"EDITOR_INIT_FAILED"===i?this.isFailing=!0:"EDITOR_RECOVERY_NOTICE"===i?this.$emit("editorRecoveryNotice"):"EDITOR_FOOTER_SETTINGS_CHANGE"===i&&this.$emit("footerSettingsUpdated",e.data.footer_settings)}}},Le={key:0,style:{display:"flex","justify-content":"center","align-items":"center","column-gap":"10px"}},Oe={class:"editor-container"},Ie={ref:"iframeContainer",class:"iframe-container"};const Pe={name:"BlockComposer",props:{campaign:{type:Object,required:!0},enable_templates:Boolean,disable_fixed:Boolean,body_key:String,enable_template_save:Boolean,show_merge:Boolean,use_fullscreen_editor:{type:Boolean,default:!1},iframe_nav_mode:{type:String,default:""},hideBackBtn:{type:Boolean,default:!1},hideNextBtn:{type:Boolean,default:!1},hideSaveBtn:{type:Boolean,default:!1},disableGutenbergAutosave:{type:Boolean,default:!1},extra_tags:{type:Array,default:()=>[]},show_audit:Boolean,disabled_templates:{type:Object,default:()=>({})},features:{type:Object,default:()=>({})}},components:{PromoCard:ne,BuildInTemplatesList:ae,Icons:K,ImageRadioToolTip:ge,RawEditor:de,EmailStyleEditor:ve,BlockEditor:me,EmailPreview:te,WpEditor:X,PaginationBar:ie,MergeCodes:se,BuiltinTemplateDrawer:oe,AiEmailBodyGenerator:$e,Plus:w,Help:v,FolderOpened:b,MoreFilled:y,Search:f,Upload:u,View:g,FullScreen:h,Close:_,NewEditorFrame:J(Fe,[["render",function(e,t,i,s,o,a){const n=l,r=L("EditorLoader");return I(),O("div",null,[a.notLoading?(I(),O("div",Le,[A("p",null,j(e.$t("Problem with loading the editor?")),1),B(n,{onClick:t[0]||(t[0]=e=>a.editorFailed())},{default:N(()=>[z(j(e.$t("Use Alternative Editor")),1)],void 0),_:1})])):R("",!0),A("div",Oe,[o.dataSent?R("",!0):(I(),P(r,{key:0,loaderText:e.$t("Loading editor. Please wait....")},null,8,["loaderText"])),A("div",Ie,null,512)])])}],["__scopeId","data-v-0b3373b2"]])},emits:["save","template_inserted","fetch","editor_next","editor_back"],data(){return{showNewEditor:!1,isFullScreen:!1,loadingTemplates:!1,templates:[],fetchingTemplate:!1,loading:!1,editor_status:!0,templates_modal:!1,importTemplateActiveTab:"my_templates",email_body_key:this.body_key||"email_body",search:"",pagination:{current_page:1,per_page:10,total:0},crmTemplates:[],crmTemplateCatalog:[],crmPagination:{current_page:1,per_page:8,total:0},crmLoading:!1,crmTemplatesLoaded:!1,query_data:{sort_by:"ID",sort_type:"DESC"},new_template_name:"",new_template_pop:!1,saving_template:!1,footerSettings:{custom_footer:"no",footer_content:"",disable_footer:"no",background_color:"transparent",footer_padding:"20"},previewTemplateId:"",showTemplatePreview:!1,email_template:{post_title:"",post_content:"",post_excerpt:"",email_subject:"",edit_type:"html",design_template:"simple",settings:{template_config:{}}},newEditorObj:{content:"",title:"",block_type:"",id:0},open_drawer:!1,isLayoutSidebarCollapsed:!1,fixedScrollHandler:null,fixedResizeHandler:null}},created(){this.initNewEditorObj(),this.ensureFooterSettingsInitialized()},watch:{"campaign.settings.footer_settings":{deep:!0,handler(e){const t=this.normalizeFooterSettings(e,this.campaign.settings?this.campaign.settings.template_config:{});this.isFooterSettingsEqual(this.footerSettings||{},t)||(this.footerSettings=t);const i=e||{};this.isFooterSettingsEqual(i,t)||(this.campaign.settings||(this.campaign.settings={}),this.campaign.settings.footer_settings=t),this.syncLegacyDisableFooterFlag(t.disable_footer)}},"campaign.id"(e){"template"===this.newEditorObj.block_type&&e&&String(this.newEditorObj.id)!==String(e)&&(this.newEditorObj.id=e)},"campaign.ID"(e){"template"===this.newEditorObj.block_type&&e&&String(this.newEditorObj.id)!==String(e)&&(this.newEditorObj.id=e)},"$route.params.template_id"(e){"template"===this.newEditorObj.block_type&&e&&String(this.newEditorObj.id)!==String(e)&&(this.newEditorObj.id=e)},isLayoutSidebarCollapsed(e){try{le.set("layout_sidebar_collapsed",e?"yes":"no")}catch(t){}this.$nextTick(()=>{this.fixedResizeHandler&&this.fixedResizeHandler()})},"campaign.design_template"(e,t){if(this.email_template_designs[t],this.email_template_designs[e],this.editor_status&&("raw_classic"!==e&&"raw_html"!==e&&"visual_builder"!==e||this.unmountBlockEditor(),this.email_template_designs[e])){this.campaign.settings||(this.campaign.settings={});const t={...this.campaign.settings.template_config||{}},i={...this.email_template_designs[e].config||{}};if(!Object.keys(i).length)return void(this.campaign.settings.template_config={});Object.entries(i).forEach(([e])=>{"body_bg_color"!==e&&"content_bg_color"!==e&&"design_template"!==e&&t[e]&&(i[e]=t[e])}),this.campaign.settings.template_config=i}this.selectedDesign&&this.selectedDesign.use_gutenberg&&this.initNewEditorObj(),this.updateCustomEditorPageClass()},"newEditorObj.content"(e){this.selectedDesign&&this.selectedDesign.use_gutenberg&&e!==this.campaign[this.email_body_key]&&(this.campaign[this.email_body_key]=e,console.log("[BlockComposer] newEditorObj.content watcher - synced to campaign"))}},computed:{ft(){const e=this.features||{};return{email_style_settings:void 0===e.email_style_settings||e.email_style_settings,email_footer:void 0===e.email_footer||e.email_footer,email_preview:void 0!==e.email_preview?e.email_preview:!!this.show_audit,save_as_template:void 0!==e.save_as_template?e.save_as_template:!!this.enable_template_save,browse_templates:void 0!==e.browse_templates?e.browse_templates:!!this.enable_templates,smartcodes:void 0!==e.smartcodes?e.smartcodes:!!this.show_merge,design_switcher:void 0===e.design_switcher||e.design_switcher}},resolvedFooterSettings(){return this.normalizeFooterSettings(this.footerSettings,this.campaign.settings?this.campaign.settings.template_config:{})},showFooterComplianceWarning(){return!(!this.ft.email_footer||"yes"!==this.resolvedFooterSettings.disable_footer)},selectedDesign(){const e=this.email_template_designs[this.campaign.design_template];return e||this.email_template_designs.simple},classic_styles:()=>"body {line-height: 150%;padding: 0px 20px 20px;} body p, ul, li, ol { font-size: 16px; }",email_template_designs(){return this.disabled_templates?Object.fromEntries(Object.entries(window.fcAdmin.email_template_designs).filter(([e,t])=>!this.disabled_templates[e])):window.fcAdmin.email_template_designs},defaultGutenbergEditorId(){const e=Object.values(this.email_template_designs||{}).find(e=>e&&e.use_gutenberg);return e&&e.id||"simple"},editorTemplateDesigns(){const e=this.email_template_designs||{},t={[this.defaultGutenbergEditorId]:this.$t("Default (Gutenberg)"),raw_html:this.$t("Raw HTML")};return[this.defaultGutenbergEditorId,"raw_classic","raw_html","visual_builder"].reduce((i,s)=>(s&&e[s]&&(i[s]={...e[s],label:t[s]??e[s].label}),i),{})},selectedEditorTemplateId:{get(){const e=this.campaign.design_template;if(this.editorTemplateDesigns[e])return e;const t=this.email_template_designs[e];return t&&t.use_gutenberg&&this.editorTemplateDesigns[this.defaultGutenbergEditorId]?this.defaultGutenbergEditorId:e},set(e){this.campaign.design_template=e}},fullScreenEditorUrl(){const e=this.appVars&&this.appVars.crm_editor_frame?this.appVars.crm_editor_frame:"";if(!e||!this.newEditorObj.block_type)return"#";return e+"&"+new URLSearchParams({block_type:this.newEditorObj.block_type||"",campaign_title:this.newEditorObj.title||"",bid:this.newEditorObj.id||0}).toString()},editorIframeHeight(){return this.isFullScreen?"calc(100vh - 50px)":"calc(100vh - 80px)"},iframeEditorParams(){const e={block_type:this.newEditorObj.block_type,campaign_title:this.newEditorObj.title,bid:this.newEditorObj.id};return this.iframe_nav_mode&&(e.fcrm_ui=this.iframe_nav_mode),this.hideBackBtn&&(e.hideBackBtn="1"),this.hideNextBtn&&(e.hideNextBtn="1"),this.hideSaveBtn&&(e.hideSaveBtn="1"),this.disableGutenbergAutosave&&(e.disable_autosave="1"),this.campaign&&this.campaign.design_template&&(e.design_template=this.campaign.design_template),e},shouldRenderGutenbergEditor(){return this.selectedDesign&&this.selectedDesign.use_gutenberg},aiEmailContext(){var e;return{design_template:this.campaign.design_template||"",editor_type:this.selectedDesign&&this.selectedDesign.use_gutenberg?"block_editor":(null==(e=this.selectedDesign)?void 0:e.template_type)||"",output_format:this.aiEmailOutputFormat,campaign_type:this.newEditorObj.block_type||this.campaign.type||"",has_existing_body:this.hasExistingEmailBody?"yes":"no"}},aiEmailOutputFormat(){return this.selectedDesign?this.selectedDesign.use_gutenberg?"gutenberg_blocks":"classic_editor"===this.selectedDesign.template_type?"classic_html":"raw_html":"html"},showAiEmailGenerator(){return!!this.selectedDesign&&("visual_builder"!==this.campaign.design_template&&"visual_builder_demo"!==this.selectedDesign.template_type&&(this.selectedDesign.use_gutenberg||["classic_editor","raw_html","raw_classic"].includes(this.selectedDesign.template_type)||!this.selectedDesign.template_type))},hasExistingEmailBody(){const e=this.selectedDesign&&this.selectedDesign.use_gutenberg?this.newEditorObj.content:this.campaign[this.email_body_key];return!(!e||!String(e).trim())}},methods:{defaultFooterSettings:()=>({custom_footer:"no",footer_content:"",disable_footer:"no",background_color:"transparent",footer_padding:"20"}),normalizeFooterSettings(e,t={}){const i=e||{},s=Object.prototype.hasOwnProperty.call(i,"disable_footer"),o=Object.prototype.hasOwnProperty.call(i,"custom_footer"),a={...this.defaultFooterSettings(),...i},l=t&&t.disable_footer;s||"yes"===a.disable_footer||"no"===a.disable_footer||(a.disable_footer="yes"===l||"no"===l?l:"no"),a.custom_footer="yes"===a.custom_footer?"yes":"no";!s&&!o&&"yes"===a.disable_footer&&t&&"yes"===t.disable_footer&&"yes"!==a.custom_footer&&0===String(a.footer_content||"").replace(/<[^>]*>/g,"").trim().length&&(a.disable_footer="no",a.custom_footer="no");const n=parseInt(a.footer_padding,10);return!Number.isNaN(n)&&n>=0?(a.footer_padding=String(Math.min(n,80)),a):(a.footer_padding="20",a)},isFooterSettingsEqual(e,t){const i=e||{},s=t||{};return Array.from(new Set([...Object.keys(i),...Object.keys(s)])).every(e=>i[e]===s[e])},ensureFooterSettingsInitialized(){this.campaign.settings||(this.campaign.settings={});const e=this.normalizeFooterSettings(this.campaign.settings.footer_settings,this.campaign.settings.template_config||{});this.isFooterSettingsEqual(this.footerSettings||{},e)||(this.footerSettings=e);const t=this.campaign.settings.footer_settings||{};this.isFooterSettingsEqual(t,e)||(this.campaign.settings.footer_settings=e),this.syncLegacyDisableFooterFlag(e.disable_footer)},onFooterSettingsUpdated(e){this.campaign.settings||(this.campaign.settings={});const t=this.normalizeFooterSettings(e,this.campaign.settings.template_config||{});this.isFooterSettingsEqual(this.footerSettings||{},t)||(this.footerSettings=t);const i=this.campaign.settings.footer_settings||{};this.isFooterSettingsEqual(i,t)||(this.campaign.settings.footer_settings=t),this.syncLegacyDisableFooterFlag(t.disable_footer)},syncLegacyDisableFooterFlag(e){this.campaign.settings||(this.campaign.settings={}),this.campaign.settings.template_config&&"object"==typeof this.campaign.settings.template_config||(this.campaign.settings.template_config={});const t="yes"===e?"yes":"no";this.campaign.settings.template_config.disable_footer!==t&&(this.campaign.settings.template_config.disable_footer=t)},parseEditorType(e){const t=this.email_template_designs[e];return t?t.use_gutenberg?this.$t("Gutenberg Editor"):"classic_editor"===t.template_type?this.$t("Classic Editor"):"custom_component"===t.template_type?this.$t("Custom Component: ")+t.name:"visual_builder_demo"===t.template_type?this.$t("Visual Builder (Demo)"):t.name||e:""},toggleLayoutSidebar(){this.isLayoutSidebarCollapsed=!this.isLayoutSidebarCollapsed},restoreLayoutSidebarState(){try{this.isLayoutSidebarCollapsed="yes"===le.get("layout_sidebar_collapsed")}catch(e){}},closeGutenbergFullScreen(){this.toggleFullScreen()},updateCustomEditorPageClass(){if(!this.use_fullscreen_editor)return;const e=this.selectedDesign&&this.selectedDesign.use_gutenberg;document.documentElement.classList.toggle("fcrm_custom_editor_page",!!e),document.body.classList.toggle("fcrm_custom_editor_page",!!e)},handleEditorNext(){this.$emit("editor_next")},handleEditorBack(){this.$emit("editor_back")},onEditorFullscreenToggle(e){if(this.selectedDesign&&this.selectedDesign.use_gutenberg)if("boolean"!=typeof e)null==e&&this.toggleFullScreen();else{if(this.isFullScreen===e)return;this.toggleFullScreen()}},onOpenEmailPreview(){this.$nextTick(()=>{var e,t,i,s;null==(t=null==(e=this.$refs.iframePreviewRef)?void 0:e.open)||t.call(e),null==(s=null==(i=this.$refs.fullscreenPreviewRef)?void 0:i.open)||s.call(i)})},onOpenTemplatePicker(){this.enable_templates&&this.fetchTemplates()},onOpenSaveTemplate(){this.enable_template_save&&(this.new_template_pop=!0)},onEditorSaveDraft(){this.triggerSave()},onEditorRecoveryNotice(){this.$notify.success(this.$t("Invalid blocks were auto-recovered and saved."))},onStyleConfigChange(e){if(this.campaign.settings||(this.campaign.settings={}),this.campaign.settings.template_config={...this.campaign.settings.template_config||{},...e},e&&Object.prototype.hasOwnProperty.call(e,"disable_footer")){const t="yes"===e.disable_footer?"yes":"no",i=this.normalizeFooterSettings({...this.footerSettings||{},disable_footer:t},this.campaign.settings.template_config||{});this.footerSettings=i,this.campaign.settings.footer_settings=i,this.syncLegacyDisableFooterFlag(i.disable_footer)}},onLayoutChange(e){if(this.campaign&&e&&this.email_template_designs&&this.email_template_designs[e]){this.campaign.design_template=e;const t=this.email_template_designs[e];t&&!t.use_gutenberg&&this.useAlternateEditor(e)}},initNewEditorObj(){if("post_content"===this.body_key){const e=this.campaign.id||this.campaign.ID||this.$route.params.template_id||0;this.newEditorObj.block_type="template",this.newEditorObj.content=this.campaign.post_content||"",this.newEditorObj.title=this.campaign.post_title||"",this.newEditorObj.id=e}else this.campaign.__fcrm_block_type?this.newEditorObj.block_type=this.campaign.__fcrm_block_type:"recurring_campaign"===this.campaign.type?this.newEditorObj.block_type="recurring_campaign":"recurring_mail"===this.campaign.type?this.newEditorObj.block_type="recurring_mail":"sequence_mail"===this.campaign.type?this.newEditorObj.block_type="sequence_mail":this.newEditorObj.block_type="campaign",this.newEditorObj.content=this.campaign.email_body||"",this.newEditorObj.title=this.campaign.title||"",this.newEditorObj.id=this.campaign.id||0,console.log("[BlockComposer] Initialized newEditorObj for block_type:",this.newEditorObj.block_type,"obj:",this.newEditorObj)},useAlternateEditor(e){console.log("useAlternateEditor"),this.unmountBlockEditor();const t=e||(this.selectedDesign&&!this.selectedDesign.use_gutenberg?this.campaign.design_template:"raw_classic");this.campaign.design_template=t,this.editor_status=!1,this.$nextTick(()=>{this.editor_status=!0})},contentChanged(e){this.campaign[this.email_body_key]=e,this.newEditorObj.content=e},handleAiEmailBodyInsert(e){const t=e.email_body||"",i=this.selectedDesign&&this.selectedDesign.use_gutenberg?this.normalizeGutenbergGeneratedContent(t):t;this.campaign[this.email_body_key]=i,this.newEditorObj.content=i,e.subject&&!this.campaign.email_subject&&(this.campaign.email_subject=e.subject),e.preview_text&&("post_content"!==this.body_key||this.campaign.post_excerpt?this.campaign.email_pre_header||(this.campaign.email_pre_header=e.preview_text):this.campaign.post_excerpt=e.preview_text),this.$notify.success(this.$t("AI generated email body inserted"))},normalizeGutenbergGeneratedContent(e){const t=String(e||"");return t.includes("\x3c!-- wp:")?t:this.convertHtmlToGutenbergBlocks(t)},convertHtmlToGutenbergBlocks(e){const t=document.createElement("div");t.innerHTML=this.$sanitize(e||"");const i=[],s=e=>e.innerHTML||e.textContent||"",o=(e,t,i="")=>((e,t="")=>"\x3c!-- wp:"+e+t+" --\x3e")(e,i)+t+(e=>"\x3c!-- /wp:"+e+" --\x3e")(e),a=e=>{const t=String(e||"").trim();t&&i.push(o("paragraph","

"+t+"

"))};return Array.from(t.childNodes).forEach(e=>{if(e.nodeType===Node.TEXT_NODE)return void a(e.textContent);if(e.nodeType!==Node.ELEMENT_NODE)return;const t=e.tagName.toLowerCase();if("h2"===t||"h3"===t){const a="h3"===t?3:2;i.push(o("heading","<"+t+">"+s(e)+"",' {"level":'+a+"}"))}else if("ul"===t||"ol"===t)i.push(o("list","<"+t+">"+s(e)+""));else if("p"===t)a(s(e));else{if("br"===t)return;a(s(e))}}),i.length?i.join("\n\n"):o("paragraph","

")},unmountBlockEditor(){this.showNewEditor=!1},triggerSave(){const e=this.normalizeFooterSettings(this.footerSettings,this.campaign.settings?this.campaign.settings.template_config:{});this.footerSettings=e,this.campaign.settings.footer_settings=e,this.syncLegacyDisableFooterFlag(e.disable_footer),this.$nextTick(()=>{this.$emit("save")})},resetTemplateImportModal(){this.templates=[],this.search="",this.importTemplateActiveTab="my_templates",this.query_data={sort_by:"ID",sort_type:"DESC"},this.pagination={...this.pagination,current_page:1,total:0}},fetchTemplates(){this.loading=!0,this.loadingTemplates=!0,this.templates_modal=!0,this.importTemplateActiveTab="my_templates";const e={per_page:this.pagination.per_page,page:this.pagination.current_page,search:this.search,orderBy:this.query_data.sort_by,order:this.query_data.sort_type};this.$get("templates",e).then(e=>{this.templates=e.templates.data,this.pagination.total=e.templates.total,this.loading=!1}).catch(e=>{console.log(e)}).finally(()=>{this.loadingTemplates=!1,this.loading=!1,this.editor_status=!0})},formatTemplateUpdatedAt(e){return this.nsHumanDiffTime(e.post_modified)||this.nsHumanDiffTime(e.post_date)||""},async InsertChange(e){if(e){if("object"==typeof e){return void(await this.insertTemplateWithWarning(e,"")&&(this.templates_modal=!1))}this.fetchingTemplate=!0;try{const t=await this.$get(`templates/${e}`);await this.insertTemplateWithWarning(t.template,e)&&(this.templates_modal=!1)}catch(t){this.handleError(t)}finally{this.fetchingTemplate=!1}}},getEditorFamily(e){var t;const i={visual_builder:"visual_builder",raw_html:"raw_html",raw_classic:"raw_classic"};if(i[e])return i[e];const s=null==(t=this.email_template_designs)?void 0:t[e];return s&&s.use_gutenberg?"gutenberg":e||""},getEditorFamilyLabel(e){return{gutenberg:this.$t("Gutenberg Editor"),visual_builder:this.$t("Visual Builder"),raw_html:this.$t("Raw HTML Editor"),raw_classic:this.$t("Classic Editor")}[e]||e},async confirmTemplateEditorChange(e){const t=this.getEditorFamily(this.campaign.design_template),i=e.design_template||"simple",s=this.getEditorFamily(i);if(!t||!s||t===s)return!0;const o=this.getEditorFamilyLabel(t),a=this.getEditorFamilyLabel(s),l=this.$t("This template uses %s. Importing it will switch this email from %s to %s. Continue?",a,o,a);try{return await this.$confirm(l,this.$t("Switch Email Editor?"),{confirmButtonText:this.$t("Continue"),cancelButtonText:this.$t("Cancel"),type:"warning"}),!0}catch(n){return!1}},async insertTemplateWithWarning(e,t){return!!(await this.confirmTemplateEditorChange(e))&&this.applyTemplateToCampaign(e,t)},applyTemplateToCampaign(e,t){if(this.disabled_templates&&this.disabled_templates[e.design_template])return this.$notify.error(this.$t("Email_Campaign_Insert_Error_Alert")),!1;this.campaign.settings||(this.campaign.settings={});const i=e.settings||{},s=e.design_template||"simple",o=this.getEditorFamily(s),a=i.template_config||{},l=this.normalizeFooterSettings(i.footer_settings,a),n="gutenberg"===o?this.normalizeGutenbergGeneratedContent(e.post_content||""):e.post_content||"";return this.campaign.template_id=t||"",this.campaign[this.email_body_key]=n,this.campaign.email_subject=e.email_subject||"",this.campaign.email_pre_header=e.post_excerpt||"",this.campaign.design_template=s,this.campaign.settings.template_config={...a,disable_footer:l.disable_footer},this.campaign.settings.footer_settings=l,this.footerSettings=l,e._visual_builder_design?this.campaign._visual_builder_design=e._visual_builder_design:this.campaign._visual_builder_design&&delete this.campaign._visual_builder_design,this.$emit("template_inserted",e),"gutenberg"===o&&(this.newEditorObj.content=n),"visual_builder"===o&&e._visual_builder_design&&this.$nextTick(()=>{var t,i;null==(i=null==(t=this.$refs.customEditorRef)?void 0:t.loadDesign)||i.call(t,e._visual_builder_design)}),!0},handleFixed(){if(this.disable_fixed)return;const e=this.$el&&this.$el.classList?this.$el:null;if(!!(!e||!e.closest(".fcrm_sticky_block_composer_page")))return;if(this.fixedScrollHandler||this.fixedResizeHandler)return;const t=this.$el&&this.$el.classList?this.$el:document.querySelector(".fluentcrm_visual_editor.fc_is_guten");if(!t||!t.classList.contains("fc_is_guten"))return;const i=t.parentElement;if(!i)return;const s=()=>document.contains(i)&&t.parentElement===i;let o=0,a=0,l=null;const n=()=>{s()?(o=(()=>{let e=0;const t=document.getElementById("wpadminbar");if(t){const i=t.getBoundingClientRect();i.bottom>0&&(e=Math.max(e,i.bottom))}return e?Math.round(e+8):window.innerWidth<=782?46:68})(),l=i.getBoundingClientRect(),a=l.top+(window.pageYOffset||document.documentElement.scrollTop||0)):l=null},r=()=>{t.classList.remove("fc_element_fixed"),t.style.removeProperty("position"),t.style.removeProperty("top"),t.style.removeProperty("left"),t.style.removeProperty("width"),t.style.removeProperty("z-index"),t.style.removeProperty("background"),t.style.removeProperty("transition"),s()&&i.style.removeProperty("min-height");const e=document.querySelector(".fcrm_topbar");e&&e.classList.remove("fcrm_has_fixed_composer")};let d=!1,c=!1;const m=()=>{if(this.isFullScreen)return void(d&&(r(),d=!1));if(!l)return void(d&&(r(),d=!1));const e=(window.pageYOffset||document.documentElement.scrollTop||0)>a-o;if(e!==d){if(e){t.classList.add("fc_element_fixed"),s()&&(i.style.minHeight=`${t.offsetHeight}px`),t.style.position="fixed",t.style.top=`${o}px`,t.style.left=`${l.left}px`,t.style.width=`${l.width}px`,t.style.zIndex="30",t.style.background="#ffffff",t.style.transition="top 220ms ease-out";const e=document.querySelector(".fcrm_topbar");e&&e.classList.add("fcrm_has_fixed_composer")}else r();d=e}else d&&(t.style.left=`${l.left}px`,t.style.width=`${l.width}px`)};this.fixedScrollHandler=()=>{c||(c=!0,this._fixedScrollRafId&&cancelAnimationFrame(this._fixedScrollRafId),this._fixedScrollRafId=requestAnimationFrame(()=>{this._fixedScrollRafId=null,c=!1,m()}))},this.fixedResizeHandler=()=>{c||(c=!0,this._fixedResizeRafId&&cancelAnimationFrame(this._fixedResizeRafId),this._fixedResizeRafId=requestAnimationFrame(()=>{this._fixedResizeRafId=null,c=!1,n(),m()}))},window.addEventListener("scroll",this.fixedScrollHandler,{passive:!0}),window.addEventListener("resize",this.fixedResizeHandler,{passive:!0}),this.$nextTick(()=>{n(),m(),this._fixedInitTimer=setTimeout(()=>{this._fixedInitTimer=null,n(),m()},300)})},showInserter(){const e=document.querySelector(".fce_inserter button.block-editor-inserter__toggle");e&&e.click()},handleSortable(e){"descending"===e.order?(this.query_data.sort_by=e.prop,this.query_data.sort_type="desc"):(this.query_data.sort_by=e.prop,this.query_data.sort_type="asc"),this.fetchTemplates()},saveAsTemplate(){if(!this.new_template_name)return this.$notify.error(this.$t("Please provide a template name")),!1;const e={post_content:this.campaign[this.email_body_key],email_subject:this.campaign.email_subject,post_excerpt:this.campaign.email_pre_header,design_template:this.campaign.design_template,settings:{template_config:this.campaign.settings.template_config,footer_settings:this.footerSettings},post_title:this.new_template_name,edit_type:"html"};this.selectedDesign&&this.selectedDesign.use_gutenberg&&(e.post_content=this.newEditorObj.content),"visual_builder"===this.campaign.design_template&&(e._visual_builder_design=this.campaign._visual_builder_design),this.saving_template=!0,this.$post("templates",{template:JSON.stringify(e)}).then(e=>{this.$notify.success(e.message),this.new_template_name="",this.new_template_pop=!1}).catch(e=>{this.handleError(e)}).finally(()=>{this.saving_template=!1})},showPreview(e){this.previewTemplateId=e.ID,this.$get(`templates/${this.previewTemplateId}`).then(e=>{this.email_template=e.template,this.showTemplatePreview=!0}).catch(e=>{console.log(e)}).finally(()=>{})},openBuiltinTemplateDrawer(){this.open_drawer=!0},openFullScreenEditor(){},toggleFullScreen(){if(!this.selectedDesign.use_gutenberg)return;this.isFullScreen=!this.isFullScreen;const e=this.$el,t=e.querySelector(".fc_visual_header");if(this.isFullScreen){this._prevScrollY=window.scrollY||window.pageYOffset||document.documentElement.scrollTop,this._fsHiddenSiblings=[];const i=e.parentElement;i&&Array.from(i.children).forEach(t=>{if(t!==e&&"none"!==t.style.display){const e=t.style.display||"";this._fsHiddenSiblings.push({el:t,display:e}),t.style.display="none"}});const s=document.getElementById("wpadminbar");s&&(this._wpAdminBarPrevDisplay=s.style.display||"",s.style.display="none"),this._fsBodyStyle={position:document.body.style.position||"",top:document.body.style.top||"",left:document.body.style.left||"",right:document.body.style.right||"",overflow:document.body.style.overflow||"",width:document.body.style.width||"",height:document.body.style.height||""},this._fsRootStyle={position:e.style.position||"",top:e.style.top||"",left:e.style.left||"",right:e.style.right||"",bottom:e.style.bottom||"",width:e.style.width||"",height:e.style.height||"",zIndex:e.style.zIndex||"",margin:e.style.margin||"",padding:e.style.padding||""},t&&(this._fsHeaderStyle=t.getAttribute("style")||"",t.style.width="100%",t.style.maxWidth="100%",t.style.left="0",t.style.right="0",t.style.position="relative"),e.style.position="fixed",e.style.top="0",e.style.left="0",e.style.right="0",e.style.bottom="0",e.style.width="100%",e.style.height="100%",e.style.zIndex="999999",e.style.margin="0",e.style.padding="0",document.body.style.position="fixed",document.body.style.top=`-${this._prevScrollY}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.overflow="hidden",document.body.style.width="100%",document.body.style.height="100%",e.classList.add("fcrm_fullscreen_active"),document.body.classList.add("fcrm-editor-fullscreen"),document.documentElement.classList.add("fcrm-editor-fullscreen"),this.$nextTick(()=>{const t=e.querySelector(".iframe-container");t&&(this._fsIframeContainerStyle=t.style.height||"",t.style.height="calc(100vh - 50px)")})}else{this._fsHiddenSiblings&&(this._fsHiddenSiblings.forEach(e=>{e.display?e.el.style.display=e.display:e.el.style.removeProperty("display")}),this._fsHiddenSiblings=[]),this._fsRootStyle&&Object.keys(this._fsRootStyle).forEach(t=>{this._fsRootStyle[t]?e.style[t]=this._fsRootStyle[t]:e.style.removeProperty(t)}),e.classList.remove("fcrm_fullscreen_active"),document.body.classList.remove("fcrm-editor-fullscreen"),document.documentElement.classList.remove("fcrm-editor-fullscreen"),t&&(this._fsHeaderStyle&&"null"!==this._fsHeaderStyle&&""!==this._fsHeaderStyle?t.setAttribute("style",this._fsHeaderStyle):t.removeAttribute("style")),this._fsBodyStyle&&Object.keys(this._fsBodyStyle).forEach(e=>{this._fsBodyStyle[e]?document.body.style[e]=this._fsBodyStyle[e]:document.body.style.removeProperty(e)}),"number"==typeof this._prevScrollY&&window.scrollTo(0,this._prevScrollY);const i=document.getElementById("wpadminbar");if(i&&void 0!==this._wpAdminBarPrevDisplay&&(this._wpAdminBarPrevDisplay?i.style.display=this._wpAdminBarPrevDisplay:i.style.removeProperty("display")),void 0!==this._fsIframeContainerStyle){const t=e.querySelector(".iframe-container");t&&(this._fsIframeContainerStyle?t.style.height=this._fsIframeContainerStyle:t.style.removeProperty("height"))}this.$nextTick(()=>{setTimeout(()=>{try{this.handleFixed()}catch(e){}},10)})}}},beforeUnmount(){this._fixedScrollRafId&&(cancelAnimationFrame(this._fixedScrollRafId),this._fixedScrollRafId=null),this._fixedResizeRafId&&(cancelAnimationFrame(this._fixedResizeRafId),this._fixedResizeRafId=null),this._fixedInitTimer&&(clearTimeout(this._fixedInitTimer),this._fixedInitTimer=null),this.fixedScrollHandler&&(window.removeEventListener("scroll",this.fixedScrollHandler),this.fixedScrollHandler=null),this.fixedResizeHandler&&(window.removeEventListener("resize",this.fixedResizeHandler),this.fixedResizeHandler=null);const e=this.$el&&this.$el.classList?this.$el:null;if(e&&e.classList.contains("fc_element_fixed")){const t=e.parentElement;e.classList.remove("fc_element_fixed"),e.style.removeProperty("position"),e.style.removeProperty("top"),e.style.removeProperty("left"),e.style.removeProperty("width"),e.style.removeProperty("z-index"),e.style.removeProperty("background"),e.style.removeProperty("transition"),t&&t.style.removeProperty("min-height")}if(this.isFullScreen){this.isFullScreen=!1,this._fsHiddenSiblings&&(this._fsHiddenSiblings.forEach(e=>{e&&e.el&&(e.el.style.display=e.display??"")}),this._fsHiddenSiblings=null),this.$el&&this.$el.classList.remove("fcrm_fullscreen_active"),document.documentElement.classList.remove("fcrm-editor-fullscreen"),document.body.classList.remove("fcrm-editor-fullscreen"),this._fsBodyStyle&&Object.keys(this._fsBodyStyle).forEach(e=>{this._fsBodyStyle[e]?document.body.style[e]=this._fsBodyStyle[e]:document.body.style.removeProperty(e)});const e=document.getElementById("wpadminbar");e&&void 0!==this._wpAdminBarPrevDisplay&&(this._wpAdminBarPrevDisplay?e.style.display=this._wpAdminBarPrevDisplay:e.style.removeProperty("display"))}this.use_fullscreen_editor&&(document.documentElement.classList.remove("fcrm_custom_editor_page"),document.body.classList.remove("fcrm_custom_editor_page"))},mounted(){this.handleFixed(),this.updateCustomEditorPageClass(),this.restoreLayoutSidebarState()}},Re={class:"fc_editor_iframe_refs","aria-hidden":"true",style:{position:"absolute",top:"0","pointer-events":"none",visibility:"hidden"}},Be={key:1,class:"fc_editor_fullscreen_refs","aria-hidden":"true",style:{position:"absolute",left:"-9999px",top:"0","pointer-events":"none",visibility:"hidden"}},je={class:"fcrm_block_composer_editor--header"},Ve={class:"fcrm_block_composer_editor--header-content"},Ae={class:"fcrm_block_composer_editor--header-title"},Ne={class:"fcrm_block_composer_editor--header-actions"},Ue={class:"icon"},He={class:"el-dropdown-link fcrm_editor_more_link"},ze={key:0,class:"fcrm_input_hint",style:{"font-size":"90%"}},Me=["disabled"],Ge={class:"fcrm_block_composer_editor--body"},qe={class:"fcrm_block_composer_editor--compose-body-row"},We={class:"fcrm_block_composer_editor--compose-body"},Ye={key:0,class:"fc_composer_classic"},Je={key:2,class:"fcrm_p_24"},Ke={key:3,class:"fc_composer_raw_hrml"},Ze={class:"fc_template_sidebar"},Qe={class:"fcrm_block_composer_editor--compose-sidebar-header"},Xe={class:"fcrm_block_composer_editor--compose-sidebar-header-title"},et={class:"fcrm_block_composer_editor--compose-sidebar-header-actions"},tt=["aria-label"],it={class:"fcrm_block_composer_editor--compose-sidebar-body"},st={class:"fc_template_info"},ot=["innerHTML"],at={key:0,class:"fcrm_fixed_bottom_actions"},lt={key:0,class:"fc_complience_suggest"},nt={class:"fc_editor_warnning"},rt={class:"fcrm_import_template_tabs"},dt={key:0,class:"fcrm_import_template_tab_content"},ct={class:"fcrm_table_wrapper fcrm_import_template_table_wrapper"},mt={class:"fcrm_table_header"},pt={class:"fcrm_table_header_inner"},_t={class:"fcrm_table_header_inner_left"},ht={class:"icon"},gt={class:"fcrm_table_body"},ut=["onClick"],ft={class:"fcrm_template_type_icon"},yt={class:"fcrm-action-btns"},bt={class:"icon"},vt={key:1,class:"fcrm_import_template_tab_content"},wt={key:0,style:{"font-size":"90%","margin-top":"10px"}},Et={key:3};const St=J(Pe,[["render",function(t,o,n,r,c,m){const p=L("NewEditorFrame"),_=L("email-preview"),h=L("email-style-editor"),g=L("ai-email-body-generator"),u=L("merge-codes"),f=L("Icons"),y=l,b=L("FolderOpened"),v=a,w=S,F=e,H=L("Plus"),M=T,J=E,K=x,Z=L("wp-editor"),Q=L("PromoCard"),X=L("raw-editor"),ee=i,te=L("image-radio-tool-tip"),ie=$,se=s,oe=D,ae=C,le=L("pagination-bar"),ne=L("BuildInTemplatesList"),re=d,de=L("builtin-template-drawer"),ce=k;return I(),O("div",{class:V([{fc_is_guten:m.selectedDesign&&m.selectedDesign.use_gutenberg},"fluentcrm_visual_editor"])},[c.editor_status?(I(),O("div",{key:0,class:V(["fc_visual_body",{fcrm_not_guten:!m.selectedDesign.use_gutenberg,fcrm_has_fullscreen_bar:c.isFullScreen&&m.selectedDesign.use_gutenberg}])},[A("div",null,[m.selectedDesign.use_gutenberg?(I(),O(U,{key:0},[m.shouldRenderGutenbergEditor?(I(),P(p,{key:0,onUseAlternateEditor:o[0]||(o[0]=e=>m.useAlternateEditor()),editorParams:m.iframeEditorParams,frameHeight:m.editorIframeHeight,documentTitle:c.newEditorObj.title,templateConfig:n.campaign.settings?n.campaign.settings.template_config:{},footerSettings:m.resolvedFooterSettings,extra_tags:n.extra_tags,fallback_content:c.newEditorObj.content,onTitleUpdated:o[1]||(o[1]=e=>{c.newEditorObj.title=e}),onContentUpdated:m.contentChanged,onEditorNext:m.handleEditorNext,onEditorBack:m.handleEditorBack,onEditorFullscreenToggle:m.onEditorFullscreenToggle,onLayoutChange:m.onLayoutChange,onFooterSettingsUpdated:m.onFooterSettingsUpdated,onOpenEmailPreview:m.onOpenEmailPreview,onOpenTemplatePicker:m.onOpenTemplatePicker,onOpenSaveTemplate:m.onOpenSaveTemplate,onEditorSaveDraft:m.onEditorSaveDraft,onStyleConfigChange:m.onStyleConfigChange,onEditorRecoveryNotice:m.onEditorRecoveryNotice,modelValue:c.newEditorObj.content,"onUpdate:modelValue":o[2]||(o[2]=e=>c.newEditorObj.content=e)},null,8,["editorParams","frameHeight","documentTitle","templateConfig","footerSettings","extra_tags","fallback_content","onContentUpdated","onEditorNext","onEditorBack","onEditorFullscreenToggle","onLayoutChange","onFooterSettingsUpdated","onOpenEmailPreview","onOpenTemplatePicker","onOpenSaveTemplate","onEditorSaveDraft","onStyleConfigChange","onEditorRecoveryNotice","modelValue"])):R("",!0),A("div",Re,[B(_,{ref:"iframePreviewRef",show_audit:n.show_audit,campaign:n.campaign},null,8,["show_audit","campaign"])]),m.ft.email_style_settings&&n.use_fullscreen_editor&&n.campaign.settings?(I(),O("div",Be,[B(h,{ref:"fullscreenStyleEditorRef",footer_settings:c.footerSettings,template_config:n.campaign.settings.template_config,onSave:o[3]||(o[3]=e=>m.triggerSave())},null,8,["footer_settings","template_config"]),B(_,{ref:"fullscreenPreviewRef",show_audit:n.show_audit,campaign:n.campaign},null,8,["show_audit","campaign"])])):R("",!0)],64)):(I(),O(U,{key:1},[A("div",{class:V(["fc_design_template_"+m.selectedDesign.id+"_wrapper","fcrm_block_composer_editor_wrapper"])},[A("div",je,[A("div",Ve,[A("h3",Ae,j(t.$t("Email Body")),1)]),A("div",Ne,[B(_,{show_audit:n.show_audit,campaign:n.campaign},null,8,["show_audit","campaign"]),m.showAiEmailGenerator?(I(),P(g,{key:0,context:m.aiEmailContext,onInsert:m.handleAiEmailBodyInsert},null,8,["context","onInsert"])):R("",!0),n.show_merge?(I(),P(u,{key:1,extra_tags:n.extra_tags,button_text:"{ }"},null,8,["extra_tags"])):R("",!0),n.enable_templates?(I(),P(y,{key:2,title:t.$t("Use template"),size:"small",onClick:m.fetchTemplates},{default:N(()=>[A("span",Ue,[B(f,{"icon-name":"import"})]),z(" "+j(t.$t("Import Templates")),1)],void 0),_:1},8,["title","onClick"])):R("",!0),G(t.$slots,"fc_editor_actions",{},void 0,!0),n.enable_template_save||n.enable_templates||n.campaign.settings?(I(),P(K,{key:3,trigger:"click"},{dropdown:N(()=>[B(J,null,{default:N(()=>[n.enable_templates?(I(),P(w,{key:0,onClick:m.fetchTemplates},{default:N(()=>[B(v,null,{default:N(()=>[B(b)],void 0,!0),_:1}),z(" "+j(t.$t("Import / Use templates")),1)],void 0,!0),_:1},8,["onClick"])):R("",!0),n.enable_template_save?(I(),P(w,{key:1},{default:N(()=>[B(M,{placement:"right-start",width:"400",visible:c.new_template_pop,"onUpdate:visible":o[6]||(o[6]=e=>c.new_template_pop=e),trigger:"click"},{reference:N(()=>[q((I(),O("span",{disabled:c.saving_template},[B(v,null,{default:N(()=>[B(H)],void 0,!0),_:1}),z(" "+j(t.$t("Save as template")),1)],8,Me)),[[ce,c.saving_template]])]),default:N(()=>[A("label",null,j(t.$t("Template Name")),1),B(F,{placeholder:t.$t("Template Name"),style:{margin:"10px 0"},type:"text",modelValue:c.new_template_name,"onUpdate:modelValue":o[4]||(o[4]=e=>c.new_template_name=e)},null,8,["placeholder","modelValue"]),q((I(),P(y,{disabled:c.saving_template,onClick:o[5]||(o[5]=e=>m.saveAsTemplate()),type:"primary",size:"small"},{default:N(()=>[z(j(t.$t("Save")),1)],void 0,!0),_:1},8,["disabled"])),[[ce,c.saving_template]]),"visual_builder"==n.campaign.design_template?(I(),O("p",ze,j(t.$t("Will be stored from your last saved email contents")),1)):R("",!0)],void 0,!0),_:1},8,["visible"])],void 0,!0),_:1})):R("",!0)],void 0,!0),_:1})]),default:N(()=>[A("span",He,[B(f,{"icon-name":"more"})])],void 0),_:1})):R("",!0)]),n.use_fullscreen_editor&&n.campaign.settings?(I(),P(h,{key:0,ref:"legacyStyleEditorRef",footer_settings:c.footerSettings,template_config:n.campaign.settings.template_config,onSave:o[7]||(o[7]=e=>m.triggerSave()),style:{display:"none"}},null,8,["footer_settings","template_config"])):R("",!0)]),A("div",Ge,[A("div",qe,[A("div",We,["classic_editor"==m.selectedDesign.template_type?(I(),O("div",Ye,[B(Z,{height:350,extra_style:m.classic_styles,modelValue:n.campaign[c.email_body_key],"onUpdate:modelValue":o[8]||(o[8]=e=>n.campaign[c.email_body_key]=e),showSmartCodes:!1},null,8,["extra_style","modelValue"])])):"custom_component"==m.selectedDesign.template_type?(I(),O("div",{key:1,class:V("fc_composer_"+m.selectedDesign.id)},[(I(),P(W(m.selectedDesign.component),{ref:"customEditorRef",onSave:o[9]||(o[9]=e=>m.triggerSave()),modelValue:n.campaign[c.email_body_key],"onUpdate:modelValue":o[10]||(o[10]=e=>n.campaign[c.email_body_key]=e),extra_tags:n.extra_tags,campaign:n.campaign},null,40,["modelValue","extra_tags","campaign"]))],2)):"visual_builder_demo"==m.selectedDesign.template_type?(I(),O("div",Je,[B(Q,{heading:t.$t("Build Email By Drag and Drop Visual Editor"),description:t.$t("Visual_Email_Builder_Alert"),"show-header-upgrade-icon":!1},null,8,["heading","description"])])):(I(),O("div",Ke,[B(X,{modelValue:n.campaign[c.email_body_key],"onUpdate:modelValue":o[11]||(o[11]=e=>n.campaign[c.email_body_key]=e),hide_smart_codes:!0},null,8,["modelValue"])]))]),A("div",{class:V(["fcrm_block_composer_editor--compose-sidebar",{fcrm_is_collapsed:c.isLayoutSidebarCollapsed}])},[A("div",Ze,[A("div",Qe,[A("div",Xe,j(t.$t("Select Editor")),1),A("div",et,[B(ee,{content:c.isLayoutSidebarCollapsed?t.$t("Open Sidebar"):t.$t("Close Sidebar"),placement:"top"},{default:N(()=>[A("button",{type:"button",class:"fcrm_template_sidebar_toggle","aria-label":c.isLayoutSidebarCollapsed?t.$t("Open Sidebar"):t.$t("Close Sidebar"),onClick:o[12]||(o[12]=(...e)=>m.toggleLayoutSidebar&&m.toggleLayoutSidebar(...e))},[B(f,{"icon-name":"sidebar"})],8,tt)],void 0),_:1},8,["content"])])]),A("div",it,[B(te,{boxWidth:60,boxHeight:50,field:{options:m.editorTemplateDesigns},modelValue:m.selectedEditorTemplateId,"onUpdate:modelValue":o[13]||(o[13]=e=>m.selectedEditorTemplateId=e)},null,8,["field","modelValue"]),A("div",st,[A("div",{innerHTML:m.selectedDesign.template_info},null,8,ot)])])])],2)])])],2),n.hideBackBtn&&n.hideNextBtn?R("",!0):(I(),O("div",at,[n.hideBackBtn?R("",!0):(I(),P(y,{key:0,onClick:m.handleEditorBack},{default:N(()=>[z(j(t.$t("Back")),1)],void 0),_:1},8,["onClick"])),n.hideNextBtn?R("",!0):(I(),P(y,{key:1,type:"primary",onClick:m.handleEditorNext},{default:N(()=>[z(j(t.$t("Next")),1)],void 0),_:1},8,["onClick"]))]))],64))]),m.showFooterComplianceWarning?(I(),O("div",lt,[A("p",nt,[z(j(t.$t("Default footer has been disabled. Please include"))+" ",1),o[22]||(o[22]=A("code",null,"##crm.unsubscribe_url##",-1)),z(" "+j(t.$t("or"))+" ",1),o[23]||(o[23]=A("code",null,"##crm.manage_subscription_url##",-1)),z(" "+j(t.$t("in your email body for compliance")),1)]),A("div",null,[A("b",null,j(t.$t("Suggested text to include:")),1),o[24]||(o[24]=A("p",{innerHTML:"{{crm.unsubscribe_html|Unsubscribe}} | {{crm.manage_subscription_html|Manage Preference}}"},null,-1))])])):R("",!0)],2)):R("",!0),n.enable_templates?(I(),P(re,{key:1,"close-on-click-modal":!1,title:t.$t("Select Template"),modelValue:c.templates_modal,"onUpdate:modelValue":o[16]||(o[16]=e=>c.templates_modal=e),onClosed:m.resetTemplateImportModal,"append-to-body":!0,width:"60%",class:"fluentcrm_import_email_templates","modal-class":"fcrm_import_template_modal"},{default:N(()=>[A("div",rt,[B(se,{modelValue:c.importTemplateActiveTab,"onUpdate:modelValue":o[14]||(o[14]=e=>c.importTemplateActiveTab=e),class:"fcrm_import_template_tabs_nav"},{default:N(()=>[B(ie,{value:"my_templates"},{default:N(()=>[z(j(t.$t("My Templates")),1)],void 0,!0),_:1}),B(ie,{value:"crm_templates"},{default:N(()=>[z(j(t.$t("CRM Templates")),1)],void 0,!0),_:1})],void 0,!0),_:1},8,["modelValue"])]),"my_templates"===c.importTemplateActiveTab?(I(),O("div",dt,[A("div",ct,[A("div",mt,[A("div",pt,[A("div",_t,[B(F,{clearable:"",size:"small",modelValue:c.search,"onUpdate:modelValue":o[15]||(o[15]=e=>c.search=e),onClear:m.fetchTemplates,onKeyup:Y(m.fetchTemplates,["enter"]),placeholder:t.$t("Type and Enter...")},{prefix:N(()=>[A("span",ht,[B(f,{"icon-name":"search"})])]),_:1},8,["modelValue","onClear","onKeyup","placeholder"])])])]),A("div",gt,[q((I(),P(ae,{"empty-text":t.$t("No Data Available"),data:c.templates,stripe:"",onSortChange:m.handleSortable,border:"",style:{width:"100%"}},{default:N(()=>[B(oe,{prop:"post_title",label:t.$t("Title"),sortable:"custom"},{default:N(e=>[A("h3",{class:"template-name",onClick:t=>m.InsertChange(e.row.ID)},[A("span",ft,["visual_builder"==e.row.design_template?(I(),P(f,{key:0,"icon-name":"visualBuilder"})):"raw_classic"==e.row.design_template?(I(),P(f,{key:1,"icon-name":"classicEditor"})):"raw_html"==e.row.design_template?(I(),P(f,{key:2,"icon-name":"rawHTML"})):(I(),P(f,{key:3,"icon-name":"gutenberg"}))]),z(" "+j(e.row.post_title),1)],8,ut)]),_:1},8,["label"]),R("",!0),B(oe,{width:"150",prop:"post_modified",label:t.$t("Last Modified"),sortable:"custom"},{default:N(e=>[z(j(m.formatTemplateUpdatedAt(e.row)),1)]),_:1},8,["label"]),B(oe,{width:"200",align:"right"},{default:N(e=>[A("div",yt,[B(y,{loading:c.fetchingTemplate,disabled:c.fetchingTemplate,onClick:t=>m.InsertChange(e.row.ID),size:"small"},{default:N(()=>[z(j(t.$t("Use Template")),1)],void 0,!0),_:1},8,["loading","disabled","onClick"]),B(y,{onClick:t=>m.showPreview(e.row),class:"only-icon-btn small","aria-label":t.$t("Preview Template"),title:t.$t("Preview Template")},{default:N(()=>[A("span",bt,[B(f,{"icon-name":"eye"})])],void 0,!0),_:1},8,["onClick","aria-label","title"])])]),_:1})],void 0,!0),_:1},8,["empty-text","data","onSortChange"])),[[ce,c.loading]])])]),B(le,{pagination:c.pagination,onFetch:m.fetchTemplates},null,8,["pagination","onFetch"])])):(I(),O("div",vt,[B(ne,{"insert-mode":!0,redirect_on_import:!1,onTemplateImported:m.InsertChange},null,8,["onTemplateImported"])]))],void 0),_:1},8,["title","modelValue","onClosed"])):R("",!0),n.enable_template_save&&m.selectedDesign&&m.selectedDesign.use_gutenberg?(I(),P(re,{key:2,title:t.$t("Save as template"),modelValue:c.new_template_pop,"onUpdate:modelValue":o[19]||(o[19]=e=>c.new_template_pop=e),width:"460px","append-to-body":!0,"close-on-click-modal":!1,class:"fluentcrm_save_as_template_dialog"},{default:N(()=>[A("label",null,j(t.$t("Template Name")),1),B(F,{placeholder:t.$t("Template Name"),style:{margin:"10px 0"},type:"text",modelValue:c.new_template_name,"onUpdate:modelValue":o[17]||(o[17]=e=>c.new_template_name=e)},null,8,["placeholder","modelValue"]),q((I(),P(y,{disabled:c.saving_template,onClick:o[18]||(o[18]=e=>m.saveAsTemplate()),type:"primary"},{default:N(()=>[z(j(t.$t("Save")),1)],void 0,!0),_:1},8,["disabled"])),[[ce,c.saving_template]]),"visual_builder"==n.campaign.design_template?(I(),O("p",wt,j(t.$t("Will be stored from your last saved email contents")),1)):R("",!0)],void 0),_:1},8,["title","modelValue"])):R("",!0),c.showTemplatePreview?(I(),O("div",Et,[B(_,{onModalClosed:o[20]||(o[20]=()=>{c.showTemplatePreview=!1}),auto_load:!0,show_audit:!0,campaign:c.email_template},null,8,["campaign"])])):R("",!0),B(de,{open_drawer:c.open_drawer,"onUpdate:open_drawer":o[21]||(o[21]=e=>c.open_drawer=e)},null,8,["open_drawer"])],2)}],["__scopeId","data-v-5a5780f5"]]);export{St as E};