(function() {
	'use strict';

	document.addEventListener('click', function(event) {
		var button = event.target.closest('.seovaultseo-notice-review .seovaultseo-notice-action');
		if (!button) {
			return;
		}

		var action = button.getAttribute('data-action');
		if ('rate' === action) {
			return;
		}

		event.preventDefault();
		var config = window.seovaultseo_notices || {};
		if (!config.ajax_url || !config.nonce) {
			return;
		}

		var body = new URLSearchParams({
			action: 'seovaultseo_notice_response',
			nonce: config.nonce,
			notice_action: action
		});

		fetch(config.ajax_url, {
			method: 'POST',
			headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
			body: body.toString(),
			credentials: 'same-origin'
		}).finally(function() {
			var notice = button.closest('.seovaultseo-notice-review');
			if (notice) {
				notice.remove();
			}
		});
	});
}());
