/**
 * HR Press Lite — Upgrade notice dismiss handler.
 *
 * Sends an AJAX request to permanently dismiss the upgrade notice for the
 * current user. Uses wp_ajax_ (admin-only, logged-in users only).
 *
 * Enqueued via wp_enqueue_script() — no inline <script> tags in PHP.
 *
 * @package HR_Press_Lite
 */
( function ( $ ) {
	'use strict';

	$( document ).on( 'click', '#hrp-dismiss-upgrade-notice', function () {
		var $btn    = $( this );
		var $notice = $btn.closest( '#hrp-upgrade-notice' );
		var nonce   = $btn.data( 'nonce' );

		// Optimistically hide the notice immediately for a smooth UX.
		$notice.slideUp( 250, function () {
			$notice.remove();
		} );

		// Permanently dismiss via AJAX — stored in user meta server-side.
		$.ajax( {
			url:    hrpUpgradeData.ajaxUrl,
			method: 'POST',
			data: {
				action: 'hrp-dismiss-upgrade-notice',
				nonce:  nonce,
			},
		} );
	} );

} )( jQuery );
