"use strict";(function(){angular.module("app").controller("membershipController",["$scope","membershipService","ngDialog",function(n,t,i){n.showLoader=!1;n.ShowTravelDocPopup=function(){n.response=null;i.open({template:"/travel-documentation-template.html",scope:n,className:"ngdialog-travel-document box popup",showClose:!0})};n.GetTravelDocumentation=function(i,r){t.GetTravelDocumentation(i,r).then(function(t){n.response=t},function(t){n.response=t;n.response.data=t.data.messages[0].message})};n.WishListCount=function(){return $.cookie("WishListCount")==null||$.cookie("WishListCount")==""?0:$.cookie("WishListCount")}}])})(),function(){angular.module("app").controller("accountController",["$scope","ngDialog","membershipService","$templateCache","blockUI","model","$rootScope","$timeout",function(n,t,i,r,u,f,e,o){var s={};s.returnUrl=getQueryStringParameterByName("returnUrl");n.password="";n.uniquecode="";n.youAndSunPopup=null;n.YouAndSunUrl="";n.loginHeaderPopupHTML=r.get("/login-template.html");n.loginHeaderPopup=function(t){$(".utravel.collapse.in").removeClass("in");$("#login-modal").show();$(".header-mobile--step #login-header-popup").show();n.loginError=!1;n.error=!1;t&&(_.isUndefined(e.username)||e.username==""||_.isUndefined(n.password)||n.password==""?n.error=!0:(u.start(" "),i.LoginHeaderPopup(e.username,n.password).then(function(t){s.performPostLoginAction(t,e.username,n.password)},function(t){u.stop();n.loginError=!0;n.loginErrorMessage=t.data.messages[0].message})))};n.loginMyAssistant=function(t){n.loginError=!1;n.error=!1;t&&(_.isUndefined(e.username)||e.username==""||_.isUndefined(n.password)||n.password==""?n.error=!0:(u.start("Login in corso..."),i.LoginMyAssistant(e.username,n.password).then(function(n){u.stop();s.goToMyAssistantHomePage(n.data)},function(t){u.stop();n.loginError=!0;n.loginErrorMessage=t.data.messages[0].message})))};n.FBLoginHeaderPopup=function(t){t&&(e.username=$("#FBUserName").val().split("|")[0],n.password=$("#FBPassword").val(),n.loginError=!1,n.error=!1,t&&(_.isUndefined(e.username)||e.username==""||_.isUndefined(n.password)||n.password==""?n.error=!0:i.LoginHeaderPopup($("#FBUserName").val(),n.password).then(function(t){s.performPostLoginAction(t,$("#FBUserName").val(),n.password);window.location.reload()},function(t){n.loginError=!0;n.loginErrorMessage=t.data.messages[0].message})))};n.gotoRegistrationPage=function(t){u.start(" ");i.CheckRegistration(t).then(function(i){if(u.stop(),i.data.data.IsValid){var r=i.data.data.MarketingConsent==null?"":i.data.data.MarketingConsent,f=i.data.data.ProfilingConsent==null?"":i.data.data.ProfilingConsent,e=window.btoa(t),o="/my-alpitour-world/conferma-registrazione?e="+e+"&m="+r+"&p="+f;window.location.href=o}else n.loginError=!0,n.loginErrorMessage=i.data.data.Outcome=="DP"?"DP":"Si è verificato un errore!"},function(){u.stop();n.loginError=!0;n.loginErrorMessage="Si è verificato un errore!"})};n.registerHeaderPopupHTML=r.get("/register-template.html");n.registerHeaderPopup=function(t){if(t){var r=parseInt(n.birthday.split("/")[0]),f=parseInt(n.birthday.split("/")[1]),e=parseInt(n.birthday.split("/")[2]);n.isDate18orMoreYearsOld(r,f,e)||n.birthday==""?(u.start(" "),i.RegisterHeaderPopup(n.email,n.name,n.surname,n.birthday,n.marketingConsentBool,n.profilingConsentBool,n.uniquecode).then(function(t){u.stop();t.data.trim().startsWith("<div")?(n.registerHeaderPopupHTML=t.data,$("#modal-wrapper").show(),typeof fbAsyncInit=="function"&&window.fbAsyncInit(),setTimeout(function(){$("#register-modal [rel = tooltip]").tooltip()},500)):($("#popup-login").hide(),$("#register-modal").hide(),$("#register-ok").show())})):(n.loginError=!0,n.loginErrorMessage="Devi essere maggiorenne per proseguire nella registrazione!")}};n.registerUTravelHeaderPopupHTML=r.get("/register-utravel-template.html");n.registerUTravelHeaderPopup=function(t){$(".utravel.collapse.in").removeClass("in");t&&(u.start(" "),i.RegisterHeaderPopup(n.email,n.name,n.surname,n.uniquecode).then(function(t){u.stop();t.data.trim().startsWith("<div")?(n.registerHeaderPopupHTML=t.data,$("#modal-wrapper").show(),typeof fbAsyncInit=="function"&&window.fbAsyncInit(),setTimeout(function(){$("#register-modal [rel = tooltip]").tooltip()},500)):($("#popup-login").hide(),$("#register-modal").hide(),$("#register-ok").show())}))};n.showPrivacyPopup=function(){t.open({template:"/privacy-policy-template.html",scope:n,className:"ngdialog-membership",showClose:!0})};e.username=f.Passengers!=null&&f.Passengers[0]!=null&&f.Passengers[0].Email?f.Passengers[0].Email:e.username;n.passwordRecoveryHTML=r.get("/password-recovery-template.html");n.recoveryPassword=!0;n.recoveryPasswordSuccess=!1;n.passwordRecoveryPopup=function(r){if(n.message="",n.UsernameError=!1,n.passwordRecoveryHTML="",(_.isUndefined(e.username)||e.username=="")&&!_.isUndefined(r))n.UsernameError=!0;else if(r){u.start(" ");var f=window.location.href;i.PasswordRecovery(e.username,f).then(function(t){u.stop();t.data.success==!0?(n.recoveryPassword=!1,n.recoveryPasswordSuccess=!0,$("#recoveryPasswordMessage").hide()):t.data.messages.length>0&&(n.message=t.data.messages)})}else u.stop(),t.open({template:"/password-recovery-popup-template.html",controller:"accountController",scope:n,className:"ngdialog-membership",showClose:!0})};n.loginPurchasePopupHTML=r.get("/login-purchase-template.html");n.loginPurchasePopup=function(r){r?(u.start(" "),i.LoginPurchasePopup(e.username,n.password).then(function(t){u.stop();n.loginPurchasePopupHTML=t.data})):(u.stop(),t.open({template:"/login-purchase-popup-template.html",controller:"accountController",scope:n,className:"ngdialog-membership",showClose:!0}))};n.loginPurchaseFormHTML=r.get("/login-purchase-form-template.html");n.loginPurchaseFormAction=function(){n.loginError=!1;n.error=!1;_.isUndefined(e.username)||e.username==""||_.isUndefined(n.password)||n.password==""?n.error=!0:(u.start(" "),i.LoginPurchaseForm(e.username,n.password).then(function(){u.stop();window.location.reload(!0)},function(t){u.stop();n.loginError=!0;n.loginErrorMessage=t.data.messages[0].message}))};n.pressEnter=function(){event&&event.keyCode==13&&n.loginHeaderPopup(!0)};n.pressEnterMyAssistant=function(){event&&event.keyCode==13&&n.loginMyAssistant(!0)};s.performPostLoginAction=function(n,t,i){(n.data==null||n.data.data==null)&&window.location.reload();n.data.data.YouAndSunCardNumber==""&&n.data.data.PasswordChangeRequired!="RANDOM"&&websiteName.toLowerCase()!="utravel"?(u.stop(),closeModal(),s.showYouAndSunPopup()):n.data.data.PasswordChangeRequired=="RANDOM"&&websiteName.toLowerCase()!="utravel"?s.logOffAndChangePassword(n.data.data.domainUser,i):(window.location.reload(),s.goToReturnUrl())};s.goToReturnUrl=function(){if(s.returnUrl){window.location=s.returnUrl;return}websiteName.toLowerCase()=="utravel"&&window.location.href.indexOf("?")>0?(window.location.href=window.location.href.split("?")[0],window.location.reload(!0)):window.location.reload(!0)};s.goToMyAssistantHomePage=function(n){n.data.LandingPage&&(window.location.href=window.location.href.concat(n.data.LandingPage))};s.logOffAndChangePassword=function(n,t){i.UserLogOff("/my-alpitour-world/recupera-password").then(function(){u.stop();i.SingleOptinPasswordChange(n,t,"/").then(function(n){n.data.success==!0&&(window.location.href=n.data.redirectUrl)})})};s.showYouAndSunPopup=function(){n.youAndSunPopup=t.open({template:"/youandsun-popup-template.html",scope:n,className:"ngdialog-youandsun",width:422,showClose:!1,closeByDocument:!1});n.youAndSunPopup.closePromise.then(function(n){console.log(n)})};n.closeYouAndSunDialog=function(i){t.closeAll(i);i=="OK"&&(console.log("redirecting to ",n.YouAndSunUrl),window.location.href=n.YouAndSunUrl);s.goToReturnUrl()};n.UTravelRegister=function(){$(".utravel.collapse.in").removeClass("in");$("#register-header-popup").show();$("#register-utravel-popup").show()};s.registerEventHandlers=function(){n.$on("openLoginPanel",function(){n.loginHeaderPopup()})};s.getCustomLayoutPageHref=function(n){_.forEach(n,function(n){n!==undefined&&n!==null&&n.href!==undefined&&n.href!==null&&(n.href=n.href.indexOf("cl=y")>0?n.href:n.href+"?cl=y")})};s.init=function(){var t,i;if(n.birthday="",getQueryStringParameterByName("auth")){window.location.href=window.location.href.split("?")[0]+"?cl=y";return}if(getQueryStringParameterByName("cl")=="y"){t=$(".myPage_header > ul > li > a").not(".esci");s.getCustomLayoutPageHref(t);i=$(".boxSpalla.listato > ul > li > a");s.getCustomLayoutPageHref(i);return}s.registerEventHandlers();s.returnUrl&&o(function(){$("#loginLinkDesktop").click()})};s.init()}])}(),function(){angular.module("app").service("membershipService",["$http",function(n){this.CheckEmail=function(t){return n({url:"/webapi/AccountApi/CheckEmail?emailAddress="+t,method:"POST"})};this.CheckRegistration=function(t){return n({url:"/webapi/AccountApi/CheckRegistration?emailAddress="+t,method:"POST"})};this.GetTravelDocumentation=function(t,i){return n({url:"/webapi/TravelDocumentsWebApi/GetTravelDocumentation",method:"POST",data:{mail:t,code:i}}).then(function(n){return n.data})};this.PasswordRecovery=function(t,i){return n({url:"/Account/PasswordRecovery",method:"POST",data:{UserName:t,RedirectUrl:i}}).then(function(n){return n})};this.SingleOptinPasswordChange=function(t,i,r){return n({url:"/Account/SingleOptinPasswordChange",method:"POST",data:{username:t,password:i,redirectUrl:r}}).then(function(n){return n})};this.LoginHeaderPopup=function(t,i){return n({url:"/webapi/AccountApi/Login",method:"POST",data:{UserName:t,Password:i}}).then(function(n){return n})};this.UserLogOff=function(t){return n({url:"/Account/LogOff",method:"POST",data:{returnUrl:t}}).then(function(n){return n})};this.LoginMyAssistant=function(t,i){return n({url:"/webapi/AccountApi/LoginMyAssistant",method:"POST",data:{UserName:t,Password:i}}).then(function(n){return n})};this.RegisterHeaderPopup=function(t,i,r,u,f,e){return n({url:"/webapi/AccountApi/Register",method:"POST",data:{Email:t,Name:i,Surname:r,Birthday:u,MarketingConsentBool:f,ProfilingConsentBool:e}}).then(function(n){return n})};this.RegisterHeaderPopupMobile=function(t,i,r,u,f){return n({url:"/webapi/AccountApi/Register",method:"POST",data:{Email:t,Name:i,Surname:r,Birthday:u,UniqueCode:f}}).then(function(n){return n})};this.ConfirmRegistration=function(t){return n({url:"/webapi/AccountApi/ConfirmRegistration",method:"POST",data:t}).then(function(n){return n})};this.ForceConfirmRegistration=function(t){return n({url:"/webapi/AccountApi/ForceConfirmRegistration",method:"POST",data:t}).then(function(n){return n})};this.SetPassword=function(t){return n({url:"/webapi/AccountApi/SetPassword",method:"POST",data:t}).then(function(n){return n})};this.LoginPurchasePopup=function(t,i){return n({url:"/Account/LoginPurchasePopup",method:"POST",data:{UserName:t,Password:i}}).then(function(n){return n})};this.LoginPurchaseForm=function(t,i){return n({url:"/webapi/AccountApi/Login",method:"POST",data:{UserName:t,Password:i}}).then(function(n){return n})};this.UpdateNewsLetterConsents=function(t){return n({url:"/webapi/NewsLetterApi/UpdateNewsLetterConsents",method:"POST",data:t}).then(function(n){return n})}}])}()