document.addEventListener("DOMContentLoaded",function(){if(void 0!==e||"undefined"!=typeof jQuery){var e=window.jQuery||window.$,o=!1,t="",n=function(e,o,t){var n=new Date;n.setDate(n.getDate()+t),o=encodeURIComponent(o)+(null==t?"":"; expires="+n.toUTCString()),document.cookie="fob-comment-".concat(e,"=").concat(o,"; path=/")},i=function(e){document.cookie="fob-comment-".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/")};e(document).find(".fob-comment-form input").each(function(o,t){var n=e(t).prop("name"),i=function(e){var o=document.cookie.match(new RegExp("(^| )fob-comment-".concat(e,"=([^;]*)(;|$)")));return null!=o?decodeURIComponent(o[2]):null}(n);i&&"null"!==i&&("cookie_consent"===n?e(t).prop("checked",!0):e(t).val(e(t).val()||i))});var r=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:fobComment.listUrl,t=e(document).find(".fob-comment-list-section"),n=t.find(".fob-comment-list-loading"),i=t.find(".fob-comment-list-content");n.show(),i.hide(),e.ajax({url:o,type:"GET",dataType:"json",success:function(o){var r,c=o.error,a=o.data,m=o.message;if(n.hide(),void 0!==(null===(r=window)||void 0===r?void 0:r.Theme)&&c)return Theme.showError(m),void t.hide();var d=a.title,l=a.html;a.comments.total<1?t.hide():(t.show(),i.show(),e(document).find(".fob-comment-list-title").text(d),e(document).find(".fob-comment-list-wrapper").html(l))},error:function(){n.hide(),t.hide()}})};e(document).on("submit",".fob-comment-form",function(c){c.stopPropagation(),c.preventDefault();var a=e(c.currentTarget),m=a.find('button[type="submit"], input[type="submit"]');if(!a.data("submitting")&&(void 0===e.fn.validate||e(".fob-comment-form").valid())){var d=new FormData(a[0]),l=a.find('input[type="checkbox"][name="cookie_consent"]'),f=l.length>0&&l.is(":checked");a.data("submitting",!0);var s=m.text()||m.val();m.prop("disabled",!0).addClass("fob-btn-loading"),m.is("button")&&m.html('<svg class="fob-spinner" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>'+s);var u=function(){a.data("submitting",!1),m.prop("disabled",!1).removeClass("fob-btn-loading"),m.is("button")&&m.text(s)};e.ajax({url:a.prop("action"),type:"POST",data:d,processData:!1,contentType:!1,dataType:"json",success:function(c){var m,l=c.error,s=c.message;if(u(),void 0!==(null===(m=window)||void 0===m?void 0:m.Theme)){if(l)return void Theme.showError(s);Theme.showSuccess(s)}f?(n("name",d.get("name"),365),n("email",d.get("email"),365),n("website",d.get("website"),365),n("cookie_consent",1,365),a.find('textarea[name="content"]').val("")):(a[0].reset(),i("name"),i("email"),i("website"),i("cookie_consent")),r(),o&&(o=!1,e(document).find(".fob-comment-form-section").remove(t),e(document).find(".fob-comment-list-section").after(t))},error:function(e){var o;u(),void 0!==(null===(o=window)||void 0===o?void 0:o.Theme)&&Theme.handleError(e)}})}}).on("click",".fob-comment-pagination a",function(o){o.preventDefault();var t=o.currentTarget.href;t&&(r(t),e("html, body").animate({scrollTop:e(".fob-comment-list-section").offset().top}))}).on("click",".fob-comment-item-reply",function(n){n.preventDefault();var i=e(n.currentTarget),r=e(document).find(".fob-comment-form-section");r&&r.remove(),o||(t=r.clone()),i.closest(".fob-comment-item").after(r),r.find(".fob-comment-form-title span").text(i.data("reply-to")),r.find(".fob-comment-form-title .cancel-comment-reply-link").remove(),r.find(".fob-comment-form-title").append('<a href="#" class="cancel-comment-reply-link" rel="nofollow">'.concat(i.data("cancel-reply"),"</a")),r.find("form").prop("action",i.prop("href")),o=!0}).on("click",".cancel-comment-reply-link",function(n){n.preventDefault(),o=!1;var i=e(document).find(".fob-comment-form-section");i&&i.remove(),e(document).find(".fob-comment-list-section").after(t)}).on("click",".fob-comment-item-delete",function(o){o.preventDefault();var t=e(o.currentTarget),n=t.data("confirm");confirm(n)&&e.ajax({url:t.attr("href"),type:"DELETE",headers:{"X-CSRF-TOKEN":fobComment.csrfToken},dataType:"json",success:function(e){var o,t=e.error,n=e.message;if(void 0!==(null===(o=window)||void 0===o?void 0:o.Theme)){if(t)return void Theme.showError(n);Theme.showSuccess(n)}r()},error:function(e){var o;void 0!==(null===(o=window)||void 0===o?void 0:o.Theme)&&Theme.handleError(e)}})}),r()}else console.error("fob-comment: jQuery is required")});