import{_ as f,o as r,c as o,a as t,d as P,l as i,f as k,H as S,F as p,x as w,p as g,b as y,t as m,q as b,s as C,y as T,Q as N}from"./C8VztkeY.js";import{_ as $}from"./WebPager-D1LNwyLU.mjs";import"./Pager-IQX1Rj4U.mjs";const B={props:{processing:{type:Boolean}}},F={class:"web-processing-spinner"},W={key:0,class:"spinner"};function V(s,a,n,l,h,c){var u;const _=k;return r(),o("div",F,[n.processing?(r(),o("div",W,[t("div",null,[P(_,{icon:"ei:spinner-3",width:100,"icon-color":(u=s.$ss)!=null&&u.useNewDesign?s.$ss.colors.primary.main:s.$ss.baseStyles.primaryColor},null,8,["icon-color"])])])):i("",!0)])}const q=f(B,[["render",V]]),D={props:{templates:{type:Array,required:!0},showPager:{type:Boolean,default:!1}},data(){return{currTemplates:this.templates,currPage:1,processing:!1}},computed:{useConvertUtcTimeToLocalDate(){return S},itemsPerPage(){return 20}},methods:{hasNextPage(s){var a,n;return(n=(a=s==null?void 0:s.campaigns)==null?void 0:a.pageInfo)==null?void 0:n.hasNextPage},async getPage(s,a){this.processing=!0;const n={templateId:this.currTemplates[s].id,omedaStatus:["Sent","Sending"],sortOrder:"desc",limit:this.itemsPerPage,skip:(a-1)*this.itemsPerPage,hideOnWeb:!1},l=await this.$gql.queryStream("getNewsletterCampaignStream",n);l.error?this.currTemplates[0].campaigns={items:[]}:(this.currTemplates[s].campaigns={...l.data},this.currPage=a),this.processing=!1}}},L={class:"web-newsletter-campaigns-wrapper"},M={key:0,style:{maxWidth:"630px"}},O=["src"],j={key:1,style:{maxWidth:"630px"}},E=["src"],U={key:2},z={style:{height:"75px",width:"calc(100% - 250px)",padding:"5px 10px"}},I=["src"],A={class:"campaigns"},H=["href"],Q={class:"date"},R={class:"actions"},G=["href"],J={key:0,class:"divider"},K=["href"];function X(s,a,n,l,h,c){const _=q,u=$,v=N;return r(),o("div",L,[t("div",{class:T(["web-newsletter-campaigns",h.currTemplates.length>1?"multi":""])},[(r(!0),o(p,null,w(h.currTemplates,(e,x)=>(r(),o("div",{key:e.id,class:"template"},[t("div",{class:"content",style:g({fontFamily:s.$ss.primaryFontFamily})},[n.showPager?(r(),y(_,{key:0,processing:h.processing},null,8,["processing"])):i("",!0),t("div",{class:"heading",style:g({backgroundColor:e.header.backgroundColor})},[e.header.headerStyle.style===1?(r(),o("div",M,[t("img",{src:e.header.headerStyle.style1Settings.image,style:{maxWidth:"100%"}},null,8,O)])):i("",!0),e.header.headerStyle.style===2?(r(),o("div",j,[t("img",{src:e.header.headerStyle.style2Settings.image,style:{maxWidth:"100%"}},null,8,E)])):i("",!0),e.header.headerStyle.style===3?(r(),o("div",U,[t("table",{style:g({width:"100%",backgroundColor:e.header.backgroundColor})},[t("tbody",null,[t("tr",null,[t("td",z,[t("h1",{style:g({color:e.header.headerStyle.style3Settings.nameColor,fontFamily:e.styles.primaryFontFamily})},m(e.name),5)]),t("td",{style:g({height:"75px",padding:"10px",width:"120px",background:e.header.headerStyle.style3Settings.logoBackgroundColor})},[t("img",{src:e.header.headerStyle.style3Settings.image,width:120},null,8,I)],4)])])],4)])):i("",!0)],4),t("div",A,[(r(!0),o(p,null,w(e.campaigns.items,d=>(r(),o("div",{key:d.id,class:"campaign"},[t("a",{target:"_blank",href:`/newsletter/${d.id}`,class:"link"},[t("span",Q,m(c.useConvertUtcTimeToLocalDate(d.deploymentDate,"MMM d, yyyy")),1),b(m(d.subject),1)],8,H)]))),128))]),P(v,null,{default:C(()=>[n.showPager&&e.campaigns.totalCount>c.itemsPerPage?(r(),y(u,{key:0,"active-page":h.currPage,"total-count":e.campaigns.totalCount,"items-per-page":c.itemsPerPage,onChangeValue:d=>c.getPage(x,d)},null,8,["active-page","total-count","items-per-page","onChangeValue"])):i("",!0)]),_:2},1024),t("div",R,[t("a",{href:`/latest-newsletter/${e.id}`,target:"_blank"},"Latest Edition",8,G),!n.showPager&&c.hasNextPage(e)?(r(),o("span",J,"|")):i("",!0),!n.showPager&&c.hasNextPage(e)?(r(),o("a",{key:1,href:`/newsletters/${e.id}`},"View More",8,K)):i("",!0)])],4)]))),128))],2)])}const Y=f(D,[["render",X]]),te={__name:"NewsletterCampaignsBlock",props:{data:{type:Object,required:!0,validator(s){return["templates"].every(a=>a in s)}},settings:{type:Object,required:!0,validator(s){return["showPager"].every(a=>a in s)}}},setup(s){return(a,n)=>{const l=Y;return r(),y(l,{templates:s.data.templates,"show-pager":s.settings.showPager},null,8,["templates","show-pager"])}}};export{te as default};