/* Blocksy header account modal — reset Turnstile when opening account panel */
document.addEventListener('DOMContentLoaded', function () {
	if (typeof turnstile === 'undefined') {
		return;
	}
	document.querySelectorAll('.ct-header-account').forEach(function (element) {
		element.addEventListener('click', function () {
			try {
				turnstile.remove('.ct-account-panel #cf-turnstile-woo-register');
			} catch (e) {}
			setTimeout(function () {
				try {
					if (document.querySelector('.ct-account-panel #loginform .cf-turnstile')) {
						turnstile.reset('.ct-account-panel #loginform .cf-turnstile');
					}
					if (document.querySelector('.ct-account-panel #registerform .cf-turnstile')) {
						turnstile.reset('.ct-account-panel #registerform .cf-turnstile');
						turnstile.remove('.ct-account-panel #registerform .sct-woocommerce-register');
					}
				} catch (e2) {}
			}, 500);
		});
	});
});
