1class C{constructor(e,t){this.DOM=e,this.reportDialog=this.DOM.querySelector(".js-dialog-comments-report"),this.commentsDialog=this.DOM.querySelector(".js-dialog-comments"),this.createCommentForm=this.DOM.querySelector("#create-comment-form"),this.showBtns=this.DOM.querySelectorAll(".js-comment-dialog-show"),this.reportDialogContent=document.getElementById("js-comment-report-dialog-content"),this.reportErrorContainer=this.DOM.querySelector("#send-report-error"),this.reportSuccessContainer=this.DOM.querySelector("#send-report-success"),this.newCommentErrorContainer=this.DOM.querySelector("#send-new-comment-error"),this.newCommentSuccessContainer=document.querySelector("#send-new-comment-success"),this.lenis=t}initCreateCommentDialog(){this.createCommentForm&&this.createCommentForm.addEventListener("submit",e=>{var a,o,m,h,p;e.preventDefault();const t=((a=this.createCommentForm)==null?void 0:a.getAttribute("action"))||"",r=(o=this.createCommentForm)==null?void 0:o.querySelector('input[name="name"]'),n=(m=this.createCommentForm)==null?void 0:m.querySelector('textarea[name="comment"]'),s=(h=this.createCommentForm)==null?void 0:h.querySelector('input[name="article"]'),c=(p=this.createCommentForm)==null?void 0:p.querySelector('textarea[name="g-recaptcha-response"]'),l={article:s.value,name:r.value,comment:n.value,"g-recaptcha-response":c.value};this.newCommentErrorContainer&&(this.newCommentErrorContainer.style.display="none"),this.newCommentSuccessContainer&&(this.newCommentSuccessContainer.style.display="none"),fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}).then(i=>{if(!i.ok)throw this.newCommentErrorContainer&&(this.newCommentErrorContainer.style.display="block"),new Error("Network response was not ok");return i.json()}).then(i=>{this.newCommentSuccessContainer&&(this.newCommentSuccessContainer.style.display="block"),this.createCommentForm&&(this.createCommentForm.style.display="none")}).catch(i=>{console.error("Error creating comment:",i)})})}initReportDialog(){var t;const e=(t=this.reportDialog)==null?void 0:t.querySelector("form");e&&e.addEventListener("submit",r=>{r.preventDefault();const n=e.getAttribute("action")||"",s=e.querySelector(".js-id-input"),c=s==null?void 0:s.value,l=Array.from(e.querySelectorAll('input[name="reason"]:checked')).map(o=>o.value),a={comment:c,reasons:l};this.reportErrorContainer&&(this.reportErrorContainer.style.display="none"),this.reportSuccessContainer&&(this.reportSuccessContainer.style.display="none"),fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(o=>{if(!o.ok)throw this.reportErrorContainer&&(this.reportErrorContainer.style.display="block"),new Error("Network response was not ok");return o.json()}).then(o=>{this.reportDialogContent&&(this.reportDialogContent.style.display="none"),this.reportSuccessContainer&&(this.reportSuccessContainer.style.display="block")}).catch(o=>{console.error("Error reporting comment:",o)})})}init(){this.showBtns.forEach(e=>{e.addEventListener("click",t=>{var r;if(t.preventDefault(),e.getAttribute("data-id")&&this.reportDialog){this.reportErrorContainer&&(this.reportErrorContainer.style.display="none"),this.reportSuccessContainer&&(this.reportSuccessContainer.style.display="none"),this.reportDialogContent&&(this.reportDialogContent.style.display="block"),(r=this.reportDialog)==null||r.showModal(),this.close(this.reportDialog);const n=this.reportDialog.querySelector(".js-id-input");this.lenis.stop(),n&&(n.value=e.getAttribute("data-id"))}else this.commentsDialog&&(this.commentsDialog.showModal(),this.close(this.commentsDialog),this.lenis.stop())})}),this.initReportDialog(),this.initCreateCommentDialog()}close(e){const t=e.querySelector(".js-close");t==null||t.addEventListener("click",r=>{r.preventDefault(),e.close(),this.lenis.start()})}}export{C as CommentsDialogs};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.