/* global utils */

function showLoginContentInsteadOfOtherLoginMethods() {
	utils.changeDisplay(otherLoginMethodsMobileView, 'hidden', 'block');
	utils.changeDisplay(loginContent, 'block', 'hidden');
}

const loginContent = document.querySelector('#loginContent');
const accessAppMobileBtnContainer = document.querySelector('#accessAppMobileBtnContainer');
const securityKeyMobileBtnContainer = document.querySelector('#securityKeyMobileBtnContainer');
const mobileOtherLoginMethodsBtn = document.querySelector('#mobileOtherLoginMethodsBtn');
const otherLoginMethodsMobileView = document.querySelector('#otherLoginMethodsMobileView');
// TODO: set when on eid branch
const onSwiyuLogin = false;

accessAppMobileBtnContainer.addEventListener('click', () => {
	if (onSwiyuLogin === false) {
		showLoginContentInsteadOfOtherLoginMethods();
		document.dispatchEvent(new Event('showAccessAppLogin'));
	}
	else {
		const form = utils.createForm();
		utils.addInput(form, 'oid4vp', 'APP');
		document.body.appendChild(form);
		form.submit();
	}
});

securityKeyMobileBtnContainer.addEventListener('click', () => {
	if (onSwiyuLogin === false) {
		showLoginContentInsteadOfOtherLoginMethods();
		document.dispatchEvent(new Event('showSecurityKeyLogin'));
	}
	else {
		const form = utils.createForm();
		utils.addInput(form, 'oid4vp', 'FIDO2');
		document.body.appendChild(form);
		form.submit();
	}
});

mobileOtherLoginMethodsBtn.addEventListener('click', () => {
	utils.changeDisplay(loginContent, 'hidden', 'block');
	utils.changeDisplay(otherLoginMethodsMobileView, 'block', 'hidden');
});
