@questdb/web-console 2.0.0 → 2.0.1

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.
@@ -0,0 +1,1047 @@
1
+ import{p as le,Q as ft,s as je,u as Te,a as Fa,j as t,c as qt,A as it,K as Lt,b as r,B as ue,t as _e,C as He,e as Ze,d as Dt,f as q,g as Ra,h as yt,i as xt,k as Tt,l as za,m as $a,n as Ft,o as Ba,q as be,r as wt,v as Rt,w as Wa,T as Qa,x as zt,y as $t,z as Oa,D as Bt,S as Ka,L as Pe,E as Pa,F as de,G as Wt,H as Ct,I as Ua,J as Ga,M as Ae,N as bt,O as Xa,P as Ya,R as At,U as Fe,V as Ja,W as Qt,X as en,Y as tn,Z as an,_ as nn,$ as rn,a0 as sn,a1 as on,a2 as ln,a3 as dn,a4 as Ot,a5 as cn,a6 as hn,a7 as mn,a8 as ge,a9 as un,aa as gn,ab as pn,ac as fn,ad as Kt,ae as Re,af as yn,ag as xn,ah as wn,ai as Ue,aj as Ge,ak as Xe,al as Ye,am as Je,an as Cn,ao as bn,ap as An,aq as vn,ar as kn,as as Mn,at as jn,au as _n,av as st,aw as Pt,ax as Hn,ay as En,az as In,aA as Nn}from"./index-zPfXTse8.js";import{b as e,E as Ee,H as i,Z as vt,R as ot,C as re,U as Vn,D as Ut}from"./vendor-BhHVTKlu.js";const Zn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a100,100,0,0,1-98.66,100H128a99.39,99.39,0,0,1-68.62-27.29,12,12,0,0,1,16.48-17.45,76,76,0,1,0-1.57-109c-.13.13-.25.25-.39.37L54.89,92H72a12,12,0,0,1,0,24H24a12,12,0,0,1-12-12V56a12,12,0,0,1,24,0V76.72L57.48,57.06A100,100,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L60.63,81.29l17,17A8,8,0,0,1,72,112H24a8,8,0,0,1-8-8V56A8,8,0,0,1,29.66,50.3L49.31,70,60.25,60A96,96,0,0,1,224,128Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a94,94,0,0,1-92.74,94H128a93.43,93.43,0,0,1-64.5-25.65,6,6,0,1,1,8.24-8.72A82,82,0,1,0,70,70l-.19.19L39.44,98H72a6,6,0,0,1,0,12H24a6,6,0,0,1-6-6V56a6,6,0,0,1,12,0V90.34L61.63,61.4A94,94,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a92,92,0,0,1-90.77,92H128a91.47,91.47,0,0,1-63.13-25.1,4,4,0,1,1,5.5-5.82A84,84,0,1,0,68.6,68.57l-.13.12L34.3,100H72a4,4,0,0,1,0,8H24a4,4,0,0,1-4-4V56a4,4,0,0,1,8,0V94.89l35-32A92,92,0,0,1,220,128Z"}))]]),Sn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208.49,120.49a12,12,0,0,1-17,0L140,69V216a12,12,0,0,1-24,0V69L64.49,120.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0l72,72A12,12,0,0,1,208.49,120.49Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M200,112H56l72-72Z",opacity:"0.2"}),e.createElement("path",{d:"M205.66,106.34l-72-72a8,8,0,0,0-11.32,0l-72,72A8,8,0,0,0,56,120h64v96a8,8,0,0,0,16,0V120h64a8,8,0,0,0,5.66-13.66ZM75.31,104,128,51.31,180.69,104Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M207.39,115.06A8,8,0,0,1,200,120H136v96a8,8,0,0,1-16,0V120H56a8,8,0,0,1-5.66-13.66l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,207.39,115.06Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M204.24,116.24a6,6,0,0,1-8.48,0L134,54.49V216a6,6,0,0,1-12,0V54.49L60.24,116.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0l72,72A6,6,0,0,1,204.24,116.24Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M202.83,114.83a4,4,0,0,1-5.66,0L132,49.66V216a4,4,0,0,1-8,0V49.66L58.83,114.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0l72,72A4,4,0,0,1,202.83,114.83Z"}))]]),qn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M88,128a16,16,0,1,1,16,16A16,16,0,0,1,88,128Zm64,16a16,16,0,1,0-16-16A16,16,0,0,0,152,144Zm84-80V192a20,20,0,0,1-20,20H84.47L53,239.17l-.12.11A19.91,19.91,0,0,1,40.05,244a20.14,20.14,0,0,1-8.49-1.9A19.82,19.82,0,0,1,20,224V64A20,20,0,0,1,40,44H216A20,20,0,0,1,236,64Zm-24,4H44V215.23l28.16-24.32A11.93,11.93,0,0,1,80,188H212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,64V192a8,8,0,0,1-8,8H80L45.15,230.11A8,8,0,0,1,32,224V64a8,8,0,0,1,8-8H216A8,8,0,0,1,224,64Z",opacity:"0.2"}),e.createElement("path",{d:"M116,128a12,12,0,1,1,12,12A12,12,0,0,1,116,128ZM84,140a12,12,0,1,0-12-12A12,12,0,0,0,84,140Zm88,0a12,12,0,1,0-12-12A12,12,0,0,0,172,140Zm60-76V192a16,16,0,0,1-16,16H83l-32.6,28.16-.09.07A15.89,15.89,0,0,1,40,240a16.13,16.13,0,0,1-6.8-1.52A15.85,15.85,0,0,1,24,224V64A16,16,0,0,1,40,48H216A16,16,0,0,1,232,64ZM40,224h0ZM216,64H40V224l34.77-30A8,8,0,0,1,80,192H216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.84,15.84,0,0,0,9.25,14.5A16.05,16.05,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM84,140a12,12,0,1,1,12-12A12,12,0,0,1,84,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,172,140Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM84,118a10,10,0,1,0,10,10A10,10,0,0,0,84,118Zm88,0a10,10,0,1,0,10,10A10,10,0,0,0,172,118Zm58-54V192a14,14,0,0,1-14,14H82.23L49.07,234.64l-.06.05A13.87,13.87,0,0,1,40,238a14.11,14.11,0,0,1-5.95-1.33A13.88,13.88,0,0,1,26,224V64A14,14,0,0,1,40,50H216A14,14,0,0,1,230,64Zm-12,0a2,2,0,0,0-2-2H40a2,2,0,0,0-2,2V224a2,2,0,0,0,3.26,1.55l34.82-30.08A6,6,0,0,1,80,194H216a2,2,0,0,0,2-2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M116,128a12,12,0,1,1,12,12A12,12,0,0,1,116,128ZM84,140a12,12,0,1,0-12-12A12,12,0,0,0,84,140Zm88,0a12,12,0,1,0-12-12A12,12,0,0,0,172,140Zm60-76V192a16,16,0,0,1-16,16H83l-32.6,28.16-.09.07A15.89,15.89,0,0,1,40,240a16.13,16.13,0,0,1-6.8-1.52A15.85,15.85,0,0,1,24,224V64A16,16,0,0,1,40,48H216A16,16,0,0,1,232,64ZM40,224h0ZM216,64H40V224l34.77-30A8,8,0,0,1,80,192H216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-52-8a8,8,0,1,0,8,8A8,8,0,0,0,84,120Zm88,0a8,8,0,1,0,8,8A8,8,0,0,0,172,120Zm56-56V192a12,12,0,0,1-12,12H81.49L47.76,233.13l0,0A11.89,11.89,0,0,1,40,236a12.17,12.17,0,0,1-5.1-1.14A11.89,11.89,0,0,1,28,224V64A12,12,0,0,1,40,52H216A12,12,0,0,1,228,64Zm-8,0a4,4,0,0,0-4-4H40a4,4,0,0,0-4,4V224a4,4,0,0,0,6.56,3.08L77.38,197A4,4,0,0,1,80,196H216a4,4,0,0,0,4-4Z"}))]]),Ln=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,44H40A20,20,0,0,0,20,64V224A19.82,19.82,0,0,0,31.56,242.1a20.14,20.14,0,0,0,8.49,1.9,19.91,19.91,0,0,0,12.82-4.72l.12-.11L84.47,212H216a20,20,0,0,0,20-20V64A20,20,0,0,0,216,44Zm-4,144H80a11.93,11.93,0,0,0-7.84,2.92L44,215.23V68H212ZM84,108A12,12,0,0,1,96,96h64a12,12,0,1,1,0,24H96A12,12,0,0,1,84,108Zm0,40a12,12,0,0,1,12-12h64a12,12,0,0,1,0,24H96A12,12,0,0,1,84,148Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,64V192a8,8,0,0,1-8,8H80L45.15,230.11A8,8,0,0,1,32,224V64a8,8,0,0,1,8-8H216A8,8,0,0,1,224,64Z",opacity:"0.2"}),e.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.84,15.84,0,0,0,9.25,14.5A16.05,16.05,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM160,152H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,50H40A14,14,0,0,0,26,64V224a13.88,13.88,0,0,0,8.09,12.69A14.11,14.11,0,0,0,40,238a13.87,13.87,0,0,0,9-3.31l.06-.05L82.23,206H216a14,14,0,0,0,14-14V64A14,14,0,0,0,216,50Zm2,142a2,2,0,0,1-2,2H80a6,6,0,0,0-3.92,1.46L41.26,225.53A2,2,0,0,1,38,224V64a2,2,0,0,1,2-2H216a2,2,0,0,1,2,2Zm-52-80a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,112Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,144Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48H40A16,16,0,0,0,24,64V224a15.85,15.85,0,0,0,9.24,14.5A16.13,16.13,0,0,0,40,240a15.89,15.89,0,0,0,10.25-3.78l.09-.07L83,208H216a16,16,0,0,0,16-16V64A16,16,0,0,0,216,48ZM40,224h0ZM216,192H80a8,8,0,0,0-5.23,1.95L40,224V64H216ZM88,112a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H96A8,8,0,0,1,88,112Zm0,32a8,8,0,0,1,8-8h64a8,8,0,1,1,0,16H96A8,8,0,0,1,88,144Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,52H40A12,12,0,0,0,28,64V224a11.89,11.89,0,0,0,6.93,10.88A12.17,12.17,0,0,0,40,236a11.89,11.89,0,0,0,7.69-2.83l0,0L81.49,204H216a12,12,0,0,0,12-12V64A12,12,0,0,0,216,52Zm4,140a4,4,0,0,1-4,4H80a4,4,0,0,0-2.62,1L42.56,227.06A4,4,0,0,1,36,224V64a4,4,0,0,1,4-4H216a4,4,0,0,1,4,4Zm-56-80a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,112Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,144Z"}))]]),Dn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M236,137A108.13,108.13,0,1,1,119,20,12,12,0,0,1,121,44,84.12,84.12,0,1,0,212,135,12,12,0,1,1,236,137ZM116,76v52a12,12,0,0,0,12,12h52a12,12,0,0,0,0-24H140V76a12,12,0,0,0-24,0Zm92,20a16,16,0,1,0-16-16A16,16,0,0,0,208,96ZM176,64a16,16,0,1,0-16-16A16,16,0,0,0,176,64Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M232,136.66A104.12,104.12,0,1,1,119.34,24,8,8,0,0,1,120.66,40,88.12,88.12,0,1,0,216,135.34,8,8,0,0,1,232,136.66ZM120,72v56a8,8,0,0,0,8,8h56a8,8,0,0,0,0-16H136V72a8,8,0,0,0-16,0Zm40-24a12,12,0,1,0-12-12A12,12,0,0,0,160,48Zm36,24a12,12,0,1,0-12-12A12,12,0,0,0,196,72Zm24,36a12,12,0,1,0-12-12A12,12,0,0,0,220,108Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,96a12,12,0,1,1,12,12A12,12,0,0,1,208,96ZM196,72a12,12,0,1,0-12-12A12,12,0,0,0,196,72Zm28.66,56a8,8,0,0,0-8.63,7.31A88.12,88.12,0,1,1,120.66,40,8,8,0,0,0,119.34,24,104.12,104.12,0,1,0,232,136.66,8,8,0,0,0,224.66,128ZM128,56a72,72,0,1,1-72,72A72.08,72.08,0,0,1,128,56Zm-8,72a8,8,0,0,0,8,8h48a8,8,0,0,0,0-16H136V80a8,8,0,0,0-16,0Zm40-80a12,12,0,1,0-12-12A12,12,0,0,0,160,48Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M230,136.49A102.12,102.12,0,1,1,119.51,26a6,6,0,0,1,1,12A90.13,90.13,0,1,0,218,135.51a6,6,0,1,1,12,1ZM122,72v56a6,6,0,0,0,6,6h56a6,6,0,0,0,0-12H134V72a6,6,0,0,0-12,0Zm38-26a10,10,0,1,0-10-10A10,10,0,0,0,160,46Zm36,24a10,10,0,1,0-10-10A10,10,0,0,0,196,70Zm24,36a10,10,0,1,0-10-10A10,10,0,0,0,220,106Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,136.66A104.12,104.12,0,1,1,119.34,24,8,8,0,0,1,120.66,40,88.12,88.12,0,1,0,216,135.34,8,8,0,0,1,232,136.66ZM120,72v56a8,8,0,0,0,8,8h56a8,8,0,0,0,0-16H136V72a8,8,0,0,0-16,0Zm40-24a12,12,0,1,0-12-12A12,12,0,0,0,160,48Zm36,24a12,12,0,1,0-12-12A12,12,0,0,0,196,72Zm24,36a12,12,0,1,0-12-12A12,12,0,0,0,220,108Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,136.33A100.13,100.13,0,1,1,119.67,28a4,4,0,1,1,.66,8A92.13,92.13,0,1,0,220,135.67a4,4,0,1,1,8,.66ZM128,132h56a4,4,0,0,0,0-8H132V72a4,4,0,0,0-8,0v56A4,4,0,0,0,128,132Zm32-88a8,8,0,1,0-8-8A8,8,0,0,0,160,44Zm36,24a8,8,0,1,0-8-8A8,8,0,0,0,196,68Zm24,36a8,8,0,1,0-8-8A8,8,0,0,0,220,104Z"}))]]),Tn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M140,80v41.21l34.17,20.5a12,12,0,1,1-12.34,20.58l-40-24A12,12,0,0,1,116,128V80a12,12,0,0,1,24,0ZM128,28A99.38,99.38,0,0,0,57.24,57.34c-4.69,4.74-9,9.37-13.24,14V64a12,12,0,0,0-24,0v40a12,12,0,0,0,12,12H72a12,12,0,0,0,0-24H57.77C63,86,68.37,80.22,74.26,74.26a76,76,0,1,1,1.58,109,12,12,0,0,0-16.48,17.46A100,100,0,1,0,128,28Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z",opacity:"0.2"}),e.createElement("path",{d:"M136,80v43.47l36.12,21.67a8,8,0,0,1-8.24,13.72l-40-24A8,8,0,0,1,120,128V80a8,8,0,0,1,16,0Zm-8-48A95.44,95.44,0,0,0,60.08,60.15C52.81,67.51,46.35,74.59,40,82V64a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16H49c7.15-8.42,14.27-16.35,22.39-24.57a80,80,0,1,1,1.66,114.75,8,8,0,1,0-11,11.64A96,96,0,1,0,128,32Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128A96,96,0,0,1,62.11,197.82a8,8,0,1,1,11-11.64A80,80,0,1,0,71.43,71.43C67.9,75,64.58,78.51,61.35,82L77.66,98.34A8,8,0,0,1,72,112H32a8,8,0,0,1-8-8V64a8,8,0,0,1,13.66-5.66L50,70.7c3.22-3.49,6.54-7,10.06-10.55A96,96,0,0,1,224,128ZM128,72a8,8,0,0,0-8,8v48a8,8,0,0,0,3.88,6.86l40,24a8,8,0,1,0,8.24-13.72L136,123.47V80A8,8,0,0,0,128,72Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M134,80v44.6l37.09,22.25a6,6,0,0,1-6.18,10.3l-40-24A6,6,0,0,1,122,128V80a6,6,0,0,1,12,0Zm-6-46A93.4,93.4,0,0,0,61.51,61.56c-8.58,8.68-16,17-23.51,25.8V64a6,6,0,0,0-12,0v40a6,6,0,0,0,6,6H72a6,6,0,0,0,0-12H44.73C52.86,88.29,60.79,79.35,70,70a82,82,0,1,1,1.7,117.62,6,6,0,1,0-8.24,8.72A94,94,0,1,0,128,34Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M136,80v43.47l36.12,21.67a8,8,0,0,1-8.24,13.72l-40-24A8,8,0,0,1,120,128V80a8,8,0,0,1,16,0Zm-8-48A95.44,95.44,0,0,0,60.08,60.15C52.81,67.51,46.35,74.59,40,82V64a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H72a8,8,0,0,0,0-16H49c7.15-8.42,14.27-16.35,22.39-24.57a80,80,0,1,1,1.66,114.75,8,8,0,1,0-11,11.64A96,96,0,1,0,128,32Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M132,80v45.74l38.06,22.83a4,4,0,0,1-4.12,6.86l-40-24A4,4,0,0,1,124,128V80a4,4,0,0,1,8,0Zm-4-44A91.42,91.42,0,0,0,62.93,63C53.05,73,44.66,82.47,36,92.86V64a4,4,0,0,0-8,0v40a4,4,0,0,0,4,4H72a4,4,0,0,0,0-8H40.47C49.61,89,58.3,79,68.6,68.6a84,84,0,1,1,1.75,120.49,4,4,0,1,0-5.5,5.82A92,92,0,1,0,128,36Z"}))]]),Fn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M51.51,104.49l-32-32a12,12,0,0,1,0-17l32-32a12,12,0,1,1,17,17L45,64,68.49,87.51a12,12,0,0,1-17,17Zm48,0a12,12,0,0,0,17,0l32-32a12,12,0,0,0,0-17l-32-32a12,12,0,1,0-17,17L123,64,99.51,87.51A12,12,0,0,0,99.51,104.49ZM200,36H180a12,12,0,0,0,0,24h16V196H60V140a12,12,0,0,0-24,0v60a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M152,32V96a16,16,0,0,1-16,16H32A16,16,0,0,1,16,96V32A16,16,0,0,1,32,16H136A16,16,0,0,1,152,32Z",opacity:"0.2"}),e.createElement("path",{d:"M58.34,101.66l-32-32a8,8,0,0,1,0-11.32l32-32A8,8,0,0,1,69.66,37.66L43.31,64,69.66,90.34a8,8,0,0,1-11.32,11.32Zm40,0a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0,0-11.32l-32-32A8,8,0,0,0,98.34,37.66L124.69,64,98.34,90.34A8,8,0,0,0,98.34,101.66ZM200,40H176a8,8,0,0,0,0,16h24V200H56V136a8,8,0,0,0-16,0v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M200,40H168a16,16,0,0,0-16-16H32A16,16,0,0,0,16,40v80a16,16,0,0,0,16,16h8v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40ZM106.34,61.66a8,8,0,0,1,11.32-11.32l24,24a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L124.69,80Zm-64,24a8,8,0,0,1,0-11.32l24-24A8,8,0,0,1,77.66,61.66L59.31,80,77.66,98.34a8,8,0,0,1-11.32,11.32ZM200,200H56V136h96a16,16,0,0,0,16-16V56h32Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M59.76,100.24l-32-32a6,6,0,0,1,0-8.48l32-32a6,6,0,1,1,8.48,8.48L40.49,64,68.24,91.76a6,6,0,1,1-8.48,8.48Zm40,0a6,6,0,0,0,8.48,0l32-32a6,6,0,0,0,0-8.48l-32-32a6,6,0,1,0-8.48,8.48L127.51,64,99.76,91.76A6,6,0,0,0,99.76,100.24ZM200,42H176a6,6,0,0,0,0,12h24a2,2,0,0,1,2,2V200a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V136a6,6,0,0,0-12,0v64a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M58.34,101.66l-32-32a8,8,0,0,1,0-11.32l32-32A8,8,0,0,1,69.66,37.66L43.31,64,69.66,90.34a8,8,0,0,1-11.32,11.32Zm40,0a8,8,0,0,0,11.32,0l32-32a8,8,0,0,0,0-11.32l-32-32A8,8,0,0,0,98.34,37.66L124.69,64,98.34,90.34A8,8,0,0,0,98.34,101.66ZM200,40H176a8,8,0,0,0,0,16h24V200H56V136a8,8,0,0,0-16,0v64a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M61.17,98.83l-32-32a4,4,0,0,1,0-5.66l32-32a4,4,0,0,1,5.66,5.66L37.66,64,66.83,93.17a4,4,0,0,1-5.66,5.66Zm40,0a4,4,0,0,0,5.66,0l32-32a4,4,0,0,0,0-5.66l-32-32a4,4,0,0,0-5.66,5.66L130.34,64,101.17,93.17A4,4,0,0,0,101.17,98.83ZM200,44H176a4,4,0,0,0,0,8h24a4,4,0,0,1,4,4V200a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V136a4,4,0,0,0-8,0v64a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Z"}))]]),Rn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M209.88,69.83A115.19,115.19,0,0,0,128,36h-.41C63.85,36.22,12,88.76,12,153.13V176a20,20,0,0,0,20,20H224a20,20,0,0,0,20-20V152A115.25,115.25,0,0,0,209.88,69.83ZM220,172H127.32l46.44-65A12,12,0,1,0,154.24,93L97.82,172H36V153.13c0-1.72,0-3.43.14-5.13H56a12,12,0,0,0,0-24H40.62c10.91-33.39,40-58.52,75.38-63.21V80a12,12,0,0,0,24,0V60.8A92,92,0,0,1,215.66,124H200a12,12,0,0,0,0,24h19.9c.06,1.33.1,2.66.1,4Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232,152v24a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V153.13C24,95.65,70.15,48.2,127.63,48A104,104,0,0,1,232,152Z",opacity:"0.2"}),e.createElement("path",{d:"M207.06,72.67A111.24,111.24,0,0,0,128,40h-.4C66.07,40.21,16,91,16,153.13V176a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V152A111.25,111.25,0,0,0,207.06,72.67ZM224,176H119.71l54.76-75.3a8,8,0,0,0-12.94-9.42L99.92,176H32V153.13c0-3.08.15-6.12.43-9.13H56a8,8,0,0,0,0-16H35.27c10.32-38.86,44-68.24,84.73-71.66V80a8,8,0,0,0,16,0V56.33A96.14,96.14,0,0,1,221,128H200a8,8,0,0,0,0,16h23.67c.21,2.65.33,5.31.33,8Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M240,152v24a16,16,0,0,1-16,16H115.93a4,4,0,0,1-3.24-6.35L174.27,101a8.21,8.21,0,0,0-1.37-11.3,8,8,0,0,0-11.37,1.61l-72,99.06A4,4,0,0,1,86.25,192H32a16,16,0,0,1-16-16V153.13c0-1.79,0-3.57.13-5.33a4,4,0,0,1,4-3.8H48a8,8,0,0,0,8-8.53A8.17,8.17,0,0,0,47.73,128H23.92a4,4,0,0,1-3.87-5c12-43.84,49.66-77.13,95.52-82.28a4,4,0,0,1,4.43,4V72a8,8,0,0,0,8.53,8A8.17,8.17,0,0,0,136,71.73V44.67a4,4,0,0,1,4.43-4A112.18,112.18,0,0,1,236.23,123a4,4,0,0,1-3.88,5H208.27a8.17,8.17,0,0,0-8.25,7.47,8,8,0,0,0,8,8.53h27.92a4,4,0,0,1,4,3.86C240,149.23,240,150.61,240,152Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M205.65,74.08A109.26,109.26,0,0,0,128,42h-.39C67.17,42.21,18,92.06,18,153.13V176a14,14,0,0,0,14,14H224a14,14,0,0,0,14-14V152A109.3,109.3,0,0,0,205.65,74.08ZM226,176a2,2,0,0,1-2,2H115.78l57.07-78.47a6,6,0,0,0-9.7-7.06L100.94,178H32a2,2,0,0,1-2-2V153.13A102.36,102.36,0,0,1,30.62,142H56a6,6,0,0,0,0-12H32.71C42.6,88.4,78.53,56.86,122,54.19V80a6,6,0,0,0,12,0V54.19A98.05,98.05,0,0,1,223.53,130H200a6,6,0,0,0,0,12h25.5c.33,3.3.5,6.64.5,10Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M207.06,72.67A111.24,111.24,0,0,0,128,40h-.4C66.07,40.21,16,91,16,153.13V176a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V152A111.25,111.25,0,0,0,207.06,72.67ZM224,176H119.71l54.76-75.3a8,8,0,0,0-12.94-9.42L99.92,176H32V153.13c0-3.08.15-6.12.43-9.13H56a8,8,0,0,0,0-16H35.27c10.32-38.86,44-68.24,84.73-71.66V80a8,8,0,0,0,16,0V56.33A96.14,96.14,0,0,1,221,128H200a8,8,0,0,0,0,16h23.67c.21,2.65.33,5.31.33,8Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M204.23,75.5A107.37,107.37,0,0,0,127.62,44C68.28,44.21,20,93.16,20,153.13V176a12,12,0,0,0,12,12H224a12,12,0,0,0,12-12V152A107.25,107.25,0,0,0,204.23,75.5ZM228,176a4,4,0,0,1-4,4H111.85l59.38-81.65a4,4,0,1,0-6.46-4.7L102,180H32a4,4,0,0,1-4-4V153.13A103.42,103.42,0,0,1,28.84,140H56a4,4,0,0,0,0-8H30.21C39.59,87.66,77.84,53.93,124,52.09V80a4,4,0,0,0,8,0V52.08A100.08,100.08,0,0,1,226,132H200a4,4,0,0,0,0,8h27.29a101.6,101.6,0,0,1,.71,12Z"}))]]),zn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M71.51,144.49a12,12,0,0,1,0-17l24-24a12,12,0,0,1,17,17L109,124h55V104a12,12,0,0,1,24,0v32a12,12,0,0,1-12,12H109l3.52,3.51a12,12,0,0,1-17,17ZM236,56V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56Zm-24,4H44V196H212Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,56V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),e.createElement("path",{d:"M184,104v32a8,8,0,0,1-8,8H99.31l10.35,10.34a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L99.31,128H168V104a8,8,0,0,1,16,0Zm48-48V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm-32,96a8,8,0,0,1-8,8H99.31l10.35,10.34a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L99.31,128H168V104a8,8,0,0,1,16,0Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M182,104v32a6,6,0,0,1-6,6H94.48l13.76,13.76a6,6,0,1,1-8.48,8.48l-24-24a6,6,0,0,1,0-8.48l24-24a6,6,0,0,1,8.48,8.48L94.48,130H170V104a6,6,0,0,1,12,0Zm48-48V200a14,14,0,0,1-14,14H40a14,14,0,0,1-14-14V56A14,14,0,0,1,40,42H216A14,14,0,0,1,230,56Zm-12,0a2,2,0,0,0-2-2H40a2,2,0,0,0-2,2V200a2,2,0,0,0,2,2H216a2,2,0,0,0,2-2Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M184,104v32a8,8,0,0,1-8,8H99.31l10.35,10.34a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L99.31,128H168V104a8,8,0,0,1,16,0Zm48-48V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M180,104v32a4,4,0,0,1-4,4H89.66l17.17,17.17a4,4,0,0,1-5.66,5.66l-24-24a4,4,0,0,1,0-5.66l24-24a4,4,0,0,1,5.66,5.66L89.66,132H172V104a4,4,0,0,1,8,0Zm48-48V200a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V56A12,12,0,0,1,40,44H216A12,12,0,0,1,228,56Zm-8,0a4,4,0,0,0-4-4H40a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H216a4,4,0,0,0,4-4Z"}))]]),$n=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z",opacity:"0.2"}),e.createElement("path",{d:"M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z"}))]]),Bn=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM188,204H68V72H188ZM76,20A12,12,0,0,1,88,8h80a12,12,0,0,1,0,24H88A12,12,0,0,1,76,20Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M200,56V208a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V56Z",opacity:"0.2"}),e.createElement("path",{d:"M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,56a8,8,0,0,1-8,8h-8V208a16,16,0,0,1-16,16H64a16,16,0,0,1-16-16V64H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,56ZM88,32h80a8,8,0,0,0,0-16H88a8,8,0,0,0,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,50H40a6,6,0,0,0,0,12H50V208a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V62h10a6,6,0,0,0,0-12ZM194,208a2,2,0,0,1-2,2H64a2,2,0,0,1-2-2V62H194ZM82,24a6,6,0,0,1,6-6h80a6,6,0,0,1,0,12H88A6,6,0,0,1,82,24Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,52H40a4,4,0,0,0,0,8H52V208a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V60h12a4,4,0,0,0,0-8ZM196,208a4,4,0,0,1-4,4H64a4,4,0,0,1-4-4V60H196ZM84,24a4,4,0,0,1,4-4h80a4,4,0,0,1,0,8H88A4,4,0,0,1,84,24Z"}))]]),Gt=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Zn}));Gt.displayName="ArrowCounterClockwiseIcon";const Xt=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Sn}));Xt.displayName="ArrowUpIcon";const Yt=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:qn}));Yt.displayName="ChatDotsIcon";const Jt=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Ln}));Jt.displayName="ChatTextIcon";const ea=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Dn}));ea.displayName="ClockCountdownIcon";const ta=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Tn}));ta.displayName="ClockCounterClockwiseIcon";const aa=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Fn}));aa.displayName="CodeBlockIcon";const na=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Rn}));na.displayName="GaugeIcon";const ra=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:zn}));ra.displayName="KeyReturnIcon";const ia=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:$n}));ia.displayName="MagnifyingGlassIcon";const sa=e.forwardRef((a,n)=>e.createElement(le,{ref:n,...a,weights:Bn}));sa.displayName="TrashSimpleIcon";const Wn=i(q).attrs({alignItems:"center",gap:"0"}).withConfig({displayName:"ExplainQueryButton__KeyBinding"})([`
2
+ color: `,`;
3
+ `],({theme:a})=>a.color.pinkPrimary),Qn=`${qt}+E`,On=i(ue).withConfig({displayName:"ExplainQueryButton__ExplainButton"})([`
4
+ gap: 1rem;
5
+ `]),Kn=({conversationId:a,queryText:n})=>{const{quest:o}=e.useContext(ft),c=Ee(je.query.getTables),{setStatus:u,abortController:g,hasSchemaAccess:y,currentModel:H,apiKey:A,aiAssistantSettings:_}=Te(),{addMessage:C,updateMessage:k,updateConversationName:b,persistMessages:p,setIsStreaming:N}=Fa(),l=()=>{_e(He.AI_EXPLAIN_QUERY),Ze(Dt({conversationId:a,queryText:n,settings:{model:H,apiKey:A},aiAssistantSettings:_,questClient:o,tables:c,hasSchemaAccess:y,abortSignal:g==null?void 0:g.signal}),{addMessage:C,updateMessage:k,setStatus:u,setIsStreaming:N,persistMessages:p,updateConversationName:b})};return t.jsxs(On,{skin:"gradient",gradientWeight:"thin",onClick:l,title:`Explain query with AI Assistant (${Qn})`,"data-hook":"button-explain-query",children:[t.jsx(it,{size:12,variant:"hollow"}),"Explain query",t.jsxs(Wn,{children:[t.jsx(Lt,{keyString:qt,color:r("pinkPrimary"),hoverColor:r("pinkPrimary")}),t.jsx(Lt,{keyString:"E",color:r("pinkPrimary"),hoverColor:r("pinkPrimary")})]})]})},oa=(a,n,o,c)=>{if(!(o!=null&&o.current)||!c.current)return null;const u=c.current.getModel();if(!u)return null;const g=o.current[n.toString()];if(!g)return null;const y=g[a];if(!y||!y.error)return null;const H=y.selection?y.selection.startOffset:y.startOffset,A=y.selection?y.selection.endOffset:y.endOffset,_=u.getPositionAt(H),C=u.getPositionAt(H+y.error.position),k=u.getWordAtPosition(C),b=u.getPositionAt(A),p=y.selection?u.getValueInRange({startLineNumber:_.lineNumber,startColumn:_.column,endLineNumber:b.lineNumber,endColumn:b.column}):Ra(a).queryText;return{errorMessage:y.error.error||"Query execution failed",word:k?k.word:null,fixStart:H,fixEnd:A,queryText:p}},Pn=i(ue).withConfig({displayName:"FixQueryButton__FixButton"})([`
6
+ gap: 1rem;
7
+ `]),Un=()=>{const{quest:a}=e.useContext(ft),{editorRef:n,executionRefs:o}=yt(),c=Ee(je.query.getTables),{setStatus:u,abortController:g,hasSchemaAccess:y,currentModel:H,apiKey:A,aiAssistantSettings:_}=Te(),{chatWindowState:C,getConversationMeta:k,addMessage:b,updateMessage:p,updateConversationName:N,persistMessages:l,setIsStreaming:v}=xt(),R=()=>{_e(He.AI_FIX_QUERY);const d=C.activeConversationId,x=k(d),h=oa(x.queryKey,x.bufferId,o,n),{errorMessage:T,queryText:X,word:F}=h;Ze(Tt({conversationId:d,queryText:X,errorMessage:T,errorWord:F??void 0,settings:{model:H,apiKey:A},aiAssistantSettings:_,questClient:a,tables:c,hasSchemaAccess:y,abortSignal:g==null?void 0:g.signal}),{addMessage:b,updateMessage:p,setStatus:u,setIsStreaming:v,persistMessages:l,updateConversationName:N})};return t.jsxs(Pn,{skin:"gradient",gradientWeight:"thin",onClick:R,title:"Fix query with AI Assistant","data-hook":"button-fix-query",children:[t.jsx(it,{size:12,variant:"hollow"}),"Fix query"]})},kt=a=>{if(!a||typeof a!="string")return`
8
+ `;let n=a.trim();return n.endsWith(";")&&(n=n.slice(0,-1).trim()),n+`
9
+ `},la=i.div.withConfig({displayName:"AssistantModesCompact__Container"})([`
10
+ display: flex;
11
+ flex-direction: column;
12
+ gap: 0.4rem;
13
+ align-items: flex-start;
14
+ width: 100%;
15
+ overflow-y: auto;
16
+ overflow-x: hidden;
17
+ min-height: 0;
18
+ `]),da=i.div.withConfig({displayName:"AssistantModesCompact__ModeHeader"})([`
19
+ display: flex;
20
+ flex-shrink: 0;
21
+ width: 100%;
22
+
23
+ `,`
24
+ `,`
25
+ gap: 0.8rem;
26
+ `],({$expanded:a})=>a?re([`
27
+ flex-direction: column;
28
+ align-items: flex-start;
29
+ `]):re([`
30
+ align-items: center;
31
+ justify-content: space-between;
32
+ padding: 0.4rem;
33
+ `]),({$abort:a})=>a&&re([`
34
+ opacity: 0.7;
35
+ `])),Mt=i.div.withConfig({displayName:"AssistantModesCompact__ModeChevron"})([`
36
+ width: 1.4rem;
37
+ height: 1.4rem;
38
+ flex-shrink: 0;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ color: `,`;
43
+ cursor: pointer;
44
+ transition:
45
+ color 0.2s,
46
+ transform 0.2s;
47
+ transform: rotate(`,`);
48
+ `],r("gray2"),({$expanded:a})=>a?"90deg":"0deg"),jt=i.div.withConfig({displayName:"AssistantModesCompact__ModeTitle"})([`
49
+ font-weight: 500;
50
+ font-size: 1.4rem;
51
+ color: `,`;
52
+ text-align: center;
53
+ margin-right: auto;
54
+ transition: color 0.2s;
55
+ flex-shrink: 0;
56
+
57
+ `,`
58
+ `,`
59
+ `],r("gray2"),({$isActive:a})=>a&&Bt,({$isTopLevel:a})=>a&&re([`
60
+ color: `,`;
61
+ `],r("foreground"))),ca=i.div.withConfig({displayName:"AssistantModesCompact__ModeHeaderTop"})([`
62
+ display: flex;
63
+ gap: 0.8rem;
64
+ align-items: center;
65
+ flex-shrink: 0;
66
+ `,`
67
+ `,`
68
+ `,`
69
+ `],({$expanded:a})=>a&&re([`
70
+ padding: 0.4rem;
71
+ `]),({$expanded:a})=>!a&&re([`
72
+ min-height: 0;
73
+ min-width: 0;
74
+ `]),({$isExpandable:a})=>a&&re([`
75
+ cursor: pointer;
76
+ user-select: none;
77
+ &:hover `,", &:hover ",` {
78
+ color: `,`;
79
+ }
80
+ `],jt,Mt,r("foreground"))),_t=i.div.withConfig({displayName:"AssistantModesCompact__ExpandableWrapper"})([`
81
+ display: grid;
82
+ grid-template-rows: `,`;
83
+ transition:
84
+ grid-template-rows 0.1s ease-out,
85
+ opacity 0.3s ease-out;
86
+ width: 100%;
87
+
88
+ `,`
89
+ `],({$expanded:a})=>a?"1fr":"0fr",({$expanded:a})=>!a&&re([`
90
+ height: 0;
91
+ opacity: 0;
92
+ `])),Ht=i.div.withConfig({displayName:"AssistantModesCompact__ExpandableContent"})([`
93
+ min-height: 0;
94
+ overflow: hidden;
95
+ `]),Gn=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningThread"})([`
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 0.8rem;
99
+ align-items: flex-start;
100
+ padding: 0 2.8rem;
101
+ `]),lt=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningItem"})([`
102
+ display: flex;
103
+ gap: 0.5rem;
104
+ align-items: center;
105
+ padding: 0.4rem;
106
+ padding-left: 0;
107
+ `]),et=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningIcon"})([`
108
+ width: 1.4rem;
109
+ height: 1.4rem;
110
+ flex-shrink: 0;
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ color: `,`;
115
+ `],r("foreground")),dt=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningText"})([`
116
+ display: flex;
117
+ flex-wrap: wrap;
118
+ gap: 0.4rem;
119
+ align-items: center;
120
+ min-height: 0;
121
+ min-width: 0;
122
+ `]),ie=i.span.withConfig({displayName:"AssistantModesCompact__ReasoningTextPart"})([`
123
+ font-weight: 400;
124
+ font-size: 1.4rem;
125
+ color: `,`;
126
+ `],r("gray2")),Se=i.div.withConfig({displayName:"AssistantModesCompact__CodeBadge"})([`
127
+ background: `,`;
128
+ border: 1px solid `,`;
129
+ border-radius: 0.4rem;
130
+ padding: 0 0.4rem;
131
+ display: flex;
132
+ align-items: center;
133
+ justify-content: center;
134
+ transform: translateY(1px);
135
+ `],r("background"),r("selection")),qe=i.span.withConfig({displayName:"AssistantModesCompact__CodeBadgeText"})([`
136
+ font-family: `,`;
137
+ font-size: 1.2rem;
138
+ color: `,`;
139
+ `],({theme:a})=>a.fontMonospace,r("purple")),ha=i(Oa).withConfig({displayName:"AssistantModesCompact__CheckIcon"})([`
140
+ width: 1.6rem;
141
+ height: 1.6rem;
142
+ color: `,`;
143
+ flex-shrink: 0;
144
+ `],r("pink")),Xn=i($t).withConfig({displayName:"AssistantModesCompact__CloseCircleIcon"})([`
145
+ color: `,`;
146
+ flex-shrink: 0;
147
+ `],r("red")),Yn=i.div.withConfig({displayName:"AssistantModesCompact__CollapsedSectionsWrapper"})([`
148
+ display: flex;
149
+ flex-direction: column;
150
+ gap: 0.8rem;
151
+ padding-left: 2.8rem;
152
+ `]),Jn=i.span.withConfig({displayName:"AssistantModesCompact__DurationText"})([`
153
+ font-size: 1.2rem;
154
+ color: `,`;
155
+ font-family: `,`;
156
+ font-weight: 400;
157
+ flex-shrink: 0;
158
+ transform: translateY(1px);
159
+ `],r("graphLegend"),({theme:a})=>a.fontMonospace),e0=(a,n)=>{if(a===be.Processing&&n&&"type"in n)switch(n.type){case"fix":return"Processing fix request";case"explain":return"Processing explain request";default:return a}return a},t0=i.div.withConfig({displayName:"AssistantModesCompact__ThinkingContent"})([`
160
+ font-size: 1.3rem;
161
+ color: `,`;
162
+ padding: 0 2.8rem;
163
+ white-space: pre-wrap;
164
+ word-break: break-word;
165
+ opacity: 0.7;
166
+ `],r("gray2")),ma=({operationHistory:a,status:n,isLive:o=!1,onScrollNeeded:c,collapsed:u=!1,endTimestamp:g})=>{const y=vt(),[H,A]=e.useState({}),[_,C]=e.useState(!1),k=e.useRef(0),b=e.useRef(null),p=e.useMemo(()=>za(a,n,o),[a,n,o]),N=e.useRef(o);e.useEffect(()=>{if(N.current&&!o){const d={};p.forEach(x=>{d[x.id]=!0}),A(d)}else if(o&&p.length>k.current){const d={};p.forEach((x,h)=>{h<p.length-1&&(d[x.id]=!0)}),A(d),c==null||c()}k.current=p.length,N.current=o},[p,o,c]);const l=d=>{A(x=>{const h=p.find(I=>I.id===d),T=h?Ft(h):!1,X=p.findIndex(I=>I.id===d)===p.length-1,F=u?!1:o?X:!0;return x[d]===void 0?{...x,[d]:F&&T}:{...x,[d]:!x[d]}})},v=e.useMemo(()=>{var h,T;if(a.length===0)return null;const d=(h=a[0])==null?void 0:h.timestamp,x=g??((T=a[a.length-1])==null?void 0:T.timestamp);return!d||!x||d===x?null:$a(x-d)},[a,g]);if(a.length===0)return null;const R=p.map((d,x)=>{var L;const h=Ft(d),T=x===p.length-1,X=u?!1:o?T:!0,F=H[d.id]===void 0?X&&h:!H[d.id]&&h,I=p[x+1],V=Ba(d,I,I?void 0:g),z=d.type===be.Thinking||d.type===be.RunningQuery,Z=z?((L=d.operations[0])==null?void 0:L.content)??"":"";return t.jsxs(da,{$expanded:F,$abort:d.abort,children:[t.jsxs(ca,{$expanded:F,$isExpandable:h,"data-hook":`assistant-mode-${d.type.toLowerCase().replace(/\s+/g,"-")}`,role:h?"button":"presentation",tabIndex:h?0:void 0,"aria-expanded":h?F:void 0,onClick:h?()=>l(d.id):void 0,onKeyDown:h?j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),l(d.id))}:void 0,children:[t.jsx(et,{children:d.active?t.jsx(wt,{size:14}):d.abort?t.jsx(Xn,{size:14}):t.jsx(ha,{})}),t.jsxs(q,{gap:"0.3rem",children:[t.jsx(jt,{$isActive:d.active,children:d.type}),V&&t.jsxs(Jn,{children:["(",V,")"]}),h&&t.jsx(Mt,{$expanded:F,children:t.jsx(Rt,{size:14})})]})]}),h&&z&&t.jsx(_t,{$expanded:F,children:t.jsx(Ht,{children:Z?t.jsx(t0,{children:Z}):null})}),h&&!z&&t.jsx(_t,{$expanded:F,children:t.jsx(Ht,{children:t.jsx(Gn,{children:d.operations.map((j,Ie)=>{const ee=`${d.id}-${Ie}-${JSON.stringify(j.args)}`;if(j.type===be.Processing){const K=e0(j.type,j.args);return t.jsxs(lt,{children:[t.jsx(et,{children:t.jsx(Wa,{style:{width:"14px",height:"14px"}})}),t.jsx(dt,{children:t.jsx(ie,{children:K})})]},ee)}if(j.type===be.InvestigatingTable){const K=j.args&&"name"in j.args?j.args.name:"table",Y=j.args&&"tableOpType"in j.args?j.args.tableOpType:"details";return t.jsxs(lt,{children:[t.jsx(et,{children:t.jsx(Qa,{size:14,color:y.color.gray2})}),t.jsxs(dt,{children:[t.jsx(ie,{children:"Investigating"}),t.jsx(Se,{children:t.jsx(qe,{children:K})}),t.jsx(ie,{children:Y})]})]},ee)}if(j.type===be.InvestigatingDocs){const K=j.args&&"items"in j.args&&Array.isArray(j.args.items)?j.args.items:null;if(K&&K.length>0)return t.jsx(ot.Fragment,{children:K.map((pe,ke)=>{const J=`${ee}-item-${ke}`;return t.jsxs(lt,{children:[t.jsx(et,{children:t.jsx(zt,{size:14,color:y.color.gray2})}),t.jsx(dt,{children:pe.section?t.jsxs(t.Fragment,{children:[t.jsx(ie,{children:"Investigating"}),t.jsx(Se,{children:t.jsx(qe,{children:pe.section})}),t.jsx(ie,{children:"in"}),t.jsx(Se,{children:t.jsx(qe,{children:pe.name})})]}):t.jsxs(t.Fragment,{children:[t.jsx(ie,{children:"Investigating"}),t.jsx(Se,{children:t.jsx(qe,{children:pe.name})})]})})]},J)})},ee);const Y=j.args&&"name"in j.args?j.args.name:null,ve=j.args&&"section"in j.args?j.args.section:null;return t.jsxs(lt,{children:[t.jsx(et,{children:t.jsx(zt,{size:14})}),t.jsx(dt,{children:Y&&ve?t.jsxs(t.Fragment,{children:[t.jsx(ie,{children:"Investigating"}),t.jsx(Se,{children:t.jsx(qe,{children:ve})}),t.jsx(ie,{children:"in"}),t.jsx(Se,{children:t.jsx(qe,{children:Y})}),t.jsx(ie,{children:"documentation"})]}):Y?t.jsxs(t.Fragment,{children:[t.jsx(ie,{children:"Investigating"}),t.jsx(Se,{children:t.jsx(qe,{children:Y})}),t.jsx(ie,{children:"documentation"})]}):t.jsx(ie,{children:"Investigating documentation"})})]},ee)}return null})})})})]},d.id)});return u?t.jsx(la,{ref:b,"data-hook":"assistant-modes-container",children:t.jsxs(da,{$expanded:_,$abort:!1,children:[t.jsxs(ca,{$expanded:_,$isExpandable:!0,onClick:()=>C(d=>!d),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),C(x=>!x))},"data-hook":"assistant-mode-processing-collapsed",role:"button",tabIndex:0,"aria-expanded":_,children:[t.jsx(ha,{}),t.jsx(jt,{$isActive:!1,children:v?`Thought for ${v}`:"Thought"}),t.jsx(Mt,{$expanded:_,children:t.jsx(Rt,{size:14})})]}),t.jsx(_t,{$expanded:_,children:t.jsx(Ht,{children:t.jsx(Yn,{children:R})})})]})}):t.jsx(la,{ref:b,"data-hook":"assistant-modes-container",children:R})},a0=i.div.withConfig({displayName:"AssistantMarkdown__CodeBlockWrapper"})([`
167
+ margin: 1rem 0;
168
+ width: 100%;
169
+ `]),n0=i.div.withConfig({displayName:"AssistantMarkdown__MarkdownContent"})([`
170
+ margin: 0;
171
+ width: 100%;
172
+ font-family: `,`;
173
+ font-size: 1.4rem;
174
+ line-height: 2.1rem;
175
+ color: `,`;
176
+ word-break: break-word;
177
+
178
+ p {
179
+ margin: 0 0 1rem 0;
180
+ &:last-child {
181
+ margin-bottom: 0;
182
+ }
183
+ }
184
+
185
+ code {
186
+ background: `,`;
187
+ border: 1px solid `,`;
188
+ border-radius: 0.4rem;
189
+ padding: 0.1rem 0.4rem;
190
+ font-family: `,`;
191
+ font-size: 1.3rem;
192
+ color: `,`;
193
+ white-space: pre-wrap;
194
+ }
195
+
196
+ strong {
197
+ font-weight: 600;
198
+ color: `,`;
199
+ }
200
+
201
+ em {
202
+ font-style: italic;
203
+ }
204
+
205
+ ul,
206
+ ol {
207
+ margin: 0.5rem 0;
208
+ padding-left: 2rem;
209
+ }
210
+
211
+ li {
212
+ margin-bottom: 0.3rem;
213
+ }
214
+
215
+ a {
216
+ color: `,`;
217
+ text-decoration: none;
218
+ &:hover {
219
+ text-decoration: underline;
220
+ }
221
+ }
222
+
223
+ h1,
224
+ h2,
225
+ h3,
226
+ h4 {
227
+ margin: 1rem 0 0.5rem 0;
228
+ font-weight: 600;
229
+ }
230
+
231
+ h1 {
232
+ font-size: 1.8rem;
233
+ }
234
+ h2 {
235
+ font-size: 1.6rem;
236
+ }
237
+ h3 {
238
+ font-size: 1.5rem;
239
+ }
240
+ h4 {
241
+ font-size: 1.4rem;
242
+ }
243
+
244
+ blockquote {
245
+ border-left: 3px solid `,`;
246
+ margin: 1rem 0;
247
+ padding-left: 1rem;
248
+ color: `,`;
249
+ }
250
+
251
+ .table-wrapper {
252
+ overflow-x: auto;
253
+ margin: 1rem 0;
254
+ }
255
+
256
+ table {
257
+ border-collapse: collapse;
258
+ min-width: max-content;
259
+ border-radius: 0.8rem;
260
+ }
261
+
262
+ th,
263
+ td {
264
+ padding: 0.6rem 0.8rem;
265
+ border: 1px solid `,`;
266
+ text-align: left;
267
+ white-space: nowrap;
268
+ }
269
+
270
+ th {
271
+ background: `,`;
272
+ font-weight: 600;
273
+ }
274
+
275
+ td:last-child {
276
+ white-space: normal;
277
+ min-width: 200px;
278
+ }
279
+ `],({theme:a})=>a.font,r("foreground"),r("background"),r("selection"),({theme:a})=>a.fontMonospace,r("purple"),r("foreground"),({theme:a})=>a.color.cyan,r("selection"),r("gray2"),r("selection"),r("backgroundDarker")),r0=a=>({table:({children:n,...o})=>t.jsx("div",{className:"table-wrapper",children:t.jsx("table",{...o,children:n})}),pre:({children:n})=>t.jsx(t.Fragment,{children:n}),code:e.memo(({children:n,className:o})=>{if(typeof o=="string"&&o.includes("language-")){const c=(Array.isArray(n)?n.join(""):typeof n=="string"?n:"").replace(/\n$/,"");return t.jsx(a0,{"data-hook":"chat-message-code-block",children:t.jsx(Pe,{value:c,maxHeight:216,onOpenInEditor:()=>{var u;(u=a.current)==null||u.call(a,{type:"code",value:c})}})})}return t.jsx("code",{children:n})},(n,o)=>n.children===o.children&&n.className===o.className)}),ua=e.memo(({content:a,messageId:n,onOpenInEditor:o})=>{const c=e.useRef(o);e.useEffect(()=>{c.current=o},[o]);const u=e.useMemo(()=>r0(c),[]);return t.jsx(n0,{children:t.jsx(Ka,{allowImages:!0,components:u,children:a})},n)},(a,n)=>a.content===n.content);function ga(a){return a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toString()}const pa=i.div.withConfig({displayName:"AssistantMessageContent__Divider"})([`
280
+ width: 100%;
281
+ height: 1px;
282
+ background: linear-gradient(
283
+ 90deg,
284
+ `,` 0%,
285
+ rgba(54, 14, 26, 0) 100%
286
+ );
287
+ margin-bottom: 1rem;
288
+ `],r("dividerAccent")),fa=i.div.withConfig({displayName:"AssistantMessageContent__OperationHistoryContainer"})([`
289
+ width: 100%;
290
+ `]),i0=i(q).attrs({alignItems:"center",gap:"1rem"}).withConfig({displayName:"AssistantMessageContent__AssistantHeader"})([`
291
+ width: 100%;
292
+ padding: 1.2rem 0.4rem;
293
+ flex: 1 0 auto;
294
+ `]),s0=i(de).attrs({className:"assistant-label"}).withConfig({displayName:"AssistantMessageContent__AssistantLabel"})([`
295
+ font-size: 1.4rem;
296
+ color: `,`;
297
+ `],r("foreground")),o0=i(q).attrs({className:"token-display"}).withConfig({displayName:"AssistantMessageContent__TokenDisplay"})([`
298
+ align-items: center;
299
+ gap: 0.9rem;
300
+ margin: 0 0 0 auto;
301
+ `]),ya=i(q).withConfig({displayName:"AssistantMessageContent__ExplanationContent"})([`
302
+ display: flex;
303
+ flex-direction: column;
304
+ border-radius: 0.6rem;
305
+ padding: 0 0.8rem;
306
+ flex-shrink: 0;
307
+ width: 100%;
308
+ `]),l0=Vn([`
309
+ 0%, 50% { opacity: 1; }
310
+ 51%, 100% { opacity: 0; }
311
+ `]),xa=i.span.withConfig({displayName:"AssistantMessageContent__StreamingCursor"})([`
312
+ display: inline-block;
313
+ width: 2px;
314
+ height: 1.4em;
315
+ background: `,`;
316
+ margin-left: 2px;
317
+ margin-right: auto;
318
+ vertical-align: text-bottom;
319
+ animation: `,` 1s infinite;
320
+ `],r("foreground"),l0),d0=e.memo(({turnMessages:a,anchorMessage:n,status:o,isLiveOperation:c,isMessageStreaming:u,onScrollNeeded:g,onOpenInEditor:y})=>{const H=vt(),{operationHistory:A,endTimestamp:_,timeline:C}=e.useMemo(()=>{const l=n.operationHistory??[],v=l.filter(x=>x.type!==be.Aborted),R=l.length>0?Math.max(...l.map(x=>x.timestamp)):void 0,d=v.some(x=>{var h;return x.type===be.GeneratingResponse&&!!((h=x.content)!=null&&h.trim())});return{operationHistory:v.filter(x=>x.type!==be.GeneratingResponse),endTimestamp:R,timeline:d?Pa(v):null}},[n.operationHistory]),k=e.useMemo(()=>a.filter(l=>l.role==="assistant"&&typeof l.content=="string"&&!!l.content).map(l=>l.content).join(`
321
+
322
+ `),[a]),b=!!k,p=e.useMemo(()=>{const l=n.tokenUsage;return!l||typeof l.inputTokens!="number"||typeof l.outputTokens!="number"?null:t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontWeight:600},children:ga(l.inputTokens)})," ","input /"," ",t.jsx("span",{style:{fontWeight:600},children:ga(l.outputTokens)})," ","output tokens"]})},[n.tokenUsage]),N=t.jsxs(i0,{"data-hook":"assistant-header",children:[t.jsx(it,{size:20,variant:"filled"}),t.jsx(s0,{children:n.model||"Assistant"}),p&&t.jsxs(o0,{className:"token-display",children:[t.jsx(na,{size:"16px",color:H.color.gray2}),t.jsx(de,{size:"sm",color:"gray2",children:p})]})]});if(C&&C.length>0){let l=!1;return t.jsxs(t.Fragment,{children:[C.map((v,R)=>{const d=R===C.length-1;if(v.type==="operations")return t.jsxs(ot.Fragment,{children:[R===0&&t.jsx(pa,{}),t.jsx(fa,{children:t.jsx(ma,{operationHistory:v.operations,status:o,isLive:c&&d,onScrollNeeded:g,collapsed:!d,endTimestamp:v.endTimestamp})})]},`ops-${v.timestamp}`);const x=!l;return l=!0,t.jsxs(ot.Fragment,{children:[x&&N,t.jsx(ya,{children:t.jsx(ua,{content:v.content,messageId:n.id,onOpenInEditor:y})})]},`content-${v.timestamp}`)}),u&&t.jsx(xa,{"data-hook":"streaming-cursor"})]})}return t.jsxs(t.Fragment,{children:[A.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(pa,{}),t.jsx(fa,{children:t.jsx(ma,{operationHistory:A,status:o,isLive:c,onScrollNeeded:g,collapsed:b||!!n.error,endTimestamp:_})})]}),b&&t.jsxs(t.Fragment,{children:[N,t.jsxs(ya,{children:[t.jsx(ua,{content:k,messageId:n.id,onOpenInEditor:y}),u&&t.jsx(xa,{"data-hook":"streaming-cursor"})]})]})]})},(a,n)=>{const o=a.turnMessages[a.turnMessages.length-1],c=n.turnMessages[n.turnMessages.length-1];return o===c&&a.anchorMessage===n.anchorMessage&&a.status===n.status&&a.isLiveOperation===n.isLiveOperation&&a.isMessageStreaming===n.isMessageStreaming}),c0=i(q).withConfig({displayName:"ChatMessages__MessagesContainer"})([`
323
+ display: flex;
324
+ flex-direction: column;
325
+ gap: 1.5rem;
326
+ padding: 2rem 1rem;
327
+ overflow-y: auto;
328
+ flex: 1 1 auto;
329
+ min-height: 0;
330
+ width: 100%;
331
+ `,`
332
+ `],({$scrolled:a})=>!a&&re([`
333
+ opacity: 0;
334
+ `])),h0=i(q).attrs({align:"flex-start"}).withConfig({displayName:"ChatMessages__MessageBubble"})([`
335
+ display: flex;
336
+ flex-direction: column;
337
+ gap: 0.5rem;
338
+ padding: 0.8rem;
339
+ border-radius: 0.8rem;
340
+ width: 100%;
341
+ align-self: flex-end;
342
+ background: `,`;
343
+ border: 1px solid `,`;
344
+ flex-shrink: 0;
345
+ `],r("loginBackground"),r("black32")),wa=i(q).withConfig({displayName:"ChatMessages__UserRequestBox"})([`
346
+ display: flex;
347
+ flex-direction: column;
348
+ gap: 0.5rem;
349
+ padding: 0.8rem;
350
+ width: 100%;
351
+ align-self: flex-end;
352
+ background: `,`;
353
+ border: 1px solid `,`;
354
+ border-radius: 0.6rem;
355
+ flex-shrink: 0;
356
+ `],r("loginBackground"),r("black32")),m0=i(q).attrs({alignItems:"center",gap:"0.8rem"}).withConfig({displayName:"ChatMessages__UserRequestHeader"})([`
357
+ width: 100%;
358
+ padding: 0.4rem;
359
+ flex: 1 0 auto;
360
+ `]),ct=i(q).withConfig({displayName:"ChatMessages__UserRequestContent"})([`
361
+ display: flex;
362
+ flex-direction: column;
363
+ border-radius: 0.6rem;
364
+ overflow: hidden;
365
+ flex-shrink: 0;
366
+ width: 100%;
367
+ align-items: flex-start;
368
+ `]),Ca=i.div.withConfig({displayName:"ChatMessages__InlineSQLEditor"})([`
369
+ width: 100%;
370
+ `]),u0=i(q).attrs({gap:"1rem",alignItems:"center"}).withConfig({displayName:"ChatMessages__OperationBadge"})([`
371
+ width: 100%;
372
+ padding: 0 0.4rem;
373
+ `]),g0=i(q).attrs({align:"center",justifyContent:"center"}).withConfig({displayName:"ChatMessages__BadgeIconContainer"})([`
374
+ background: `,`;
375
+ border: 1px solid `,`;
376
+ border-radius: 0.4rem;
377
+ padding: 0.8rem;
378
+ width: 4.8rem;
379
+ height: 4rem;
380
+ flex-shrink: 0;
381
+ `],r("aiBadgeIconBg"),r("aiBadgeIconBorder")),p0=i.div.withConfig({displayName:"ChatMessages__BadgeIconWrapper"})([`
382
+ width: 2.4rem;
383
+ height: 2.4rem;
384
+ display: flex;
385
+ align-items: center;
386
+ justify-content: center;
387
+ color: `,`;
388
+
389
+ svg {
390
+ width: 100%;
391
+ height: 100%;
392
+ }
393
+ `],({theme:a})=>a.color.pink),f0=i(de).withConfig({displayName:"ChatMessages__BadgeTitle"})([`
394
+ font-weight: 500;
395
+ font-size: 1.6rem;
396
+ line-height: 1.6rem;
397
+ color: `,`;
398
+ `],r("foreground")),y0=i(q).withConfig({displayName:"ChatMessages__BadgeDescriptionContainer"})([`
399
+ align-items: flex-start;
400
+ flex-direction: column;
401
+ padding: 0.8rem;
402
+ width: 100%;
403
+ `]),x0=i(de).withConfig({displayName:"ChatMessages__BadgeDescriptionText"})([`
404
+ font-size: 1.4rem;
405
+ line-height: 2.1rem;
406
+ color: `,`;
407
+ `],r("foreground")),w0=i(de).withConfig({displayName:"ChatMessages__BadgeDescriptionIssueText"})([`
408
+ font-size: 1.4rem;
409
+ line-height: 2.1rem;
410
+ font-weight: 600;
411
+ `]),C0=i(q).withConfig({displayName:"ChatMessages__IssueMessageRow"})([`
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 0.5rem;
415
+ `]),ba=i(ue).withConfig({displayName:"ChatMessages__SchemaNameDisplay"})([`
416
+ margin-left: 0.4rem;
417
+ padding: 0.5rem 1rem;
418
+ align-items: center;
419
+ gap: 1rem;
420
+ border-radius: 0.6rem;
421
+ border: 1px solid `,`;
422
+ background: `,`;
423
+
424
+ &:hover,
425
+ &:active {
426
+ background: `,` !important;
427
+ border-color: `,` !important;
428
+ }
429
+ `],r("selection"),r("backgroundDarker"),r("backgroundLighter"),r("cyan")),Aa=i(de).withConfig({displayName:"ChatMessages__SchemaName"})([`
430
+ font-size: 1.4rem;
431
+ color: `,`;
432
+ `],r("foreground")),va=i(de).withConfig({displayName:"ChatMessages__MessageContent"})([`
433
+ font-size: 1.4rem;
434
+ line-height: 1.8rem;
435
+ color: `,`;
436
+ white-space: pre-wrap;
437
+ word-wrap: break-word;
438
+ `],r("foreground")),b0=i(q).withConfig({displayName:"ChatMessages__ExplanationBox"})([`
439
+ display: flex;
440
+ flex-direction: column;
441
+ gap: 0.8rem;
442
+ width: 100%;
443
+ align-self: flex-start;
444
+ text-align: left;
445
+ background: transparent;
446
+ padding: 0.4rem;
447
+ border-radius: 0.6rem;
448
+ flex-shrink: 0;
449
+
450
+ `,`
451
+
452
+ .assistant-label,
453
+ .token-display {
454
+ transition: opacity 0.2s;
455
+ opacity: 0;
456
+ }
457
+
458
+ &:hover,
459
+ &:focus-within {
460
+ .assistant-label,
461
+ .token-display {
462
+ opacity: 1;
463
+ }
464
+ }
465
+ `],({$hasOperationHistory:a})=>a&&re([`
466
+ padding-top: 0;
467
+ `])),A0=i.div.withConfig({displayName:"ChatMessages__ErrorContainer"})([`
468
+ display: flex;
469
+ align-items: center;
470
+ flex-shrink: 0;
471
+ gap: 0.5rem;
472
+ padding: 0.4rem 0.4rem 0.4rem 0.8rem;
473
+ border: 1px solid `,`;
474
+ border-radius: 0.6rem;
475
+ color: `,`;
476
+ font-size: 1.4rem;
477
+ line-height: 2rem;
478
+ width: 100%;
479
+ `],r("red"),r("foreground")),v0=i(ue).withConfig({displayName:"ChatMessages__RetryButton"})([`
480
+ margin-left: auto;
481
+ flex-shrink: 0;
482
+ padding: 0.5rem 0.8rem;
483
+ height: auto;
484
+ `]),k0=i.div.withConfig({displayName:"ChatMessages__MessagesEnd"})([`
485
+ min-height: 1px;
486
+ width: 100%;
487
+ background: transparent;
488
+ `]),M0=i(q).withConfig({displayName:"ChatMessages__DiffContainer"})([`
489
+ display: flex;
490
+ flex-direction: column;
491
+ gap: 1rem;
492
+ margin-top: 1rem;
493
+ padding: 0.8rem 1.2rem;
494
+ border: 1px solid `,`;
495
+ border-radius: 0.8rem;
496
+ background: `,`;
497
+ width: 100%;
498
+ `],r("selection"),r("backgroundDarker")),j0=i(q).withConfig({displayName:"ChatMessages__DiffHeader"})([`
499
+ display: flex;
500
+ align-items: center;
501
+ justify-content: space-between;
502
+ padding-bottom: 0.8rem;
503
+ border-bottom: 1px solid `,`;
504
+ width: 100%;
505
+ `,`
506
+ `],r("selectionDarker"),({$isExpanded:a})=>!a&&re([`
507
+ border-bottom: 0;
508
+ padding-bottom: 0;
509
+ `])),_0=i(q).withConfig({displayName:"ChatMessages__DiffHeaderLeft"})([`
510
+ display: flex;
511
+ align-items: center;
512
+ gap: 1rem;
513
+ padding: 0.4rem 0;
514
+ `]),H0=i.span.withConfig({displayName:"ChatMessages__DiffHeaderLabel"})([`
515
+ font-size: 1.4rem;
516
+ color: `,`;
517
+ `],r("offWhite")),E0=i(q).withConfig({displayName:"ChatMessages__DiffHeaderRight"})([`
518
+ display: flex;
519
+ align-items: center;
520
+ gap: 1.8rem;
521
+ margin-left: auto;
522
+ `]),ka=i(q).withConfig({displayName:"ChatMessages__DiffHeaderStatus"})([`
523
+ display: flex;
524
+ align-items: center;
525
+ gap: 0.8rem;
526
+ color: `,`;
527
+ font-size: 1.3rem;
528
+ `],({$isAccepted:a,$isRejected:n,$isRejectedWithFollowUp:o})=>n?r("red"):o?r("cyan"):a?r("greenDarker"):r("gray2")),Ma=i.span.withConfig({displayName:"ChatMessages__StatusIcon"})([`
529
+ display: flex;
530
+ align-items: center;
531
+ color: `,`;
532
+ `],({$isAccepted:a,$isRejected:n,$isRejectedWithFollowUp:o})=>n?r("red"):o?r("cyan"):a?r("greenDarker"):r("gray2")),Et=i.button.withConfig({displayName:"ChatMessages__IconButton"})([`
533
+ display: flex;
534
+ align-items: center;
535
+ justify-content: center;
536
+ padding: 0;
537
+ background: transparent;
538
+ border: none;
539
+ cursor: pointer;
540
+ height: 2.2rem;
541
+ width: 2.2rem;
542
+ color: `,`;
543
+
544
+ &:hover:not(:disabled) {
545
+ svg {
546
+ filter: brightness(1.3);
547
+ }
548
+ }
549
+
550
+ &:disabled {
551
+ opacity: 0.4;
552
+ cursor: not-allowed;
553
+ }
554
+ `],r("gray2")),I0=i(Et).withConfig({displayName:"ChatMessages__ExpandButton"})([`
555
+ width: 1.6rem;
556
+ height: 1.6rem;
557
+ `]),N0=i.div.withConfig({displayName:"ChatMessages__DiffEditorWrapper"})([`
558
+ position: relative;
559
+ width: 100%;
560
+ `]),V0=i(q).withConfig({displayName:"ChatMessages__ButtonBar"})([`
561
+ padding: 0.5rem;
562
+ gap: 1rem;
563
+ justify-content: center;
564
+ flex-shrink: 0;
565
+ width: fit-content;
566
+ margin: 0 auto;
567
+ background: `,`;
568
+ border: 1px solid `,`;
569
+ border-radius: 0.4rem;
570
+ `],r("backgroundDarker"),r("selection")),Z0=i(ue).withConfig({displayName:"ChatMessages__AcceptButton"})([`
571
+ background: `,`;
572
+ color: `,`;
573
+ border: 0.1rem solid `,`;
574
+ width: 10rem;
575
+
576
+ &:hover:not(:disabled) {
577
+ background: `,`;
578
+ border-color: `,`;
579
+ filter: brightness(1.2);
580
+ }
581
+ `],({theme:a})=>a.color.pinkDarker,r("foreground"),({theme:a})=>a.color.pinkDarker,({theme:a})=>a.color.pinkDarker,({theme:a})=>a.color.pinkDarker),S0=i(ue).withConfig({displayName:"ChatMessages__RejectButton"})([`
582
+ background: `,`;
583
+ color: `,`;
584
+ border: 1px solid transparent;
585
+ width: 10rem;
586
+
587
+ &:hover:not(:disabled) {
588
+ background: `,`;
589
+ border-color: transparent;
590
+ }
591
+ `],r("background"),r("foreground"),r("selection")),q0=a=>{switch(a){case"fix_request":return{icon:t.jsx(sn,{size:24}),title:"Fix Query",description:"Help me debug and fix the error with the attached SQL query"};case"explain_request":return{icon:t.jsx(rn,{size:24}),title:"Explain Query",description:"Explain this query in detail"};case"schema_explain_request":return{icon:t.jsx(nn,{size:24}),title:"Explain Schema",description:"Provide an overview, detailed column descriptions and storage details."};case"health_issue_request":return{icon:t.jsx(an,{size:24}),title:"Health Issue Analysis",description:"Analyze table health issue and provide steps for resolution:"};default:return null}},L0=(a,n)=>{switch(a){case"loading":return t.jsx(Ot,{size:24,color:n.color.red});case"success":return t.jsx(dn,{});case"error":return t.jsx(ln,{});default:return t.jsx(on,{})}},D0=({messages:a,onAcceptChange:n,onRejectChange:o,onRunQuery:c,onOpenInEditor:u,onApplyToEditor:g,onRetry:y,onCancelQuery:H,runningQueryKey:A,queryNotifications:_,isOperationInProgress:C,editorSQL:k,isStreaming:b,isLoadingMessages:p,scrollToMessageId:N,onScrollToMessageComplete:l})=>{const v=vt(),R=Ut(),d=Ee(je.query.getTables),x=e.useRef(null),h=e.useRef(null),T=e.useRef(new Map),{status:X}=Te(),[F,I]=e.useState(!1),V=e.useRef(!1),z=e.useCallback(()=>{if(F&&V.current||N)return;const E=F?"smooth":"instant";setTimeout(()=>{var m;(m=x.current)==null||m.scrollIntoView({behavior:E}),I(!0)})},[F,N]),Z=e.useCallback(E=>{const m=d.find(Q=>Q.table_name===E.tableName&&Wt(Q)===E.kind);m&&R(Ct.console.pushSidebarHistory({type:"tableDetails",payload:{tableName:m.table_name,isMatView:m.table_type==="M",isView:m.table_type==="V"}}))},[d]);e.useEffect(()=>{const E=h.current;if(!E)return;const m=()=>{V.current=!0};return E.addEventListener("wheel",m),()=>E.removeEventListener("wheel",m)},[]),e.useEffect(()=>{V.current=!1},[a.length]);const L=e.useMemo(()=>{for(let E=a.length-1;E>=0;E--){const m=a[E];if(m.role==="assistant"&&m.sql)return E}return-1},[a]),j=e.useRef(L>=0?L:-1),[Ie,ee]=e.useState(L>=0?new Set([L]):new Set);e.useEffect(()=>{L>=0&&L!==j.current&&(ee(E=>new Set([...E,L])),j.current=L)},[L]);const{visibleEntries:K,lastAssistantAnchorIndex:Y,lastVisibleUserIndex:ve}=e.useMemo(()=>Ua(a),[a]),pe=e.useMemo(()=>Ga(b,a),[b,a]);e.useEffect(()=>{z()},[pe,z]),e.useLayoutEffect(()=>{if(!N||p)return;const E=T.current.get(N);if(E){const m=setTimeout(()=>{E.scrollIntoView({behavior:"smooth",block:"start"}),I(!0),l()},100);return()=>clearTimeout(m)}},[N,p,l]),e.useEffect(()=>()=>{l()},[]);const ke=K[K.length-1],J=K.length>0?ke.type==="user"?ke.index:ke.anchorIndex:-1,ze=Y;return t.jsxs(c0,{ref:h,$scrolled:F,role:"log","data-hook":"chat-messages-container",children:[K.map(E=>{var tt,Ke,P;if(E.type==="user"){const{message:M}=E,U=`${M.id}`,fe=(tt=M.displayHealthIssueData)==null?void 0:tt.severity,at=Ae(M.sql||"")===Ae(k||""),ye=M.displayType,me=M.sql;if(ye&&ye!=="ask_request"){const W=q0(ye);let xe=null;if(ye==="schema_explain_request"&&M.displaySchemaData){const ae=M.displaySchemaData;xe=t.jsx(ct,{children:t.jsxs(ba,{onClick:()=>Z(ae),children:[t.jsx(bt,{kind:ae.kind,partitionBy:ae.partitionBy,walEnabled:ae.walEnabled,designatedTimestamp:ae.designatedTimestamp}),t.jsx(Aa,{children:ae.tableName})]})})}else if(ye==="health_issue_request"&&M.displayHealthIssueData){const ae=M.displayHealthIssueData;xe=t.jsx(ct,{children:t.jsxs(ba,{children:[t.jsx(bt,{kind:"table"}),t.jsx(Aa,{children:ae.tableName})]})})}else me&&(xe=t.jsx(ct,{children:t.jsx(Ca,{"data-hook":"user-request-sql-editor",children:t.jsx(Pe,{value:me,maxHeight:216,onOpenInEditor:()=>u({type:"code",value:me},at)})})}));return t.jsxs(wa,{"data-hook":"chat-message-user",ref:ae=>{ae&&T.current.set(M.id,ae)},children:[t.jsxs(u0,{children:[t.jsx(g0,{children:t.jsx(p0,{children:W==null?void 0:W.icon})}),t.jsx(f0,{children:W==null?void 0:W.title})]}),(W==null?void 0:W.description)&&t.jsxs(y0,{children:[t.jsx(x0,{children:W.description}),ye==="health_issue_request"&&((Ke=M.displayHealthIssueData)==null?void 0:Ke.issueMessage)&&t.jsxs(C0,{children:[fe==="critical"?t.jsx(Xa,{size:14,weight:"fill",color:v.color.red}):t.jsx(Ya,{size:14,weight:"fill",color:v.color.orange}),t.jsx(w0,{color:fe==="critical"?"red":"orange",children:M.displayHealthIssueData.issueMessage})]})]}),xe]},U)}if(ye==="ask_request"&&me){const W=M.displayUserMessage||M.content||"";return t.jsxs(wa,{"data-hook":"chat-message-user",ref:xe=>{xe&&T.current.set(M.id,xe)},children:[t.jsx(m0,{children:t.jsx(va,{children:W})}),t.jsx(ct,{children:t.jsx(Ca,{"data-hook":"user-request-sql-editor",children:t.jsx(Pe,{value:me,maxHeight:216,onOpenInEditor:()=>u({type:"code",value:me},at)})})})]},U)}return t.jsx(h0,{"data-hook":"chat-message-user",ref:W=>{W&&T.current.set(M.id,W)},children:t.jsx(va,{children:M.displayUserMessage||M.content})},U)}const{anchorMessage:m,anchorIndex:Q,turnMessages:$e}=E,Be=`${m.id}`,We=Ae(m.sql||"")===Ae(k||""),ce=!!m.sql,Ne=ce&&m.previousSQL!==void 0&&Ae(m.sql||"")===Ae(m.previousSQL||""),Le=Ie.has(Q),he=m.isAccepted===!0,s=m.isRejected===!0,te=ce&&!he&&!s&&Q<ve,Qe=Q===J,Me=b&&Qe,De=ce&&!Ne&&!he&&!s&&!te&&Qe;let $="neutral";if(m.sql){const M=Ae(m.sql),U=At(M);if(A&&U===A)$="loading";else if(_){const fe=(P=_[U])==null?void 0:P.latest;fe&&(fe.type===Fe.ERROR?$="error":(fe.type===Fe.SUCCESS||fe.type===Fe.INFO)&&($="success"))}}const B=kt(m.previousSQL),Oe=kt(m.sql),O=!!m.error,ht=O&&!b&&!C&&Qe,mt=Q===ze&&C===!0,se=!!m.operationHistory&&m.operationHistory.length>0;return t.jsxs(b0,{$hasOperationHistory:se,"data-hook":"chat-message-assistant",ref:M=>{M&&T.current.set(m.id,M)},children:[t.jsx(d0,{turnMessages:$e,anchorMessage:m,status:X,isLiveOperation:mt,isMessageStreaming:Me,onScrollNeeded:z,onOpenInEditor:u}),ce&&!Me&&t.jsxs(M0,{"data-hook":"inline-diff-container",children:[t.jsxs(j0,{$isExpanded:Le,children:[t.jsxs(_0,{children:[t.jsx(Ja,{size:22,color:v.color.offWhite}),t.jsx(H0,{children:"Suggested change"})]}),Ne&&t.jsxs(ka,{"data-hook":"diff-status-unchanged",children:[t.jsx(Ma,{children:t.jsx(Qt,{size:"14px"})}),"Already accepted"]}),!Ne&&(he||s||te)&&t.jsxs(ka,{$isAccepted:he,$isRejected:s,$isRejectedWithFollowUp:te,"data-hook":s?"diff-status-rejected":te?"diff-status-followed-up":"diff-status-accepted",children:[t.jsx(Ma,{$isAccepted:he,$isRejected:s,$isRejectedWithFollowUp:te,children:s?t.jsx(en,{size:"14px"}):te?t.jsx(Yt,{size:"14px"}):t.jsx(Qt,{size:"14px"})}),s?"Rejected":te?"Followed up":"Accepted"]}),t.jsxs(E0,{children:[t.jsx(Et,{onClick:M=>{M.stopPropagation(),$==="loading"&&m.sql?H==null||H(At(Ae(m.sql))):m.sql&&c&&c(m.sql)},title:$==="loading"?"Cancel query":"Run this query","aria-label":$==="loading"?"Cancel query":"Run this query","data-hook":"message-action-run-sql",children:L0($,v)}),!De&&g&&!(Q===L&&he)&&!We&&t.jsx(Et,{onClick:M=>{M.stopPropagation(),m.id&&m.sql&&!C&&(_e(He.AI_EDITOR_SUGGESTION_APPLY),g(m.id,m.sql))},title:"Apply to editor","aria-label":"Apply to editor",disabled:C,"data-hook":"message-action-apply",children:t.jsx(ra,{size:22,color:v.color.offWhite})}),t.jsx(I0,{title:"Expand diff view","aria-label":Le?"Collapse diff view":"Expand diff view","aria-expanded":Le,"data-hook":"diff-expand-button",onClick:()=>{ee(M=>{const U=new Set(M);return U.has(Q)?U.delete(Q):U.add(Q),U})},children:t.jsx(tn,{})})]})]}),Le&&t.jsxs(t.Fragment,{children:[t.jsx(N0,{children:t.jsx(Pe,{diffEditor:!0,original:B,modified:Oe,maxHeight:300,onOpenInEditor:()=>u({type:"diff",original:B??"",modified:Oe??""}),handleScrollNeeded:z})}),De&&t.jsxs(V0,{align:"center",justifyContent:"center",children:[o&&m.id&&t.jsx(S0,{onClick:()=>o(m.id),"data-hook":"message-action-reject",children:"Reject"}),n&&m.id&&t.jsx(Z0,{onClick:()=>n(m.id),"data-hook":"message-action-accept",children:"Accept"})]})]})]}),O&&t.jsxs(A0,{role:"alert","data-hook":"chat-message-error",children:[t.jsx($t,{size:16,color:v.color.red,style:{flexShrink:0}}),m.error,ht&&y&&t.jsx(v0,{size:"sm",skin:"secondary",prefixIcon:t.jsx(Gt,{size:12}),onClick:()=>{const M=a.slice(0,Q).findLastIndex(U=>U.role==="user");M>=0&&y(a[M].id)},"data-hook":"retry-button",children:"Retry"})]})]},Be)}),t.jsx(k0,{ref:x,"data-hook":"messages-end"})]})},T0=i(q).withConfig({displayName:"ChatInput__InputContainer"})([`
592
+ display: flex;
593
+ flex-direction: column;
594
+ align-items: stretch;
595
+ gap: 0.8rem;
596
+ padding: 1rem 1.2rem;
597
+ flex-shrink: 0;
598
+ width: 100%;
599
+ margin-top: auto;
600
+ border-top: 1px solid `,`;
601
+ `],r("selection")),F0=i(q).withConfig({displayName:"ChatInput__InputWrapper"})([`
602
+ display: flex;
603
+ position: relative;
604
+ width: 100%;
605
+ overflow: hidden;
606
+ `]),R0=i.textarea.withConfig({displayName:"ChatInput__StyledTextArea"})([`
607
+ flex: 1;
608
+ min-height: 8rem;
609
+ max-height: 30rem;
610
+ line-height: 1.3;
611
+ padding: `,`;
612
+ background: `,`;
613
+ border: 1px solid `,`;
614
+ border-radius: 0.6rem;
615
+ color: `,`;
616
+ font-size: 1.4rem;
617
+ font-family: `,`;
618
+ resize: none;
619
+ outline: none;
620
+
621
+ &:focus {
622
+ border-color: `,`;
623
+ }
624
+
625
+ &::placeholder {
626
+ color: `,`;
627
+ }
628
+
629
+ &:disabled {
630
+ opacity: 0.5;
631
+ }
632
+ `],({$hasContext:a})=>a?"4.4rem 4.5rem 1.2rem 1.2rem":"1.2rem 4.5rem 1.2rem 1.2rem",r("backgroundDarker"),r("selection"),r("foreground"),({theme:a})=>a.font,r("pinkDarker"),r("gray2")),z0=i.button.withConfig({displayName:"ChatInput__ActionButton"})([`
633
+ position: absolute;
634
+ right: 0.8rem;
635
+ bottom: 0.8rem;
636
+ padding: 0.6rem;
637
+ border: none;
638
+ display: flex;
639
+ align-items: center;
640
+ justify-content: center;
641
+ border-radius: 0.4rem;
642
+ cursor: pointer;
643
+ `]),$0=i.div.withConfig({displayName:"ChatInput__ContextBadgeContainer"})([`
644
+ position: absolute;
645
+ padding: 0.8rem;
646
+ top: 2px;
647
+ border-radius: 0.6rem;
648
+ left: 1px;
649
+ width: calc(100% - 0.2rem);
650
+ display: inline-flex;
651
+ background: `,`;
652
+ `],r("backgroundDarker")),B0=i.button.withConfig({displayName:"ChatInput__ContextBadge"})([`
653
+ display: flex;
654
+ padding: 0.3rem 0.6rem;
655
+ align-items: center;
656
+ gap: 0.4rem;
657
+ line-height: 1.4;
658
+ border-radius: 0.6rem;
659
+ border: 1px solid
660
+ `,`;
661
+ background: `,`;
662
+ color: `,`;
663
+ font-size: 1.3rem;
664
+ user-select: none;
665
+ cursor: `,`;
666
+ font-family: inherit;
667
+
668
+ &:hover {
669
+ border: 1px solid
670
+ `,`;
671
+ color: `,`;
672
+ }
673
+ `],({$warn:a,theme:n})=>a?n.color.red:n.color.selection,r("chatBackground"),({theme:a})=>a.color.gray2,({$warn:a})=>a?"default":"pointer",({$warn:a,theme:n})=>a?n.color.red:n.color.offWhite,({theme:a})=>a.color.offWhite),W0=i.div.withConfig({displayName:"ChatInput__ContextBadgeIcon"})([`
674
+ display: flex;
675
+ align-items: center;
676
+ color: `,`;
677
+ flex-shrink: 0;
678
+
679
+ svg {
680
+ color: `,`;
681
+ }
682
+ `],r("gray2"),({$warn:a,theme:n})=>a?n.color.red:r("gray2")),Q0=i(z0).withConfig({displayName:"ChatInput__SendButton"})([`
683
+ background: `,`;
684
+ color: `,`;
685
+
686
+ &:hover:not(:disabled) {
687
+ background: `,`;
688
+ }
689
+
690
+ &:disabled {
691
+ opacity: 0.5;
692
+ cursor: not-allowed;
693
+ }
694
+ `],r("pinkDarker"),r("foreground"),r("pink")),O0=i.div.withConfig({displayName:"ChatInput__ThoughtStream"})([`
695
+ display: flex;
696
+ position: relative;
697
+ width: 100%;
698
+ background: `,`;
699
+ border: 1px solid transparent;
700
+ background:
701
+ linear-gradient(`,", ",`)
702
+ padding-box,
703
+ `,` border-box;
704
+ border-radius: 0.6rem;
705
+ height: 4rem;
706
+ `],r("backgroundDarker"),r("backgroundDarker"),r("backgroundDarker"),mn),K0=i.div.withConfig({displayName:"ChatInput__ThoughtStreamContent"})([`
707
+ display: flex;
708
+ align-items: center;
709
+ background: `,`;
710
+ gap: 0.8rem;
711
+ width: 100%;
712
+ height: 100%;
713
+ border-radius: 0.6rem;
714
+ padding: 0 1.2rem;
715
+ padding-right: 4.5rem;
716
+ `],r("backgroundDarker")),P0=i.div.withConfig({displayName:"ChatInput__ThoughtText"})([`
717
+ font-weight: 500;
718
+ font-size: 1.4rem;
719
+ color: `,`;
720
+ `,`
721
+ `],r("gray2"),Bt),U0=i.div.withConfig({displayName:"ChatInput__StopButtonWrapper"})([`
722
+ position: absolute;
723
+ right: 0.8rem;
724
+ top: 50%;
725
+ transform: translateY(-50%);
726
+ `]),It=(a,n=30)=>{if(!a)return"";const o=a.trim().replace(/\s+/g," ");return o.length<=n?o:o.slice(0,n)+"..."},G0=e.forwardRef(({onSend:a,disabled:n=!1,placeholder:o="Ask a question or request a refinement...",contextSQL:c,contextTableId:u,contextNotebook:g,onContextClick:y},H)=>{const[A,_]=e.useState(""),C=e.useRef(null),k=Ee(je.query.getTables),b=e.useMemo(()=>u==null?null:k.find(I=>I.id===u)??null,[u,k]),p=g?It(g.label):b!=null&&b.table_name?It(b.table_name):c?It(c):null,N=!!p,l=g==null?void 0:g.warn,v=g?l==="archived"?"Notebook archived":l==="deleted"?"Notebook deleted":`Attached: ${g.label} \u2014 click to switch`:void 0;e.useImperativeHandle(H,()=>({focus:()=>{var I;(I=C.current)==null||I.focus()}}));const{status:R,abortOperation:d}=Te(),x=ge(R);e.useEffect(()=>{C.current&&(C.current.style.height="auto",C.current.style.height=`${C.current.scrollHeight}px`)},[A]);const h=()=>{const I=A.trim();I&&!n&&!x&&(a(I),_(""),C.current&&(C.current.style.height="auto"))},T=I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),h())},X=()=>{d()},F=x;return t.jsxs(T0,{children:[F?t.jsxs(O0,{"data-hook":"chat-assistant-modes",children:[t.jsxs(K0,{children:[t.jsx(wt,{size:20}),t.jsx(P0,{role:"status","aria-live":"polite",children:R})]}),t.jsx(U0,{children:t.jsx(cn,{size:"md",onClick:X,title:"Stop generation",ariaLabel:"Stop AI generation",dataHook:"chat-stop-button"})})]}):t.jsxs(F0,{children:[N&&t.jsx($0,{children:t.jsxs(B0,{type:"button",$warn:!!l,onClick:g?()=>void g.onClick():y,title:v,"aria-label":`Chat context: ${p}`,"data-hook":"chat-context-badge",children:[t.jsx(W0,{$warn:!!l,children:g?t.jsx(hn,{size:14,weight:"regular"}):b?t.jsx(bt,{kind:Wt(b),partitionBy:b.partitionBy,walEnabled:b.walEnabled,designatedTimestamp:b.designatedTimestamp}):t.jsx(aa,{size:14,weight:"regular"})}),l==="archived"?`Archived: ${p}`:l==="deleted"?`Deleted: ${p}`:p]})}),t.jsx(R0,{ref:C,value:A,onChange:I=>_(I.target.value),onKeyDown:T,placeholder:o,"aria-label":"Chat with AI assistant","aria-keyshortcuts":"Enter",disabled:n,rows:1,$hasContext:N,"data-hook":"chat-input-textarea"}),t.jsx(Q0,{onClick:h,disabled:!A.trim()||n,title:"Send (Enter) \u2022 New line (Shift+Enter)","aria-label":"Send message","data-hook":"chat-send-button",children:t.jsx(Xt,{size:20,weight:"bold"})})]}),t.jsx(de,{color:"gray2",size:"sm",align:"center",children:"Chats are connected to a single query to improve responses."})]})}),Nt=i.div.withConfig({displayName:"ChatHistoryItem__Container"})([`
727
+ display: flex;
728
+ align-items: center;
729
+ gap: 0.6rem;
730
+ padding: 0.4rem 0.8rem;
731
+ border-radius: 4px;
732
+ cursor: `,`;
733
+ background: `,`;
734
+ opacity: `,`;
735
+ border: 0;
736
+ width: 100%;
737
+ text-align: left;
738
+
739
+ &:hover,
740
+ &:focus-visible {
741
+ background: `,`;
742
+
743
+ .chat-title {
744
+ color: `,`;
745
+ }
746
+ }
747
+
748
+ &:focus-visible {
749
+ outline: 2px solid `,`;
750
+ outline-offset: -2px;
751
+ }
752
+ `],({$disabled:a})=>a?"not-allowed":"pointer",r("transparent"),({$disabled:a})=>a?.5:1,({$disabled:a})=>a?"transparent":r("selection"),({$disabled:a})=>a?r("offWhite"):r("foreground"),r("pink")),X0=i.div.withConfig({displayName:"ChatHistoryItem__IconWrapper"})([`
753
+ display: flex;
754
+ align-items: center;
755
+ justify-content: center;
756
+ flex-shrink: 0;
757
+ color: `,`;
758
+ `],r("gray2")),Y0=i.div.withConfig({displayName:"ChatHistoryItem__Content"})([`
759
+ display: flex;
760
+ flex-direction: column;
761
+ flex: 1;
762
+ min-width: 0;
763
+ padding-left: 0.4rem;
764
+ `]),J0=i.div.attrs({className:"chat-title"}).withConfig({displayName:"ChatHistoryItem__Title"})([`
765
+ padding: 0.2rem 0.4rem;
766
+ border: 1px solid transparent;
767
+ color: `,`;
768
+ white-space: nowrap;
769
+ overflow: hidden;
770
+ text-overflow: ellipsis;
771
+ transform: translateX(-0.4rem);
772
+ `],r("offWhite")),er=i.input.withConfig({displayName:"ChatHistoryItem__TitleInput"})([`
773
+ color: `,`;
774
+ background: transparent;
775
+ border: 1px solid `,`;
776
+ border-radius: 6px;
777
+ outline: none;
778
+ padding: 0.2rem 0.4rem;
779
+ font-family: inherit;
780
+ transform: translateX(-0.4rem);
781
+
782
+ &:focus {
783
+ outline: none;
784
+ }
785
+
786
+ &::selection {
787
+ background: `,`;
788
+ }
789
+ &::-moz-selection {
790
+ background: `,`;
791
+ }
792
+ &::-webkit-selection {
793
+ background: `,`;
794
+ }
795
+ `],r("foreground"),r("pinkDarker"),r("pinkPrimary"),r("pinkPrimary"),r("pinkPrimary")),tr=i.div.withConfig({displayName:"ChatHistoryItem__Subtitle"})([`
796
+ font-size: 1.2rem;
797
+ line-height: 1.5;
798
+ color: `,`;
799
+ white-space: nowrap;
800
+ overflow: hidden;
801
+ text-overflow: ellipsis;
802
+ `],r("gray2")),ar=i.div.withConfig({displayName:"ChatHistoryItem__ActionsContainer"})([`
803
+ display: flex;
804
+ align-items: center;
805
+ gap: 0.4rem;
806
+ flex-shrink: 0;
807
+ `]),ja=i.button.withConfig({displayName:"ChatHistoryItem__ActionButton"})([`
808
+ display: flex;
809
+ align-items: center;
810
+ justify-content: center;
811
+ padding: 0.4rem;
812
+ background: transparent;
813
+ border: none;
814
+ border-radius: 4px;
815
+ cursor: pointer;
816
+ color: `,`;
817
+ opacity: 0;
818
+
819
+ `,`:hover &,
820
+ `,`:focus-within & {
821
+ opacity: 1;
822
+ }
823
+
824
+ &:focus-visible {
825
+ opacity: 1;
826
+ outline: 2px solid `,`;
827
+ outline-offset: -2px;
828
+ }
829
+
830
+ &:hover {
831
+ background: `,`;
832
+ }
833
+ `],r("foreground"),Nt,Nt,r("pink"),r("backgroundDarker")),nr=i.span.withConfig({displayName:"ChatHistoryItem__CurrentIndicator"})([`
834
+ font-size: 1.2rem;
835
+ line-height: 1.5rem;
836
+ color: `,`;
837
+ white-space: nowrap;
838
+ `],r("mutedLabel")),rr=({conversation:a,subtitle:n,isCurrent:o,hasOngoingProcess:c,disabled:u,onSelect:g,onRename:y,onDelete:H})=>{const[A,_]=e.useState(!1),[C,k]=e.useState(a.conversationName),b=e.useRef(null);e.useEffect(()=>{A&&b.current&&(b.current.focus(),b.current.select())},[A]);const p=h=>{h.stopPropagation(),k(a.conversationName),_(!0)},N=h=>{h.stopPropagation(),H(a.id)},l=async()=>{const h=C.trim();h&&h!==a.conversationName&&(_e(He.AI_CHAT_RENAME),await y(a.id,h)),_(!1)},v=async h=>{h.key==="Enter"?await l():h.key==="Escape"&&(k(a.conversationName),_(!1))},R=async()=>{await l()},d=async()=>{!A&&!u&&await g(a.id)},x=async h=>{A||u||h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),await g(a.id))};return t.jsxs(Nt,{role:"button",tabIndex:u?-1:0,"aria-disabled":u||void 0,onClick:d,onKeyDown:x,$disabled:u,"data-hook":"chat-history-item",children:[t.jsx(X0,{children:t.jsx(Jt,{size:18})}),t.jsxs(Y0,{children:[A?t.jsx(er,{ref:b,value:C,onChange:h=>k(h.target.value),onKeyDown:v,onBlur:R,onClick:h=>h.stopPropagation(),"data-hook":"chat-history-rename"}):t.jsx(J0,{"data-hook":"chat-history-title",children:a.conversationName}),n&&t.jsx(tr,{children:n})]}),t.jsxs(ar,{children:[!A&&t.jsxs(t.Fragment,{children:[t.jsx(ja,{onClick:p,title:"Edit title","data-hook":"chat-history-edit",children:t.jsx(un,{size:18})}),!c&&t.jsx(ja,{onClick:N,title:"Delete","data-hook":"chat-history-delete",children:t.jsx(sa,{size:18})})]}),o&&t.jsx(nr,{children:"Current"})]})]})},ir=i.div.withConfig({displayName:"DateSeparator__Container"})([`
839
+ display: flex;
840
+ align-items: center;
841
+ gap: 1rem;
842
+ padding: 0.4rem 0;
843
+ width: 100%;
844
+ `]),_a=i.div.withConfig({displayName:"DateSeparator__Line"})([`
845
+ flex: 1;
846
+ height: 1px;
847
+ background: `,`;
848
+ `],r("selection")),sr=i.div.withConfig({displayName:"DateSeparator__LabelContainer"})([`
849
+ display: flex;
850
+ align-items: center;
851
+ gap: 0.8rem;
852
+ color: `,`;
853
+ `],r("gray2")),or=i.span.withConfig({displayName:"DateSeparator__Label"})([`
854
+ font-size: 1.3rem;
855
+ white-space: nowrap;
856
+ `]),lr=({label:a})=>t.jsxs(ir,{children:[t.jsx(_a,{}),t.jsxs(sr,{children:[t.jsx(ea,{size:16}),t.jsx(or,{children:a})]}),t.jsx(_a,{})]}),dr=6e4;function Ha(a){const n=gn(),o=fn(n);return pn(a,new Date().getTime(),{locale:o})+" ago"}function cr(a){const n=[...a].sort((g,y)=>y.updatedAt-g.updatedAt),o=new Map;for(const g of n){const y=Ha(g.updatedAt),H=o.get(y)||[];o.set(y,[...H,g])}const c=[],u=new Set;for(const g of n){const y=Ha(g.updatedAt);u.has(y)||(u.add(y),c.push({label:y,conversations:o.get(y)||[]}))}return c}function hr(a){const[n,o]=e.useState(0);return e.useEffect(()=>{const c=setInterval(()=>{o(u=>u+1)},dr);return()=>clearInterval(c)},[]),e.useMemo(()=>cr(a),[a,n])}function mr(a,n){if(!n.trim())return a;const o=n.toLowerCase().trim();return a.filter(c=>c.conversationName.toLowerCase().includes(o))}const Ea=i.div.withConfig({displayName:"ChatHistoryView__Container"})([`
857
+ display: flex;
858
+ flex-direction: column;
859
+ height: 100%;
860
+ width: 100%;
861
+ padding: 2rem 1rem 4rem 1rem;
862
+ background: `,`;
863
+ overflow: hidden;
864
+ `],r("chatBackground")),ur=i.div.withConfig({displayName:"ChatHistoryView__SearchContainer"})([`
865
+ position: relative;
866
+ display: flex;
867
+ align-items: center;
868
+ flex-shrink: 0;
869
+ `]),gr=i.div.withConfig({displayName:"ChatHistoryView__SearchIcon"})([`
870
+ position: absolute;
871
+ left: 1.2rem;
872
+ display: flex;
873
+ align-items: center;
874
+ color: `,`;
875
+ pointer-events: none;
876
+ z-index: 1;
877
+ `],r("gray2")),pr=i.button.withConfig({displayName:"ChatHistoryView__ClearButton"})([`
878
+ position: absolute;
879
+ right: 0.8rem;
880
+ display: flex;
881
+ align-items: center;
882
+ justify-content: center;
883
+ padding: 0.2rem;
884
+ background: transparent;
885
+ border: none;
886
+ border-radius: 4px;
887
+ cursor: pointer;
888
+ color: `,`;
889
+
890
+ &:hover {
891
+ color: `,`;
892
+ }
893
+ `],r("gray2"),r("foreground")),fr=i(wn).withConfig({displayName:"ChatHistoryView__SearchInput"})([`
894
+ width: 100%;
895
+ background: transparent;
896
+ color: `,`;
897
+ padding: 0.8rem 3.6rem 0.8rem 3.6rem;
898
+ border: 1px solid `,`4d;
899
+ height: 3rem;
900
+ border-radius: 0.6rem;
901
+
902
+ &:focus {
903
+ background: transparent;
904
+ border-color: `,`;
905
+ }
906
+ `],r("foreground"),r("gray2"),r("pinkDarker")),yr=i.div.withConfig({displayName:"ChatHistoryView__ListContainer"})([`
907
+ display: flex;
908
+ flex-direction: column;
909
+ gap: 0.6rem;
910
+ padding: 2rem 0.4rem;
911
+ overflow-y: auto;
912
+ flex: 1;
913
+ min-height: 0;
914
+ `]),Ia=i.div.withConfig({displayName:"ChatHistoryView__EmptyState"})([`
915
+ display: flex;
916
+ flex-direction: column;
917
+ align-items: center;
918
+ justify-content: center;
919
+ flex: 1;
920
+ color: `,`;
921
+ font-size: 1.3rem;
922
+ text-align: center;
923
+ padding: 2rem;
924
+ `],r("gray2")),xr=i(Re.Content).withConfig({displayName:"ChatHistoryView__AlertDialogContent"})([`
925
+ background: `,`;
926
+ `],r("chatBackground")),wr=i.div.withConfig({displayName:"ChatHistoryView__DialogHeader"})([`
927
+ display: flex;
928
+ align-items: center;
929
+ justify-content: space-between;
930
+ padding: 1.5rem 2rem;
931
+ border-bottom: 1px solid `,`;
932
+ `],r("selection")),Cr=i.h3.withConfig({displayName:"ChatHistoryView__DialogTitle"})([`
933
+ margin: 0;
934
+ font-weight: 500;
935
+ color: `,`;
936
+ `],r("foreground")),br=i.p.withConfig({displayName:"ChatHistoryView__DialogDescription"})([`
937
+ margin: 2rem;
938
+ font-size: 1.4rem;
939
+ line-height: 1.5;
940
+ `]),Ar=i.div.withConfig({displayName:"ChatHistoryView__DialogButtons"})([`
941
+ display: flex;
942
+ justify-content: flex-end;
943
+ gap: 1rem;
944
+ padding: 0 2rem 0 2rem;
945
+ `]),vr=i(ue).attrs({skin:"secondary"}).withConfig({displayName:"ChatHistoryView__CancelButton"})([""]),kr=i(ue).withConfig({displayName:"ChatHistoryView__DeleteButton"})([`
946
+ background: `,`;
947
+ border-color: `,`;
948
+
949
+ &:hover:not(:disabled) {
950
+ background: `,`;
951
+ filter: brightness(1.1);
952
+ }
953
+ `],r("red"),r("red"),r("red")),Mr=({currentConversationId:a})=>{const[n,o]=e.useState(""),[c,u]=e.useState(!1),[g,y]=e.useState(null),H=e.useRef(null),{conversationMetas:A,chatWindowState:_,openChatWindow:C,updateConversationName:k,deleteConversation:b}=xt(),{status:p}=Te(),{buffers:N}=yt(),l=Ee(je.query.getTables),v=e.useMemo(()=>Array.from(A.values()),[A]),R=e.useMemo(()=>mr(v,n),[v,n]),d=hr(R),x=(V,z)=>{if(V){if(z==="buffer"){const Z=N.find(L=>L.id===V);if(Z)return Z.label}else if(z==="table"){const Z=l.find(L=>L.id===V);if(Z)return Z.table_name}}},h=async V=>{await C(V)},T=async(V,z)=>{await k(V,z)},X=V=>{y(V),u(!0)},F=async()=>{g&&await b(g),u(!1),y(null)},I=()=>{u(!1),y(null)};return e.useEffect(()=>{H.current&&H.current.scrollIntoView({block:"center"})},[]),v.length===0?t.jsx(Ea,{children:t.jsx(Ia,{"data-hook":"chat-history-empty",children:"No conversations yet"})}):t.jsxs(Ea,{children:[t.jsxs(ur,{children:[t.jsx(gr,{children:t.jsx(ia,{size:18})}),t.jsx(fr,{type:"text",placeholder:"Search chats",value:n,onChange:V=>o(V.target.value),"data-hook":"chat-history-search"}),n&&t.jsx(pr,{onClick:()=>o(""),title:"Clear search","data-hook":"chat-history-search-clear",children:t.jsx(Kt,{size:16})})]}),t.jsxs(yr,{"data-hook":"chat-history-list",children:[d.map((V,z)=>t.jsxs(ot.Fragment,{children:[z>0&&t.jsx(lr,{label:V.label}),V.conversations.map(Z=>{const L=Z.id===a;return t.jsx("div",{ref:L?H:void 0,children:t.jsx(rr,{conversation:Z,subtitle:Z.bufferId??Z.tableId?x(Z.bufferId??Z.tableId,Z.bufferId?"buffer":"table"):void 0,isCurrent:L,hasOngoingProcess:Z.id===_.activeConversationId&&ge(p),disabled:ge(p)&&Z.id!==_.activeConversationId,onSelect:h,onRename:T,onDelete:X})},Z.id)})]},V.label)),R.length===0&&n&&t.jsx(Ia,{children:"No chats match your search"})]}),t.jsx(Re.Root,{open:c,onOpenChange:u,children:t.jsxs(Re.Portal,{children:[t.jsx(yn,{children:t.jsx(xn,{primitive:Re.Overlay})}),t.jsxs(xr,{maxwidth:"40rem",children:[t.jsx(wr,{children:t.jsx(Cr,{children:"Delete conversation"})}),t.jsx(br,{children:"Are you sure you want to delete this conversation? This action cannot be undone."}),t.jsxs(Ar,{children:[t.jsx(Re.Cancel,{asChild:!0,children:t.jsx(vr,{onClick:I,children:"Cancel"})}),t.jsx(Re.Action,{asChild:!0,children:t.jsx(kr,{onClick:F,children:"Delete"})})]})]})]})})]})};async function jr(a){var C,k,b;const{normalizedSQL:n,queryKey:o,namespaceKey:c,quest:u,dispatch:g,executionRefs:y,releaseExecution:H}=a,{promise:A,queryId:_}=u.queryRaw(n,{limit:"0,1000",explain:!0,cancellable:!0});(C=a.onQueryStarted)==null||C.call(a,_);try{const p=await A;if(y.current[c]||(y.current[c]={}),y.current[c][o]={success:!0,queryText:n,startOffset:-1,endOffset:-1},g(Ue.setResult(p)),p.type===Ge.DDL||p.type===Ge.DML){g(Ue.addNotification({query:o,content:t.jsx(Xe,{query:n})},c)),Ye.publish(Je.MSG_QUERY_SCHEMA);return}if(p.type===Ge.NOTICE){g(Ue.addNotification({query:o,content:t.jsxs(de,{color:"foreground",ellipsis:!0,title:n,children:[p.notice,n!==""?`: ${n}`:""]}),type:Fe.NOTICE,sideContent:t.jsx(Xe,{query:n})},c)),Ye.publish(Je.MSG_QUERY_SCHEMA);return}p.type===Ge.DQL&&(g(Ue.addNotification({query:o,jitCompiled:((k=p.explain)==null?void 0:k.jitCompiled)??!1,content:t.jsx(Cn,{...p.timings,rowCount:p.count}),sideContent:t.jsx(Xe,{query:n})},c)),Ye.publish(Je.MSG_QUERY_DATASET,p))}catch(p){const N=p;y.current[c]||(y.current[c]={}),y.current[c][o]={success:!1,queryText:n,startOffset:-1,endOffset:-1},g(Ue.addNotification({query:o,content:t.jsx(de,{color:"red",children:N.error||N.message||"Query execution failed"}),type:Fe.ERROR,sideContent:t.jsx(Xe,{query:n})},c))}finally{(b=a.onSettled)==null||b.call(a),H(o)}}const _r=i(ue).withConfig({displayName:"AIChatWindow__CancelButton"})([`
954
+ padding: 1.2rem 0.6rem;
955
+ `]),Hr=i.div.withConfig({displayName:"AIChatWindow__HeaderLeft"})([`
956
+ display: flex;
957
+ align-items: center;
958
+ gap: 1rem;
959
+ flex: 1;
960
+ min-width: 0;
961
+ overflow: hidden;
962
+ `]),Er=i.span.withConfig({displayName:"AIChatWindow__HeaderTitle"})([`
963
+ white-space: nowrap;
964
+ overflow: hidden;
965
+ text-overflow: ellipsis;
966
+ font-size: 1.6rem;
967
+ `]),Vt=i(ue).attrs(({$active:a})=>({skin:"transparent",$active:a})).withConfig({displayName:"AIChatWindow__HeaderButton"})([`
968
+ color: `,`;
969
+ padding: 0.6rem;
970
+
971
+ `,`
972
+ `],r("foreground"),({$active:a})=>a&&re([`
973
+ background: `,`;
974
+ `],r("selection"))),Ir=i.div.withConfig({displayName:"AIChatWindow__HeaderRight"})([`
975
+ display: flex;
976
+ align-items: center;
977
+ gap: 0.5rem;
978
+ flex-shrink: 0;
979
+ `]),Nr=i.div.withConfig({displayName:"AIChatWindow__ChatWindowContent"})([`
980
+ display: flex;
981
+ height: 100%;
982
+ width: 100%;
983
+ overflow: hidden;
984
+ `]),Vr=i.div.withConfig({displayName:"AIChatWindow__InitialQueryContainer"})([`
985
+ display: flex;
986
+ flex-direction: column;
987
+ gap: 1rem;
988
+ padding: 1.5rem;
989
+ overflow-y: auto;
990
+ flex: 1 1 auto;
991
+ min-height: 0;
992
+ width: 100%;
993
+ `]),Zr=i.div.withConfig({displayName:"AIChatWindow__InitialQueryBox"})([`
994
+ display: flex;
995
+ flex-direction: column;
996
+ align-self: flex-end;
997
+ flex-shrink: 0;
998
+ overflow: hidden;
999
+ width: 100%;
1000
+ `]),Sr=i.div.withConfig({displayName:"AIChatWindow__InitialQueryEditor"})([`
1001
+ width: 100%;
1002
+ overflow: hidden;
1003
+ `]),qr=i.div.withConfig({displayName:"AIChatWindow__ButtonContainer"})([`
1004
+ display: flex;
1005
+ justify-content: flex-start;
1006
+ align-items: center;
1007
+ gap: 1rem;
1008
+ width: 100%;
1009
+ margin-top: 0.5rem;
1010
+ `]),Lr=i.div.withConfig({displayName:"AIChatWindow__BlankChatContainer"})([`
1011
+ display: flex;
1012
+ flex-direction: column;
1013
+ align-items: flex-start;
1014
+ justify-content: center;
1015
+ gap: 1.2rem;
1016
+ padding: 1.8rem;
1017
+ flex: 1 1 auto;
1018
+ min-height: 0;
1019
+ max-width: 40rem;
1020
+ text-align: center;
1021
+ margin: 0 auto;
1022
+ `]),Dr=i.h2.withConfig({displayName:"AIChatWindow__BlankChatHeading"})([`
1023
+ font-size: 2rem;
1024
+ font-weight: 600;
1025
+ text-align: left;
1026
+ color: `,`;
1027
+ margin: 0;
1028
+ `],r("foreground")),Tr=i.p.withConfig({displayName:"AIChatWindow__BlankChatSubheading"})([`
1029
+ font-size: 1.4rem;
1030
+ font-weight: 400;
1031
+ color: `,`;
1032
+ text-align: left;
1033
+ margin: 0;
1034
+ line-height: 1.5;
1035
+ `],r("gray2")),Na=i(q).withConfig({displayName:"AIChatWindow__ChatPanel"})([`
1036
+ display: flex;
1037
+ flex-direction: column;
1038
+ align-items: stretch;
1039
+ height: 100%;
1040
+ width: 100%;
1041
+ gap: 0;
1042
+ `]),Fr=()=>{const a=Ut(),n=Ee(je.console.getActiveSidebar),{quest:o,questExecution:c}=e.useContext(ft),{editorRef:u,showPreviewBuffer:g,closePreviewBuffer:y,addBuffer:H,executionRefs:A,highlightQuery:_,buffers:C,activeBuffer:k,setActiveBuffer:b}=yt(),p=bn(),{conversationMetas:N,chatWindowState:l,isLoadingMessages:v,isStreaming:R,setIsStreaming:d,scrollToMessageId:x,setScrollToMessageId:h,closeChatWindow:T,openBlankChatWindow:X,openHistoryView:F,closeHistoryView:I,getConversationMeta:V,addMessage:z,removeMessages:Z,updateMessage:L,updateMessagesWithCompaction:j,updateConversationName:Ie,acceptSuggestion:ee,rejectSuggestion:K,persistMessages:Y,bindConversationToNotebook:ve,readUserActionDigest:pe,rotateUserActionDigest:ke}=xt(),{status:J,setStatus:ze,abortController:E,canUse:m,hasSchemaAccess:Q,currentModel:$e,apiKey:Be,aiAssistantSettings:We}=Te(),ce=Ee(je.query.getTables),{active:Ne}=An(),Le=(Ne==null?void 0:Ne.queryKey)??null,he=l.activeConversationId?V(l.activeConversationId):null,s=e.useMemo(()=>he?{...he,messages:p}:null,[he,p]),te=e.useMemo(()=>s?s.bufferId!==void 0?s.bufferId:s.id:-1,[s==null?void 0:s.bufferId,s==null?void 0:s.id]),Qe=Ee(je.query.getQueryNotificationsForBuffer(te)),Me=e.useRef(null),De=e.useRef(!1),$=e.useRef(null),B=e.useMemo(()=>kt(s==null?void 0:s.currentSQL),[s==null?void 0:s.currentSQL]),Oe=e.useMemo(()=>vn(s==null?void 0:s.queryKey),[s==null?void 0:s.queryKey]),O=p,ht=e.useMemo(()=>kn(O)!==null,[O]),mt=e.useMemo(()=>O.length>0&&!v,[O,v]),se=e.useMemo(()=>O.length===0&&B&&B.trim()!==`
1043
+ `&&m&&!ge(J),[O.length,B,m,J]),tt=e.useMemo(()=>!se||!s||!s.queryKey||!s.bufferId||!u.current?!1:oa(s.queryKey,s.bufferId,A,u)!==null,[se,s,u,A]),Ke=se&&tt&&m&&!ge(J),P=l.isHistoryOpen??!1,M=N.size>0,U=e.useMemo(()=>ge(J)?!0:s?s.messages.length===0&&!s.queryKey&&!s.tableId:!1,[s,J]),fe=e.useMemo(()=>{if(P)return"Chat history";if(!s)return"";if(s.conversationName)return s.conversationName;const f=s.messages[0];if(f!=null&&f.displayType)switch(f.displayType){case"fix_request":return"Fix query";case"explain_request":return"Explain query";case"ask_request":return"Ask AI";case"health_issue_request":return"Health issue analysis";default:return"AI Assistant"}return"AI Assistant"},[s,P]),at=e.useCallback(()=>{P?I():F()},[P,I,F]),ye=()=>O.length>0?"Ask a follow up question or request refinement...":(s==null?void 0:s.tableId)!=null||B!=null&&B.trim()?"Ask a question or request an edit...":"Ask AI about your tables, or generate a query...",me=e.useCallback(async f=>{var Ve;const w=(Ve=V(f))==null?void 0:Ve.notebookBufferId,D=typeof w=="number"?Mn(w):void 0,G=w?await jn(w).catch(S=>(console.warn("Notebook snapshot unavailable, sending without it",S),null)):null,ne=pe(f),we=C.filter(S=>!!S.notebookViewState&&typeof S.id=="number"),Ce=we.length>0||typeof k.id=="number"?{notebooks:we.map(S=>({buffer_id:S.id,label:S.label,archived:!!S.archived,...S.id===w?{bound_to_this_chat:!0}:{}})),active:typeof k.id=="number"?{buffer_id:k.id,label:k.label,kind:k.notebookViewState?"notebook":k.metricsViewState?"metrics":k.editorViewState?"sql":"other"}:void 0}:void 0;if(!(!G&&!ne&&!Ce))return{snapshot:G,digest:ne,workspace:Ce,readSeq:D}},[V,pe,C,k]),W=async(f,w=!1)=>{if(!m||!l.activeConversationId||!s)return;_e(He.AI_CHAT_SEND);const D=l.activeConversationId;w&&y();const G=s.messages.some(ne=>ne.role==="assistant");Ze(Pt({conversationId:D,userMessage:f,currentSQL:B,conversationHistory:s.messages,isFirstMessage:!G,settings:{model:$e,apiKey:Be},aiAssistantSettings:We,questClient:o,tables:ce,hasSchemaAccess:Q,abortSignal:E==null?void 0:E.signal,notebookContext:await me(D)}),{addMessage:z,removeMessages:Z,updateMessage:L,setStatus:ze,setIsStreaming:d,persistMessages:Y,updateConversationName:Ie,bindConversationToNotebook:ve,rotateUserActionDigest:ke,updateMessagesWithCompaction:j})},xe=e.useCallback(async f=>{l.activeConversationId&&(_e(He.AI_CHAT_ACCEPT),await ee({conversationId:l.activeConversationId,messageId:f}))},[l.activeConversationId,ee]),ae=e.useCallback(async f=>{l.activeConversationId&&(_e(He.AI_CHAT_REJECT),await K(l.activeConversationId,f),setTimeout(()=>{var w;(w=Me.current)==null||w.focus()},100))},[l.activeConversationId,K]),Va=e.useCallback(f=>{if(!s)return;const w=Ae(f),D=At(w);let G=null;c.requestExecution({abort:()=>{G!==null&&o.abort(G)},bufferId:te,queryKey:D,execute:()=>{const ne=window.setTimeout(()=>{a(Ct.query.addNotification({query:D,type:Fe.LOADING,content:t.jsxs(q,{gap:"1rem",align:"center",children:[t.jsx(de,{color:"foreground",children:"Running..."}),t.jsx(_r,{skin:"error",onClick:()=>{c.cancelActive()},children:t.jsx(Ot,{size:"18px"})})]}),sideContent:t.jsx(Xe,{query:w})},te)),$.current=null},1e3);$.current=ne,jr({normalizedSQL:w,queryKey:D,namespaceKey:te,quest:o,dispatch:a,executionRefs:A,releaseExecution:c.releaseExecution,onQueryStarted:we=>{G=we},onSettled:()=>{$.current===ne&&(window.clearTimeout(ne),$.current=null)}})}})},[s,A,te,o,c]),Za=e.useCallback(f=>{var w;((w=c.getActive())==null?void 0:w.queryKey)===f&&($.current!==null&&(window.clearTimeout($.current),$.current=null),c.cancelActive())},[c]),ut=e.useCallback(async()=>{if(_e(He.AI_CONTEXT_BADGE_CLICK,{type:s!=null&&s.tableId?"table":"query"}),(s==null?void 0:s.queryKey)&&(s==null?void 0:s.bufferId))return await _(s.queryKey,s.bufferId);if(s!=null&&s.tableId){const f=ce.find(w=>w.id===s.tableId);if(f)return a(Ct.console.pushSidebarHistory({type:"tableDetails",payload:{tableName:f.table_name,isMatView:f.table_type==="M",isView:f.table_type==="V"}})),!0}return!1},[s==null?void 0:s.queryKey,s==null?void 0:s.bufferId,s==null?void 0:s.tableId,_,ce]),Sa=e.useCallback(()=>{h(null)},[h]),Zt=e.useCallback(async(f,w=!1)=>{if(!(w&&await ut()))if(f.type==="diff"){if(!l.activeConversationId)return;g({type:"diff",original:f.original,modified:f.modified,conversationId:l.activeConversationId})}else H({value:f.value})},[g,H,l.activeConversationId,ut]),qa=e.useCallback(async(f,w)=>{if(!l.activeConversationId)return;const D=_n(w,!1);try{await ee({conversationId:l.activeConversationId,messageId:f,skipDefaultMessage:!0}),z({role:"user",content:`User replaced query with one of your previous suggestions. Now the query is:
1044
+
1045
+ \`\`\`sql
1046
+ ${D.replaceAll(/\s+/g," ").trim()}
1047
+ \`\`\``,timestamp:Date.now(),hideFromUI:!0}),await Y(l.activeConversationId)}catch(G){console.error("Error applying SQL to editor:",G),st.error("Failed to apply changes to editor")}},[l.activeConversationId,ee,z,Y]),La=e.useCallback(async f=>{if(!l.activeConversationId||!m||ge(J))return;const w=l.activeConversationId,D=O.find(S=>S.id===f);if(!D)return;const G=O.findIndex(S=>S.id===f);if(G<0)return;const ne=O.slice(G).map(S=>S.id),we=new Set(ne);Z(ne);const Ce={settings:{model:$e,apiKey:Be},aiAssistantSettings:We,questClient:o,tables:ce,hasSchemaAccess:Q,abortSignal:E==null?void 0:E.signal,notebookContext:await me(w)},Ve={addMessage:z,updateMessage:L,removeMessages:Z,setStatus:ze,setIsStreaming:d,persistMessages:Y,updateConversationName:Ie,updateMessagesWithCompaction:j,bindConversationToNotebook:ve,rotateUserActionDigest:ke};switch(D.displayType){case"explain_request":{if(!D.sql)return;Ze(Dt({conversationId:w,queryText:D.sql,...Ce}),Ve);break}case"fix_request":{if(!D.sql)return;Ze(Tt({conversationId:w,queryText:D.sql,...Ce}),Ve);break}case"schema_explain_request":{if(!D.displaySchemaData)return;const S=D.displaySchemaData;try{const oe=S.kind==="matview"?await o.showMatViewDDL(S.tableName):S.kind==="view"?await o.showViewDDL(S.tableName):await o.showTableDDL(S.tableName);if((oe==null?void 0:oe.type)!==Ge.DQL||!oe.data||oe.data.length===0){st.error("Failed to fetch table schema for retry");return}const rt=oe.data[0];if(!rt.ddl){st.error("Failed to fetch table schema for retry");return}Ze(Hn({conversationId:w,tableName:S.tableName,schema:rt.ddl,kindLabel:En(S.kind),schemaDisplayData:S,...Ce}),Ve)}catch(oe){console.error("Error fetching DDL for retry:",oe),st.error("Failed to fetch table schema for retry")}break}case"ask_request":default:{const S=D.displayUserMessage||D.content||"",oe=O.filter(pt=>!we.has(pt.id)),rt=oe.some(pt=>pt.role==="assistant");Ze(Pt({conversationId:w,userMessage:S,currentSQL:D.sql||B,conversationHistory:oe,isFirstMessage:!rt,...Ce}),Ve);break}}},[l.activeConversationId,m,J,O,Z,$e,Be,We,o,ce,Q,E,z,L,ze,d,Y,Ie,j,ve,me,B]),St=e.useRef(null),nt=e.useCallback(()=>{var f,w;(w=(f=St.current)==null?void 0:f.querySelector('button[data-hook="button-explain-query"]'))==null||w.click()},[]),gt=e.useCallback(f=>{se&&(f.metaKey||f.ctrlKey)&&(f.key==="e"||f.key==="E")&&(f.preventDefault(),nt())},[se]);e.useEffect(()=>{if(se)return Ye.subscribe(Je.EXPLAIN_QUERY_EXEC,nt),document.addEventListener("keydown",gt),()=>{document.removeEventListener("keydown",gt),Ye.unsubscribe(Je.EXPLAIN_QUERY_EXEC,nt)}},[se,gt,nt]),e.useEffect(()=>()=>{$.current!==null&&(window.clearTimeout($.current),$.current=null)},[]),e.useEffect(()=>{De.current||P||v||Me.current&&(Me.current.focus(),De.current=!0)},[P,v]);const Da=e.useCallback(async()=>{var f;De.current=!1,await X(),(f=Me.current)==null||f.focus()},[X]);if((n==null?void 0:n.type)!=="aiChat"||!s&&!P)return null;const Ta=(()=>{const f=s==null?void 0:s.notebookBufferId;if(typeof f!="number")return;const w=C.find(Ce=>Ce.id===f),D=!w,G=!!(w!=null&&w.archived),ne=(w==null?void 0:w.label)??`#${f}`,we=D?"deleted":G?"archived":null;return{label:ne,warn:we,onClick:async()=>{we||w&&await b(w)}}})();return t.jsx(t.Fragment,{children:t.jsx(In,{mode:"side","data-hook":"ai-chat-window",open:(n==null?void 0:n.type)==="aiChat",onOpenChange:f=>{f||T()},onDismiss:T,trigger:t.jsx("span",{}),title:t.jsxs(Hr,{children:[t.jsx(it,{size:20,variant:"filled"}),t.jsx(Er,{"data-hook":"chat-window-title",children:fe})]}),afterTitle:t.jsxs(Ir,{children:[t.jsx(Vt,{onClick:Da,title:"New chat","aria-label":"New chat",disabled:U,"data-hook":"chat-window-new",children:t.jsx(Nn,{size:16,weight:"bold"})}),t.jsx(Vt,{$active:P,onClick:at,title:P?"Back to chat":"Chat history","aria-label":P?"Back to chat":"Chat history","aria-pressed":P,disabled:!M||ge(J),"data-hook":"chat-window-history",children:t.jsx(ta,{size:16,weight:"bold"})}),t.jsx(Vt,{onClick:T,title:"Close","aria-label":"Close AI chat","data-hook":"chat-window-close",children:t.jsx(Kt,{size:16,weight:"bold"})})]}),children:t.jsx(Nr,{children:v?t.jsx(Na,{children:t.jsx(wt,{size:20,style:{margin:"auto"}})}):P?t.jsx(Mr,{currentConversationId:l.previousConversationId??null}):t.jsxs(Na,{children:[mt?t.jsx(D0,{messages:O,onAcceptChange:xe,onRejectChange:ae,onRunQuery:Va,onOpenInEditor:Zt,onApplyToEditor:qa,onRetry:La,onCancelQuery:Za,runningQueryKey:Le,queryNotifications:Qe,isOperationInProgress:ge(J),editorSQL:Oe.queryText,isStreaming:R,isLoadingMessages:v,scrollToMessageId:x,onScrollToMessageComplete:Sa}):B&&B.trim()?t.jsxs(Vr,{children:[t.jsx(Zr,{"data-hook":"chat-initial-query-box",children:t.jsx(Sr,{"data-hook":"chat-lite-editor",children:t.jsx(Pe,{value:B.trim(),maxHeight:216,onOpenInEditor:()=>Zt({type:"code",value:B.trim()},!0)})})}),(se||Ke)&&t.jsxs(qr,{ref:St,children:[se&&t.jsx(Kn,{conversationId:s.id,queryText:B.trim()}),Ke&&t.jsx(Un,{})]})]}):t.jsxs(Lr,{"data-hook":"chat-blank-state",children:[t.jsx(Dr,{children:"Leverage AI directly in your database"}),t.jsx(Tr,{children:"Our AI Assistant is a specialized programming and support agent that makes you more effective and helps you solve problems as you interface with your QuestDB database. Start a conversation."})]}),t.jsx(G0,{ref:Me,onSend:f=>W(f,ht),disabled:!m||ge(J),placeholder:ye(),contextSQL:Oe.queryText,contextTableId:s==null?void 0:s.tableId,contextNotebook:Ta,onContextClick:ut})]})})})})};export{Fr as default};