import{_ as x,bs as N,aY as m,z as f,o as i,b as _,w,d as u,n as c,a as r,t as b,c as l,i as d,F as S,r as I,v as F,K as T,L as E,M as V,k as y,f as B,aZ as M,N as P}from"./entry.DPwc-EV0.js";import{_ as O}from"./WebFormFieldsNew-e5jbMxoy.mjs";import{_ as U}from"./WebFormWrapper-Dq_9vKBT.mjs";import{u as q}from"./useVueRecaptcha-BjW5Chvt.mjs";import{u as z}from"./dynamic-import-helper-CUkzFinH.mjs";const L={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:o,getCurrentCountry:s}=N({inlineLabels:!0}),h=q(e.recaptchaKey);return{localeFields:o,getCurrentCountry:s,recaptcha:h}},data(){return{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(o=>this.userInfo?!this.subscribed.includes(o.omedaProductId)&&o.showInSubscribeBlock:o.showInSubscribeBlock)},methods:{update(e,o,s){this.fieldValues[e]=o,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,o){if(this.userInfo){this.toggleUserSubscription(e,o);return}const s=this.subscribed.indexOf(e);s===-1?this.subscribed.push(e):this.subscribed.splice(s,1)},handleSubmitClick(){this.showErrors=z(this.fieldErrors??{})>0,this.checkErrors()},async submit(){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 e=await this.recaptcha("newsletterSubscribeSignUp"),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:e},s=await this.$gql.mutate("subscribeAnonymousCustomer",o);if(s.error)throw new Error(s.message);this.message="You're all done!You will now receive updates from the newsletter(s) you selected."}catch(e){this.error=e}finally{this.processing=!1}},checkErrors(){var e,o,s,h;this.emailField.showErrors=!((e=this.fieldErrors.email)!=null&&e.errorObj.valid),this.countryCodeField.showErrors=!((o=this.fieldErrors.countryCode)!=null&&o.errorObj.valid),this.regionsField&&(this.regionsField.showErrors=!((s=this.fieldErrors.region)!=null&&s.errorObj.valid)),this.complianceField&&(this.complianceField.showErrors=!((h=this.fieldErrors.compliance)!=null&&h.errorObj.valid))},async toggleUserSubscription(e,o){this.subscribed.includes(e)?confirm("Are you sure you wish to opt out from this newsletter?")&&((await m.unsubscribeToNewsletter(e)).error?f.error("Newsletter opt out failed.Please try again or contact support for assistance."):(this.subscribed.splice(this.subscribed.indexOf(e),1),f.success("Newsletter opt out successful!"))):(await m.subscribeToNewsletter(e,o,"nl_widget",this.$ss.memberships.newsletterPromoCode)).error?f.error("Newsletter opt in failed.Please try again or contact support for assistance."):(this.subscribed.push(e),f.success("Newsletter opt in successful!"))}}},A={key:0,class:"user-welcome"},D=["innerHTML"],j={key:1},H={class:"toggle"},W={key:0,class:"overview"},Q={style:{"font-weight":"800"},class:"name"},R=["innerHTML"],Y={key:1,class:"overview"},K={class:"name"},G={class:"non-compliance-fields"},Z={class:"full-button"},J={key:0,class:"compliance-fields"},X={class:"mobile-button"},$={key:2,class:"web-subscribe-form simple",action:"https://endeavor.dragonforms.com/loading.do",method:"GET"},ee=["value"],se=["value"],oe={key:0},te={key:1},ie=r("a",{href:"https://www.endeavorbusinessmedia.com/endeavor-terms"},"Terms of Service",-1),re=r("a",{href:"https://www.endeavorbusinessmedia.com/privacy-policy"},"Privacy Policy",-1);function le(e,o,s,h,t,n){const v=B,g=O,p=M,C=U,k=P;return i(),_(k,null,{default:w(()=>[u(C,{"include-frame":!1,error:t.error,message:t.message,processing:t.processing,style:c({fontFamily:e.$ss.primaryFontFamily,padding:s.simpleMode?"10px 0":0}),padding:"0",class:"ebm-subscribe-wrapper"},{default:w(()=>[r("div",{class:"ebm-subscribe",style:c(n.textStyle)},[r("div",{class:"header",style:c({backgroundColor:s.headerBackgroundColor,color:s.headerTextColor})},[r("h2",null,b(s.headerText),1)],4),r("div",{class:"subscribe-container",style:c({backgroundColor:s.bodyBackgroundColor})},[s.simpleMode?d("",!0):(i(),l("div",{key:0,class:"subscribe-info",style:c({color:s.bodyTextColor})},[t.userInfo?(i(),l("div",A,[t.availableNewsletters.length===0?(i(),l("div",{key:0,innerHTML:s.noAvailableNlText},null,8,D)):(i(),l("div",j," Hello "+b(t.userInfo.firstName)+", would you like to update your newsletter subscription(s)?",1))])):d("",!0),r("div",{class:"newsletters",style:c({padding:t.availableNewsletters.length===0?"0":"20px 0"})},[(i(!0),l(S,null,I(t.availableNewsletters,a=>(i(),l("div",{key:a.omedaProductId,class:F(["newsletter",t.availableNewsletters.length===1?"single":""])},[r("div",{class:"newsletter-content",style:c({alignItems:n.canRenderDescription(a)?"flex-start":"center"})},[r("div",H,[u(v,{icon:t.subscribed.includes(a.omedaProductId)?"mdi:checkbox-outline":"mdi:checkbox-blank-outline",width:26,"icon-color":s.bodyTextColor,onClick:ne=>n.handleNewsletterClick(a.omedaProductId,a.title)},null,8,["icon","icon-color","onClick"])]),n.canRenderDescription(a)?(i(),l("div",W,[r("div",Q,b(a.title),1),r("div",{class:"description",innerHTML:a.description},null,8,R)])):(i(),l("div",Y,[r("div",K,b(a.title),1)]))],4)],2))),128))],4)],4)),!t.userInfo&&!s.simpleMode?(i(),l("form",{key:1,class:"web-subscribe-form",onSubmit:o[0]||(o[0]=T((...a)=>n.submit&&n.submit(...a),["prevent"]))},[r("div",G,[u(g,{class:"fields","field-info":t.fieldInfo,"field-values":t.fieldValues,onUpdate:n.update},null,8,["field-info","field-values","onUpdate"]),r("div",Z,[u(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:n.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])]),t.complianceNeeded?(i(),l("div",J,[t.complianceNeeded?(i(),_(g,{key:0,"field-info":t.fieldInfoCompliance,"field-values":t.fieldValuesCompliance,onUpdate:n.update},null,8,["field-info","field-values","onUpdate"])):d("",!0)])):d("",!0),r("div",X,[u(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:n.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])],32)):d("",!0),s.simpleMode?(i(),l("form",$,[r("input",{type:"hidden",name:"omedasite",value:n.omedaSite},null,8,ee),E(r("input",{"onUpdate:modelValue":o[1]||(o[1]=a=>t.fieldValues.email=a),type:"email",name:"em",placeholder:"Email Address"},null,512),[[V,t.fieldValues.email]]),n.omedaQuery?(i(),l("input",{key:0,type:"hidden",name:"pk",value:n.omedaQuery},null,8,se)):d("",!0),u(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"fullWidth"},null,8,["color","alt-color","label"])])):d("",!0)],4),!s.simpleMode&&t.availableNewsletters.length!==0?(i(),l("div",{key:0,class:"consent",style:c({backgroundColor:s.bodyBackgroundColor,color:s.bodyTextColor})},[t.userInfo?(i(),l("span",oe,"Your account is subject")):(i(),l("span",te,"By submitting your information, you are agreeing")),y(" to Endeavor Business Media's "),ie,y(" and "),re,y(".")],4)):d("",!0)],4)]),_:1},8,["error","message","processing","style"])]),_:1})}const me=x(L,[["render",le]]);export{me as default};