/**
 * Upgrade banner dismiss handler.
 *
 * Receives ajaxUrl + nonce via wp_add_inline_script as `strpSubUpgradeBanner`.
 */
(function () {
	var btn = document.getElementById( 'strp-sub-dismiss-banner' );
	if ( ! btn ) {
		return;
	}
	btn.addEventListener( 'click', function () {
		var banner = document.getElementById( 'strp-sub-upgrade-banner' );
		if ( banner ) {
			banner.style.display = 'none';
		}
		if ( typeof strpSubUpgradeBanner === 'undefined' ) {
			return;
		}
		var xhr = new XMLHttpRequest();
		xhr.open( 'POST', strpSubUpgradeBanner.ajaxUrl );
		xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
		xhr.send(
			'action=strp_sub_dismiss_upgrade_banner&_wpnonce=' +
			encodeURIComponent( strpSubUpgradeBanner.nonce )
		);
	} );
})();
