import{$ as D,A as g,y as C,z as S,_ as A,U as c,o as m,c as u,a as o,p as v,d as L}from"./app-CNwDlsKB.js";import"./_commonjsHelpers-Cpj98o6Y.js";class F{encryptParamters(e){return D.ajax({url:agenda.request.url,method:"POST",data:{header:{type:"aktionsRequest",action:"dynamics"},form:{anrede:{value:e.anrede},vorname:{value:e.vorname},nachname:{value:e.nachname},firma:{value:e.firma},marktsegment:{value:e.segment},email:{value:e.email}}}})}initDynamicsScript(e){(function(t,a,n,i,r,d){var h=function(f){var y=0,p=function(){y==0&&(y++,w&&w.w(t,n,f))},l=document.createElement("script");l.src=i,l.type="text/javascript",l.onload=p,l.onreadystatechange=function(){(this.readyState=="complete"||this.readyState=="loaded")&&p()};var b=document.getElementsByTagName("head")[0];b.appendChild(l)};typeof r=="function"?d===null?h(function(){r(t,a,n)}):d.w(t,n,function(f){r(t,a,n,f)},null):h()})(e,"https://ea9272bc87ab43459bd1b4ca96faa2b2.svc.dynamics.com/f","https://ea9272bc87ab43459bd1b4ca96faa2b2.svc.dynamics.com/t","https://ea9272bc87ab43459bd1b4ca96faa2b2.svc.dynamics.com/t/w",typeof ms_tr_il_08>"u"?null:ms_tr_il_08,typeof ms_tr_il_w_01>"u"?null:ms_tr_il_w_01)}}const k=new F;class T{constructor(){this.agaCategory="",this.agaAction="",this.agaLabel="",this.agaValue="",this.blockId="",this.clickfunnelData="",this.formType="",this.formData={},this.requestError=!1}init(e,t,a,n,i,r,d){this.blockId=e,this.formType=t,this.clickfunnelData=a,this.agaCategory=n,this.agaAction=i,this.agaLabel=r,this.agaValue=d}onAfterFormLoad(){this.moveLabels(),this.fillHiddenFields()}onFormSubmit(){g.send(this.agaCategory,this.agaAction,this.agaLabel,this.agaValue)}onAfterFormSubmit(){this.formType==="onlinetest"&&this.redirectToOnlinetest()}moveLabels(){var e=this.getInitDataNotHiddenFields(),t=document.querySelectorAll('div[data-form-block-id="'+this.blockId+'"] div[data-editorblocktype]');for(let a=0;a<t.length;a++)if(this.checkField(t[a].attributes[0].nodeValue)){let n=t[a].children[0].children[0].getElementsByTagName("span")[0],i=t[a].children[0].children[0].getElementsByTagName("label")[0],r=t[a].children[0].children[0].getElementsByTagName("input")[0];typeof r>"u"&&(r=t[a].children[0].children[0].getElementsByTagName("select")[0],typeof r>"u"&&(r=t[a].children[0].children[0].getElementsByTagName("textarea")[0])),(r.value===""||r.value===" ")&&(n!==void 0&&(n.style.top="33px"),i.style.top="33px"),this.addDynamicsInput(i,r,n,e)}else if(t[a].attributes[0].nodeValue==="Field-radioButtons"){let n=t[a].children[0].children[0],r=t[a].children[0].children[0].querySelectorAll("label")[0].innerHTML;r==="Online-Test für"&&(r="Marktsegment"),this.formData[r]=n}}fillHiddenFields(){if(typeof this.formData.Kampagnencode<"u"){let e=this.formData.Kampagnencode.value,t=C.getAktionsParameter(e);this.formData.Kampagnencode.value=t.aktnr,typeof this.formData.Referrer<"u"&&(this.formData.Referrer.value=t.ref),typeof this.formData.Suchbegriff<"u"&&typeof t.sb<"u"&&(this.formData.Suchbegriff.value=t.sb),typeof this.formData.LetzteUrl<"u"&&(this.formData.LetzteUrl.value=document.location.href)}}getInitDataNotHiddenFields(){let e={};return this.formType==="clickfunnel"?e.Nachricht=this.clickfunnelData:this.formType==="newsletter"&&agenda.wUserCur.isLoggedIn&&(this.checkUtmParams(),e.Anrede=agenda.wUserCur.salutation==="Herr"?"2":"1",e.Vorname=agenda.wUserCur.firstName,e.Nachname=agenda.wUserCur.lastName,e["E-Mail"]=agenda.wUserCur.email),e}addDynamicsInput(e,t,a,n){this.formData[e.innerHTML]=t,typeof n[e.innerHTML]<"u"&&(this.formData[e.innerHTML].value=n[e.innerHTML],this.focusIn(e,t,a)),t.addEventListener("focusin",()=>{this.focusIn(e,t,a)},!1),t.addEventListener("focusout",()=>{this.focusOut(e,t,a)},!1)}focusIn(e,t,a){a!==void 0&&(a.style.top="14px"),e.style.top="14px"}focusOut(e,t,a){(t.value===""||t.value===" ")&&(a!==void 0&&(a.style.top="33px"),e.style.top="33px",(t.required&&t.value===""||t.value===" ")&&(t.style.border="solid #af052a 1px"))}checkField(e){return e==="Field-text"||e==="Field-url"||e==="Field-dropdown"||e==="Field-email"||e==="Field-phone"||e==="Field-textarea"}checkUtmParams(){let e=S("utm_content");typeof e=="string"&&(e=e.split("#")[0],e==="optin"&&(window.history.replaceState({},document.title,"/newsletter/newsletter-anmeldung-registrierung.php"),g.send("formular","abgeschickt","registrierung","")))}redirectToOnlinetest(){let e=this.formData.Marktsegment.querySelectorAll("input:checked")[0],t={anrede:this.formData.Anrede.value==="2"?"Herr":"Frau",vorname:this.formData.Vorname.value,nachname:this.formData.Nachname.value,firma:this.formData.Firma.value,segment:e.nextSibling.innerHTML.toLowerCase(),email:this.formData["E-Mail"].value};k.encryptParamters(t).then(a=>{a.err.code===-1?window.location=a.form.url:this.requestError=!0},()=>{this.requestError=!0})}}class E{displayContent(e){let t=window.innerWidth;switch(e){case"xl_min":return!(t>=1921);case"xl_max":return!(t<1921);case"l_min":return!(t>=1281);case"l_max":return!(t<1281);case"m_min":return!(t>=1025);case"m_max":return!(t<1025);case"s_min":return!(t>=769);case"s_max":return!(t<769);case"xs_min":return!(t>=415);case"xs_max":return!(t<415);default:return!0}}}const M=new E,_={props:{dynamicsId:{type:String,required:!0},blockId:{type:String,required:!0},agaCategory:{type:String,default:""},agaAction:{type:String,default:""},agaLabel:{type:String,default:""},agaValue:{type:String,default:""},formType:{type:String,default:"default"},clickfunnelData:{type:String,default:""},conditionalResolution:{type:String,default:""}},emits:["formLoaded"],data:()=>({alreadyLoaded:!1,cookieAllowed:!1,events:new T}),mounted(){this.updateServiceAllowed(),c.addConsentListener(this.updateServiceAllowed)},computed:{requestError(){return this.events.requestError},showContent(){return M.displayContent(this.conditionalResolution)}},methods:{async updateServiceAllowed(){const s=await c.isServiceEnabled("Microsoft Dynamics CRM");s!==this.cookieAllowed&&(this.cookieAllowed=s,this.cookieAllowed&&!this.alreadyLoaded&&(this.alreadyLoaded=!0,this.initComponent()))},async acceptCookiesForDynamics(){await c.acceptServiceByName("Microsoft Dynamics CRM")||await c.openConsent()},initComponent(){const s="https://mktdplp102cdn.azureedge.net/public/latest/js/form-loader.js?v=1.71.2017.0",e=()=>{k.initDynamicsScript(this.dynamicsId),typeof MsCrmMkt<"u"&&this.initEvents()},t=document.createElement("script"),a=document.getElementsByTagName("head")[0],n=document.getElementsByTagName("script");for(let i=0;i<n.length;i++)if(n[i].src===s){if(window.dynamicsLoaded){e();return}window.dynamicActions=window.dynamicActions||[],window.dynamicActions.push(e);return}a.appendChild(t),t.type="text/javascript",t.onload=()=>{if(window.dynamicsLoaded=!0,e(),window.dynamicActions!==void 0)for(let i=0;i<window.dynamicActions.length;i++)window.dynamicActions[i]()},t.src=s},initEvents(){this.events.init(this.blockId,this.formType,this.clickfunnelData,this.agaCategory,this.agaAction,this.agaLabel,this.agaValue),MsCrmMkt.MsCrmFormLoader.on("afterFormLoad",s=>{s.formPageId===this.blockId&&(this.events.onAfterFormLoad(),this.$emit("formLoaded"))}),MsCrmMkt.MsCrmFormLoader.on("formSubmit",s=>{s.formPageId===this.blockId&&this.events.onFormSubmit()}),MsCrmMkt.MsCrmFormLoader.on("afterFormSubmit",s=>{s.formPageId===this.blockId&&this.events.onAfterFormSubmit()})}}},x={key:0,class:"agenda-dynamics"},I={key:0,class:"dynamics_cookie"},N={key:1},B=["data-form-block-id"],H=["id"],U={key:2,class:"dynamics_error"};function q(s,e,t,a,n,i){return i.showContent?(m(),u("div",x,[s.cookieAllowed?i.requestError?(m(),u("div",U,e[4]||(e[4]=[o("p",null,"Leider ist bei der Weiterleitung ein Fehler aufgetreten.",-1),o("p",null,"Bitte versuchen Sie es später noch einmal, oder nehmen Sie mit uns Kontakt auf.",-1)]))):(m(),u("div",N,[o("div",{"data-form-block-id":t.blockId},null,8,B),o("div",{id:"d"+t.dynamicsId},null,8,H)])):(m(),u("div",I,[e[1]||(e[1]=o("p",{class:"h2"},"Dieser Services nutzt „funktionale Cookies“",-1)),e[2]||(e[2]=o("p",null," Um Ihnen diesen Service anbieten zu können, setzen wir auf die professionelle Technologie von Microsoft. Dafür werden Cookies gesetzt. Bitte akzeptieren Sie funktionale Cookies, um hier fortzufahren. (Alle anderen Cookie-Einstellungen bleiben davon unberührt.) ",-1)),o("div",{onClick:e[0]||(e[0]=(...r)=>i.acceptCookiesForDynamics&&i.acceptCookiesForDynamics(...r)),class:"dynamics_cookie_button"},"Cookies akzeptieren und fortfahren"),e[3]||(e[3]=o("p",null,[v("Oder senden Sie uns eine "),o("a",{href:"mailto:interessent@agenda-software.de",title:"E-Mail senden"},"E-Mail"),v(" und wir melden uns bei Ihnen.")],-1))]))])):L("",!0)}const R=A(_,[["render",q]]);export{R as default};