(()=>{"use strict";!function(t){var s=function(){var s=(window.RTSB||{}).cache,i=null==s?void 0:s.create("wishlist");return{name:"wishlist",version:"1.0.0",init:function(){return this.bindWishlistButtonEvents(),this.initWishlistEventActions(),i.set("initialized",!0),this},bindWishlistButtonEvents:function(){var s=this,r=t(document),e=".rtsb-wishlist-add",n=".rtsb-wishlist-remove";r.off("click",e).off("click",n).on("click",e,function(e){e.preventDefault();var n=t(e.currentTarget),o=n.data("product_id");if(!o)return s;var a="undefined"!=typeof RTSB&&RTSB.toastr||window.rtsbToastr;if(null==i?void 0:i.get("add_".concat(o)))return s;null==i||i.set("add_".concat(o),!0),t.ajax({type:"POST",headers:{"X-WP-Nonce":rtsbWishlistParams.rest_nonce},url:rtsbWishlistParams.resturl+"rtsb/v1/wishlist/add_to_list/",data:{product_id:o},beforeSend:function(){n.rtsbBlock(),r.trigger("rtsb.wishlist.adding",[n])},success:function(t){var s,e=rtsbWishlistParams.notice.added;rtsbWishlistParams.notice.browse&&(e=' <a href="'+rtsbWishlistParams.pageUrl+'">'+rtsbWishlistParams.notice.browse+"</a>"),t.success?(null==i||i.set("status_".concat(o),"added"),r.trigger("rtsb.wishlist.added",[t,n]),s=rtsbWishlistParams.notice.added,a.success(e,s)):(r.trigger("rtsb.wishlist.adding_error",[t,n]),t.data&&"exist"===t.data.action?(s=rtsbWishlistParams.notice.exist,a.success(e,s)):a.error(t.message)),n.rtsbUnblock()},error:function(t){r.trigger("rtsb.wishlist.adding_error",[t,n]),n.rtsbUnblock(),"authentication_error"===t.responseJSON.code?a.error(t.responseJSON.message):a.error(rtsbWishlistParams.notice.error)},complete:function(t){null==i||i.delete("add_".concat(o)),r.trigger("rtsb.wishlist.adding_completed",[t,n])}})}).on("click",n,function(e){e.preventDefault();var n=t(e.currentTarget),o=n.data("product_id");if(!o)return s;var a="undefined"!=typeof RTSB&&RTSB.toastr||window.rtsbToastr;if(null==i?void 0:i.get("remove_".concat(o)))return s;null==i||i.set("remove_".concat(o),!0),t.ajax({type:"POST",headers:{"X-WP-Nonce":rtsbWishlistParams.rest_nonce},url:rtsbWishlistParams.resturl+"rtsb/v1/wishlist/remove_from_list/",data:{product_id:o},beforeSend:function(){n.rtsbBlock(),r.trigger("rtsb.wishlist.removing",[n])},success:function(t){t.success?(null==i||i.set("status_".concat(o),"removed"),r.trigger("rtsb.wishlist.removed",[t,n]),a.success(rtsbWishlistParams.notice.removed,"",{toastClass:"toast toast-wishlist-removed"})):(r.trigger("rtsb.wishlist.removing_error",[t,n]),a.error(t.message)),n.rtsbUnblock()},error:function(t){r.trigger("rtsb.wishlist.removing_error",[t,n]),n.rtsbUnblock(),a.error(rtsbWishlistParams.notice.error)},complete:function(t){null==i||i.delete("remove_".concat(o)),r.trigger("rtsb.wishlist.removing_completed",[t,n])}})})},initWishlistEventActions:function(){t(document).on("rtsb.wishlist.added",function(s,i,r){r.removeClass("rtsb-wishlist-add").addClass("rtsb-wishlist-remove"),t(".rtsb-wishlist-counter").text(i.data.item_count),r.attr("original-title",rtsbWishlistParams.notice.remove_wishlist),r.find(".icon i").removeClass("rtsb-icon-heart-empty").addClass("rtsb-icon-heart"),r.find(".button-text").text(rtsbWishlistParams.notice.remove_wishlist)}).on("rtsb.wishlist.removed",function(s,i,r){r.removeClass("rtsb-wishlist-remove").addClass("rtsb-wishlist-add").parents('tr.rtsb-wl-product[data-product_id="'+i.data.product_id+'"]').slideUp("slow",function(){t(this).remove()}),t(".rtsb-wishlist-counter").text(i.data.item_count),r.attr("original-title",rtsbWishlistParams.notice.add_to_wishlist),r.find(".icon i").removeClass("rtsb-icon-heart").addClass("rtsb-icon-heart-empty"),r.find(".button-text").text(rtsbWishlistParams.notice.button_text)})},destroy:function(){i.clear("wishlist")}}};if(window.RTSB&&window.RTSB._initialized){var i;null===(i=RTSB.modules.register("wishlist",s))||void 0===i||i.init()}else{var r=s();t.fn.rtsb_wishlist=function(){r.bindWishlistButtonEvents()},t.fn.rtsb_wishlist(),r.initWishlistEventActions()}}(jQuery)})();