"use strict";

var _wp = wp,
    apiFetch = _wp.apiFetch;
jQuery(function ($) {
  var narzo_liteRedirectToKitPage = function narzo_liteRedirectToKitPage(res) {
    // if( res?.status && 'active' === res.status ) {
    window.location = "".concat(window.narzo_lite.gutenify_kit_gallery); // }
  }; // Activate Gutenify.


  $(document).on('click', '.narzo-lite-activate-gutenify', function () {
    $(this).html('<span class="dashicons dashicons-update"></span> Loading...').addClass('narzo-lite-importing-gutenify');
    apiFetch({
      path: '/wp/v2/plugins/gutenify/gutenify',
      method: 'POST',
      data: {
        "status": "active"
      }
    }).then(function (res) {
      narzo_liteRedirectToKitPage(res);
    })["catch"](function () {
      narzo_liteRedirectToKitPage({});
    });
  });
  $(document).on('click', '.narzo-lite-install-gutenify', function () {
    $(this).html('<span class="dashicons dashicons-update"></span> Loading...').addClass('narzo-lite-importing-gutenify');
    apiFetch({
      path: '/wp/v2/plugins',
      method: 'POST',
      data: {
        "slug": "gutenify",
        "status": "active"
      }
    }).then(function (res) {
      narzo_liteRedirectToKitPage(res);
    })["catch"](function () {
      narzo_liteRedirectToKitPage({});
    });
  });
  $(document).on('click', '.narzo-lite-admin-notice .notice-dismiss', function () {
    console.log(ajaxurl + "?action=narzo_lite_hide_theme_info_noticebar");
    apiFetch({
      url: ajaxurl + "?action=narzo_lite_hide_theme_info_noticebar&narzo_lite-nonce-name=".concat(window.narzo_lite.narzo_lite_nonce),
      method: 'POST'
    }).then(function (res) {
      console.log(res);
    })["catch"](function (res) {
      console.log(res);
    });
  });
});