window.digitals2=window.digitals2||{};window.digitals2.main=window.digitals2.main||{};window.digitals2.main.cqIsInEditMode=!1;window.CQ&&window.CQ.WCM&&window.CQ.WCM.isEditMode()&&!window.CQ.WCM.isPreviewMode()&&(window.digitals2.main.cqIsInEditMode=!0);
define("ds2-main","jquery ds2-animation lodash componentInitializer ds2-resize-events ds2-cookie-controller".split(" "),function(d,z,C,y,A){function w(){this.$window=d(window);this.animation=new z;this.initTrigger()}var c=w.prototype;c.initTrigger=function(){this.init();this.$window.trigger("initializeComponents");this.delayLinkAction();this.checkCQMode();this.cqIsInEditMode||this.positionFooter();this.navigationElementControl();this.layerInit()};c.init=function(){this.scrollToAnkers=!0;d.fn.hasAttr=
function(a){return void 0!==this.attr(a)};this.checkCQMode();this.policyConformationIsRequired;this.externalCommunicationInit();this.$window.on("message onmessage",function(a){var b=a.originalEvent;a=b.origin;b=b.data;var e=null;try{e=JSON.parse(b)}catch(f){}null!=e&&0<=a.indexOf(".bmw.")&&"changeIdModule"===e.type&&e.imgSrc&&d(".ds2-navigation-main--id-module").find("img").attr("src",e.imgSrc)});if(this.checkLoaded())this.jumpToAnchor();else this.$window.on("load",this.jumpToAnchor());this.checkFrame();
this.initializeGcdmOnVCOForm();setTimeout(function(){var a;window.consentcontroller&&window.consentcontroller.api&&(a=window.consentcontroller.api.getPersistence("gcdm-accessToken"));window.ds2configurator&&a&&window.ds2configurator.$.publish("h5vco.account.loggedIn",[!0])},100)};c.checkLoaded=function(){return"complete"===document.readyState};c.jumpToAnchor=function(){var a=window.location.hash.replace(/#\//g,"");if(""!==a){try{var b=d(a)}catch(f){return!1}if(b.length){var e=document.documentElement.style.overflow;
document.body.style.overflow="hidden";y.initElement(d(".ds2-uxn-navigation-content-bar"));d("html, body").animate({scrollTop:b[0].offsetTop+"px"},{duration:3E3,step:function(f,k){f=b.offset().top;k.end!==f&&(k.end=f)},always:function(){d(".ds2-anchor-wall").hide();document.body.style.overflow=e}})}else d(".ds2-anchor-wall").hide()}else d(".ds2-anchor-wall").hide()};c.checkCQMode=function(){window.CQ&&window.CQ.WCM&&window.CQ.WCM.isEditMode()&&!window.CQ.WCM.isPreviewMode()&&(this.cqIsInEditMode=!0)};
c.delayLinkAction=function(){d("a").each(function(){var a=this.hash;if(a&&0<a.length&&!(0<a.indexOf("/"))){var b=this.pathname,e=d(this);e.on("click",function(f){f.preventDefault();b&&window.location.pathname===b&&0<document.querySelectorAll("img[data-src].ds2-slider--img:not([data-was-processed])").length&&(window.location.hash=a);setTimeout(function(){"_blank"===e.attr("target")?window.open(e.attr("href"),"_blank"):window.location.href=e.attr("href")},100)})}})};c.layerInit=function(){var a=this,
b;d(".ds2-login-js--layer-opener").on("click",function(){var e=d(this);b=e.data("layerId");a.loginOpendFromExternal=e.data("layerNoRedirect");a.openLayer(b)})};c.externalCommunicationInit=function(){var a=this,b=d(document);window.ds2configurator&&(ds2configurator.$.subscribe("h5vco.account.openLogin",function(){a.loginOpenFromExternal()}),ds2configurator.$.subscribe("h5vco.account.openLoginThroughSaveButton",function(){a.loginOpenThroughSaveButtonFromExternal()}));b.on("ds2-reactionAfterLogin",function(){a.reactionAfterLogin()});
b.on("ds2-policyConformationRequired",function(){a.policyConformationRequired()});b.on("ds2-reactionAfterRegistration",function(){a.reactionAfterRegistration()});b.on("ds2-reactionAfterReregistration",function(){a.reactionAfterReRegistration()});b.on("ds2-reRegistrationRequired",function(){a.reRegistrationRequired()});b.on("ds2-dlo-error",function(){a.openLayer("ds2-messages-js--dlo-error")});d("#ds2-messages-js--dlo-error").find(".close").on("click",function(){a.closeLayer("ds2-messages-js--dlo-error")});
b.on("ds2-gcdmDownError-invokedFromPage",function(){d("[data-lightbox-id\x3dgcdmError]").find(".ds2-dialog-button--show-for-layer").addClass("hide");d("[data-lightbox-id\x3dgcdmError]").find(".ds2-dialog-button--show-for-page").removeClass("hide");a.openLightbox("gcdmError")});b.on("ds2-gcdmDownError-invokedFromLayer",function(){d("[data-lightbox-id\x3dgcdmError]").find(".ds2-dialog-button--show-for-layer").removeClass("hide");d("[data-lightbox-id\x3dgcdmError]").find(".ds2-dialog-button--show-for-page").addClass("hide");
a.openLightbox("gcdmError")})};c.redirectAfterLogin=function(){c.loginOpendFromExternal&&(c.loginOpendFromExternalThroughSaveButton?ds2configurator.$.publish("h5vco.account.closeRegisterThroughSaveButton"):0==d("form[d2-campaign-required-login]").length&&(targetUrl=d("#loginform").data("redirectGarage"),c.redirectToTargetPage(targetUrl)))};c.reactionAfterLogin=function(){c.closeLayer("gcdmLogin");c.closeLayer("gcdmPolicy");c.loginSuccessful=!0;c.registrationSuccessful||c.redirectAfterLogin()};c.reRegistrationRequired=
function(){c.closeLayer("gcdmPolicy");c.closeLayer("gcdmLogin");c.openLayer("gcdmReregistration")};c.reactionAfterReRegistration=function(){c.closeLayer("gcdmReregistration");c.reactionAfterLogin()};c.reactionAfterRegistration=function(){c.registrationSuccessful=!0;var a=d(".ds2-registration--button-save","[data-lightbox-id\x3dgcdmRegistration]"),b=d(".ds2-registration--button-end","[data-lightbox-id\x3dgcdmRegistration]");c.loginOpendFromExternal?(a.on("click",c.redirectAfterLogin),b.on("click",
c.redirectAfterLogin),c.loginOpendFromExternalThroughSaveButton&&(a.removeClass("hide"),b.addClass("hide"))):(a.addClass("hide"),b.removeClass("hide"))};c.policyConformationRequired=function(){this.policyConformationIsRequired=!0;document.querySelector("[data-lightbox-id\x3dgcdmPolicy] [gcdm-policy-confirmation]").classList.remove("ng-hide");this.closeLayer("gcdmLogin");this.openLayer("gcdmPolicy")};c.loginOpenFromExternal=function(){c.loginOpendFromExternal=!0;c.addGcdmMarkup().then(function(){c.openLayer("gcdmLogin")})};
c.loginOpenThroughSaveButtonFromExternal=function(){c.loginOpendFromExternal=!0;c.loginOpendFromExternalThroughSaveButton=!0;c.addGcdmMarkup().then(function(){c.openLayer("gcdmLogin")})};c.redirectToTargetPage=function(a){a&&(window.location=a)};c.closeLayer=function(a){(a=document.querySelector("[data-lightbox-id\x3d"+a+"]"))&&a.Lightbox&&a.Lightbox.closeLightbox()};var x;c.addGcdmMarkup=function(){if(x)return x;var a=d.Deferred(),b=d("#ng-app"),e=b.find("[data-lightbox-id\x3dgcdmLogin] .ds2-lightbox__container").children().length,
f={},k=b.find("[data-modalpath]"),p=function(g,h){var n=d.Deferred();return{d:n,resolve:function(){g.find(".ds2-lightbox__container").load(h+".html?wcmmode\x3ddisabled",function(t,r){"error"!==r?(g.attr("data-component-initialized")&&g.attr("data-component-initialized",!1),n.resolve(t)):(n.reject(r),console.log(r))})}}},l=function(){k.each(function(){var g=d(this),h=g.data("modalpath"),n=g.attr("id")||g.data("lightbox-id");f[n]=new p(g,h)})},m=function(){Object.keys(f).map(function(g){f[g].resolve()})},
q,u=function(){setTimeout(function(){y.initAll(b)},1E3);q=document.createEvent("Event");q.initEvent("ds2-lightbox-ready",!1,!1);for(var g=document.querySelectorAll(".ds2-lightbox"),h=0;h<g.length;h++)g[h].dispatchEvent(q);a.resolve()};!e&&b?(this.loadingAnimation().onMarkupRequestStart(),l(),d.when(f.gcdmLogin.d,f.gcdmForgottenPassword.d,f.gcdmRegistration.d,f.gcdmReregistration.d,f.gcdmPolicy.d).then(u).fail(u),m()):a.resolve();return x=a.promise()};c.loadingAnimation=function(){var a=d("#ds2-gcdm-placeholder__container");
return{onMarkupRequestStart:function(){a.addClass("ds2-image-loader--preloader-wrapper")},onMarkupRequestEnd:function(){setTimeout(function(){a.removeClass("ds2-image-loader--preloader-wrapper")},10)}}};c.waitForGcdmInit=function(){var a=d.Deferred(),b=0,e=function(){nn.global.ngAppInitalized||5<b++?a.resolve():setTimeout(e,500)};e();return a.promise()};var v;c.loadGcdmJs=function(){if(v)return v;var a=d("#ds2-lightbox-container"),b=a.data("angularapi-url"),e=a.data("gcdmformapi-url"),f=a.data("formsapi-url");
a=[];b&&e?(a.push({url:b,isLoaded:function(){return d.isPlainObject(window.angular)}}),a.push({url:e,isLoaded:function(){return d.isPlainObject(window.gcdm)}}),a.push({url:f,isLoaded:function(){return!!document.querySelectorAll('head \x3e script[src\x3d"'+f+'"]').length}}),v=this.lazyLoadScriptMulti(a).then(this.waitForGcdmInit.bind(this))):v=d.when();return v};c.openLayer=function(a){var b=this;b.loadGcdmJs().then(function(){b.openLightbox(a);console.log(window.angular);console.log(window.gcdm);
b.loadingAnimation().onMarkupRequestEnd()}).fail(function(e){console.log(e)})};c.openLightbox=function(a){var b=document.querySelector("[data-lightbox-id\x3d"+a+"]");b&&b.Lightbox?b.Lightbox.openLightbox():b.addEventListener("ds2-lightbox-initialized",function(){b.Lightbox&&b.Lightbox.openLightbox()})};c.initializeGcdmOnVCOForm=function(){var a=this;d("#vco").length&&a.addGcdmMarkup().then(a.loadGcdmJs.bind(a)).then(function(){a.loadingAnimation().onMarkupRequestEnd()})};c.lazyLoadScriptMulti=function(a){function b(){u++;
u===p&&0!==p&&f.resolve()}function e(){for(var h;l[0]&&"loaded"===l[0].readyState;)h=l.shift(),h.onreadystatechange=null,m.parentNode.insertBefore(h,m),b()}var f=d.Deferred(),k=0,p=0,l=[],m=document.scripts[document.scripts.length-1],q="async"in m,u=0;scriptsToLoad=function(h){for(var n=[],t,r=0,B=h.length;r<B;r++)t=h[r],d.isFunction(t.isLoaded)&&t.isLoaded()||n.push(t);return n}(a);if(p=scriptsToLoad.length){for(;k<p;k++){a=scriptsToLoad[k];var g=document.createElement("script");q?(g.async=!1,g.onload=
b,g.src=a.url,document.head.appendChild(g)):m.readyState?(l.push(g),g.onreadystatechange=e,g.src=a.url):(g.defer="defer",g.onload=b,g.src=a.url,document.body.appendChild(g))}window.setTimeout(function(){f.reject()},1E4)}else f.resolve();return f.promise()};c.isIOS=function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream};c.componentsUpdate=function(){window.digitals2.main.$window.trigger("initializeComponents")};c.checkFrame=function(){window.self!==window.top&&window.self&&
window.self.document&&window.self.document.body&&d(window.self.document.body).addClass("ds2-iframe--body")};c.navigationElementControl=function(){var a=d(".ds2-stage-presentation.ds2-contentnavigation"),b=d(".ds2-subbrand-icon--wrapper"),e=d(".ds2-subbrand-icon--spacing__below-text");b=b.length&&b.parents(".ds2-subbrand-icon--spacing__below-text").length;a&&b&&e.css("margin-top","35px")};c.positionFooter=function(){var a=d(window),b=function(){var e=d("footer"),f=d("main"),k=d(".ds2-navigation-main").height();
e=e.height()+parseInt(e.css("padding-top"));var p=f.height(),l=a.height(),m=d("main").find("iframe"),q=d(m).attr("id");k+p<l&&(0==m.length||q&&0!=q.indexOf("externalContentIFrame"))&&f.css("min-height",l-k-e)};b();a.on("resize",b)};window.digitals2.main=void 0;window.digitals2.main=new w;window.digitals2.main.supportsPassiveEventListeners=function(){var a=!1;try{var b=Object.defineProperty({},"passive",{get:function(){return a=!0}});window.addEventListener("testPassive",null,b);window.removeEventListener("testPassive",
null,b)}catch(e){a=!1}return a};window.digitals2.resizeEvents=new A;return w});requirejs(["ds2-main"],function(d){});