var Application,__extends,Commerce,Constants,Entities,Helpers,Services,AccountInfoModel,WebContent;(function(n){$(document).ready(function(){return t.Initialize()});$(document).ajaxSend(function(n,i){return t.SetupAuthorization(i)});$(document).ajaxComplete(function(n,i,r){return t.AjaxComplete(n,i,r)});var t=function(){function t(){}return t.Initialize=function(){this.ProcessApplyingPromo();this.SetupKnockoutSetting();this.InitalizeTypeScriptContexts();this.InitalizeKnockOutViewModels()},t.SetupAuthorization=function(n){if($.cookie(Constants.Global.UserTokenCookieKey)){var t=new Entities.Token;$.extend(t,JSON.parse($.cookie(Constants.Global.UserTokenCookieKey)));t&&n.setRequestHeader("Authorization",t.TokenType+" "+t.TokenValue)}},t.AjaxComplete=function(n,t){var r,u,i;t.readyState===4&&(t.status===401?($.removeCookie(Constants.Global.BasketCookieKey,{path:"/"}),r=$(".js-wkis-login-open"),location.href=location.origin+r.length&&r.first().attr("href")?r.first().attr("href"):"/store/checkout/sign-in/"):$.cookie(Constants.Global.UserTokenCookieKey)&&(u=new Entities.Token,$.extend(u,JSON.parse($.cookie(Constants.Global.UserTokenCookieKey))),i=new Date,i.setTime(i.getTime()+Constants.Global.UserTokenExpirationMinutes*6e4),u.ExpiresAt=i.toISOString(),$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(u),{path:"/",expires:i,secure:!0}),$.cookie(Constants.Global.BasketCookieKey)&&$.cookie(Constants.Global.BasketCookieKey,$.cookie(Constants.Global.BasketCookieKey),{path:"/",expires:i})))},t.SetupKnockoutSetting=function(){n.Knockout.InitializeContributedRules();n.Knockout.InitializeHandlers();ko.validation.init({decorateInputElement:!0,errorElementClass:"ko-error",errorMessageClass:"ko-validation-message"})},t.InitalizeTypeScriptContexts=function(){var n=this.GetAllContext("[ts-initialize]",document),t=this.GetMappedContexts(n,"ts-initialize");this.InitializeContexts(t)},t.InitalizeKnockOutViewModels=function(){var n=this.GetAllContext("[ko-viewmodel]",document),t=this.GetMappedContexts(n,"ko-viewmodel");this.InitializeKnockoutViewModels(t)},t.GetAllContext=function(n,t){return $(n,t).toArray()},t.GetMappedContexts=function(n,t){var r=this,i=[];return n.length&&n.forEach(function(n){i.push({element:n,"class":r.ActivateObject(n.getAttribute(t).split("."))})}),i},t.ActivateObject=function(n){for(var f=[],i,r,e,u,t=1;t<arguments.length;t++)f[t-1]=arguments[t];for(i=window,r=0;r<n.length;r++)e=n[r].trim(),i=i[e];return u=Object.create(i.prototype),u.constructor.apply(u,f),u},t.InitializeContexts=function(n){n.forEach(function(n){n.element&&n.class&&n.class.Initialize&&n.element instanceof HTMLElement&&n.class.Initialize(n.element)})},t.InitializeKnockoutViewModels=function(n){n.forEach(function(n){n.element&&n.class&&n.element instanceof HTMLElement&&ko.applyBindings(Object.create(n.class),n.element)})},t.ProcessApplyingPromo=function(){var n=Helpers.UrlHelper.GetUrlParam(window.location.href,"applyPromo");n&&localStorage.setItem(Constants.Commerce.ApplyingPromoCodeKey,n)},t}();n.App=t})(Application||(Application={})),function(n){var t=function(){function n(){}return n.InitializeContributedRules=function(){ko.validation.rules.spaceInPassword={validator:function(n,t){return t?!n||n.charAt(0)!=Constants.Global.Space&&n.charAt(n.length-1)!=Constants.Global.Space:!0},message:"No validation was done for leading or trailing spaces in password."};ko.validation.registerExtenders()},n.InitializeHandlers=function(){ko.bindingHandlers.masked={init:function(n,t,i){var r=i().mask||{},u=i().placeholder;u?$(n).mask(r,{placeholder:u}):$(n).mask(r);ko.utils.registerEventHandler(n,"blur",function(){var i=t();i($(n).val())})},update:function(n,t){var i=ko.utils.unwrapObservable(t());$(n).val(i)}}},n}();n.Knockout=t}(Application||(Application={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){var t=this.InitAccountInformation(n);this.InitChangePasswordForm();this.InitChangeEmailForm(t)},t.prototype.InitAccountInformation=function(t){var i=new n.ViewModel.AccountInformationViewModel(t);return ko.applyBindings(i,t),i},t.prototype.InitChangeEmailForm=function(t){var i=$('[role="dialog"][data-modal="edit-email"]');$('button[data-modal="edit-email"]').click(function(){$("input",i).val("");$(".ko-validation-message",i).not("[instant]").remove();ko.cleanNode(i[0]);var r=new n.ViewModel.ChangeEmailViewModel(i[0],t);ko.applyBindings(r,i[0])})},t.prototype.InitChangePasswordForm=function(){var t=$('[role="dialog"][data-modal="edit-password"]').first(),i=$('button[data-modal="edit-password"]').click(function(){$("input",t).val("");$(".ko-validation-message",t).not("[instant]").remove();ko.cleanNode(t[0]);var i=new n.ViewModel.ChangePasswordViewModel(t[0]);ko.applyBindings(i,t[0])})},t}();t.AccountInformationPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.Initialize=function(){Helpers.HtmlHelper.PreventJumpingOnTargetElemnet(null,this.ShowActiveTabAccordingSelectedTarget);this.ShowDefaultActiveTab();this.HadnleWindowHashChangeEvent();this.ShowActiveTabAccordingSelectedTarget();this.AutoHideHelpInfoOnSelectTab();Helpers.HtmlHelper.HideHelpInfo()},n.prototype.HadnleWindowHashChangeEvent=function(){var n=this;window.onhashchange=function(){n.ShowActiveTabAccordingSelectedTarget()}},n.prototype.ShowActiveTabAccordingSelectedTarget=function(){if(location.hash.length){$(".wkis-account-tabs a").removeClass("-active");var n=$(".wkis-account-tabs a[href='"+location.hash+"']");n.addClass("-active");n.parent().siblings("li").removeClass("active");n.parent().addClass("active");$("#accountLastBreadcrumb").text(n.text())}},n.prototype.ShowDefaultActiveTab=function(){location.hash.length||(location.href=location.href.replace("#","")+"#accountOverviewContainer",$(document).scrollTop(0))},n.prototype.AutoHideHelpInfoOnSelectTab=function(){$("ul.wkis-account-tabs-inner li").bind("click.autoHideHelpInfo",function(n){var t=$(n.currentTarget);t.hasClass("active")&&$("#accountOrderHistoryLink",t).length&&$("#accountOrderHistoryContainer").hasClass("loaded-history-model")?Helpers.HtmlHelper.ShowHelpInfo():Helpers.HtmlHelper.HideHelpInfo()})},n}();n.AccountOverviewPageInitializer=t})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){t.GetAndShowCartItems(n)},t.CallInitialize=function(t,i){try{var r=Services.UserServices.GetUserBasketViewModel(!1,!0);r.Basket_orderLines&&r.Basket_orderLines.length&&(n.ViewModel.BasketViewModel.Basket.setBasketLines(r.Basket_orderLines),n.ViewModel.BasketViewModel.Basket.loadRecommendedProducts([i],3))}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t.GetAndShowCartItems=function(i){Helpers.HtmlHelper.ShowGlobalLoaderElement();try{var r=Services.UserServices.GetUserBasketViewModel(!1),u=new n.ViewModel.BasketViewModel(r,i);i.className==="wkis-page-container"&&u.loadRecommendedProducts();ko.applyBindings(u,i);t.CheckCartForExpiredProducts(r)}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t.BindProductPageLinks=function(n){$(".wkis-cart-item-product-container-title",n).find("a").each(function(n,t){var i=$(t);i.attr("href",i.attr("href")+"//"+i.siblings("[name='productUrl']").text())})},t.CheckCartForExpiredProducts=function(n){var r,t,u,i,f;n.Warnings&&(r="expired-product",t=$('div[role="dialog"][data-modal='+r+"]"),t.length&&(u=$(".wkis-modal-body",t),i=[],n.Warnings.forEach(function(n){var t,f,r;if(n.Code=="ExpiredOrderLines"){if(t="",f="",n.Attributes)for(r in n.Attributes)switch(r){case"Sku":t=t+n.Attributes[r]+",";break;case"VariantSku":t=t+n.Attributes[r];break;case"ProductName":f=n.Attributes[r]}t&&f&&(u.append("<p>- "+f+"<\/p>"),i.push(t))}}),i.length&&(f=$("button[type='submit']",t),f.unbind("click.removeExpiredProducts").bind("click.removeExpiredProducts",function(){i.forEach(function(t){Services.OrderServices.RemoveOrderLine(n.Id,t)})}),Helpers.HtmlHelper.OpenModalDialog(r))))},t}();t.CartPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.Initialize=function(){var n=$.cookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey);n&&Services.AddressServices.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency()},n}();n.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyInitializer=t})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.LoadOrderModel(n)},t.prototype.LoadOrderModel=function(t){var r,i,u,f,e;Helpers.HtmlHelper.ShowGlobalLoaderElement();r=Helpers.UrlHelper.GetUrlParam(window.location.href,"orderNumber");i=new Entities.OrderModels.OrderModel;r&&(u=$(".order-data",t),$.ajax("/Ecommerce.svc/Orders('"+r+"')?$expand=Order_orderLines/Product/ShippingLocation",{method:"GET",async:!1}).done(function(t){$.extend(i,t);var r=new n.ViewModel.OrderViewModel(i,u[0]);ko.applyBindings(r,u[0])}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}),f=function(i){var u=$(".wkis-page-header-container",t),f=new n.ViewModel.ResendEmailViewModel(r,i,u);ko.applyBindings(f,u[0])},e=void 0,i&&i.ShippingAddress&&i.ShippingAddress.Email?(e=i.ShippingAddress.Email,f(e)):Services.UserServices.GetUserInfo().done(function(n){var t=n.value?n.value[0]:null;t&&t.Email&&f(t.Email)}))},t}();t.ConfirmationPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.BindActiveTabElements();this.BindLazyLoadAddressBook(n)},t.prototype.BindActiveTabElements=function(){$('ul[role="navigation"] li').on("click",function(n){var t=$(n.currentTarget);t.siblings("li").removeClass("active");t.addClass("active")})},t.prototype.BindLazyLoadAddressBook=function(t){var i=[],r=function(){if(i=Services.UserServices.GetUserAddressBook(!1),!!ko.dataFor(t)){var r=[];i.forEach(function(i){var u=new n.ViewModel.AddressViewModel(t,i);r.push(u)});n.ViewModel.AddressBookModel.AddressBook.Addresses(r)}else ko.applyBindings(new n.ViewModel.AddressBookModel(i,t),t)};$("#addressBookLink").parent().hasClass("active")&&r();$('[href="#addressBookContainer"]').on("click",function(){r()})},t}();t.CustomerAddressBookInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.ForgotPasswordViewModel(t),t)},t}();t.ForgotPasswordInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=0,r,u;n.ViewModel.BasketViewModel.Basket?i=n.ViewModel.BasketViewModel.Basket.TotalItemCount():(r=new n.ViewModel.BasketViewModel(Services.UserServices.GetUserBasketViewModel(),t),i=r.TotalItemCount());u=new n.ViewModel.CartItemCounterViewModel(i);ko.applyBindings(u,t)},t}();t.HeaderPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.LoginUserViewModel(t),t)},t}();t.LoginUserInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.OrderHistoryViewModel(t),t)},t}();t.OrderHistoryPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(n){this.PreIntialize(n)},t.prototype.PreIntialize=function(t){var i,r,u,f;try{if(i=$.cookie(Constants.Global.BasketCookieKey),r=localStorage.getItem(Constants.Commerce.ApplyingPromoCodeKey),i&&r&&$.ajax("/api/commerce/basket/"+i+"/applyPromo/",{type:"POST",data:JSON.stringify(r),contentType:"application/json",async:!1,success:function(){localStorage.removeItem(Constants.Commerce.ApplyingPromoCodeKey)}}),u=Services.UserServices.GetUserBasketViewModel(!1,!0),$.cookie(Constants.Global.UserTokenCookieKey))var e=Services.UserServices.GetUserAddressBook(!1),o=$(".wkis-address-returning-user-inner",t)[0],s=new n.ViewModel.AddressBookModel(e,o);f=new n.ViewModel.OrderViewModel(u,t,s);ko.applyBindings(f,t);n.ViewModel.OrderViewModel.Order.ShippingAddress().Country.clearError();n.ViewModel.OrderViewModel.Order.BillingAddress().Country.clearError()}finally{Helpers.HtmlHelper.HideGlobalLoaderElement()}},t}();t.PaymentSubmitInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){this.agreementModalDialog=$('div[data-modal="terms-conditions"]')}return t.prototype.Initialize=function(){this.InitializeProgramPopup();this.InitializeRecommendations();this.InitializeSeriesVariants();this.InitializeAddToCartFlow();this.BindProductSelection();this.InitializeQuantity();this.BindDigitalProductAddToCart();this.BindCheckingQunatityOnAddToCart();this.RemoveIntegratedEvents();this.triggerTagForSelectedProduct(this.sendProductInformationTag)},t.prototype.InitializeProgramPopup=function(){var t=$(".radios label",'div[role="dialog"][data-modal^="standing-order-"]'),n;t.bind("click.selectProgram",function(n){var t=$(n.currentTarget).siblings('input[type="radio"]').first(),i=t.attr("name").replace(/standing-order-/g,""),r=$('input[name="participatingInProgram"]','form[sku="'+i+'"]');r.val(t.val()=="enroll"?"true":"false");t[0].checked=!0});n=$('.js-wkis-modal-open[data-modal^="standing-order-"]');n.bind("click.setDefaultProgram",function(n){var t=$(n.currentTarget),i=t.attr("sku");$('label[for="decline-'+i+'"]').first().click()})},t.prototype.RemoveIntegratedEvents=function(){var n,t;this.agreementModalDialog.length&&(n=$("button.js-wkis-terms-agree-button",this.agreementModalDialog),n.length&&(t=$("input.js-wkis-terms-agree-input",this.agreementModalDialog),t.bind("change",function(){n.removeAttr("disabled")}),n.removeAttr("disabled")))},t.prototype.GetOfferNumber=function(){var n=$(".wkis-product-format[data-active=true]").first();return n.length===0&&(n=$(".wkis-product-format").first()),n.attr("data-offer-number")},t.prototype.InitializeRecommendations=function(){var t=new n.ViewModel.RecommendedProductsViewModel,i;this.recommendedProductsViewModel=t;ko.applyBindings(t,$("#related-products")[0]);t.RecommendedProducts.subscribe(function(n){n&&n.length>0?$("a[href='#related-products']").parent().show():$("a[href='#related-products']").parent().hide()});i=this.GetOfferNumber();i&&t.loadRecommendedProducts([i])},t.prototype.InitializeSeriesVariants=function(){var i=new n.ViewModel.SeriesProductVariantsViewModel,t,r,u;this.seriesVariantsViewModel=i;ko.applyBindings(i,$("#series-variants")[0]);i.Variants.subscribe(function(n){n&&n.length>0?$("a[href='#series-variants']").parent().show():$("a[href='#series-variants']").parent().hide()});t=$(".wkis-product-format[data-active=true]").first();t.length===0&&(t=$(".wkis-product-format").first());r=t.attr("data-offer-number");u=t.attr("data-has-series")==="true";r&&i.loadSeriesVariants(r)},t.prototype.BindDigitalProductAddToCart=function(){var t=this,r=$("div.js-wkis-product-detail-header-selected-info-content[digital]"),u,n,f,i,e;r&&(u=$(".add-to-cart-button",r),n=$('div[role="dialog"][data-modal="terms-conditions"]'),$.cookie(Constants.Global.UserTokenCookieKey)&&(f=function(t){t&&t.Email&&$(".wkis-terms-modal-info-email",n).text(t.Email)},Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0];f(t)})),i=function(){var n=$('div[role="dialog"][data-modal="login"]'),i=$(".wkis-account-login",n),r=$(".wkis-account-register",n),u=$('div[role="dialog"][data-modal="forgot-password"]');i.length&&t.LoginPopupInitialize(i[0]);r.length&&t.RegisterPopupInitialize(r[0]);u.length&&t.ForgotPasswordPopupInitialize(u[0])},e=$(".wkis-terms-modal-info-logout a").click(function(){Services.UserServices.Logout();i()}),u.bind("click.openDialog",function(t){var u,f,e;t.preventDefault();var r=$(t.currentTarget),c=r.attr("digital")=="true",o=r.parent(),s=!!$.cookie(Constants.Global.UserTokenCookieKey),h=$(".wkis-product-detail-header-selected-info-price-value-original",o).text();$(".price-info",n).text(h);u=r.attr("sku");$(".js-wkis-terms-agree-button",n).attr("sku",u);f=r.attr("has-program").toLowerCase()=="true";e=f?"standing-order-"+u:"added-cart";$(".js-wkis-terms-agree-button",n).attr("data-modal",e);s?Helpers.HtmlHelper.OpenModalDialog("terms-conditions"):(i(),Helpers.HtmlHelper.OpenModalDialog("login"))}))},t.prototype.BindCheckingQunatityOnAddToCart=function(){$("a[id='addToCartBtn']").bind("click.checkQuantity",function(n){var f;n.preventDefault();var t=$(n.currentTarget),e=t.parent(),i=$("input[id='quantity']",e);if(i.length){var o=$("ko-error-text[for='quantity'][rule='minQuantity']").text(),r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"ERROR",o,{duration:2e4}),u=$("div.wkis-product-detail-header-info");try{if(f=parseInt(i.val()),f<1){u.prepend(r);return}t.siblings("[id='add-to-cart-link']")[0].click()}catch(s){u.prepend(r);return}}})},t.prototype.LoginPopupInitialize=function(t){var i=ko.dataFor(t);!i?ko.applyBindings(new n.ViewModel.LoginUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),$.cookie(Constants.Global.RememberMeCookieKey)?(i.email($.cookie(Constants.Global.RememberMeCookieKey)),i.verifyEmail(i)):i.email(undefined),i.password(undefined),i.errors.showAllMessages(!1))},t.prototype.RegisterPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.RegisterUserViewModel(t),t):($("div",t).add("input",t).removeClass("ko-valid"),i.email(undefined),i.verifiedEmail=!1,i.password(undefined),i.firstName(undefined),i.lastName(undefined),i.errors.showAllMessages(!1))},t.prototype.ForgotPasswordPopupInitialize=function(t){var i=ko.dataFor(t);!ko.dataFor(t)?ko.applyBindings(new n.ViewModel.ForgotPasswordViewModel(t),t):(i.email(undefined),i.errors.showAllMessages(!1))},t.prototype.InitializeQuantity=function(){var n=$("#quantity"),t=$("#itemCount");t.val(n.val());n.change(function(n){t.text(n.currentTarget.value)})},t.prototype.InitializeAddToCartFlow=function(){var t=this,i=$("input.js-wkis-terms-agree-input",this.agreementModalDialog),r=$("div.ko-validation-custom-message[for='agreement'][rule='accept']");i.bind("click",function(n){var t=$(n.currentTarget)[0];t.checked&&r.hide()});$('.js-wkis-modal-open[data-modal="added-cart"][sku]').add("button.js-wkis-terms-agree-button[sku]").click(function(u){var e=$(u.currentTarget),f=e.attr("digital")=="true",s,o;if(f){if(i.length&&!i[0].checked)return r.show(),!1;r.hide()}(e.attr("data-modal")==="added-cart"||f)&&(s=$(u.currentTarget).attr("sku"),o=$('[id="addToCart"][sku="'+s+'"]'),$.ajax({type:o.attr("method"),url:o.attr("action"),data:o.serialize(),beforeSend:function(){var n=$(".wkis-modal-body",$("#added-cart-popup"));Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(i){var o=!1,r,s,u;f&&n.ViewModel.BasketViewModel.Basket.BasketLines().forEach(function(n){n.Id()==i.Id&&(o=!0)});f&&o?(Helpers.HtmlHelper.HideGlobalLoaderElement(),r=e.siblings(".digital-warning").text(),r&&(Helpers.HtmlHelper.CloseModalDialog(),Helpers.HtmlHelper.SetGlobalAlertMessage(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Warning,"WARNING",r)),Helpers.HtmlHelper.ShowGlobalAlertMessage())):(s=t.GetOfferNumber(),n.Initializer.CartPageInitializer.CallInitialize($("#added-cart-popup")[0],s),f?(Helpers.HtmlHelper.CloseModalDialog(),u=e.siblings("a.js-wkis-modal-open.js-wkis-terms-agree-button[data-modal]"),u.length&&u[0].click()):t.triggerTagForSelectedProduct(t.sendAddedProductInformationTag))},error:function(n){Helpers.HtmlHelper.HideGlobalLoaderElement();n.status===409&&Helpers.HtmlHelper.OpenModalDialog("added-cart-conflict")}}))})},t.prototype.BindProductSelection=function(){var n=this,t=location.pathname.split("/"),i=t.indexOf("product"),u="",r="";i!=-1&&t.length>i+1&&(u=t[i+1],t.length>i+2&&(r=t[i+2],r&&($("div .wkis-product-format").attr("data-active","false"),$("div .wkis-product-format[sku="+r+"]").attr("data-active","true"),$(".wkis-product-detail-header-info .js-wkis-product-detail-header-selected-info-content").attr("data-active","false"),$(".wkis-product-detail-header-info .js-wkis-product-detail-header-selected-info-content[data-format="+r+"]").attr("data-active","true"),$("div .wkis-product-format[data-active='true']").length||$("div .wkis-product-format[data-active]").first().attr("data-active","true"))));$("div.wkis-product-format[data-format][sku]").click(function(t){var r=$(t.currentTarget),e=r.attr("product"),u=r.attr("sku"),i,f;n.ChangeFormatUrl(e,u);n.ChangeProductImage(u);i=r.attr("data-offer-number");i?n.recommendedProductsViewModel.loadRecommendedProducts([i]):n.recommendedProductsViewModel.RecommendedProducts([]);f=r.attr("data-has-series")==="true";i&&f?n.seriesVariantsViewModel.loadSeriesVariants(i):n.seriesVariantsViewModel.Variants([]);n.sendProductInformationTag($(t.currentTarget).first())})},t.prototype.triggerTagForSelectedProduct=function(n){var t=$("div.wkis-product-format[data-format][sku][data-active='true']").first();t.length&&n&&n(t)},t.prototype.sendProductInformationTag=function(n){var t=n.attr("product"),i=n.attr("isbn"),r=n.attr("format");window.dataLayer&&window.dataLayer.push({event:"viewProduct",eventCategory:"ProductDetails",product:{productName:t,isbn:i,format:r}})},t.prototype.sendAddedProductInformationTag=function(n){var i=n.attr("product"),r=n.attr("isbn"),u=n.attr("format"),t=$('form[sku="'+n.attr("sku")+'"]').first();if(t.length){var f=$('input[name="sKu"]',t).val(),e=$('input[name="variantSku"]',t).val(),o=$('input[name="quantity"]',t).val(),s=$(".wkis-product-detail-header-selected-info-price-value-original",".js-wkis-product-detail-header-selected-info-content[data-format="+n.attr("sku")+"]").text();window.dataLayer&&window.dataLayer.push({event:"itemWasAddedToCart",eventCategory:"ProductDetails",product:{productName:i,isbn:r,format:u,quantity:o,price:s,id:f+";"+e}})}},t.prototype.ChangeFormatUrl=function(n,t){if(typeof history.pushState!="undefined"){var i={Page:n,Url:t};history.pushState(i,i.Page,i.Url)}},t.prototype.ChangeProductImage=function(n){$("img[sku]").hide();$("img[sku="+n+"]").show()},t.prototype.InitializeImages=function(){var n=$("img[sku]",".wkis-product-detail-header-container");n.length==1&&n.first().show()},t}();t.ProductDetailsPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.RegisterUserViewModel(t),t)},t}();t.RegisterUserInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=new n.ViewModel.ResetPasswordViewModel(t),r;(ko.applyBindings(i,t),r=Helpers.UrlHelper.GetUrlParam(window.location.toString(),"reset"),r!==null)&&(i.resetToken(r),i.validateToken())},t}();t.ResetPasswordInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){var i=new n.ViewModel.StorePageViewModel;ko.applyBindings(i,t)},t}();t.StorePageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t;(function(n){var h=function(){function n(){this.Labels=[]}return n}(),i,r,u,f,e,o,t,s;n.FacetArg=h;i=function(){function n(){}return n}();n.SearchArgs=i;r=function(){function n(){}return n}();n.Row=r;u=function(){function n(){}return n}();n.FacetResultItem=u;f=function(){function n(){}return n}();n.FacetResult=f;e=function(){function n(){}return n}();n.SearchResult=e;o=function(){function n(){}return n}();n.SelectOptionModel=o;t=function(){function n(){}return n}();t.MarketSegment="marketSegments";t.PracticeArea="practiceAreas";t.Format="format";t.Industry="industry";t.Role="role";n.FacetNames=t;s=function(){function n(){this.Text=ko.observable();this.Value=ko.observable();this.HitCount=ko.observable();this.IsChecked=ko.observable();this.Children=ko.observableArray()}return n}();n.FacetModel=s})(t=n.StorePage||(n.StorePage={}))})(t=n.Models||(n.Models={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.load=function(){$.getJSON("/Ecommerce.svc/Users",function(n){if(n&&n.value){var i=n.value[0];t.Email(i.Email);t.FirstName(i.FirstName);t.LastName(i.LastName);t.PhoneNumber(i.PhoneNumber)}})};this.update=function(n,i){i.preventDefault();var r=$(i.currentTarget).parents(".wkis-account-content").children().first(),u={FirstName:t.FirstName(),LastName:t.LastName(),PhoneNumber:t.PhoneNumber(),CompanyName:null,Id:null,Password:null,Email:null};$.extend(u,{"odata.type":Constants.Global.ODataOperation("User")});$.ajax("/Ecommerce.svc/Users('0')",{data:JSON.stringify(u),type:"put",contentType:"application/json;odata=minimalmetadata",success:function(){var i=$(".wkis-account-welcome")[0],n;i&&(n=ko.dataFor(i),n&&(n.FirstName(t.FirstName()),n.LastName(t.LastName())));r.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Account Information was successfully updated",{duration:1e4}))},error:function(){r.after(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Account Information was not updated because of an error",{duration:1e4}))}})};this.$container=$(n);this.Email=ko.observable();this.FirstName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("FirstName","required",this.$container)}});this.LastName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("LastName","required",this.$container)}});this.PhoneNumber=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","required",this.$container)}});this.load()}return n}();n.AccountInformationViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function i(f,e){var o=this,s;this.BasketLines=ko.observableArray();this.RecommendedProducts=ko.observable(new n.ViewModel.RecommendedProductsViewModel);this.removeOrderLine=function(n,i,r){r===void 0&&(r=!1);Services.OrderServices.RemoveOrderLine(o.Id+";"+n.Id()).done(function(){if(o.updateSubTotalPrice(),o.BasketLines.remove(n),r&&o.BasketLines().length==0){var i=$("#redirectLinkForEmptyCart").val();location.href=i?i:location.origin}t.OrderViewModel.Order&&t.OrderViewModel.Order.getUpdatedOrderData();o.loadRecommendedProducts()}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement()})};this.updateOrderLine=function(n,i){if(n.Quantity()==0)o.removeOrderLine(n,i);else{var r={Id:n.Id(),Quantity:parseInt(n.Quantity()),PriceInfo:null,ParticipatesInProgram:n.ParticipatesInProgram(),ProgramSubscribtion:null};$.extend(r,{"odata.type":Constants.Global.ODataOperation("OrderLine")});Services.OrderServices.UpdateOrderLine(o.Id+";"+n.Id(),JSON.stringify(r)).done(function(i){o.updateSubTotalPrice();var r;(i||Services.OrderServices.GetOrderLine(o.Id,n.Id(),!1).done(function(n){r=n}),r)&&(n.PriceInfo.RegularItemPrice(parseFloat(r.PriceInfo.RegularItemPrice)),n.PriceInfo.ActualItemPrice(parseFloat(r.PriceInfo.ActualItemPrice)),n.PriceInfo.RegularTotalPrice(parseFloat(r.PriceInfo.RegularTotalPrice)),n.PriceInfo.ActualTotalPrice(parseFloat(r.PriceInfo.ActualTotalPrice)),t.OrderViewModel.Order&&t.OrderViewModel.Order.getUpdatedOrderData(),o.loadRecommendedProducts())})}};this.loadRecommendedProducts=function(n,t){n||(n=[],o.BasketLines().map(function(t){var r=t.ProductInfo(),i;r&&(i=r.BackofficeProductId(),i&&n.push(i))}));o.RecommendedProducts().loadRecommendedProducts(n,t)};this.updateSubTotalPrice=function(){var n=Services.UserServices.GetUserBasketViewModel(!1);o.PriceInfo().SubTotal(parseFloat(n.PriceInfo.SubTotal))};this.setBasketLines=function(n){var t=[];n.forEach(function(n){var i=new u(n);t.push(i)});o.BasketLines(t);o.BasketLines.sort(function(n,t){var i=Helpers.CommonHelper.GetUTCDate(n.ProductInfo().CreateOnDate()),r=Helpers.CommonHelper.GetUTCDate(t.ProductInfo().CreateOnDate());return i<r?1:-1})};this.continueShoppingClick=function(n,t){var i=$.cookie(Constants.Global.StorePageCookieKey);window.location.href=i?i:t.target.href};this.$container=$(e);this.Id=f.Id;s=new r(f.PriceInfo);this.PriceInfo=ko.observable(s);this.OrderStatus=ko.observable(f.OrderStatus);f.Order_orderLines&&(f.Basket_orderLines=f.Order_orderLines);f.Basket_orderLines&&this.setBasketLines(f.Basket_orderLines);this.Discounted=ko.computed(function(){return o.PriceInfo().Discount()>0});this.TotalItemCount=ko.computed(function(){var n=0;return o.BasketLines().forEach(function(t){var i=t.Quantity();n+=i instanceof Number?i:parseInt(i)}),t.CartItemCounterViewModel.Counter&&o.OrderStatus()=="Basket"&&t.CartItemCounterViewModel.Counter.TotalItemCount(n),n});this.calculatedSubTotalPrice=ko.computed(function(){return o.PriceInfo().CurrencySymbol()+o.PriceInfo().SubTotal().toFixed(2)});this.HasOnlyDigitalProducts=ko.computed(function(){var n=!0;return o.BasketLines().forEach(function(t){t.ProductInfo().VariantType()!=Constants.VariantType.Digital&&(n=!1)}),n});i.Basket=this}return i}(),r,u,f,e,o;t.BasketViewModel=i;r=function(){function n(n){var t=this;this.TaxValue=ko.observable(0);this.TaxCalculationError=ko.observable(!1);this.Discount=ko.observable(0);this.ShippingPrice=ko.observable(0);this.OrderTotal=ko.observable(0);this.SubTotal=ko.observable(0);this.CurrencySymbol=ko.observable("");this.Precision=ko.observable(2);n&&(this.TaxValue=ko.observable(parseFloat(n.Tax)),this.TaxCalculationError=ko.observable(n.TaxCalculationError),this.Discount=ko.observable(parseFloat(n.Discount)),this.ShippingPrice=ko.observable(parseFloat(n.Shipping)),this.OrderTotal=ko.observable(parseFloat(n.OrderTotal)),this.SubTotal=ko.observable(parseFloat(n.SubTotal)),this.CurrencySymbol=ko.observable(n.CurrencySymbol));this.formatedTaxValue=ko.computed(function(){return t.CurrencySymbol()+t.TaxValue().toFixed(t.Precision())});this.formatedDiscount=ko.computed(function(){return t.Discount()>0?"-"+t.CurrencySymbol()+t.Discount().toFixed(t.Precision()):""});this.formatedShippingPrice=ko.computed(function(){return t.CurrencySymbol()+t.ShippingPrice().toFixed(t.Precision())});this.formatedOrderTotal=ko.computed(function(){return t.CurrencySymbol()+t.OrderTotal().toFixed(t.Precision())});this.formatedSubTotal=ko.computed(function(){return t.CurrencySymbol()+t.SubTotal().toFixed(t.Precision())})}return n}();t.OrderPriceInfoModel=r;u=function(){function n(n){var r=this;this.updateProgramForm=function(){var n=$('[role="dialog"][data-modal="standing-order"]')[0];ko.cleanNode(n);ko.applyBindings(r,n)};this.updateProgram=function(){var u=$.cookie(Constants.Global.BasketCookieKey),n;u&&(n={Id:r.Id(),Quantity:parseInt(r.Quantity()),PriceInfo:null,ParticipatesInProgram:r.ProductInfo().Program().Enroll(),ProgramSubscribtion:null},$.extend(n,{"odata.type":Constants.Global.ODataOperation("OrderLine")}),Services.OrderServices.UpdateOrderLine(i.Basket.Id+";"+r.Id(),JSON.stringify(n)).done(function(n){var u,f;(n||Services.OrderServices.GetOrderLine(i.Basket.Id,r.Id(),!1).done(function(n){u=n}),u)&&(f=u.ParticipatesInProgram,r.ParticipatesInProgram(f=="true"||f==!0),t.OrderViewModel.Order&&t.OrderViewModel.Order.getUpdatedOrderData())}))};this.Id=ko.observable(n.Id);this.Quantity=ko.observable(n.Quantity);this.ProductInfo=ko.observable(new f(n.Product?n.Product:n.ProductInfo,n.ParticipatesInProgram));this.PriceInfo=new o(n.PriceInfo);this.ParticipatesInProgram=ko.observable(n.ParticipatesInProgram)}return n}();t.OrderLine=u;f=function(){function n(n,t){t===void 0&&(t=!1);var i=this;this.Id=ko.observable();this.ProductName=ko.observable();this.ProductTitle=ko.observable();this.FormatName=ko.observable();this.Program=ko.observable();this.IsDownloadable=ko.observable();this.IsDisplayed=ko.observable();this.ShippingLocation=ko.observable();this.Isbn=ko.observable();this.PublicationFrequency=ko.observable();this.EstimatedShippingDate=ko.observable();this.BackofficeProductId=ko.observable();this.Categories=ko.observable();this.Authors=ko.observable();this.ThumbnailUrl=ko.observable();this.SmallImageUrl=ko.observable();this.ProductUrl=ko.observable();this.RegularPrice=ko.observable(0);this.ActualPrice=ko.observable(0);this.ExtendedRegularPrice=ko.observable(0);this.ExtendedActualPrice=ko.observable(0);this.CurrencySymbol=ko.observable();this.Pages=ko.observable();this.Volumes=ko.observable();this.OrderTrackingUrl=ko.observable();this.VariantType=ko.observable();this.Precision=ko.observable(2);this.Id=ko.observable(n.Id);this.ProductName=ko.observable(n.ProductName);this.ProductTitle=ko.observable(n.ProductTitle);this.FormatName=ko.observable(n.FormatName);this.IsDownloadable=ko.observable(n.IsDownloadable);this.IsDisplayed=ko.observable(n.IsDisplayed);this.ShippingLocation=ko.observable(n.ShippingLocation?n.ShippingLocation.Name:null);this.PublicationDate=ko.observable(n.PublicationDate);this.CreateOnDate=ko.observable(n.CreateOnDate);this.Program=ko.observable(new e(n.Program,t));this.Isbn=ko.observable(n.Isbn);this.PublicationFrequency=ko.observable(n.PublicationFrequency);this.EstimatedShippingDate=ko.observable(n.EstimatedShippingDate);this.BackofficeProductId=ko.observable(n.BackofficeProductId);this.Categories=ko.observable(n.Categories);this.Authors=ko.observable(n.Authors);this.ThumbnailUrl=ko.observable(n.ThumbnailImageUrl);this.OrderTrackingUrl=ko.observable(n.OrderTrackingUrl);this.SmallImageUrl=ko.observable(n.SmallImageUrl);this.ProductUrl=ko.observable(n.ProductVariantUrl);this.RegularPrice=ko.observable(parseFloat(n.RegularPrice));this.ActualPrice=ko.observable(parseFloat(n.ActualPrice));this.ExtendedRegularPrice=ko.observable(parseFloat(n.ExtendedRegularPrice));this.ExtendedActualPrice=ko.observable(parseFloat(n.ExtendedActualPrice));this.CurrencySymbol=ko.observable(n.CurrencySymbol);this.Pages=ko.observable(n.Pages);this.Volumes=ko.observable(n.Volumes);this.VariantType=ko.observable(n.VariantTypeValue?n.VariantTypeValue:n.VariantType);this.Sku=ko.computed(function(){return i.Id().split(",")[1]});this.formatedRegularPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.RegularPrice().toFixed(i.Precision())});this.formatedActualPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ActualPrice().toFixed(i.Precision())});this.formatedExtendedRegularPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ExtendedRegularPrice().toFixed(i.Precision())});this.formatedExtendedActualPrice=ko.computed(function(){return i.VariantType()===Constants.VariantType.NonSellable?null:i.CurrencySymbol()+i.ExtendedActualPrice().toFixed(i.Precision())});this.formatedAuthors=ko.computed(function(){var n="";return i.Authors()&&i.Authors().length&&i.Authors().forEach(function(t){n+=t;i.Authors().indexOf(t)!=i.Authors().length-1&&(n+=", ")}),n});this.shippingFromLocation=ko.computed(function(){return i.ShippingLocation()?i.ShippingLocation():""});this.trackingNumber=ko.computed(function(){return i.OrderTrackingUrl()?i.OrderTrackingUrl():"<test number>"})}return n}();t.ProductInfo=f;e=function(){function n(n,t){t===void 0&&(t=!1);this.Type=ko.observable();this.IsSubscribed=ko.observable();this.Enroll=ko.observable();n&&(this.Type(n.TypeValue?n.TypeValue:n.Type),this.IsSubscribed(n.IsSubscribed),this.Enroll(t))}return n}();t.ProductProgram=e;o=function(){function n(n){var t=this;this.RegularItemPrice=ko.observable(0);this.ActualItemPrice=ko.observable(0);this.RegularTotalPrice=ko.observable(0);this.ActualTotalPrice=ko.observable(0);this.CurrencySymbol=ko.observable();this.Precision=ko.observable(2);this.RegularItemPrice=ko.observable(parseFloat(n.RegularItemPrice));this.ActualItemPrice=ko.observable(parseFloat(n.ActualItemPrice));this.RegularTotalPrice=ko.observable(parseFloat(n.RegularTotalPrice));this.ActualTotalPrice=ko.observable(parseFloat(n.ActualTotalPrice));this.CurrencySymbol=ko.observable(n.CurrencySymbol);this.formatedRegularItemPrice=ko.computed(function(){return t.CurrencySymbol()+t.RegularItemPrice().toFixed(t.Precision())});this.formatedActualItemPrice=ko.computed(function(){return t.CurrencySymbol()+t.ActualItemPrice().toFixed(t.Precision())});this.formatedRegularTotalPrice=ko.computed(function(){return t.CurrencySymbol()+t.RegularTotalPrice().toFixed(t.Precision())});this.formatedActualTotalPrice=ko.computed(function(){return t.CurrencySymbol()+t.ActualTotalPrice().toFixed(t.Precision())})}return n}();t.PriceInfo=o})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n,t){var i=this;this.verifiedEmail=!1;this.isChangingEmail=ko.observable(!1);this.save=function(n,t){if(t.preventDefault(),$("[for='password'][rule='invalid']",i.$container).hide(),i.errors().length>0||!i.verifiedEmail){i.errors.showAllMessages(!0);i.verifiedEmail?$("[for='email'][rule='exist']",i.$container).hide():$("[for='email'][rule='exist']",i.$container).show();return}if(!i.isChangingEmail()){i.isChangingEmail(!0);var r=$(".wkis-account-content .wkis-field-group","#accountInformationContainer"),u=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ChangeEmail"),EmailAddress:i.OldEmail(),NewEmailAddress:i.NewEmail(),Password:i.Password()}});$.ajax("/Ecommerce.svc/CustomerAdministration_ChangeEmail",{method:"POST",data:u,success:function(){$("button.js-wkis-modal-close",i.$container)[0].click();r.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Email was successfully changed",{duration:1e4}));$(".wkis-signout-link")[0].click()},error:function(n){var u="",t;n.responseText&&(u=n.responseText.split(":")[1].trim().replace(".",""));switch(u){case"invalid password":$("input[type='password']",i.$container).addClass("ko-error");$("[for='password'][rule='invalid']",i.$container).show();break;case"email already exists":t=$("#NewEmailInput",i.$container);t.addClass("ko-error");t.removeClass("ko-valid");t.parent().removeClass("ko-valid");$("[for='NewEmail'][rule='exist']",i.$container).show();break;default:$("button.js-wkis-modal-close",i.$container)[0].click();r.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"FAILED!","Error occured while changing password",{duration:1e4}))}},complete:function(){i.isChangingEmail(!1)}})}};this.verifyEmail=function(n,t){var r,u,f;if(t.preventDefault(),r=$(t.currentTarget),!i.NewEmail.isValid()){$("[for='NewEmail'][rule='exist']",i.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");return}i.verifiedEmail=!1;u=Constants.Global.ODataOperation("EmailExists");f=JSON.stringify({request:{Email:r.val(),"odata.type":u}});$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='NewEmail'][rule='exist']",i.$container).hide(),i.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='NewEmail'][rule='exist']",i.$container).show(),i.verifiedEmail=!1)}})};this.keyUp=function(n,t){t.keyCode===13&&i.save(n,t)};this.$container=$(n);this.OldEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"OldEmail");this.OldEmail(t.Email());this.NewEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"NewEmail").extend({notEqual:{message:Helpers.KnockoutHelper.validationMessage("NewEmail","notEqual",this.$container),params:this.NewEmail}});this.ConfirmEmail=Helpers.KnockoutHelper.GetObservableByType("email",this.$container,"ConfirmEmail").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("ConfirmEmail","equal",this.$container),params:this.NewEmail}});this.Password=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("password","required",this.$container)}});this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ChangeEmailViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.changePassword=function(){if(t.errors().length){t.errors.showAllMessages(!0);return}var n=$(".wkis-account-content .wkis-field-group","#accountInformationContainer"),i=Constants.Global.ODataOperation("ChangePassword"),r=JSON.stringify({request:{OldPassword:t.OldPassword(),NewPassword:t.NewPassword(),"odata.type":i}});$.ajax("/Ecommerce.svc/CustomerAdministration_ChangePassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:r,success:function(){$('[for="wrongOldPasword"]',t.$container).hide();$("button.js-wkis-modal-close",t.$container)[0].click();n.append(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS!","Password was successfully changed",{duration:1e4}))},error:function(){$('[for="wrongOldPasword"]',t.$container).show()}})};this.$container=$(n);this.OldPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"OldPassword");this.NewPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"NewPassword");this.ConfirmPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"ConfirmPassword").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("ConfirmPassword","equal",this.$container),params:this.NewPassword}});this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ChangePasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(r,u){var f=this,e,o,s;this.Addresses=ko.observableArray();this.addAddressForm=function(n,r){var f=$(r.currentTarget).attr("data-modal"),u=$("[data-modal='"+f+"'][role='dialog']")[0],e;t.AddAddressModel()?(t.AddAddressModel().clear(),$("input",u).add("select",u).removeClass("ko-error"),$(".ko-validation-custom-message",u).hide()):(e=new i(u,null,!0),t.AddAddressModel(e));f.indexOf("billing")!=-1?t.AddAddressModel().IsBilling=ko.observable(!0):f.indexOf("shipping")!=-1&&(t.AddAddressModel().IsBilling=ko.observable(!1));!!ko.dataFor(u)||(ko.applyBindings(t.AddAddressModel,u),t.AddAddressModel().Country&&t.AddAddressModel().Country.clearError());$("span.ko-validation-message",u).hide();t.AddAddressModel().isValid(!1)};this.selectAddress=function(n){f.Addresses().forEach(function(t){t.IsBilling()==n.IsBilling()&&t!=n&&t.Selected(!1)});n.Selected(!0)};this.$container=$(u);e=[];r&&r.length&&r.forEach(function(t){var r=new i(u,t);n.OrderViewModel.Order&&(o=n.OrderViewModel.Order.BillingAddress()&&n.OrderViewModel.Order.BillingAddress().AddressId()?n.OrderViewModel.Order.BillingAddress():undefined,s=n.OrderViewModel.Order.ShippingAddress()&&n.OrderViewModel.Order.ShippingAddress().AddressId()?n.OrderViewModel.Order.ShippingAddress():undefined);e.push(r)});this.Addresses=ko.observableArray(e);this.ShippingAddress=ko.computed(function(){var n=[];return f.Addresses().forEach(function(t){t.IsBilling()||n.push(t)}),ko.observableArray(n)});this.BillingAddress=ko.computed(function(){var n=[];return f.Addresses().forEach(function(t){t.IsBilling()&&n.push(t)}),ko.observableArray(n)});this.ShippingAddressExcludeDefault=ko.computed(function(){var n=[];return f.ShippingAddress()().forEach(function(t){t.IsDefaultShipping()||n.push(t)}),n});this.BillingAddressExcludeDefault=ko.computed(function(){var n=[];return f.BillingAddress()().forEach(function(t){t.IsDefaultBilling()||n.push(t)}),n});this.DefualtShippingAddress=ko.computed(function(){var n;return f.ShippingAddress()().forEach(function(t){t.IsDefaultShipping()==!0&&(n=t)}),n});this.DefualtBillingAddress=ko.computed(function(){var n;return f.BillingAddress()().forEach(function(t){t.IsDefaultBilling()==!0&&(n=t)}),n});this.SelectedShippingAddress=ko.computed(function(){var n;return f.ShippingAddress()().forEach(function(t){t.Selected()==!0&&(n=t)}),n});this.SelectedBillingAddress=ko.computed(function(){var n;return f.BillingAddress()().forEach(function(t){t.Selected()==!0&&(n=t)}),n});s||this.DefualtShippingAddress()&&(this.DefualtShippingAddress().Selected(!0),n.OrderViewModel.Order&&n.OrderViewModel.Order.ShippingAddress().AddressId()!=this.DefualtShippingAddress().AddressId()&&n.OrderViewModel.Order.setShippingAddress(this.DefualtShippingAddress()));o||this.DefualtBillingAddress()&&(this.DefualtBillingAddress().Selected(!0),n.OrderViewModel.Order&&n.OrderViewModel.Order.BillingAddress().AddressId()!=this.DefualtBillingAddress().AddressId()&&n.OrderViewModel.Order.setBillingAddress(this.DefualtBillingAddress()));t.AddressBook=this}return t}(),i;t.EditAddressModel=ko.observable();t.AddAddressModel=ko.observable();n.AddressBookModel=t;i=function(){function i(r,u,f,e){var o,s;f===void 0&&(f=!1);o=this;this.AddressId=ko.observable();this.AddressLine=ko.observable();this.AddressLine2=ko.observable();this.AvailableCountries=ko.observableArray();this.AvailableStates=ko.observableArray();this.CompanyName=ko.observable();this.Country=ko.observable(new Entities.AddressBookModels.CountryModel);this.CountryIso=ko.observable();this.CountryName=ko.observable();this.City=ko.observable();this.Email=ko.observable();this.FirstName=ko.observable();this.IsBilling=ko.observable();this.IsDefaultBilling=ko.observable();this.IsDefaultShipping=ko.observable();this.LastName=ko.observable();this.PostalCode=ko.observable();this.PhoneNumber=ko.observable();this.Selected=ko.observable();this.State=ko.observable(new Entities.AddressBookModels.StateModel);this.StateIso=ko.observable();this.StateName=ko.observable();this.Region=ko.observable();this.VerificationMessage=ko.observable();this.regionVisibility=ko.observable(!0);this.SaveAsDefault=!1;this.verifiedEmail=!1;this.bindValidation=function(){o.FirstName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("FirstName","required",o.$container)}});o.LastName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("LastName","required",o.$container)}});o.CompanyName.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CompanyName","required",o.$container)}});o.AddressLine.extend({required:{message:Helpers.KnockoutHelper.validationMessage("AddressLine","required",o.$container)}});o.City.extend({required:{message:Helpers.KnockoutHelper.validationMessage("City","required",o.$container)}});o.PostalCode.extend({required:{message:Helpers.KnockoutHelper.validationMessage("PostalCode","required",o.$container)}});o.PhoneNumber.extend({required:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","required",o.$container)}});o.Email.extend({email:{message:Helpers.KnockoutHelper.validationMessage("email","email",o.$container)}}).extend({required:{message:Helpers.KnockoutHelper.validationMessage("email","required",o.$container)}});o.Country.extend({required:{message:Helpers.KnockoutHelper.validationMessage("Country","required",o.$container)}})};this.prefillAddress=function(){i.Countries&&i.Countries.length?o.setCountriesAndStates(i.Countries):$.ajax("/Ecommerce.svc/AddressAdministration_GetCountries",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetCountries")}}),success:function(n){i.Countries=n.Countries;i.DefaultCountryIso=n.DefaultCountryIso;o.setCountriesAndStates(n.Countries)}})};this.setCountriesAndStates=function(n,t){var i=o.CountryIso(),u=o.StateName(),f=o.Region(),r;n&&n.length&&(o.AvailableCountries.removeAll(),r=!1,o.sortedCountries(n).forEach(function(n){o.AvailableCountries.push(n);r||(t?o.selectCountryAndState(n,i,null,null,t):o.selectCountryAndState(n,i,u,f))}));o.Country.clearError()};this.selectCountryAndState=function(n,t,r,u,f){if(o.CountryIso()||i.DefaultCountryIso&&!t&&(t=i.DefaultCountryIso),n.CountryIso&&n.CountryIso==t){o.setCountry(n);var e=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetStates"),Name:o.CountryName()}});$.ajax("/Ecommerce.svc/AddressAdministration_GetStates/",{type:"POST",async:!1,contentType:Constants.ContentType.OsaContentType,data:e,success:function(t){var i=t.value,e;i&&i.length?(e=!1,o.AvailableStates.removeAll(),o.sortedStates(i).forEach(function(n){o.AvailableStates.push(n);r&&!e&&n.StateName==r&&(e=o.setState(n));o.checkRegionVisibility()}),f&&o.chooseState(f)):(n.HasChildren&&u&&o.Region(u),o.setState())}})}};this.changeCountryHandler=function(n,t){o.setCountry(o.Country());o.setState();o.Region("");o.changePhoneValidationAccordingCountry(n);o.getStatesByCountry(n,t);o.checkRegionVisibility()};this.changeStateHandler=function(n,t){t&&!t.eventPhase&&!o.State()&&o.StateName()&&o.StateIso()&&(o.State(new Entities.AddressBookModels.StateModel(o.StateName(),o.StateIso())),o.chooseState(o.StateIso()));o.setState(o.State());o.validateRegionState()};this.changeCityHandler=function(n,t){t.preventDefault();o.checkRegionVisibility()};this.checkRegionVisibility=function(){o.regionVisibility(!(o.City()&&Constants.AddressBook.CitiesWithoutRegionValidation.indexOf(o.City().toLowerCase())!=-1))};this.changePhoneValidationAccordingCountry=function(n){var i=n.CountryIso(),t=$("[name='phone']",n.$container).not(".prepopulated");i==Constants.CountriesIso.US||i==Constants.CountriesIso.CA?(n.PhoneNumber.rules.remove(function(n){return n.rule=="digit"}),n.PhoneNumber.rules.remove(function(n){return n.rule=="maxLength"}),n.PhoneNumber.extend({phoneUS:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","phoneUS",n.$container)}}).extend({maxLength:12}),t.length&&t.unbind("keypress.checkForDigit").bind("keypress.checkForDigit",function(n){return o.customMaskForUSPhone(n)})):(n.PhoneNumber.rules.remove(function(n){return n.rule=="phoneUS"}),n.PhoneNumber.rules.remove(function(n){return n.rule=="maxLength"}),n.PhoneNumber.extend({digit:{message:Helpers.KnockoutHelper.validationMessage("PhoneNumber","number",n.$container)}}).extend({maxLength:16}),t.length&&t.unbind("keypress.checkForDigit"))};this.getStatesByCountry=function(n,t){if(t.preventDefault(),!n.Country()){n.CountryIso(null);n.CountryName(null);return}var n=ko.isObservable(n)?n():n;n.CountryName(n.Country().CountryName);n.CountryIso(n.Country().CountryIso);n.CountryIso()&&(n.AvailableStates.removeAll(),$.ajax("/Ecommerce.svc/AddressAdministration_GetStates/",{type:"POST",async:!1,contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetStates"),Name:o.CountryName()}}),success:function(t){var i=t.value,r;i&&i.length?(r=!1,o.sortedStates(i).forEach(function(t,u){n.AvailableStates.push(t);r||n.StateName()&&i[u].StateName==n.StateName()&&(r=n.setState(i[u]))}),o.checkRegionVisibility()):n.setState()}}))};this.getCityStateByZip=function(n,t){t.preventDefault();n.Country()&&n.Country().CountryIso==Constants.CountriesIso.US&&n.PostalCode()&&$.ajax("/Ecommerce.svc/AddressAdministration_CityStateByZip/",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("CityStateByZip"),Zip:n.PostalCode()}}),success:function(t){t&&(t.City&&!n.City()&&n.City(t.City),t.State&&n.AvailableStates().length&&!n.State()&&o.chooseState(t.State))}})};this.addAddress=function(n,t,i,r){if(i===void 0&&(i=!1),t.preventDefault(),o.isValid()){var u=$("input[default]",n.$container)[0],f=u?u.checked:!1;(n.SaveAsDefault=f,o.suggestAddress(n,"add",f,r))||o.saveAddress(n,t,i)}};this.suggestAddress=function(n,t,r,u){var f,e;if(t===void 0&&(t="add"),!n.IsBilling()&&n.CountryIso()&&n.CountryIso().toLowerCase()===Constants.CountriesIso.US.toLowerCase()&&(f=Services.UserServices.GetSuggestedAddress(ko.mapping.toJS(n,Constants.KnockooutMapping.IgnoreJQueryMapping),!1),f)){e=void 0;f.addressModel?(f.addressModel.Id=f.Id,e=new i(n.$container,f.addressModel,!0),r&&(e.SaveAsDefault=r)):e=new i(n.$container,null,!1,f.message);var o=u?$('[role="dialog"][data-modal="address-verification-apply"]'):$('[role="dialog"][data-modal="address-verification"]'),s=$(".current-address",o)[0],h=$(".wkis-modal-header",o)[0],c=$(".suggested-address",o)[0];return $("button",o).attr("operation",t),ko.cleanNode(s),ko.cleanNode(h),ko.cleanNode(c),ko.applyBindings(n,s),ko.applyBindings(n,h),ko.applyBindings(e,c),Helpers.HtmlHelper.OpenModalDialog(o.attr("data-modal")),!0}return!1};this.useAddress=function(n,t,i){var r=$(t.currentTarget).attr("operation");if(r)switch(r){case"add":o.saveAddress(n,t,i);break;case"update":o.updateAddress(n,t)}else o.saveAddress(n,t,i)};this.applyNewAddress=function(i){t.AddressBook&&t.AddressBook.Addresses()&&t.AddressBook.Addresses().length?o.saveAddress(i,null,!0):n.OrderViewModel.Order.SameAddresses()?n.OrderViewModel.Order.applyAddresses(i,i):i.IsBilling()?n.OrderViewModel.Order.applyAddresses(n.OrderViewModel.Order.ShippingAddress(),i):n.OrderViewModel.Order.applyAddresses(i,n.OrderViewModel.Order.BillingAddress());Helpers.HtmlHelper.CloseModalDialog()};this.saveAddress=function(r,u,f,e){var r,h,s,c,l;e===void 0&&(e=!0);r||(r=o);h={ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","verifiedEmail","SaveAsDefault","CustomerName","IsDefaultBilling","IsDefaultShipping","regionVisibility"]};$("button[type=submit]",o.$container).attr("disabled","disabled");s=ko.mapping.toJS(r,h);$.extend(s,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:r.Region()},{Email:r.Email()});c=o.IsBilling()?0:1;l=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsDefaultBilling(),IsDefaultShipping:o.IsDefaultShipping(),TypeValue:c,Address:s});$.ajax("/Ecommerce.svc/CustomerAddresses",{type:"POST",data:l,async:e,contentType:Constants.ContentType.OsaContentType,complete:function(u){if(u.readyState==4&&u.status==201){var e=new i(o.$container,u.responseJSON,!0);t.AddressBook&&t.AddressBook.Addresses&&t.AddressBook.Addresses.push(e);f==!0&&(t.AddressBook&&t.AddressBook.selectAddress(e),n.OrderViewModel.Order&&(n.OrderViewModel.Order.SameAddresses()?(n.OrderViewModel.Order.setBillingAddress(e),n.OrderViewModel.Order.setShippingAddress(e)):e.IsBilling()?n.OrderViewModel.Order.setBillingAddress(e):n.OrderViewModel.Order.setShippingAddress(e)));r.SaveAsDefault===!0&&e.setDefault();$('.js-wkis-alert-message[data-type="success"]').remove();$(".js-wkis-modal-overlay")[0].click()}$("button[type=submit]",o.$container).removeAttr("disabled")}})};this.validateRegionState=function(n){var t,i,r,u;return n===void 0&&(n=!0),o.Country()&&o.Country().HasChildren?o.AvailableStates().length?(t=$("div.ko-validation-custom-message[for='State'][rule='required']"),i=$("select[name=stateSelector]",o.$container),o.StateIso()||o.City()&&Constants.AddressBook.CitiesWithoutRegionValidation.indexOf(o.City().toLowerCase())!=-1?(i.removeClass("ko-error"),t.hide(),!0):(n&&(i.addClass("ko-error"),t.show()),!1)):(r=$("div.ko-validation-custom-message[for='Region'][rule='required']"),u=$("[name=region]",o.$container),o.Region()?(u.removeClass("ko-error"),r.hide(),!0):(n&&(u.addClass("ko-error"),r.show()),!1)):!0};this.isValid=function(n,t){return(n===void 0&&(n=!0),t===void 0&&(t=!1),o.errors().length>0)?(o.errors.showAllMessages(!1),o.errors.showAllMessages(n),o.validateRegionState(n),!1):o.validateRegionState(n)?t&&o.emailErrors().length>0&&(o.Email()&&!o.verifiedEmail||!o.Email())?(o.emailErrors.showAllMessages(n),!1):!0:!1};this.setDefault=function(){var n=o,i=ko.mapping.toJS(n,{ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","IsDefaultBilling","IsDefaultShipping","verifiedEmail","SaveAsDefault","AddressId","CustomerName","Selected","regionVisibility"]}),r,u;$.extend(i,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:n.Region()},{Email:n.Email()});r=o.IsBilling()?0:1;u=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsBilling(),IsDefaultShipping:!o.IsBilling(),TypeValue:r,Address:i});$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')",{type:"PATCH",contentType:Constants.ContentType.OsaContentType,data:u,success:function(){var i,r;n.IsBilling()!=!0?(t.AddressBook.DefualtShippingAddress()&&t.AddressBook.DefualtShippingAddress().IsDefaultShipping(!1),n.IsDefaultShipping(!0),i=$("div[data-type='shipping']",t.AddressBook.$container).children("button").first(),i&&(r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS","The Default Shipping address was changed successfully",{duration:1e4}),i.after(r))):n.IsBilling()==!0&&(t.AddressBook.DefualtBillingAddress()&&t.AddressBook.DefualtBillingAddress().IsDefaultBilling(!1),n.IsDefaultBilling(!0),i=$("div[data-type='billing']",t.AddressBook.$container).children("button").first(),i&&(r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"SUCCESS","The Default Billing address was changed successfully",{duration:1e4}),i.after(r)))}})};this.removeAddressForm=function(n,t){var r=$(t.currentTarget).attr("data-modal"),i=$("[data-modal='"+r+"'][role='dialog']")[0];ko.cleanNode(i);$("span.ko-validation-message",i).remove();ko.applyBindings(n,i)};this.removeAddress=function(n){if(t.AddressBook)var r=o.IsBilling()?"billing":"shipping",i=$("div[data-type="+r+"]",t.AddressBook.$container).children("button").first();$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')/",{type:"DELETE",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({key:n.AddressId}),success:function(){var r,u;t.AddressBook.Addresses.remove(n);n.IsDefaultBilling()?t.AddressBook.BillingAddress()().length?t.AddressBook.BillingAddress()()[0].setDefault():r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Info,"ADVICE","A Default Address should be set to enable a faster checkout process in the future"):n.IsDefaultShipping()&&(t.AddressBook.ShippingAddress()().length?t.AddressBook.ShippingAddress()()[0].setDefault():r=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Info,"ADVICE","A Default Address should be set to enable a faster checkout process in the future"));i&&(r&&i.after(r),u=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Success,"Success!","The address has been removed from your address book",{duration:1e4}),i.after(u))},error:function(){if(i){var n=Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"Failed!","The address failed to be removed from your address book. Please try again",{duration:1e4});i.after(n)}}})};this.editAddressForm=function(n,i){var f=$(i.currentTarget),r=$("[role=dialog][data-modal="+f.attr("data-modal")+"]")[0],u;$("span.ko-validation-message",r).hide();u=n.clone(r);u.prefillAddress();$("input",r).add("select",r).removeClass("ko-error");$(".ko-validation-custom-message",r).hide();t.EditAddressModel(u);!!ko.dataFor(r)||(ko.applyBindings(t.EditAddressModel,r),t.EditAddressModel().Country&&t.EditAddressModel().Country.clearError())};this.changeAddress=function(n,t,i){(i===void 0&&(i=!1),t.preventDefault(),o.isValid())&&(o.suggestAddress(n,"update")||o.updateAddress(n,t,i))};this.updateAddress=function(n,r,u){var e,f,s,h;(u===void 0&&(u=!1),r.preventDefault(),o.isValid())&&(e={ignore:["$container","AvailableCountries","AvailableStates","State","Selected","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","IsDefaultBilling","IsDefaultShipping","verifiedEmail","SaveAsDefault","AddressId","CustomerName","regionVisibility"]},$("button[type=submit]",o.$container).attr("disabled","disabled"),f=ko.mapping.toJS(n,e),$.extend(f,{"odata.type":Constants.Global.ODataOperation("Address")},{Region:n.Region()},{Email:n.Email()}),s=o.IsBilling()?0:1,h=JSON.stringify({"odata.type":Constants.Global.ODataOperation("CustomerAddress"),Id:o.AddressId(),IsDefaultBilling:o.IsDefaultBilling(),IsDefaultShipping:o.IsDefaultShipping(),TypeValue:s,Address:f}),$.ajax("/Ecommerce.svc/CustomerAddresses('"+n.AddressId()+"')/",{type:"PUT",contentType:Constants.ContentType.OsaContentType,data:h,success:function(){var f=t.AddressBook.Addresses().filter(function(t){return t.AddressId()==n.AddressId()}),e=new i(f[0].$container,n.toEntity());t.AddressBook.Addresses.replace(f[0],e);($(r.currentTarget).attr("aria-label")=="close dialog"||$(r.currentTarget).attr("operation"))&&$("button[aria-label='close dialog']",n.$container).click();u&&o.returnToAddressBook()}}))};this.selectAddress=function(){t.AddressBook?t.AddressBook.selectAddress(o):o.Selected(!o.Selected)};this.returnToAddressBook=function(){var n=o.IsBilling()?'[data-modal="address-book-billing"]':'[data-modal="address-book-shipping"]';$("a.js-wkis-modal-open.wkis-arrow-link.-back"+n)[0].click()};this.verifyEmail=function(t,i){var r,u,f;if(i.preventDefault(),n.OrderViewModel.Order&&n.OrderViewModel.Order.IsGuestOrder()){if(r=$(i.currentTarget),t.emailErrors().length>0){$("[for='email'][rule='exist']",t.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");t.emailErrors.showAllMessages(!0);return}u=Constants.Global.ODataOperation("EmailExists");f=JSON.stringify({request:{Email:r.val(),"odata.type":u}});$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){n&&n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).hide(),o.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).show(),o.verifiedEmail=!1)}})}};this.setCountry=function(n){return o.CountryName(n?n.CountryName:undefined),o.CountryIso(n?n.CountryIso:undefined),o.Country(n),o.changePhoneValidationAccordingCountry(o),!0};this.setState=function(n){return n?(o.StateName(n.StateName),o.StateIso(n.StateIso),o.State(n)):(o.StateName(""),o.StateIso(""),o.State(null)),!0};this.chooseState=function(n){if(o.AvailableStates()&&o.AvailableStates().length){var t=!1;o.AvailableStates().forEach(function(i){t||i.StateIso.search(n)==-1||(o.setState(i),t=!0)})}};this.sortedStates=function(n){return n.sort(function(n,t){return n.StateName<t.StateName?-1:1})};this.sortedCountries=function(n){return n.sort(function(n,t){return Constants.AddressBook.PriorityCountries.indexOf(n.CountryIso)!=-1?-1:Constants.AddressBook.PriorityCountries.indexOf(t.CountryIso)!=-1?1:n.CountryName<t.CountryName?-1:1})};this.clone=function(n){var r=o.toEntity(),t=new i(n?n:o.$container,r);return t.CustomerName=o.CustomerName,t.AvailableCountries(o.AvailableCountries()),t.AvailableStates(o.AvailableStates()),t.Country(o.Country()),t.State(o.State()),t.Selected(o.Selected()),t.SaveAsDefault=o.SaveAsDefault,t};this.toEntity=function(){var t=new Entities.AddressBookModels.AddressBookModel,n=new Entities.AddressBookModels.AddressModel;return n.AddressLine=o.AddressLine(),n.AddressLine2=o.AddressLine2(),n.City=o.City(),n.CompanyName=o.CompanyName(),n.CountryIso=o.CountryIso(),n.CountryName=o.CountryName(),n.Email=o.Email(),n.FirstName=o.FirstName(),n.LastName=o.LastName(),n.Telephone=o.Telephone(),n.ZipCode=o.ZipCode(),n.StateIso=o.StateIso(),n.StateName=o.StateName(),n.Region=o.Region(),n.IsBilling=o.IsBilling(),t.Address=n,t.Id=o.AddressId(),t.IsDefaultBilling=o.IsDefaultBilling(),t.IsDefaultShipping=o.IsDefaultShipping(),t.TypeValue=o.IsBilling()?0:1,t};this.clear=function(){o.AddressLine(null);o.AddressLine2(null);o.City(null);o.CompanyName(null);o.CountryIso(null);o.CountryName(null);o.Email(null);o.FirstName(null);o.IsBilling(!1);o.IsDefaultBilling(!1);o.IsDefaultShipping(!1);o.LastName(null);o.PhoneNumber(null);o.PostalCode(null);o.StateIso(null);o.StateName(null);o.Region(null);o.AvailableCountries([]);o.AvailableStates([]);o.prefillAddress()};this.customMaskForUSPhone=function(n){var t=$(n.currentTarget)[0],f=!1,e,i,u,r;for(n.key&&(e=n.key.toString(),f=e.search(/\d/)!=-1,t.selectionStart!=t.selectionEnd&&(t.value=t.value.replace(t.value.substr(t.selectionStart,t.selectionEnd),""))),i=t.value,u=0,r=0;r<i.length;r++)i[r].toString().search(/\d/)!=-1&&u++;f&&u>9&&(t.value=i.substring(0,i.length-1))};this.$container=$(r);u&&(u.Address?(this.AddressId=ko.observable(u.Id),this.FirstName=ko.observable(u.Address.FirstName),this.LastName=ko.observable(u.Address.LastName),this.CompanyName=ko.observable(u.Address.CompanyName),this.AddressLine=ko.observable(u.Address.AddressLine),this.AddressLine2=ko.observable(u.Address.AddressLine2),this.CountryIso=ko.observable(u.Address.CountryIso),this.CountryName=ko.observable(u.Address.CountryName),this.City=ko.observable(u.Address.City),this.StateIso=ko.observable(u.Address.StateIso),this.StateName=ko.observable(u.Address.StateName),this.PostalCode=ko.observable(u.Address.ZipCode),this.Email=ko.observable(u.Address.Email),this.IsBilling=ko.observable(u.TypeValue===0),this.IsDefaultBilling=ko.observable(u.IsDefaultBilling),this.IsDefaultShipping=ko.observable(u.IsDefaultShipping),this.PhoneNumber=ko.observable(u.Address.Telephone),this.Region=ko.observable(u.Address.Region)):(s=u,this.AddressId=ko.observable(s.Id),this.FirstName=ko.observable(s.FirstName),this.LastName=ko.observable(s.LastName),this.CompanyName=ko.observable(s.CompanyName),this.AddressLine=ko.observable(s.AddressLine),this.AddressLine2=ko.observable(s.AddressLine2),this.CountryIso=ko.observable(s.CountryIso),this.CountryName=ko.observable(s.CountryName),this.City=ko.observable(s.City),this.StateIso=ko.observable(s.StateIso),this.StateName=ko.observable(s.StateName),this.PostalCode=ko.observable(s.ZipCode?s.ZipCode:s.PostalCode),this.Email=ko.observable(s.Email),this.IsBilling=ko.observable(s.IsBilling),this.IsDefaultBilling=ko.observable(u.IsDefaultBilling),this.IsDefaultShipping=ko.observable(u.IsDefaultShipping),this.PhoneNumber=ko.observable(s.Telephone?s.Telephone:s.PhoneNumber),this.Region=ko.observable(s.Region)));this.ZipCode=ko.computed(function(){return o.PostalCode()?o.PostalCode():""});this.Telephone=ko.computed(function(){return o.PhoneNumber()?o.PhoneNumber():""});this.CustomerName=ko.computed(function(){return o.FirstName()&&o.LastName()?o.FirstName()+" "+o.LastName():""});e&&this.VerificationMessage(e);this.bindValidation();f&&this.prefillAddress();this.errors=ko.validation.group([this.FirstName,this.LastName,this.CompanyName,this.AddressLine,this.City,this.PostalCode,this.PhoneNumber,this.Country,this.State,this.Region],{deep:!0});this.emailErrors=ko.validation.group([this.Email]);this.bindBrowserPrepopulating()}return i.prototype.bindBrowserPrepopulating=function(){var n=this;$('input.prepopulated[name="country"]',this.$container).on("input",function(t){var f=$(t.currentTarget).val(),r,u;f&&n.AvailableCountries()&&n.AvailableCountries().length>0&&(n.AvailableCountries().forEach(function(n){r||n.CountryIso!=f||(r=n)}),n.setCountry(r),u=$('input.prepopulated[name="state"]',$(t.currentTarget).parents("form")).val(),u?n.setCountriesAndStates(i.Countries,u):n.prefillAddress())});$('input.prepopulated[name="zip"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.PostalCode(i)});$('input.prepopulated[name="phone"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.PhoneNumber(i)});$('input.prepopulated[name="AddressLine"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.AddressLine(i)});$('input.prepopulated[name="AddressLine2"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.AddressLine2(i)});$('input.prepopulated[name="city"]',this.$container).on("input",function(t){var i=$(t.currentTarget).val();i&&n.City(i)})},i}();n.AddressViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.resetModel=function(){var n=$("[captcha-id]",this.$container);n.length&&(this.grecaptchaWidget=$("[captcha-id]",this.$container).attr("captcha-id"));this.email("");this.email.isModified(!1);grecaptcha.reset(Number(this.grecaptchaWidget));$("#forgotPasswordRecaptcha").css({"border-color":"","border-style":"",width:"",height:""})};this.forgotPassword=function(n,i){var u;if(i.preventDefault(),u=n.email(),t.errors().length>0)t.errors.showAllMessages(!0),$("[for='email'][rule='exist']",t.$container).show();else{var r=!1,f=Constants.Global.ODataOperation("ValidateCaptcha"),e=JSON.stringify({request:{Captcha:$("#forgotPasswordRecaptcha .g-recaptcha-response").val(),"odata.type":f}});$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ValidateCaptcha",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:e,success:function(n){r=n.value},error:function(){r=!1;$("#btnForgotPasswordError").click()}})).done(function(){r?($("#forgotPasswordRecaptcha").css({"border-color":"","border-style":"",width:"",height:""}),$("[for='forgot'][rule='captcha']",t.$container).hide(),$.ajax("/Ecommerce.svc/CustomerAdministration_ForgotPassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ForgotPassword"),Email:u}}),success:function(n){var t=n.value;t==!0?$("#btnForgotPasswordSuccess").click():$("#btnForgotPasswordEmailNotFoundError").click()},error:function(){$("#btnForgotPasswordError").click()}}).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement();t.resetModel()})):($("[for='forgot'][rule='captcha']",t.$container).show(),$("#forgotPasswordRecaptcha").css({"border-color":"#f00","border-style":"solid",width:"308px",height:"82px"}))})}};$('.js-wkis-modal-open[data-modal="forgot-password"]').unbind("click.initializeDialog").bind("click.initializeDialog",function(){$("[for='forgot'][rule='captcha']",t.$container).hide()});this.$container=$(n);this.email=Helpers.KnockoutHelper.GetObservableByType("email",this.$container);this.errors=ko.validation.group(this,{deep:!0})}return n}();n.ForgotPasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(t){t===void 0&&(t=0);this.TotalItemCount=ko.observable(0);this.TotalItemCount(t);n.Counter=this}return n}();n.CartItemCounterViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.rememberMe=ko.observable(!0);this.inProgress=ko.observable(!1);this.login=function(n){if(!t.inProgress()){if(t.errors().length>0){t.errors.showAllMessages(!0);return}var i=$(n).find("[type='submit']").attr("href"),r=function(n){var r;$("[for='register']",t.$container).hide();$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});t.rememberMe()&&(r=new Date,r.setTime(r.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,t.email(),{path:"/",expires:r}));var u=!0,f=function(n){var t,r,f,e,o;n?(t=n.Id,r=$.cookie(Constants.Global.BasketCookieKey),u=!1,f=function(){$.cookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey,Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey,{path:"/"});location.href=i},$.cookie(Constants.Global.BasketCookieKey,t,{path:"/"}),t!==r?(e=Constants.Global.ODataOperation("AppendBasketOrderLines"),o=JSON.stringify({request:{BasketId:t,FromBasketId:r,"odata.type":e}}),Services.UserServices.AppendBasket(o,!0).always(f)):f()):$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},e=function(){$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},o=function(){u&&(location.href=i)};Services.UserServices.GetCurrentBasket(!1).done(f).fail(e).always(o)},u=function(){$("[for='register']",t.$container).show();Helpers.HtmlHelper.HideGlobalLoaderElement()},f=Constants.Global.ODataOperation("Auth"),e=JSON.stringify({request:{Email:t.email(),Password:t.password(),"odata.type":f}});t.inProgress(!0);Services.UserServices.Authentification(e,!0,!0).done(r).fail(u).always(function(){return t.inProgress(!1)})}};this.loginPopup=function(n,i){var r;if(i.preventDefault(),t.inProgress())return!1;if(r=$(i.currentTarget),t.errors().length>0)return t.errors.showAllMessages(!0),!1;var u=function(n){var i,u,f;$("[for='register']",t.$container).hide();$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});t.rememberMe()&&(i=new Date,i.setTime(i.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,t.email(),{path:"/",expires:i}));u=function(n){var t,i,r,u;n?(t=n.Id,i=$.cookie(Constants.Global.BasketCookieKey),i&&(r=Constants.Global.ODataOperation("AppendBasketOrderLines"),u=JSON.stringify({requset:{BasketId:t,FromBasketId:i,"odata.type":r}}),Services.UserServices.AppendBasket(u,!0)),$.cookie(Constants.Global.BasketCookieKey,t,{path:"/"})):$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})};f=function(){$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})};Services.UserServices.GetCurrentBasket(!0).done(u).fail(f);$(".wkis-terms-modal-info-email","[role='dialog'][data-modal='terms-conditions']").text(t.email());Services.UserServices.ShowMyAccHeader();r.siblings('a.js-wkis-modal-open[data-modal="terms-conditions"]')[0].click()},f=function(){$("[for='register']",t.$container).show()},e=Constants.Global.ODataOperation("Auth"),o=JSON.stringify({request:{Email:t.email(),Password:t.password(),"odata.type":e}});t.inProgress(!0);Services.UserServices.Authentification(o,!0,!0).done(u).fail(f).always(function(){Helpers.HtmlHelper.HideGlobalLoaderElement();t.inProgress(!1)})};this.verifyEmail=function(n,i){var r,u,f;if(i?(i.preventDefault(),r=$(i.currentTarget)):r=$("[name='Email']",n.$container),!n.email.isValid()){$("[for='email'][rule='exist']",n.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");return}u=Constants.Global.ODataOperation("EmailExists");f=JSON.stringify({request:{Email:r.val()?r.val():t.email(),"odata.type":u}});$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){n.value==!0?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).hide()):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))}})};this.verifyPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);t.password.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};this.$container=$(n);this.email=Helpers.KnockoutHelper.GetObservableByType("email",this.$container);this.password=Helpers.KnockoutHelper.GetObservableByType("password",this.$container);this.errors=ko.validation.group(this,{deep:!0});this.odataElement=Constants.Global.ODataElement;$.cookie(Constants.Global.RememberMeCookieKey)&&(this.email($.cookie(Constants.Global.RememberMeCookieKey)),this.verifyEmail(this))}return n}();n.LoginUserViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(t){var i=this,r;if(this.Orders=ko.observableArray(),this.NoOrdersToDisplay=ko.observable(!1),this.OrderViewModel=ko.observable(),this.loadOrders=function(n){var t=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetHistoryOrder"),LastDays:i.Period().LastDays,Year:i.Period().Year,IncludeYears:n}});$.ajax("/Ecommerce.svc/OrderAdministration_GetHistoryOrder/",{method:"POST",data:t,contentType:Constants.ContentType.OsaContentType,success:function(t){var r,u,f;if(n&&t.Years)for(r=0,u=t.Years;r<u.length;r++)f=u[r],i.AvailablePeriods.push({Name:f.toString(),Year:f});i.Orders(t.Order);i.NoOrdersToDisplay(t.Order&&t.Order.length===0)}})},this.periodChanged=function(){i.loadOrders(!1)},this.loadOrder=function(t){$.ajax("/Ecommerce.svc/Orders('"+t+"')?$expand=Order_orderLines/Product",{method:"GET",success:function(t){var r=new Entities.OrderModels.OrderModel,u;$.extend(r,t);u=new n.OrderViewModel(r,i.viewModelContainer);i.OrderViewModel(u);Helpers.HtmlHelper.ShowHelpInfo();i.$container.addClass("loaded-history-model")}})},this.loadOrderClick=function(n){return i.loadOrder(n.Id),!1},this.clearOrder=function(n,t){i.OrderViewModel(null);Helpers.HtmlHelper.HideHelpInfo();i.$container.removeClass("loaded-history-model");t.preventDefault()},this.viewModelContainer=t,this.$container=$(t),this.AvailablePeriods=ko.observableArray([{Name:$("#accountOrderHistoryLast30DaysContainer").text(),LastDays:30},{Name:$("#accountOrderHistoryLast60DaysContainer").text(),LastDays:60}]),this.Period=ko.observable(this.AvailablePeriods()[0]),$("#accountOrderHistoryLink").parent().hasClass("active"))this.loadOrders(!0);else{r=!1;$('[href="#accountOrderHistoryContainer"]').on("click",function(){r||(i.loadOrders(!0),r=!0)})}}return t}();n.OrderHistoryViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t;(function(n){var i=function(i){function r(u,f,e){var o=i.call(this,u,f,e)||this,s,h,c;return o.Password=Helpers.KnockoutHelper.GetObservableByType("password",o.$container),o.ShippingMethods=ko.observableArray(),o.PaymentMethods=ko.observableArray(),o.Promotions=ko.observableArray(),o.BillingAddress=ko.observable(),o.ShippingAddress=ko.observable(),o.AcceptAgreement=ko.observable(!1),o.VatNumber=ko.observable(""),o.IsValidVatNumber=ko.observable(!0),o.NameOnCC=ko.observable(),o.ExpirationDateCC=ko.observable(),o.IsValidCardNumber=ko.observable(!0),o.appliedShippingAddress=ko.observable(!1),o.appliedBillingAddress=ko.observable(!1),o.isValidPaymentInfo=function(){return o.PaymentMethod()!=="Credit Card"?!0:(Spreedly.validate(),o.IsValidCardNumber()&&!!o.ExpirationDateCC()&&!!o.NameOnCC())},o.initializeShippingAddress=function(t,i){var r;return t?(r=new n.AddressViewModel($('[data-address="shipping"]',i),t,!0),o.appliedShippingAddress(!0)):r=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.DefualtShippingAddress()?n.AddressBookModel.AddressBook.DefualtShippingAddress():new n.AddressViewModel($('[data-address="shipping"]',i),undefined,!0),r},o.initializeBillingAddress=function(t,i,r){var u;return t?(u=new n.AddressViewModel($('[data-address="billing"]',r),t,!0),o.appliedBillingAddress(!0)):u=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.DefualtBillingAddress()?n.AddressBookModel.AddressBook.DefualtBillingAddress():i?new n.AddressViewModel($('[data-address="billing"]',r),undefined,!0):o.ShippingAddress(),u},o.bindValidation=function(){o.NameOnCC.extend({required:{message:Helpers.KnockoutHelper.validationMessage("NameOnCC","required",o.$container)}});o.CardNumber.extend({required:{message:Helpers.KnockoutHelper.validationMessage("CardNumber","required",o.$container)}});o.ExpirationDateCC.extend({required:{message:Helpers.KnockoutHelper.validationMessage("ExpirationDateCC","required",o.$container)}});o.Password.rules.remove(function(n){return n.rule=="required"});o.registrationDataErrors=ko.validation.group([o.ShippingAddress,o.BillingAddress,o.Password]);o.paymentDataErrors=ko.validation.group([o.BillingAddress,o.ExpirationDateCC,o.NameOnCC])},o.verifyPassword=function(n,t){t.preventDefault();var i=$(t.currentTarget);o.Password.isValid()?(i.addClass("ko-valid"),i.parent().addClass("ko-valid")):(i.removeClass("ko-valid"),i.parent().removeClass("ko-valid"))},o.applyPromo=function(i,r){var f=$(r.currentTarget).siblings("div.wkis-field-item").find("input").first(),e=$(r.currentTarget).parent().siblings(".ko-validation-custom-message"),u=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(u);$.ajax("/api/commerce/basket/"+o.Id+"/applyPromo/",{type:"POST",data:JSON.stringify(o.PromoCode()),contentType:"application/json",success:function(i){var r,f;i.IsApplied&&i.IsApplied===!0?(r={},i.Order||(i.Order=Services.UserServices.GetUserBasketViewModel(!1)),$.extend(r,i.Order),o.PriceInfo(new n.OrderPriceInfoModel(r.PriceInfo)),f=[],r.Promotions.forEach(function(n){var i=new t(n);f.push(i)}),o.Promotions(f)):u.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"Error",$("div[for='promo'][rule='invalid']").first().text()));o.PromoCode("");o.getUpdatedOrderData()}})},o.removePromo=function(){var n=o.Promotions()[0].PromotionCode();$.ajax("/Ecommerce.svc/BasketAdministration_DeletePromo",{type:"POST",headers:Constants.JQuery.HeaderReturnContent,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("DeletePromo"),PromoCode:n,BasketId:o.Id}}),contentType:Constants.ContentType.OsaContentType,success:function(){o.getUpdatedOrderData()}})},o.accept=function(){if(o.AcceptAgreement(!o.AcceptAgreement()),o.AcceptAgreement()){var n=$("div.ko-validation-custom-message[for='placeorder'][rule='acceptAgreement']");n&&n.hide()}},o.updateOrder=function(n,t,i){t===void 0&&(t=!0);var u=ko.mapping.toJS(n),r={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(r,u);$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(r),contentType:Constants.ContentType.OsaContentType,headers:Constants.JQuery.HeaderReturnContent,beforeSend:function(){i?i():Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(n){n||(n=Services.UserServices.GetUserBasketViewModel(!1));o._updateOrderInfo(n,t)},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement();Helpers.HtmlHelper.HideMinilLoaderElement()}})},o.updateShippingMethod=function(n,t){var i=$(t.currentTarget),r=function(){Helpers.HtmlHelper.ShowMiniLoaderElement(i,i.width()+40)};o.updateOrder({ShippingMethod:n.ShippingMethod()},!1,r)},o.updatePaymentMethod=function(n){o.updateOrder({PaymentMethod:n.PaymentMethod()},!1)},o.getUpdatedOrderData=function(){var n=Services.UserServices.GetUserBasketViewModel(!1,!0);o._updateOrderInfo(n,!0,!0)},o.getCreditCardType=function(n){var t="unknown";return/^5[1-5]/.test(n)?t="002":/^4/.test(n)?t="001":/^3[47]/.test(n)&&(t="003"),t},o.setShippingAddress=function(n,t){(t===void 0&&(t=!0),n.isValid(t,o.IsGuestOrder()))&&o.updateShippingAddress(n)},o.updateShippingAddress=function(n){var t,r=o.SameAddresses(),u=Constants.KnockooutMapping.AddressModelOsaMapping,i,f;r?(i=new Entities.AddressBookModels.AddressBookModel,f=ko.mapping.toJS(n,u),$.extend(i,f,{"odata.type":Constants.Global.ODataOperation("Address")}),t={ShippingAddress:n?i:null,BillingAddress:n?i:null}):($.extend(n,{"odata.type":Constants.Global.ODataOperation("Address")}),t={ShippingAddress:n?ko.mapping.toJS(n,u):null});$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:ko.mapping.toJSON(t),contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},headers:Constants.JQuery.HeaderReturnContent,success:function(i){t.ShippingAddress&&o.showInfoMessageForPoBoxAddress(t.ShippingAddress);o._updateOrderInfo(i);o.ShippingAddress(n);r&&(o.BillingAddress(o.ShippingAddress()),o.appliedBillingAddress(!0),o.checkCurrencyDoesntMatchToBillingAddressCurrency());o.appliedShippingAddress(!0)},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.setBillingAddress=function(n,t){(t===void 0&&(t=!0),n.isValid(t))&&o.updateBillingAddress(n)},o.updateBillingAddress=function(n){var i=Constants.KnockooutMapping.AddressModelOsaMapping,t;$.extend(n,{"odata.type":Constants.Global.ODataOperation("Address")});t={BillingAddress:n?ko.mapping.toJS(n,i):null};$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},data:ko.mapping.toJSON(t),contentType:Constants.ContentType.OsaContentType,headers:Constants.JQuery.HeaderReturnContent,success:function(){o.BillingAddress(n);o.appliedBillingAddress(!0);o.checkCurrencyDoesntMatchToBillingAddressCurrency();o.getPaymentMethods()},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.applyAddresses=function(n,t,i){if(i===void 0&&(i=!1),n&&t){if(i&&n.isValid(!0,o.IsGuestOrder())&&o.addressVerification(n))return;(o.HasOnlyDigitalProducts()||n.isValid(!0,o.IsGuestOrder()))&&t.isValid(!0,!1)&&o.updateAddresses(n,t)}},o.updateAddresses=function(n,t){var e=Constants.KnockooutMapping.AddressModelOsaMapping,u=n&&n.isValid(!1)?o.mappAddress(n):null,f=t&&t.isValid(!1)?o.mappAddress(t):null,i={},r;u&&($.extend(i,{ShippingAddress:u}),i.ShippingAddress["odata.type"]=Constants.Global.ODataOperation("Address"));f&&($.extend(i,{BillingAddress:f}),i.BillingAddress["odata.type"]=Constants.Global.ODataOperation("Address"));r={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(r,ko.mapping.toJS(i,e));Helpers.HtmlHelper.ShowGlobalLoaderElement();$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(r),headers:Constants.JQuery.HeaderReturnContent,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(i){i||o.getUpdatedOrderData();r.ShippingAddress&&o.showInfoMessageForPoBoxAddress(r.ShippingAddress);o._updateOrderInfo(i);o.ShippingAddress(n);o.BillingAddress(t);o.appliedShippingAddress(!0);o.appliedBillingAddress(!0);var u=$("div.ko-validation-custom-message[for='address'][rule='shouldBeApplied']");u&&u.hide()},complete:function(){Helpers.HtmlHelper.HideGlobalLoaderElement()}})},o.showInfoMessageForPoBoxAddress=function(n){if(n.AddressLine&&n.AddressLine.search(Constants.Commerce.POBoxAddressLineRegexp)>-1||n.AddressLine2&&n.AddressLine2.search(Constants.Commerce.POBoxAddressLineRegexp)>-1){var t=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(t);t.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Info,"",$("ko-error-text[for='address'][rule='POBox']").first().text()))}},o.mappAddress=function(n){var t={};return $.extend(t,{AddressLine:n.AddressLine()},{AddressLine2:n.AddressLine2()},{Telephone:n.Telephone()},{ZipCode:n.ZipCode()},{CountryName:n.CountryName()},{CountryIso:n.CountryIso()},{CompanyName:n.CompanyName()},{City:n.City()},{FirstName:n.FirstName()},{LastName:n.LastName()},{StateIso:n.StateIso()},{StateName:n.StateName()},{Region:n.Region()},{Email:n.Email()}),t},o.checkCurrencyDoesntMatchToBillingAddressCurrency=function(){var t=o.BillingAddress(),n;t&&(n=t.CountryName(),n&&Services.AddressServices.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency(n))},o.applyAddress=function(t){var r=t==o.ShippingAddress(),i;t.isValid(!0,r)&&(i=n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.SelectedShippingAddress()&&n.AddressBookModel.AddressBook.SelectedShippingAddress()==t,t.IsBilling()||i||!t.CountryIso()||t.CountryIso().toLowerCase()!=Constants.CountriesIso.US.toLowerCase()||!o.addressVerification(t))&&o.setShippingAddress(t)},o.addressVerification=function(t){var i,r;if(t.CountryIso()&&t.CountryIso().toLowerCase()===Constants.CountriesIso.US.toLowerCase()&&(i=Services.UserServices.GetSuggestedAddress(ko.mapping.toJS(t,Constants.KnockooutMapping.IgnoreJQueryMapping),!1),i)){r=void 0;r=i.addressModel?new n.AddressViewModel(t.$container,i.addressModel,!0):new n.AddressViewModel(t.$container,null,!1,i.message);var u=$('[role="dialog"][data-modal="address-verification-apply"]'),f=$(".current-address",u)[0],e=$(".suggested-address",u)[0];return ko.cleanNode(f),ko.cleanNode(e),ko.applyBindings(t,f),ko.applyBindings(r,e),Helpers.HtmlHelper.OpenModalDialog(u.attr("data-modal")),!0}return!1},o.getShippingMethods=function(){$.post({url:"/Ecommerce.svc/BasketAdministration_GetShippingMethods/",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetShippingMethods"),BasketId:o.Id}}),async:!1,success:function(n){o.setShippingMethods(n.value)}})},o.setShippingMethods=function(n){if(n.length){var t=[],i=o.ShippingMethod(),r=o.sortShippingMethods(n);r.forEach(function(n){t.push(n.MethodName)});o.ShippingMethods(t);o.ShippingMethod(i?i:r[0].MethodName)}},o.getPaymentMethods=function(){$.post({url:"/Ecommerce.svc/BasketAdministration_GetPaymentMethods/",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("GetPaymentMethods"),BasketId:o.Id}}),success:function(n){o.setPaymentMethods(n.value)}})},o.setPaymentMethods=function(n){var t=o.PaymentMethod(),i=[];n.forEach(function(n){i.push(n.MethodName)});o.PaymentMethods(i);t&&o.PaymentMethods().indexOf(o.PaymentMethod())!=-1?o.PaymentMethod(t):o.PaymentMethod(o.PaymentMethods()[0])},o.sameAddress=function(t,i){var r=$(i.currentTarget)[0];r.checked?o.BillingAddress(o.ShippingAddress()):o.BillingAddress(new n.AddressViewModel($('[data-address="billing"]',o.$container),null,!0))},o.createToken=function(n,t){var r,i;if(t&&t.preventDefault(),o.isValidOrderData())try{if(o.PaymentMethod()!=="Proforma"){if(o.paymentDataErrors().length>0){o.paymentDataErrors.showAllMessages(!0);return}r=o.ExpirationDateCC().split("/");r.length===2&&(i={},i.full_name=o.NameOnCC(),i.month=r[0].trim(),i.year="20"+r[1].trim(),i.email=o.BillingAddress().Email(),i.address1=o.BillingAddress().AddressLine(),i.address2=o.BillingAddress().AddressLine2(),i.city=o.BillingAddress().City(),i.state=o.BillingAddress().StateName(),i.zip=o.BillingAddress().ZipCode(),i.country=o.BillingAddress().CountryName(),i.phone_number=o.BillingAddress().Telephone(),i.company=o.BillingAddress().CompanyName(),Helpers.HtmlHelper.ShowGlobalLoaderElement(),Spreedly.tokenizeCreditCard(i))}else o.submitOrder()}catch(u){Helpers.HtmlHelper.HideGlobalLoaderElement()}},o.submitOrder=function(t){var r,i;if(t===void 0&&(t=""),!o.isValidOrderData()){Helpers.HtmlHelper.HideGlobalLoaderElement();return}if(r=function(){var n=["$container","AddressBook"];o.HasOnlyDigitalProducts()&&n.push("ShippingAddress");n.push("VatNumber","AcceptAgreement","Order","IsGuestOrder","Password","ShippingMethods","PaymentMethods","Promotions","VatNumber","NameOnCC","ExpirationDateCC","IsValidVatNumber","CardNumber","CardType","SameAddresses","registrationDataErrors","paymentDataErrors","enableSubmit","isSameAddress","appliedShippingAddress","appliedBillingAddress","Discounted","HasOnlyDigitalProducts","PriceInfo","RecommendedProducts","BasketLines","RecommendedProducts","ShippingAddress","BillingAddress","TotalItemCount","calculatedSubTotalPrice","formatedCardNumber","IsValidCardNumber","Email","cartSummary");var r={ignore:n},u=ko.mapping.toJS(o,r),i={"odata.type":Constants.Global.ODataOperation("Basket")};$.extend(i,u);$.ajax("/Ecommerce.svc/Baskets('"+o.Id+"')",{type:"PUT",data:JSON.stringify(i),contentType:Constants.ContentType.OsaContentType,success:function(){var n={Id:o.Id,BillingAddress:null,ShippingAddress:null,OrderCurrency:null,OrderDate:o.OrderDate(),OrderStatus:o.OrderStatus(),PaymentMethod:o.PaymentMethod(),PriceInfo:null,PromoCode:null,Promotion:[],ShippingMethod:o.ShippingMethod()},i;$.extend(n,{"odata.type":Constants.Global.ODataOperation("Order"),BasketId:o.Id,VatNumber:o.VatNumber(),CreditCardToken:t?t:null,PaymentInfo:null},{"Promotion@odata.type":"Collection(ecommerce.Promotion)"});i=JSON.stringify(n);$.ajax("/Ecommerce.svc/Orders",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:i,beforeSend:function(){Helpers.HtmlHelper.ShowGlobalLoaderElement()},success:function(n){!$.cookie(Constants.Global.UserTokenCookieKey)||o.saveAppliedAddresses();$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"});o.sendOrderSubmitTags(n);location.href=Helpers.UrlHelper.SetUrlParam($("#btnPlaceOrder").attr("href"),"orderNumber",n.Id)},error:function(n){var t=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(t);n.status==400?t.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",$("ko-error-text[for='placeorder'][rule='400']").first().text())):n.status==500&&t.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",$("ko-error-text[for='placeorder'][rule='500']").first().text()));Helpers.HtmlHelper.HideGlobalLoaderElement()}})}})},o.IsGuestOrder()&&o.Password()&&o.ShippingAddress().Email.isValid()&&o.ShippingAddress().verifiedEmail&&o.Password.isValid()){if(o.registrationDataErrors().length>0){o.registrationDataErrors.showAllMessages(!0);return}i=new n.RegisterUserViewModel(null);i.firstName(o.ShippingAddress().FirstName());i.lastName(o.ShippingAddress().LastName());i.email(o.ShippingAddress().Email());i.password(o.Password());i.registrating(null,r)}else r()},o.isValidOrderData=function(n){var t,i,r;return n===void 0&&(n=!0),t=!0,o.isValidPaymentInfo()||(t=!1),o.PaymentMethod()=="Credit Card"&&o.paymentDataErrors().length>0&&(o.paymentDataErrors.showAllMessages(!0),t=!1),o.HasOnlyDigitalProducts()||(o.ShippingAddress().isValid(n,o.IsGuestOrder())||(t=!1),i=$("div.ko-validation-custom-message[for='address'][rule='shouldBeApplied']"),o.appliedShippingAddress()?i.length&&i.hide():(i.length&&i.show(),t=!1)),o.BillingAddress().isValid(n,!1)||(t=!1),o.IsValidVatNumber()||(t=!1),r=$("div.ko-validation-custom-message[for='placeorder'][rule='acceptAgreement']"),o.AcceptAgreement()?r.hide():(r.show(),t=!1),t},o.saveAppliedAddresses=function(){n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.Addresses().length||(o.ShippingAddress().isValid(!1)&&(o.ShippingAddress().IsBilling(!1),o.ShippingAddress().IsDefaultShipping(!0),o.ShippingAddress().SaveAsDefault=!0,o.ShippingAddress().saveAddress(null,null,null,!1)),o.BillingAddress().isValid(!1)&&(o.BillingAddress().IsBilling(!0),o.BillingAddress().IsDefaultBilling(!0),o.BillingAddress().SaveAsDefault=!0,o.BillingAddress().saveAddress()))},o._updateOrderInfo=function(i,r,u){var f,e;r===void 0&&(r=!0);u===void 0&&(u=!1);f=i;o.Promotions.removeAll();e=[];u&&f.Basket_orderLines&&o.setBasketLines(f.Basket_orderLines);f.Promotions&&(f.Promotion=f.Promotions);f.Promotion&&f.Promotion.forEach(function(n){var i=new t(n);e.push(i)});o.Promotions(e);o.PriceInfo(new n.OrderPriceInfoModel(f.PriceInfo));o.checkTaxError();r&&(o.ShippingMethod(f.ShippingMethod),o.getShippingMethods(),o.getPaymentMethods())},o.checkTaxError=function(){if(o.PriceInfo()&&o.PriceInfo().TaxCalculationError()){var n=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(n);n.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Warning,"",$("ko-error-text[for='taxes'][rule='calculationError']").first().text()))}},o.loadSpreedlyFrame=function(){var t=$("#spreedly-env-key").attr("key"),n,i;if(t){n=".ko-validation-custom-message[for='CardNumber'][rule='required']";i="color: rgb(102, 102, 102); font-size: 16px; font-family: 'Fira Sans', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;";Spreedly.init(t,{numberEl:"spreedly-number",cvvEl:"spreedly-cvv"});Spreedly.on("ready",function(){Spreedly.setPlaceholder("number","XXXX XXXX XXXX XXXX");Spreedly.setFieldType("number","text");Spreedly.setNumberFormat("prettyFormat");Spreedly.setStyle("number",i)});Spreedly.on("paymentMethod",function(t,i){i.card_type!=="discover"?o.submitOrder(t):(o.showSpreedlyValidationError(),$("#spreedly-number").addClass("ko-error"),$(n).show())});Spreedly.on("validation",function(t){t.validNumber?($("#spreedly-number").removeClass("ko-error"),$(n).hide(),o.IsValidCardNumber(!0)):($("#spreedly-number").addClass("ko-error"),$(n).show(),o.IsValidCardNumber(!1))});Spreedly.on("errors",function(t){o.showSpreedlyValidationError();t&&t[0].attribute=="number"?($("#spreedly-number").addClass("ko-error"),$(n).show()):($("#spreedly-number").removeClass("ko-error"),$(n).hide())})}},o.showSpreedlyValidationError=function(){var n=$("div.wkis-place-order-content-left").first();Helpers.HtmlHelper.RemoveAlertMessages(n);n.prepend(Helpers.HtmlHelper.GetAlertMessageElement(Constants.AlertMessageTypes.Failed,"",$("ko-error-text[for='placeorder'][rule='400']").first().text()));Helpers.HtmlHelper.HideGlobalLoaderElement()},o.canSendVatNumber=function(){for(var i,n=0,t=o.PaymentMethods();n<t.length;n++)if(i=t[n],i==="Proforma")return!0;return!1},o.isCreditCardSelected=function(){var n=o.PaymentMethod();return n==="Credit Card"?!0:!1},o.verifyVatNumber=function(n,t){var i=$(t.currentTarget),r=o.VatNumber(),u=function(){$("[for='vatNumber'][rule='valid']",o.$container).hide();i.removeClass("ko-valid");i.parent().removeClass("ko-valid");i.removeClass("ko-error");o.IsValidVatNumber(!0)},f=function(){$("[for='vatNumber'][rule='valid']",o.$container).hide();i.addClass("ko-valid");i.parent().addClass("ko-valid");i.removeClass("ko-error");o.IsValidVatNumber(!0)},e=function(){$("[for='vatNumber'][rule='valid']",o.$container).show();i.removeClass("ko-valid");i.parent().removeClass("ko-valid");i.addClass("ko-error");o.IsValidVatNumber(!1)};if(!r){u();return}$.ajax("/Ecommerce.svc/BasketAdministration_ValidateVatNumber",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidateVatNumber"),VatNumber:r}}),success:function(n){n.value===!0?f():e()},error:function(){u()}})},o.sortShippingMethods=function(n){return n.sort(function(n,t){return n.DefaultPriotity>t.DefaultPriotity?-1:1})},o.OrderDate=ko.observable(u.OrderDate),o.ShippingMethod=ko.observable(u.ShippingMethod),o.PaymentMethod=ko.observable(u.PaymentMethod),o.PromoCode=ko.observable(),o.CardNumber=u.PaymentInfo&&u.PaymentInfo.CardNumber?ko.observable(u.PaymentInfo.CardNumber):ko.observable(""),o.CardType=u.PaymentInfo&&u.PaymentInfo.CardType?ko.observable(u.PaymentInfo.CardType.toUpperCase()):ko.observable(""),o.bindValidation(),o.formatedCardNumber=ko.computed(function(){return o.CardNumber()?o.CardNumber().replace(/X/g,"*").replace(/-/g," "):""}),o.cartSummary=ko.computed(function(){if(window.paymentItemsInYourCartLabel){var n=o.BasketLines().length;return Helpers.String.Format(window.paymentItemsInYourCartLabel,n,n>1?"s":"")}return""}),o.enableSubmit=ko.computed(function(){return o.AcceptAgreement()&&(o.appliedShippingAddress()||o.HasOnlyDigitalProducts())&&o.ShippingMethod()&&o.appliedBillingAddress()&&o.IsValidVatNumber()&&o.isValidPaymentInfo()}),o.IsGuestOrder=ko.computed(function(){return $.cookie(Constants.Global.UserTokenCookieKey)?!1:!0}),u.Promotions&&(u.Promotion=u.Promotions),u.Promotion&&(s=[],u.Promotion.forEach(function(n){var i=new t(n);s.push(i)}),o.Promotions=ko.observableArray(s)),o.AddressBook=ko.observable(e),o.SameAddresses=ko.computed(function(){return!(n.AddressBookModel.AddressBook&&n.AddressBookModel.AddressBook.Addresses().length>0)&&!o.HasOnlyDigitalProducts()&&(!o.BillingAddress()||o.ShippingAddress()&&o.BillingAddress().FirstName()==o.ShippingAddress().FirstName()&&o.BillingAddress().LastName()==o.ShippingAddress().LastName()&&o.BillingAddress().CountryIso()==o.ShippingAddress().CountryIso()&&o.BillingAddress().CountryName()==o.ShippingAddress().CountryName()&&o.BillingAddress().StateIso()==o.ShippingAddress().StateIso()&&o.BillingAddress().StateName()==o.ShippingAddress().StateName()&&o.BillingAddress().AddressLine()==o.ShippingAddress().AddressLine()&&o.BillingAddress().AddressLine2()==o.ShippingAddress().AddressLine2()&&o.BillingAddress().City()==o.ShippingAddress().City()&&o.BillingAddress().Region()==o.ShippingAddress().Region()&&o.BillingAddress().CompanyName()==o.ShippingAddress().CompanyName()&&o.BillingAddress().ZipCode()==o.ShippingAddress().ZipCode()&&o.BillingAddress().Telephone()==o.ShippingAddress().Telephone())}),o.ShippingAddress(o.initializeShippingAddress(u.ShippingAddress,f)),o.BillingAddress(o.initializeBillingAddress(u.BillingAddress,u.ShippingAddress,f)),o.OrderStatus()==="Basket"&&(h=!u.ShippingAddress&&o.ShippingAddress().isValid(!1)?o.ShippingAddress():null,c=!u.BillingAddress&&o.BillingAddress().isValid(!1)?o.BillingAddress():null,h||c?o.updateAddresses(h,c):(o.getPaymentMethods(),o.ShippingMethods().length||o.getShippingMethods()),o.loadSpreedlyFrame(),o.checkTaxError()),o.IsGuestOrder()||o.AddressBook()&&o.AddressBook().Addresses().length!=0||$.get("/Ecommerce.svc/Users",function(n){if(n&&n.value&&!o.ShippingAddress().FirstName()&&!o.ShippingAddress().LastName()){var t=n.value[0];o.ShippingAddress().FirstName(t.FirstName);o.ShippingAddress().LastName(t.LastName);o.SameAddresses()&&(o.BillingAddress().FirstName(t.FirstName),o.BillingAddress().LastName(t.LastName))}}),$.cookie(Constants.Global.UserTokenCookieKey)&&Services.UserServices.GetUserInfo().done(function(n){var t=n.value[0];t&&t.Email&&(o.Email=t.Email)}),r.Order=o,o}return __extends(r,i),r.prototype.sendOrderSubmitTags=function(n){if(!n){var t="undefined email";this.Email?t=this.Email:n.ShippingAddress&&n.ShippingAddress.Email&&(t=n.ShippingAddress.Email);window.dataLayer&&(window.dataLayer.push({event:"orderSubmit",eventCategory:"Order",order:{id:n.Id,currency:n.PriceInfo.CurrencySymbol,totalPrice:n.PriceInfo.OrderTotal,shippingTotalPrice:n.PriceInfo.Shipping,discount:n.PriceInfo.Discount,taxPrice:n.PriceInfo.Tax,email:t,city:n.BillingAddress.City,state:n.BillingAddress.StateName,country:n.BillingAddress.CountryIso,zipCode:n.BillingAddress.ZipCode,promotionCode:n.Promotion&&n.Promotion.length?n.Promotion[0].PromotionCode:""}}),this.sendSubmitedProducts(ko.mapping.toJS(this.BasketLines),n.Id,t))}},r.prototype.sendSubmitedProducts=function(n,t,i){window.dataLayer&&n&&n.forEach(function(n){window.dataLayer.push({event:"orderLinesSubmit",eventCategory:"Order",orderLine:{id:n.Id,productName:n.ProductInfo.ProductName,price:n.PriceInfo.ActualItemPrice,email:i,quantity:n.Quantity,orderId:t,format:n.ProductInfo.FormatName,orderTotal:n.PriceInfo.ActualTotalPrice}})})},r}(n.BasketViewModel),t;n.OrderViewModel=i;t=function(){function t(t){var r=this;this.PromotionCode=ko.observable();this.PromotionId=ko.observable();this.PromotionTitle=ko.observable();this.PromotionDescription=ko.observable();this.Name=ko.observable();this.TotalDiscount=ko.observable(0);this.IsFreeShipping=ko.observable();this.displayPromoDetails=function(){var t=document.createElement("div"),n;t.innerHTML=r.PromotionDescription();n=$("#promo-description-popup-text")[0];n.innerHTML="";n.appendChild(t);$("#promo-title-popup-text").text(r.PromotionTitle())};t&&(this.PromotionCode=ko.observable(t.PromotionCode),this.PromotionTitle=ko.observable(t.PromotionTitle),this.PromotionDescription=ko.observable(t.PromotionDescription),this.PromotionId=ko.observable(t.PromotionId),this.Name=ko.observable(t.Name),this.IsFreeShipping=ko.observable(t.IsFreeShipping),this.TotalDiscount=ko.observable(t.TotalDiscount),this.formatedTotalDiscount=ko.computed(function(){return i.Order?"-("+i.Order.PriceInfo().CurrencySymbol()+Number(r.TotalDiscount()).toFixed(i.Order.PriceInfo().Precision())+")":n.BasketViewModel.Basket?"-("+n.BasketViewModel.Basket.PriceInfo().CurrencySymbol()+Number(r.TotalDiscount()).toFixed(n.BasketViewModel.Basket.PriceInfo().Precision())+")":void 0}),this.formatedDescription=ko.computed(function(){return r.PromotionCode()?r.PromotionCode()+" - "+r.Name():r.Name()}))}return t}();n.PromotionModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function t(){var t=this;this.RecommendedProducts=ko.observableArray();this.loadRecommendedProducts=function(i,r){i.length>0?(r||(r=4),$.ajax("/api/commerce/recommendation/getbyoffernumbers/"+i.join(",")+"/"+r,{type:"GET",success:function(i){for(var f=[],e,r=0,u=i;r<u.length;r++)e=u[r],f.push(new n.ProductInfo(e));t.RecommendedProducts(f)}})):t.RecommendedProducts([])}}return t}();n.RecommendedProductsViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.viewModelContainer=n;this.rememberMe=ko.observable(!0);this.verifiedEmail=!0;this.inProgress=ko.observable(!1);this.register=function(n,i){if(i.preventDefault(),!t.inProgress()){if(n.errors().length>0||!t.verifiedEmail){n.errors.showAllMessages(!0);n.verifiedEmail||n.errors().length>0?$("[for='email'][rule='exist']",n.$container).hide():$("[for='email'][rule='exist']",n.$container).show();return}t.checkCaptcha(function(){return n.registrating(i)})}};this.checkCaptcha=function(n){var i=!1,r=$(".register-recaptcha .g-recaptcha-response").val(),u=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidateCaptcha"),Captcha:r}});t.inProgress(!0);$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ValidateCaptcha",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:u,success:function(n){i=n.value},error:function(){i=!1}})).done(function(){i?($("[for='captcha'][rule='required']",t.$container).hide(),$(".register-recaptcha").css({"border-color":"","border-style":"",width:"",height:""}),n()):(t.inProgress(!1),$("[for='captcha'][rule='required']",t.$container).show(),$(".register-recaptcha").css({"border-color":"#f00","border-style":"solid",width:"308px",height:"82px"}))})};this.registerPopup=function(n,i){var r,u;if(i.preventDefault(),!t.inProgress()){if(r=$(i.currentTarget),n.errors().length>0||!n.verifiedEmail){n.errors.showAllMessages(!0);n.verifiedEmail||n.errors().length>0?$("[for='email'][rule='exist']",n.$container).hide():$("[for='email'][rule='exist']",n.$container).show();return}u=function(){Services.UserServices.ShowMyAccHeader();$(".wkis-terms-modal-info-email","[role='dialog'][data-modal='terms-conditions']").text(n.email());r.siblings('a.js-wkis-modal-open[data-modal="terms-conditions"]')[0].click();Helpers.HtmlHelper.HideGlobalLoaderElement()};t.checkCaptcha(function(){return n.registrating(i,u)})}};this.registrating=function(n,i){var r=JSON.stringify({"odata.type":Constants.Global.ODataOperation("User"),FirstName:t.firstName(),LastName:t.lastName(),Email:t.email(),Password:t.password()}),u=function(r){var f,e,u;r.readyState==4&&(r.status==201?(t.sendRegistarionTag({firstName:t.firstName(),lastName:t.lastName(),email:t.email()}),f=function(t){$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(t),{path:"/"});var r=$.cookie(Constants.Global.BasketCookieKey),u=function(){i?i():location.href=$(n.currentTarget).attr("href")},f=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("AssignBasket"),BasketId:r}});Services.UserServices.AssignBasketToCurrentUser(f,!0).always(u)},e=JSON.stringify({request:{Email:t.email(),Password:t.password(),"odata.type":"ecommerce.Auth"}}),Services.UserServices.Authentification(e,!0).done(f),t.rememberMe()&&(u=new Date,u.setTime(u.getTime()+Constants.Global.RememberMeExpirationDays*864e5),$.cookie(Constants.Global.RememberMeCookieKey,t.email(),{path:"/",expires:u}))):Helpers.HtmlHelper.HideGlobalLoaderElement())};Services.UserServices.Register(r,!0,!0).always(function(n,i,r){t.inProgress(!1);u(r)})};this.verifyEmail=function(n,i){i.preventDefault();var r=$(i.currentTarget);if(!t.email.isValid()){$("[for='email'][rule='exist']",t.$container).hide();r.removeClass("ko-valid");r.parent().removeClass("ko-valid");return}$.ajax("/Ecommerce.svc/CustomerAdministration_EmailExists",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{Email:r.val(),"odata.type":Constants.Global.ODataOperation("EmailExists")}}),success:function(n){n.value===!1?(r.removeClass("ko-error"),r.parent().addClass("ko-valid"),r.addClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).hide(),t.verifiedEmail=!0):(r.addClass("ko-error"),r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"),$("[for='email'][rule='exist']",t.$container).show(),t.verifiedEmail=!1)}})};this.verifyPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);t.password.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};n&&(this.$container=$(n));this.firstName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("firstName","required",this.$container)}});this.lastName=ko.observable().extend({required:{message:Helpers.KnockoutHelper.validationMessage("lastName","required",this.$container)}});this.email=Helpers.KnockoutHelper.GetObservableByType("email",this.$container);this.password=Helpers.KnockoutHelper.GetObservableByType("password",this.$container);this.errors=ko.validation.group(this,{deep:!0});$(n).keyup(function(t){t.which==13&&($(t.currentTarget).blur(),$("[type='submit']",n).click())})}return n.prototype.sendRegistarionTag=function(n){window.dataLayer&&window.dataLayer.push({event:"registrationSuccess",eventCategory:"User",userInfo:{email:n.email,firstName:n.firstName,lastName:n.lastName}})},n}();n.RegisterUserViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n,t,i){var r=this;this.orderNumber=n;this.Email=ko.observable();this.isSendingEmail=ko.observable(!1);this.sendEmail=function(){if(r.emailErrors().length>0){r.emailErrors.showAllMessages(!0);return}if(!r.isSendingEmail()){r.isSendingEmail(!0);var n={request:{"odata.type":Constants.Global.ODataOperation("ResendEmailConfirmation"),Email:r.Email(),OrderNumber:r.orderNumber}};Services.OrderServices.ResendConfirmationEmail(n).done(function(){Helpers.HtmlHelper.OpenModalDialog("resend-confirmation-email-success")}).always(function(){r.isSendingEmail(!1)})}};this.emailInputKeyUp=function(n,t){t.keyCode===13&&r.sendEmail()};this.emailErrors=ko.validation.group([this.Email]);this.Email(t);this.Email.extend({email:{message:Helpers.KnockoutHelper.validationMessage("email","email",i)}}).extend({required:{message:Helpers.KnockoutHelper.validationMessage("email","required",i)}})}return n}();n.ResendEmailViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.viewModelContainer=n;this.resetToken=ko.observable();this.isValidToken=ko.observable();this.resetInProgress=ko.observable(!1);this.showResetPopup=function(){$("#btnResetPassword").click()};this.resetPassword=function(n,i){if(t.resetToken()!==""&&t.resetToken()!==null){if(t.errors().length>0){t.errors.showAllMessages(!0);return}var f=JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ResetPassword"),Token:t.resetToken(),NewPassword:t.password()}}),r=!1,u="";t.resetInProgress(!0);$.when($.ajax("/Ecommerce.svc/CustomerAdministration_ResetPassword",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:f,success:function(n){r=n.IsSuccessfullyReset;u=n.Email},error:function(){$("#btnResetPasswordFailed").click()}})).done(function(){r?$.ajax("/Ecommerce.svc/CustomerAdministration_Auth",{type:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("Auth"),Email:u,Password:t.password()}}),success:function(n){$.cookie(Constants.Global.UserTokenCookieKey,JSON.stringify(n),{path:"/"});var t=$(i.currentTarget).attr("href");location.href=t},error:function(){$("#btnResetPasswordFailed").click()}}):$("#btnResetPasswordFailed").click()})}};this.validateToken=function(){$.ajax("/Ecommerce.svc/CustomerAdministration_ValidatePasswordReset",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("ValidatePasswordReset"),Token:t.resetToken()}}),success:function(n){n.value==!0?t.showResetPopup():t.showInvalidTokenPopup()},error:function(){return!1}})};this.verifyPassword=function(n,i){var r,u;i.preventDefault();r=$(i.currentTarget);t.password.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"));u=$('input[name="ConfirmPassword"]',t.$container);t.confirmPassword.isValid()?(u.addClass("ko-valid"),u.parent().addClass("ko-valid")):(u.removeClass("ko-valid"),u.parent().removeClass("ko-valid"))};this.verifyConfirmationPassword=function(n,i){i.preventDefault();var r=$(i.currentTarget);t.confirmPassword.isValid()?(r.addClass("ko-valid"),r.parent().addClass("ko-valid")):(r.removeClass("ko-valid"),r.parent().removeClass("ko-valid"))};this.$container=$(n);this.password=Helpers.KnockoutHelper.GetObservableByType("password",this.$container);this.confirmPassword=Helpers.KnockoutHelper.GetObservableByType("password",this.$container,"confirmPassword").extend({equal:{message:Helpers.KnockoutHelper.validationMessage("confirmPassword","equal",this.$container),params:this.password}});this.isValidToken=ko.observable();this.errors=ko.validation.group(this,{deep:!0})}return n.prototype.showInvalidTokenPopup=function(){$("#btnInvalidtoken").click()},n}();n.ResetPasswordViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function n(n){this.IsChecked=ko.observable(!1);this.Variant=new t.ProductInfo(n)}return n}(),r=function(){function t(){var t=this;this.Variants=ko.observableArray();this.loadSeriesVariants=function(n){$.ajax("/api/commerce/product/getSeriesVariants/"+n,{type:"GET",success:function(n){for(var u=[],e,r=0,f=n;r<f.length;r++)e=f[r],u.push(new i(e));t.Variants(u);u.length<=4?t.expandViewMore():t.collapseViewMore()},error:function(){t.Variants([])}})};this.expandViewMore=function(){var t=$("#volumes-view-more-action-button"),n=t.closest(".js-wkis-read-more").find(".js-wkis-read-more-content"),i;n.attr("data-expanded","true");n.css("height","100%");i=n.height();n.css("height","500px");n.stop().animate({height:i},400);t.text("View Less")};this.collapseViewMore=function(){var n=$("#volumes-view-more-action-button"),t=n.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");t.attr("data-expanded","false");t.stop().animate({height:"500px"},200);n.text("View More")};this.viewMoreClick=function(n,i){var r=$(i.target),u=r.closest(".js-wkis-read-more").find(".js-wkis-read-more-content");u.css("height")!=="500px"?t.collapseViewMore():t.expandViewMore()};this.canAddToCart=function(){for(var r,n=0,i=t.Variants();n<i.length;n++)if(r=i[n],r.IsChecked())return!0;return!1};this.addToCart=function(){for(var i=[],f,o,r=0,u=t.Variants();r<u.length;r++)f=u[r],f.IsChecked()&&i.push(f);if(i.length!==0){var l=$.cookie(Constants.Global.BasketCookieKey),e=0,s=0,h=!1,c=null;Helpers.HtmlHelper.ShowGlobalLoaderElement();o=function(){var t=i[e],r=new Entities.OrderModels.OrderLineModel;r.Id=t.Variant.Id();r.Quantity=1;$.ajax("/api/commerce/basket/"+l+"/orderLine",{type:"POST",data:r,success:function(){t.IsChecked(!1);c=t.Variant.BackofficeProductId();s++},error:function(n){n.status===409&&(h=!0)},complete:function(){e++;e===i.length?(Helpers.HtmlHelper.HideGlobalLoaderElement(),h?Helpers.HtmlHelper.OpenModalDialog("added-cart-conflict"):s===i.length&&($("#volumes-added-cart-popup-button")[0].click(),n.Initializer.CartPageInitializer.CallInitialize($("#added-cart-popup")[0],c))):o()}})};o()}}}return t}();t.SeriesProductVariantsViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t;(function(t){var i=function(){function t(){var t=this,i,r,u;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.SearchString=ko.observable();this.CurrentSearchString=ko.observable();this.Rows=ko.observableArray();this.IsGridView=ko.observable(!0);this.IsClearAllFiltersVisible=ko.observable(!1);this.TotalRowsCount=ko.observable(-1);this.ResultsPerPage=ko.observable();this.ResultsPerPageList=ko.observableArray();this.SortBy=ko.observable();this.SortByList=ko.observableArray();this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.SelectedMarketSegmentFacet=ko.observable();this.FormatFacets=ko.observableArray();this.NoticeBannerIndex=ko.observable(-1);this.performSearch=function(i){var u=++t.loadCounter,r;i==null&&(i=1);r={IndexType:"product,productPlatform",QueryStr:t.SearchString(),PageSize:t.ResultsPerPage().Value,Page:i,SortBy:t.SortBy().Value,Facets:t.getFacets()};r.ReturnFacets=[n.Models.StorePage.FacetNames.MarketSegment,n.Models.StorePage.FacetNames.PracticeArea,n.Models.StorePage.FacetNames.Format,n.Models.StorePage.FacetNames.Industry,n.Models.StorePage.FacetNames.Role];u!==1&&(t.updateSearchUrlPart(i),t.IsClearAllFiltersVisible(r.Facets.length>0||r.QueryStr!=null&&r.QueryStr.length>0));t.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){if(u===1&&(t.initFormatFacets(n.Facets),t.updateFacetsHitCount(n.Facets,!0)),u===1&&location.search)t.loadFromSearchUrlPart();else{if(u!==t.loadCounter)return;u!==1&&t.updateFacetsHitCount(n.Facets,!1);t.IsLoading(!1);t.CurrentSearchString(r.QueryStr);t.Rows(n.Rows);t.generateRandomNoticeBannerIndex();t.TotalRowsCount(n.TotalRowsCount);t.Page(n.Page);t.PagesCount(n.PagesCount);t.updateStorePageHistory()}}})};this.updateStorePageHistory=function(){$.cookie(Constants.Global.StorePageCookieKey,location.pathname+location.search,{path:"/"})};this.loadFromSearchUrlPart=function(){var i={},tt=function(){for(var r=/\+/g,u=/([^&=]+)=?([^&]*)/g,t=function(n){return decodeURIComponent(n.replace(r," "))},n;;){if(n=u.exec(location.search.substring(1)),!n)break;i[t(n[1])]=n[2].split(",").map(function(n){return t(n)})}},f,r,e,d,o,y,s,u,h,c,g,l,p,w,a,nt,v,b,k;if(tt(),f=i.query,f&&f.length===1&&t.SearchString(f[0]),r=function(n,r){var f=i[n],e,c,u,o,l,w,a,s,v,y,h,p,b;if(f&&f.length!==0)for(e=0,c=r();e<c.length;e++){for(u=c[e],o=0,l=f;o<l.length;o++)if(w=l[o],u.Value()===w){u.IsChecked(!0);t.updateFacetParentAndChildren(u);break}if(a=!1,!u.IsChecked())for(s=0,v=u.Children();s<v.length;s++)for(y=v[s],h=0,p=f;h<p.length;h++)if(b=p[h],y.Value()===b){y.IsChecked(!0);a=!0;break}a&&$("#"+n+"-filter-accordion-trigger-"+r().indexOf(u)).click()}},e=i[n.Models.StorePage.FacetNames.MarketSegment],e&&e.length===1)for(d=e[0],o=0,y=t.MarketSegmentFacets();o<y.length;o++)if(s=y[o],s.Value()===d){t.SelectedMarketSegmentFacet(s);r(n.Models.StorePage.FacetNames.PracticeArea,s.Children);break}if(r(n.Models.StorePage.FacetNames.Format,t.FormatFacets),r(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets),r(n.Models.StorePage.FacetNames.Role,t.RoleFacets),u=1,h=i.page,h&&h.length===1&&(u=parseInt(h[0],10),isNaN(u)&&(u=1)),c=i.resultsPerPage,c&&c.length===1)for(g=c[0],l=0,p=t.ResultsPerPageList();l<p.length;l++)if(w=p[l],w.Value.toString()===g){t.ResultsPerPage(w);break}if(a=i.sortBy,a&&a.length===1)for(nt=a[0],v=0,b=t.SortByList();v<b.length;v++)if(k=b[v],k.Value===nt){t.SortBy(k);break}t.performSearch(u)};this.updateSearchUrlPart=function(i){var r="",u=function(n,t){r+=r?"&":"?";r+=encodeURIComponent(n)+"="+encodeURIComponent(t)},o=function(n,t){r+=r?"&":"?";r+=encodeURIComponent(n)+"="+t.map(function(n){return encodeURIComponent(n)}).join(",")},f,e;t.SearchString()&&u("query",t.SearchString());f=function(n,t){for(var i=[],u,f,s,h,r=0,e=t();r<e.length;r++)for(u=e[r],u.IsChecked()&&i.push(u.Value()),f=0,s=u.Children();f<s.length;f++)h=s[f],h.IsChecked()&&i.push(h.Value());i.length>0&&o(n,i)};e=Helpers.UrlHelper.GetUrlParam(window.location.href,"cm_mmc");e!=null&&o("cm_mmc",[e]);t.SelectedMarketSegmentFacet()&&(u(n.Models.StorePage.FacetNames.MarketSegment,t.SelectedMarketSegmentFacet().Value()),f(n.Models.StorePage.FacetNames.PracticeArea,t.SelectedMarketSegmentFacet().Children));f(n.Models.StorePage.FacetNames.Format,t.FormatFacets);f(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets);f(n.Models.StorePage.FacetNames.Role,t.RoleFacets);i>1&&u("page",i.toString());t.ResultsPerPageList().indexOf(t.ResultsPerPage())>0&&u("resultsPerPage",t.ResultsPerPage().Value.toString());t.SortByList().indexOf(t.SortBy())>0&&u("sortBy",t.SortBy().Value);history.replaceState({},null,location.pathname+r+location.hash)};this.generateRandomNoticeBannerIndex=function(){var n=Math.ceil(t.Rows().length/3),i;if(n<=2){t.NoticeBannerIndex(-1);return}i=Math.floor(Math.random()*(n-2)+2);t.NoticeBannerIndex(i*3)};this.gridViewClick=function(){t.IsGridView(!0)};this.listViewClick=function(){t.IsGridView(!1)};this.searchInputKeyUp=function(n,i){i.keyCode===13&&t.performSearch()};this.performSearchClick=function(){return t.performSearch(),!0};this.incrementPageClick=function(){var n=t.Page()+1;n<=t.PagesCount()&&(t.performSearch(n),t.scrollToTop())};this.decrementPageClick=function(){var n=t.Page()-1;n>0&&(t.performSearch(n),t.scrollToTop())};this.scrollToTop=function(){var n=$(".wkis-store-content").offset();$("html, body").animate({scrollTop:n.top})};this.getFacets=function(){var u=[],i=function(t,i){var r=new n.Models.StorePage.FacetArg,f;r.Name=t;f=function(n){for(var i,t=0,u=n();t<u.length;t++)i=u[t],i.IsChecked()&&r.Labels.push(i.Value()),f(i.Children)};f(i);r.Labels.length>0&&u.push(r)},f=t.SelectedMarketSegmentFacet(),r;return f!=null&&(r=new n.Models.StorePage.FacetArg,r.Name=n.Models.StorePage.FacetNames.MarketSegment,r.Labels.push(f.Value()),u.push(r),i(n.Models.StorePage.FacetNames.PracticeArea,f.Children)),i(n.Models.StorePage.FacetNames.Format,t.FormatFacets),i(n.Models.StorePage.FacetNames.Industry,t.IndustryFacets),i(n.Models.StorePage.FacetNames.Role,t.RoleFacets),u};this.initFormatFacets=function(i){for(var s,h,e,c,r,u,f=0,o=i;f<o.length;f++)if(s=o[f],s.Name===n.Models.StorePage.FacetNames.Format){for(h=[],e=0,c=s.Items;e<c.length;e++)(r=c[e],r.HitCount!==0)&&(u=new n.Models.StorePage.FacetModel,u.Text(r.Label),u.Value(r.Label),u.HitCount(r.HitCount),h.push(u));t.FormatFacets(h);break}};this.updateFacetsHitCount=function(i,r){for(var p=function(n){for(var u={},r,t=0,i=n;t<i.length;t++)r=i[t],u[r.Label]=r.HitCount;return u},f=function(n,t){for(var o=[],i,e,u=0,f=n();u<f.length;u++)i=f[u],e=t[i.Value()],e?(i.HitCount(e),o.push(i)):i.HitCount(0);r&&n(o)},c,u,o,l,a,s,v,y,e=0,h=i;e<h.length;e++){c=h[e];u=p(c.Items);switch(c.Name){case n.Models.StorePage.FacetNames.MarketSegment:f(t.MarketSegmentFacets,u);break;case n.Models.StorePage.FacetNames.PracticeArea:for(o=0,l=t.MarketSegmentFacets();o<l.length;o++)for(a=l[o],f(a.Children,u),s=0,v=a.Children();s<v.length;s++)y=v[s],f(y.Children,u);break;case n.Models.StorePage.FacetNames.Format:f(t.FormatFacets,u);break;case n.Models.StorePage.FacetNames.Industry:f(t.IndustryFacets,u);break;case n.Models.StorePage.FacetNames.Role:f(t.RoleFacets,u)}}};this.withHits=function(n){for(var u=[],t,r,e,o,i=0,f=n;i<f.length;i++)if(t=f[i],t.HitCount())u.push(t);else for(r=0,e=t.Children();r<e.length;r++)if(o=e[r],o.HitCount()){u.push(t);break}return u};this.clearFacets=function(n){for(var r=function(n){var t,i,u;for(n.IsChecked(!1),t=0,i=n.Children();t<i.length;t++)u=i[t],r(u)},u,t=0,i=n();t<i.length;t++)u=i[t],r(u)};this.marketSegmentFacetClick=function(n){t.clearFacets(t.MarketSegmentFacets);t.SelectedMarketSegmentFacet(n);t.performSearch()};this.marketSegmentFacetCloseClick=function(){t.clearFacets(t.MarketSegmentFacets);t.SelectedMarketSegmentFacet(null);t.performSearch()};this.accordionTriggerClick=function(n,t){$(t.target).toggleClass("-open");$(t.target).next(".js-wkis-filter-accordion-content").slideToggle(300).toggleClass("-open")};this.facetClick=function(n){return t.updateFacetParentAndChildren(n),t.performSearch(),!0};this.updateFacetParentAndChildren=function(n){var i=function(n){for(var f=n.IsChecked(),u,t=0,r=n.Children();t<r.length;t++)u=r[t],u.IsChecked(f),i(u)},t;i(n);t=function(n){var r,i,u,f;if(n.Parent!=null){for(r=!0,i=0,u=n.Parent.Children();i<u.length;i++)if(f=u[i],!f.IsChecked()){r=!1;break}r&&n.Parent.IsChecked(!0);t(n.Parent)}};t(n)};this.clearAllFiltersClick=function(){t.clearFacets(t.MarketSegmentFacets);t.clearFacets(t.FormatFacets);t.clearFacets(t.IndustryFacets);t.clearFacets(t.RoleFacets);t.SelectedMarketSegmentFacet(null);t.SearchString(null);t.performSearch()};i=function(){t.ResultsPerPageList([{Text:"20",Value:20},{Text:"50",Value:50},{Text:"80",Value:80},{Text:"110",Value:110}]);t.ResultsPerPage(t.ResultsPerPageList()[0])};i();r=function(){t.SortByList([{Text:$("#storeSortByAZDictText").text(),Value:"title-az"},{Text:$("#storeSortByZADictText").text(),Value:"title-za"}])};r();this.SortBy(this.SortByList()[0]);u=function(){var i=function(n){var t,r,u;for(n.IsChecked=ko.observable(!1),n.HitCount=ko.observable(0),t=0,r=n.Children();t<r.length;t++)u=r[t],u.Parent=n,i(u)},e=window.InitialPageJsonModel,r,o,u,s,f,h,n;for(t.MarketSegmentFacets=ko.mapping.fromJS(e.MarketSegmentFacets),r=0,o=t.MarketSegmentFacets();r<o.length;r++)n=o[r],i(n);for(t.IndustryFacets=ko.mapping.fromJS(e.IndustryFacets),u=0,s=t.IndustryFacets();u<s.length;u++)n=s[u],i(n);for(t.RoleFacets=ko.mapping.fromJS(e.RoleFacets),f=0,h=t.RoleFacets();f<h.length;f++)n=h[f],i(n)};u();this.performSearch()}return t}();t.StorePageViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(Commerce||(Commerce={})),function(n){var t=function(){function n(){}return n}(),f,i,e,o,r,u,h,s;t.Space=" ";t.BasketCookieKey="basketid";t.StorePageCookieKey="storePage";t.RememberMeCookieKey="auth";t.UserTokenCookieKey="userToken";t.AlertMessageClass="js-wkis-alert-message";t.RememberMeExpirationDays=90;t.BasketIdExpirationCookieDays=90;t.UserTokenExpirationMinutes=20;t.ODataElement="odata.type";t.ODataOperation=function(n){return"ecommerce."+n};n.Global=t;f=function(){function n(){}return n}();f.OsaContentType="application/json;odata=minimalmetadata";f.CommonContentType="application/x-www-form-urlencoded";n.ContentType=f;i=function(){function n(){}return n}();i.Success="success";i.Failed="failed";i.Info="info";i.Warning="warning";n.AlertMessageTypes=i;e=function(){function n(){}return n}();e.US="US";e.CA="CA";n.CountriesIso=e;o=function(){function n(){}return n}();o.PriorityCountries=[n.CountriesIso.US];o.CitiesWithoutRegionValidation=["london"];n.AddressBook=o;r=function(){function n(){}return n}();r.ApplyingPromoCodeKey="applyingPromoCode";r.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey="checkGeoIpCurrencyDoesntMatchToBillingAddressCurrency";r.POBoxAddressLineRegexp=/(?:P(?:ost(?:al)?)?[\.\-\s]*(?:(?:O(?:ffice)?[\.\-\s]*)?B(?:ox|in|\b|\d)|o(?:ffice|\b)(?:[-\s]*\d)|code)|box[-\s\b]*\d)/i;n.Commerce=r;u=function(){function n(){}return n}();u.Sellable=0;u.NonSellable=1;u.Digital=2;n.VariantType=u;h=function(){function n(){}return n}();h.HeaderReturnContent={Prefer:"return-content"};n.JQuery=h;s=function(){function n(){}return n}();s.AddressModelOsaMapping={ignore:["$container","AvailableCountries","AvailableStates","State","errors","emailErrors","Country","PhoneNumber","PostalCode","IsBilling","verifiedEmail","SaveAsDefault","CustomerName","IsDefaultBilling","IsDefaultShipping","Selected","AddressId","regionVisibility"]};s.IgnoreJQueryMapping={ignore:["$container","alsoIgnoreThis"]};n.KnockooutMapping=s}(Constants||(Constants={})),function(n){var t;(function(n){var t=function(){function n(){}return n}();n.AccountInfoModel=t})(t=n.AccountInfoModels||(n.AccountInfoModels={}))}(Entities||(Entities={})),function(n){var t;(function(n){var f=function(){function n(){}return n}(),t,i,r,u;n.CustomerAddressBookModel=f;t=function(){function n(){}return n}();n.AddressBookModel=t;i=function(){function n(){}return n}();n.AddressModel=i;r=function(){function n(){}return n}();n.CountryModel=r;u=function(){function n(n,t){this.StateName=n?n:"";this.StateIso=t?t:""}return n}();n.StateModel=u})(t=n.AddressBookModels||(n.AddressBookModels={}))}(Entities||(Entities={})),function(n){var t;(function(n){var t=function(){function n(){}return n}();n.Warning=t})(t=n.Common||(n.Common={}))}(Entities||(Entities={})),function(n){var t;(function(n){var c=function(){function n(){}return n}(),t,i,r,u,f,e,o,s,h;n.OrderModel=c;t=function(){function n(){}return n}();n.OrderLineModel=t;i=function(){function n(){}return n}();n.ShippingLocation=i;r=function(){function n(){}return n}();n.ProductInfo=r;u=function(){function n(){}return n}();n.PriceInfo=u;f=function(){function n(){}return n}();n.ProductProgramModel=f;e=function(){function n(){}return n}();n.OrderPriceInfo=e;o=function(){function n(){}return n}();n.PromotionModel=o;s=function(){function n(){}return n}();n.ShippingMethod=s;h=function(){function n(){}return n}();n.PaymentInfo=h})(t=n.OrderModels||(n.OrderModels={}))}(Entities||(Entities={})),function(n){var t=function(){function n(){}return n}();n.Token=t}(Entities||(Entities={})),function(n){var i=function(){function n(){}return n.TrimArray=function(n){for(var t=0;t<n.length;t++)n[t]=n[t].trim()},n.GetUniqueArray=function(n){return n.filter(function(n,t,i){return i.indexOf(n)===t})},n.GetUTCDate=function(n){var t=/\/Date\((\d+)\)\//;return n.search(t)!=-1?parseInt(n.replace(t,"$1")):Date.parse(n)},n}(),t;n.CommonHelper=i;t=function(){function n(){}return n.Format=function(t){for(var u=[],r,i=1;i<arguments.length;i++)u[i-1]=arguments[i];try{return r=u,t.replace(/{(\d+)}/g,function(n,t){return typeof r[t]!="undefined"?r[t]:n})}catch(f){return n.Empty}},n.Capitalize=function(n){return n.replace(/(^|\s)([a-z])/g,function(n,t,i){return t+i.toUpperCase()})},n}();t.Empty="";n.String=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.GetAlertMessageElement=function(t,i,r,u){var f=document.createElement("div"),e;return f.classList.add(Constants.Global.AlertMessageClass),f.setAttribute("data-type",t),e='<div class="js-wkis-alert-message-content">\n                   <div class="wkis-eyebrow">'+i+'<\/div>\n                   <div class="js-wkis-alert-message-text">'+r+'<\/div>\n                <\/div>\n                <a class="js-wkis-alert-message-close close-alert">Close<\/a>',f.innerHTML=e,$(".close-alert",f).click(function(t){t.preventDefault();$(t.currentTarget).parent("."+Constants.Global.AlertMessageClass).remove();n.CloseGlobalAlertMessage()}),u&&(u.complete||(u.complete=function(){$(f).remove()}),$(f).fadeOut(u.duration,u.complete)),f},n.PreventJumpingOnTargetElemnet=function(n,t){$("a[href^='#']",n).on("click",function(n){n.preventDefault();var i=$(document).scrollTop();history.pushState({},"",this.href);location.href=this.href;$(document).scrollTop(i);t&&t()})},n.RemoveAlertMessages=function(n,t){var i=t?"."+Constants.Global.AlertMessageClass+"[data-type="+t+"]":"."+Constants.Global.AlertMessageClass;$(i,n).remove()},n.GetLoaderElement=function(n){var t,i,u,r;for(n===void 0&&(n=24),t=document.createElement("div"),t.classList.add("js-wkis-preloader"),t.style.background="none",t.style.opacity="1",t.style.transition="none",t.style["box-shadow"]="none",t.style.visibility="visible",i=document.createElement("div"),i.classList.add(".wkis-preloader-cube"),i.style.width=n+"px",i.style.height=n+"px",u=0;u<9;u++)r=document.createElement("div"),r.classList.add("wkis-preloader-cube-part"),r.setAttribute("data-cube",u.toString()),r.style.width=(n/3).toFixed().toString(),r.style.height=(n/3).toFixed().toString(),i.appendChild(r);return t.appendChild(i),t},n.ShowGlobalLoaderElement=function(){$("html").attr("data-loading","true");$(".js-wkis-preloader").show()},n.HideGlobalLoaderElement=function(){$("html").attr("data-loading","false");$(".js-wkis-preloader").hide()},n.ShowMiniLoaderElement=function(n,t,i){t===void 0&&(t=0);i===void 0&&(i=0);var r=$("#miniLoader");r.insertAfter($(n));r.css("left",t);r.css("top",i);r.show()},n.HideMinilLoaderElement=function(){$("#miniLoader").hide()},n.CloseModalDialog=function(){var n=$(".js-wkis-modal-overlay").first();n.length&&n[0].click()},n.OpenModalDialog=function(n){var t=$(".js-wkis-modal-open[data-modal="+n+"]");t.length&&t[0].click()},n.ShowHelpInfo=function(){var n=$(".wkis-account-help");n.length&&n.show()},n.HideHelpInfo=function(){var n=$(".wkis-account-help");n.length&&n.hide()},n.SetGlobalAlertMessage=function(n){var t=$(".js-wkis-dialog-box");t.length&&(t.html(""),t.append(n))},n.ShowGlobalAlertMessage=function(){$("html").addClass("-dialog-open")},n.CloseGlobalAlertMessage=function(){$("html").removeClass("-dialog-open")},n}();n.HtmlHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function t(){}return t.validationMessage=function(n,t,i){var r=$("ko-error-text[for="+n+"][rule="+t+"]",i).first();return r&&r.text().length?r.text():this.DefaultErrorMessage},t.GetObservableByType=function(t,i,r){var u=r?r:t;switch(t){case"password":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({minLength:{params:6,message:n.KnockoutHelper.validationMessage(u,"minLength",i)}}).extend({spaceInPassword:{message:n.KnockoutHelper.validationMessage(u,"spaces",i)}});case"email":return ko.observable().extend({required:{message:n.KnockoutHelper.validationMessage(u,"required",i)}}).extend({email:{message:n.KnockoutHelper.validationMessage(u,"email",i)}})}return ko.observable()},t}();t.DefaultErrorMessage="";n.KnockoutHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.GetUrlParam=function(n,t){return(RegExp(t+"=(.+?)(&|$)").exec(n)||[,null])[1]},n.SetUrlParam=function(n,t,i){var r,u,f;return n?(r=new RegExp("(.*)"+t+"=[^&]*?&(.*)"),r.test(n))?n.replace(r,"$1"+(t+"="+i+"&")+"$2"):(u=new RegExp("(.*)"+t+"=[^&]*?$"),u.test(n))?n.replace(u,"$1"+(t+"="+i)):n.indexOf("/")>=0?(f=n.indexOf("?"),f<0?n+("?"+t+"="+i):f<=n.length-1?n+("&"+t+"="+i):n+("&"+t+"="+i)):n+("&"+t+"="+i):t+"="+i},n}();n.UrlHelper=t}(Helpers||(Helpers={})),function(n){var t=function(){function n(){}return n.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency=function(n){$.ajax("/Ecommerce.svc/AddressAdministration_CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({request:{"odata.type":Constants.Global.ODataOperation("CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrency"),BillingCountryName:n}}),success:function(n){$.removeCookie(Constants.Commerce.CheckGeoIpCurrencyDoesntMatchToBillingAddressCurrencyKey);n.value===!0&&$("#geo-ip-currency-is-not-billing-message-link")[0].click()}})},n}();n.AddressServices=t}(Services||(Services={})),function(n){var t=function(){function n(){}return n.UpdateExpirationBasketIdCookie=function(){var t=$.cookie(Constants.Global.BasketCookieKey),n;t&&(n=new Date,n.setTime(n.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5),$.cookie(Constants.Global.BasketCookieKey,t,{path:"/",expires:n}))},n}();t.GetOrderLine=function(t,i,r,u){return r===void 0&&(r=!0),u===void 0&&(u=!1),$.ajax(n.UrlManager.GetBasketUrl(t)+"/Basket_orderLines('"+i+"')",{type:"GET",async:r,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){u&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.RemoveOrderLine=function(t,i){return i===void 0&&(i=!1),$.ajax(n.UrlManager.OrderLinesUrl(t),{type:"DELETE",contentType:Constants.ContentType.OsaContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.UpdateOrderLine=function(t,i,r){return r===void 0&&(r=!1),$.ajax(n.UrlManager.OrderLinesUrl(t),{type:"PUT",data:i,contentType:Constants.ContentType.OsaContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.ResendConfirmationEmail=function(t,i){return i===void 0&&(i=!1),$.ajax(n.UrlManager.ResendConfirmationEmailUrl,{type:"POST",data:JSON.stringify(t),contentType:Constants.ContentType.OsaContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};n.OrderServices=t}(Services||(Services={})),function(n){var t=function(){function n(){}return n}();t.generateAllPages=function(n){for(var i=[],t=1;t<=n;t++)i.push(t);return i};t.generateMaxPage=function(n,t,i){for(var o=1,r=n+(i-1)/2,u=n-(i-1)/2,e,f;r>t;)r--,u>o&&u--;while(u<o)u++,r<t&&r++;for(e=[],f=u;f<=r;f++)e.push(f);return e};t.getPages=function(n,i,r){return n<=i?t.generateAllPages(n):t.generateMaxPage(r,n,i)};n.PaginationServices=t}(Services||(Services={})),function(n){var t=function(){function n(){}return n}(),i;t.RoutePrefix="/Ecommerce.svc/";t.AddressApi=t.RoutePrefix+"Addresses";t.BasketApi=t.RoutePrefix+"Baskets";t.OrderApi=t.RoutePrefix+"Orders";t.UserApi=t.RoutePrefix+"Users";t.UserManagmentApi="/Ecommerce.svc";t.AuthApi=t.RoutePrefix+"CustomerAdministration_Auth";t.BasketAppendApi=t.RoutePrefix+"BasketAdministration_AppendBasketOrderLines";t.BasketAssignToCurrentUserApi=t.RoutePrefix+"BasketAdministration_AssignBasket";t.OrderResenEmailConfirmationApi=t.RoutePrefix+"OrderAdministration_ResendEmailConfirmation";t.OrderLineApi=function(n){return t.RoutePrefix+"OrderLines('"+n+"')"};i=function(){function n(){}return n}();i.GetUserInfoUrl=t.UserApi;i.RegisterUserUrl=t.UserApi;i.AuthentificationUrl=t.AuthApi;i.GetCurrentBasketUrl=t.BasketApi+"('_')";i.GetCurrentBasketCommerceUrl="/api/commerce/basket/getcurrent";i.GetBasketUrl=function(n){return t.BasketApi+"('"+n+"')"};i.AppendBasketUrl=t.BasketAppendApi;i.AssignBasketToCurrentUserUrl=t.BasketAssignToCurrentUserApi;i.GetOrderUrl=function(n){return t.OrderApi+"('"+n+"')"};i.OrderLinesUrl=function(n){return t.OrderLineApi(n)};i.ResendConfirmationEmailUrl=t.OrderResenEmailConfirmationApi;n.UrlManager=i}(Services||(Services={})),function(n){var t=function(){function t(){}return t.GetUserAddressBook=function(n){n===void 0&&(n=!0);var t=[];return $.ajax("/api/commerce/address",{type:"GET",async:n,success:function(n){$.extend(t,n)}}),t},t.GetUserBasketViewModel=function(n,t){var r=this,e;n===void 0&&(n=!0);t===void 0&&(t=!1);var u=$.cookie(Constants.Global.BasketCookieKey),i=new Entities.OrderModels.OrderModel,f=function(n){var u;window.preInit&&window.preInit.order&&window.preInit.order[n]?(u=window.preInit.order[n],$.extend(i,u)):(u=t?r.GetJsonBasketCommerceApi(n):r.GetJsonBasket(n),$.extend(i,u))};return u?f(u):(e=function(n){if(n.readyState==4&&n.status==201){var t=new Date;t.setTime(t.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,n.responseJSON.Id,{path:"/",expires:t});f(n.responseJSON.Id)}},this.CreateBasket(n,e)),i},t.GetSuggestedAddress=function(n,t){t===void 0&&(t=!0);var i={},r=Constants.Global.ODataOperation("SuggestAddress"),u=Constants.Global.ODataOperation("ValidatingAddress"),f=JSON.stringify({request:{"odata.type":r,Address:{"odata.type":u,AddressLine:n.AddressLine,AddressLine2:n.AddressLine2,City:n.City,CountryName:n.CountryName,CountryIso:n.CountryIso,PostalCode:n.PostalCode,StateName:n.StateName,StateIso:n.StateIso}}});return $.ajax("/Ecommerce.svc/AddressAdministration_SuggestAddress",{method:"POST",async:t,data:f,contentType:Constants.ContentType.OsaContentType,success:function(t){if(t.IsValid==!0)i.addressModel=new Entities.AddressBookModels.AddressBookModel,$.extend(i.addressModel,t),n.AddressId&&(i.Id=n.AddressId),i.addressModel.CountryName=n.CountryName,i.addressModel.StateName=n.StateName,i.addressModel.IsBilling=n.IsBilling,i.addressModel.FirstName=n.FirstName,i.addressModel.LastName=n.LastName,i.addressModel.CompanyName=n.CompanyName,i.addressModel.PhoneNumber=n.PhoneNumber,i.addressModel.Email=n.Email,i.addressModel.IsDefaultShipping=n.IsDefaultShipping,i.addressModel.IsDefaultBilling=n.IsDefaultBilling,i.addressModel.IsBilling=n.IsBilling;else{var r=t.ErrorDescription.indexOf("]");t.ErrorDescription&&(i.message=t.ErrorDescriptionstartIndex!=-1&&r!=-1?t.ErrorDescription.substring(r+1):t.ErrorDescription)}}}),i},t.Logout=function(){var n=$(".js-wkis-login-open","header").css("display","inline-block"),t=$(".js-wkis-myaccount-open","header").hide();$.removeCookie(Constants.Global.UserTokenCookieKey,{path:"/"});$.removeCookie(Constants.Global.BasketCookieKey,{path:"/"})},t.ShowMyAccHeader=function(){var n=$(".js-wkis-login-open","header").hide(),t=$(".js-wkis-myaccount-open","header").css("display","inline-block")},t.GetJsonBasket=function(t){var r=this,i=new Entities.OrderModels.OrderModel;return $.ajax("/Ecommerce.svc/Baskets('"+t+"')?$expand=Basket_orderLines/Product/ShippingLocation",{method:"GET",async:!1,success:function(n){$.extend(i,n)},error:function(){var n,t=function(t){if(t.readyState==4&&t.status==201){var i=new Date;i.setTime(i.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,t.responseJSON.Id,{path:"/",expires:i});n=t.responseJSON}};r.CreateBasket(!1,t);$.extend(i,n);i.Basket_orderLines=n.BasketLines},complete:function(){n.OrderServices.UpdateExpirationBasketIdCookie()}}),i},t.GetJsonBasketCommerceApi=function(t){var r=this,i=new Entities.OrderModels.OrderModel;return $.ajax("/api/commerce/basket/"+t,{method:"GET",async:!1,success:function(n){$.extend(i,n);i.Basket_orderLines=n.BasketLines},error:function(){var n,t=function(t){if(t.readyState==4&&t.status==201){var i=new Date;i.setTime(i.getTime()+Constants.Global.BasketIdExpirationCookieDays*864e5);$.cookie(Constants.Global.BasketCookieKey,t.responseJSON.Id,{path:"/",expires:i});n=t.responseJSON}};r.CreateBasket(!1,t);$.extend(i,n);i.Basket_orderLines=n.BasketLines},complete:function(){n.OrderServices.UpdateExpirationBasketIdCookie()}}),i},t.CreateBasket=function(n,t){var i=Constants.Global.ODataOperation("Basket");$.ajax("/Ecommerce.svc/Baskets",{method:"POST",contentType:Constants.ContentType.OsaContentType,data:JSON.stringify({"odata.type":i}),async:n,complete:function(n){return t(n)}})},t}();t.GetUserInfo=function(t,i){return t===void 0&&(t=!1),i===void 0&&(i=!1),$.ajax(n.UrlManager.GetUserInfoUrl,{type:"GET",contentType:t?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.Authentification=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AuthentificationUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.GetCurrentBasket=function(t,i){return t===void 0&&(t=!1),i===void 0&&(i=!1),$.ajax(t?n.UrlManager.GetCurrentBasketUrl:n.UrlManager.GetCurrentBasketCommerceUrl,{type:"GET",contentType:t?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){i&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.AppendBasket=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AppendBasketUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.Register=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.RegisterUserUrl,{data:t,type:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};t.AssignBasketToCurrentUser=function(t,i,r){return i===void 0&&(i=!1),r===void 0&&(r=!1),$.ajax(n.UrlManager.AssignBasketToCurrentUserUrl,{data:t,method:"POST",contentType:i?Constants.ContentType.OsaContentType:Constants.ContentType.CommonContentType,beforeSend:function(){r&&Helpers.HtmlHelper.ShowGlobalLoaderElement()}})};n.UserServices=t}(Services||(Services={})),function(n){var t;(function(n){var t;(function(n){var i=function(){function n(){}return n}(),t;n.FacetModel=i;t=function(){function n(){}return n}();n.FacetArg=t})(t=n.FacetEntities||(n.FacetEntities={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t;(function(n){var y=function(){function n(){}return n}(),t,i,r,u,f,e,o,s,h,c,l,a,v;n.SelectOptionModel=y;t=function(){function n(){this.Labels=[]}return n}();n.FacetArg=t;i=function(){function n(){}return n}();n.SearchArgs=i;r=function(){function n(){}return n}();n.Row=r;u=function(){function n(){}return n}();n.FacetResultItem=u;f=function(){function n(){}return n}();n.FacetResult=f;e=function(){function n(){}return n}();n.SearchResult=e;o=function(){function n(){this.Text=ko.observable();this.Name=ko.observable();this.Facets=ko.observableArray()}return n}();n.FacetContainerModel=o;s=function(){function n(){this.Text=ko.observable();this.Value=ko.observable();this.Children=ko.observableArray();this.HitCount=ko.observable();this.IsChecked=ko.observable()}return n}();n.FacetModel=s;h=function(){function n(){}return n}();n.DateRangeFacet=h;c=function(){function n(){}return n}();n.DateRangeModel=c;l=function(){function n(n,i){var r=this;this.initializeFacets=function(n){for(var r=function(n,t){var i,u,f;for(n.IsChecked=ko.observable(!1),n.HitCount=ko.observable(0),n.Container=t,i=0,u=n.Children();i<u.length;i++)f=u[i],f.Parent=n,r(f,t);n.HasSubHits=ko.computed(function(){for(var r,t=0,i=n.Children();t<i.length;t++)if(r=i[t],r.HasHits())return!0;return!1});n.HasHits=ko.computed(function(){return n.HitCount()>0?!0:n.HasSubHits()});n.AllHitCount=ko.computed(function(){for(var r=0,u,t=0,i=n.Children();t<i.length;t++)u=i[t],r+=u.AllHitCount();return r+n.HitCount()})},u=ko.mapping.fromJS(n),e=function(n){for(var u,t=0,i=n.Facets();t<i.length;t++)u=i[t],r(u,n);n.HasSubHits=ko.computed(function(){for(var r,t=0,i=n.Facets();t<i.length;t++)if(r=i[t],r.HasHits())return!0;return!1})},f,t=0,i=u();t<i.length;t++)f=i[t],e(f);return u};this.isClearFilterVisible=function(n){for(var r=function(n){var t,i,u;if(n.IsChecked())return!0;for(t=0,i=n.Children();t<i.length;t++)if(u=i[t],r(u))return!0;return!1},u,t=0,i=n.Facets();t<i.length;t++)if(u=i[t],r(u))return!0;return!1};this.isClearAllFiltersVisible=function(){for(var i,n=0,t=r.Facets();n<t.length;n++)if(i=t[n],r.isClearFilterVisible(i))return!0;return!1};this.clearFilter=function(n){for(var u,t=0,i=n();t<i.length;t++)u=i[t],u.IsChecked(!1),r.clearFilter(u.Children)};this.clearFilterClick=function(n){r.clearFilter(n.Facets);r.performSearch()};this.clearAllFilters=function(){for(var i,n=0,t=r.Facets();n<t.length;n++)i=t[n],r.clearFilter(i.Facets)};this.updateFacetsHitCount=function(n){for(var c=function(n){for(var u={},r,t=0,i=n;t<i.length;t++)r=i[t],u[r.Label]=r.HitCount;return u},s=function(n,t,i){var u,f,r,e;for(i===void 0&&(i=!0),u=0,f=n();u<f.length;u++)r=f[u],e=t[r.Value()],e?r.HitCount(e):r.HitCount(0),i&&s(r.Children,t)},f,h,i,e,o,t=0,u=n;t<u.length;t++)for(f=u[t],h=c(f.Items),i=0,e=r.Facets();i<e.length;i++)if(o=e[i],o.Name()===f.Name){s(o.Facets,h);break}r.HitCountUpdatedTime(Date.now())};this.updateFacetParentAndChildren=function(n){var i=function(n){for(var f=n.IsChecked(),t,r=0,u=n.Children();r<u.length;r++)t=u[r],t.HasHits()?t.IsChecked(f):t.IsChecked(!1),i(t)},t;i(n);t=function(n){var r,i,u,f;if(n.Parent!=null){for(r=!0,i=0,u=n.Parent.Children();i<u.length;i++)if(f=u[i],!f.IsChecked()&&f.HasHits()){r=!1;break}r&&n.Parent.IsChecked(!0);t(n.Parent)}};t(n)};this.getFacets=function(){for(var f=[],e=function(n,i,r){var u,e;r===void 0&&(r=!0);u=new t;u.Name=n;e=function(n){for(var i,t=0,f=n();t<f.length;t++)i=f[t],i.IsChecked()&&u.Labels.push(i.Value()),r&&e(i.Children)};e(i);u.Labels.length>0&&f.push(u)},u,n=0,i=r.Facets();n<i.length;n++)u=i[n],e(u.Name(),u.Facets);return f};this.facetClick=function(n){return r.updateFacetParentAndChildren(n),r.performSearch(),!0};this.accordionTriggerClick=function(n,t){$(t.target).toggleClass("-open");$(t.target).next(".js-wkis-filter-accordion-content").slideToggle(300).toggleClass("-open")};this.Facets=this.initializeFacets(n);this.performSearch=i;this.HitCountUpdatedTime=ko.observable(Date.now())}return n}();n.FacetsService=l;a=function(){function n(n,t,i){var r=this;this.DateFormat=moment("20001030","YYYYMMDD").format("L").replace("2000","YYYY").replace("10","MM").replace("30","DD");this.DateFrom=ko.observable();this.DateTo=ko.observable();this.SelectPeriod=ko.observable(!1);this.getEditionFacetContainer=function(n){return n.Facets().filter(function(n){return n.Text()==="Editie"})[0]};this.updateEditionDatePicker=function(n,t){var w=r.getEditionFacetContainer(t),i,h,u,c,f,l,e,b,a,v,o,y,s,p;if(w)for(i=0,h=w.Facets();i<h.length;i++)if(u=h[i],u.Text())for(c={},r.EditionFacets[u.Text()]=c,f=0,l=u.Children();f<l.length;f++)if((e=l[f],e.Text())&&(b=e.Text().toLowerCase(),a=n[b],a))for(v={},c[a]=v,o=0,y=e.Children();o<y.length;o++)(s=y[o],s.Text()&&s.HasHits())&&(p=s.Text().split(" ")[0],p)&&(v[p]=!0)};this.initializeEditionDatePickers=function(n){var h=r.getEditionFacetContainer(n),f,i,s,o,e,t,u;if(h){for(f=[],f.push(moment().isoWeekday(7).format("dd")),t=1;t<=6;t++)f.push(moment().isoWeekday(t).format("dd"));for(i=[],s=[],t=0;t<12;t++)u=moment().month(t),i.push(u.format("MMMM")),s.push(u.format("MMM"));for(o=i.map(function(n){return n.toLowerCase()}),e={},t=0;t<o.length;t++)u=o[t],e[u]=t.toString();r.EditionFacets={};r.updateEditionDatePicker(e,n);n.HitCountUpdatedTime.subscribe(function(){r.updateEditionDatePicker(e,n)});setTimeout(function(){var t=r.$container.find(".js-wkis-datebox-calendar.calendar-from"),n;t.datepicker({changeMonth:!0,changeYear:!0,firstDay:1,numberOfMonths:1,dayNamesMin:f,monthNames:i,monthNamesShort:i,nextText:'Next<span class="wkis-icon-arrow-right"><\/span>',prevText:'<span class="wkis-icon-arrow-left"><\/span>Previous',dateFormat:"mm/dd/yy",showOtherMonths:!0,selectOtherMonths:!0,onSelect:function(n){var t=moment(n,"MM/DD/YYYY"),i=t.isValid()?t.format("D-M-YYYY"):"";r.DateFrom(i);r.hideCalendar();setTimeout(r.updateCalendarUi);r.performSearch()}});t.on("click",function(){r.updateCalendarUi();t.find("select").on("change",r.updateCalendarUi)});n=r.$container.find(".js-wkis-datebox-calendar.calendar-to");n.datepicker({changeMonth:!0,changeYear:!0,firstDay:1,numberOfMonths:1,dayNamesMin:f,monthNames:i,monthNamesShort:i,nextText:'Next<span class="wkis-icon-arrow-right"><\/span>',prevText:'<span class="wkis-icon-arrow-left"><\/span>Previous',dateFormat:"mm/dd/yy",showOtherMonths:!0,selectOtherMonths:!0,onSelect:function(n){var t=moment(n,"MM/DD/YYYY"),i=t.isValid()?t.format("D-M-YYYY"):"";r.DateTo(i);r.SelectPeriod()&&r.hideCalendar();setTimeout(r.updateCalendarUi);r.performSearch()}});n.on("click",function(){r.updateCalendarUi();n.find("select").on("change",r.updateCalendarUi)});r.$container.on("click",".js-wkis-datebox-close, .js-wkis-datebox-overlay",function(){r.hideCalendar()}).on("keyup",function(n){n.keyCode===27&&r.hideCalendar()})})}};this.updateCalendarUi=function(){r.$container.find(".ui-datepicker-header a").attr("title","");var n=r.$container.find(".ui-datepicker-calendar td");n.each(function(n,t){var i=$(t),e=!1,c=i.attr("data-year"),o=r.EditionFacets[c],s,u,f,h;o&&(s=i.attr("data-month"),u=o[s],u&&(f=i.find("a"),f.length&&(h=u[f.text()],h&&(e=!0))));e||i.addClass("wkepam-datepicker-inactive-day")})};this.showCalendar=function(){var i=r.DateFrom()?moment(r.DateFrom(),"L").format("MM/DD/YYYY"):null,n,t;r.$container.find(".js-wkis-datebox-calendar.calendar-from").datepicker("setDate",i);n=r.DateTo()?moment(r.DateTo(),"L").format("MM/DD/YYYY"):null;r.$container.find(".js-wkis-datebox-calendar.calendar-to").datepicker("setDate",n);r.SelectPeriod(r.DateFrom()!==r.DateTo());t=r.$container.find(".js-wkis-datebox");t.fadeIn(200);r.$container.find(".js-wkis-datebox-overlay").show();r.updateCalendarUi()};this.hideCalendar=function(){r.$container.find(".js-wkis-datebox").fadeOut(200);r.$container.find(".js-wkis-datebox-overlay").hide()};this.dateFromClick=function(){return r.showCalendar(),!0};this.clearEditionFilter=function(){r.DateFrom("");r.DateTo("")};this.isClearEditionFilterVisible=function(){return r.DateFrom()||r.DateTo()?!0:!1};this.clearEditionFilterClick=function(){r.clearEditionFilter();r.performSearch()};this.$container=n;this.initializeEditionDatePickers(t);this.DatePeriod=ko.computed(function(){return r.DateFrom()});this.performSearch=i}return n}();n.EditionDatesService=a;v=function(){function n(){var n=this;this.decodeUrlParams=function(){for(var t={},r=/\+/g,u=/([^&=]+)=?([^&]*)/g,i=function(n){return decodeURIComponent(n.replace(r," "))},n;;){if(n=u.exec(location.search.substring(1)),!n)break;t[i(n[1])]=n[2].split(",").map(function(n){return i(n)})}return t};this.updateSearchUrlPart=function(t,i,r,u,f,e,o,s,h,c,l){var a="",v=function(n,t){a+=a?"&":"?";a+=encodeURIComponent(n)+"="+encodeURIComponent(t)},k=function(n,t){a+=a?"&":"?";a+=encodeURIComponent(n)+"="+t.map(function(n){return encodeURIComponent(n)}).join(",")},p,y,w,b;for(l&&v("lastdays",l.IndexValue()),i&&v("query",i),r&&v("dateFrom",r),u&&v("dateTo",u),p=n.decodeUrlParams().cm_mmc,p!=null&&k("cm_mmc",[p]),y=0,w=f;y<w.length;y++)b=w[y],k(b.Name,b.Labels);t>1&&v("page",t.toString());e&&e.indexOf(o)>0&&v("resultsPerPage",o.Value.toString());s&&s.indexOf(h)>0&&v("sortBy",h.Value);c&&c!=="all"&&v("topFilter",c);history.replaceState({},null,location.pathname+a+location.hash)};this.loadFromSearchUrlPart=function(t,i,r,u,f,e,o,s,h,c){var l=n.decodeUrlParams(),vt=function(){for(var i=/\+/g,r=/([^&=]+)=?([^&]*)/g,t=function(n){return decodeURIComponent(n.replace(i," "))},n;;){if(n=r.exec(location.search.substring(1)),!n)break;l[t(n[1])]=n[2].split(",").map(function(n){return t(n)})}},p,a,v,ht,w,rt,ct,b,lt,k,ut,ft,d,at,g,et,ot,nt,y,tt;if(vt(),t&&(p=l.query,p&&p.length===1&&t(p[0])),i&&(a=l.cl_Editie,a&&a.length===1)){var it=decodeURIComponent(a[0]).split("/"),yt=it[2].split(" "),st=moment(it[0]+" "+Helpers.String.Capitalize(it[1])+" "+yt[0],"YYYY MMM D");st.isValid()&&i(st.format("D-M-YYYY"))}if(c&&(a=l.lastdays,a&&a.length===1))for(v=0;v<c.Facets().length;v++)c.Facets()[v].IndexValue()==a[0]&&c.Facets()[v].IsChecked(!0);if(u)for(ht=function(n){var t=l[n.Name()],u,i,r,f;if(!t||t.length===0)return"continue";for(u=function(i){for(var l,o,u,s,h,f,c,a,r=0,e=t;r<e.length;r++)if(l=e[r],i.Value()===l){i.IsChecked(!0);break}for(o=!1,u=0,s=i.Children();u<s.length;u++)for(h=s[u],f=0,c=t;f<c.length;f++)if(a=c[f],h.Value()===a){h.IsChecked(!0);o=!0;break}o&&setTimeout(function(){var t="#"+n.Name()+"-filter-accordion-trigger-"+n.Facets().indexOf(i);$(t).toggleClass("-open");$(t).next(".js-wkis-filter-accordion-content").slideToggle(300).toggleClass("-open")})},i=0,r=n.Facets();i<r.length;i++)f=r[i],u(f)},w=0,rt=u;w<rt.length;w++)ct=rt[w],ht(ct);if(e&&(b=l.resultsPerPage,b&&b.length===1))for(lt=b[0],k=0,ut=f;k<ut.length;k++)if(ft=ut[k],ft.Value.toString()===lt){e(ft);break}if(s&&(d=l.sortBy,d&&d.length===1))for(at=d[0],g=0,et=o;g<et.length;g++)if(ot=et[g],ot.Value===at){s(ot);break}return h&&(nt=l.topFilter,nt&&nt.length===1&&h(nt[0])),y=1,tt=l.page,tt&&tt.length===1&&(y=parseInt(tt[0],10),isNaN(y)&&(y=1)),y}}return n}();n.UrlService=v})(t=n.SearchEntities||(n.SearchEntities={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t;(function(n){var b=function(){function n(){}return n}(),r,u,f,e,o,s,h,c,t,l,i,a,v,y,p,w;n.SearchResultItemModel=b;r=function(){function n(){}return n}();n.MsFacetModel=r;u=function(){function n(){}return n}();n.PaFacetModel=u;f=function(){function n(){}return n}();n.TgFacetModel=f;e=function(){function n(){}return n}();n.EventFacetModel=e;o=function(){function n(){}return n}();n.SearchResultItemsByDateModel=o;s=function(){function n(){this.Labels=[]}return n}();n.FacetArg=s;h=function(){function n(){}return n}();n.PressReleaseYearModel=h;c=function(){function n(){}return n}();n.KeyValuePair=c;t=function(){function n(){}return n}();n.ResourceMetaDataItem=t;l=function(){function n(){}return n}();n.SearchParams=l;i=function(){function n(){}return n}();i.MarketSegment="marketSegments";i.PracticeArea="practiceAreas";i.Type="type";n.FacetNames=i;a=function(){function n(){var n=this;this.addResourceMetaDataItem=function(n,t){t.IsSeparator?n.resourceMetaDataItems.length>0&&(n.resourceMetaDataItems[n.resourceMetaDataItems.length-1].IsSeparator||n.resourceMetaDataItems.push(t)):n.resourceMetaDataItems.push(t)};this.addSeparator=function(i){var r=new t;r.IsSeparator=!0;n.addResourceMetaDataItem(i,r)};this.momentMonthDateYearFormat=function(n){return moment(n,"MM-DD-YYYY").format("LL")};this.addDate=function(i){var u,f,r;i.HasMetaDate||i.MetaDateFrom&&(u=new Date(i.MetaDateFrom),f=new Date(0),u>f&&(i.HasMetaDate=!0,i.MetaDate=n.momentMonthDateYearFormat(u)));i.HasMetaDate&&(r=new t,r.IsSeparator=!1,r.Class="wkis-teaser-meta-date",r.Text=i.MetaDate,n.addResourceMetaDataItem(i,r))};this.addTime=function(i){if(i.HasMetaTime){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-time";r.Text=i.MetaTime;n.addResourceMetaDataItem(i,r)}};this.addDuration=function(i){if(!i.HasDuration&&(i.DocumentType==="pastWebinar"||i.ContentTypeDisplayName==="Webinar"||i.ContentTypeDisplayName==="Past Webinar"||i.ContentTypeDisplayName==="Webinars"||i.ContentTypeDisplayName==="Past Webinars")&&i.AdditionalText&&(i.HasDuration=!0,i.MetaDuration=i.AdditionalText),i.HasDuration){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-duration";r.Text=i.MetaDuration;n.addResourceMetaDataItem(i,r)}};this.addAuthors=function(i){if(i.HasAuthors){var r=new t;r.IsSeparator=!1;r.Class="wkis-teaser-meta-author";r.Text=i.Authors;n.addResourceMetaDataItem(i,r)}else n.addDynamicMetaDataItem(i,"dc:contributor","wkis-teaser-meta-author")};this.addDynamicMetaDataItem=function(i,r,u){var f,e;if(i.dynamicLength>0)for(f=0;f<i.dynamicLength;f++)if(i.dynamicFieldArray[f].key===r){e=new t;e.IsSeparator=!1;e.Class=u;e.Text=i.dynamicFieldArray[f].value;n.addResourceMetaDataItem(i,e);return}};this.createResourceMetaDataItems=function(t){if(t.resourceMetaDataItems=[],t.DynamicFields!=null&&t.DynamicFields.length>0&&t.DynamicFields!=="]"?(t.dynamicFieldArray=JSON.parse(t.DynamicFields),t.dynamicLength=t.dynamicFieldArray.length):(t.dynamicFieldArray=[],t.dynamicLength=0),t.ContentTypeDisplayName)switch(t.ContentTypeDisplayName.toLowerCase()){case"news":case"daily news":n.addAuthors(t);n.addSeparator(t);n.addDate(t);break;case"whitepaper":case"whitepapers":case"white paper":case"white papers":n.addAuthors(t);n.addSeparator(t);n.addDate(t);break;case"past webinar":case"past webinars":case"webinar":case"webinars":case"educational webinar":case"educational webinars":case"educational video":case"educational videos":n.addDuration(t);n.addSeparator(t);n.addAuthors(t);n.addSeparator(t);n.addDate(t);n.addSeparator(t);n.addTime(t);break;case"treatise":case"treatises":case"strategic perspective":case"strategic perspectives":case"journal":case"journals":case"journal article":case"journal articles":case"explanation":case"explanations":n.addAuthors(t);n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-journal-title","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t);break;case"case":case"cases":case"law":case"laws":n.addDynamicMetaDataItem(t,"data-court-title","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-court","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-law-section-heading","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-law-section","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"dcterms:title","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-case-number","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-citation","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t);break;case"final rule":case"final rules":case"rule":case"rules":case"regulation":case"regulations":case"form":case"forms":case"agency document":case"agency documents":case"administrative decision":case"administrative decisions":n.addDynamicMetaDataItem(t,"data-issuing-body-title","wkis-teaser-meta-author");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-issuing-body","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"data-citation","wkis-teaser-meta-info");n.addSeparator(t);n.addDynamicMetaDataItem(t,"opt-Decision Number","wkis-teaser-meta-info");n.addSeparator(t);n.addDate(t)}}}return n}();n.ResourceMetaDataMapper=a;v=function(){function n(){this.Text=ko.observable();this.Value=ko.observable();this.HitCount=ko.observable();this.IsChecked=ko.observable();this.Children=ko.observableArray()}return n}();n.FacetModel=v;y=function(){function n(){this.Text=ko.observable();this.Name=ko.observable();this.Facets=ko.observableArray()}return n}();n.FacetContainerModel=y;p=function(){function n(){}return n}();n.FacetResultItem=p;w=function(){function n(){}return n}();n.FacetResult=w})(t=n.SearchResultEntities||(n.SearchResultEntities={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.ColumnistsLandingViewModel,t)},t}();t.ColumnistsLandingPageInitializer=i})(t=n.Initializer||(n.Initializer={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.EloquaFormViewModel(t),t)},t}();t.EloquaFormInitializer=i})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"filter"),u=i.GetUrlParam(window.location.href,"query"),f=i.GetUrlParam(window.location.href,"ms"),e=i.GetUrlParam(window.location.href,"pa"),o=i.GetUrlParam(window.location.href,"type");ko.applyBindings(new n.ViewModel.EventsLandingViewModel(t,r,u,f,e,o),t)},t}();t.EventsLandingInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(){}return n.prototype.Initialize=function(n){this.InitializeReadMoreButton(n)},n.prototype.InitializeReadMoreButton=function(n){var t=$(".js-wkis-seo-more-content.wkis-global-type-styles",n),u=$(".js-wkis-seo-more-action",n),i,r,f;if(t.length&&u.length){i=$("p",t).toArray();r=0;for(f in i)r+=$(i[f]).outerHeight(!0);r<parseInt(t.css("height"))&&u.hide()}},n}();n.ExpandedContentInitializer=t})(t=n.Initializer||(n.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"ms"),u=i.GetUrlParam(window.location.href,"pa"),f=i.GetUrlParam(window.location.href,"query"),e=i.GetUrlParam(window.location.href,"resultsPerPage"),o=i.GetUrlParam(window.location.href,"page");ko.applyBindings(new n.ViewModel.ExpertsLandingViewModel(t,f,r,u,e,o),t)},t}();t.ExpertsLandingPageInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.KlLandingViewModel(t),t)},t}();t.KlLandingInitializer=i})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=Helpers.UrlHelper,r=function(){function t(){}return t.prototype.Initialize=function(t){var r=i.GetUrlParam(window.location.href,"resultsPerPage"),u=i.GetUrlParam(window.location.href,"page");ko.applyBindings(new n.ViewModel.PressReleasesLandingViewModel(t,r,u),t)},t}();t.PressReleasesLandingPageInitializer=r})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.RelevantProductsProductsViewModel(t),t)},t}();t.RelevantProductsInitializer=i})(t=n.Initializer||(n.Initializer={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.SearchListViewModel(t),t)},t}();t.SearchListInitializer=i})(t=n.Initializer||(n.Initializer={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i;(function(t){var i=function(){function t(){}return t.prototype.Initialize=function(t){ko.applyBindings(new n.ViewModel.SearchResultsViewModel(t),t)},t}();t.SearchResultsPageInitializer=i})(i=t.Initializer||(t.Initializer={}))})(t=n.Entities||(n.Entities={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(){var t=this,i,r;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.SearchString=ko.observable();this.CurrentSearchString=ko.observable();this.ResultsPerPage=ko.observable();this.ResultsPerPageList=ko.observableArray();this.Facets=ko.observableArray();this.SelectedFacet=ko.observable();this.Rows=ko.observableArray();this.TotalRowsCount=ko.observable(-1);this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.searchInputKeyUp=function(n,i){i.keyCode===13&&t.performSearch()};this.performSearchClick=function(){return t.performSearch(),!0};this.performSearch=function(n){var i=++t.loadCounter,r;n==null&&(n=1);r={IndexType:"columnist",Language:document.documentElement.lang.substr(0,2),QueryStr:t.SearchString(),PageSize:t.ResultsPerPage().Value,Page:n,SortBy:"title-az",Facets:t.getFacets()};i===1&&(r.ReturnFacets=[t.facetName]);i!==1&&t.updateSearchUrlPart(n);t.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){if(i===1&&t.removeEmptyFacets(n.Facets),i===1&&location.search)t.loadFromSearchUrlPart();else{if(i!==t.loadCounter)return;t.IsLoading(!1);t.CurrentSearchString(r.QueryStr);t.Rows(n.Rows);t.TotalRowsCount(n.TotalRowsCount);t.Page(n.Page);t.PagesCount(n.PagesCount)}}})};this.removeEmptyFacets=function(n){for(var e=function(n){for(var u={},r,t=0,i=n;t<i.length;t++)r=i[t],u[r.Label]=r.HitCount;return u},o=function(n,t){for(var f=[],r,e,i=0,u=n();i<u.length;i++)r=u[i],e=t[r.Value],(e||r.Value===null)&&f.push(r);n(f)},u,f,i=0,r=n;i<r.length;i++)u=r[i],f=e(u.Items),u.Name===t.facetName&&o(t.Facets,f)};this.getFacets=function(){var u=[],r=t.SelectedFacet(),i;return r!=null&&r.Value!=null&&(i=new n.Entities.SearchEntities.FacetArg,i.Name=t.facetName,i.Labels.push(r.Value),u.push(i)),u};this.decodeUrlParams=function(){for(var t={},r=/\+/g,u=/([^&=]+)=?([^&]*)/g,i=function(n){return decodeURIComponent(n.replace(r," "))},n;;){if(n=u.exec(location.search.substring(1)),!n)break;t[i(n[1])]=n[2].split(",").map(function(n){return i(n)})}return t};this.updateSearchUrlPart=function(n){var i="",r=function(n,t){i+=i?"&":"?";i+=encodeURIComponent(n)+"="+encodeURIComponent(t)},e=function(n,t){i+=i?"&":"?";i+=encodeURIComponent(n)+"="+t.map(function(n){return encodeURIComponent(n)}).join(",")},f,u;t.SearchString()&&r("query",t.SearchString());f=t.decodeUrlParams().cm_mmc;f!=null&&e("cm_mmc",[f]);u=t.SelectedFacet();u&&u.Value!=null&&r(t.facetName,u.Value);n>1&&r("page",n.toString());t.ResultsPerPageList().indexOf(t.ResultsPerPage())>0&&r("resultsPerPage",t.ResultsPerPage().Value.toString());history.replaceState({},null,location.pathname+i+location.hash)};this.loadFromSearchUrlPart=function(){var n=t.decodeUrlParams(),p=function(){for(var r=/\+/g,u=/([^&=]+)=?([^&]*)/g,i=function(n){return decodeURIComponent(n.replace(r," "))},t;;){if(t=u.exec(location.search.substring(1)),!t)break;n[i(t[1])]=t[2].split(",").map(function(n){return i(n)})}},r,u,v,f,h,c,i,e,o,y,s,l,a;if(p(),r=n.query,r&&r.length===1&&t.SearchString(r[0]),u=n[t.facetName],u&&u.length===1)for(v=u[0],f=0,h=t.Facets();f<h.length;f++)if(c=h[f],c.Value===v){t.SelectedFacet(c);break}if(i=1,e=n.page,e&&e.length===1&&(i=parseInt(e[0],10),isNaN(i)&&(i=1)),o=n.resultsPerPage,o&&o.length===1)for(y=o[0],s=0,l=t.ResultsPerPageList();s<l.length;s++)if(a=l[s],a.Value.toString()===y){t.ResultsPerPage(a);break}t.performSearch(i)};this.incrementPageClick=function(){var n=t.Page()+1;n<=t.PagesCount()&&(t.performSearch(n),t.scrollToTop())};this.decrementPageClick=function(){var n=t.Page()-1;n>0&&(t.performSearch(n),t.scrollToTop())};this.scrollToTop=function(){var n=$(".wkis-our-experts-filter-section").offset();$("html, body").animate({scrollTop:n.top})};i=function(){t.ResultsPerPageList([{Text:"10",Value:10},{Text:"20",Value:20},{Text:"50",Value:50},{Text:"80",Value:80},{Text:"110",Value:110}]);t.ResultsPerPage(t.ResultsPerPageList()[0])};i();r=function(){var i=window.InitialPageJsonModel,n,r,u;for(t.Facets.push({Text:i.FacetDropDownText,Value:null}),n=0,r=i.FacetContainer.Facets;n<r.length;n++)u=r[n],t.Facets.push(u);t.facetName=i.FacetContainer.Name};r();this.performSearch()}return t}();t.ColumnistsLandingViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={}));AccountInfoModel=Entities.AccountInfoModels.AccountInfoModel,function(n){var t;(function(n){var t=function(){function n(n){var t=this;this.processSuccess=function(n,i){t.submitDisabled=ko.observable(!1);t.isModal&&($(".js-wkis-modal").removeClass("-is-open"),$("html").removeClass("-js-modal-open"));t.saveFieldsToSessionStorage(i);t.isContentLocked?t.showLockedContent():t.postToNewWindow||t.showSuccessModal()};this.showIFrameModal=function(n){var t=$(".js-wkis-modal[data-modal='modal-iframe']"),i=t.find("iframe");i.attr("src",n);t.addClass("-is-open");$("html").addClass("-js-modal-open")};this.showSuccessModal=function(){t.successModalUserLoggedIn&&t.successModalUserLoggedIn.length>0&&t.userIsLoggedIn()?t.showModal(t.successModalUserLoggedIn):t.successModal&&t.successModal.length>0?t.showModal(t.successModal):t.showGenericModal("success",t.eloquaFormSuccessMessage,null);$("html, body").animate({scrollTop:0},300)};this.processLockedContentResult=function(n){var i,r;if(n&&n.FullContent&&n.FullContent.length>0){if(i=$("div.wkis-content-locked"),i.remove(),r=$('div[name="gated-content-article-body"]'),r.replaceWith(n.FullContent),t.showSuccessModal(),$("a.metadataLink.osa-doc-metadata-link")&&$("a.metadataLink.osa-doc-metadata-link").length===1&&$("a.metadataLink.osa-doc-metadata-link").children().length===2&&$("div.osa-doc-metadata")&&$("div.osa-doc-metadata").length===1)$("a.metadataLink.osa-doc-metadata-link").on("click",function(){var n=$("div.osa-doc-metadata").is(":visible");n?($("a.metadataLink.osa-doc-metadata-link").children().first().show(),$("a.metadataLink.osa-doc-metadata-link").children().last().hide(),$("div.osa-doc-metadata").hide()):($("a.metadataLink.osa-doc-metadata-link").children().first().hide(),$("a.metadataLink.osa-doc-metadata-link").children().last().show(),$("div.osa-doc-metadata").show())})}else t.showGenericModal("failed","Gated content not available.",null)};this.showLockedContent=function(){var n=$('div[name="gated-content-article-body"]'),i=n.attr("gated-content-id"),r="/Umbraco/Api/GatedContentApi/GetGatedContent?gatedContentId="+i,u=t;$.ajax({type:"GET",url:r,contentType:"application/json",dataType:"json",success:function(n){u.processLockedContentResult(n)},error:function(){this.showGenericModal("failed","Failed to loaded gated content.",null)}})};this.showModal=function(n){$(".js-wkis-modal[data-modal='"+n+"']").addClass("-is-open");$("html").addClass("-js-modal-open")};this.checkRedirectUrlResult=function(n){var r,u,i,t;return n&&n.length>0&&n.indexOf("document.location.href")>0&&(r=n.substr(n.indexOf("document.location.href")),u=r.indexOf("http"),u>0&&((i=r.substr(u),t=i.indexOf("'"),t>0)||(t=i.indexOf('"'),t>0)))?i.substr(0,t):""};this.submitForm=function(){var n=t,i;t.checkFormValid()?(n.formData=t.eloquaForm.serializeArray(),t.postToNewWindow?(n.processSuccess("",n.formData),t.eloquaForm.submit()):(i=t.eloquaForm.attr("action"),$.ajax({url:i,type:"POST",dataType:"html",cache:!1,data:n.formData,beforeSend:function(){n.submitDisabled=ko.observable(!0)},success:function(t){var i=n.checkRedirectUrlResult(t);n.processSuccess(i,n.formData)},error:function(){n.processSuccess("",n.formData)}}))):t.isInline&&t.displayInlineValidations()};this.getValidator=function(n,i){var r="ko-error-text[for='"+n+"'][rule='"+i+"']";return t.eloquaForm.find(r)};this.validateOnBlur=function(n){t.performedValidationOnce&&t.validateElement(n.target)};this.validateElement=function(n){var u=t.failsRequired(n),i,r;return u?!1:(i=t.failsEmail(n),i)||(r=t.failsMinimumLength(n),r)?!1:!0};this.checkFormValid=function(){var u=window.validations,r=!0,n,i;return u.forEach(function(n){var u=n.key,f=n.value,t=n.link,i;(t===""||t==null)&&(t="#");i=$("[type='checkbox'][name="+n.key+"]");i.parent("div").siblings("a.error-text[for='"+u+"']").remove();i[0].value!=="true"&&(r=!1,i.parent("div").after("<a for='"+u+"' rule='required' class='error-text' style='visibility: visible; display: inline; opacity: 1;' href='"+t+"'>"+f+"<\/a>"))}),n=t.eloquaForm.find("[hasvalidation]"),t.inlineValidations=[],t.performedValidationOnce||t.isInline||(t.performedValidationOnce=!0,n.blur(t.validateOnBlur)),i=!0,n.each(function(n,u){var f=t.validateElement(u);f&&r||(i=!1)}),i};this.failsRequired=function(n){var i=t.getValidator(n.name,"required"),f,r,u;if(i&&i.length===1){if(f=n.value,n.type==="select-one"&&(n.selectedIndex>0||(f=!1)),n.type==="select-multiple"){for(r=[],u=0;u<n.length;u++)n.options[u].selected&&r.push(u);f=r.length>0&&!(r.length===1&&r[0]===0)}return f?(t.hide(i),!1):(t.isInline?t.pushValidatorText(i):t.show(i),!0)}return!1};this.failsEmail=function(n){var i=t.getValidator(n.name,"email"),r;return i&&i.length===1?(r=n.value,r&&/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(r))?(t.hide(i),!1):(t.isInline?t.pushValidatorText(i):t.show(i),!0):!1};this.failsMinimumLength=function(n){var i=t.getValidator(n.name,"minlength"),r,u;return i&&i.length===1?(r=n.value,u=r.attr("minlength"),r&&r.length>=u)?(t.hide(i),!1):(t.isInline?t.pushValidatorText(i):t.show(i),!0):!1};this.showGenericModal=function(n,t,i){var u=$("div.js-wkis-dialog-box.-generic-modal"),f=u.find("div.js-wkis-alert-message"),r,e;f.attr("data-type",n);r=u.find("div.wkis-eyebrow");i!==null?r.text(i):r.text(r.attr(n));e=u.find(".js-wkis-alert-message-text");e.html(t);$("html").toggleClass("-dialog-open");f.css({opacity:1,transition:"opacity 0.3s"}).slideDown(300)};this.hide=function(n){n.css("visibility","hidden");n.css("opacity","0");n.fadeOut("fast")};this.show=function(n){n.css("visibility","visible");n.css("opacity","1");n.fadeIn("fast")};this.pushValidatorText=function(n){var i=n.html();t.inlineValidations.push(i)};this.displayInlineValidations=function(){var n="";t.inlineValidations.forEach(function(t){n+="<p>"+t+"<\/p>"});t.showGenericModal("failed",n,null)};this.saveFieldsToSessionStorage=function(n){var f,r,u,h,c,i;if(window.sessionStorage){for(f=new Date,window.sessionStorage.setItem("LastEloquaSaveTime",f.getMilliseconds().toString()),r=0,u=n;r<u.length;r++){var e=u[r],o=e.name,s=t.eloquaForm.find("input[type='hidden'][name='"+o+"']");s&&s.length!==0||(h=e.value,window.sessionStorage.setItem("EloquaField_"+o,h))}c=t.eloquaForm.find("[user-field-map]");i=new AccountInfoModel;c.each(function(n,t){var r=$(t),u=r.attr("user-field-map");if(u)switch(u){case"Email":i.Email=r.val();break;case"FirstName":i.FirstName=r.val();break;case"LastName":i.LastName=r.val();break;case"PhoneNumber":i.PhoneNumber=r.val()}});window.sessionStorage.setItem("EloquaAccountInfoModel",JSON.stringify(i))}};this.userIsLoggedIn=function(){return!!$.cookie(Constants.Global.UserTokenCookieKey)};this.getUserAccountInfo=function(){var s,n,f,i,c;if(window.sessionStorage){var o=window.sessionStorage.getItem("LastEloquaSaveTime"),r=!1,u=!1;if(u||r||(o&&o.toString().length>0?r=!0:t.userIsLoggedIn()&&(u=!0)),u)Services.UserServices.GetUserInfo().done(function(n){if(n&&n.value){var i=n.value[0];t.mapUserAccountInfo(i)}});else if(r)for(s=t.eloquaForm.serializeArray(),n=0,f=s;n<f.length;n++){var l=f[n],e=l.name,h=t.eloquaForm.find("input[type='hidden'][name='"+e+"']");h&&h.length!==0||(i=window.sessionStorage.getItem("EloquaField_"+e),i&&i.toString().length>0&&(c=t.eloquaForm.find("[name='"+e+"']"),c.val(i.toString())))}}};this.mapUserAccountInfo=function(n){if(n){var i=t.eloquaForm.find("[user-field-map]");i.each(function(t,i){var r=$(i),u=r.attr("user-field-map");if(u)switch(u){case"Email":r.val(n.Email);r.val()&&r.attr("disabled","disabled");break;case"FirstName":r.val(n.FirstName);break;case"LastName":r.val(n.LastName);break;case"PhoneNumber":r.val(n.PhoneNumber)}})}};this.$container=$(n);this.eloquaForm=this.$container.find("form");this.submitDisabled=ko.observable(!1);this.isModal=this.eloquaForm.attr("is-on-modal")==="true";this.isInline=this.eloquaForm.attr("is-inline")==="true";this.postToNewWindow=this.eloquaForm.attr("target")==="_blank";this.isContentLocked=this.eloquaForm.attr("is-content-locked")==="true";this.successModal=this.eloquaForm.attr("success-modal");this.successModalUserLoggedIn=this.eloquaForm.attr("success-modal-user-logged-in");this.performedValidationOnce=!1;this.eloquaFormSuccessMessage=this.$container.find("div.-eloquaFormSuccessMessage").html();this.eloquaFormFailMessage=this.$container.find("div.-eloquaFormFailMessage").html();this.getUserAccountInfo()}return n}();n.EloquaFormViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(t,i,r,u,f,e){var o=this,c,h,a,s,l,v;this.initDatePicker=function(){var t=[],i,n,r;for(t.push(moment().isoWeekday(7).format("dd")),n=1;n<=6;n++)t.push(moment().isoWeekday(n).format("dd"));for(i=[],n=0;n<12;n++)r=moment().month(n).format("MMMM"),i.push(r);$(".js-wkis-datebox-calendar").datepicker({numberOfMonths:1,dayNamesMin:t,monthNames:i,nextText:'Next<span class="wkis-icon-arrow-right"><\/span>',prevText:'<span class="wkis-icon-arrow-left"><\/span>Previous',dateFormat:"dd/mm/yy",showOtherMonths:!0,selectOtherMonths:!0,onSelect:function(n){o.SelectedDate(moment(n,"DD/MM/YYYY").format("D-M-YYYY"))}});$(".js-wkis-datebox-trigger").on("click",function(n){n.preventDefault();$(".js-wkis-datebox").fadeIn(200);o.SelectedDate(moment(o.SearchDate(),"D-M-YYYY").format("D-M-YYYY"));var t=o.SelectedDate()?moment(o.SelectedDate(),"D-M-YYYY").format("DD/MM/YYYY"):null;$(".js-wkis-datebox-calendar").datepicker("setDate",t);$(".js-wkis-datebox-overlay").show()});$("html").on("click",".js-wkis-datebox-close, .js-wkis-datebox-overlay",function(){$(".js-wkis-datebox").fadeOut(200);$(".js-wkis-datebox-overlay").hide()}).on("keyup",function(n){n.keyCode===27&&($(".js-wkis-datebox").fadeOut(200),$(".js-wkis-datebox-overlay").hide())}).on("click",".js-wkis-datebox-action button",function(){$(".js-wkis-datebox-input input").val()!==""&&($(".js-wkis-datebox").fadeOut(200),$(".js-wkis-datebox-overlay").hide(),$(".js-wkis-events-see-all").fadeIn(300))});$(".wkis-events-calendar-header-months a").on("click",function(n){n.preventDefault();$(".js-wkis-events-see-all").fadeOut(300)})};this.onSearchButtonClick=function(){if(!o.OnInit){o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.ShowMonthByDaysPagination(!1);o.ShowFullMonthPagination(!1);o.ShowDayPagination(!0);var n=$("#seealllink");n.show();o.SearchDate(moment(o.SelectedDate(),"D-M-YYYY").format("D-M-YYYY"));o.performSearch()}};this.getMonthResults=function(){o.SeeAllMonthEvents=!0;o.ShowFullMonthPagination(!0);o.ShowMonthByDaysPagination(!1);o.ShowDayPagination(!1);o.setMonthPagination();var n=$("#seealllink");n.hide();o.performSearch()};this.setMonthPagination=function(){var n=$("#limitmonthbydays"),t,i,r;n&&(t=n.attr("limitbydays"),t==="limitbydays"&&(i=n.attr("noofdays"),r=parseInt(i),o.PageSize=r,o.ShowFullMonthPagination(!1),o.ShowMonthByDaysPagination(!0)))};this.momentDayFormat=function(n){return moment(n,"D-M-YYYY").format("dddd")};this.momentMonthDateFormat=function(n){return moment(n,"D-M-YYYY").format("D")+" "+moment(n,"D-M-YYYY").format("MMMM")};this.momentSelectedMonth=function(n){return moment(n,"D-M-YYYY").format("MMMM")};this.momentSelectedYear=function(n){return moment(n,"D-M-YYYY").format("YYYY")};this.moveToNextMonth=function(){o.SearchDate(moment(o.SearchDate(),"D-M-YYYY").add(1,"months").startOf("month").format("D-M-YYYY"));o.getMonthResults()};this.moveToPreviousMonth=function(){o.SearchDate(moment(o.SearchDate(),"D-M-YYYY").subtract(1,"months").startOf("month").format("D-M-YYYY"));o.getMonthResults()};this.marketSegmentSelected=function(n){o.SelectedMarketSegment(n);o.SelectedPracticeArea("");o.performSearch()};this.practiceAreaSelected=function(n){o.SelectedPracticeArea(n);o.performSearch()};this.eventTypeSelected=function(n){return o.SelectedEventType(n),o.performSearch(),!0};this.clearFilters=function(){(o.SelectedEventType()||o.SelectedMarketSegment()||o.SelectedPracticeArea())&&(o.SelectedEventType(""),o.SelectedMarketSegment(""),o.SelectedPracticeArea(""),o.performSearch())};this.movePage=function(n){var r,t,i,u;for(o.RequestedPage=o.CurrentPage()+n,r=o.SearchResultItemsByDatePerPage().length,t=0;t<r;t++)o.SearchResultItemsByDatePerPage.pop();o.PageSize*o.RequestedPage-o.SearchResultItemsByDate().length>0?o.CurrentResultsPerPage(o.PageSize*o.RequestedPage-o.SearchResultItemsByDate().length):o.CurrentResultsPerPage(o.PageSize);i=o.PageSize*(o.RequestedPage-1);u=i+o.CurrentResultsPerPage();ko.utils.arrayForEach(o.SearchResultItemsByDate.slice(i,u),function(n){return o.SearchResultItemsByDatePerPage.push(n)});o.CurrentPage(o.RequestedPage)};this.incrementPage=function(){o.movePage(1)};this.decrementPage=function(){o.movePage(-1)};this.previousDaySelected=function(){o.SearchDate(moment(o.SearchDate(),"D-M-YYYY").subtract(1,"days").format("D-M-YYYY"));o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.performSearch()};this.nextDaySelected=function(){o.SearchDate(moment(o.SearchDate(),"D-M-YYYY").add(1,"days").format("D-M-YYYY"));o.SeeAllMonthEvents=!1;o.SeeRestOfTheMonthEvents=!1;o.performSearch()};this.performSearch=function(){var i,f,e,s,r,u,l,a;o.SearchDateFromForQuery(moment(o.SearchDate(),"D-M-YYYY").format());o.SearchDateToForQuery(moment(o.SearchDate(),"D-M-YYYY").endOf("day").format());o.SeeAllMonthEvents&&(o.SearchDateFromForQuery(moment(o.SearchDate(),"D-M-YYYY").startOf("month").format()),o.SearchDateToForQuery(moment(o.SearchDate(),"D-M-YYYY").endOf("month").format()));o.SeeRestOfTheMonthEvents&&o.SearchDateToForQuery(moment(o.SearchDate(),"D-M-YYYY").endOf("month").format());i=[];o.SelectedEventType()&&(f=new n.Entities.SearchResultEntities.FacetArg,f.Name="eventCategories",f.Labels=[o.SelectedEventType()],i.push(f));o.SelectedMarketSegment()&&(e=new n.Entities.SearchResultEntities.FacetArg,e.Name="marketSegments",e.Labels=[o.SelectedMarketSegment()],i.push(e));o.SelectedPracticeArea()&&(s=new n.Entities.SearchResultEntities.FacetArg,s.Name="practiceAreas",s.Labels=[o.SelectedPracticeArea()],i.push(s));var t="",v=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+encodeURIComponent(i)},c=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+i.map(function(n){return encodeURIComponent(n)}).join(",")},h=ko.utils.arrayFirst(i,function(n){return n.Name==="marketSegments"});h&&h.Labels&&h.Labels.length>0&&c("ms",h.Labels);r=ko.utils.arrayFirst(i,function(n){return n.Name==="practiceAreas"});r&&r.Labels&&r.Labels.length>0&&c("pa",r.Labels);u=ko.utils.arrayFirst(i,function(n){return n.Name==="eventCategories"});u&&u.Labels&&u.Labels.length>0&&c("type",u.Labels);history.replaceState({},null,location.pathname+t+location.hash);l={IndexType:"event",Language:document.documentElement.lang.substr(0,2),Facets:i,MetaDateFrom:o.SearchDateFromForQuery(),MetaDateTo:o.SearchDateToForQuery(),PageSize:1e4};a=o;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(l),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){a.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(t){var u,r,i,e,f,s;if(o.SearchResultItemsByDate([]),o.SearchResultItemsByDatePerPage([]),o.CurrentResultsSearchDate(o.SearchDateForQuery),o.TotalRowsCount(t.TotalRowsCount),t.TotalRowsCount>0){for(o.NoResults(!1),u=0;u<t.TotalRowsCount;u++)for(r=t.Rows[u],i=moment(r.MetaDateFrom);i.diff(r.MetaDateTo,"days")<=0;i.add(1,"days"))i.isBetween(o.SearchDateFromForQuery(),o.SearchDateToForQuery(),null,"[]")&&(e=ko.utils.arrayFirst(o.SearchResultItemsByDate(),function(n){return n.Date===i.format("D-M-YYYY")}),e?e.ResultItems.push(r):(f=new n.Entities.SearchResultEntities.SearchResultItemsByDateModel,f.Date=i.format("D-M-YYYY"),f.ResultItems=[r],o.SearchResultItemsByDate.push(f)));o.SeeAllMonthEvents||o.SeeRestOfTheMonthEvents?(o.SearchResultItemsByDate.sort(function(n,t){return n.Date===t.Date?0:n.Date>t.Date?1:-1}),o.ShowFullMonthPagination()||!o.ShowFullMonthPagination()&&o.SearchResultItemsByDate().length<=o.PageSize?(o.SearchResultItemsByDatePerPage(o.SearchResultItemsByDate()),o.TotalPages(1)):(o.SearchResultItemsByDatePerPage(o.SearchResultItemsByDate.slice(0,o.PageSize)),o.TotalPages(Math.ceil(o.SearchResultItemsByDate().length/o.PageSize)),console.log("this by day"),console.log(o.SearchResultItemsByDate()),console.log(o.PageSize),console.log(o.SearchResultItemsByDatePerPage()))):(s=ko.utils.arrayFirst(o.SearchResultItemsByDate(),function(n){return n.Date===moment(o.SearchDate(),"D-M-YYYY").format("D-M-YYYY")}),s&&o.SearchResultItemsByDatePerPage.push(s),o.TotalPages(1));o.CurrentPage(1)}else o.TotalPages(0),o.ShowMonthByDaysPagination(!1),o.NoResults(!0),o.CurrentPage(0)};this.$container=$(t);this.OnInit=!0;this.RequestedPage=0;this.SearchDateForQuery="";this.CurrentResultsSearchDate=ko.observable("");this.NoResults=ko.observable(!0);this.SearchResultItems=ko.observableArray([]);this.SearchResultItemsByDate=ko.observableArray([]);this.SearchResultItemsByDatePerPage=ko.observableArray([]);this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.SelectedMarketSegment=ko.observable("");this.SelectedPracticeArea=ko.observable("");this.SelectedEventType=ko.observable("");this.SeeAllMonthEvents=!0;this.SeeRestOfTheMonthEvents=!0;this.PreventPASubscription=!1;this.PageSize=1;this.CurrentResultsPerPage=ko.observable(0);this.SearchDateFromForQuery=ko.observable("");this.SearchDateToForQuery=ko.observable("");this.ShowMonthByDaysPagination=ko.observable(!1);this.ShowFullMonthPagination=ko.observable(!0);this.ShowDayPagination=ko.observable(!1);this.SelectedDate=ko.observable(moment().format("D-M-YYYY"));this.setMonthPagination();this.SearchDate=ko.observable(moment().format("D-M-YYYY"));u!=null&&u.length>0&&(u=decodeURIComponent(u).replace("#",""),c=u.split(","),c.length>0&&(s=c[0],this.SelectedMarketSegment(s)));f!=null&&f.length>0&&(f=decodeURIComponent(f).replace("#",""),h=f.split(","),h.length>0&&(a=h[0],s=$("#"+h[0]).attr("parent-ms-facet"),s&&this.SelectedMarketSegment(s),this.SelectedPracticeArea(a)));e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),l=e.split(","),l.length>0&&(v=l[0],this.SelectedEventType(v)));this.OnInit=!1;this.SelectedMarketSegment.subscribe(function(){o.PreventPASubscription=!0;o.SelectedPracticeArea("");o.PreventPASubscription=!1;o.performSearch()});this.SelectedPracticeArea.subscribe(function(){o.PreventPASubscription||o.performSearch()});this.SelectedEventType.subscribe(function(){o.performSearch()});this.initDatePicker();this.performSearch()}return t}();t.EventsLandingViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(t,i,r,u,f,e){var o=this,c,h,l,s;this.enterSearch=function(n,t){return t.keyCode===13&&o.performSearch(),!0};this.movePage=function(n){o.RequestedPage=o.CurrentPage()+n;o.performSearch()};this.incrementPage=function(){o.movePage(1)};this.decrementPage=function(){o.movePage(-1)};this.clickSearchIcon=function(){o.performSearch()};this.performSearch=function(){var s,i,r,u,f,e,l,a;o.SearchTermForQuery=o.SearchTerm();s=o.RequestedPage>0?o.RequestedPage:1;o.RequestedPage=0;i=[];o.MarketSegmentFacet()!=null&&o.MarketSegmentFacet().length>0&&(r=new n.Entities.SearchResultEntities.FacetArg,r.Name="marketSegments",r.Labels=[],r.Labels.push(o.MarketSegmentFacet()),i.push(r),o.PracticeAreaFacet()!=null&&o.PracticeAreaFacet().length>0&&(u=new n.Entities.SearchResultEntities.FacetArg,u.Name="practiceAreas",u.Labels=[],u.Labels.push(o.PracticeAreaFacet()),i.push(u)));var t="",h=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+encodeURIComponent(i)},c=function(n,i){t+=t?"&":"?";t+=encodeURIComponent(n)+"="+i.map(function(n){return encodeURIComponent(n)}).join(",")};o.SearchTerm()&&h("query",o.SearchTerm());o.ResultsPerPage()&&o.ResultsPerPage()!==o.DefaultResultsPerPage&&h("resultsPerPage",o.ResultsPerPage());s>1&&h("page",s.toString());f=ko.utils.arrayFirst(i,function(n){return n.Name==="marketSegments"});f&&f.Labels&&f.Labels.length>0&&c("ms",f.Labels);e=ko.utils.arrayFirst(i,function(n){return n.Name==="practiceAreas"});e&&e.Labels&&e.Labels.length>0&&c("pa",e.Labels);history.replaceState({},null,location.pathname+t+location.hash);l={IndexType:o.SelectedTopFilter(),Language:document.documentElement.lang.substr(0,2),QueryStr:o.SearchTermForQuery,PageSize:o.ResultsPerPage(),Page:s,SortBy:o.SortBy(),Facets:i};a=o;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(l),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){a.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(n){o.CurrentResultsSearchTerm(o.SearchTermForQuery);o.TotalRowsCount(n.TotalRowsCount);n.TotalRowsCount>0?(o.TotalPages(n.PagesCount),o.ShowPagination(n.PagesCount>1),o.NoResults(!1),o.CurrentPage(n.Page),o.SearchResultItems(n.Rows)):(o.TotalPages(0),o.ShowPagination(!1),o.NoResults(!0),o.CurrentPage(0),o.SearchResultItems([]))};this.$container=$(t);this.OnInit=!0;this.RequestedPage=0;this.NoResults=ko.observable(!0);this.SearchTerm=ko.observable("");this.SearchResultItems=ko.observableArray([]);this.SearchTermForQuery="";this.CurrentResultsSearchTerm=ko.observable("");this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.ShowPagination=ko.observable(!1);this.OnMarketSegmentChange=!1;r!=null&&r.length>0?(this.MarketSegmentFacet=ko.observable(r),this.PracticeAreaFacet=u!=null&&u.length>0?ko.observable(u):ko.observable("")):(this.MarketSegmentFacet=ko.observable(""),this.PracticeAreaFacet=ko.observable(""));this.ValidResultsPerPage=["10","50","100","150","200"];this.DefaultResultsPerPage="10";this.ResultsPerPage=f!=null&&f.length>0&&this.ValidResultsPerPage.indexOf(f)>-1?ko.observable(f):ko.observable(this.DefaultResultsPerPage);this.SortBy=ko.observable("title-az");this.SelectedTopFilter=ko.observable("expert");i!=null&&i.length>0&&(i=decodeURIComponent(i).replace("#",""),this.SearchTerm=ko.observable(i));e!=null&&e.length>0&&(e=decodeURIComponent(e).replace("#",""),this.RequestedPage=parseInt(e));r!=null&&r.length>0&&(r=decodeURIComponent(r).replace("#",""),c=r.split(","),c.length>0&&(s=c[0],this.MarketSegmentFacet(s)));u!=null&&u.length>0&&(u=decodeURIComponent(u).replace("#",""),h=u.split(","),h.length>0&&(l=h[0],s=$("#"+h[0]).attr("parent-ms-facet"),s&&this.MarketSegmentFacet(s),this.PracticeAreaFacet(l)));this.ResultsPerPage.subscribe(function(){o.TotalRowsCount()>0&&o.performSearch()});this.MarketSegmentFacet.subscribe(function(){o.OnMarketSegmentChange=!0;o.PracticeAreaFacet("");o.performSearch();o.OnMarketSegmentChange=!1});this.PracticeAreaFacet.subscribe(function(){o.OnMarketSegmentChange||o.performSearch()});this.ResultsPerPage.extend({rateLimit:50});this.OnInit=!1;this.performSearch()}return t}();i.isNaNModified=function(n){var t=parseFloat(n);return isNaN(t)||t.toString().length!=n.length};t.ExpertsLandingViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.ResourceMetaDataMapper,r=function(){function t(t){var r=this,u,f,e,o;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.SearchString=ko.observable();this.ResultsPerPage=ko.observable();this.ResultsPerPageList=ko.observableArray();this.SortBy=ko.observable();this.SortByList=ko.observableArray();this.TotalRowsCount=ko.observable(-1);this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.Rows=ko.observableArray();this.NoResults=ko.observable(!1);this.performSearch=function(t){var l=++r.loadCounter,i,f,h,e,c,u,o,s,a,v;for(t==null&&(t=1),i={IndexType:"resource",Language:document.documentElement.lang.substr(0,2),QueryStr:r.SearchString(),PageSize:r.ResultsPerPage().Value,Page:t,SortBy:r.SortBy().Value,Facets:[],ReturnFacets:r.FacetsService.Facets().map(function(n){return n.Name()})},f=0,h=r.searchArgs.Facets;f<h.length;f++)u=h[f],i.Facets.push(u);for(e=0,c=r.FacetsService.getFacets();e<c.length;e++)u=c[e],i.Facets.push(u);r.EditionDates.DateFrom()&&(o=moment(r.EditionDates.DateFrom(),"DD-MM-YYYY"),s=new n.Entities.SearchEntities.FacetArg,s.Name="cl_Editie",s.Labels.push(o.format("YYYY")+"/"+o.format("MMMM")+"/"+o.format("D MMMM").toLowerCase()),i.Facets.push(s));a="";v="";l!==1&&r.UrlService.updateSearchUrlPart(t,i.QueryStr,a,v,i.Facets,r.ResultsPerPageList(),r.ResultsPerPage(),r.SortByList(),r.SortBy(),null);r.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(i),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){l===r.loadCounter&&(r.FacetsService.updateFacetsHitCount(n.Facets),r.IsLoading(!1),r.processRows(n.Rows),r.Rows(n.Rows),r.NoResults(n.Rows.length===0),r.TotalRowsCount(n.TotalRowsCount),r.Page(n.Page),r.PagesCount(n.PagesCount),$("html").removeAttr("data-loading"))}})};this.clearAllFiltersClick=function(){r.SearchString("");r.FacetsService.clearAllFilters();r.EditionDates.clearEditionFilter();r.performSearch()};this.isClearAllFiltersVisible=function(){return r.SearchString()?!0:r.FacetsService.isClearAllFiltersVisible()?!0:r.EditionDates.isClearEditionFilterVisible()?!0:!1};this.searchInputKeyUp=function(n,t){t.keyCode===13&&r.performSearch()};this.performSearchClick=function(){return r.performSearch(),!0};this.getLinkTarget=function(n){var t=function(n){return n?/(?:^[a - z][a - z0 - 9 +.-]*:|\/\/)/.test(n):!1},i=function(n){if(t(n)){var u=new URL(n),i=u.hostname,r=window.location.hostname;if(i&&r&&i.toLowerCase()!==r.toLowerCase())return!0}return!1};return i(n)?"_blank":""};this.processRows=function(n){var u,t;if(n.length){var e=function(n,t){return new Date(n.getDate()+t)<new Date},o=function(n){return n&&n.replace(/0/g,"").replace(/:/g,"")!==""},f=function(n){return n&&n!=="0001-01-01T00:00:00"},s=function(n){var i,t,u;if(n.overlayGated=!1,n.Gated&&n.GatingType&&n.GatingType.toLowerCase()==="overlay"&&r.overlayForm)if(r.jsonMaxGatedDays&&r.jsonMaxGatedDays.length!==0&&f(n.Timestamp)){for(i=!1,t=0;t<r.jsonMaxGatedDays.length;t++)if(u=r.jsonMaxGatedDays[t][n.ContentTypeDisplayName],u>0){i=!0;n.overlayGated=e(new Date(n.Timestamp),u);break}i||(n.overlayGated=!0)}else n.overlayGated=!0;n.overlayGated?(n.Url="#",n.overlayForm=r.overlayForm):n.overlayForm=null},h=new i;for(u=0;u<n.length;u++)t=n[u],t.HasMetaDate=f(t.MetaDate),t.HasMetaTime=!1,t.HasAuthors=t.Authors&&t.Authors.length>0,t.HasDuration=o(t.MetaDuration),s(t),h.createResourceMetaDataItems(t),t.Title&&(t.Title=t.Title.replace(/(<p[^>]+?>|<p>|<\/p>)/img,""));r.overlayForm&&r.overlayForm.length>0&&setTimeout(function(){$('a[data-modal="'+r.overlayForm+'"]').addClass("js-wkis-modal-open")},100)}};this.incrementPageClick=function(){var n=r.Page()+1;n<=r.PagesCount()&&(r.performSearch(n),r.scrollToTop())};this.decrementPageClick=function(){var n=r.Page()-1;n>0&&(r.performSearch(n),r.scrollToTop())};this.scrollToTop=function(){var n=$(".wkis-knowledge-library-content").offset();$("html, body").animate({scrollTop:n.top})};this.getPages=function(){return Services.PaginationServices.getPages(r.PagesCount(),7,r.Page())};this.movePage=function(n){r.performSearch(n);r.scrollToTop()};this.$container=$(t);this.jsonMaxGatedDays=JSON.parse($("#jsonMaxGatedDays").attr("data-maxgateddays"));this.overlayForm=$("#jsonMaxGatedDays").attr("data-overlayform");u=window.InitialPageJsonModel;this.searchArgs=u.SearchArgs;this.FacetsService=new n.Entities.SearchEntities.FacetsService(u.Facets,this.performSearch);this.EditionDates=new n.Entities.SearchEntities.EditionDatesService(this.$container,this.FacetsService,this.performSearch);this.UrlService=new n.Entities.SearchEntities.UrlService;f=function(){r.ResultsPerPageList([{Text:"20",Value:20},{Text:"50",Value:50},{Text:"80",Value:80},{Text:"110",Value:110}]);r.ResultsPerPage(r.ResultsPerPageList()[0])};f();e=function(){r.SortByList([{Text:r.$container.find("#sortByAZDictText").text(),Value:"title-az"},{Text:r.$container.find("#sortByZADictText").text(),Value:"title-za"}]);r.SortBy(r.SortByList()[0])};e();o=this.UrlService.loadFromSearchUrlPart(this.SearchString,this.EditionDates.DateFrom,this.EditionDates.DateTo,this.FacetsService.Facets(),this.ResultsPerPageList(),this.ResultsPerPage,this.SortByList(),this.SortBy,null);this.performSearch(o)}return t}();t.KlLandingViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.PressReleaseYearModel,r=function(){function n(n,t,r){var u=this,f;this.movePage=function(n){u.RequestedPage=u.CurrentPage()+n;u.performSearch()};this.incrementPage=function(){u.movePage(1)};this.decrementPage=function(){u.movePage(-1)};this.saveToSessionStorage=function(n,t){window.sessionStorage&&window.sessionStorage.setItem(u.sessionStoragePrefix+n,t)};this.retrieveFromSessionStorage=function(n){return window.sessionStorage?window.sessionStorage.getItem(u.sessionStoragePrefix+n):null};this.formatDate=function(n){return moment(n).format("MMMM DD, YYYY ")};this.performSearch=function(){var t=u.RequestedPage>0?u.RequestedPage:1,n,i,r,f;u.RequestedPage=0;n="";i=function(t,i){n+=n?"&":"?";n+=encodeURIComponent(t)+"="+encodeURIComponent(i)};u.ResultsPerPage()&&u.ResultsPerPage()!==u.DefaultResultsPerPage&&i("resultsPerPage",u.ResultsPerPage());t>1&&i("page",t.toString());history.replaceState({},null,location.pathname+n+location.hash);r={IndexType:u.SelectedTopFilter(),PageSize:u.ResultsPerPage(),Page:t,SortBy:u.SortBy()};f=u;$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){f.processJsonResult(n);$("html").removeAttr("data-loading")},error:function(){$("html").removeAttr("data-loading")}})};this.processJsonResult=function(n){var f,s,r;if(u.TotalRowsCount(n.TotalRowsCount),n.TotalRowsCount>0){u.TotalPages(n.PagesCount);u.ShowPagination(n.PagesCount>0);u.CurrentPage(n.Page);u.SearchResultItems(n.Rows);var e=[],o="0",t=new i,h=n.Rows.length,c=ko.mapping.fromJS(u.SearchResultItems);for(f=0;f<h;f++)s=n.Rows[f].Timestamp,r=new Date(s).getFullYear().toString(),r!==o&&(t=new i,t.Year=r,t.PressReleaseItemModels=[],t.PressReleaseItemModels=c.remove(function(n){var t=n.Timestamp(),i=new Date(t).getFullYear().toString();if(i===r)return n}),e.push(t)),o=r;u.SearchResultItems(e)}else u.TotalPages(0),u.ShowPagination(!1),u.CurrentPage(0),u.SearchResultItems([])};this.sessionStoragePrefix="pressReleases_";this.$container=$(n);this.OnInit=!0;this.RequestedPage=0;this.SearchResultItems=ko.observableArray([]);this.CurrentPage=ko.observable(0);this.TotalPages=ko.observable(0);this.TotalRowsCount=ko.observable(0);this.ShowPagination=ko.observable(!1);this.NoResults=ko.observable(!0);this.ValidResultsPerPage=["10","20","50","100","150","200"];this.DefaultResultsPerPage="10";t!=null&&t.length>0&&this.ValidResultsPerPage.indexOf(t)>-1?this.ResultsPerPage=ko.observable(t):(f=this.retrieveFromSessionStorage("ResultsPerPage"),this.ResultsPerPage=f!=null&&f.length>0&&this.ValidResultsPerPage.indexOf(f)>-1?ko.observable(f):ko.observable(this.DefaultResultsPerPage));r!=null&&r.length>0&&(r=decodeURIComponent(r).replace("#",""),this.RequestedPage=parseInt(r));this.SortBy=ko.observable("timestamp-za");this.SelectedTopFilter=ko.observable("pressReleaseDetail");this.ResultsPerPage.subscribe(function(n){u.saveToSessionStorage("ResultsPerPage",n);u.TotalRowsCount()>0&&u.performSearch()});this.ResultsPerPage.extend({rateLimit:50});this.OnInit=!1;this.performSearch()}return n}();r.isNaNModified=function(n){var t=parseFloat(n);return isNaN(t)||t.toString().length!=n.length};t.PressReleasesLandingViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(n){var t=function(){function n(){var n=this,t;this.RelevantProducts=ko.observableArray();this.getDescription=function(n,t){return t?t>n.length?n:n.substring(0,t)+" [...]":n};this.getProductType=function(t){return n.productTypeDictionary[t]};this.loadRelevantProducts=function(){$.ajax({url:n.ApiSearchUrl,type:"GET",contentType:"application/json",success:n.responseProcess,error:n.errorProcess})};this.errorProcess=function(n){console.log(n.statusText)};this.responseProcess=function(t){for(var r,i=0,u=t.elements;i<u.length;i++)r=u[i],r.image=r.image||n.DefaultImageUrl,n.RelevantProducts.push(r)};this.getRelevantProducts=function(t){return t?n.RelevantProducts().slice(0,t):n.RelevantProducts().slice(0,4)};this.currencyFormat=function(n){try{var t=parseFloat(n);return t.toFixed(2).replace(".",",")}catch(i){return n}};t=window.RelevantProducts_ProductTypeFacets;this.productTypeDictionary=window.RelevantProducts_ProductTypeDictionary;this.DefaultImageUrl=window.RelevantProducts_DefaultImageUrl;this.ApiSearchUrl="/umbraco/api/RelevantProducts/"+t;this.loadRelevantProducts()}return n}();n.RelevantProductsProductsViewModel=t})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=function(){function t(t){var i=this,u,r;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.performSearch=function(t){var p=++i.loadCounter,r,u,f,e,o,s,d,g,h,a,w,c,v,b,l,y,k;if(t==null&&(t=1),r={Language:i.searchArgs.Language,IndexType:i.searchArgs.IndexType,QueryStr:i.searchArgs.QueryStr,PageSize:i.searchArgs.PageSize,Page:t,SortBy:i.searchArgs.SortBy,Facets:[],ReturnFacets:[]},p===1&&(r.Page=i.searchArgs.Page),i.DataRange){if(u=null,i.DataRange.Facets!=null)for(f=0;f<=i.DataRange.Facets.length;f++)e=i.DataRange.Facets()[f],e&&e.IsChecked&&(u=e);if(u)switch(u.TimeUnit()){case"d":r.LastDays=u.RangeAmount();break;case"m":r.LastDays=u.RangeAmount()*30;break;case"y":r.LastDays=u.RangeAmount()*365;break;default:r.LastDays=u.RangeAmount()}else i.searchArgs.LastDays&&(r.LastDays=i.searchArgs.LastDays)}else i.searchArgs.LastDays&&(r.LastDays=i.searchArgs.LastDays);for(i.EditionDates.DateFrom()&&(o=moment(i.EditionDates.DateFrom(),"DD-MM-YYYY"),s=new n.Entities.SearchEntities.FacetArg,s.Name="cl_Editie",s.Labels.push(o.format("YYYY")+"/"+Helpers.String.Capitalize(o.format("MMMM"))+"/"+o.format("D MMMM").toLowerCase()),r.Facets.push(s)),d="",g="",h=0,a=i.searchArgs.Facets;h<a.length;h++)w=a[h],r.Facets.push(w);for(c=0,v=i.FacetsService.getFacets();c<v.length;c++)b=v[c],r.Facets.push(b);for(l=0,y=i.FacetsService.Facets();l<y.length;l++)k=y[l],r.ReturnFacets.push(k.Name());i.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(r),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){if(p===i.loadCounter){i.FacetsService.updateFacetsHitCount(n.Facets);i.Page(n.Page);i.PagesCount(n.PagesCount);i.IsLoading(!1);i.updateRows(n.Rows);var t=document.URL.split("#").length>1?document.URL.split("#")[1]:null;t=="disqus_thread"&&document.getElementById("disqus_thread").scrollIntoView();$.globalEval('if("koLoaded" in window) koLoaded();')}}})};this.initializtDataRanges=function(n){return ko.mapping.fromJS(n)};this.getClassification=function(n){for(var u=[],f=n.split(","),t,r=0;r<f.length;r++)t=f[r].split(":"),t.length==2&&i.ShowClassification.indexOf(t[0].trim())>=0&&u.push(t[1].substr(t[1].lastIndexOf("/")+1).trim());return u.join(", ")};this.updateRows=function(n){for(var f=[],s,u,o,t,r=0,e=i.preselectedRows;r<e.length;r++)(t=e[r],t.Classification!=null)&&(t.ClassificationView=i.getClassification(t.Classification),f.push(t));for(s=function(n){if(n.Classification==null)return"continue";n.ClassificationView=i.getClassification(n.Classification);var t=i.preselectedRows.some(function(t){return t.IndexType===n.IndexType&&t.Id===n.Id});t||f.push(n)},u=0,o=n;u<o.length;u++)t=o[u],s(t);i.Rows(f)};this.isEvent=function(n){if(n.IndexType!=="event"||!n.MetaDateFrom||!n.MetaDateTo)return!1;var t=moment(n.MetaDateTo).diff(moment(),"days");return t>=0?!0:!1};this.isVideo=function(n){return["Webinar","Educational Webinar","Webinars","Educational Webinars"].some(function(t){return t===n.ContentTypeDisplayName})};this.getAuthor=function(n){return i.showAuthor?n.Authors:null};this.getMainClassification=function(n){var r,t,i,u;if(n.Classification!=null)for(r=n.Classification.split(","),t=0;t<r.length;t++)if(i=r[t].split(":"),i.length>1&&(u=i[0].trim(),u=="Informatiesoort"||u=="Producten"))return i[1].trim();return"Nieuws"};this.getColor=function(n,t){var u,i,f,e,r;if(n.Classification!=null)for(u=n.Classification.split(","),i=0;i<u.length;i++)if(f=u[i].split(":"),f.length>1&&(e=f[1].trim(),r=t[e],r!=""&&r!=null))return r;return""};this.getDate=function(n){return i.showDate?n.MetaDateFrom?moment(n.MetaDateFrom).format("LL"):null:null};this.getEventPassedDays=function(n){if(n.IndexType!=="event"||!n.MetaDateTo)return null;var t=moment().diff(moment(n.MetaDateTo),"days");return t>0?moment(n.MetaDateTo).fromNow():null};this.clearAllFiltersClick=function(){i.FacetsService.clearAllFilters();i.EditionDates.clearEditionFilter();i.performSearch()};this.isClearAllFiltersVisible=function(){return i.FacetsService.isClearAllFiltersVisible()?!0:i.EditionDates.isClearEditionFilterVisible()?!0:!1};this.stripHtml=function(n){var t=document.createElement("DIV");return t.innerHTML=n,t.textContent||t.innerText||""};this.truncateText=function(n,t){return t===0?n:n.length>t?n.substring(0,t)+"...":n};this.incrementPageClick=function(){var n=i.Page()+1;n<=i.PagesCount()&&i.performSearch(n)};this.decrementPageClick=function(){var n=i.Page()-1;n>0&&i.performSearch(n)};this.getPages=function(){return Services.PaginationServices.getPages(i.PagesCount(),7,i.Page())};this.movePage=function(n){i.performSearch(n)};this.rangeClick=function(n){for(var t=0;t<i.DataRange.Facets().length;t++)i.DataRange.Facets()[t]!=n&&i.DataRange.Facets()[t].IsChecked(!1);return i.performSearch(),!0};this.clearRangeClick=function(){for(var n=0;n<i.DataRange.Facets().length;n++)i.DataRange.Facets()[n].IsChecked(!1);i.performSearch()};this.$container=$(t);u=this.$container.attr("data-epam-initial-json-model-alias");r=window[u];this.preselectedRows=r.PreselectedRows;this.Rows=ko.observableArray([]);this.searchArgs=r.SearchArgs;this.showAuthor=r.ShowAuthor;this.showDate=r.ShowDate;this.showPagination=r.ShowPagination;this.FacetsHeader=r.FacetsHeader;this.MetaDateFrom=r.SearchArgs.MetaDateFrom;this.MetaDateTo=r.SearchArgs.MetaDateTo;this.ShowClassification=r.ShowClassification;this.DataRange=r.DateRange?this.initializtDataRanges(r.DateRange):null;this.FacetsService=new n.Entities.SearchEntities.FacetsService(r.Facets,this.performSearch);this.EditionDates=new n.Entities.SearchEntities.EditionDatesService(this.$container,this.FacetsService,this.performSearch);this.preselectedRows.length<this.searchArgs.PageSize&&this.performSearch()}return t}();t.SearchListViewModel=i})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={})),function(n){var t;(function(t){var i=n.Entities.SearchResultEntities.ResourceMetaDataMapper,r=function(){function t(t){var r=this,u,f,e,o;this.loadCounter=0;this.IsLoading=ko.observable(!1);this.SearchString=ko.observable();this.CurrentSearchString=ko.observable();this.ResultsPerPage=ko.observable();this.ResultsPerPageList=ko.observableArray();this.SortBy=ko.observable();this.SortByList=ko.observableArray();this.TotalRowsCount=ko.observable(-1);this.Page=ko.observable(1);this.PagesCount=ko.observable(0);this.Rows=ko.observableArray();this.DataRange=null;this.NoResults=ko.observable(!1);this.SelectedTopFilter=ko.observable("all");this.ShowClearRange=ko.observable(!1);this.initializtDataRanges=function(n){return n?ko.mapping.fromJS(n):null};this.performSearch=function(t){var l=++r.loadCounter,i,u,f,e,o,c,a,s,h,v,y,p;if(t==null&&(t=1),i={IndexType:"all",Language:document.documentElement.lang.substr(0,2),QueryStr:r.SearchString(),PageSize:r.ResultsPerPage().Value,Page:t,SortBy:r.SortBy().Value,Facets:[],ReturnFacets:r.FacetsService.Facets().map(function(n){return n.Name()})},u=null,r.DataRange.Facets!=null)for(f=0;f<=r.DataRange.Facets().length;f++)e=r.DataRange.Facets()[f],e&&e.IsChecked()&&(u=e);if(u){switch(u.TimeUnit()){case"d":i.LastDays=u.RangeAmount();break;case"m":i.LastDays=u.RangeAmount()*30;break;case"y":i.LastDays=u.RangeAmount()*365;break;default:i.LastDays=u.RangeAmount()}r.ShowClearRange(!0)}for(o=0,c=r.FacetsService.getFacets();o<c.length;o++)a=c[o],i.Facets.push(a);r.EditionDates.DateFrom()&&(s=moment(r.EditionDates.DateFrom(),"DD-MM-YYYY"),h=new n.Entities.SearchEntities.FacetArg,h.Name="cl_Editie",h.Labels.push(s.format("YYYY")+"/"+Helpers.String.Capitalize(s.format("MMMM"))+"/"+s.format("D MMMM").toLowerCase()),i.Facets.push(h));v="";y="";l!==1&&r.UrlService.updateSearchUrlPart(t,i.QueryStr,v,y,i.Facets,r.ResultsPerPageList(),r.ResultsPerPage(),r.SortByList(),r.SortBy(),r.SelectedTopFilter(),u);switch(r.SelectedTopFilter()){case"vandaag":i.IndexType="resource";r.InfoFacetContainer&&r.VandaagFacetLabel&&i.Facets.push({Name:r.InfoFacetContainer.Name(),Labels:[r.VandaagFacetLabel]});break;case"article":i.IndexType="resource";r.InfoFacetContainer&&r.VandaagFacetLabel&&(p=r.InfoFacetContainer.Facets().map(function(n){return n.Value()}).filter(function(n){return n!==r.VandaagFacetLabel}),i.Facets.push({Name:r.InfoFacetContainer.Name(),Labels:p}));break;default:i.IndexType=r.SelectedTopFilter()}r.IsLoading(!0);$.ajax({type:"POST",url:"/Umbraco/Api/SearchApi/Search",data:JSON.stringify(i),contentType:"application/json",dataType:"json",traditional:!0,success:function(n){if(l===r.loadCounter){r.FacetsService.updateFacetsHitCount(n.Facets);r.IsLoading(!1);r.processRows(n.Rows);r.Rows(n.Rows);r.NoResults(n.Rows.length===0);r.TotalRowsCount(n.TotalRowsCount);r.Page(n.Page);r.PagesCount(n.PagesCount);r.CurrentSearchString(i.QueryStr);$("html").removeAttr("data-loading");var t=document.getElementById("wkis-results-bar");t&&window.scrollTo(t.offsetLeft,t.offsetTop)}}})};this.clearAllFiltersClick=function(){r.SearchString("");r.FacetsService.clearAllFilters();r.EditionDates.clearEditionFilter();r.performSearch()};this.isClearAllFiltersVisible=function(){return r.SearchString()?!0:r.FacetsService.isClearAllFiltersVisible()?!0:r.EditionDates.isClearEditionFilterVisible()?!0:!1};this.searchInputKeyUp=function(n,t){t.keyCode===13&&r.performSearch()};this.performSearchClick=function(){return r.performSearch(),!0};this.getLinkTarget=function(n){var t=function(n){return n?/(?:^[a - z][a - z0 - 9 +.-]*:|\/\/)/.test(n):!1},i=function(n){if(t(n)){var u=new URL(n),i=u.hostname,r=window.location.hostname;if(i&&r&&i.toLowerCase()!==r.toLowerCase())return!0}return!1};return i(n)?"_blank":""};this.getDate=function(n){return n.MetaDateFrom?moment(n.MetaDateFrom).format("LL"):null};this.getMainClassification=function(n){var r,t,i,u;if(n.Classification!=null)for(r=n.Classification.split(","),t=0;t<r.length;t++)if(i=r[t].split(":"),i.length>1&&(u=i[0].trim(),u=="Informatiesoort"||u=="Producten"))return i[1].trim();return"Nieuws"};this.getColor=function(n,t){var u,i,f,e,r;if(n.Classification!=null)for(u=n.Classification.split(","),i=0;i<u.length;i++)if(f=u[i].split(":"),f.length>1&&(e=f[1].trim(),r=t[e],r!=""&&r!=null))return r;return""};this.processRows=function(n){var u,t;if(n.length){var e=function(n,t){return new Date(n.getDate()+t)<new Date},o=function(n){return n&&n.replace(/0/g,"").replace(/:/g,"")!==""},f=function(n){return n&&n!=="0001-01-01T00:00:00"},s=function(n){var i,t,u;if(n.overlayGated=!1,n.Gated&&n.GatingType&&n.GatingType.toLowerCase()==="overlay"&&r.overlayForm)if(r.jsonMaxGatedDays&&r.jsonMaxGatedDays.length!==0&&f(n.Timestamp)){for(i=!1,t=0;t<r.jsonMaxGatedDays.length;t++)if(u=r.jsonMaxGatedDays[t][n.ContentTypeDisplayName],u>0){i=!0;n.overlayGated=e(new Date(n.Timestamp),u);break}i||(n.overlayGated=!0)}else n.overlayGated=!0;n.overlayGated?(n.Url="#",n.overlayForm=r.overlayForm):n.overlayForm=null},h=new i;for(u=0;u<n.length;u++)t=n[u],t.HasMetaDate=f(t.MetaDate),t.HasMetaTime=!1,t.HasAuthors=t.Authors&&t.Authors.length>0,t.HasDuration=o(t.MetaDuration),s(t),h.createResourceMetaDataItems(t),t.Title&&(t.Title=t.Title.replace(/(<p[^>]+?>|<p>|<\/p>)/img,""));r.overlayForm&&r.overlayForm.length>0&&setTimeout(function(){$('a[data-modal="'+r.overlayForm+'"]').addClass("js-wkis-modal-open")},100)}};this.incrementPageClick=function(){var n=r.Page()+1;n<=r.PagesCount()&&(r.performSearch(n),r.scrollToTop())};this.decrementPageClick=function(){var n=r.Page()-1;n>0&&(r.performSearch(n),r.scrollToTop())};this.scrollToTop=function(){var n=$(".wkis-page-header-container").offset();$("html, body").animate({scrollTop:n.top})};this.getPages=function(){return Services.PaginationServices.getPages(r.PagesCount(),7,r.Page())};this.movePage=function(n){r.performSearch(n);r.scrollToTop()};this.clickedTopFilterAnchor=function(n){r.SelectedTopFilter()!==n&&(r.SelectedTopFilter(n),r.performSearch())};this.rangeClick=function(n){r.ShowClearRange(!1);for(var t=0;t<r.DataRange.Facets().length;t++)r.DataRange.Facets()[t]!=n&&r.DataRange.Facets()[t].IsChecked(!1);return r.performSearch(),!0};this.clearRangeClick=function(){for(var n=0;n<r.DataRange.Facets().length;n++)r.DataRange.Facets()[n].IsChecked(!1);r.performSearch();r.ShowClearRange(!1)};this.$container=$(t);this.jsonMaxGatedDays=JSON.parse($("#jsonMaxGatedDays").attr("data-maxgateddays"));this.overlayForm=$("#jsonMaxGatedDays").attr("data-overlayform");u=window.InitialPageJsonModel;this.VandaagFacetLabel=u.VandaagFacetLabel;u.InfoFacetContainer&&(this.InfoFacetContainer=ko.mapping.fromJS(u.InfoFacetContainer));this.ShowClearRange(!1);this.DataRange=this.initializtDataRanges(u.DateRange);this.FacetsService=new n.Entities.SearchEntities.FacetsService(u.Facets,this.performSearch);this.EditionDates=new n.Entities.SearchEntities.EditionDatesService(this.$container,this.FacetsService,this.performSearch);this.UrlService=new n.Entities.SearchEntities.UrlService;f=function(){r.ResultsPerPageList([{Text:"20",Value:20},{Text:"50",Value:50},{Text:"80",Value:80},{Text:"110",Value:110}]);r.ResultsPerPage(r.ResultsPerPageList()[0])};f();e=function(){r.SortByList([{Text:r.$container.find("#sortByRelevanceDictText").text(),Value:"relevance"},{Text:r.$container.find("#sortByAZDictText").text(),Value:"title-az"},{Text:r.$container.find("#sortByZADictText").text(),Value:"title-za"},{Text:r.$container.find("#sortByTimestampAZDictText").text(),Value:"timestamp-az"},{Text:r.$container.find("#sortByTimestampZADictText").text(),Value:"timestamp-za"},]);r.SortBy(r.SortByList()[0])};e();o=this.UrlService.loadFromSearchUrlPart(this.SearchString,this.EditionDates.DateFrom,this.EditionDates.DateTo,this.FacetsService.Facets(),this.ResultsPerPageList(),this.ResultsPerPage,this.SortByList(),this.SortBy,this.SelectedTopFilter,this.DataRange);this.performSearch(o)}return t}();t.SearchResultsViewModel=r})(t=n.ViewModel||(n.ViewModel={}))}(WebContent||(WebContent={}))