@katechat/ui 1.0.53 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -448,7 +448,7 @@ $$${n}$$`):""}function Rs(e,t=!1){return e?t?[bk.parse(e,{renderer:Mr})]:(e=hk(e
448
448
  </svg>
449
449
  <span class="action-btn-label">${ce.label}</span>
450
450
  </div>`:"";it.innerHTML=he.replaceAll("<LANG>",Ne).replace("<EXECUTE_BTN>",et).replace("<DOWNLOAD_TITLE>",z).replace("<COPY_TITLE>",Z),Ke.appendChild(it),Te.parentNode?.insertBefore(Ke,Te),Ke.appendChild(Te)}}),V.current.querySelectorAll("img").forEach(Te=>{if(!Te?.classList?.contains("message-image")){Te.classList.add("message-image");let it=Te.src.split("/").pop()||"";Te.setAttribute("data-file-name",it)}}),V.current.querySelectorAll("table").forEach(Te=>{if(!Te?.classList?.contains("message-table")){if(Te.classList.add("message-table"),!Te.tFoot){let Ne=document.createElement("tfoot");Te.appendChild(Ne);let Ke=document.createElement("tr");Ke.className="table-controls-row",Ne.appendChild(Ke);let ce=document.createElement("th");ce.classList.add("table-controls"),ce.colSpan=Te.querySelectorAll("th").length||1,Ke.appendChild(ce)}let it=Te.querySelector("tfoot tr .table-controls");it.innerHTML=Se.replace("<COPY_CSV_TITLE>",J).replace("<DOWNLOAD_CSV_TITLE>",ae);let Ve=0;Te.querySelectorAll("th").forEach(Ne=>{Ne.classList.contains("table-controls")||(Ne.classList.add("table-sort-btn"),Ne.setAttribute("data-col-index",String(Ve++)))})}}))},Ii+10),[z,Z,J,ae,d]);vv(()=>{if(!k&&V.current){let Te=new MutationObserver(pe);return Te.observe(V.current,{childList:!0,subtree:!0}),pe(),()=>Te.disconnect()}},[u,k,pe]);let Ce=()=>le(Te=>!Te),Ue=_r(()=>s?s(t):null,[s,t]),Ge=_r(()=>{let Te=o?o(t):null,it=l?.find(Ve=>Ve.modelId===t?.modelId);return ve.createElement(ve.Fragment,null,ve.createElement(fd,{align:"center",pt:"sm"},ve.createElement(Dk,{color:"gray",radius:"xl",size:"md",src:xe?t?.user?.avatarUrl:void 0},xe?ve.createElement(Uk,null):it?ve.createElement(Ai,{apiProvider:it.apiProvider,provider:it.provider}):ve.createElement(Rv,null)),ve.createElement(fd,{gap:"sm"},ve.createElement(Sd,{size:"sm",fw:500,c:xe?"blue":"teal"},be),ve.createElement(Sd,{size:"sm",c:"dimmed"},ge),G&&ve.createElement(Do,{status:G}),U&&G!=="reasoning"&&ve.createElement(Sd,{size:"sm",c:"dimmed"},U))),ve.createElement("div",{className:["katechat-message-content",k?"streaming":""].join(" ")},ve.createElement(Ri,{status:G,content:v,statusInfo:U,streaming:k}),R?R.map((Ve,Ne)=>ve.createElement("div",{key:Ne,dangerouslySetInnerHTML:{__html:Ve}})):ve.createElement("div",null,v),ve.createElement("div",{className:"katechat-message-footer"},ve.createElement(wo,{messageId:p,messageIndex:n}),Ue&&ve.createElement(Cv,{label:Q("Details"),position:"top",withArrow:!0},ve.createElement(bd,{className:"edit-message-btn","data-message-id":p,size:"sm",variant:"subtle",color:"gray",disabled:a,onClick:Ce},$?ve.createElement(Fk,null):ve.createElement(Bk,null))),Te),ve.createElement(Mk,{in:$},ve.createElement("div",{className:"katechat-message-content-details"},Ue))))},[u,be,ge,v,R,p,E,b,l,n,Y,Ue,$,k,ie.language]),[ze,lt]=ve.useState(0),[Et,ct]=ve.useState("idle"),[Ot,vt]=ve.useState(!1);vv(()=>{if(!L||L.length===0)return;let Te=L.findIndex(it=>it.streaming);Te>=0&&lt(Te)},[L]);let Kt=_r(()=>!L||L.length===0?[]:L.map(Te=>ve.createElement(Td,{key:Te.id,message:Te,parentIndex:n,index:ze,models:l,plugins:o?.(Te)})),[L,l,n,ie.language]),Ct=_r(()=>{if(!L||L.length===0)return null;let Te=L.length,it=Ke=>{Ke.stopPropagation(),!Ot&&(vt(!0),ct("exit-right"),setTimeout(()=>{lt(ce=>(ce-1+Te)%Te),ct("enter-left"),setTimeout(()=>{ct("idle"),vt(!1)},Ii)},Ii))},Ve=Ke=>{Ke.stopPropagation(),!Ot&&(vt(!0),ct("exit-left"),setTimeout(()=>{lt(ce=>(ce+1)%Te),ct("enter-right"),setTimeout(()=>{ct("idle"),vt(!1)},Ii)},Ii))},Ne=Kt[ze];return ve.createElement("div",{className:"katechat-message-carousel"},ve.createElement("div",{className:"message-carousel-header"},ve.createElement("div",{className:"message-carousel-controls"},Te>1&&ve.createElement(ve.Fragment,null,ve.createElement(bd,{onClick:it,"aria-label":"Previous",radius:"xl",variant:"light"},ve.createElement(kk,null)),ve.createElement(bd,{onClick:Ve,"aria-label":"Next",radius:"xl",variant:"light"},ve.createElement(Pk,null))))),ve.createElement("div",{className:`carousel-message-content animation-${Et}`},Ne),Te>1&&ve.createElement(fd,{className:"carousel-model-icons"},L.map((Ke,ce)=>{let et=l?.find(qe=>qe.modelId===Ke.modelId),dt=ce===ze;return ve.createElement(Cv,{key:Ke.id,label:et?.name||Q("AI"),position:"top"},ve.createElement(Lk,{key:Ke.id,c:dt?void 0:"dimmed",onClick:()=>lt(ce)},et?ve.createElement(Ai,{apiProvider:et.apiProvider,provider:et.provider,size:20}):ve.createElement(Rv,{size:20})))})))},[Kt,ie.language,ze,Et,Ot]);return Ct?ve.createElement("div",{id:`message-${t.id}`,className:["katechat-message",`katechat-message__${u||""}`].join(" "),ref:V},ve.createElement("div",{className:"katechat-message-linked-toggle"},ve.createElement(wk,{checked:q,onChange:Te=>te(Te.currentTarget.checked),label:Q(q?"Main":"Others"),size:"sm"})),ve.createElement("div",{className:["katechat-message-main",q?"":"hidden"].join(" ")},Ge),ve.createElement("div",{className:["katechat-message-linked",q?"hidden":""].join(" ")},Ct)):ve.createElement("div",{id:`message-${t.id}`,className:["katechat-message",`katechat-message__${u||""}`].join(" "),ref:V},ve.createElement("div",{className:"katechat-message-main"},Ge))});hd.displayName="ChatMessage";import Ni from"react";import{ScrollArea as Yk}from"@mantine/core";var EF=({html:e,text:t})=>Ni.createElement(Yk,{type:"hover",offsetScrollbars:!0,className:["katechat-message-content","katechat-message-preview"].join(" ")},t?Ni.createElement(Ni.Fragment,null,e?e.map((n,a)=>Ni.createElement("div",{key:a,dangerouslySetInnerHTML:{__html:n}})):Ni.createElement("div",null,t)):"...");import $t,{useMemo as Kk}from"react";import{Text as Nv,Group as Ov,Avatar as Xk,Box as Zk}from"@mantine/core";import{IconRobot as Jk}from"@tabler/icons-react";import mr from"react";import{IconBrandOpenai as zk,IconBrandAws as Av,IconBrandYandex as Hk,IconMessageChatbot as Vk,IconAi as Wk,IconBrandMeta as qk,IconBrandMedium as Qk,IconBrandGoogle as $k}from"@tabler/icons-react";var Ai=({apiProvider:e,provider:t,size:n=24})=>{switch(e){case"OPEN_AI":return mr.createElement(zk,{size:n});case"AWS_BEDROCK":switch(t?.toLowerCase()){case"amazon":return mr.createElement(Av,{size:n});case"anthropic":return mr.createElement(Wk,{size:n});case"mistral ai":return mr.createElement(Qk,{size:n});case"meta":return mr.createElement(qk,{size:n});default:return mr.createElement(Av,{size:n})}case"YANDEX_FM":return mr.createElement(Hk,{size:n});case"GOOGLE_VERTEX_AI":return mr.createElement($k,{size:n});default:return mr.createElement(Vk,{size:n})}};var Td=({message:e,parentIndex:t,index:n,plugins:a,models:o})=>{let s=Kk(()=>o?.find(l=>l.modelId===e.modelId),[o,e.modelId]);return $t.createElement(Zk,{key:e.id},$t.createElement(Ov,{align:"center",pt:"sm"},$t.createElement(Xk,{radius:"xl",size:"md"},s?$t.createElement(Ai,{apiProvider:s.apiProvider,provider:s.provider}):$t.createElement(Jk,null)),$t.createElement(Ov,{gap:"xs"},$t.createElement(Nv,{size:"sm",fw:500,c:"teal"},e.modelName),e.status&&$t.createElement(Do,{status:e.status}),e.statusInfo&&e.status!=="reasoning"&&$t.createElement(Nv,{size:"xs",c:"dimmed"},e.statusInfo))),$t.createElement("div",{className:"katechat-message-content"},$t.createElement(Ri,{status:e.status,content:e.content,statusInfo:e.statusInfo,streaming:e.streaming||!1}),e.html?e.html.map((l,d)=>$t.createElement("div",{key:d,dangerouslySetInnerHTML:{__html:l}})):$t.createElement("div",null,e.content),$t.createElement("div",{className:"katechat-message-footer"},$t.createElement(wo,{messageId:e.id,messageIndex:t,linkedMessageIndex:n}),a)))};Td.displayName="LinkedChatMessage";import nt,{forwardRef as d3,useCallback as Rd,useEffect as Dv,useImperativeHandle as u3,useMemo as _3,useRef as m3,useState as Ns}from"react";import{Text as Id,Textarea as p3,Button as wv,Group as Mv,ActionIcon as Lv,Stack as g3,Tooltip as E3,Menu as Ad}from"@mantine/core";import{IconCirclePlus as S3,IconPlayerStopFilled as f3,IconSend as b3,IconX as h3}from"@tabler/icons-react";import{notifications as xa}from"@mantine/notifications";import pr,{useState as jk,useCallback as Is,useRef as yv,useEffect as e3}from"react";import{Group as t3,Tooltip as n3,Box as xv,ActionIcon as r3}from"@mantine/core";import{IconFileUpload as a3}from"@tabler/icons-react";import{useTranslation as i3}from"react-i18next";var Oi={dropzone:"_dropzone_16zca_1",dragging:"_dragging_16zca_8",disabled:"_disabled_16zca_12"};var o3=["image/jpeg","image/png","image/webp"],vd=({onFilesAdd:e,disabled:t,uploadFormats:n=o3})=>{let[a,o]=jk(!1),s=yv(null),l=yv(null),{t:d}=i3();e3(()=>{let R=I=>{if(!t&&I.clipboardData&&I.clipboardData.items){let N=Array.from(I.clipboardData.items).map(k=>k.getAsFile()).filter(vi);N.length>0&&(I.preventDefault(),I.stopPropagation(),e(N))}};return document.addEventListener("paste",R),()=>{document.removeEventListener("paste",R)}},[e,t]);let u=Is(R=>{R.preventDefault(),R.stopPropagation(),o(!0)},[]),p=Is(R=>{R.preventDefault(),R.stopPropagation(),o(!1)},[]),E=Is(R=>{if(R.preventDefault(),R.stopPropagation(),o(!1),t)return;let I=R.dataTransfer.files&&R.dataTransfer.files.length>0?Array.from(R.dataTransfer.files).filter(N=>N.size>0):[];e(I)},[e]),b=Is(R=>{if(R.target.files&&R.target.files.length>0){let I=Array.from(R.target.files).filter(N=>N.size>0);I.length&&e(I),l.current&&(l.current.value="")}},[e]),v=()=>{t||l.current?.click()};return pr.createElement(pr.Fragment,null,pr.createElement(xv,{ref:s,className:`drop-zone ${Oi.dropzone} ${a?Oi.dragging:""} ${t?Oi.disabled:""}`,onDragOver:u,onDragLeave:p,onDrop:E,onClick:v},pr.createElement(t3,{justify:"start",className:"drop-zone-control",gap:"xs"},pr.createElement(n3,{label:d("Click or drop an image/document here to upload"),position:"top"},pr.createElement(r3,{variant:"default",size:"lg"},pr.createElement(a3,{size:"24"}))),pr.createElement(xv,{hiddenFrom:"xs",pe:"sm"},d("Upload File")),pr.createElement("input",{ref:l,type:"file",multiple:!0,accept:n?.join(","),onChange:b,className:Oi.fileInput,style:{display:"none"},disabled:t}))))};import As from"react";import{Text as s3}from"@mantine/core";import{IconFileUpload as l3}from"@tabler/icons-react";var Cd={overlay:"_overlay_vjudp_1",content:"_content_vjudp_16"};import{useTranslation as c3}from"react-i18next";var oU=({visible:e,message:t,onDragOver:n,onDragLeave:a,onDrop:o})=>{let{t:s}=c3();return e?As.createElement("div",{className:Cd.overlay,onDragOver:n,onDragLeave:a,onDrop:o},As.createElement("div",{className:Cd.content},As.createElement(l3,{size:48,color:"var(--mantine-color-blue-4)"}),As.createElement(s3,{size:"lg",fw:500,c:"blue.4"},t||s("Drop files here to upload")))):null};import{useTranslation as T3}from"react-i18next";var Ut={chatControlsContainer:"_chatControlsContainer_sg9gr_1",chatInputContainer:"_chatInputContainer_sg9gr_4",chatInputGroup:"_chatInputGroup_sg9gr_7",chatInput:"_chatInput_sg9gr_4",hidden:"_hidden_sg9gr_22",promptMode:"_promptMode_sg9gr_34",promptModeText:"_promptModeText_sg9gr_41",promptFadeInUp:"_promptFadeInUp_sg9gr_1",promptShimmer:"_promptShimmer_sg9gr_1",headerRow:"_headerRow_sg9gr_71",documentsInput:"_documentsInput_sg9gr_89",columned:"_columned_sg9gr_95",imagesList:"_imagesList_sg9gr_103",previewImage:"_previewImage_sg9gr_108",removeButton:"_removeButton_sg9gr_120"};var RU=d3(({loadCompleted:e=!1,disabled:t=!1,promptMode:n=!1,promptText:a,uploadAllowed:o=!0,streaming:s,setSending:l,previousMessages:d=[],header:u,inputPlugins:p,uploadFormats:E,maxUploadFileSize:b=64*1024*1024,maxImagesCount:v=0,onSendMessage:R,onStopRequest:I,onDocumentsUpload:N},k)=>{let[L,G]=Ns(""),[U,V]=Ns([]),[Y,q]=Ns(0),[te,$]=Ns(!1),le=m3(null),{t:Q}=T3();u3(k,()=>({handleAddFiles:Z=>he(Z)})),Dv(()=>{le.current?.focus()},[e,t]),Dv(()=>{q(d?.length?d.length:0)},[e,d]);let ie=async()=>{if(!(!L?.trim()&&!U.length)){l(!0);try{G(""),V([]),await R(L,U)}catch(Z){xa.show({title:"Error",message:Z instanceof Error?Z.message:Q("Failed to send message"),color:"red"})}finally{l(!1)}}},ge=Rd(Z=>{let J=!L?.trim();if(Z.key==="Enter"&&!Z.shiftKey&&!Z.altKey)Z.preventDefault(),ie(),$(!1);else if(Z.key==="ArrowUp"&&(J||te)){let ae=Math.max(0,Y-1);G(d[ae]),q(ae),$(!0)}else if(Z.key==="ArrowDown"&&(J||te)){let ae=Math.min(d.length-1,Y+1);G(d[ae]),q(ae),$(!0)}else $(!1)},[ie,L,d,Y]),xe=Rd(Z=>{G(Z.currentTarget.value)},[]),be=_3(()=>t||s||!L?.trim()&&!U.length,[L,U,s,t]),he=Rd(Z=>{let J=Z.filter(pe=>pe.size<b);J.length<Z.length&&xa.show({title:Q("Warning"),message:Q("Some files are too large and were not added (max size: {{size}} MB)",{size:b/(1024*1024)}),color:"yellow"});let ae=J.filter(pe=>pe.type?.startsWith("image/")),Se=J.filter(pe=>!pe.type?.startsWith("image/"));ae.length&&v<=0&&(xa.show({title:Q("Warning"),message:Q("Image uploads are not allowed in this chat."),color:"yellow"}),ae=[]),ae.length+U.length>v&&(xa.show({title:Q("Warning"),message:Q("You can only add up to {{count}} images at a time",{count:v}),color:"yellow"}),ae=ae.slice(0,v-U.length)),ae.length&&Promise.all(ae.map(pe=>new Promise((Ce,Ue)=>{let Ge=new FileReader;Ge.onload=ze=>{if(ze.target?.result){let lt=ze.target.result;Ce({fileName:pe.name,mimeType:pe.type,bytesBase64:lt})}else Ue(new Error(Q("Failed to read file: {{fileName}}",{fileName:pe.name})))},Ge.onerror=ze=>{Ue(new Error(Q("Failed to read file: {{fileName}}, error: {{error}}",{fileName:pe.name,error:ze})))},Ge.readAsDataURL(pe)}))).then(pe=>{V(Ce=>[...Ce,...pe])}).catch(pe=>{xa.show({title:Q("Error"),message:pe.message||Q("Failed to read image files"),color:"red"})}),Se.length&&N?N(Se):Se.length&&xa.show({title:Q("Warning"),message:Q("Document upload is not available in this chat."),color:"orange"})},[U,N,v,b]),z=Z=>J=>{J.stopPropagation(),V(ae=>ae.filter(Se=>Se.fileName!==Z))};return nt.createElement("div",{className:[Ut.chatControlsContainer,n?Ut.promptMode:"",e?"":Ut.hidden].join(" ")},n?nt.createElement(g3,{align:"center",justify:"center",gap:"md",mb:"lg"},nt.createElement(Id,{c:"dimmed",size:"lg",ta:"center",className:Ut.promptModeText},a||Q("Start the conversation by sending a message"))):null,nt.createElement("div",{className:Ut.chatControls},u&&nt.createElement(Mv,{align:"center",gap:"xs",className:Ut.headerRow},u),nt.createElement("div",{className:[Ut.chatInputContainer,U.length?Ut.columned:""].join(" ")},o&&nt.createElement("div",{className:Ut.documentsInput},nt.createElement(Mv,{visibleFrom:"xs",gap:"xs"},nt.createElement(vd,{onFilesAdd:he,uploadFormats:E}),p),U?.length>0&&nt.createElement("div",{className:Ut.imagesList},U.map(Z=>nt.createElement("div",{key:Z.fileName,className:Ut.previewImage},nt.createElement("img",{src:Z.bytesBase64,alt:Z.fileName}),nt.createElement(Lv,{className:Ut.removeButton,color:"red.9",size:"xs",onClick:z(Z.fileName)},nt.createElement(h3,{size:16})))))),nt.createElement("div",{className:Ut.chatInputGroup},o&&nt.createElement(Ad,{shadow:"md",width:"content"},nt.createElement(Ad.Target,null,nt.createElement(Lv,{size:"lg",variant:"subtle",hiddenFrom:"xs"},nt.createElement(E3,{label:Q("More..."),position:"right",withArrow:!0},nt.createElement(S3,{size:"24"})))),nt.createElement(Ad.Dropdown,null,nt.createElement(vd,{onFilesAdd:he,uploadFormats:E}),p)),nt.createElement(p3,{ref:le,className:Ut.chatInput,placeholder:Q("Type your message..."),value:L||"",autosize:!0,minRows:1,maxRows:7,onChange:xe,onKeyDown:ge,disabled:t}),I&&s?nt.createElement(wv,{onClick:I,disabled:t},nt.createElement(f3,{size:24})," ",nt.createElement(Id,{visibleFrom:"md"},Q("Stop"))):nt.createElement(wv,{onClick:ie,disabled:be,className:I&&s?Ut.hidden:"",radius:"md"},nt.createElement(b3,{size:24})," ",nt.createElement(Id,{visibleFrom:"md",ml:"xs"},Q("Send")))))))});import gr,{useCallback as yi,useRef as F3,useState as yd}from"react";import{Stack as U3}from"@mantine/core";import{notifications as xd}from"@mantine/notifications";import{useTranslation as G3}from"react-i18next";import gn,{useEffect as y3,useCallback as zv}from"react";import{Image as x3,Text as Os,Group as Hv,Stack as D3,ActionIcon as w3,Tooltip as M3,Drawer as L3}from"@mantine/core";import{useDisclosure as k3}from"@mantine/hooks";import{IconExternalLink as P3}from"@tabler/icons-react";var Gv=jl(tc(),1);import Uv from"i18next";import{initReactI18next as A3}from"react-i18next";import N3 from"i18next-browser-languagedetector";var kv={AI:"AI","Are you sure you want to delete this item? This action cannot be undone.":"Are you sure you want to delete this item? This action cannot be undone.",Cancel:"Cancel",Cancelled:"Cancelled","Click or drop an image/document here to upload":"Click or drop an image/document here to upload","Code block is empty":"Code block is empty","Code Interpreter":"Code Interpreter",Completed:"Completed","Confirm Deletion":"Confirm Deletion",Copy:"Copy","Copy CSV":"Copy CSV","Copy message":"Copy message",Delete:"Delete",Details:"Details","Document upload is not available in this chat.":"Document upload is not available in this chat.",Download:"Download","Download CSV":"Download CSV","Drop files here to upload":"Drop files here to upload",Error:"Error","Failed to copy message":"Failed to copy message","Failed to read file: {{fileName}}":"Failed to read file: {{fileName}}","Failed to read file: {{fileName}}, error: {{error}}":"Failed to read file: {{fileName}}, error: {{error}}","Failed to read image files":"Failed to read image files","Failed to send message":"Failed to send message","Image Preview":"Image Preview","Image uploads are not allowed in this chat.":"Image uploads are not allowed in this chat.","In Progress":"In Progress",language:{de:"Deutsch",en:"English",label:"Language",ru:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",zh:"\u4E2D\u6587"},"Language is not specified for this code block":"Language is not specified for this code block",Main:"Main","More...":"More...","Open image source":"Open image source",Others:"Others","RAG Search":"RAG Search",Reasoning:"Reasoning",Send:"Send","Some files are too large and were not added (max size: {{size}} MB)":"Some files are too large and were not added (max size: {{size}} MB)",source:"source","Start the conversation by sending a message":"Start the conversation by sending a message",Started:"Started",Stop:"Stop","Tool Call":"Tool Call","Tool Call Completed":"Tool Call Completed","Type your message...":"Type your message...","Upload File":"Upload File",Warning:"Warning","Web Search":"Web Search",You:"You","You can only add up to {{count}} images at a time":"You can only add up to {{count}} images at a time"};var Pv={AI:"KI","Are you sure you want to delete this item? This action cannot be undone.":"M\xF6chten Sie dieses Element wirklich l\xF6schen? Diese Aktion kann nicht r\xFCckg\xE4ngig gemacht werden.",Cancel:"Abbrechen",Cancelled:"Abgebrochen","Click or drop an image/document here to upload":"Klicken oder Bild/Dokument hierher ziehen zum Hochladen","Code block is empty":"Codeblock ist leer","Code Interpreter":"Code-Interpreter",Completed:"Abgeschlossen","Confirm Deletion":"L\xF6schen best\xE4tigen",Copy:"Kopieren","Copy CSV":"CSV kopieren","Copy message":"Nachricht kopieren",Delete:"L\xF6schen",Details:"Details","Document upload is not available in this chat.":"Dokumenten-Upload ist in diesem Chat nicht verf\xFCgbar.",Download:"Herunterladen","Download CSV":"CSV herunterladen","Drop files here to upload":"Dateien zum Hochladen hier ablegen",Error:"Fehler","Failed to copy message":"Nachricht konnte nicht kopiert werden","Failed to read file: {{fileName}}":"Datei konnte nicht gelesen werden: {{fileName}}","Failed to read file: {{fileName}}, error: {{error}}":"Datei konnte nicht gelesen werden: {{fileName}}, Fehler: {{error}}","Failed to read image files":"Bilddateien konnten nicht gelesen werden","Failed to send message":"Nachricht konnte nicht gesendet werden","Image Preview":"Bildvorschau","Image uploads are not allowed in this chat.":"Bild-Uploads sind in diesem Chat nicht erlaubt.","In Progress":"In Bearbeitung",language:{de:"Deutsch",en:"English",label:"Sprache",ru:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",zh:"\u4E2D\u6587"},"Language is not specified for this code block":"F\xFCr diesen Codeblock ist keine Sprache angegeben",Main:"Haupt","More...":"Mehr...","Open image source":"Bildquelle \xF6ffnen",Others:"Andere","RAG Search":"RAG-Suche",Reasoning:"Argumentation",Send:"Senden","Some files are too large and were not added (max size: {{size}} MB)":"Einige Dateien sind zu gro\xDF und wurden nicht hinzugef\xFCgt (max. Gr\xF6\xDFe: {{size}} MB)",source:"Quelle","Start the conversation by sending a message":"Beginnen Sie das Gespr\xE4ch, indem Sie eine Nachricht senden",Started:"Gestartet",Stop:"Stopp","Tool Call":"Tool-Aufruf","Tool Call Completed":"Tool-Aufruf abgeschlossen","Type your message...":"Nachricht eingeben...","Upload File":"Datei hochladen",Warning:"Warnung","Web Search":"Websuche",You:"Sie","You can only add up to {{count}} images at a time":"Sie k\xF6nnen nur bis zu {{count}} Bilder gleichzeitig hinzuf\xFCgen"};var Bv={AI:"\u0418\u0418","Are you sure you want to delete this item? This action cannot be undone.":"\u0412\u044B \u0443\u0432\u0435\u0440\u0435\u043D\u044B, \u0447\u0442\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u044D\u0442\u043E\u0442 \u044D\u043B\u0435\u043C\u0435\u043D\u0442? \u042D\u0442\u043E \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043D\u0435\u043B\u044C\u0437\u044F \u043E\u0442\u043C\u0435\u043D\u0438\u0442\u044C.",Cancel:"\u041E\u0442\u043C\u0435\u043D\u0430",Cancelled:"\u041E\u0442\u043C\u0435\u043D\u0435\u043D\u043E","Click or drop an image/document here to upload":"\u041D\u0430\u0436\u043C\u0438\u0442\u0435 \u0438\u043B\u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435/\u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442 \u0441\u044E\u0434\u0430 \u0434\u043B\u044F \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438","Code block is empty":"\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430 \u043F\u0443\u0441\u0442","Code Interpreter":"\u0418\u043D\u0442\u0435\u0440\u043F\u0440\u0435\u0442\u0430\u0442\u043E\u0440 \u043A\u043E\u0434\u0430",Completed:"\u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u043E","Confirm Deletion":"\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C \u0443\u0434\u0430\u043B\u0435\u043D\u0438\u0435",Copy:"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C","Copy CSV":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C CSV","Copy message":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435",Delete:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",Details:"\u041F\u043E\u0434\u0440\u043E\u0431\u043D\u043E\u0441\u0442\u0438","Document upload is not available in this chat.":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0430 \u0432 \u044D\u0442\u043E\u043C \u0447\u0430\u0442\u0435.",Download:"\u0421\u043A\u0430\u0447\u0430\u0442\u044C","Download CSV":"\u0421\u043A\u0430\u0447\u0430\u0442\u044C CSV","Drop files here to upload":"\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u044B \u0441\u044E\u0434\u0430 \u0434\u043B\u044F \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438",Error:"\u041E\u0448\u0438\u0431\u043A\u0430","Failed to copy message":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435","Failed to read file: {{fileName}}":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0444\u0430\u0439\u043B: {{fileName}}","Failed to read file: {{fileName}}, error: {{error}}":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0444\u0430\u0439\u043B: {{fileName}}, \u043E\u0448\u0438\u0431\u043A\u0430: {{error}}","Failed to read image files":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u0442\u044C \u0444\u0430\u0439\u043B\u044B \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0439","Failed to send message":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435","Image Preview":"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","Image uploads are not allowed in this chat.":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0439 \u0432 \u044D\u0442\u043E\u043C \u0447\u0430\u0442\u0435 \u0437\u0430\u043F\u0440\u0435\u0449\u0435\u043D\u0430.","In Progress":"\u0412 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0435",language:{de:"Deutsch",en:"English",label:"\u042F\u0437\u044B\u043A",ru:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",zh:"\u4E2D\u6587"},"Language is not specified for this code block":"\u042F\u0437\u044B\u043A \u043D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u0431\u043B\u043E\u043A\u0430 \u043A\u043E\u0434\u0430",Main:"\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439","More...":"\u0415\u0449\u0451...","Open image source":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F",Others:"\u0414\u0440\u0443\u0433\u0438\u0435","RAG Search":"RAG-\u043F\u043E\u0438\u0441\u043A",Reasoning:"\u0420\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0435",Send:"\u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C","Some files are too large and were not added (max size: {{size}} MB)":"\u041D\u0435\u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0444\u0430\u0439\u043B\u044B \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u0438\u0435 \u0438 \u043D\u0435 \u0431\u044B\u043B\u0438 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u044B (\u043C\u0430\u043A\u0441. \u0440\u0430\u0437\u043C\u0435\u0440: {{size}} \u041C\u0411)",source:"\u0438\u0441\u0442\u043E\u0447\u043D\u0438\u043A","Start the conversation by sending a message":"\u041D\u0430\u0447\u043D\u0438\u0442\u0435 \u0434\u0438\u0430\u043B\u043E\u0433, \u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0432 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435",Started:"\u041D\u0430\u0447\u0430\u0442\u043E",Stop:"\u0421\u0442\u043E\u043F","Tool Call":"\u0412\u044B\u0437\u043E\u0432 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0430","Tool Call Completed":"\u0412\u044B\u0437\u043E\u0432 \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0451\u043D","Type your message...":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435...","Upload File":"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u0430\u0439\u043B",Warning:"\u041F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u0435","Web Search":"\u0412\u0435\u0431-\u043F\u043E\u0438\u0441\u043A",You:"\u0412\u044B","You can only add up to {{count}} images at a time":"\u0412\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043D\u0435 \u0431\u043E\u043B\u0435\u0435 {{count}} \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0439 \u0437\u0430 \u0440\u0430\u0437"};var Fv={AI:"AI","Are you sure you want to delete this item? This action cannot be undone.":"\u60A8\u786E\u5B9A\u8981\u5220\u9664\u6B64\u9879\u5417\uFF1F\u6B64\u64CD\u4F5C\u65E0\u6CD5\u64A4\u6D88\u3002",Cancel:"\u53D6\u6D88",Cancelled:"\u5DF2\u53D6\u6D88","Click or drop an image/document here to upload":"\u70B9\u51FB\u6216\u62D6\u653E\u56FE\u7247/\u6587\u6863\u5230\u6B64\u5904\u4E0A\u4F20","Code block is empty":"\u4EE3\u7801\u5757\u4E3A\u7A7A","Code Interpreter":"\u4EE3\u7801\u89E3\u91CA\u5668",Completed:"\u5DF2\u5B8C\u6210","Confirm Deletion":"\u786E\u8BA4\u5220\u9664",Copy:"\u590D\u5236","Copy CSV":"\u590D\u5236 CSV","Copy message":"\u590D\u5236\u6D88\u606F",Delete:"\u5220\u9664",Details:"\u8BE6\u60C5","Document upload is not available in this chat.":"\u6B64\u804A\u5929\u4E0D\u652F\u6301\u6587\u6863\u4E0A\u4F20\u3002",Download:"\u4E0B\u8F7D","Download CSV":"\u4E0B\u8F7D CSV","Drop files here to upload":"\u5C06\u6587\u4EF6\u62D6\u653E\u5230\u6B64\u5904\u4E0A\u4F20",Error:"\u9519\u8BEF","Failed to copy message":"\u590D\u5236\u6D88\u606F\u5931\u8D25","Failed to read file: {{fileName}}":"\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A{{fileName}}","Failed to read file: {{fileName}}, error: {{error}}":"\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A{{fileName}}\uFF0C\u9519\u8BEF\uFF1A{{error}}","Failed to read image files":"\u8BFB\u53D6\u56FE\u7247\u6587\u4EF6\u5931\u8D25","Failed to send message":"\u53D1\u9001\u6D88\u606F\u5931\u8D25","Image Preview":"\u56FE\u7247\u9884\u89C8","Image uploads are not allowed in this chat.":"\u6B64\u804A\u5929\u4E0D\u5141\u8BB8\u4E0A\u4F20\u56FE\u7247\u3002","In Progress":"\u8FDB\u884C\u4E2D",language:{de:"Deutsch",en:"English",label:"\u8BED\u8A00",ru:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",zh:"\u4E2D\u6587"},"Language is not specified for this code block":"\u6B64\u4EE3\u7801\u5757\u672A\u6307\u5B9A\u8BED\u8A00",Main:"\u4E3B\u8981","More...":"\u66F4\u591A...","Open image source":"\u6253\u5F00\u56FE\u7247\u6765\u6E90",Others:"\u5176\u4ED6","RAG Search":"RAG \u641C\u7D22",Reasoning:"\u63A8\u7406",Send:"\u53D1\u9001","Some files are too large and were not added (max size: {{size}} MB)":"\u90E8\u5206\u6587\u4EF6\u8FC7\u5927\uFF0C\u672A\u88AB\u6DFB\u52A0\uFF08\u6700\u5927\uFF1A{{size}} MB\uFF09",source:"\u6765\u6E90","Start the conversation by sending a message":"\u53D1\u9001\u6D88\u606F\u5F00\u59CB\u5BF9\u8BDD",Started:"\u5DF2\u5F00\u59CB",Stop:"\u505C\u6B62","Tool Call":"\u5DE5\u5177\u8C03\u7528","Tool Call Completed":"\u5DE5\u5177\u8C03\u7528\u5B8C\u6210","Type your message...":"\u8F93\u5165\u6D88\u606F...","Upload File":"\u4E0A\u4F20\u6587\u4EF6",Warning:"\u8B66\u544A","Web Search":"\u7F51\u7EDC\u641C\u7D22",You:"\u4F60","You can only add up to {{count}} images at a time":"\u4E00\u6B21\u6700\u591A\u53EA\u80FD\u6DFB\u52A0 {{count}} \u5F20\u56FE\u7247"};var Nd=["en","de","ru","zh"],Od="ui-language";function O3(e={}){return(0,Gv.merge)({en:{translation:kv},de:{translation:Pv},ru:{translation:Bv},zh:{translation:Fv}},e)}async function GU({lookupLocalStorage:e=Od,supportedLngs:t=Nd,fallbackLng:n="en",resources:a={}}={}){return Uv.use(N3).use(A3).init({resources:O3(a),fallbackLng:n,supportedLngs:t,interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:e,caches:["localStorage"]}})}function Yv(e){return(typeof e=="string"?new Date(e):e).toLocaleDateString(Uv.language||"ru-RU",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}import{useTranslation as B3}from"react-i18next";var Vv=({fileName:e,fileUrl:t,mimeType:n,createdAt:a,onOpenSource:o,sourceTitle:s,onClose:l})=>{let[d,{open:u,close:p}]=k3(!1);y3(()=>{t&&u()},[t,u]);let E=zv(()=>{l(),p()},[l,p]),b=zv(()=>{o?.(),E()},[o,E]),{t:v}=B3();return gn.createElement(L3,{size:"xl",opened:d,onClose:E,title:v("Image Preview")},t&&gn.createElement(D3,{gap:"md"},gn.createElement(x3,{src:t,alt:e,fit:"contain",mah:"70vh"}),gn.createElement(Hv,{justify:"space-between"},gn.createElement("div",null,gn.createElement(Os,{size:"sm",fw:500},e),gn.createElement(Os,{size:"xs",c:"dimmed"},a?Yv(a)+" \u2022":""," ",n)),o&&gn.createElement(Hv,{gap:"xs"},gn.createElement(M3,{label:v("Open image source")},gn.createElement(w3,{variant:"light",onClick:b},gn.createElement(P3,{size:16}))))),o&&gn.createElement(Os,{size:"sm",c:"dimmed"},"From:"," ",gn.createElement(Os,{span:!0,c:"blue",style:{cursor:"pointer"},onClick:b},s||v("source")))))};var Wv=e=>[...Array.from(e.tHead?.querySelectorAll("tr")??[]),...Array.from(e.tBodies[0]?.querySelectorAll("tr")??[])].map(n=>Array.from(n.querySelectorAll("th, td")).map(a=>`"${(a.textContent||"").replace(/"/g,'""')}"`).join(",")).join(`
451
- `),qv=gr.memo(({messages:e,onMessageDeleted:t,onAddMessage:n,plugins:a=[],detailsPlugins:o=[],codePlugins:s,models:l=[]})=>{let{t:d}=G3(),u=F3(null),[p,E]=yd(),[b,v]=yd(),[R,I]=yd(new Set),N=yi(Y=>I(q=>new Set(q).add(Y)),[]),k=yi(Y=>{I(q=>{let te=new Set(q);return te.delete(Y),te})},[]),L=()=>{E(void 0),v(void 0)},G=yi(Y=>{if(!Y.target)return;let q=["code-run-btn","code-copy-btn","code-download-btn","code-toggle-all","copy-message-btn","code-header","message-image","table-sort-btn","table-copy-csv-btn","table-download-csv-btn"],te=Y.target;for(let Q of q){let ie=te.closest(`.${Q}`);if(ie){te=ie;break}}if(!te)return;let $=te,le=Q=>{let ie=Q?.parentElement;ie.classList.contains("collapsed")?(Q.classList.remove("collapsed"),ie&&ie.classList.remove("collapsed")):(Q.classList.add("collapsed"),ie&&ie.classList.add("collapsed"))};if($.classList.contains("code-run-btn")||$.classList.contains("code-download-btn")){let Q=$.dataset.lang,ie=$.classList.contains("code-run-btn"),xe=$.closest(".code-header")?.parentElement?.querySelector(".code-data");if(xe){let be=decodeURIComponent(xe.dataset.code||"").trim();if(!be)return xd.show({title:d("Error"),message:d("Code block is empty"),color:"red"});if(ie){if(!Q)return xd.show({title:d("Error"),message:d("Language is not specified for this code block"),color:"red"});s?.[Q]?.execute(be,Q)}else{let he=`code.${hv(Q||"txt")}`,z=new Blob([be],{type:"text/plain"}),Z=URL.createObjectURL(z),J=document.createElement("a");J.href=Z,J.download=he,J.click(),URL.revokeObjectURL(Z)}}}else if($.classList.contains("code-copy-btn")){let Q=$.parentElement?.parentElement?.nextElementSibling?.querySelector(".code-data");if(Q){let xe=decodeURIComponent(Q.dataset.code||"").trim();navigator.clipboard.writeText(xe)}let ie=$.querySelector(".copy-icon"),ge=$.querySelector(".check-icon");ie&&ge&&(ie.style.display="none",ge.style.display="block",setTimeout(()=>{ie.style.display="block",ge.style.display="none"},2e3))}else if($.classList.contains("code-header"))le($);else if($.classList.contains("code-toggle-all"))u.current?.querySelectorAll(".code-header").forEach(Q=>{le(Q)});else if($.classList.contains("copy-message-btn")){if($.dataset.messageId){let Q=$.dataset.messageIndex,ie=$.dataset.messageLinkedIndex,ge=$.dataset.messageId,xe=Q!=null?e[Number(Q)]:e.find(Z=>Z.id===ge);ie!=null&&(xe=xe?.linkedMessages?.[Number(ie)]),Ed(xe,"Message should exist to copy");let be=(xe.content||"").trim(),he=xe.html||[];if(he.length&&he[0]){let Z=new Blob([he.join("<br/>")],{type:"text/html"}),J=new Blob([be],{type:"text/plain"});navigator.clipboard.write([new ClipboardItem({[Z.type]:Z,[J.type]:J})]).catch(ae=>xd.show({title:d("Error"),message:ae.message||d("Failed to copy message"),color:"red"}))}else navigator.clipboard.writeText(be);let z=$.parentElement?.querySelector(".check-icon");z&&($.style.display="none",z.style.display="inline-block",setTimeout(()=>{$.style.display="inline-block",z.style.display="none"},2e3))}}else if($.classList.contains("message-image")){let Q=$.dataset.fileName,ie=$.src;E(ie),v(Q)}else if($.classList.contains("table-sort-btn")){let Q=parseInt($.dataset.colIndex||"0"),ie=$.closest("table");if(!ie)return;let ge=ie.querySelector("tbody");if(!ge)return;let be=$.dataset.sortDir==="asc"?"desc":"asc";ie.querySelectorAll("th.table-sort-btn").forEach(z=>{delete z.dataset.sortDir,z.classList.remove("sort-asc","sort-desc")}),$.dataset.sortDir=be,$.classList.add(be==="asc"?"sort-asc":"sort-desc");let he=Array.from(ge.querySelectorAll("tr"));he.sort((z,Z)=>{let J=z.querySelectorAll("td")[Q]?.textContent||"",ae=Z.querySelectorAll("td")[Q]?.textContent||"",Se=parseFloat(J),pe=parseFloat(ae);return!isNaN(Se)&&!isNaN(pe)?be==="asc"?Se-pe:pe-Se:be==="asc"?J.localeCompare(ae):ae.localeCompare(J)}),he.forEach(z=>ge.appendChild(z))}else if($.classList.contains("table-copy-csv-btn")){let Q=$.closest(".message-table");if(!Q)return;navigator.clipboard.writeText(Wv(Q));let ie=$.querySelector(".copy-icon"),ge=$.querySelector(".check-icon");ie&&ge&&(ie.style.display="none",ge.style.display="block",setTimeout(()=>{ie.style.display="block",ge.style.display="none"},2e3))}else if($.classList.contains("table-download-csv-btn")){let Q=$.closest(".message-table");if(!Q)return;let ie=new Blob([Wv(Q)],{type:"text/csv"}),ge=URL.createObjectURL(ie),xe=document.createElement("a");xe.href=ge,xe.download="table.csv",xe.click(),URL.revokeObjectURL(ge)}},[e,s]),U=yi(Y=>gr.createElement(gr.Fragment,null,a.map((q,te)=>gr.createElement(q,{key:te,message:Y,onAddMessage:n,onAction:N,onActionEnd:k,onMessageDeleted:t,disabled:R.has(Y.id)}))),[a,n,t,R,N,k]),V=yi(Y=>{let q=o.map((te,$)=>te(Y)).filter(vi);return q.length?q:null},[a,o]);return gr.createElement(gr.Fragment,null,gr.createElement(U3,{gap:"sm",ref:u,onClick:G},e.map((Y,q)=>gr.createElement(hd,{key:Y.id,message:Y,index:q,disabled:R.has(Y.id),pluginsLoader:U,messageDetailsLoader:V,models:l,codePlugins:s}))),gr.createElement(Vv,{fileName:b??"",fileUrl:p??"",onClose:L}))});import Ln,{useCallback as ys,useEffect as Xv,useImperativeHandle as q3,useRef as Zv,useState as Q3}from"react";import{Group as $3,Loader as K3}from"@mantine/core";import{IconCircleChevronDown as X3}from"@tabler/icons-react";import{useEffect as Y3,useRef as Qv}from"react";function Dd(e,t,n=0){let a=Qv(null),o=Qv(null);return Y3(()=>{a.current?.disconnect();let s=setTimeout(()=>{a.current=new IntersectionObserver(l=>{l[0].isIntersecting&&e()}),o.current&&a.current.observe(o.current)},n);return()=>{clearTimeout(s),a.current?.disconnect()}},[t,e]),o}import z3,{createContext as H3,useContext as V3,useEffect as $v}from"react";import{useLocalStorage as W3}from"@mantine/hooks";var Kv=H3(void 0),d8=({children:e})=>{let[t,n]=W3({key:"ui-theme",defaultValue:"light"});$v(()=>{if(t==="auto"){let o=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.dataset.mantine=o?"dark":"light"}else document.documentElement.dataset.mantine=t},[t]);let a=()=>{let o=t==="dark"?"light":"dark";n(o),document.documentElement.dataset.mantine=o};return $v(()=>{if(t==="auto"){let o=window.matchMedia("(prefers-color-scheme: dark)"),s=l=>{document.documentElement.dataset.mantine=l.matches?"dark":"light"};return o.addEventListener("change",s),()=>o.removeEventListener("change",s)}},[t]),z3.createElement(Kv.Provider,{value:{colorScheme:t,setColorScheme:n,toggleColorScheme:a}},e)},u8=()=>{let e=V3(Kv);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};var Jv=Ln.forwardRef(({messages:e,models:t=[],addChatMessage:n,removeMessages:a,loadMoreMessages:o,plugins:s,detailsPlugins:l,codePlugins:d,streaming:u=!1,loadCompleted:p=!0,loading:E=!1,autoScroll:b=!0,id:v="chat"},R)=>{let[I,N]=Q3(!1),k=Zv(null),L=Zv(null),G=ys(()=>{k.current?.scrollTo(0,k.current?.scrollHeight??0)},[k]);q3(R,()=>({scrollToBottom:G}),[G]);let U=ys(()=>{I||G()},[G,I]);Xv(()=>{if(b)U();else{let te=k.current;if(te){let{scrollTop:$,scrollHeight:le,clientHeight:Q}=te;le-$-Q<2||N(!0)}}},[e,U,b]);let V=ys(te=>{let{scrollTop:$,scrollHeight:le,clientHeight:Q}=te.target;L.current&&clearTimeout(L.current),le-$-Q<2?N(!1):e?.length&&(u?L.current=setTimeout(()=>{N(!0)},100):N(!0))},[e?.length,u]),Y=ys(()=>{N(!1),G()},[G]);Xv(()=>{p&&(N(!1),setTimeout(G,200))},[p,b]);let q=Dd(()=>o?.(),[o],200);return Ln.createElement("div",{className:["katechat-messages-container",p?"container--load-completed":"",p&&e?.length===0?"container--empty":""].join(" ")},Ln.createElement("div",{className:"katechat-messages-container-scroller",ref:k,onScroll:V},Ln.createElement("div",{ref:q,id:`${v}-first-message`}),E&&Ln.createElement($3,{justify:"center",align:"center",py:"xl"},Ln.createElement(K3,null)),Ln.createElement("div",{className:"katechat-messages-list"},e&&Ln.createElement(qv,{messages:e,onMessageDeleted:a,onAddMessage:n,models:t,plugins:s,detailsPlugins:l,codePlugins:d}))),Ln.createElement("div",{className:["katechat-anchor-container",I?"container--visible":""].join(" ")},Ln.createElement("div",{className:"katechat-anchor"},Ln.createElement(X3,{size:32,color:"teal",onClick:Y}))))});Jv.displayName="ChatMessagesContainer";import Da from"react";import{Modal as Z3,Button as jv,Group as J3,Text as j3,Stack as eP}from"@mantine/core";import{useTranslation as tP}from"react-i18next";var M8=({isOpen:e,onClose:t,onConfirm:n,title:a,message:o,confirmLabel:s,cancelLabel:l,isLoading:d=!1})=>{let{t:u}=tP();return Da.createElement(Z3,{opened:e,onClose:t,title:a||u("Confirm Deletion"),centered:!0},Da.createElement(eP,null,Da.createElement(j3,{style:{wordBreak:"break-word"}},o||u("Are you sure you want to delete this item? This action cannot be undone.")),Da.createElement(J3,{mt:"md",justify:"flex-end"},Da.createElement(jv,{variant:"outline",onClick:t,disabled:d},l||u("Cancel")),Da.createElement(jv,{color:"red",onClick:n,loading:d},s||u("Delete")))))};import ta from"react";import{Menu as xs,ActionIcon as nP,Tooltip as rP}from"@mantine/core";import{IconLanguage as aP}from"@tabler/icons-react";import{useTranslation as iP}from"react-i18next";var W8=({languages:e=Nd})=>{let{t,i18n:n}=iP(),a=o=>{n.changeLanguage(o),localStorage.setItem(Od,o)};return ta.createElement(xs,{shadow:"md",width:150,position:"bottom-end"},ta.createElement(xs.Target,null,ta.createElement(rP,{label:t("language.label")},ta.createElement(nP,{variant:"subtle","aria-label":t("language.label")},ta.createElement(aP,{size:18})))),ta.createElement(xs.Dropdown,null,e.map(o=>ta.createElement(xs.Item,{key:o,onClick:()=>a(o),fw:n.language===o?700:400},t(`language.${o}`)))))};export{Nd as BASE_SUPPORTED_LANGUAGES,j1 as ChatFileType,RU as ChatInput,hd as ChatMessage,EF as ChatMessagePreview,Jv as ChatMessagesContainer,qv as ChatMessagesList,J1 as CustomModelProtocol,M8 as DeleteConfirmationModal,oU as DropFilesOverlay,vd as FileDropzone,o3 as IMAGE_UPLOAD_FORMATS,Vv as ImagePopup,Od as LANGUAGE_STORAGE_KEY,W8 as LanguageSelector,Td as LinkedChatMessage,ec as MessageRole,Do as MessageStatus,X1 as MessageType,Z1 as ModelType,Ai as ProviderIcon,ti as ResponseStatus,Kv as ThemeContext,d8 as ThemeProvider,Tv as assert,Lr as escapeHtml,Yv as formatDate,LB as formatFileSize,PB as formatTokensLimit,hv as getProgrammingLanguageExt,GU as initI18n,hk as normalizeMatJax,wB as parseChatMessages,Rs as parseMarkdown,FB as sortItemsBySections,Dd as useIntersectionObserver,u8 as useTheme};
451
+ `),qv=gr.memo(({messages:e,onMessageDeleted:t,onAddMessage:n,plugins:a=[],detailsPlugins:o=[],codePlugins:s,models:l=[]})=>{let{t:d}=G3(),u=F3(null),[p,E]=yd(),[b,v]=yd(),[R,I]=yd(new Set),N=yi(Y=>I(q=>new Set(q).add(Y)),[]),k=yi(Y=>{I(q=>{let te=new Set(q);return te.delete(Y),te})},[]),L=()=>{E(void 0),v(void 0)},G=yi(Y=>{if(!Y.target)return;let q=["code-run-btn","code-copy-btn","code-download-btn","code-toggle-all","copy-message-btn","code-header","message-image","table-sort-btn","table-copy-csv-btn","table-download-csv-btn"],te=Y.target;for(let Q of q){let ie=te.closest(`.${Q}`);if(ie){te=ie;break}}if(!te)return;let $=te,le=Q=>{let ie=Q?.parentElement;ie.classList.contains("collapsed")?(Q.classList.remove("collapsed"),ie&&ie.classList.remove("collapsed")):(Q.classList.add("collapsed"),ie&&ie.classList.add("collapsed"))};if($.classList.contains("code-run-btn")||$.classList.contains("code-download-btn")){let Q=$.dataset.lang,ie=$.classList.contains("code-run-btn"),xe=$.closest(".code-header")?.parentElement?.querySelector(".code-data");if(xe){let be=decodeURIComponent(xe.dataset.code||"").trim();if(!be)return xd.show({title:d("Error"),message:d("Code block is empty"),color:"red"});if(ie){if(!Q)return xd.show({title:d("Error"),message:d("Language is not specified for this code block"),color:"red"});s?.[Q]?.execute(be,Q)}else{let he=`code.${hv(Q||"txt")}`,z=new Blob([be],{type:"text/plain"}),Z=URL.createObjectURL(z),J=document.createElement("a");J.href=Z,J.download=he,J.click(),URL.revokeObjectURL(Z)}}}else if($.classList.contains("code-copy-btn")){let Q=$.parentElement?.parentElement?.nextElementSibling?.querySelector(".code-data");if(Q){let xe=decodeURIComponent(Q.dataset.code||"").trim();navigator.clipboard.writeText(xe)}let ie=$.querySelector(".copy-icon"),ge=$.querySelector(".check-icon");ie&&ge&&(ie.style.display="none",ge.style.display="block",setTimeout(()=>{ie.style.display="block",ge.style.display="none"},2e3))}else if($.classList.contains("code-header"))le($);else if($.classList.contains("code-toggle-all"))u.current?.querySelectorAll(".code-header").forEach(Q=>{le(Q)});else if($.classList.contains("copy-message-btn")){if($.dataset.messageId){let Q=$.dataset.messageIndex,ie=$.dataset.messageLinkedIndex,ge=$.dataset.messageId,xe=Q!=null?e[Number(Q)]:e.find(Z=>Z.id===ge);ie!=null&&(xe=xe?.linkedMessages?.[Number(ie)]),Ed(xe,"Message should exist to copy");let be=(xe.content||"").trim(),he=xe.html||[];if(he.length&&he[0]){let Z=new Blob([he.join("<br/>")],{type:"text/html"}),J=new Blob([be],{type:"text/plain"});navigator.clipboard.write([new ClipboardItem({[Z.type]:Z,[J.type]:J})]).catch(ae=>xd.show({title:d("Error"),message:ae.message||d("Failed to copy message"),color:"red"}))}else navigator.clipboard.writeText(be);let z=$.parentElement?.querySelector(".check-icon");z&&($.style.display="none",z.style.display="inline-block",setTimeout(()=>{$.style.display="inline-block",z.style.display="none"},2e3))}}else if($.classList.contains("message-image")){let Q=$.dataset.fileName,ie=$.src;E(ie),v(Q)}else if($.classList.contains("table-sort-btn")){let Q=parseInt($.dataset.colIndex||"0"),ie=$.closest("table");if(!ie)return;let ge=ie.querySelector("tbody");if(!ge)return;let be=$.dataset.sortDir==="asc"?"desc":"asc";ie.querySelectorAll("th.table-sort-btn").forEach(z=>{delete z.dataset.sortDir,z.classList.remove("sort-asc","sort-desc")}),$.dataset.sortDir=be,$.classList.add(be==="asc"?"sort-asc":"sort-desc");let he=Array.from(ge.querySelectorAll("tr"));he.sort((z,Z)=>{let J=z.querySelectorAll("td")[Q]?.textContent||"",ae=Z.querySelectorAll("td")[Q]?.textContent||"",Se=parseFloat(J),pe=parseFloat(ae);return!isNaN(Se)&&!isNaN(pe)?be==="asc"?Se-pe:pe-Se:be==="asc"?J.localeCompare(ae):ae.localeCompare(J)}),he.forEach(z=>ge.appendChild(z))}else if($.classList.contains("table-copy-csv-btn")){let Q=$.closest(".message-table");if(!Q)return;navigator.clipboard.writeText(Wv(Q));let ie=$.querySelector(".copy-icon"),ge=$.querySelector(".check-icon");ie&&ge&&(ie.style.display="none",ge.style.display="block",setTimeout(()=>{ie.style.display="block",ge.style.display="none"},2e3))}else if($.classList.contains("table-download-csv-btn")){let Q=$.closest(".message-table");if(!Q)return;let ie=new Blob([Wv(Q)],{type:"text/csv"}),ge=URL.createObjectURL(ie),xe=document.createElement("a");xe.href=ge,xe.download="table.csv",xe.click(),URL.revokeObjectURL(ge)}},[e,s]),U=yi(Y=>gr.createElement(gr.Fragment,null,a.map((q,te)=>gr.createElement(q,{key:te,message:Y,onAddMessage:n,onAction:N,onActionEnd:k,onMessageDeleted:t,disabled:R.has(Y.id)}))),[a,n,t,R,N,k]),V=yi(Y=>{let q=o.map((te,$)=>te(Y)).filter(vi);return q.length?q:null},[a,o]);return gr.createElement(gr.Fragment,null,gr.createElement(U3,{gap:"sm",ref:u,onClick:G},e.map((Y,q)=>gr.createElement(hd,{key:Y.id,message:Y,index:q,disabled:R.has(Y.id),pluginsLoader:U,messageDetailsLoader:V,models:l,codePlugins:s}))),gr.createElement(Vv,{fileName:b??"",fileUrl:p??"",onClose:L}))});import Ln,{useCallback as ys,useEffect as Xv,useImperativeHandle as q3,useRef as Zv,useState as Q3}from"react";import{Group as $3,Loader as K3}from"@mantine/core";import{IconCircleChevronDown as X3}from"@tabler/icons-react";import{useEffect as Y3,useRef as Qv}from"react";function Dd(e,t,n=0){let a=Qv(null),o=Qv(null);return Y3(()=>{a.current?.disconnect();let s=setTimeout(()=>{a.current=new IntersectionObserver(l=>{l[0].isIntersecting&&e()}),o.current&&a.current.observe(o.current)},n);return()=>{clearTimeout(s),a.current?.disconnect()}},[t,e]),o}import z3,{createContext as H3,useContext as V3,useEffect as $v}from"react";import{useLocalStorage as W3}from"@mantine/hooks";var Kv=H3(void 0),d8=({children:e})=>{let[t,n]=W3({key:"ui-theme",defaultValue:"light"});$v(()=>{if(t==="auto"){let o=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.dataset.mantine=o?"dark":"light"}else document.documentElement.dataset.mantine=t},[t]);let a=()=>{let o=t==="dark"?"light":"dark";n(o),document.documentElement.dataset.mantine=o};return $v(()=>{if(t==="auto"){let o=window.matchMedia("(prefers-color-scheme: dark)"),s=l=>{document.documentElement.dataset.mantine=l.matches?"dark":"light"};return o.addEventListener("change",s),()=>o.removeEventListener("change",s)}},[t]),z3.createElement(Kv.Provider,{value:{colorScheme:t,setColorScheme:n,toggleColorScheme:a}},e)},u8=()=>{let e=V3(Kv);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};var Jv=Ln.forwardRef(({messages:e,models:t=[],addChatMessage:n,removeMessages:a,loadMoreMessages:o,plugins:s,detailsPlugins:l,codePlugins:d,streaming:u=!1,loadCompleted:p=!0,loading:E=!1,autoScroll:b=!0,id:v="chat"},R)=>{let[I,N]=Q3(!1),k=Zv(null),L=Zv(null),G=ys(()=>{k.current?.scrollTo(0,k.current?.scrollHeight??0)},[k]);q3(R,()=>({scrollToBottom:G}),[G]);let U=ys(()=>{I||G()},[G,I]);Xv(()=>{if(b)U();else{let te=k.current;if(te){let{scrollTop:$,scrollHeight:le,clientHeight:Q}=te;le-$-Q<2||N(!0)}}},[e,U,b]);let V=ys(te=>{let{scrollTop:$,scrollHeight:le,clientHeight:Q}=te.target;L.current&&clearTimeout(L.current),le-$-Q<2?N(!1):e?.length&&(u?L.current=setTimeout(()=>{N(!0)},100):N(!0))},[e?.length,u]),Y=ys(()=>{N(!1),G()},[G]);Xv(()=>{p&&(N(!1),setTimeout(G,200))},[p,b]);let q=Dd(()=>o?.(),[o],200);return Ln.createElement("div",{className:["katechat-messages-container",p?"container--load-completed":"",p&&e?.length===0?"container--empty":""].join(" ")},Ln.createElement("div",{className:"katechat-messages-container-scroller",ref:k,onScroll:V},Ln.createElement("div",{ref:q,id:`${v}-first-message`}),E&&Ln.createElement($3,{justify:"center",align:"center",py:"xl"},Ln.createElement(K3,null)),Ln.createElement("div",{className:"katechat-messages-list"},e&&Ln.createElement(qv,{messages:e,onMessageDeleted:a,onAddMessage:n,models:t,plugins:s,detailsPlugins:l,codePlugins:d}))),Ln.createElement("div",{className:["katechat-anchor-container",I?"container--visible":""].join(" ")},Ln.createElement("div",{className:"katechat-anchor"},Ln.createElement(X3,{size:32,color:"teal",onClick:Y}))))});Jv.displayName="ChatMessagesContainer";import Da from"react";import{Modal as Z3,Button as jv,Group as J3,Text as j3,Stack as eP}from"@mantine/core";import{useTranslation as tP}from"react-i18next";var M8=({isOpen:e,onClose:t,onConfirm:n,title:a,message:o,confirmLabel:s,cancelLabel:l,isLoading:d=!1})=>{let{t:u}=tP();return Da.createElement(Z3,{opened:e,onClose:t,title:a||u("Confirm Deletion"),centered:!0},Da.createElement(eP,null,Da.createElement(j3,{style:{wordBreak:"break-word"}},o||u("Are you sure you want to delete this item? This action cannot be undone.")),Da.createElement(J3,{mt:"md",justify:"flex-end"},Da.createElement(jv,{variant:"outline",onClick:t,disabled:d},l||u("Cancel")),Da.createElement(jv,{color:"red",onClick:n,loading:d},s||u("Delete")))))};import ta from"react";import{Menu as xs,ActionIcon as nP,Tooltip as rP}from"@mantine/core";import{IconLanguage as aP}from"@tabler/icons-react";import{useTranslation as iP}from"react-i18next";var W8=({languages:e=Nd,size:t=20})=>{let{t:n,i18n:a}=iP(),o=s=>{a.changeLanguage(s),localStorage.setItem(Od,s)};return ta.createElement(xs,{shadow:"md",width:150,position:"bottom-end"},ta.createElement(xs.Target,null,ta.createElement(rP,{label:n("language.label")},ta.createElement(nP,{variant:"subtle","aria-label":n("language.label")},ta.createElement(aP,{size:t})))),ta.createElement(xs.Dropdown,null,e.map(s=>ta.createElement(xs.Item,{key:s,onClick:()=>o(s),fw:a.language===s?700:400},n(`language.${s}`)))))};export{Nd as BASE_SUPPORTED_LANGUAGES,j1 as ChatFileType,RU as ChatInput,hd as ChatMessage,EF as ChatMessagePreview,Jv as ChatMessagesContainer,qv as ChatMessagesList,J1 as CustomModelProtocol,M8 as DeleteConfirmationModal,oU as DropFilesOverlay,vd as FileDropzone,o3 as IMAGE_UPLOAD_FORMATS,Vv as ImagePopup,Od as LANGUAGE_STORAGE_KEY,W8 as LanguageSelector,Td as LinkedChatMessage,ec as MessageRole,Do as MessageStatus,X1 as MessageType,Z1 as ModelType,Ai as ProviderIcon,ti as ResponseStatus,Kv as ThemeContext,d8 as ThemeProvider,Tv as assert,Lr as escapeHtml,Yv as formatDate,LB as formatFileSize,PB as formatTokensLimit,hv as getProgrammingLanguageExt,GU as initI18n,hk as normalizeMatJax,wB as parseChatMessages,Rs as parseMarkdown,FB as sortItemsBySections,Dd as useIntersectionObserver,u8 as useTheme};
452
452
  /*! Bundled license information:
453
453
 
454
454
  lodash/lodash.js: