1"use strict";(self.webpackChunkkms=self.webpackChunkkms||[]).push([[9889],{51744(t,e,s){var n=s(85804),i=s(20454);class o{constructor(t){this.element=t,this.feedback=[],this.suggestButton=document.createElement("button"),this.suggestButton.innerText="Suggest Content",this.suggestButton.type="button",this.suggestButton.classList.add("btn","btn-purple","mt-3","text-white"),t.insertAdjacentElement("beforebegin",this.suggestButton),this.suggestButton.addEventListener("click",this.suggest.bind(this)),(0,n.u)().then(t=>{this.csrf_token=t})}suggest(){const t=this.modal=document.createElement("div");t.classList.add("modal","fade"),t.setAttribute("tabindex","-1"),t.innerHTML='\n <div class="modal-dialog modal-xl" role="document" style="position:relative">\n <form>\n <div class="modal-content">\n <div class="modal-header align-items-center gap-3">\n <h4 class="modal-title">Suggest Content</h4>\n <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>\n \n </div>\n <div class="modal-body">\n <div class="step step-suggest">\n <div class="form-group">\n <label class="control-label">\n <h5 class="text-green">What is the main topic for this page?</h5>\n <input class="form-control" type="text" name="topic" required />\n </label>\n </div>\n <div class="form-group my-3">\n <label class="control-label">\n <h5 class="text-green">What would you like to cover in your content?</h5>\n <textarea class="form-control" name="bullet-points" required></textarea>\n </label>\n </div>\n <button type="submit" class="btn btn-primary text-white get-suggestions">Get suggestions</button>\n </div>\n <div class="step step-refine" style="display:none">\n <div class="result-display"></div>\n <div class="form-group">\n <label class="control-label">Any feedback?\n <input type="text" class="form-control" name="feedback" />\n </label>\n </div>\n <button type="submit" class="btn btn-primary text-white get-feedback">Refine Content</button>\n </div>\n </div>\n <div class="modal-footer">\n <button type="button" class="btn btn-pink text-white fw-bold apply-suggestion" disabled>Apply Content</button> \n <button type="button" class="btn btn-outline-grey fw-bold" data-bs-dismiss="modal">Close</button>\n \n </div>\n </div>\n </form>\n </div>',document.body.appendChild(t),this.suggestStep=t.querySelector(".step-suggest"),this.refineStep=t.querySelector(".step-refine"),this.resultDisplay=t.querySelector(".result-display"),this.applySuggestionsButton=t.querySelector(".apply-suggestion"),this.applySuggestionsButton.addEventListener("click",this.applySuggestion.bind(this)),this.form=t.querySelector("form"),this.form.addEventListener("submit",this.submit.bind(this));const e=new i.aF(t);t.addEventListener("hidden.bs.modal",()=>t.remove()),e.show()}submit(t){t.preventDefault(),this.showLoader(),this.suggestStep.style.display="none",this.refineStep.style.display="none",this.applySuggestionsButton.disabled=!0;const e=t.target;var s,n,i,o;e.feedback.value&&(this.feedback.push(e.feedback.value),e.feedback.value=""),(s=this.csrf_token,n=e.topic.value,i=e["bullet-points"].value,o=this.feedback,fetch("/console/content-suggest/",{method:"POST",headers:{Accept:"application/json","X-CSRF":s},body:JSON.stringify({topic:n,bullet_points:i,feedback:o})}).then(t=>{if(!t.ok){const e=new Error(t.statusText);throw e.response=t,e}return t.json()})).then(t=>this.loadSuggestions(t)).catch(t=>this.handleError(t))}loadSuggestions(t){this.resultDisplay.innerHTML=t.meta_summaries[0].message.content,this.hideLoader(),this.refineStep.style.display="block",this.applySuggestionsButton.disabled=!1}handleError(t){console.error(t),this.hideLoader(),this.feedback.length>0?(this.suggestStep.style.display="none",this.refineStep.style.display="block",this.form.feedback.value=this.feedback.pop()):(this.suggestStep.style.display="block",this.refineStep.style.display="none",this.applySuggestionsButton.disabled=!0),alert("Sorry, there was an error generating your suggestion. Please try again.")}showLoader(){this.loader||(this.loader=document.createElement("div"),this.loader.classList.add("light-bg
1-loader"),this.modal.querySelector(".modal-dialog").appendChild(this.loader))}hideLoader(){this.loader&&(this.loader.remove(),this.loader=null)}applySuggestion(){const t=this.resultDisplay.innerHTML;"undefined"!=typeof CKEDITOR?CKEDITOR.instances["editor-content"].setData(t):this.element.value=t,i.aF.getInstance(this.modal).hide()}}window.initialise_content_suggest=function(){const t=document.getElementById("editor-content");new o(t)}}}]); 2//# sourceMappingURL=chunk-console-content-content_suggest.d1383354bb7a3d25.build.js.map
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.