'use strict';
import { setLoginState } from '../../../../fd-toolbox/auth/internal-login-states.js';
import { authParam } from '../../../../fd-toolbox/constants/internal-auth-constants.js';
import { defaultLogin } from './standard-login.js';
import { logErrorRaw } from '../../../../fd-toolbox/logging/loggers.js';
import { createError } from '../../../../fd-toolbox/errors/errors.js';
import { loginErrorMessages } from './login-error-constants.js';
import { microsoftOAuth } from './microsoft-login.js';
import { facebookOAuth } from './facebook-login.js';
import { googleOAuth } from './google-login.js';
import { defaultOAuthProviders } from '../../../../fd-toolbox/auth/oauth-provider-types.js';

var __defProp=Object['defineProperty'],__name=(_0x39066a,_0x5e6923)=>__defProp(_0x39066a,'name',{'value':_0x5e6923,'configurable':!![]});async function onLoginSubmit(_0x48fa7d,_0x4ca9a2,_0x463ea2,_0x199989,_0x1cb688){if(!_0x4ca9a2){_0x463ea2(!![]);const _0x20aa19=await defaultLogin(_0x199989,_0x48fa7d['email'],_0x48fa7d['password']);if(!_0x20aa19['isSuccess']){_0x463ea2(![]);return;}const _0xabb10c={'loggedIn':!![],'userId':_0x20aa19['user']['id'],'displayName':_0x20aa19['user']?.['firstName']+'\x20'+_0x20aa19['user']?.['lastName'],'email':_0x20aa19['user']['email'],'imageUrl':_0x20aa19['user']['imageUrl']};setLoginState(_0xabb10c),_0x1cb688?.(_0xabb10c);}}__name(onLoginSubmit,'onLoginSubmit');function getOAuthProvider(_0x321ba9,_0x3ad5ad){const _0x110709=_0x321ba9['get'](authParam);if(_0x110709)return _0x110709;for(const _0x1c4bc7 of _0x3ad5ad??[]){if(_0x1c4bc7['oAuthProviderUrlParam']){const _0xc80bac=_0x321ba9['get'](_0x1c4bc7['oAuthProviderUrlParam']);if(_0xc80bac)return _0xc80bac;}}return void(0xfac+0xbe*0x4+-0x12a4);}__name(getOAuthProvider,'getOAuthProvider');async function handleOAuth(_0x28c1e1,_0x4b5226,_0x332089,_0x38b11a){let _0x43c612;for(const _0x3e107c of _0x332089){if(_0x28c1e1===_0x3e107c['oAuthProvider'])return _0x3e107c['handleOAuth'](_0x4b5226,_0x38b11a);}switch(_0x28c1e1){case defaultOAuthProviders['microsoft']:_0x43c612=microsoftOAuth(_0x4b5226,_0x38b11a);break;case defaultOAuthProviders['facebook']:_0x43c612=facebookOAuth(_0x4b5226,_0x38b11a);break;case defaultOAuthProviders['google']:_0x43c612=googleOAuth(_0x4b5226,_0x38b11a);break;default:{if(!_0x332089)logErrorRaw(createError(loginErrorMessages['unexpectedDefaultWhileLogin']));}}return _0x43c612;}__name(handleOAuth,'handleOAuth');function getLoginButtonId(_0xf77321){return _0xf77321+'LoginButton';}__name(getLoginButtonId,'getLoginButtonId');function isFullSizeOAuthButton(_0x2d8d73,_0x2a863c){const _0x5c86a4=0x2*0xa0d+0x1089+0x2*-0x1250;return !(_0x2a863c%_0x5c86a4)||_0x2a863c%_0x5c86a4===0x1139*0x1+0x27*0xeb+-0x3505*0x1&&_0x2a863c+(0x99*-0x12+-0x189+0xc4c)===_0x2d8d73['length'];}__name(isFullSizeOAuthButton,'isFullSizeOAuthButton');

export { getLoginButtonId, getOAuthProvider, handleOAuth, isFullSizeOAuthButton, onLoginSubmit };
