@questdb/web-console 2.0.3 → 2.0.5

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,915 @@
1
+ import{p as Ve,Q as yt,s as _e,u as Re,a as Ra,j as e,c as Rt,A as st,K as Dt,b as o,B as oe,t as Me,C as He,e as Ze,d as zt,f as Z,g as Da,h as Ct,i as wt,k as Ft,l as za,m as Fa,n as $t,o as $a,q as we,r as bt,v as Bt,w as Ba,x as Pt,y as Ot,z as Qt,D as Pa,E as Wt,S as Oa,L as Ke,F as Qa,T as le,G as vt,H as rt,I as jt,J as Wa,M as Ka,N as be,O as At,P as Ua,R as Ya,U as _t,V as De,W as Ga,X as Kt,Y as Xa,Z as Ja,_ as en,$ as tn,a0 as an,a1 as nn,a2 as sn,a3 as ot,a4 as rn,a5 as on,a6 as ln,a7 as Ut,a8 as dn,a9 as cn,aa as hn,ab as mn,ac as un,ad as ue,ae as pn,af as gn,ag as fn,ah as xn,ai as yn,aj as Yt,ak as ze,al as Cn,am as wn,an as bn,ao as Ue,ap as Ye,aq as Ge,ar as Xe,as as Je,at as vn,au as jn,av as An,aw as _n,ax as Mn,ay as Hn,az as kn,aA as In,aB as En,aC as Nn,aD as lt,aE as Gt,aF as Sn,aG as Vn,aH as Zn,aI as qn,aJ as Tn}from"./index-CuR3ubvw.js";import{b as t,D as ke,H as i,Z as Mt,R as dt,C as de,U as Ln,B as Xt}from"./vendor-Db-z1rVX.js";const Rn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),Dn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),zn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),Fn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),$n=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),Bn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),Pn=new Map([["bold",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.createElement("path",{d:"M200,56V208a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V56Z",opacity:"0.2"}),t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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",t.createElement(t.Fragment,null,t.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"}))]]),Jt=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:Rn}));Jt.displayName="ChatDotsIcon";const ea=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:Dn}));ea.displayName="ChatTextIcon";const ta=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:zn}));ta.displayName="ClockCountdownIcon";const aa=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:Fn}));aa.displayName="CodeBlockIcon";const na=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:$n}));na.displayName="GaugeIcon";const ia=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:Bn}));ia.displayName="KeyReturnIcon";const sa=t.forwardRef((a,n)=>t.createElement(Ve,{ref:n,...a,weights:Pn}));sa.displayName="TrashSimpleIcon";const On=i(Z).attrs({alignItems:"center",gap:"0"}).withConfig({displayName:"ExplainQueryButton__KeyBinding"})([`
2
+ color: `,`;
3
+ `],({theme:a})=>a.color.aiPinkStart),Qn=`${Rt}+E`,Wn=i(oe).withConfig({displayName:"ExplainQueryButton__ExplainButton"})([`
4
+ gap: 1rem;
5
+ `]),Kn=({conversationId:a,queryText:n})=>{const{quest:r}=t.useContext(yt),c=ke(_e.query.getTables),{setStatus:u,abortController:p,hasSchemaAccess:f,currentModel:k,apiKey:v,aiAssistantSettings:H}=Re(),{addMessage:w,updateMessage:A,updateConversationName:b,persistMessages:m,setIsStreaming:S}=Ra(),l=()=>{Me(He.AI_EXPLAIN_QUERY),Ze(zt({conversationId:a,queryText:n,settings:{model:k,apiKey:v},aiAssistantSettings:H,questClient:r,tables:c,hasSchemaAccess:f,abortSignal:p==null?void 0:p.signal}),{addMessage:w,updateMessage:A,setStatus:u,setIsStreaming:S,persistMessages:m,updateConversationName:b})};return e.jsxs(Wn,{variant:"gradient",gradientWeight:"thin",onClick:l,title:`Explain query with AI Assistant (${Qn})`,"data-hook":"button-explain-query",children:[e.jsx(st,{size:12,variant:"hollow"}),"Explain query",e.jsxs(On,{children:[e.jsx(Dt,{keyString:Rt,color:o("aiPinkStart")}),e.jsx(Dt,{keyString:"E",color:o("aiPinkStart")})]})]})},ra=(a,n,r,c)=>{if(!(r!=null&&r.current)||!c.current)return null;const u=c.current.getModel();if(!u)return null;const p=r.current[n.toString()];if(!p)return null;const f=p[a];if(!f||!f.error)return null;const k=f.selection?f.selection.startOffset:f.startOffset,v=f.selection?f.selection.endOffset:f.endOffset,H=u.getPositionAt(k),w=u.getPositionAt(k+f.error.position),A=u.getWordAtPosition(w),b=u.getPositionAt(v),m=f.selection?u.getValueInRange({startLineNumber:H.lineNumber,startColumn:H.column,endLineNumber:b.lineNumber,endColumn:b.column}):Da(a).queryText;return{errorMessage:f.error.error||"Query execution failed",word:A?A.word:null,fixStart:k,fixEnd:v,queryText:m}},Un=i(oe).withConfig({displayName:"FixQueryButton__FixButton"})([`
6
+ gap: 1rem;
7
+ `]),Yn=()=>{const{quest:a}=t.useContext(yt),{editorRef:n,executionRefs:r}=Ct(),c=ke(_e.query.getTables),{setStatus:u,abortController:p,hasSchemaAccess:f,currentModel:k,apiKey:v,aiAssistantSettings:H}=Re(),{chatWindowState:w,getConversationMeta:A,addMessage:b,updateMessage:m,updateConversationName:S,persistMessages:l,setIsStreaming:j}=wt(),z=()=>{const d=w.activeConversationId;if(!d)return;const y=A(d);if(!(y!=null&&y.queryKey)||y.bufferId==null)return;const h=ra(y.queryKey,y.bufferId,r,n);if(!h)return;Me(He.AI_FIX_QUERY);const{errorMessage:R,queryText:Y,word:D}=h;Ze(Ft({conversationId:d,queryText:Y,errorMessage:R,errorWord:D??void 0,settings:{model:k,apiKey:v},aiAssistantSettings:H,questClient:a,tables:c,hasSchemaAccess:f,abortSignal:p==null?void 0:p.signal}),{addMessage:b,updateMessage:m,setStatus:u,setIsStreaming:j,persistMessages:l,updateConversationName:S})};return e.jsxs(Un,{variant:"gradient",gradientWeight:"thin",onClick:z,title:"Fix query with AI Assistant","data-hook":"button-fix-query",children:[e.jsx(st,{size:12,variant:"hollow"}),"Fix query"]})},Ht=a=>{if(!a||typeof a!="string")return`
8
+ `;let n=a.trim();return n.endsWith(";")&&(n=n.slice(0,-1).trim()),n+`
9
+ `},Gn=a=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",color:"currentColor",...a,children:e.jsx("path",{d:"M13.1254 5.4664C13.1248 4.88689 12.9602 4.3194 12.6505 3.82958C12.3408 3.33977 11.8987 2.94768 11.3754 2.69867V2.62265C11.3749 2.05894 11.1929 1.51037 10.8565 1.0581C10.52 0.605836 10.0468 0.273902 9.50706 0.111415C8.96727 -0.0510722 8.38952 -0.0354796 7.85929 0.155885C7.32906 0.34725 6.87451 0.704221 6.56291 1.17398C6.25131 0.704221 5.79676 0.34725 5.26653 0.155885C4.7363 -0.0354796 4.15855 -0.0510722 3.61876 0.111415C3.07898 0.273902 2.60584 0.605836 2.26936 1.0581C1.93287 1.51037 1.75091 2.05894 1.75041 2.62265V2.69867C1.22669 2.94699 0.784189 3.33885 0.474336 3.82869C0.164484 4.31853 0 4.88624 0 5.46585C0 6.04547 0.164484 6.61318 0.474336 7.10302C0.784189 7.59286 1.22669 7.98471 1.75041 8.23304V8.31015C1.75091 8.87386 1.93287 9.42243 2.26936 9.8747C2.60584 10.327 3.07898 10.6589 3.61876 10.8214C4.15855 10.9839 4.7363 10.9683 5.26653 10.7769C5.79676 10.5856 6.25131 10.2286 6.56291 9.75882C6.87451 10.2286 7.32906 10.5856 7.85929 10.7769C8.38952 10.9683 8.96727 10.9839 9.50706 10.8214C10.0468 10.6589 10.52 10.327 10.8565 9.8747C11.1929 9.42243 11.3749 8.87386 11.3754 8.31015V8.23304C11.8986 7.98422 12.3406 7.59231 12.6503 7.10269C12.96 6.61307 13.1248 6.04575 13.1254 5.4664ZM4.37541 10.0602C3.9439 10.0601 3.52762 9.9006 3.20653 9.61232C2.88545 9.32404 2.68219 8.92729 2.6358 8.49828C2.77728 8.51846 2.92 8.52869 3.06291 8.5289H3.50041C3.61644 8.5289 3.72772 8.48281 3.80977 8.40076C3.89182 8.31871 3.93791 8.20743 3.93791 8.0914C3.93791 7.97537 3.89182 7.86409 3.80977 7.78204C3.72772 7.69999 3.61644 7.6539 3.50041 7.6539H3.06291C2.54642 7.6545 2.04637 7.47233 1.6513 7.13964C1.25624 6.80695 0.991627 6.3452 0.904328 5.83614C0.817029 5.32708 0.91267 4.80355 1.17432 4.35824C1.43597 3.91293 1.84674 3.57456 2.33393 3.40304C2.41917 3.37286 2.49296 3.31701 2.54516 3.24317C2.59736 3.16933 2.6254 3.08112 2.62541 2.9907V2.62265C2.62541 2.15852 2.80978 1.7134 3.13797 1.38521C3.46616 1.05702 3.91128 0.87265 4.37541 0.87265C4.83954 0.87265 5.28466 1.05702 5.61285 1.38521C5.94104 1.7134 6.12541 2.15852 6.12541 2.62265V6.35562C5.64499 5.92353 5.02156 5.68467 4.37541 5.68515C4.25938 5.68515 4.1481 5.73124 4.06605 5.81329C3.984 5.89534 3.93791 6.00662 3.93791 6.12265C3.93791 6.23868 3.984 6.34996 4.06605 6.43201C4.1481 6.51406 4.25938 6.56015 4.37541 6.56015C4.83954 6.56015 5.28466 6.74452 5.61285 7.07271C5.94104 7.4009 6.12541 7.84602 6.12541 8.31015C6.12541 8.77428 5.94104 9.2194 5.61285 9.54759C5.28466 9.87578 4.83954 10.0602 4.37541 10.0602ZM10.0629 7.6539H9.62541C9.50938 7.6539 9.3981 7.69999 9.31605 7.78204C9.234 7.86409 9.18791 7.97537 9.18791 8.0914C9.18791 8.20743 9.234 8.31871 9.31605 8.40076C9.3981 8.48281 9.50938 8.5289 9.62541 8.5289H10.0629C10.2058 8.52869 10.3485 8.51846 10.49 8.49828C10.4537 8.83442 10.3207 9.15284 10.1073 9.41504C9.89379 9.67723 9.60894 9.87198 9.28715 9.97573C8.96536 10.0795 8.6204 10.0878 8.29398 9.99965C7.96756 9.91151 7.67367 9.73071 7.44783 9.47909C7.22198 9.22748 7.07386 8.91583 7.02138 8.58182C6.96889 8.24781 7.01428 7.90575 7.15206 7.597C7.28985 7.28824 7.51412 7.02601 7.79777 6.842C8.08142 6.658 8.4123 6.5601 8.75041 6.56015C8.86644 6.56015 8.97772 6.51406 9.05977 6.43201C9.14182 6.34996 9.18791 6.23868 9.18791 6.12265C9.18791 6.00662 9.14182 5.89534 9.05977 5.81329C8.97772 5.73124 8.86644 5.68515 8.75041 5.68515C8.10426 5.68467 7.48083 5.92353 7.00041 6.35562V2.62265C7.00041 2.15852 7.18478 1.7134 7.51297 1.38521C7.84116 1.05702 8.28628 0.87265 8.75041 0.87265C9.21454 0.87265 9.65966 1.05702 9.98785 1.38521C10.316 1.7134 10.5004 2.15852 10.5004 2.62265V2.9907C10.5004 3.08112 10.5285 3.16933 10.5807 3.24317C10.6329 3.31701 10.7067 3.37286 10.7919 3.40304C11.2791 3.57456 11.6899 3.91293 11.9515 4.35824C12.2131 4.80355 12.3088 5.32708 12.2215 5.83614C12.1342 6.3452 11.8696 6.80695 11.4745 7.13964C11.0794 7.47233 10.5794 7.6545 10.0629 7.6539ZM10.9379 4.81015C10.9379 4.92618 10.8918 5.03746 10.8098 5.11951C10.7277 5.20156 10.6164 5.24765 10.5004 5.24765H10.2817C9.75951 5.24765 9.25876 5.04023 8.88954 4.67102C8.52033 4.3018 8.31291 3.80105 8.31291 3.2789V3.06015C8.31291 2.94412 8.359 2.83284 8.44105 2.75079C8.5231 2.66874 8.63438 2.62265 8.75041 2.62265C8.86644 2.62265 8.97772 2.66874 9.05977 2.75079C9.14182 2.83284 9.18791 2.94412 9.18791 3.06015V3.2789C9.18791 3.56898 9.30314 3.84718 9.50826 4.0523C9.71338 4.25742 9.99158 4.37265 10.2817 4.37265H10.5004C10.6164 4.37265 10.7277 4.41874 10.8098 4.50079C10.8918 4.58284 10.9379 4.69412 10.9379 4.81015ZM2.84416 5.24765H2.62541C2.50938 5.24765 2.3981 5.20156 2.31605 5.11951C2.234 5.03746 2.18791 4.92618 2.18791 4.81015C2.18791 4.69412 2.234 4.58284 2.31605 4.50079C2.3981 4.41874 2.50938 4.37265 2.62541 4.37265H2.84416C3.13424 4.37265 3.41244 4.25742 3.61756 4.0523C3.82268 3.84718 3.93791 3.56898 3.93791 3.2789V3.06015C3.93791 2.94412 3.984 2.83284 4.06605 2.75079C4.1481 2.66874 4.25938 2.62265 4.37541 2.62265C4.49144 2.62265 4.60272 2.66874 4.68477 2.75079C4.76682 2.83284 4.81291 2.94412 4.81291 3.06015V3.2789C4.81291 3.80105 4.60549 4.3018 4.23628 4.67102C3.86706 5.04023 3.3663 5.24765 2.84416 5.24765Z",fill:"currentColor",transform:"translate(0.5, 1.5)"})}),oa=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
+ `]),la=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?de([`
27
+ flex-direction: column;
28
+ align-items: flex-start;
29
+ `]):de([`
30
+ align-items: center;
31
+ justify-content: space-between;
32
+ padding: 0.4rem;
33
+ `]),({$abort:a})=>a&&de([`
34
+ opacity: 0.7;
35
+ `])),kt=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
+ `],o("contentSecondary"),({$expanded:a})=>a?"90deg":"0deg"),It=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
+ `],o("contentSecondary"),({$isActive:a})=>a&&Wt,({$isTopLevel:a})=>a&&de([`
60
+ color: `,`;
61
+ `],o("contentPrimary"))),da=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&&de([`
70
+ padding: 0.4rem;
71
+ `]),({$expanded:a})=>!a&&de([`
72
+ min-height: 0;
73
+ min-width: 0;
74
+ `]),({$isExpandable:a})=>a&&de([`
75
+ cursor: pointer;
76
+ user-select: none;
77
+ border-radius: 0.4rem;
78
+ transition: background-color 120ms ease;
79
+
80
+ &:hover {
81
+ background: `,`;
82
+ }
83
+
84
+ &:focus-visible {
85
+ outline: 1px solid
86
+ `,`;
87
+ outline-offset: 2px;
88
+ }
89
+
90
+ &:hover `,", &:hover ",` {
91
+ color: `,`;
92
+ }
93
+ `],o("surfaceRaised"),({theme:n})=>Ot(n.color.statusInfo),It,kt,o("contentPrimary"))),Et=i.div.withConfig({displayName:"AssistantModesCompact__ExpandableWrapper"})([`
94
+ display: grid;
95
+ grid-template-rows: `,`;
96
+ transition:
97
+ grid-template-rows 0.1s ease-out,
98
+ opacity 0.3s ease-out;
99
+ width: 100%;
100
+
101
+ `,`
102
+ `],({$expanded:a})=>a?"1fr":"0fr",({$expanded:a})=>!a&&de([`
103
+ height: 0;
104
+ opacity: 0;
105
+ `])),Nt=i.div.withConfig({displayName:"AssistantModesCompact__ExpandableContent"})([`
106
+ min-height: 0;
107
+ overflow: hidden;
108
+ `]),Xn=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningThread"})([`
109
+ display: flex;
110
+ flex-direction: column;
111
+ gap: 0.8rem;
112
+ align-items: flex-start;
113
+ padding: 0 2.8rem;
114
+ `]),ct=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningItem"})([`
115
+ display: flex;
116
+ gap: 0.5rem;
117
+ align-items: center;
118
+ padding: 0.4rem;
119
+ padding-left: 0;
120
+ `]),et=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningIcon"})([`
121
+ width: 1.4rem;
122
+ height: 1.4rem;
123
+ flex-shrink: 0;
124
+ display: flex;
125
+ align-items: center;
126
+ justify-content: center;
127
+ color: `,`;
128
+ `],o("contentPrimary")),ht=i.div.withConfig({displayName:"AssistantModesCompact__ReasoningText"})([`
129
+ display: flex;
130
+ flex-wrap: wrap;
131
+ gap: 0.4rem;
132
+ align-items: center;
133
+ min-height: 0;
134
+ min-width: 0;
135
+ `]),ie=i.span.withConfig({displayName:"AssistantModesCompact__ReasoningTextPart"})([`
136
+ font-weight: 400;
137
+ font-size: 1.4rem;
138
+ color: `,`;
139
+ `],o("contentSecondary")),qe=i.div.withConfig({displayName:"AssistantModesCompact__CodeBadge"})([`
140
+ background: `,`;
141
+ border: 1px solid `,`;
142
+ border-radius: 0.4rem;
143
+ padding: 0 0.4rem;
144
+ display: flex;
145
+ align-items: center;
146
+ justify-content: center;
147
+ transform: translateY(1px);
148
+ `],o("surfaceRaised"),o("interactionNeutral")),Te=i.span.withConfig({displayName:"AssistantModesCompact__CodeBadgeText"})([`
149
+ font-family: `,`;
150
+ font-size: 1.2rem;
151
+ color: `,`;
152
+ `],({theme:a})=>a.fontMonospace,o("statusFeature")),ca=i(Pa).withConfig({displayName:"AssistantModesCompact__CheckIcon"})([`
153
+ width: 1.6rem;
154
+ height: 1.6rem;
155
+ color: `,`;
156
+ flex-shrink: 0;
157
+ `],o("aiPinkStart")),Jn=i(Qt).withConfig({displayName:"AssistantModesCompact__CloseCircleIcon"})([`
158
+ color: `,`;
159
+ flex-shrink: 0;
160
+ `],o("statusDanger")),ei=i.div.withConfig({displayName:"AssistantModesCompact__CollapsedSectionsWrapper"})([`
161
+ display: flex;
162
+ flex-direction: column;
163
+ gap: 0.8rem;
164
+ padding-left: 2.8rem;
165
+ `]),ti=i.span.withConfig({displayName:"AssistantModesCompact__DurationText"})([`
166
+ font-size: 1.2rem;
167
+ color: `,`;
168
+ font-family: `,`;
169
+ font-weight: 400;
170
+ flex-shrink: 0;
171
+ transform: translateY(1px);
172
+ `],o("contentMuted"),({theme:a})=>a.fontMonospace),ai=(a,n)=>{if(a===we.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},ni=i.div.withConfig({displayName:"AssistantModesCompact__ThinkingContent"})([`
173
+ font-size: 1.3rem;
174
+ color: `,`;
175
+ padding: 0 2.8rem;
176
+ white-space: pre-wrap;
177
+ word-break: break-word;
178
+ opacity: 0.7;
179
+ `],o("contentSecondary")),ha=({operationHistory:a,status:n,isLive:r=!1,onScrollNeeded:c,collapsed:u=!1,endTimestamp:p})=>{const f=Mt(),[k,v]=t.useState({}),[H,w]=t.useState(!1),A=t.useRef(0),b=t.useRef(null),m=t.useMemo(()=>za(a,n,r),[a,n,r]),S=t.useRef(r);t.useEffect(()=>{if(S.current&&!r){const d={};m.forEach(y=>{d[y.id]=!0}),v(d)}else if(r&&m.length>A.current){const d={};m.forEach((y,h)=>{h<m.length-1&&(d[y.id]=!0)}),v(d),c==null||c()}A.current=m.length,S.current=r},[m,r,c]);const l=d=>{v(y=>{const h=m.find(E=>E.id===d),R=h?$t(h):!1,Y=m.findIndex(E=>E.id===d)===m.length-1,D=u?!1:r?Y:!0;return y[d]===void 0?{...y,[d]:D&&R}:{...y,[d]:!y[d]}})},j=t.useMemo(()=>{var h,R;if(a.length===0)return null;const d=(h=a[0])==null?void 0:h.timestamp,y=p??((R=a[a.length-1])==null?void 0:R.timestamp);return!d||!y||d===y?null:Fa(y-d)},[a,p]);if(a.length===0)return null;const z=m.map((d,y)=>{var q;const h=$t(d),R=y===m.length-1,Y=u?!1:r?R:!0,D=k[d.id]===void 0?Y&&h:!k[d.id]&&h,E=m[y+1],N=$a(d,E,E?void 0:p),F=d.type===we.Thinking||d.type===we.RunningQuery,V=F?((q=d.operations[0])==null?void 0:q.content)??"":"";return e.jsxs(la,{$expanded:D,$abort:d.abort,children:[e.jsxs(da,{$expanded:D,$isExpandable:h,"data-hook":`assistant-mode-${d.type.toLowerCase().replace(/\s+/g,"-")}`,role:h?"button":"presentation",tabIndex:h?0:void 0,"aria-expanded":h?D:void 0,onClick:h?()=>l(d.id):void 0,onKeyDown:h?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),l(d.id))}:void 0,children:[e.jsx(et,{children:d.active?e.jsx(bt,{size:14}):d.abort?e.jsx(Jn,{size:14}):e.jsx(ca,{})}),e.jsxs(Z,{gap:"0.3rem",children:[e.jsx(It,{$isActive:d.active,children:d.type}),N&&e.jsxs(ti,{children:["(",N,")"]}),h&&e.jsx(kt,{$expanded:D,children:e.jsx(Bt,{size:14})})]})]}),h&&F&&e.jsx(Et,{$expanded:D,children:e.jsx(Nt,{children:V?e.jsx(ni,{children:V}):null})}),h&&!F&&e.jsx(Et,{$expanded:D,children:e.jsx(Nt,{children:e.jsx(Xn,{children:d.operations.map((M,Ie)=>{const ee=`${d.id}-${Ie}-${JSON.stringify(M.args)}`;if(M.type===we.Processing){const W=ai(M.type,M.args);return e.jsxs(ct,{children:[e.jsx(et,{children:e.jsx(Gn,{style:{width:"14px",height:"14px"}})}),e.jsx(ht,{children:e.jsx(ie,{children:W})})]},ee)}if(M.type===we.InvestigatingTable){const W=M.args&&"name"in M.args?M.args.name:"table",G=M.args&&"tableOpType"in M.args?M.args.tableOpType:"details";return e.jsxs(ct,{children:[e.jsx(et,{children:e.jsx(Ba,{size:14,color:f.color.contentSecondary})}),e.jsxs(ht,{children:[e.jsx(ie,{children:"Investigating"}),e.jsx(qe,{children:e.jsx(Te,{children:W})}),e.jsx(ie,{children:G})]})]},ee)}if(M.type===we.InvestigatingDocs){const W=M.args&&"items"in M.args&&Array.isArray(M.args.items)?M.args.items:null;if(W&&W.length>0)return e.jsx(dt.Fragment,{children:W.map((pe,je)=>{const X=`${ee}-item-${je}`;return e.jsxs(ct,{children:[e.jsx(et,{children:e.jsx(Pt,{size:14,color:f.color.contentSecondary})}),e.jsx(ht,{children:pe.section?e.jsxs(e.Fragment,{children:[e.jsx(ie,{children:"Investigating"}),e.jsx(qe,{children:e.jsx(Te,{children:pe.section})}),e.jsx(ie,{children:"in"}),e.jsx(qe,{children:e.jsx(Te,{children:pe.name})})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{children:"Investigating"}),e.jsx(qe,{children:e.jsx(Te,{children:pe.name})})]})})]},X)})},ee);const G=M.args&&"name"in M.args?M.args.name:null,ve=M.args&&"section"in M.args?M.args.section:null;return e.jsxs(ct,{children:[e.jsx(et,{children:e.jsx(Pt,{size:14})}),e.jsx(ht,{children:G&&ve?e.jsxs(e.Fragment,{children:[e.jsx(ie,{children:"Investigating"}),e.jsx(qe,{children:e.jsx(Te,{children:ve})}),e.jsx(ie,{children:"in"}),e.jsx(qe,{children:e.jsx(Te,{children:G})}),e.jsx(ie,{children:"documentation"})]}):G?e.jsxs(e.Fragment,{children:[e.jsx(ie,{children:"Investigating"}),e.jsx(qe,{children:e.jsx(Te,{children:G})}),e.jsx(ie,{children:"documentation"})]}):e.jsx(ie,{children:"Investigating documentation"})})]},ee)}return null})})})})]},d.id)});return u?e.jsx(oa,{ref:b,"data-hook":"assistant-modes-container",children:e.jsxs(la,{$expanded:H,$abort:!1,children:[e.jsxs(da,{$expanded:H,$isExpandable:!0,onClick:()=>w(d=>!d),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),w(y=>!y))},"data-hook":"assistant-mode-processing-collapsed",role:"button",tabIndex:0,"aria-expanded":H,children:[e.jsx(ca,{}),e.jsx(It,{$isActive:!1,children:j?`Thought for ${j}`:"Thought"}),e.jsx(kt,{$expanded:H,children:e.jsx(Bt,{size:14})})]}),e.jsx(Et,{$expanded:H,children:e.jsx(Nt,{children:e.jsx(ei,{children:z})})})]})}):e.jsx(oa,{ref:b,"data-hook":"assistant-modes-container",children:z})},ii=i.div.withConfig({displayName:"AssistantMarkdown__CodeBlockWrapper"})([`
180
+ margin: 1rem 0;
181
+ width: 100%;
182
+ `]),si=i.div.withConfig({displayName:"AssistantMarkdown__MarkdownContent"})([`
183
+ margin: 0;
184
+ width: 100%;
185
+ font-family: `,`;
186
+ font-size: 1.4rem;
187
+ line-height: 2.1rem;
188
+ color: `,`;
189
+ word-break: break-word;
190
+
191
+ p {
192
+ margin: 0 0 1rem 0;
193
+ &:last-child {
194
+ margin-bottom: 0;
195
+ }
196
+ }
197
+
198
+ code {
199
+ background: `,`;
200
+ border: 1px solid `,`;
201
+ border-radius: 0.4rem;
202
+ padding: 0.1rem 0.4rem;
203
+ font-family: `,`;
204
+ font-size: 1.3rem;
205
+ color: `,`;
206
+ white-space: pre-wrap;
207
+ }
208
+
209
+ strong {
210
+ font-weight: 600;
211
+ color: `,`;
212
+ }
213
+
214
+ em {
215
+ font-style: italic;
216
+ }
217
+
218
+ ul,
219
+ ol {
220
+ margin: 0.5rem 0;
221
+ padding-left: 2rem;
222
+ }
223
+
224
+ li {
225
+ margin-bottom: 0.3rem;
226
+ }
227
+
228
+ a {
229
+ color: `,`;
230
+ text-decoration: none;
231
+ &:hover {
232
+ text-decoration: underline;
233
+ }
234
+ }
235
+
236
+ h1,
237
+ h2,
238
+ h3,
239
+ h4 {
240
+ margin: 1rem 0 0.5rem 0;
241
+ font-weight: 600;
242
+ }
243
+
244
+ h1 {
245
+ font-size: 1.8rem;
246
+ }
247
+ h2 {
248
+ font-size: 1.6rem;
249
+ }
250
+ h3 {
251
+ font-size: 1.5rem;
252
+ }
253
+ h4 {
254
+ font-size: 1.4rem;
255
+ }
256
+
257
+ blockquote {
258
+ border-left: 3px solid `,`;
259
+ margin: 1rem 0;
260
+ padding-left: 1rem;
261
+ color: `,`;
262
+ }
263
+
264
+ .table-wrapper {
265
+ overflow-x: auto;
266
+ margin: 1rem 0;
267
+ }
268
+
269
+ table {
270
+ border-collapse: collapse;
271
+ min-width: max-content;
272
+ border-radius: 0.8rem;
273
+ }
274
+
275
+ th,
276
+ td {
277
+ padding: 0.6rem 0.8rem;
278
+ border: 1px solid `,`;
279
+ text-align: left;
280
+ white-space: nowrap;
281
+ }
282
+
283
+ th {
284
+ background: `,`;
285
+ font-weight: 600;
286
+ }
287
+
288
+ td:last-child {
289
+ white-space: normal;
290
+ min-width: 200px;
291
+ }
292
+ `],({theme:a})=>a.font,o("contentPrimary"),o("surfaceInset"),o("interactionNeutral"),({theme:a})=>a.fontMonospace,o("statusFeature"),o("contentPrimary"),({theme:a})=>a.color.statusInfo,o("interactionNeutral"),o("contentSecondary"),o("interactionNeutral"),o("surfaceInset")),ri=a=>({table:({children:n,...r})=>e.jsx("div",{className:"table-wrapper",children:e.jsx("table",{...r,children:n})}),pre:({children:n})=>e.jsx(e.Fragment,{children:n}),code:t.memo(({children:n,className:r})=>{if(typeof r=="string"&&r.includes("language-")){const c=(Array.isArray(n)?n.join(""):typeof n=="string"?n:"").replace(/\n$/,"");return e.jsx(ii,{"data-hook":"chat-message-code-block",children:e.jsx(Ke,{value:c,maxHeight:216,onOpenInEditor:()=>{var u;(u=a.current)==null||u.call(a,{type:"code",value:c})}})})}return e.jsx("code",{children:n})},(n,r)=>n.children===r.children&&n.className===r.className)}),ma=t.memo(({content:a,messageId:n,onOpenInEditor:r})=>{const c=t.useRef(r);t.useEffect(()=>{c.current=r},[r]);const u=t.useMemo(()=>ri(c),[]);return e.jsx(si,{children:e.jsx(Oa,{allowImages:!0,components:u,children:a})},n)},(a,n)=>a.content===n.content);function ua(a){return a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toString()}const pa=i.div.withConfig({displayName:"AssistantMessageContent__Divider"})([`
293
+ width: 100%;
294
+ height: 1px;
295
+ background: linear-gradient(
296
+ 90deg,
297
+ `,` 0%,
298
+ `,` 100%
299
+ );
300
+ margin-bottom: 1rem;
301
+ `],({theme:a})=>vt(a.color.aiPinkStart,.42),({theme:a})=>a.color.transparent),ga=i.div.withConfig({displayName:"AssistantMessageContent__OperationHistoryContainer"})([`
302
+ width: 100%;
303
+ `]),oi=i(Z).attrs({alignItems:"center",gap:"1rem"}).withConfig({displayName:"AssistantMessageContent__AssistantHeader"})([`
304
+ width: 100%;
305
+ padding: 1.2rem 0.4rem;
306
+ flex: 1 0 auto;
307
+ `]),li=i(le).attrs({className:"assistant-label"}).withConfig({displayName:"AssistantMessageContent__AssistantLabel"})([`
308
+ font-size: 1.4rem;
309
+ color: `,`;
310
+ `],o("contentPrimary")),di=i(Z).attrs({className:"token-display"}).withConfig({displayName:"AssistantMessageContent__TokenDisplay"})([`
311
+ align-items: center;
312
+ gap: 0.9rem;
313
+ margin: 0 0 0 auto;
314
+ `]),fa=i(Z).withConfig({displayName:"AssistantMessageContent__ExplanationContent"})([`
315
+ display: flex;
316
+ flex-direction: column;
317
+ border-radius: 0.6rem;
318
+ padding: 0 0.8rem;
319
+ flex-shrink: 0;
320
+ width: 100%;
321
+ `]),ci=Ln([`
322
+ 0%, 50% { opacity: 1; }
323
+ 51%, 100% { opacity: 0; }
324
+ `]),xa=i.span.withConfig({displayName:"AssistantMessageContent__StreamingCursor"})([`
325
+ display: inline-block;
326
+ width: 2px;
327
+ height: 1.4em;
328
+ background: `,`;
329
+ margin-left: 2px;
330
+ margin-right: auto;
331
+ vertical-align: text-bottom;
332
+ animation: `,` 1s infinite;
333
+ `],o("contentPrimary"),ci),hi=t.memo(({turnMessages:a,anchorMessage:n,status:r,isLiveOperation:c,isMessageStreaming:u,onScrollNeeded:p,onOpenInEditor:f})=>{const k=Mt(),{operationHistory:v,endTimestamp:H,timeline:w}=t.useMemo(()=>{const l=n.operationHistory??[],j=l.filter(y=>y.type!==we.Aborted),z=l.length>0?Math.max(...l.map(y=>y.timestamp)):void 0,d=j.some(y=>{var h;return y.type===we.GeneratingResponse&&!!((h=y.content)!=null&&h.trim())});return{operationHistory:j.filter(y=>y.type!==we.GeneratingResponse),endTimestamp:z,timeline:d?Qa(j):null}},[n.operationHistory]),A=t.useMemo(()=>a.filter(l=>l.role==="assistant"&&typeof l.content=="string"&&!!l.content).map(l=>l.content).join(`
334
+
335
+ `),[a]),b=!!A,m=t.useMemo(()=>{const l=n.tokenUsage;return!l||typeof l.inputTokens!="number"||typeof l.outputTokens!="number"?null:e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontWeight:600},children:ua(l.inputTokens)})," ","input /"," ",e.jsx("span",{style:{fontWeight:600},children:ua(l.outputTokens)})," ","output tokens"]})},[n.tokenUsage]),S=e.jsxs(oi,{"data-hook":"assistant-header",children:[e.jsx(st,{size:20,variant:"filled"}),e.jsx(li,{children:n.model||"Assistant"}),m&&e.jsxs(di,{className:"token-display",children:[e.jsx(na,{size:"16px",color:k.color.contentSecondary}),e.jsx(le,{size:"sm",color:"contentSecondary",children:m})]})]});if(w&&w.length>0){let l=!1;return e.jsxs(e.Fragment,{children:[w.map((j,z)=>{const d=z===w.length-1;if(j.type==="operations")return e.jsxs(dt.Fragment,{children:[z===0&&e.jsx(pa,{}),e.jsx(ga,{children:e.jsx(ha,{operationHistory:j.operations,status:r,isLive:c&&d,onScrollNeeded:p,collapsed:!d,endTimestamp:j.endTimestamp})})]},`ops-${j.timestamp}`);const y=!l;return l=!0,e.jsxs(dt.Fragment,{children:[y&&S,e.jsx(fa,{children:e.jsx(ma,{content:j.content,messageId:n.id,onOpenInEditor:f})})]},`content-${j.timestamp}`)}),u&&e.jsx(xa,{"data-hook":"streaming-cursor"})]})}return e.jsxs(e.Fragment,{children:[v.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(pa,{}),e.jsx(ga,{children:e.jsx(ha,{operationHistory:v,status:r,isLive:c,onScrollNeeded:p,collapsed:b||!!n.error,endTimestamp:H})})]}),b&&e.jsxs(e.Fragment,{children:[S,e.jsxs(fa,{children:[e.jsx(ma,{content:A,messageId:n.id,onOpenInEditor:f}),u&&e.jsx(xa,{"data-hook":"streaming-cursor"})]})]})]})},(a,n)=>{const r=a.turnMessages[a.turnMessages.length-1],c=n.turnMessages[n.turnMessages.length-1];return r===c&&a.anchorMessage===n.anchorMessage&&a.status===n.status&&a.isLiveOperation===n.isLiveOperation&&a.isMessageStreaming===n.isMessageStreaming}),mi=i(Z).withConfig({displayName:"ChatMessages__MessagesContainer"})([`
336
+ display: flex;
337
+ flex-direction: column;
338
+ gap: 1.5rem;
339
+ padding: 2rem 1rem;
340
+ overflow-y: auto;
341
+ flex: 1 1 auto;
342
+ min-height: 0;
343
+ width: 100%;
344
+ `,`
345
+ `],({$scrolled:a})=>!a&&de([`
346
+ opacity: 0;
347
+ `])),ui=i(Z).attrs({align:"flex-start"}).withConfig({displayName:"ChatMessages__MessageBubble"})([`
348
+ display: flex;
349
+ flex-direction: column;
350
+ gap: 0.5rem;
351
+ padding: 0.8rem;
352
+ border-radius: 0.8rem;
353
+ width: 100%;
354
+ align-self: flex-end;
355
+ background: `,`;
356
+ border: 1px solid `,`;
357
+ flex-shrink: 0;
358
+ `],({theme:a})=>a.mode==="light"?a.color.surfaceValue:a.color.authBackdrop,o("borderDefault")),ya=i(Z).withConfig({displayName:"ChatMessages__UserRequestBox"})([`
359
+ display: flex;
360
+ flex-direction: column;
361
+ gap: 0.5rem;
362
+ padding: 0.8rem;
363
+ width: 100%;
364
+ align-self: flex-end;
365
+ background: `,`;
366
+ border: 1px solid `,`;
367
+ border-radius: 0.6rem;
368
+ flex-shrink: 0;
369
+ `],({theme:a})=>a.mode==="light"?a.color.surfaceValue:a.color.authBackdrop,o("borderDefault")),pi=i(Z).attrs({alignItems:"center",gap:"0.8rem"}).withConfig({displayName:"ChatMessages__UserRequestHeader"})([`
370
+ width: 100%;
371
+ padding: 0.4rem;
372
+ flex: 1 0 auto;
373
+ `]),mt=i(Z).withConfig({displayName:"ChatMessages__UserRequestContent"})([`
374
+ display: flex;
375
+ flex-direction: column;
376
+ border-radius: 0.6rem;
377
+ overflow: hidden;
378
+ flex-shrink: 0;
379
+ width: 100%;
380
+ align-items: flex-start;
381
+ `]),Ca=i.div.withConfig({displayName:"ChatMessages__InlineSQLEditor"})([`
382
+ width: 100%;
383
+ `]),gi=i(Z).attrs({gap:"1rem",alignItems:"center"}).withConfig({displayName:"ChatMessages__OperationBadge"})([`
384
+ width: 100%;
385
+ padding: 0 0.4rem;
386
+ `]),fi=i(Z).attrs({align:"center",justifyContent:"center"}).withConfig({displayName:"ChatMessages__BadgeIconContainer"})([`
387
+ background: `,`;
388
+ border: 1px solid `,`;
389
+ border-radius: 0.4rem;
390
+ padding: 0.8rem;
391
+ width: 4.8rem;
392
+ height: 4rem;
393
+ flex-shrink: 0;
394
+ `],({theme:a})=>vt(a.color.aiPinkStart,.12),({theme:a})=>vt(a.color.aiPinkStart,.42)),xi=i.div.withConfig({displayName:"ChatMessages__BadgeIconWrapper"})([`
395
+ width: 2.4rem;
396
+ height: 2.4rem;
397
+ display: flex;
398
+ align-items: center;
399
+ justify-content: center;
400
+ color: `,`;
401
+
402
+ svg {
403
+ width: 100%;
404
+ height: 100%;
405
+ }
406
+ `],({theme:a})=>a.color.aiPinkStart),yi=i(le).withConfig({displayName:"ChatMessages__BadgeTitle"})([`
407
+ font-weight: 500;
408
+ font-size: 1.6rem;
409
+ line-height: 1.6rem;
410
+ color: `,`;
411
+ `],o("contentPrimary")),Ci=i(Z).withConfig({displayName:"ChatMessages__BadgeDescriptionContainer"})([`
412
+ align-items: flex-start;
413
+ flex-direction: column;
414
+ padding: 0.8rem;
415
+ width: 100%;
416
+ `]),wi=i(le).withConfig({displayName:"ChatMessages__BadgeDescriptionText"})([`
417
+ font-size: 1.4rem;
418
+ line-height: 2.1rem;
419
+ color: `,`;
420
+ `],o("contentPrimary")),bi=i(le).withConfig({displayName:"ChatMessages__BadgeDescriptionIssueText"})([`
421
+ font-size: 1.4rem;
422
+ line-height: 2.1rem;
423
+ font-weight: 600;
424
+ `]),vi=i(Z).withConfig({displayName:"ChatMessages__IssueMessageRow"})([`
425
+ display: flex;
426
+ align-items: center;
427
+ gap: 0.5rem;
428
+ `]),wa=i(oe).attrs({variant:"tertiary"}).withConfig({displayName:"ChatMessages__SchemaNameDisplay"})([`
429
+ margin-left: 0.4rem;
430
+ padding: 0.5rem 1rem;
431
+ align-items: center;
432
+ gap: 1rem;
433
+ border-radius: 0.6rem;
434
+ `]),ba=i(le).withConfig({displayName:"ChatMessages__SchemaName"})([`
435
+ font-size: 1.4rem;
436
+ color: `,`;
437
+ `],o("contentPrimary")),va=i(le).withConfig({displayName:"ChatMessages__MessageContent"})([`
438
+ font-size: 1.4rem;
439
+ line-height: 1.8rem;
440
+ color: `,`;
441
+ white-space: pre-wrap;
442
+ word-wrap: break-word;
443
+ `],o("contentPrimary")),ji=i(Z).withConfig({displayName:"ChatMessages__ExplanationBox"})([`
444
+ display: flex;
445
+ flex-direction: column;
446
+ gap: 0.8rem;
447
+ width: 100%;
448
+ align-self: flex-start;
449
+ text-align: left;
450
+ background: transparent;
451
+ padding: 0.4rem;
452
+ border-radius: 0.6rem;
453
+ flex-shrink: 0;
454
+
455
+ `,`
456
+
457
+ .assistant-label,
458
+ .token-display {
459
+ transition: opacity 0.2s;
460
+ opacity: 0;
461
+ }
462
+
463
+ &:hover,
464
+ &:focus-within {
465
+ .assistant-label,
466
+ .token-display {
467
+ opacity: 1;
468
+ }
469
+ }
470
+ `],({$hasOperationHistory:a})=>a&&de([`
471
+ padding-top: 0;
472
+ `])),Ai=i.div.withConfig({displayName:"ChatMessages__ErrorContainer"})([`
473
+ display: flex;
474
+ align-items: center;
475
+ flex-shrink: 0;
476
+ gap: 0.5rem;
477
+ padding: 0.4rem 0.4rem 0.4rem 0.8rem;
478
+ border: 1px solid `,`;
479
+ border-radius: 0.6rem;
480
+ color: `,`;
481
+ font-size: 1.4rem;
482
+ line-height: 2rem;
483
+ width: 100%;
484
+ `],o("statusDanger"),o("contentPrimary")),_i=i(oe).withConfig({displayName:"ChatMessages__RetryButton"})([`
485
+ margin-left: auto;
486
+ flex-shrink: 0;
487
+ padding: 0.5rem 0.8rem;
488
+ height: auto;
489
+ `]),Mi=i.div.withConfig({displayName:"ChatMessages__MessagesEnd"})([`
490
+ min-height: 1px;
491
+ width: 100%;
492
+ background: transparent;
493
+ `]),Hi=i(Z).withConfig({displayName:"ChatMessages__DiffContainer"})([`
494
+ display: flex;
495
+ flex-direction: column;
496
+ gap: 1rem;
497
+ margin-top: 1rem;
498
+ padding: 0.8rem 1.2rem;
499
+ border: 1px solid `,`;
500
+ border-radius: 0.8rem;
501
+ background: `,`;
502
+ width: 100%;
503
+ `],o("interactionNeutral"),o("surfaceInset")),ki=i(Z).withConfig({displayName:"ChatMessages__DiffHeader"})([`
504
+ display: flex;
505
+ align-items: center;
506
+ justify-content: space-between;
507
+ padding-bottom: 0.8rem;
508
+ border-bottom: 1px solid `,`;
509
+ width: 100%;
510
+ `,`
511
+ `],o("interactionNeutralHover"),({$isExpanded:a})=>!a&&de([`
512
+ border-bottom: 0;
513
+ padding-bottom: 0;
514
+ `])),Ii=i(Z).withConfig({displayName:"ChatMessages__DiffHeaderLeft"})([`
515
+ display: flex;
516
+ align-items: center;
517
+ gap: 1rem;
518
+ padding: 0.4rem 0;
519
+ `]),Ei=i.span.withConfig({displayName:"ChatMessages__DiffHeaderLabel"})([`
520
+ font-size: 1.4rem;
521
+ color: `,`;
522
+ `],o("contentSecondary")),Ni=i(Z).withConfig({displayName:"ChatMessages__DiffHeaderRight"})([`
523
+ display: flex;
524
+ align-items: center;
525
+ gap: 1.8rem;
526
+ margin-left: auto;
527
+ `]),ja=i(Z).withConfig({displayName:"ChatMessages__DiffHeaderStatus"})([`
528
+ display: flex;
529
+ align-items: center;
530
+ gap: 0.8rem;
531
+ color: `,`;
532
+ font-size: 1.3rem;
533
+ `],({$isAccepted:a,$isRejected:n,$isRejectedWithFollowUp:r})=>n?o("statusDanger"):r?o("statusInfo"):a?o("statusSuccessStrong"):o("contentSecondary")),Aa=i.span.withConfig({displayName:"ChatMessages__StatusIcon"})([`
534
+ display: flex;
535
+ align-items: center;
536
+ color: `,`;
537
+ `],({$isAccepted:a,$isRejected:n,$isRejectedWithFollowUp:r})=>n?o("statusDanger"):r?o("statusInfo"):a?o("statusSuccessStrong"):o("contentSecondary")),St=i(ot).withConfig({displayName:"ChatMessages__IconButton"})([`
538
+ color: `,`;
539
+
540
+ &:hover:not(:disabled) {
541
+ svg {
542
+ filter: brightness(1.3);
543
+ }
544
+ }
545
+
546
+ &:disabled {
547
+ opacity: 0.4;
548
+ cursor: not-allowed;
549
+ }
550
+ `],o("contentSecondary")),Si=i(St).withConfig({displayName:"ChatMessages__ExpandButton"})([`
551
+ width: 1.6rem;
552
+ height: 1.6rem;
553
+ `]),Vi=i.div.withConfig({displayName:"ChatMessages__DiffEditorWrapper"})([`
554
+ position: relative;
555
+ width: 100%;
556
+ `]),Zi=i(Z).withConfig({displayName:"ChatMessages__ButtonBar"})([`
557
+ padding: 0.5rem;
558
+ gap: 1rem;
559
+ justify-content: center;
560
+ flex-shrink: 0;
561
+ width: fit-content;
562
+ margin: 0 auto;
563
+ background: `,`;
564
+ border: 1px solid `,`;
565
+ border-radius: 0.4rem;
566
+ `],o("surfaceInset"),o("interactionNeutral")),qi=i(oe).attrs({variant:"primary"}).withConfig({displayName:"ChatMessages__AcceptButton"})([`
567
+ width: 10rem;
568
+ `]),Ti=i(oe).attrs({variant:"secondary"}).withConfig({displayName:"ChatMessages__RejectButton"})([`
569
+ width: 10rem;
570
+ `]),Li=a=>{switch(a){case"fix_request":return{icon:e.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:e.jsx(nn,{size:24}),title:"Explain Query",description:"Explain this query in detail"};case"schema_explain_request":return{icon:e.jsx(an,{size:24}),title:"Explain Schema",description:"Provide an overview, detailed column descriptions and storage details."};case"health_issue_request":return{icon:e.jsx(tn,{size:24}),title:"Health Issue Analysis",description:"Analyze table health issue and provide steps for resolution:"};default:return null}},Ri=(a,n)=>{switch(a){case"loading":return e.jsx(Ut,{size:24,color:n.color.statusDanger});case"success":return e.jsx(ln,{});case"error":return e.jsx(on,{});default:return e.jsx(rn,{})}},Di=({messages:a,onAcceptChange:n,onRejectChange:r,onRunQuery:c,onOpenInEditor:u,onApplyToEditor:p,onRetry:f,onCancelQuery:k,runningQueryKey:v,queryNotifications:H,isOperationInProgress:w,editorSQL:A,isStreaming:b,isLoadingMessages:m,scrollToMessageId:S,onScrollToMessageComplete:l})=>{const j=Mt(),z=Xt(),d=ke(_e.query.getTables),y=t.useRef(null),h=t.useRef(null),R=t.useRef(new Map),{status:Y}=Re(),[D,E]=t.useState(!1),N=t.useRef(!1),F=t.useCallback(()=>{if(D&&N.current||S)return;const I=D?"smooth":"instant";setTimeout(()=>{var g;(g=y.current)==null||g.scrollIntoView({behavior:I}),E(!0)})},[D,S]),V=t.useCallback(I=>{const g=d.find(O=>O.table_name===I.tableName&&rt(O)===I.kind);g&&z(jt.console.pushSidebarHistory({type:"tableDetails",payload:{tableName:g.table_name,kind:rt(g)}}))},[d]);t.useEffect(()=>{const I=h.current;if(!I)return;const g=()=>{N.current=!0};return I.addEventListener("wheel",g),()=>I.removeEventListener("wheel",g)},[]),t.useEffect(()=>{N.current=!1},[a.length]);const q=t.useMemo(()=>{for(let I=a.length-1;I>=0;I--){const g=a[I];if(g.role==="assistant"&&g.sql)return I}return-1},[a]),M=t.useRef(q>=0?q:-1),[Ie,ee]=t.useState(q>=0?new Set([q]):new Set);t.useEffect(()=>{q>=0&&q!==M.current&&(ee(I=>new Set([...I,q])),M.current=q)},[q]);const{visibleEntries:W,lastAssistantAnchorIndex:G,lastVisibleUserIndex:ve}=t.useMemo(()=>Wa(a),[a]),pe=t.useMemo(()=>Ka(b,a),[b,a]);t.useEffect(()=>{F()},[pe,F]),t.useLayoutEffect(()=>{if(!S||m)return;const I=R.current.get(S);if(I){const g=setTimeout(()=>{I.scrollIntoView({behavior:"smooth",block:"start"}),E(!0),l()},100);return()=>clearTimeout(g)}},[S,m,l]),t.useEffect(()=>()=>{l()},[]);const je=W[W.length-1],X=W.length>0?je.type==="user"?je.index:je.anchorIndex:-1,Fe=G;return e.jsxs(mi,{ref:h,$scrolled:D,role:"log","data-hook":"chat-messages-container",children:[W.map(I=>{var tt,We,J;if(I.type==="user"){const{message:_}=I,K=`${_.id}`,ge=(tt=_.displayHealthIssueData)==null?void 0:tt.severity,at=be(_.sql||"")===be(A||""),fe=_.displayType,me=_.sql;if(fe&&fe!=="ask_request"){const P=Li(fe);let xe=null;if(fe==="schema_explain_request"&&_.displaySchemaData){const ae=_.displaySchemaData;xe=e.jsx(mt,{children:e.jsxs(wa,{onClick:()=>V(ae),children:[e.jsx(At,{kind:ae.kind,partitionBy:ae.partitionBy,walEnabled:ae.walEnabled,designatedTimestamp:ae.designatedTimestamp}),e.jsx(ba,{children:ae.tableName})]})})}else if(fe==="health_issue_request"&&_.displayHealthIssueData){const ae=_.displayHealthIssueData;xe=e.jsx(mt,{children:e.jsxs(wa,{children:[e.jsx(At,{kind:"table"}),e.jsx(ba,{children:ae.tableName})]})})}else me&&(xe=e.jsx(mt,{children:e.jsx(Ca,{"data-hook":"user-request-sql-editor",children:e.jsx(Ke,{value:me,maxHeight:216,onOpenInEditor:()=>u({type:"code",value:me},at)})})}));return e.jsxs(ya,{"data-hook":"chat-message-user",ref:ae=>{ae&&R.current.set(_.id,ae)},children:[e.jsxs(gi,{children:[e.jsx(fi,{children:e.jsx(xi,{children:P==null?void 0:P.icon})}),e.jsx(yi,{children:P==null?void 0:P.title})]}),(P==null?void 0:P.description)&&e.jsxs(Ci,{children:[e.jsx(wi,{children:P.description}),fe==="health_issue_request"&&((We=_.displayHealthIssueData)==null?void 0:We.issueMessage)&&e.jsxs(vi,{children:[ge==="critical"?e.jsx(Ua,{size:14,weight:"fill",color:j.color.statusDanger}):e.jsx(Ya,{size:14,weight:"fill",color:j.color.statusWarning}),e.jsx(bi,{color:ge==="critical"?"statusDanger":"statusWarning",children:_.displayHealthIssueData.issueMessage})]})]}),xe]},K)}if(fe==="ask_request"&&me){const P=_.displayUserMessage||_.content||"";return e.jsxs(ya,{"data-hook":"chat-message-user",ref:xe=>{xe&&R.current.set(_.id,xe)},children:[e.jsx(pi,{children:e.jsx(va,{children:P})}),e.jsx(mt,{children:e.jsx(Ca,{"data-hook":"user-request-sql-editor",children:e.jsx(Ke,{value:me,maxHeight:216,onOpenInEditor:()=>u({type:"code",value:me},at)})})})]},K)}return e.jsx(ui,{"data-hook":"chat-message-user",ref:P=>{P&&R.current.set(_.id,P)},children:e.jsx(va,{children:_.displayUserMessage||_.content})},K)}const{anchorMessage:g,anchorIndex:O,turnMessages:$e}=I,Be=`${g.id}`,Pe=be(g.sql||"")===be(A||""),ce=!!g.sql,Ee=ce&&g.previousSQL!==void 0&&be(g.sql||"")===be(g.previousSQL||""),Ne=Ie.has(O),he=g.isAccepted===!0,s=g.isRejected===!0,te=ce&&!he&&!s&&O<ve,Oe=O===X,Ae=b&&Oe,Le=ce&&!Ee&&!he&&!s&&!te&&Oe;let $="neutral";if(g.sql){const _=be(g.sql),K=_t(_);if(v&&K===v)$="loading";else if(H){const ge=(J=H[K])==null?void 0:J.latest;ge&&(ge.type===De.ERROR?$="error":(ge.type===De.SUCCESS||ge.type===De.INFO)&&($="success"))}}const B=Ht(g.previousSQL),Qe=Ht(g.sql),Q=!!g.error,ut=Q&&!b&&!w&&Oe,pt=O===Fe&&w===!0,se=!!g.operationHistory&&g.operationHistory.length>0;return e.jsxs(ji,{$hasOperationHistory:se,"data-hook":"chat-message-assistant",ref:_=>{_&&R.current.set(g.id,_)},children:[e.jsx(hi,{turnMessages:$e,anchorMessage:g,status:Y,isLiveOperation:pt,isMessageStreaming:Ae,onScrollNeeded:F,onOpenInEditor:u}),ce&&!Ae&&e.jsxs(Hi,{"data-hook":"inline-diff-container",children:[e.jsxs(ki,{$isExpanded:Ne,children:[e.jsxs(Ii,{children:[e.jsx(Ga,{size:22,color:j.color.contentSecondary}),e.jsx(Ei,{children:"Suggested change"})]}),Ee&&e.jsxs(ja,{"data-hook":"diff-status-unchanged",children:[e.jsx(Aa,{children:e.jsx(Kt,{size:"14px"})}),"Already accepted"]}),!Ee&&(he||s||te)&&e.jsxs(ja,{$isAccepted:he,$isRejected:s,$isRejectedWithFollowUp:te,"data-hook":s?"diff-status-rejected":te?"diff-status-followed-up":"diff-status-accepted",children:[e.jsx(Aa,{$isAccepted:he,$isRejected:s,$isRejectedWithFollowUp:te,children:s?e.jsx(Xa,{size:"14px"}):te?e.jsx(Jt,{size:"14px"}):e.jsx(Kt,{size:"14px"})}),s?"Rejected":te?"Followed up":"Accepted"]}),e.jsxs(Ni,{children:[e.jsx(St,{label:$==="loading"?"Cancel query":"Run this query",size:"sm",onClick:_=>{_.stopPropagation(),$==="loading"&&g.sql?k==null||k(_t(be(g.sql))):g.sql&&c&&c(g.sql)},title:$==="loading"?"Cancel query":"Run this query","aria-label":$==="loading"?"Cancel query":"Run this query","data-hook":"message-action-run-sql",children:Ri($,j)}),!Le&&p&&!(O===q&&he)&&!Pe&&e.jsx(St,{label:"Apply to editor",size:"sm",onClick:_=>{_.stopPropagation(),g.id&&g.sql&&!w&&(Me(He.AI_EDITOR_SUGGESTION_APPLY),p(g.id,g.sql))},title:"Apply to editor","aria-label":"Apply to editor",disabled:w,"data-hook":"message-action-apply",children:e.jsx(ia,{size:22,color:j.color.contentSecondary})}),e.jsx(Si,{label:Ne?"Collapse diff view":"Expand diff view",size:"sm",title:"Expand diff view","aria-label":Ne?"Collapse diff view":"Expand diff view","aria-expanded":Ne,"data-hook":"diff-expand-button",onClick:()=>{ee(_=>{const K=new Set(_);return K.has(O)?K.delete(O):K.add(O),K})},children:e.jsx(Ja,{})})]})]}),Ne&&e.jsxs(e.Fragment,{children:[e.jsx(Vi,{children:e.jsx(Ke,{diffEditor:!0,original:B,modified:Qe,maxHeight:300,onOpenInEditor:()=>u({type:"diff",original:B??"",modified:Qe??""}),handleScrollNeeded:F})}),Le&&e.jsxs(Zi,{align:"center",justifyContent:"center",children:[r&&g.id&&e.jsx(Ti,{onClick:()=>r(g.id),"data-hook":"message-action-reject",children:"Reject"}),n&&g.id&&e.jsx(qi,{onClick:()=>n(g.id),"data-hook":"message-action-accept",children:"Accept"})]})]})]}),Q&&e.jsxs(Ai,{role:"alert","data-hook":"chat-message-error",children:[e.jsx(Qt,{size:16,color:j.color.statusDanger,style:{flexShrink:0}}),g.error,ut&&f&&e.jsx(_i,{size:"sm",variant:"secondary",prefixIcon:e.jsx(en,{size:12}),onClick:()=>{const _=a.slice(0,O).findLastIndex(K=>K.role==="user");_>=0&&f(a[_].id)},"data-hook":"retry-button",children:"Retry"})]})]},Be)}),e.jsx(Mi,{ref:y,"data-hook":"messages-end"})]})},zi=i(Z).withConfig({displayName:"ChatInput__InputContainer"})([`
571
+ display: flex;
572
+ flex-direction: column;
573
+ align-items: stretch;
574
+ gap: 0.8rem;
575
+ padding: 1rem 1.2rem;
576
+ flex-shrink: 0;
577
+ width: 100%;
578
+ margin-top: auto;
579
+ border-top: 1px solid `,`;
580
+ `],o("interactionNeutral")),Fi=i(Z).withConfig({displayName:"ChatInput__InputWrapper"})([`
581
+ display: flex;
582
+ position: relative;
583
+ width: 100%;
584
+ overflow: hidden;
585
+ `]),$i=i(un).attrs({$tone:"accent"}).withConfig({displayName:"ChatInput__StyledTextArea"})([`
586
+ flex: 1;
587
+ min-height: 8rem;
588
+ max-height: 30rem;
589
+ line-height: 1.3;
590
+ padding: `,`;
591
+ resize: none;
592
+ `],({$hasContext:a})=>a?"4.4rem 4.5rem 1.2rem 1.2rem":"1.2rem 4.5rem 1.2rem 1.2rem"),Bi=i(ot).withConfig({displayName:"ChatInput__SendButton"})([`
593
+ position: absolute;
594
+ right: 0.8rem;
595
+ bottom: 0.8rem;
596
+ `]),Pi=i.div.withConfig({displayName:"ChatInput__ContextBadgeContainer"})([`
597
+ position: absolute;
598
+ padding: 0.8rem;
599
+ top: 2px;
600
+ border-radius: 0.6rem;
601
+ left: 1px;
602
+ width: calc(100% - 0.2rem);
603
+ display: inline-flex;
604
+ `]),Oi=i(oe).attrs(a=>({variant:a.$warn?"dangerGhost":"tertiary"})).withConfig({displayName:"ChatInput__ContextBadge"})([`
605
+ display: flex;
606
+ padding: 0.3rem 0.6rem;
607
+ align-items: center;
608
+ gap: 0.4rem;
609
+ line-height: 1.4;
610
+ border-radius: 0.6rem;
611
+ font-size: 1.3rem;
612
+ user-select: none;
613
+ height: unset;
614
+ `]),Qi=i.div.withConfig({displayName:"ChatInput__ContextBadgeIcon"})([`
615
+ display: flex;
616
+ align-items: center;
617
+ color: `,`;
618
+ flex-shrink: 0;
619
+
620
+ svg {
621
+ color: `,`;
622
+ }
623
+ `],o("contentSecondary"),({$warn:a,theme:n})=>a?n.color.statusDanger:o("contentSecondary")),Wi=i.div.withConfig({displayName:"ChatInput__ThoughtStream"})([`
624
+ display: flex;
625
+ position: relative;
626
+ width: 100%;
627
+ background: `,`;
628
+ border: 1px solid transparent;
629
+ background:
630
+ linear-gradient(`,", ",`)
631
+ padding-box,
632
+ `,` border-box;
633
+ border-radius: 0.6rem;
634
+ height: 4rem;
635
+ `],o("surfaceInset"),o("surfaceInset"),o("surfaceInset"),({theme:a})=>mn(a.color)),Ki=i.div.withConfig({displayName:"ChatInput__ThoughtStreamContent"})([`
636
+ display: flex;
637
+ align-items: center;
638
+ background: `,`;
639
+ gap: 0.8rem;
640
+ width: 100%;
641
+ height: 100%;
642
+ border-radius: 0.6rem;
643
+ padding: 0 1.2rem;
644
+ padding-right: 4.5rem;
645
+ `],o("surfaceInset")),Ui=i.div.withConfig({displayName:"ChatInput__ThoughtText"})([`
646
+ font-weight: 500;
647
+ font-size: 1.4rem;
648
+ color: `,`;
649
+ `,`
650
+ `],o("contentSecondary"),Wt),Yi=i.div.withConfig({displayName:"ChatInput__StopButtonWrapper"})([`
651
+ position: absolute;
652
+ right: 0.8rem;
653
+ top: 50%;
654
+ transform: translateY(-50%);
655
+ `]),Vt=(a,n=30)=>{if(!a)return"";const r=a.trim().replace(/\s+/g," ");return r.length<=n?r:r.slice(0,n)+"..."},Gi=t.forwardRef(({onSend:a,disabled:n=!1,placeholder:r="Ask a question or request a refinement...",contextSQL:c,contextTableId:u,contextNotebook:p,onContextClick:f},k)=>{const[v,H]=t.useState(""),w=t.useRef(null),A=ke(_e.query.getTables),b=t.useMemo(()=>u==null?null:A.find(E=>E.id===u)??null,[u,A]),m=p?Vt(p.label):b!=null&&b.table_name?Vt(b.table_name):c?Vt(c):null,S=!!m,l=p==null?void 0:p.warn,j=p?l==="archived"?"Notebook archived":l==="deleted"?"Notebook deleted":`Attached: ${p.label} \u2014 click to switch`:void 0;t.useImperativeHandle(k,()=>({focus:()=>{var E;(E=w.current)==null||E.focus()}}));const{status:z,abortOperation:d}=Re(),y=ue(z);t.useEffect(()=>{w.current&&(w.current.style.height="auto",w.current.style.height=`${w.current.scrollHeight}px`)},[v]);const h=()=>{const E=v.trim();E&&!n&&!y&&(a(E),H(""),w.current&&(w.current.style.height="auto"))},R=E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),h())},Y=()=>{d()},D=y;return e.jsxs(zi,{children:[D?e.jsxs(Wi,{"data-hook":"chat-assistant-modes",children:[e.jsxs(Ki,{children:[e.jsx(bt,{size:20}),e.jsx(Ui,{role:"status","aria-live":"polite",children:z})]}),e.jsx(Yi,{children:e.jsx(dn,{size:"md",onClick:Y,title:"Stop generation",ariaLabel:"Stop AI generation",dataHook:"chat-stop-button"})})]}):e.jsxs(Fi,{children:[S&&e.jsx(Pi,{children:e.jsxs(Oi,{type:"button",$warn:!!l,onClick:p?()=>void p.onClick():f,title:j,"aria-label":`Chat context: ${m}`,"data-hook":"chat-context-badge",children:[e.jsx(Qi,{$warn:!!l,children:p?e.jsx(cn,{size:14,weight:"regular"}):b?e.jsx(At,{kind:rt(b),partitionBy:b.partitionBy,walEnabled:b.walEnabled,designatedTimestamp:b.designatedTimestamp}):e.jsx(aa,{size:14,weight:"regular"})}),l==="archived"?`Archived: ${m}`:l==="deleted"?`Deleted: ${m}`:m]})}),e.jsx($i,{ref:w,value:v,onChange:E=>H(E.target.value),onKeyDown:R,placeholder:r,"aria-label":"Chat with AI assistant","aria-keyshortcuts":"Enter",disabled:n,rows:1,$hasContext:S,"data-hook":"chat-input-textarea"}),e.jsx(Bi,{label:"Send message",variant:"primary",onClick:h,disabled:!v.trim()||n,title:"Send (Enter) \u2022 New line (Shift+Enter)","data-hook":"chat-send-button",children:e.jsx(hn,{size:20,weight:"bold"})})]}),e.jsx(le,{color:"contentSecondary",size:"sm",align:"center",children:"Chats are connected to a single query to improve responses."})]})}),Zt=i.div.withConfig({displayName:"ChatHistoryItem__Container"})([`
656
+ display: flex;
657
+ align-items: center;
658
+ gap: 0.6rem;
659
+ padding: 0.4rem 0.8rem;
660
+ border-radius: 4px;
661
+ cursor: `,`;
662
+ background: `,`;
663
+ opacity: `,`;
664
+ border: 0;
665
+ width: 100%;
666
+ text-align: left;
667
+
668
+ &:hover {
669
+ background: `,`;
670
+
671
+ .chat-title {
672
+ color: `,`;
673
+ }
674
+ }
675
+
676
+ &:focus-visible {
677
+ outline: 1px solid `,`;
678
+ outline-offset: 2px;
679
+ }
680
+ `],({$disabled:a})=>a?"not-allowed":"pointer",o("transparent"),({$disabled:a})=>a?.5:1,({$disabled:a,theme:n})=>a?"transparent":n.mode==="light"?n.color.interactionHover:n.color.surfaceInput,({$disabled:a})=>a?o("contentSecondary"):o("contentPrimary"),({theme:a})=>Ot(a.color.statusInfo)),Xi=i.div.withConfig({displayName:"ChatHistoryItem__IconWrapper"})([`
681
+ display: flex;
682
+ align-items: center;
683
+ justify-content: center;
684
+ flex-shrink: 0;
685
+ color: `,`;
686
+ `],o("contentSecondary")),Ji=i.div.withConfig({displayName:"ChatHistoryItem__Content"})([`
687
+ display: flex;
688
+ flex-direction: column;
689
+ flex: 1;
690
+ min-width: 0;
691
+ padding-left: 0.4rem;
692
+ `]),es=i.div.attrs({className:"chat-title"}).withConfig({displayName:"ChatHistoryItem__Title"})([`
693
+ padding: 0.2rem 0.4rem;
694
+ border: 1px solid transparent;
695
+ color: `,`;
696
+ white-space: nowrap;
697
+ overflow: hidden;
698
+ text-overflow: ellipsis;
699
+ transform: translateX(-0.4rem);
700
+ `],o("contentSecondary")),ts=i.input.withConfig({displayName:"ChatHistoryItem__TitleInput"})([`
701
+ color: `,`;
702
+ background: transparent;
703
+ border: 1px solid `,`;
704
+ border-radius: 6px;
705
+ outline: none;
706
+ padding: 0.2rem 0.4rem;
707
+ font-family: inherit;
708
+ transform: translateX(-0.4rem);
709
+
710
+ &:focus {
711
+ outline: none;
712
+ }
713
+ `],o("contentPrimary"),o("borderStrong")),as=i.div.withConfig({displayName:"ChatHistoryItem__Subtitle"})([`
714
+ font-size: 1.2rem;
715
+ line-height: 1.5;
716
+ color: `,`;
717
+ white-space: nowrap;
718
+ overflow: hidden;
719
+ text-overflow: ellipsis;
720
+ `],o("contentSecondary")),ns=i.div.withConfig({displayName:"ChatHistoryItem__ActionsContainer"})([`
721
+ display: flex;
722
+ align-items: center;
723
+ gap: 0.4rem;
724
+ flex-shrink: 0;
725
+ `]),_a=i(ot).withConfig({displayName:"ChatHistoryItem__ActionButton"})([`
726
+ opacity: 0;
727
+
728
+ `,`:hover &,
729
+ `,`:focus-within & {
730
+ opacity: 1;
731
+ }
732
+
733
+ &:focus-visible {
734
+ opacity: 1;
735
+ }
736
+ `],Zt,Zt),is=i.span.withConfig({displayName:"ChatHistoryItem__CurrentIndicator"})([`
737
+ font-size: 1.2rem;
738
+ line-height: 1.5rem;
739
+ color: `,`;
740
+ white-space: nowrap;
741
+ `],o("contentMuted")),ss=({conversation:a,subtitle:n,isCurrent:r,hasOngoingProcess:c,disabled:u,onSelect:p,onRename:f,onDelete:k})=>{const[v,H]=t.useState(!1),[w,A]=t.useState(a.conversationName),b=t.useRef(null);t.useEffect(()=>{v&&b.current&&(b.current.focus(),b.current.select())},[v]);const m=h=>{h.stopPropagation(),A(a.conversationName),H(!0)},S=h=>{h.stopPropagation(),k(a.id)},l=async()=>{const h=w.trim();h&&h!==a.conversationName&&(Me(He.AI_CHAT_RENAME),await f(a.id,h)),H(!1)},j=async h=>{h.key==="Enter"?await l():h.key==="Escape"&&(A(a.conversationName),H(!1))},z=async()=>{await l()},d=async()=>{!v&&!u&&await p(a.id)},y=async h=>{v||u||h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),await p(a.id))};return e.jsxs(Zt,{role:"button",tabIndex:u?-1:0,"aria-disabled":u||void 0,onClick:d,onKeyDown:y,$disabled:u,"data-hook":"chat-history-item",children:[e.jsx(Xi,{children:e.jsx(ea,{size:18})}),e.jsxs(Ji,{children:[v?e.jsx(ts,{ref:b,value:w,onChange:h=>A(h.target.value),onKeyDown:j,onBlur:z,onClick:h=>h.stopPropagation(),"data-hook":"chat-history-rename"}):e.jsx(es,{"data-hook":"chat-history-title",children:a.conversationName}),n&&e.jsx(as,{children:n})]}),e.jsxs(ns,{children:[!v&&e.jsxs(e.Fragment,{children:[e.jsx(_a,{label:"Edit title",size:"sm",onClick:m,title:"Edit title","data-hook":"chat-history-edit",children:e.jsx(pn,{size:18})}),!c&&e.jsx(_a,{label:"Delete conversation",size:"sm",variant:"dangerGhost",onClick:S,title:"Delete","data-hook":"chat-history-delete",children:e.jsx(sa,{size:18})})]}),r&&e.jsx(is,{children:"Current"})]})]})},rs=i.div.withConfig({displayName:"DateSeparator__Container"})([`
742
+ display: flex;
743
+ align-items: center;
744
+ gap: 1rem;
745
+ padding: 0.4rem 0;
746
+ width: 100%;
747
+ `]),Ma=i.div.withConfig({displayName:"DateSeparator__Line"})([`
748
+ flex: 1;
749
+ height: 1px;
750
+ background: `,`;
751
+ `],o("interactionNeutral")),os=i.div.withConfig({displayName:"DateSeparator__LabelContainer"})([`
752
+ display: flex;
753
+ align-items: center;
754
+ gap: 0.8rem;
755
+ color: `,`;
756
+ `],o("contentSecondary")),ls=i.span.withConfig({displayName:"DateSeparator__Label"})([`
757
+ font-size: 1.3rem;
758
+ white-space: nowrap;
759
+ `]),ds=({label:a})=>e.jsxs(rs,{children:[e.jsx(Ma,{}),e.jsxs(os,{children:[e.jsx(ta,{size:16}),e.jsx(ls,{children:a})]}),e.jsx(Ma,{})]}),cs=6e4;function Ha(a){const n=gn(),r=xn(n);return fn(a,new Date().getTime(),{locale:r})+" ago"}function hs(a){const n=[...a].sort((p,f)=>f.updatedAt-p.updatedAt),r=new Map;for(const p of n){const f=Ha(p.updatedAt),k=r.get(f)||[];r.set(f,[...k,p])}const c=[],u=new Set;for(const p of n){const f=Ha(p.updatedAt);u.has(f)||(u.add(f),c.push({label:f,conversations:r.get(f)||[]}))}return c}function ms(a){const[n,r]=t.useState(0);return t.useEffect(()=>{const c=setInterval(()=>{r(u=>u+1)},cs);return()=>clearInterval(c)},[]),t.useMemo(()=>hs(a),[a,n])}function us(a,n){if(!n.trim())return a;const r=n.toLowerCase().trim();return a.filter(c=>c.conversationName.toLowerCase().includes(r))}const ka=i.div.withConfig({displayName:"ChatHistoryView__Container"})([`
760
+ display: flex;
761
+ flex-direction: column;
762
+ height: 100%;
763
+ width: 100%;
764
+ padding: 2rem 1rem 4rem 1rem;
765
+ background: `,`;
766
+ overflow: hidden;
767
+ `],({theme:a})=>a.color.surfaceRaised),ps=i.div.withConfig({displayName:"ChatHistoryView__SearchContainer"})([`
768
+ position: relative;
769
+ display: flex;
770
+ align-items: center;
771
+ flex-shrink: 0;
772
+ `]),gs=i.div.withConfig({displayName:"ChatHistoryView__SearchIcon"})([`
773
+ position: absolute;
774
+ left: 1.2rem;
775
+ display: flex;
776
+ align-items: center;
777
+ color: `,`;
778
+ pointer-events: none;
779
+ z-index: 1;
780
+ `],o("contentSecondary")),fs=i(ot).attrs({label:"Clear search",variant:"ghost",size:"sm"}).withConfig({displayName:"ChatHistoryView__ClearButton"})([`
781
+ position: absolute;
782
+ right: 0.8rem;
783
+ padding: 0.2rem;
784
+ `]),xs=i(bn).withConfig({displayName:"ChatHistoryView__SearchInput"})([`
785
+ width: 100%;
786
+ padding: 0.8rem 3.6rem 0.8rem 3.6rem;
787
+ `]),ys=i.div.withConfig({displayName:"ChatHistoryView__ListContainer"})([`
788
+ display: flex;
789
+ flex-direction: column;
790
+ gap: 0.6rem;
791
+ padding: 2rem 0.4rem;
792
+ overflow-y: auto;
793
+ flex: 1;
794
+ min-height: 0;
795
+ `]),Ia=i.div.withConfig({displayName:"ChatHistoryView__EmptyState"})([`
796
+ display: flex;
797
+ flex-direction: column;
798
+ align-items: center;
799
+ justify-content: center;
800
+ flex: 1;
801
+ color: `,`;
802
+ font-size: 1.3rem;
803
+ text-align: center;
804
+ padding: 2rem;
805
+ `],o("contentSecondary")),Cs=i.div.withConfig({displayName:"ChatHistoryView__DialogHeader"})([`
806
+ display: flex;
807
+ align-items: center;
808
+ justify-content: space-between;
809
+ padding: 1.5rem 2rem;
810
+ border-bottom: 1px solid `,`;
811
+ `],o("interactionNeutral")),ws=i.h3.withConfig({displayName:"ChatHistoryView__DialogTitle"})([`
812
+ margin: 0;
813
+ font-weight: 500;
814
+ color: `,`;
815
+ `],o("contentPrimary")),bs=i.p.withConfig({displayName:"ChatHistoryView__DialogDescription"})([`
816
+ margin: 2rem;
817
+ font-size: 1.4rem;
818
+ line-height: 1.5;
819
+ `]),vs=i.div.withConfig({displayName:"ChatHistoryView__DialogButtons"})([`
820
+ display: flex;
821
+ justify-content: flex-end;
822
+ gap: 1rem;
823
+ padding: 0 2rem 0 2rem;
824
+ `]),js=i(oe).attrs({variant:"secondary"}).withConfig({displayName:"ChatHistoryView__CancelButton"})([""]),As=i(oe).attrs({variant:"danger"}).withConfig({displayName:"ChatHistoryView__DeleteButton"})([""]),_s=({currentConversationId:a})=>{const[n,r]=t.useState(""),[c,u]=t.useState(!1),[p,f]=t.useState(null),k=t.useRef(null),{conversationMetas:v,chatWindowState:H,openChatWindow:w,updateConversationName:A,deleteConversation:b}=wt(),{status:m}=Re(),{buffers:S}=Ct(),l=ke(_e.query.getTables),j=t.useMemo(()=>Array.from(v.values()),[v]),z=t.useMemo(()=>us(j,n),[j,n]),d=ms(z),y=(N,F)=>{if(N){if(F==="buffer"){const V=S.find(q=>q.id===N);if(V)return V.label}else if(F==="table"){const V=l.find(q=>q.id===N);if(V)return V.table_name}}},h=async N=>{await w(N)},R=async(N,F)=>{await A(N,F)},Y=N=>{f(N),u(!0)},D=async()=>{p&&await b(p),u(!1),f(null)},E=()=>{u(!1),f(null)};return t.useEffect(()=>{k.current&&k.current.scrollIntoView({block:"center"})},[]),j.length===0?e.jsx(ka,{children:e.jsx(Ia,{"data-hook":"chat-history-empty",children:"No conversations yet"})}):e.jsxs(ka,{children:[e.jsxs(ps,{children:[e.jsx(gs,{children:e.jsx(yn,{size:18})}),e.jsx(xs,{type:"text",placeholder:"Search chats",value:n,onChange:N=>r(N.target.value),onKeyDown:N=>{N.key==="Escape"&&n&&r("")},"data-hook":"chat-history-search"}),n&&e.jsx(fs,{onClick:()=>r(""),title:"Clear search","data-hook":"chat-history-search-clear",children:e.jsx(Yt,{size:16})})]}),e.jsxs(ys,{"data-hook":"chat-history-list",children:[d.map((N,F)=>e.jsxs(dt.Fragment,{children:[F>0&&e.jsx(ds,{label:N.label}),N.conversations.map(V=>{const q=V.id===a;return e.jsx("div",{ref:q?k:void 0,children:e.jsx(ss,{conversation:V,subtitle:V.bufferId??V.tableId?y(V.bufferId??V.tableId,V.bufferId?"buffer":"table"):void 0,isCurrent:q,hasOngoingProcess:V.id===H.activeConversationId&&ue(m),disabled:ue(m)&&V.id!==H.activeConversationId,onSelect:h,onRename:R,onDelete:Y})},V.id)})]},N.label)),z.length===0&&n&&e.jsx(Ia,{children:"No chats match your search"})]}),e.jsx(ze.Root,{open:c,onOpenChange:u,children:e.jsxs(ze.Portal,{children:[e.jsx(Cn,{children:e.jsx(wn,{primitive:ze.Overlay})}),e.jsxs(ze.Content,{maxwidth:"40rem",children:[e.jsx(Cs,{children:e.jsx(ws,{children:"Delete conversation"})}),e.jsx(bs,{children:"Are you sure you want to delete this conversation? This action cannot be undone."}),e.jsxs(vs,{children:[e.jsx(ze.Cancel,{asChild:!0,children:e.jsx(js,{onClick:E,children:"Cancel"})}),e.jsx(ze.Action,{asChild:!0,children:e.jsx(As,{onClick:D,children:"Delete"})})]})]})]})})]})};async function Ms(a){var w,A,b;const{normalizedSQL:n,queryKey:r,namespaceKey:c,quest:u,dispatch:p,executionRefs:f,releaseExecution:k}=a,{promise:v,queryId:H}=u.queryRaw(n,{limit:"0,1000",explain:!0,cancellable:!0});(w=a.onQueryStarted)==null||w.call(a,H);try{const m=await v;if(f.current[c]||(f.current[c]={}),f.current[c][r]={success:!0,queryText:n,startOffset:-1,endOffset:-1},p(Ue.setResult(m)),m.type===Ye.DDL||m.type===Ye.DML){p(Ue.addNotification({query:r,content:e.jsx(Ge,{query:n})},c)),Xe.publish(Je.MSG_QUERY_SCHEMA);return}if(m.type===Ye.NOTICE){p(Ue.addNotification({query:r,content:e.jsxs(le,{color:"contentPrimary",ellipsis:!0,title:n,children:[m.notice,n!==""?`: ${n}`:""]}),type:De.NOTICE,sideContent:e.jsx(Ge,{query:n})},c)),Xe.publish(Je.MSG_QUERY_SCHEMA);return}m.type===Ye.DQL&&(p(Ue.addNotification({query:r,jitCompiled:((A=m.explain)==null?void 0:A.jitCompiled)??!1,content:e.jsx(vn,{...m.timings,rowCount:m.count}),sideContent:e.jsx(Ge,{query:n})},c)),Xe.publish(Je.MSG_QUERY_DATASET,m))}catch(m){const S=m;f.current[c]||(f.current[c]={}),f.current[c][r]={success:!1,queryText:n,startOffset:-1,endOffset:-1},p(Ue.addNotification({query:r,content:e.jsx(le,{color:"statusDanger",children:An(m)?jn(m):S.error||S.message||"Query execution failed"}),type:De.ERROR,sideContent:e.jsx(Ge,{query:n})},c))}finally{(b=a.onSettled)==null||b.call(a),k(r)}}const Hs=i(oe).withConfig({displayName:"AIChatWindow__CancelButton"})([`
825
+ padding: 1.2rem 0.6rem;
826
+ `]),ks=i.div.withConfig({displayName:"AIChatWindow__HeaderLeft"})([`
827
+ display: flex;
828
+ align-items: center;
829
+ gap: 1rem;
830
+ flex: 1;
831
+ min-width: 0;
832
+ overflow: hidden;
833
+ `]),Is=i.span.withConfig({displayName:"AIChatWindow__HeaderTitle"})([`
834
+ white-space: nowrap;
835
+ overflow: hidden;
836
+ text-overflow: ellipsis;
837
+ font-size: 1.6rem;
838
+ `]),qt=i(oe).attrs({variant:"ghost"}).withConfig({displayName:"AIChatWindow__HeaderButton"})([`
839
+ padding: 0.6rem;
840
+ `]),Es=i.div.withConfig({displayName:"AIChatWindow__HeaderRight"})([`
841
+ display: flex;
842
+ align-items: center;
843
+ gap: 0.5rem;
844
+ flex-shrink: 0;
845
+ `]),Ns=i.div.withConfig({displayName:"AIChatWindow__ChatWindowContent"})([`
846
+ display: flex;
847
+ height: 100%;
848
+ width: 100%;
849
+ overflow: hidden;
850
+ background: `,`;
851
+ `],({theme:a})=>a.color.surfaceRaised),Ss=i.div.withConfig({displayName:"AIChatWindow__InitialQueryContainer"})([`
852
+ display: flex;
853
+ flex-direction: column;
854
+ gap: 1rem;
855
+ padding: 1.5rem;
856
+ overflow-y: auto;
857
+ flex: 1 1 auto;
858
+ min-height: 0;
859
+ width: 100%;
860
+ `]),Vs=i.div.withConfig({displayName:"AIChatWindow__InitialQueryBox"})([`
861
+ display: flex;
862
+ flex-direction: column;
863
+ align-self: flex-end;
864
+ flex-shrink: 0;
865
+ overflow: hidden;
866
+ width: 100%;
867
+ `]),Zs=i.div.withConfig({displayName:"AIChatWindow__InitialQueryEditor"})([`
868
+ width: 100%;
869
+ overflow: hidden;
870
+ `]),qs=i.div.withConfig({displayName:"AIChatWindow__ButtonContainer"})([`
871
+ display: flex;
872
+ justify-content: flex-start;
873
+ align-items: center;
874
+ gap: 1rem;
875
+ width: 100%;
876
+ margin-top: 0.5rem;
877
+ `]),Ts=i.div.withConfig({displayName:"AIChatWindow__BlankChatContainer"})([`
878
+ display: flex;
879
+ flex-direction: column;
880
+ align-items: flex-start;
881
+ justify-content: center;
882
+ gap: 1.2rem;
883
+ padding: 1.8rem;
884
+ flex: 1 1 auto;
885
+ min-height: 0;
886
+ max-width: 40rem;
887
+ text-align: center;
888
+ margin: 0 auto;
889
+ `]),Ls=i.h2.withConfig({displayName:"AIChatWindow__BlankChatHeading"})([`
890
+ font-size: 2rem;
891
+ font-weight: 600;
892
+ text-align: left;
893
+ color: `,`;
894
+ margin: 0;
895
+ `],o("contentPrimary")),Rs=i.p.withConfig({displayName:"AIChatWindow__BlankChatSubheading"})([`
896
+ font-size: 1.4rem;
897
+ font-weight: 400;
898
+ color: `,`;
899
+ text-align: left;
900
+ margin: 0;
901
+ line-height: 1.5;
902
+ `],o("contentSecondary")),Ea=i(Z).withConfig({displayName:"AIChatWindow__ChatPanel"})([`
903
+ display: flex;
904
+ flex-direction: column;
905
+ align-items: stretch;
906
+ height: 100%;
907
+ width: 100%;
908
+ gap: 0;
909
+ background: `,`;
910
+ `],({theme:a})=>a.color.surfaceRaised),Ds=()=>{const a=Xt(),n=ke(_e.console.getActiveSidebar),{quest:r,questExecution:c}=t.useContext(yt),{editorRef:u,showPreviewBuffer:p,closePreviewBuffer:f,addBuffer:k,executionRefs:v,highlightQuery:H,buffers:w,activeBuffer:A,setActiveBuffer:b}=Ct(),m=_n(),{conversationMetas:S,chatWindowState:l,isLoadingMessages:j,isStreaming:z,setIsStreaming:d,scrollToMessageId:y,setScrollToMessageId:h,closeChatWindow:R,openBlankChatWindow:Y,openHistoryView:D,closeHistoryView:E,getConversationMeta:N,addMessage:F,removeMessages:V,updateMessage:q,updateMessagesWithCompaction:M,updateConversationName:Ie,acceptSuggestion:ee,rejectSuggestion:W,persistMessages:G,bindConversationToNotebook:ve,readUserActionDigest:pe,rotateUserActionDigest:je}=wt(),{status:X,setStatus:Fe,abortController:I,canUse:g,hasSchemaAccess:O,currentModel:$e,apiKey:Be,aiAssistantSettings:Pe}=Re(),ce=ke(_e.query.getTables),{active:Ee}=Mn(),Ne=(Ee==null?void 0:Ee.queryKey)??null,he=l.activeConversationId?N(l.activeConversationId):null,s=t.useMemo(()=>he?{...he,messages:m}:null,[he,m]),te=t.useMemo(()=>s?s.bufferId!==void 0?s.bufferId:s.id:-1,[s==null?void 0:s.bufferId,s==null?void 0:s.id]),Oe=ke(_e.query.getQueryNotificationsForBuffer(te)),Ae=t.useRef(null),Le=t.useRef(!1),$=t.useRef(null),B=t.useMemo(()=>Ht(s==null?void 0:s.currentSQL),[s==null?void 0:s.currentSQL]),Qe=t.useMemo(()=>Hn(s==null?void 0:s.queryKey),[s==null?void 0:s.queryKey]),Q=m,ut=t.useMemo(()=>kn(Q)!==null,[Q]),pt=t.useMemo(()=>Q.length>0&&!j,[Q,j]),se=t.useMemo(()=>Q.length===0&&B&&B.trim()!==`
911
+ `&&g&&!ue(X),[Q.length,B,g,X]),tt=t.useMemo(()=>!se||!s||!s.queryKey||!s.bufferId||!u.current?!1:ra(s.queryKey,s.bufferId,v,u)!==null,[se,s,u,v]),We=se&&tt&&g&&!ue(X),J=l.isHistoryOpen??!1,_=S.size>0,K=t.useMemo(()=>ue(X)?!0:s?s.messages.length===0&&!s.queryKey&&!s.tableId:!1,[s,X]),ge=t.useMemo(()=>{if(J)return"Chat history";if(!s)return"";if(s.conversationName)return s.conversationName;const x=s.messages[0];if(x!=null&&x.displayType)switch(x.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,J]),at=t.useCallback(()=>{J?E():D()},[J,E,D]),fe=()=>Q.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=t.useCallback(async x=>{var Se;const C=(Se=N(x))==null?void 0:Se.notebookBufferId,T=typeof C=="number"?In(C):void 0,U=C?await En(C).catch(L=>(console.warn("Notebook snapshot unavailable, sending without it",L),null)):null,ne=pe(x),ye=w.filter(L=>!!L.notebookViewState&&typeof L.id=="number"),Ce=ye.length>0||typeof A.id=="number"?{notebooks:ye.map(L=>({buffer_id:L.id,label:L.label,archived:!!L.archived,...L.id===C?{bound_to_this_chat:!0}:{}})),active:typeof A.id=="number"?{buffer_id:A.id,label:A.label,kind:A.notebookViewState?"notebook":A.metricsViewState?"metrics":A.editorViewState?"sql":"other"}:void 0}:void 0;if(!(!U&&!ne&&!Ce))return{snapshot:U,digest:ne,workspace:Ce,readSeq:T}},[N,pe,w,A]),P=async(x,C=!1)=>{if(!g||!l.activeConversationId||!s)return;Me(He.AI_CHAT_SEND);const T=l.activeConversationId;C&&f();const U=s.messages.some(ne=>ne.role==="assistant");Ze(Gt({conversationId:T,userMessage:x,currentSQL:B,conversationHistory:s.messages,isFirstMessage:!U,settings:{model:$e,apiKey:Be},aiAssistantSettings:Pe,questClient:r,tables:ce,hasSchemaAccess:O,abortSignal:I==null?void 0:I.signal,notebookContext:await me(T)}),{addMessage:F,removeMessages:V,updateMessage:q,setStatus:Fe,setIsStreaming:d,persistMessages:G,updateConversationName:Ie,bindConversationToNotebook:ve,rotateUserActionDigest:je,updateMessagesWithCompaction:M})},xe=t.useCallback(async x=>{l.activeConversationId&&(Me(He.AI_CHAT_ACCEPT),await ee({conversationId:l.activeConversationId,messageId:x}))},[l.activeConversationId,ee]),ae=t.useCallback(async x=>{l.activeConversationId&&(Me(He.AI_CHAT_REJECT),await W(l.activeConversationId,x),setTimeout(()=>{var C;(C=Ae.current)==null||C.focus()},100))},[l.activeConversationId,W]),Na=t.useCallback(x=>{if(!s)return;const C=be(x),T=_t(C);let U=null;c.requestExecution({abort:()=>{U!==null&&r.abort(U)},bufferId:te,queryKey:T,execute:()=>{const ne=window.setTimeout(()=>{a(jt.query.addNotification({query:T,type:De.LOADING,content:e.jsxs(Z,{gap:"1rem",align:"center",children:[e.jsx(le,{color:"contentPrimary",children:"Running..."}),e.jsx(Hs,{variant:"dangerGhost",onClick:()=>{c.cancelActive()},children:e.jsx(Ut,{size:"18px"})})]}),sideContent:e.jsx(Ge,{query:C})},te)),$.current=null},1e3);$.current=ne,Ms({normalizedSQL:C,queryKey:T,namespaceKey:te,quest:r,dispatch:a,executionRefs:v,releaseExecution:c.releaseExecution,onQueryStarted:ye=>{U=ye},onSettled:()=>{$.current===ne&&(window.clearTimeout(ne),$.current=null)}})}})},[s,v,te,r,c]),Sa=t.useCallback(x=>{var C;((C=c.getActive())==null?void 0:C.queryKey)===x&&($.current!==null&&(window.clearTimeout($.current),$.current=null),c.cancelActive())},[c]),gt=t.useCallback(async()=>{if(Me(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 H(s.queryKey,s.bufferId);if(s!=null&&s.tableId){const x=ce.find(C=>C.id===s.tableId);if(x)return a(jt.console.pushSidebarHistory({type:"tableDetails",payload:{tableName:x.table_name,kind:rt(x)}})),!0}return!1},[s==null?void 0:s.queryKey,s==null?void 0:s.bufferId,s==null?void 0:s.tableId,H,ce]),Va=t.useCallback(()=>{h(null)},[h]),Tt=t.useCallback(async(x,C=!1)=>{if(!(C&&await gt()))if(x.type==="diff"){if(!l.activeConversationId)return;p({type:"diff",original:x.original,modified:x.modified,conversationId:l.activeConversationId})}else k({value:x.value})},[p,k,l.activeConversationId,gt]),Za=t.useCallback(async(x,C)=>{if(!l.activeConversationId)return;const T=Nn(C,!1);try{await ee({conversationId:l.activeConversationId,messageId:x,skipDefaultMessage:!0}),F({role:"user",content:`User replaced query with one of your previous suggestions. Now the query is:
912
+
913
+ \`\`\`sql
914
+ ${T.replaceAll(/\s+/g," ").trim()}
915
+ \`\`\``,timestamp:Date.now(),hideFromUI:!0}),await G(l.activeConversationId)}catch(U){console.error("Error applying SQL to editor:",U),lt.error("Failed to apply changes to editor")}},[l.activeConversationId,ee,F,G]),qa=t.useCallback(async x=>{if(!l.activeConversationId||!g||ue(X))return;const C=l.activeConversationId,T=Q.find(L=>L.id===x);if(!T)return;const U=Q.findIndex(L=>L.id===x);if(U<0)return;const ne=Q.slice(U).map(L=>L.id),ye=new Set(ne);V(ne);const Ce={settings:{model:$e,apiKey:Be},aiAssistantSettings:Pe,questClient:r,tables:ce,hasSchemaAccess:O,abortSignal:I==null?void 0:I.signal,notebookContext:await me(C)},Se={addMessage:F,updateMessage:q,removeMessages:V,setStatus:Fe,setIsStreaming:d,persistMessages:G,updateConversationName:Ie,updateMessagesWithCompaction:M,bindConversationToNotebook:ve,rotateUserActionDigest:je};switch(T.displayType){case"explain_request":{if(!T.sql)return;Ze(zt({conversationId:C,queryText:T.sql,...Ce}),Se);break}case"fix_request":{if(!T.sql)return;Ze(Ft({conversationId:C,queryText:T.sql,...Ce}),Se);break}case"schema_explain_request":{if(!T.displaySchemaData)return;const L=T.displaySchemaData;try{const re=await r.showDDL(L.tableName,L.kind);if((re==null?void 0:re.type)!==Ye.DQL||!re.data||re.data.length===0){lt.error("Failed to fetch table schema for retry");return}const it=re.data[0];if(!it.ddl){lt.error("Failed to fetch table schema for retry");return}Ze(Sn({conversationId:C,tableName:L.tableName,schema:it.ddl,kindLabel:Vn(L.kind),schemaDisplayData:L,...Ce}),Se)}catch(re){console.error("Error fetching DDL for retry:",re),lt.error("Failed to fetch table schema for retry")}break}case"ask_request":default:{const L=T.displayUserMessage||T.content||"",re=Q.filter(xt=>!ye.has(xt.id)),it=re.some(xt=>xt.role==="assistant");Ze(Gt({conversationId:C,userMessage:L,currentSQL:T.sql||B,conversationHistory:re,isFirstMessage:!it,...Ce}),Se);break}}},[l.activeConversationId,g,X,Q,V,$e,Be,Pe,r,ce,O,I,F,q,Fe,d,G,Ie,M,ve,me,B]),Lt=t.useRef(null),nt=t.useCallback(()=>{var x,C;(C=(x=Lt.current)==null?void 0:x.querySelector('button[data-hook="button-explain-query"]'))==null||C.click()},[]),ft=t.useCallback(x=>{se&&(x.metaKey||x.ctrlKey)&&(x.key==="e"||x.key==="E")&&(x.preventDefault(),nt())},[se]);t.useEffect(()=>{if(se)return Xe.subscribe(Je.EXPLAIN_QUERY_EXEC,nt),document.addEventListener("keydown",ft),()=>{document.removeEventListener("keydown",ft),Xe.unsubscribe(Je.EXPLAIN_QUERY_EXEC,nt)}},[se,ft,nt]),t.useEffect(()=>()=>{$.current!==null&&(window.clearTimeout($.current),$.current=null)},[]),t.useEffect(()=>{Le.current||J||j||Ae.current&&(Ae.current.focus(),Le.current=!0)},[J,j]);const Ta=t.useCallback(async()=>{var x;Le.current=!1,await Y(),(x=Ae.current)==null||x.focus()},[Y]);if((n==null?void 0:n.type)!=="aiChat"||!s&&!J)return null;const La=(()=>{const x=s==null?void 0:s.notebookBufferId;if(typeof x!="number")return;const C=w.find(Ce=>Ce.id===x),T=!C,U=!!(C!=null&&C.archived),ne=(C==null?void 0:C.label)??`#${x}`,ye=T?"deleted":U?"archived":null;return{label:ne,warn:ye,onClick:async()=>{ye||C&&await b(C)}}})();return e.jsx(e.Fragment,{children:e.jsx(Zn,{mode:"side","data-hook":"ai-chat-window",open:(n==null?void 0:n.type)==="aiChat",onOpenChange:x=>{x||R()},onDismiss:R,trigger:e.jsx("span",{}),title:e.jsxs(ks,{children:[e.jsx(st,{size:20,variant:"filled"}),e.jsx(Is,{"data-hook":"chat-window-title",children:ge})]}),afterTitle:e.jsxs(Es,{children:[e.jsx(qt,{onClick:Ta,title:"New chat","aria-label":"New chat",disabled:K,"data-hook":"chat-window-new",children:e.jsx(qn,{size:16,weight:"bold"})}),e.jsx(qt,{onClick:at,title:J?"Back to chat":"Chat history","aria-label":J?"Back to chat":"Chat history","aria-pressed":J,disabled:!_||ue(X),"data-hook":"chat-window-history",children:e.jsx(Tn,{size:16,weight:"bold"})}),e.jsx(qt,{onClick:R,title:"Close","aria-label":"Close AI chat","data-hook":"chat-window-close",children:e.jsx(Yt,{size:16,weight:"bold"})})]}),children:e.jsx(Ns,{children:j?e.jsx(Ea,{children:e.jsx(bt,{size:20,style:{margin:"auto"}})}):J?e.jsx(_s,{currentConversationId:l.previousConversationId??null}):e.jsxs(Ea,{children:[pt?e.jsx(Di,{messages:Q,onAcceptChange:xe,onRejectChange:ae,onRunQuery:Na,onOpenInEditor:Tt,onApplyToEditor:Za,onRetry:qa,onCancelQuery:Sa,runningQueryKey:Ne,queryNotifications:Oe,isOperationInProgress:ue(X),editorSQL:Qe.queryText,isStreaming:z,isLoadingMessages:j,scrollToMessageId:y,onScrollToMessageComplete:Va}):B&&B.trim()?e.jsxs(Ss,{children:[e.jsx(Vs,{"data-hook":"chat-initial-query-box",children:e.jsx(Zs,{"data-hook":"chat-lite-editor",children:e.jsx(Ke,{value:B.trim(),maxHeight:216,onOpenInEditor:()=>Tt({type:"code",value:B.trim()},!0)})})}),(se||We)&&e.jsxs(qs,{ref:Lt,children:[se&&e.jsx(Kn,{conversationId:s.id,queryText:B.trim()}),We&&e.jsx(Yn,{})]})]}):e.jsxs(Ts,{"data-hook":"chat-blank-state",children:[e.jsx(Ls,{children:"Leverage AI directly in your database"}),e.jsx(Rs,{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."})]}),e.jsx(Gi,{ref:Ae,onSend:x=>P(x,ut),disabled:!g||ue(X),placeholder:fe(),contextSQL:Qe.queryText,contextTableId:s==null?void 0:s.tableId,contextNotebook:La,onContextClick:gt})]})})})})};export{Ds as default};