!function(){function t(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}System.register([],function(e,i){"use strict";return{execute:function(){e("N",class{constructor(){t(this,"drawer",null),t(this,"panel",null),t(this,"overlay",null),t(this,"markAllReadButton",null),t(this,"isOpen",!1),this.init()}get $(){return window.jQuery}init(){this.drawer=this.$("#adt-notification-drawer"),this.drawer&&0!==this.drawer.length&&(this.overlay=this.drawer.find(".adt-notification-drawer__overlay"),this.panel=this.drawer.find(".adt-notification-drawer__panel"),this.markAllReadButton=this.drawer.find(".adt-notification-drawer__mark-all-read"),this.bindEvents())}bindEvents(){var t,e;null===(t=this.overlay)||void 0===t||t.on("click",()=>this.close()),null===(e=this.markAllReadButton)||void 0===e||e.on("click",t=>{t.preventDefault(),this.markAllAsRead()}),this.$(document).on("keydown",t=>{"Escape"===t.key&&this.isOpen&&this.close()})}open(){var t,e,i,a,n;this.isOpen||(null===(t=this.drawer)||void 0===t||t.css("opacity",""),null===(e=this.panel)||void 0===e||e.css("transform",""),null===(i=this.drawer)||void 0===i||i.removeClass("adt-tw-pointer-events-none").addClass("adt-tw-pointer-events-auto"),null===(a=this.overlay)||void 0===a||a.removeClass("adt-tw-opacity-0 adt-tw-pointer-events-none").addClass("adt-tw-opacity-100 adt-tw-pointer-events-auto"),null===(n=this.panel)||void 0===n||n.removeClass("adt-tw-translate-x-full").addClass("adt-tw-translate-x-0"),this.isOpen=!0,this.$("body").css("overflow","hidden"))}close(){var t,e;this.isOpen&&(null===(t=this.overlay)||void 0===t||t.removeClass("adt-tw-opacity-100 adt-tw-pointer-events-auto").addClass("adt-tw-opacity-0 adt-tw-pointer-events-none"),null===(e=this.panel)||void 0===e||e.removeClass("adt-tw-translate-x-0").addClass("adt-tw-translate-x-full"),setTimeout(()=>{var t,e,i;null===(t=this.drawer)||void 0===t||t.css("opacity","0"),null===(e=this.panel)||void 0===e||e.css("transform","translateX(100%)"),null===(i=this.drawer)||void 0===i||i.removeClass("adt-tw-pointer-events-auto").addClass("adt-tw-pointer-events-none")},300),this.isOpen=!1,this.$("body").css("overflow","unset"))}toggle(){this.isOpen?this.close():this.open()}markAllAsRead(){var t,e,i;const a=null===(t=this.drawer)||void 0===t?void 0:t.find(".adt-notification-drawer__item"),n=[];if(null==a||a.each((t,e)=>{const i=this.$(e).data("notice-id");i&&n.push(i)}),0===n.length)return;const o=null===(e=this.markAllReadButton)||void 0===e?void 0:e.text();null===(i=this.markAllReadButton)||void 0===i||i.text(window.wp.i18n.__("Marking...","woo-product-feed-pro")).prop("disabled",!0),this.$.ajax({url:window.ajaxurl,type:"POST",data:{action:"adt_pfp_mark_all_read",notice_ids:n,nonce:window.adtNotificationsData.markAllReadNonce},success:t=>{var e,i;t.success?(null==a||a.fadeOut(200,()=>{a.remove(),this.updateBadgeCount(),this.checkIfEmpty()}),null===(e=this.markAllReadButton)||void 0===e||e.hide()):null===(i=this.markAllReadButton)||void 0===i||i.text(o).prop("disabled",!1)},error:()=>{var t;null===(t=this.markAllReadButton)||void 0===t||t.text(o).prop("disabled",!1)}})}updateBadgeCount(){var t;const e=(null===(t=this.drawer)||void 0===t?void 0:t.find(".adt-notification-drawer__item").length)||0,i=this.$(".adt-notification-icon__badge"),a=this.$(".toplevel_page_woo-product-feed .update-plugins .update-count");var n,o;e>0?(null==i||i.text(e).show(),null==a||a.text(e),null===(n=this.markAllReadButton)||void 0===n||n.show().prop("disabled",!1).text(window.wp.i18n.__("Mark all as read","woo-product-feed-pro"))):(null==i||i.remove(),null==a||a.parent().remove(),null===(o=this.markAllReadButton)||void 0===o||o.hide())}checkIfEmpty(){var t,e,i;const a=(null===(t=this.drawer)||void 0===t?void 0:t.find(".adt-notification-drawer__item").length)||0,n=null===(e=this.drawer)||void 0===e?void 0:e.find(".adt-notification-drawer__empty"),o=null===(i=this.drawer)||void 0===i?void 0:i.find(".adt-notification-drawer__list");0===a?(null==o||o.hide(),null==n||n.show()):(null==n||n.hide(),null==o||o.show())}})}}})}();
