(m=>{function l(){m(document.body).on("click",".question-reply",function(e){e.preventDefault();var e=m(this),t=(e.data("post-id"),e.data("question-id")),o=m("#comment-"+t),n=m(".question-form-wrapper");e.hasClass("is-replying")||(e.addClass("is-replying").siblings(".cancel-reply").addClass("show"),n.clone().insertAfter(o).show().addClass("question-form-wrapper-clone question-form-wrapper-"+t).removeClass("question-form-wrapper").find('input[name="question_parent_id"]').val(t),m("label[for=question]",".question-form-wrapper-clone").remove())}),m(document.body).on("click",".cancel-reply",function(e){e.preventDefault();e=m(this).data("question-id");m(document.body).trigger("makeaholic_question_reply_cancelled",[e])})}m(document).ready(function(){var e,c,d,p,n,o,t,a,i;function s(){m(".question-navigation",n).on("click","a",function(e){e.preventDefault(),e.stopPropagation();e=((e,t)=>(t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),null===(t=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(e))?"":decodeURIComponent(t[1].replace(/\+/g," "))))(m(this).attr("href"),"current_page");t.find('input[name="current_page"]').val(e),t.trigger("submit")})}e=m("#makeaholic-wc-question"),c=m(".woocommerce-noreviews",e),d=m(".question-list-container",e),p=m(".question-list",e),m(document.body).on("click",".question-form .submit",function(e){var o=m(this),t=o.closest(".question-form"),n=m("[name=question]",t),a=m("input[name=q-author]",t).val(),i=m("input[name=q-email]",t).val(),s=n.val(),l=parseInt(m("input[name=post_id]",t).val()),r=parseInt(m("input[name=question_parent_id]",t).val()),u=parseInt(m(".question-count",d).html()),a={action:"makeaholic_add_comment",security:$makeaholic,author:a,email:i,question:s,post_id:l,question_parent_id:r};o.hasClass("block-updating")||(o.addClass("block-updating"),d.addClass("block-updating"),m.post($makeaholic.ajaxurl,a,function(e){var t;e.success?(r?((t=m(".children","#li-comment-"+r)).length?t.prepend(e.data.response):(t=m('<ol class="children" />')).appendTo("#li-comment-"+r).html(e.data.response),m(document.body).trigger("makeaholic_product_question_child_added",[r])):(u+=1,c.length&&c.remove(),p.prepend(e.data.response)),t=1===u?e.data.single_text:e.data.plural_text,m(".question-count",d).html(u),m(".question-text",d).html(t),n.val(""),m(document.body).trigger("makeaholic_product_question_added",[e.data,!0])):m("<div/>").text(e.data).prependTo(".question-form-message-box").delay(4e3).fadeOut(500,function(){m(this).remove()}),o.removeClass("block-updating"),d.removeClass("block-updating")}),t.on("submit",function(e){e.preventDefault()}),e.preventDefault())}),l(),n=m("#makeaholic-wc-question"),o=m(".question-list-container",n),t=m(".question-search-form",n),a=m(".question-list",n),i=m(".question-toolbar",n),t.on("submit",function(e){e.preventDefault();e=t.serialize();return m.ajax({url:$makeaholic.ajaxurl,data:e,success:function(e){var t,o=m(".question-navigation",n);e.response?a.html(e.response):a.html(m('<li class="question question-no-found"/>').text(e.no_found)),e.pagination?(t=m(e.pagination)?m(e.pagination):"",o.length?o.replaceWith(t):t&&t.insertAfter(a)):o.remove(),m(".question-count",i).html(e.count),m(".question-text",i).html(e.text),s(),m(document.body).trigger("makeaholic_product_question_loaded",e)},beforeSend:function(){var e=0,t=i.offset().top;t-=e=m(document.body).hasClass("header-sticky-enable")?m("#page-header").outerHeight():e,m("html, body").animate({scrollTop:t},800),o.addClass("block-updating")},complete:function(){o.removeClass("block-updating")}}),!1}),s(),m(document.body).on("makeaholic_product_question_added",function(){l()}),m(document.body).on("makeaholic_product_question_child_added makeaholic_question_reply_cancelled",function(e,t){m(".question-reply--"+t).removeClass("is-replying"),m(".cancel-reply--"+t).removeClass("show"),m(".question-form-wrapper-"+t).remove()})})})(jQuery);