import{_ as N,b as v,o as r,v as _,d as f,bX as x,p as d,a as l,c as n,l as u,t as b,F as I,y as F,z as T,e as E,O as V,bY as B,b5 as O,Q as M,R as P,q as w,N as q,i as C,bw as m,B as p,f as U,al as A,cX as W,cr as z,c4 as D,bR as L}from"./BfF8i_OD.js";const R={props:{buttonText:{type:String,default:"SIGN UP",required:!0},headerText:{type:String,default:"Sign up for our eNewsletters",required:!0},headerTextColor:{type:String,required:!0},bodyTextColor:{type:String,required:!0},bodyBackgroundColor:{type:String},headerBackgroundColor:{type:String},buttonBackgroundColor:{type:String,required:!0},buttonTextColor:{type:String,required:!0},showDescription:{type:Boolean},noAvailableNlText:{default:"No Available Newsletters",type:String},simpleMode:{type:Boolean,default:!0},recaptchaKey:{type:String}},async setup(e){const{localeFields:t,getCurrentCountry:s}=D({inlineLabels:!0}),c=L(e.recaptchaKey);return{localeFields:t,getCurrentCountry:s,recaptcha:c}},data(){return{NewsletterSubscriptionSource:z,NewsletterSubscriptionActions:W,userInfo:null,availableNewsletters:[],subscribed:[],message:null,processing:!1,showErrors:!1,error:"",fieldValues:{email:""},fieldValuesCompliance:{},fieldErrors:{},complianceNeeded:!1,fieldInfo:{rows:[{fields:{email:{type:"email_input",placeholder:"Email Address",required:!0,showErrors:!1,icon:!1}}},{fields:{countryCode:this.localeFields.countryCode}}]},fieldInfoCompliance:{rows:[{fields:{compliance:this.localeFields.compliance}}]}}},computed:{textStyle(){return{fontFamily:this.$ss.primaryFontFamily}},emailField(){var e;return(e=this.fieldInfo.rows[0])==null?void 0:e.fields.email},countryCodeField(){var e;return(e=this.fieldInfo.rows[1])==null?void 0:e.fields.countryCode},regionsField(){var e;return(e=this.fieldInfo.rows[2])==null?void 0:e.fields.region},complianceField(){var e;return(e=this.fieldInfoCompliance.rows[0])==null?void 0:e.fields.compliance},omedaSite(){var e;return((e=this.$ss.magazine)==null?void 0:e.nlOmedaSite)??""},omedaQuery(){var e;return((e=this.$ss.magazine)==null?void 0:e.nlSignupQuery)??""}},watch:{fieldValues:{deep:!0,handler(){this.updateFieldInfo()}}},async mounted(){var e;this.userInfo=await m.getUserInfo(),this.subscribed=((e=this.userInfo)==null?void 0:e.newsletters)??[],this.availableNewsletters=this.$ss.newsletters.enabledNewsletters.filter(t=>this.userInfo?!this.subscribed.includes(t.omedaProductId)&&t.showInSubscribeBlock:t.showInSubscribeBlock)},methods:{update(e,t,s){this.fieldValues[e]=t,this.fieldErrors[e]={errorObj:s}},updateFieldInfo(){const e=this.getCurrentCountry(this.fieldValues.countryCode);e!=null&&e.regions?(this.localeFields.region.options=e.regions.options,this.localeFields.region.placeholder=e.regions.label,this.fieldInfo.rows[2]={fields:{region:this.localeFields.region}}):(delete this.fieldValues.region,this.fieldInfo.rows.splice(2,1)),e!=null&&e.compliance?this.complianceNeeded=!0:(delete this.fieldValues.compliance,this.update({...this.fieldValues,error:{valid:!0,errors:[]}}),this.complianceNeeded=!1)},canRenderDescription(e){return e.description&&this.showDescription},handleNewsletterClick(e,t){if(this.userInfo){this.toggleUserSubscription(e,t);return}const s=this.subscribed.indexOf(e);s===-1?this.subscribed.push(e):this.subscribed.splice(s,1)},handleSubmitClick(){this.showErrors=A(this.fieldErrors??{})>0,this.checkErrors()},async submit(){var e,t;try{if(this.error="",this.subscribed.length===0)throw new Error("Please select a newsletter before continuing");if(this.showErrors)throw new Error("Please correct issues with this form");this.fieldValues.compliance===""&&(this.fieldValues.compliance=!1),this.processing=!0;const s=await this.recaptcha("newsletterSubscribeSignUp"),c=((t=(e=C())==null?void 0:e.query)==null?void 0:t.pk)??this.$ss.newsletters.subscribeBlockSettings.promoCode,o={email:this.fieldValues.email,omedaProducts:this.subscribed,countryCode:this.fieldValues.countryCode,regionCode:this.fieldValues.region,consent:m.formatConsentObject({country:this.fieldValues.countryCode,region:this.fieldValues.region,compliance:this.fieldValues.compliance}),recaptchaToken:s,promoCode:c},i=await this.$gql.mutate("subscribeAnonymousCustomer",o);if(i.error)throw new Error(i.message);const{trackNewsletterSubscription:y}=U();for(let h=0;h[f(k,{"include-frame":!1,error:o.error,message:o.message,processing:o.processing,style:d({fontFamily:e.$ss.primaryFontFamily,padding:s.simpleMode?"10px 0":0}),padding:"0",class:"ebm-subscribe-wrapper"},{default:_(()=>[l("div",{class:"ebm-subscribe",style:d(i.textStyle)},[l("div",{class:"header",style:d({backgroundColor:s.headerBackgroundColor,color:s.headerTextColor})},[l("h2",null,b(s.headerText),1)],4),l("div",{class:"subscribe-container",style:d({backgroundColor:s.bodyBackgroundColor})},[s.simpleMode?u("",!0):(r(),n("div",{key:0,class:"subscribe-info",style:d({color:s.bodyTextColor})},[o.userInfo?(r(),n("div",j,[o.availableNewsletters.length===0?(r(),n("div",{key:0,innerHTML:s.noAvailableNlText},null,8,H)):(r(),n("div",Q," Hello "+b(o.userInfo.firstName)+", would you like to update your newsletter subscription(s)? ",1))])):u("",!0),l("div",{class:"newsletters",style:d({padding:o.availableNewsletters.length===0?"0":"20px 0"})},[(r(!0),n(I,null,F(o.availableNewsletters,a=>(r(),n("div",{key:a.omedaProductId,class:T(["newsletter",o.availableNewsletters.length===1?"single":""])},[l("div",{class:"newsletter-content",style:d({alignItems:i.canRenderDescription(a)?"flex-start":"center"})},[l("div",Y,[f(y,{icon:o.subscribed.includes(a.omedaProductId)?"mdi:checkbox-outline":"mdi:checkbox-blank-outline",width:26,"icon-color":s.bodyTextColor,onClick:ce=>i.handleNewsletterClick(a.omedaProductId,a.title)},null,8,["icon","icon-color","onClick"])]),i.canRenderDescription(a)?(r(),n("div",G,[l("div",K,b(a.title),1),l("div",{class:"description",innerHTML:a.description},null,8,X)])):(r(),n("div",J,[l("div",Z,b(a.title),1)]))],4)],2))),128))],4)],4)),!o.userInfo&&!s.simpleMode?(r(),n("form",{key:1,class:"web-subscribe-form",onSubmit:t[0]||(t[0]=V((...a)=>i.submit&&i.submit(...a),["prevent"]))},[l("div",$,[f(h,{class:"fields","field-info":o.fieldInfo,"field-values":o.fieldValues,onUpdate:i.update},null,8,["field-info","field-values","onUpdate"]),l("div",ee,[f(g,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:i.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])]),o.complianceNeeded?(r(),n("div",se,[o.complianceNeeded?(r(),v(h,{key:0,"field-info":o.fieldInfoCompliance,"field-values":o.fieldValuesCompliance,onUpdate:i.update},null,8,["field-info","field-values","onUpdate"])):u("",!0)])):u("",!0),l("div",te,[f(g,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:i.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])],32)):u("",!0),s.simpleMode?(r(),n("form",oe,[l("input",{type:"hidden",name:"omedasite",value:i.omedaSite},null,8,ie),M(l("input",{"onUpdate:modelValue":t[1]||(t[1]=a=>o.fieldValues.email=a),type:"email",name:"em",placeholder:"Email Address"},null,512),[[P,o.fieldValues.email]]),i.omedaQuery?(r(),n("input",{key:0,type:"hidden",name:"pk",value:i.omedaQuery},null,8,re)):u("",!0),f(g,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"fullWidth"},null,8,["color","alt-color","label"])])):u("",!0)],4),!s.simpleMode&&o.availableNewsletters.length!==0?(r(),n("div",{key:0,class:"consent",style:d({backgroundColor:s.bodyBackgroundColor,color:s.bodyTextColor})},[o.userInfo?(r(),n("span",le,"Your account is subject")):(r(),n("span",ne,"By submitting your information, you are agreeing")),t[2]||(t[2]=w(" to Endeavor Business Media's ")),t[3]||(t[3]=l("a",{href:"https://www.endeavorbusinessmedia.com/endeavor-terms"},"Terms of Service",-1)),t[4]||(t[4]=w(" and ")),t[5]||(t[5]=l("a",{href:"https://www.endeavorbusinessmedia.com/privacy-policy"},"Privacy Policy",-1)),t[6]||(t[6]=w(". "))],4)):u("",!0)],4)]),_:1},8,["error","message","processing","style"])]),_:1})}const ue=N(R,[["render",ae]]);export{ue as default};