var generic=generic||{},site=site||{},Drupal=Drupal||{},settings=Drupal.settings||{},FB=FB||"";!function(e,o,n){var t,c=e.getElementsByTagName(o)[0];if(!e.getElementById(n)){(t=e.createElement(o)).id=n;var i=settings.fb_sdk_locale||"en_US";t.src="//connect.facebook.net/"+i+"/sdk.js",c.parentNode.insertBefore(t,c)}}(document,"script","facebook-jssdk"),function(e){site.facebook=function(){var o={};void 0===typeof FB&&(FB=Object("FB"));var n=function(){e(".social-login__container").removeClass("hidden"),!site.client.isMobile&&document.querySelector("body#signin #content .social-login")&&e(window).trigger("resize")};e("body").on("click",".js-facebook_disclaimer",(function(){e(this).is(":checked")?e(".js-fb-button-overlay, .js-fb-disclaimer-error").addClass("hidden"):e(".js-fb-button-overlay, .js-fb-disclaimer-error").removeClass("hidden"),e(".js-facebook_disclaimer").prop("checked",e(this).is(":checked"))})),e("body").on("click",".js-fb-button-overlay",(function(){e(".js-fb-disclaimer-error").removeClass("hidden")}));var t=function(e){"connected"===e.status&&FB.logout(t)},c=function(){var c=settings.federal_id_check||!1;o.container=e(".social-login__container"),o.form=e("#facebook_signin"),o.appIdInput=o.form.find('input[name="appId"]'),o.tokenInput=o.form.find('input[name="token"]'),o.newAccountContainer=e(".js-new-account"),o.errorContainer=o.newAccountContainer.find(".error_messages"),o.divider=o.container.find(".social-login__divider"),o.optInInput=e('.js-facebook_email_opt_in, input[type="checkbox"].js-confirm-email-promotions'),o.fbDisconnect=e("#facebook_disconnect");var a="/account/signin.tmpl";c||!location.pathname.match("/checkout/index.tmpl")&&!location.pathname.match("/checkout/samples.tmpl")||(a="/checkout/index.tmpl"),["/checkout/checkout.tmpl","/checkout/signin.tmpl","/checkout/logginn.tmpl","/checkout/loggain.tmpl","/checkout/login.tmpl"].some((function(e){return location.pathname.match(e)}))&&(a="/checkout/checkout.tmpl"),o.form.attr("action",a);var r=e("").attr({type:"hidden",name:"RETURN_URL"}),s=null;location.pathname.match("/checkout/confirm.tmpl")&&(s="/account/profile_preferences.tmpl",r.val(s),r.appendTo(o.form)),location.search.match("RETURN_URL")?void 0!==(s="function"==typeof URLSearchParams?new URLSearchParams(location.search).get("RETURN_URL"):i("RETURN_URL"))&&(r.val(decodeURIComponent(s)),r.appendTo(o.form)):location.search.match("bvdisplaycode")&&(s=(s=location.pathname+location.search).substr(1),"function"==typeof URLSearchParams&&(new URLSearchParams(location.search),s=(s=location.pathname+location.search).substr(1)),void 0!==s&&(r.val(decodeURIComponent(s)),r.appendTo(o.form),o.form.attr("action",s))),"undefined"!==o.optInInput&&o.optInInput.on("click",(function(){o.form.find("#form--facebook_signin--field--PC_EMAIL_PROMOTIONS").prop("checked",e(this).is(":checked")),o.optInInput.prop("checked",e(this).is(":checked"));var n="Facebook_gnav";location.pathname.match("/checkout/confirm.tmpl")?n="Facebook_order_confirmation":location.pathname.match("/account/signin.tmpl")||location.pathname.match("/account/index.tmpl")?n="Facebook_account_signup":location.pathname.match("/checkout/")&&(n="Facebook_checkout_signin"),o.form.find("#form--facebook_signin--field--LAST_SOURCE").val(n)})),"undefined"!==o.fbDisconnect&&o.fbDisconnect.on("click",(function(e){e.preventDefault(),FB.logout((function(e){t(e),o.fbDisconnect.trigger("submit")}))})),e(".js-facebook-button").on("click",(function(e){e.preventDefault(),FB.login((function(e){"connected"===e.status&&site.facebook.continueWithFacebook()}),{scope:"public_profile,email"})}));var l=function(){if(settings.fb_login_app_id)return settings.fb_login_app_id}();l&&"object"==typeof FB&&function(e){FB.init({appId:e,cookie:!0,xfbml:!0,version:"v2.10"}),settings.fb_logpage_excluded||FB.AppEvents.logPageView(),FB.Event.subscribe("xfbml.render",n)}(l),"object"==typeof FB&&FB.getLoginStatus((function(e){!function(e){location.pathname.match("/account/signin.tmpl")&&location.search.match("_SUBMIT=signout")&&"connected"===e.status&&FB.logout(t)}(e)}))},i=function(e){e=e.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var o=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===o?"":decodeURIComponent(o[1].replace(/\+/g," "))};return{init:function(){c()},continueWithFacebook:function(){var n=e("input.js-facebook_disclaimer");if(n.length&&!n.is(":checked"))return e(".js-fb-disclaimer-error").removeClass("hidden"),!1;FB.getLoginStatus((function(n){!function(n){if("connected"===n.status){var t=n.authResponse.accessToken;o.tokenInput.val(t),e(document.body).append(o.form),o.form.trigger("submit")}else"not_authorized"===n.status?generic.showErrors([{text:site.facebook.not_authorized}],o.errorContainer):"unknown"===n.status||generic.showErrors([{text:site.facebook.login_error}],o.errorContainer)}(n)}))}}}(),window.fbAsyncInit=function(){site.facebook.init()}}(jQuery); //# sourceMappingURL=facebook_login.min.js.map