import{W as e,X as i,aa as t,Z as a,J as s,az as l,a8 as r,a6 as n,ac as o,$ as h}from"./vendor.js?ver=3.1.8";import{_ as d}from"./fc-bits-ui.js?ver=3.1.8";const m={name:"PreviewIframeBuilder",props:{preview_html:{type:String,default:()=>""},campaign:{type:Object,default:()=>({})},campaign_id:{default:()=>0},frame_height:{type:String,default:()=>"500px"},show_audit:{type:Boolean,default:()=>!1}},data(){return{loading_preview:!0,invalidDoms:[],preview_full_html:this.preview_html}},methods:{loadFrame(){const e=this.$refs.fc_ifr;if(!e)return;const i=e.contentDocument||e.contentWindow&&e.contentWindow.document;i&&(i.open(),i.write(this.preview_full_html),i.close(),this.loading_preview=!1,this.checkDoms(this.preview_full_html))},fetchHtml(){this.loading_preview=!0,this.showing_view=!0,this.$post("campaigns/email-preview-html",{campaign_id:this.campaign_id,disable_subscriber:"yes"}).then(e=>{this.preview_full_html=e.preview_html,this.$nextTick(()=>this.loadFrame())}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading_preview=!1})},checkDoms(e){if(!this.show_audit)return;this.invalidDoms=[];const i=jQuery('a[href=""], a:not([href]), a[href="#"]',e);this.each(i,e=>{console.log(e),this.invalidDoms.push({text:e.text||"Empty Text / Image"})})}},mounted(){this.campaign_id?this.fetchHtml():this.loadFrame()}},c={class:"fc_iframe_wrap"},p={key:0},_={key:1,class:"el-alert el-alert--error is-light",style:{display:"block",overflow:"hidden",padding:"0 20px","margin-bottom":"0px"}},f={style:{"font-size":"16px"}},v={class:"inline_disc_lists"};const u=d(m,[["render",function(d,m,u,w,g,y){return e(),i("div",c,[g.loading_preview?(e(),i("h3",p,t(d.$t("Loading Preview. Please wait...")),1)):u.show_audit&&g.invalidDoms&&g.invalidDoms.length?(e(),i("div",_,[a("h3",f,t(d.$t("Invalid_Link_Detected"))+" ("+t(g.invalidDoms.length)+")",1),a("ul",v,[(e(!0),i(s,null,l(g.invalidDoms,(a,s)=>(e(),i("li",{key:s},t(a.text),1))),128))])])):r("",!0),n(a("iframe",{ref:"fc_ifr",frameborder:"0",scrolling:"auto",style:h([{width:"100%",border:"none",display:"block"},{height:u.frame_height}])},null,4),[[o,!g.loading_preview]])])}]]);export{u as P};
