import{j as e}from"./cm-1.0.63-CSIRHMXC.js";import{r as a}from"./redux-1.0.63-Df-eBzJn.js";import{e as n,B as d,aH as g}from"./index-1.0.63-oIDff4nA.js";import{C as f}from"./index-1.0.63-MKbdS7Mb.js";import{e as u}from"./notistack-1.0.63-B49ULGrj.js";import{a as y}from"./hooks-1.0.63-CWs3kTdT.js";import{k as j}from"./StartQueryBuilder-1.0.63-REjvqyiC.js";import{B as s}from"./Spinner-1.0.63-zcgIyS7Z.js";import{L as m}from"./Link-1.0.63-wURABoab.js";import{A as h}from"./AdminTheme-1.0.63-DhJ0rrw5.js";import{M as C}from"./markdown-1.0.63-BJvkzZkj.js";import{r as b}from"./rehyperaw-1.0.63-AkovKNCK.js";import{f as v}from"./Typography-1.0.63-mecuj_Wl.js";import"./vendor-1.0.63-CN03Eozo.js";import"./ButtonBase-1.0.63-CF10PFMS.js";import"./useEnhancedEffect-1.0.63-DnR0ZFqV.js";import"./ThemeProvider-1.0.63-Cq0KMgkh.js";import"./Modal-1.0.63-fMXTbfks.js";import"./iconBase-1.0.63-CFvHhC4t.js";import"./ctc-1.0.63-C3KWqNfd.js";import"./cmJson-1.0.63-CyZ2MfFg.js";import"./lib-1.0.63-DJZPtMem.js";import"./loglevel-1.0.63-BZ7XahX3.js";import"./lodash-1.0.63-hMxolcpJ.js";import"./moment-1.0.63-C5S46NFB.js";import"./useViewHeight-1.0.63-C7T4FLFa.js";const w=({className:t,children:r})=>{var i;const p=y();return e.jsxs(s,{sx:{position:"relative","& > pre":{border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:"4px",backgroundColor:"#fafafa",padding:"35px 20px 20px 20px",whiteSpace:"pre-wrap"},"& > pre code":{padding:0,margin:0,background:"transparent"}},children:[e.jsx("pre",{className:t,children:r}),e.jsxs(s,{sx:{position:"absolute",top:10,right:12,whiteSpace:"nowrap",display:"flex",gap:"10px"},children:[e.jsx(f,{text:(i=r==null?void 0:r.props)==null?void 0:i.children,onCopy:()=>{u("Code successfully copied to clipboard",{variant:"info"})},children:e.jsx(n,{title:"Copy query to clipboard",children:e.jsxs(m,{sx:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},children:[e.jsx(d,{}),"Copy"]})})}),e.jsx(n,{title:"Copy query to editor",children:e.jsxs(m,{sx:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},onClick:()=>{var o;p(j({copyQuery:(o=r==null?void 0:r.props)==null?void 0:o.children}))},children:[e.jsx(g,{}),"Edit"]})})]})]})},W=({chatMessages:t,loading:r,fullScreen:p})=>{const i=a.useRef(null);return a.useEffect(()=>{if(i.current!==null){const o=i.current;o.scrollTo(0,o.scrollHeight)}},[t]),a.useEffect(()=>{if(r&&i.current!==null){const o=i.current;o.scrollTo(0,o.scrollHeight)}},[r]),e.jsxs(s,{ref:i,sx:{overflowX:"hidden",overflowY:"scroll",margin:"0 20px",fontSize:"14px"},children:[...t.map(o=>{var l,c,x;return e.jsxs(s,{className:o.type==="ai"?"pp-message-ai":"pp-message-me",sx:{"&.pp-message-ai":{marginTop:0},"&.pp-message-ai .pp-message":{padding:0},"&.pp-message-me":{display:"flex",flexDirection:"row-reverse",justifyContent:"end",alignItems:"center","&:hover .pp-message-icon":{visibility:"visible"}},"&.pp-message-me .pp-message":{borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",padding:"0 16px",bgcolor:"#f5f5f5"}},children:[o.message&&e.jsx(s,{className:"pp-message",sx:{whiteSpace:"normal",fontFamily:"monospace",...o.isError===!0&&{color:(x=(c=(l=h)==null?void 0:l.palette)==null?void 0:c.error)==null?void 0:x.dark},...o.isNote===!0&&{fontStyle:"italic"},"& > *":{margin:p?"2em 0":"1em 0",padding:0}},children:e.jsx(C,{rehypePlugins:[b],components:{pre:w},children:o.message})}),e.jsx(s,{className:"pp-message-icon",sx:{marginBottom:p?"2em":"1em",...o.type==="me"&&{visibility:"hidden",padding:"0 5px 0 30px",marginBottom:0}},children:o.isNote!==!0&&e.jsx(f,{text:o.message,onCopy:()=>{u("Message successfully copied to clipboard",{variant:"info"})},children:e.jsx(n,{title:"Copy to clipboard",children:e.jsxs(m,{sx:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},children:[e.jsx(d,{}),"Copy"]})})})})]})}),r?e.jsx(s,{sx:{padding:"30px",textAlign:"center","& svg":{color:"rgba(0, 0, 0, 0.23)"}},children:e.jsx(v,{size:24})}):""]})};export{W as default};
