"undefined"==typeof _FBBDP&&(_FBBDP={}),_FBBDP.BusinessID=0,_FBBDP.ShopOwnerID=0,_FBBDP.LoginUserEmail="",_FBBDP.LoginUserImage="",_FBBDP.BusinessName="#ddFBBusinessName",_FBBDP.FacebookPopup="#divFbOAuthPopup",_FBBDP.BtnFBoauthContinue="#btnFBoauthContinue",_FBBDP.BtnFBoauthAuthorize="#btnFBoauthAuthorize",_FBBDP.DivFbOAuthPopupContent="#divFbOAuthPopupContent",_FBBDP.DivFbOAuthPopupContentAuthorize="#divFbOAuthPopupContentAuthorize",_FBBDP.Scope_Configuration="configure_page_transactions",_FBBDP.FBE_Scope_Configuration="manage_business_extension",_FBBDP.BusinessName="#ddFBBusinessName",_FBBDP.lblFboAuthBusinessName="#lblFBoAuthBusinessName",_FBBDP.spnFbAuthorizeUserEmail="#fbAuthorizeUserEmail",_FBBDP.dvFbUserImage=".divFBUserImage",_FBBDP.dvFbloginUserInitials=".fbloginUserIntials",_FBBDP.isFromLoginPage=!1,_FBBDP.IsPartnerAccessAuthorizeVal=!1,_FBBDP.dvAuthorize="#dvAuthorize",_FBBDP.dvDeAuthorize="#dvDeAuthorize",_FBBDP.Encryption="",_FBBDP.objBDPData=null,_FBBDP.fbuserloginid=0,_FBBDP.isBDPConfig=!1,_FBBDP.StringisNullOrUndefineOrBlank=function(e){return void 0===e||null==e||""==e||null==e},_FBBDP.FBoAuthPageLoad=function(e,s,o,n){$FacebookLoader(function(){if(ShowLoadingPanelLogin(!1),_FBBDP.StringisNullOrUndefineOrBlank(n)||(_FBBDP.isFromLoginPage=!0,$(_FBBDP.FacebookPopup).removeClass("modal fade"),$(".stepLogin1").addClass("slide1"),$(".stepLogin2").addClass("slide2"),$(".stepLogin4").addClass("slide4"),$(".stepLogin5").addClass("slide5")),_FBBDP.ShopOwnerID=e,("/oauth/fb/home"==window.location.pathname||"/oauth/fb"==window.location.pathname)&&null!=FBoAuthredirect_uri&&""!=FBoAuthredirect_uri&&"undefined"!=typeof FBoAuthredirect_uri&&(navigator.userAgent.indexOf("FBAN")>-1||navigator.userAgent.indexOf("FBAV")>-1))return vagaro.alert({message:"Facebook integration cannot be authorized from a mobile device. Please use a web browser on your computer to complete the authorization. Thank you!",title:"Alert",callback:function(){window.close()}}),!1;"true"==o?_FBBDP.BindBusinessList():(_FBBDP.BusinessID=s,_FBBDP.GoToNextStepPopup(!0)),centerModal($(_FBBDP.FacebookPopup))})},_FBBDP.FBDeoAuth=function(e,s,o){var n;n=_FBBDP.FBE_Scope_Configuration,FB.api("/me","GET",{fields:"id,name"},function(e){""==o||null==o||0==o||o==e.id?""!=e.id&&null!=e.id&&"undefined"!=e.id?FB.api("/"+e.id+"/permissions/"+n,"DELETE",function(s){s&&!s.error?(response_message="Faceboook DeAuthorise is success.",Mode="success"):(response_message=s.error.message,Mode="warning");var o={objRequest:{businessId:_FBBDP.BusinessID,shopOwnerId:_FBBDP.ShopOwnerID,fbuserId:e.id,isdeauthorise:!0,issuccess:!s.error,fbresponse:response_message,isBDPConfig:"False"==_FBBDP.IsFBEoAuthLive}};_FBBDP.ajax("SetBusinessDeAuthorizeForFacebookBDP",o,_FBBDP.GetBusinessDeAuth_Success,_FBBDP.GetBusinessDeAuth_Fail)}):(0==_FBBDP.BusinessID&&(_FBBDP.BusinessID=BusinessID),response_message=e.error.message,_FBBDP.GetBusinessDeAuth_Fail(),_FBBDP.isFromFBIntegrationPage()&&(GetOrUpdateBusinessLastModifiedDetails(29,!1),_FBBDP.IsPartnerAccessAuthorize(_FBBDP.BusinessID)),ShowLoadingPanelLogin(!1)):response_message="You are not authorised person."})};var response_message="",Mode="";_FBBDP.FBDeoAuthPageLoad=function(e,s){if(ShowLoadingPanelLogin(!0),_FBBDP.ShopOwnerID=e,_FBBDP.BusinessID=s,navigator.userAgent.toLowerCase().indexOf("iphone")>-1||navigator.userAgent.toLowerCase().indexOf("ipad")>-1||navigator.userAgent.toLowerCase().indexOf("android")>-1){var o={objRequest:{businessId:_FBBDP.BusinessID,shopOwnerId:_FBBDP.ShopOwnerID,fbuserId:-1,isdeauthorise:!0,issuccess:!0,fbresponse:"From iPhone,Tablet",isBDPConfig:"False"==_FBBDP.IsFBEoAuthLive}};_FBBDP.ajax("SetBusinessDeAuthorizeForFacebookBDP",o,_FBBDP.GetBusinessDeAuth_Success,_FBBDP.GetBusinessDeAuth_Fail)}ShowLoadingPanelLogin(!1),$FacebookLoader(function(){FBAPP.funcLogin(function(o){o?(_FBBDP.FBDeoAuth(e,s,_FBBDP.fbuserloginid),_FBBDP.fbuserloginid=0):ShowLoadingPanelLogin(!1)})})},_FBBDP.GetBusinessDeAuth_Success=function(){ShowLoadingPanelLogin(!1),"success"==Mode&&ShowHideDoneMessageCommon("Faceboook DeAuthorise is success."),"warning"==Mode&&ShowHideWarningMessageCommon(response_message),"failed"==Mode&&ShowHideFailedMessageCommon("Facebook response failed, "+response_message),_FBBDP.isFromFBIntegrationPage()&&(GetOrUpdateBusinessLastModifiedDetails(29,!1),0==_FBBDP.BusinessID&&(_FBBDP.BusinessID=BusinessID),_FBBDP.IsPartnerAccessAuthorize(_FBBDP.BusinessID))},_FBBDP.GetBusinessDeAuth_Fail=function(){ShowLoadingPanelLogin(!1),ShowHideFailedMessageCommon(response_message)},_FBBDP.HideFBoAuthPopup=function(){window.location.href.toLocaleLowerCase().indexOf("merchants/settings/premiumfeature/integration/facebook")>0?$(_FBBDP.FacebookPopup).modal("hide"):location.href="/"},_FBBDP.BindBusinessList=function(){ShowLoadingPanelLogin(!0);var e={objRequest:{shopOwnerID:_FBBDP.ShopOwnerID}};_FBBDP.ajax("GetBusinessListForFacebookBDP",e,_FBBDP.GetBusinessList_Success,_FBBDP.GetBusinessList_Failure)},_FBBDP.GetBusinessList_Success=function(e){if(null!=e&&e.length>0){for(var s=0;s<=e.length-1;s++){var o=new Option(e[s].businessName,e[s].businessID,false,false);$(_FBBDP.BusinessName).append($(o))}1==e.length?(1!=_FBBDP.isFromLoginPage&&$(_FBBDP.FacebookPopup).modal("show"),_FBBDP.GoToNextStepPopup(!0)):1==_FBBDP.isFromLoginPage?$(_FBBDP.FacebookPopup).show():$(_FBBDP.FacebookPopup).modal("show")}else $(_FBBDP.FacebookPopup).modal("hide");ShowLoadingPanelLogin(!1)},_FBBDP.GetBusinessList_Failure=function(e){ShowLoadingPanelLogin(!1)},_FBBDP.GoToNextStepPopup=function(e){1==e&&(1==_FBBDP.isFromLoginPage&&$(".stepLogin5").addClass("slide5"),$(_FBBDP.DivFbOAuthPopupContent).hide(),$(_FBBDP.BtnFBoauthContinue).hide(),$(_FBBDP.DivFbOAuthPopupContentAuthorize).show(),setTimeout(function(){centerModal($(_FBBDP.FacebookPopup))}),$(_FBBDP.BtnFBoauthAuthorize).show(),$(_FBBDP.spnFbAuthorizeUserEmail).text(_FBBDP.LoginUserEmail),window.location.href.toLocaleLowerCase().indexOf("merchants/settings/premiumfeature/integration/facebook")>0?($(_FBBDP.dvFbUserImage).css("background-image",$("#spnLoginUserImage").css("background-image")),$(_FBBDP.dvFbloginUserInitials).text($("#spnLoginUserImage").text()),$(_FBBDP.lblFboAuthBusinessName).text(GetBusinessName()),"none"!=$("#divUserPhoto").css("background-image")&&"none"!=$(".divFBUserImage").css("background-image")||$(".fbintialsnames").css("display","block"),$(_FBBDP.FacebookPopup).modal("show")):("none"!=$("#divUserPhoto").css("background-image")?($(_FBBDP.dvFbUserImage).css("background-image",$("#divUserPhoto").css("background-image")),$(".loginUserIntials").length>1?$(_FBBDP.dvFbloginUserInitials).text($(".loginUserIntials")[0].innerText):$(_FBBDP.dvFbloginUserInitials).text($(".loginUserIntials").text())):($(".fbintialsnames").css("display","block"),$(_FBBDP.dvFbUserImage).css("background-image","none"),$(".loginUserIntials").length>1?$(_FBBDP.dvFbloginUserInitials).text($(".loginUserIntials")[0].innerText):$(_FBBDP.dvFbloginUserInitials).text($(".loginUserIntials").text())),$(_FBBDP.lblFboAuthBusinessName).text($(_FBBDP.BusinessName+" option:selected").text()),_FBBDP.BusinessID=$(_FBBDP.BusinessName+" option:selected").val()),"False"==_FBBDP.IsFBEoAuthLive&&_FBBDP.GetBusinessEncryptedValue())},_FBBDP.GetBusinessEncryptedValue=function(){var e={objRequest:{shopOwnerID:_FBBDP.ShopOwnerID,businessID:_FBBDP.BusinessID},IsBusinessToken:!0};_FBBDP.ajax("getfacebookencrypted",e,_FBBDP.GetBusinessEncrypted_Success,_FBBDP.GetBusinessList_CallBack)},_FBBDP.GetBusinessEncrypted_Success=function(e){_FBBDP.Encryption=e},_FBBDP.FBOauthAuthorize=function(){setTimeout(function(){_FBBDP.SetBusinessAuthorizeForFacebookBDP()},500),ShowLoadingPanelLogin(!0)},_FBBDP.SetBusinessAuthorizeForFacebookBDP=function(){var e={objRequest:{businessId:_FBBDP.BusinessID,shopOwnerId:_FBBDP.ShopOwnerID}};_FBBDP.ajax("SetBusinessAuthorizeForFacebookBDP",e,_FBBDP.GetSuccess_CallBack,_FBBDP.GetBusinessList_CallBack,null,null,!0)},_FBBDP.GetSuccess_CallBack=function(e){if(_FBBDP.objBDPData=e,!_FBBDP.StringisNullOrUndefineOrBlank(_FBBDP.objBDPData))if("/oauth/fb/home"!=window.location.pathname&&"/oauth/fb"!=window.location.pathname||null==FBoAuthredirect_uri||""==FBoAuthredirect_uri||"undefined"==typeof FBoAuthredirect_uri)_FBBDP.openFBLoginPopup();else if(FBoAuthredirect_uri=decodeURIComponent(FBoAuthredirect_uri),/https?:\/\/(www\.|m\.|l\.)?(svcscm\.\d{4}\.od\.)?(facebook|instagram|whatsapp)\.com(\/.*)?/.test(FBoAuthredirect_uri)){var s="",o="";o=FBoAuthredirect_uri.indexOf("?")>0?"&":"?",s="False"==_FBBDP.IsFBEoAuthLive?FBoAuthredirect_uri+o+'extras={app_access_headers:\'{"X-USER-ACCESS-TOKEN": "'+_FBBDP.Encryption+"\"}',repeat:false}":FBoAuthredirect_uri+o+'extras={"setup":{"external_business_id":"'+_FBBDP.objBDPData.business_token+'","timezone":"'+_FBBDP.objBDPData.business_time_zone+'","currency":"'+_FBBDP.objBDPData.currency+'","business_vertical":"SERVICES"},"business_config":{"business":{"name":"'+encodeURIComponent(_FBBDP.objBDPData.business_name)+'"},"page_cta":{"enabled":true,"cta_button_text":"'+_FBBDP.objBDPData.cta_button_text+'","cta_button_url":"'+_FBBDP.objBDPData.cta_button_url+'","below_button_text":"Powered by Vagaro"},"page_card": {"enabled":true,"see_all_text":"'+_FBBDP.objBDPData.see_all_text+'","see_all_url":"'+_FBBDP.objBDPData.see_all_url+'","cta_button_text":"Book"},"ig_cta":{"enabled":true,"cta_button_text":"'+_FBBDP.objBDPData.cta_button_text+'","cta_button_url":"'+_FBBDP.objBDPData.cta_button_url+'"}},"repeat":false}',window.location.href=s}else _FBBDP.openFBLoginPopup();_FBBDP.isFromFBIntegrationPage()&&GetOrUpdateBusinessLastModifiedDetails(29,!1)},_FBBDP.GetBusinessList_CallBack=function(e){_FBBDP.isFromFBIntegrationPage()&&GetOrUpdateBusinessLastModifiedDetails(29,!1),ShowLoadingPanelLogin(!1)},_FBBDP.openFBLoginPopup=function(){ShowLoadingPanelLogin(!1),$FacebookLoader(function(){"False"==_FBBDP.IsFBEoAuthLive?(FBAPP.objBDPEncryption=_FBBDP.Encryption,FBAPP.IsFBEoAuthLive=!1):(FBAPP.objBDPEncryption=_FBBDP.objBDPData,FBAPP.IsFBEoAuthLive=!0),FBAPP.funcRequestPagesAppForFBBDP(function(e){console.log("Response 1-"+JSON.stringify(e)),void 0!==e&&null!=e&&e.length>0?(console.log("Response 2-"+JSON.stringify(e)),FB.api("/me","GET",{fields:"id,name"},function(e){var s=e.id;_FBBDP.GetAuthorizedSuccess(!0,s),FBAPP.objBDPEncryption=null})):ShowLoadingPanelLogin(!1)})})},_FBBDP.GetAuthorizedSuccess=function(e,s){var o={objRequest:{shopOwnerID:_FBBDP.ShopOwnerID,businessID:_FBBDP.BusinessID,fbUserLoginID:s,access_token:"True"==_FBBDP.IsFBEoAuthLive?FBAPI.accessToken:""},isAuthorize:e};_FBBDP.ajax("SetBusinessPartnerAccessAuthorizeRequest",o,_FBBDP.PartnerAccessAuthorizeRequest_Success,_FBBDP.GetBusinessList_CallBack)},_FBBDP.PartnerAccessAuthorizeRequest_Success=function(){if("True"==_FBBDP.IsFBEoAuthLive&&_FBBDP.UpdateFacebookInventory(),window.location.href.toLocaleLowerCase().indexOf("oauth/fb")>0&&($(_FBBDP.FacebookPopup).modal("hide"),window.location.href="/ShopOwner/ChooseBusiness.aspx?RedirectPageURL=/merchants/settings/premiumfeature/integration/facebook"),window.location.href.toLocaleLowerCase().indexOf("choosebusiness.aspx")>0)return ShowHideDoneMessageCommon("Faceboook authorized is successfull"),$(_FBBDP.FacebookPopup).modal("hide"),ShowLoadingPanelLogin(!1),!1;if(_FBBDP.isFromFBIntegrationPage())return GetOrUpdateBusinessLastModifiedDetails(29,!1),0==_FBBDP.BusinessID&&(_FBBDP.BusinessID=BusinessID),_FBBDP.IsPartnerAccessAuthorize(_FBBDP.BusinessID),ShowHideDoneMessageCommon("Faceboook authorized is successfull"),$(_FBBDP.FacebookPopup).modal("hide"),ShowLoadingPanelLogin(!1),!1;$(window).width();ShowLoadingPanelLogin(!1)},_FBBDP.UpdateFacebookInventory=function(){var e={objRequest:{businessId:_FBBDP.BusinessID,access_token:FBAPI.accessToken,business_token:_FBBDP.objBDPData.business_token,shopOwnerId:_FBBDP.ShopOwnerID}};_FBBDP.ajax("UploadFBEBusinessData",e,_FBBDP.UpdateFacebookInventory_Success,_FBBDP.UpdateFacebookInventory_Fail)},_FBBDP.UpdateFacebookInventory_Success=function(e){ShowLoadingPanelLogin(!1)},_FBBDP.UpdateFacebookInventory_Fail=function(){ShowHideFailedMessageCommon("Something went wrong. Please try again"),ShowLoadingPanelLogin(!1)},_FBBDP.isFromFBIntegrationPage=function(){return window.location.href.toLocaleLowerCase().indexOf("merchants/settings/premiumfeature/integration/facebook")>0},_FBBDP.IsPartnerAccessAuthorize=function(e){var s={objRequest:{businessId:e,shopOwnerId:_FBBDP.ShopOwnerID}};_FBBDP.ajax("IsPartnerAccessAuthorize",s,_FBBDP.IsPartnerAccessAuthorize_CallBack,_FBBDP.GetBusinessList_CallBack)},_FBBDP.IsPartnerAccessAuthorize_CallBack=function(e){_FBBDP.StringisNullOrUndefineOrBlank(e)||(_FBBDP.IsPartnerAccessAuthorizeVal=e.isAuthorize,_FBBDP.isBDPConfig=e.isBDPConfig,_FBBDP.fbuserloginid=e.fbUserLoginID,_FBBDP.IsPartnerAccessAuthorizeVal?($(_FBBDP.dvAuthorize).hide(),$(_FBBDP.dvDeAuthorize).show()):($(_FBBDP.dvAuthorize).show(),$(_FBBDP.dvDeAuthorize).hide()))},_FBBDP.ajax=function(e,s,o,n,i,B,t){var a=new vagaro.ajax;a.datamodel.Token=e,a.datamodel.data=s,a.datamodel.callback=o,a.datamodel.Error=n,0==t&&(a.datamodel.async=!1),void 0!==B&&1==B&&(a.datamodel.ErrorMessage=_invoice.Empty),i?a.PostQue():a.Post()};