/* 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 () {
			setTimeout(function () {
				try {
					var loginWidget = document.querySelector('.ct-account-panel #loginform .cf-turnstile');
					if (loginWidget && typeof turnstile.reset === 'function') {
						turnstile.reset(loginWidget);
					}
					var registerWidget = document.querySelector('.ct-account-panel #registerform .cf-turnstile');
					if (registerWidget && typeof turnstile.reset === 'function') {
						turnstile.reset(registerWidget);
					}
				} catch (e) {}
			}, 500);
		});
	});
});
