deepseek-1.x-dev/js/React/dist/chatBox.js
js/React/dist/chatBox.js
import{r,j as e,d as c,h as B,l as D,m as F,i as z,f as M,C as I,k as V}from"./chat-bot.js";function _({newChat:s,removeChat:l,setShowChat:o}){var a,n;return e.jsxs("div",{className:"d-flex align-items-center justify-content-between p-2 bg-danger",children:[e.jsx("span",{className:"text-white fw-semibold fs-5",children:((n=(a=window.drupalSettings)==null?void 0:a.deepseek)==null?void 0:n.label)||"Chatbot"}),e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(c,{variant:"transparent",size:"sm",className:"btn-scale border-0 rounded-0 text-white",title:Drupal.t("New chat"),onClick:s,children:e.jsx("i",{className:"bi bi-chat-square-dots fs-6"})}),e.jsx(c,{variant:"transparent",size:"sm",className:"btn-scale border-0 rounded-0 text-white",title:Drupal.t("Delete session"),onClick:l,children:e.jsx("i",{className:"bi bi-trash fs-6"})}),e.jsx(c,{variant:"transparent",size:"sm",className:"btn-scale border-0 rounded-0 text-white",title:Drupal.t("Fullscreen"),onClick:()=>{var t,i;window.open(((i=(t=window.drupalSettings)==null?void 0:t.deepseek)==null?void 0:i.url_chat)||"/","_blank","noopener,noreferrer")},children:e.jsx("i",{className:"bi bi-fullscreen fs-6"})}),e.jsx(c,{variant:"transparent",size:"sm",className:"btn-scale border-0 rounded-0 text-white",title:Drupal.t("Close"),onClick:()=>o(!1),children:e.jsx("i",{className:"bi bi-x-lg fs-6"})})]})]})}const $=r.memo(_);function H({upFile:s,voiceChat:l,voiceStatus:o,startVoice:a,stopVoice:n,upLoad:t,setUpFile:i,sendMessage:m}){const[d,h]=r.useState(""),x=()=>{h(""),m(d)};return e.jsxs(e.Fragment,{children:[s.length>0&&e.jsx(B,{upFile:s,setUpFile:i}),e.jsxs("div",{className:"d-flex align-items-center p-2 border-top",children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between me-2",children:[e.jsx(D,{voiceStatus:o,startVoice:a,stopVoice:n}),e.jsx(F,{upLoad:t})]}),e.jsx(z,{input:d,setInput:h,voiceChat:l,upLoad:t,handleSendMessage:x,typeEditor:"box"}),e.jsx(c,{variant:"transparent",size:"sm",className:"btn-scale border-0 rounded-0",title:Drupal.t("Send"),onClick:x,children:e.jsx("i",{className:"bi bi bi-send-fill text-danger fs-5"})})]})]})}const L=r.memo(H);var f,j;const R=((j=(f=window.drupalSettings)==null?void 0:f.deepseek)==null?void 0:j.url_module)||"";function U(){const{loading:s,messages:l,upFile:o,voiceChat:a,voiceStatus:n,startVoice:t,stopVoice:i,setMessages:m,sendMessage:d,newChat:h,removeChat:x,regenerateChat:C,copyChat:g,editChatStart:w,editChatStop:v,speakChat:N,handleScroll:k,setUpFile:S,upLoad:E}=M(),[y,b]=r.useState(!1);return r.useEffect(()=>{const u=document.getElementById("chat-bot");if(u){const p=()=>b(!0);return u.addEventListener("click",p),()=>{u.removeEventListener("click",p)}}},[]),y&&e.jsx("div",{className:"chat-bot chat-box",children:e.jsx("div",{className:"chat-box-iframe position-fixed overflow-hidden rounded-3 bg-light shadow",children:e.jsxs("div",{className:"d-flex flex-column w-100 h-100",children:[e.jsx($,{setShowChat:b,setMessages:m,newChat:h,removeChat:x}),e.jsx(I,{loading:s,messages:l,regenerateChat:C,copyChat:g,editChatStart:w,editChatStop:v,speakChat:N,handleScroll:k,urlModule:R}),e.jsx(L,{upFile:o,voiceChat:a,voiceStatus:n,startVoice:t,stopVoice:i,sendMessage:d,setUpFile:S,upLoad:E})]})})})}const q=r.memo(U);V.createRoot(document.getElementById("chat-box")).render(e.jsx(q,{}));
