1import{a as i}from"./chunk-GQBYHY4G.js";import{a as n}from"./chunk-W7QALFIM.js";import{a as o}from"./chunk-DFVYOIDQ.js";import"./chunk-7XF7ZDJA.js";var r=class extends o{init(){this.bookContextId=this.el.dataset.bookContextId,this.opsUrl=(this.el.dataset.opsUrl||"").replace(/\/+$/,""),this.createUrl=this.opsUrl+"/createchatbot",this.deleteUrl=this.opsUrl+"/deletechatbot",this.updateUrl=this.opsUrl+"/updatevectorstore",this.status=this.el.querySelector("[data-chatbot-status]"),this._busy=!1,this.el.querySelector("[data-create-chatbot]")?.addEventListener("click",()=>{this._run(this.createUrl,"Creazione")}),this.el.querySelector("[data-delete-chatbot]")?.addEventListener("click",async()=>{if(this._busy)return;this._busy=!0;let e=await i({title:"Elimina chatbot",message:"Eliminare il chatbot di questa book context? Verranno rimossi il chatbot e la registrazione del vector store su LiteLLM.",confirmLabel:"Elimina",variant:"danger"});this._busy=!1,e&&this._run(this.deleteUrl,"Eliminazione")}),this.el.querySelector("[data-update-chatbot]")?.addEventListener("click",async()=>{if(this._busy)return;this._busy=!0;let e=await i({title:"Aggiorna vector store",message:"Aggiornare il chatbot al vector store corrente di StationX? Le nuove risposte useranno il nuovo contenuto.",confirmLabel:"Aggiorna",variant:"primary"});this._busy=!1,e&&this._run(this.updateUrl,"Aggiornamento")})}async _run(e,s){if(!this._busy){this._busy=!0;try{this._writeStatus("secondary",s+" in corso...");let t=await n(e,{method:"POST",body:JSON.stringify({bookContextId:this.bookContextId})});if(!t.success)throw new Error(t.message);let a=t.values.warning,l=a?t.message+" \u2014 "+a:t.message;this._writeStatus(a?"warning":"success",l+" \u2014 aggiorno la pagina..."),setTimeout(()=>{window.location.reload()},a?4e3:1500)}catch(t){this.log(s+" chatbot fallita",t,"error"),this._writeStatus("danger","Errore: "+t.message),this._busy=!1}}}_writeStatus(e,s){this.status.className="alert alert-"+e+" mt-3",this.status.textContent=s,this.status.style.display="block"}};export{r as default}; 2//# sourceMappingURL=BookContextChatbotActions-MOSZHH5X.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.