import { createContext } from 'react';

const stub = () => {
	throw new Error('You forgot to wrap your app with an WidgetProvider!');
};

export const initialContext: WidgetProvider.InitialContext = {
	authOptions: {
		redirectUri: `${window.location.origin}`,
		responseType: 'token id_token',
		// responseMode: 'fragment',
		connections: {
			password: 'Username-Password-Authentication',
		},
	},
	isInvalidCaptcha: false,
	flow: 'email-link',
	initialized: false,
	isAuthenticated: false,
	isLoading: false,
	isLoadingAuth: false,
	themeContent: {
		email: {
			title: 'Welcome',
			subtitle: 'Enter your email address to continue',
			hideLogo: false,
		},
		'email-link': {
			title: 'Welcome',
			subtitle: 'Enter your email address to continue',
			hideLogo: false,
		},
		'email-verify': {
			title: 'Link Sent!',
			hideLogo: true,
		},
		password: {
			title: 'Welcome',
			subtitle: 'Enter your password to continue',
			hideLogo: false,
		},
		sms: {
			title: 'Welcome',
			subtitle: 'Enter your phone number to continue',
			hideLogo: false,
		},
	} as Theme.Contents,
	goTo: stub,
	loginWithPassword: stub,
	loginWithRedirect: stub,
	renderCaptcha: stub,
	sendMagicLink: stub,
	socialLogin: stub,
	updateUser: stub,
	verifyMagicLink: stub,
};

export const WidgetContext = createContext(initialContext);
