require(['jquery','mage/url','mage/translate',],function($,url){'use strict';$(document).ready(function(){$(document).on('click tap','.pslogin-showmore-button',function(){if(this.dataset.psType==='knockout'){return true;} var $buttons=$(this).parents('div.pslogin-buttons');if(this.classList.contains('ps-show-less')){$buttons.find('.pslogin-hidden').fadeOut(275);}else{$buttons.find('.pslogin-hidden').fadeIn(275);} toggleButton(this);return false;});$(document).on('click','.pslogin-button-click',function(){var $this=$(this);if($this.data('useCustomClickHandler')){return true;} psLogin($this.data('href'),$this.data('width'),$this.data('height'),$this.data('openOnPage'));return false;});$('.pslogin-fake-email-message .close-message').on('click tap',function(){$(this).parent().hide();});});window.psLogin=function(href,width,height,openOnPage){if(!href){alert('The Login Application was not configured correctly. If your are the admin of store: Please activate “Enable Logging” in Magento Login Extension and try again to see error details.');return false;} if(openOnPage){require(['Magento_Customer/js/customer-data'],function(customerData){customerData.invalidate(['*']);window.location.href=href;});return;} width=width?width:650;height=height?height:350;if(href.indexOf('js_login_method')===0){prCustomJsLoginMethod(href,width,height);return;} var win=psOpenOAuthWindow(href,width,height);$(win.document).ready(function(){var loaderText='Loading...';var html=''+loaderText+'';html+='';html+='
'+loaderText+'
';html+='';$(win.document).contents().html(html);});return false;} function psOpenOAuthWindow(href,width,height){var left=parseInt(($(window).width()-width)/ 2);var top=parseInt(($(window).height()-height)/ 2);var params=['resizable=yes','scrollbars=no','toolbar=no','menubar=no','location=no','directories=no','status=yes','width='+width,'height='+height,'left='+left,'top='+top];var win=window.open(href,'pslogin_popup',params.join(','));win.focus();return win;} function prCustomJsLoginMethod(href,width,height){var parsedUrlData=atob(href.split('?',2)[1]),params=JSON.parse(parsedUrlData);$.ajax({type:'POST',url:url.build('pslogin/modal/saveContext'),data:params,success:function(response){window.addEventListener("message",function(event){$.ajax({type:'POST',url:params.login_url,data:JSON.parse(event.data).result,success:function(loginResponse){if('object'===typeof loginResponse){if(loginResponse.popup&&document.pslogin&&document.pslogin.bindEmail){document.pslogin.bindEmail.openPopup(loginResponse.popup.firstname,loginResponse.popup.email,loginResponse.popup.networkCode,loginResponse.popup.step);}else{document.location.href=loginResponse.redirectUrl;}}else if('string'==typeof(loginResponse)){var html=loginResponse.match(//)[0];$('body').append(html);}}});},false);psOpenOAuthWindow(params.popup_url,width,height);},error:function(response){if(400===response.status){alert(response.responseJSON.message);}}});} function toggleButton(button){var title='';if(button.classList.contains('ps-show-less')){button.dataset.hiddenTitle=button.innerText;title=$.mage.__('show more');if(button.dataset.visibleTitle){title=button.dataset.visibleTitle;}}else{button.dataset.visibleTitle=button.innerText;title=$.mage.__('show less');if(button.dataset.hiddenTitle){title=button.dataset.hiddenTitle;}} button.innerText=title;button.classList.toggle('ps-show-less');}});