(function () {
	'use strict';

	if (typeof truebeReviewAsk === 'undefined') {
		return;
	}

	function init() {
		var notice = document.getElementById('truebe-review-notice');
		var button = document.getElementById('truebe-review-dismiss');

		if (!notice || !button) {
			return;
		}

		button.addEventListener('click', function () {
			notice.style.display = 'none';

			var data = new URLSearchParams();
			data.append('action', 'truebe_dismiss_review');
			data.append('_ajax_nonce', truebeReviewAsk.nonce);

			fetch(truebeReviewAsk.ajax, {
				method: 'POST',
				credentials: 'same-origin',
				body: data
			});
		});
	}

	if (document.readyState === 'loading') {
		document.addEventListener('DOMContentLoaded', init);
	} else {
		init();
	}
})();