System.register([],function(t,e){"use strict";return{execute:function(){t("N",class{drawer=null;panel=null;overlay=null;markAllReadButton=null;isOpen=!1;constructor(){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(){this.overlay?.on("click",()=>this.close()),this.markAllReadButton?.on("click",t=>{t.preventDefault(),this.markAllAsRead()}),this.$(document).on("keydown",t=>{"Escape"===t.key&&this.isOpen&&this.close()})}open(){this.isOpen||(this.drawer?.css("opacity",""),this.panel?.css("transform",""),this.drawer?.removeClass("adt-tw-pointer-events-none").addClass("adt-tw-pointer-events-auto"),this.overlay?.removeClass("adt-tw-opacity-0 adt-tw-pointer-events-none").addClass("adt-tw-opacity-100 adt-tw-pointer-events-auto"),this.panel?.removeClass("adt-tw-translate-x-full").addClass("adt-tw-translate-x-0"),this.isOpen=!0,this.$("body").css("overflow","hidden"))}close(){this.isOpen&&(this.overlay?.removeClass("adt-tw-opacity-100 adt-tw-pointer-events-auto").addClass("adt-tw-opacity-0 adt-tw-pointer-events-none"),this.panel?.removeClass("adt-tw-translate-x-0").addClass("adt-tw-translate-x-full"),setTimeout(()=>{this.drawer?.css("opacity","0"),this.panel?.css("transform","translateX(100%)"),this.drawer?.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(){const t=this.drawer?.find(".adt-notification-drawer__item"),e=[];if(t?.each((t,a)=>{const i=this.$(a).data("notice-id");i&&e.push(i)}),0===e.length)return;const a=this.markAllReadButton?.text();this.markAllReadButton?.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:e,nonce:window.adtNotificationsData.markAllReadNonce},success:e=>{e.success?(t?.fadeOut(200,()=>{t.remove(),this.updateBadgeCount(),this.checkIfEmpty()}),this.markAllReadButton?.hide()):this.markAllReadButton?.text(a).prop("disabled",!1)},error:()=>{this.markAllReadButton?.text(a).prop("disabled",!1)}})}updateBadgeCount(){const t=this.drawer?.find(".adt-notification-drawer__item").length||0,e=this.$(".adt-notification-icon__badge"),a=this.$(".toplevel_page_woo-product-feed .update-plugins .update-count");t>0?(e?.text(t).show(),a?.text(t),this.markAllReadButton?.show().prop("disabled",!1).text(window.wp.i18n.__("Mark all as read","woo-product-feed-pro"))):(e?.remove(),a?.parent().remove(),this.markAllReadButton?.hide())}checkIfEmpty(){const t=this.drawer?.find(".adt-notification-drawer__item").length||0,e=this.drawer?.find(".adt-notification-drawer__empty"),a=this.drawer?.find(".adt-notification-drawer__list");0===t?(a?.hide(),e?.show()):(e?.hide(),a?.show())}})}}});
