orcaq 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/-7uW7YTy.js +1 -0
- package/.output/public/_nuxt/{DzjHXopz.js → 5450EsIE.js} +1 -1
- package/.output/public/_nuxt/6mVUr42b.js +1 -0
- package/.output/public/_nuxt/7H5y5euK.js +1 -0
- package/.output/public/_nuxt/7iCr9_qw.js +26 -0
- package/.output/public/_nuxt/{CJnTtXrv.js → B0gkARnK.js} +1 -1
- package/.output/public/_nuxt/B21nC2NZ.js +1 -0
- package/.output/public/_nuxt/B232GDut.js +2 -0
- package/.output/public/_nuxt/{DtgJAz2h.js → B6N_D8QI.js} +1 -1
- package/.output/public/_nuxt/B7C8fo37.js +1 -0
- package/.output/public/_nuxt/BC82eJHt.js +1 -0
- package/.output/public/_nuxt/BHr4_sbs.js +9 -0
- package/.output/public/_nuxt/{DSOwr8Hs.js → BJvJ0Hlu.js} +4 -4
- package/.output/public/_nuxt/BK-6CJ0A.js +1 -0
- package/.output/public/_nuxt/BMVgfiQu.js +1 -0
- package/.output/public/_nuxt/BNh4NY7v.js +1 -0
- package/.output/public/_nuxt/{DuKway_J.js → BO3FEgXG.js} +1 -1
- package/.output/public/_nuxt/BQm1mt0O.js +1 -0
- package/.output/public/_nuxt/BRCvv3op.js +1 -0
- package/.output/public/_nuxt/{Cym7bWgs.js → BRWis86L.js} +1 -1
- package/.output/public/_nuxt/{CG4v011f.js → BRzWRTTF.js} +1 -1
- package/.output/public/_nuxt/{BRVpLa1E.js → BWTTrGtY.js} +2 -2
- package/.output/public/_nuxt/{CczQKYUP.js → BXMKgn-J.js} +1 -1
- package/.output/public/_nuxt/{C7A87LE3.js → BYaoWfSN.js} +1 -1
- package/.output/public/_nuxt/{Z5g5B4NJ.js → BalNYDR1.js} +1 -1
- package/.output/public/_nuxt/{DQdL5Jcl.js → BmfnP4qD.js} +1 -1
- package/.output/public/_nuxt/Bn6_QGSK.js +1 -0
- package/.output/public/_nuxt/{RTN5rY4m.js → BsCPQnkm.js} +1 -1
- package/.output/public/_nuxt/{39ZZCZCn.js → Bu6ybm3Z.js} +1 -1
- package/.output/public/_nuxt/{2TwRWQjG.js → BuTCm7Bo.js} +1 -1
- package/.output/public/_nuxt/BuzCyLCh.js +1 -0
- package/.output/public/_nuxt/{BCm7jnPt.js → BzNEuLKx.js} +1 -1
- package/.output/public/_nuxt/{DyFXtlg0.js → BzNNFvTW.js} +1 -1
- package/.output/public/_nuxt/{nrlEwpIH.js → BzqjH2-H.js} +1 -1
- package/.output/public/_nuxt/{D0oaRUYx.js → C-e53AuW.js} +1 -1
- package/.output/public/_nuxt/C0jXhwNq.js +1 -0
- package/.output/public/_nuxt/C6K-C4_d.js +1 -0
- package/.output/public/_nuxt/{D7uoAo-G.js → C6teO48Y.js} +5 -5
- package/.output/public/_nuxt/{DUvUg_V7.js → C874itvn.js} +1 -1
- package/.output/public/_nuxt/C8ZJ2pm_.js +1 -0
- package/.output/public/_nuxt/CA3O4M9L.js +1 -0
- package/.output/public/_nuxt/{DStg2VwN.js → CAjVwGyz.js} +1 -1
- package/.output/public/_nuxt/{B41tp0B8.js → CCC5u9Ni.js} +1 -1
- package/.output/public/_nuxt/{3vYvhEat.js → CCCJ2fw7.js} +1 -1
- package/.output/public/_nuxt/{vGkKA7iH.js → CFi6G8Aj.js} +2 -2
- package/.output/public/_nuxt/CKlMKmo6.js +1 -0
- package/.output/public/_nuxt/{BvD9dW-2.js → CMDq7o88.js} +1 -1
- package/.output/public/_nuxt/CMI-3q_e.js +1 -0
- package/.output/public/_nuxt/{D_fdC3mJ.js → CMnjMfEQ.js} +1 -1
- package/.output/public/_nuxt/{DTlu-CJn.js → CQFANjzf.js} +1 -1
- package/.output/public/_nuxt/{DEjwIQuc.js → CU5cwnUW.js} +1 -1
- package/.output/public/_nuxt/{BO-QgaRL.js → CXQ2zrsE.js} +1 -1
- package/.output/public/_nuxt/{BLEKzUmC.js → CXbrqQhC.js} +1 -1
- package/.output/public/_nuxt/CZXyfpHW.js +1 -0
- package/.output/public/_nuxt/CZgTP5wX.js +1 -0
- package/.output/public/_nuxt/{BhT0iBlH.js → Cd_fVKDw.js} +1 -1
- package/.output/public/_nuxt/CeXnSKvd.js +1 -0
- package/.output/public/_nuxt/Chw5tFzx.js +1 -0
- package/.output/public/_nuxt/CkLSGVwV.js +1 -0
- package/.output/public/_nuxt/Cqk0ImDE.js +1 -0
- package/.output/public/_nuxt/{Ch-A9iSC.js → CuXTA7ZW.js} +1 -1
- package/.output/public/_nuxt/Cv9v5fHN.js +1 -0
- package/.output/public/_nuxt/{LUfaevBS.js → CvbYm0uB.js} +1 -1
- package/.output/public/_nuxt/{BV4g1sVY.js → Cw1HIv3s.js} +1 -1
- package/.output/public/_nuxt/{DxF9DsEl.js → CyEOtFwE.js} +1 -1
- package/.output/public/_nuxt/{Clm3Z8VL.js → CyKRjZZo.js} +1 -1
- package/.output/public/_nuxt/{Cj9tYr3P.js → D4DMGxvZ.js} +1 -1
- package/.output/public/_nuxt/{BNnChlxR.js → D5GonnbJ.js} +1 -1
- package/.output/public/_nuxt/D5Oboajo.js +1 -0
- package/.output/public/_nuxt/D8egDyEO.js +1 -0
- package/.output/public/_nuxt/DBSV6YXN.js +1 -0
- package/.output/public/_nuxt/{gWmEw6BT.js → DCewvWOu.js} +1 -1
- package/.output/public/_nuxt/{BG_B-fo0.js → DG9CsZCx.js} +1 -1
- package/.output/public/_nuxt/{BOVFFCPB.js → DH2V7e8U.js} +1 -1
- package/.output/public/_nuxt/{DcXAnOS1.js → DHXwq7wT.js} +1 -1
- package/.output/public/_nuxt/DJXrgohw.js +2 -0
- package/.output/public/_nuxt/{CxZK-Vs6.js → DQRyK9Io.js} +1 -1
- package/.output/public/_nuxt/{B-u0WX5Q.js → DXVrM3CN.js} +1 -1
- package/.output/public/_nuxt/{XVZ0obUR.js → DZ4xLzJg.js} +1 -1
- package/.output/public/_nuxt/DZIoL4RO.js +1 -0
- package/.output/public/_nuxt/D_kY6P5P.js +1 -0
- package/.output/public/_nuxt/{DzN4YRfa.js → DgxTwFGe.js} +2 -2
- package/.output/public/_nuxt/DkX74xDd.js +1 -0
- package/.output/public/_nuxt/{DzaPC1WB.js → DmnufEYq.js} +1 -1
- package/.output/public/_nuxt/{CCk2r9DD.js → Dopm1f4X.js} +1 -1
- package/.output/public/_nuxt/{jJeqAxmP.js → Dpkaavgs.js} +1 -1
- package/.output/public/_nuxt/DpsqSAMo.js +20 -0
- package/.output/public/_nuxt/{CRDIOG8r.js → DrkGD_bQ.js} +1 -1
- package/.output/public/_nuxt/{DLIUYAz9.js → Dtry_3Qa.js} +1 -1
- package/.output/public/_nuxt/DwPmcz47.js +1 -0
- package/.output/public/_nuxt/DyjsVMbv.js +1 -0
- package/.output/public/_nuxt/{CBgbjsPd.js → FmHWbXNk.js} +1 -1
- package/.output/public/_nuxt/{CWGzL6OE.js → JxgekUqn.js} +1 -1
- package/.output/public/_nuxt/KoGK2wLb.js +1 -0
- package/.output/public/_nuxt/LU_a7qLd.js +1 -0
- package/.output/public/_nuxt/{1VXrIDkr.js → LxqkguPP.js} +1 -1
- package/.output/public/_nuxt/Q8x88Gcd.js +1 -0
- package/.output/public/_nuxt/{RFRrMFyH.js → R04uZjs6.js} +1 -1
- package/.output/public/_nuxt/So0hX8V0.js +31 -0
- package/.output/public/_nuxt/WGDY9i_Q.js +1 -0
- package/.output/public/_nuxt/{BZQUF1W4.js → WZQ8mcv9.js} +1 -1
- package/.output/public/_nuxt/{CrwM3gOU.js → XjywAggc.js} +1 -1
- package/.output/public/_nuxt/{_fileId_.DxhkUVGK.css → _fileId_.CiauI_x3.css} +1 -1
- package/.output/public/_nuxt/{z1xPtaLw.js → _uLivI44.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/30582efd-125a-4f88-bd89-20a7b2ba8697.json +1 -0
- package/.output/public/_nuxt/{DRuCf0Sx.js → eQskTKIU.js} +1 -1
- package/.output/public/_nuxt/ecWNT6PZ.js +1 -0
- package/.output/public/_nuxt/entry.BcHy7sxf.css +1 -0
- package/.output/public/_nuxt/{BGAd-CMD.js → f6XRRKUb.js} +1 -1
- package/.output/public/_nuxt/jtwYTq7X.js +52 -0
- package/.output/public/_nuxt/{Bw-4PosZ.js → mcYTISF7.js} +1 -1
- package/.output/public/_nuxt/mcfKrWU-.js +1 -0
- package/.output/public/_nuxt/{CB56S0b2.js → soHTUlpn.js} +3 -3
- package/.output/public/_nuxt/tc7vkD0J.js +3 -0
- package/.output/public/_nuxt/vEHvfalB.js +53 -0
- package/.output/public/_nuxt/vP25tZUh.js +2 -0
- package/.output/public/_nuxt/{CpkrwN3Q.js → zndqWf9s.js} +1 -1
- package/.output/server/chunks/_/tables.factory.mjs +1 -1
- package/.output/server/chunks/build/client.manifest.mjs +794 -730
- package/.output/server/chunks/build/client.manifest.mjs.map +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +676 -648
- package/.output/server/package.json +1 -1
- package/package.json +1 -1
- package/.output/public/_nuxt/1fIGBJPQ.js +0 -1
- package/.output/public/_nuxt/1kY3DHv7.js +0 -1
- package/.output/public/_nuxt/9bnMBg54.js +0 -1
- package/.output/public/_nuxt/BFMjnjgH.js +0 -1
- package/.output/public/_nuxt/BN2mQ8OV.js +0 -20
- package/.output/public/_nuxt/BNyWhB4W.js +0 -1
- package/.output/public/_nuxt/BXziI6Bt.js +0 -3
- package/.output/public/_nuxt/BZmEvFAZ.js +0 -28
- package/.output/public/_nuxt/Ba_fqsW2.js +0 -1
- package/.output/public/_nuxt/BbzZxPNQ.js +0 -1
- package/.output/public/_nuxt/Bhm1GL_M.js +0 -1
- package/.output/public/_nuxt/BiSZmDoN.js +0 -1
- package/.output/public/_nuxt/BjK8Fug8.js +0 -1
- package/.output/public/_nuxt/BjpSpz5C.js +0 -1
- package/.output/public/_nuxt/BkqB6n0T.js +0 -1
- package/.output/public/_nuxt/BoPjUGS6.js +0 -1
- package/.output/public/_nuxt/BtwwqY0e.js +0 -1
- package/.output/public/_nuxt/C0l_59dE.js +0 -1
- package/.output/public/_nuxt/C1TOiVRQ.js +0 -9
- package/.output/public/_nuxt/C80Zs8U0.js +0 -1
- package/.output/public/_nuxt/CFZerEKx.js +0 -2
- package/.output/public/_nuxt/CSPqdI4x.js +0 -1
- package/.output/public/_nuxt/CTYqoFvv.js +0 -1
- package/.output/public/_nuxt/CYJEOEaU.js +0 -1
- package/.output/public/_nuxt/CYu-xp_f.js +0 -1
- package/.output/public/_nuxt/CZvnl0uO.js +0 -52
- package/.output/public/_nuxt/CadjlDLt.js +0 -1
- package/.output/public/_nuxt/CeXr_3vU.js +0 -2
- package/.output/public/_nuxt/Culm7V2R.js +0 -53
- package/.output/public/_nuxt/CzBFxx8v.js +0 -1
- package/.output/public/_nuxt/D8KJQqug.js +0 -1
- package/.output/public/_nuxt/D8Z5BXgG.js +0 -26
- package/.output/public/_nuxt/DDK9-_jm.js +0 -1
- package/.output/public/_nuxt/DDQU7vSH.js +0 -1
- package/.output/public/_nuxt/DSEkO8kW.js +0 -1
- package/.output/public/_nuxt/Da1F0IxL.js +0 -1
- package/.output/public/_nuxt/DdtQIDaq.js +0 -1
- package/.output/public/_nuxt/Dfz8k_Rn.js +0 -1
- package/.output/public/_nuxt/DitYzGT4.js +0 -1
- package/.output/public/_nuxt/Djh3G2Nf.js +0 -1
- package/.output/public/_nuxt/DmWFeTaU.js +0 -1
- package/.output/public/_nuxt/_ltJfz1p.js +0 -1
- package/.output/public/_nuxt/builds/meta/1cbed594-12e2-48e6-bea9-7a9159c3c1d3.json +0 -1
- package/.output/public/_nuxt/dkyHOJLf.js +0 -1
- package/.output/public/_nuxt/entry.D1DMaixs.css +0 -1
- package/.output/public/_nuxt/ixgiI20S.js +0 -1
- package/.output/public/_nuxt/lisFd8W1.js +0 -2
- package/.output/public/_nuxt/uHyBIwWw.js +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./XjywAggc.js","./C6teO48Y.js","./entry.BcHy7sxf.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var mo=Object.defineProperty;var po=(n,t,e)=>t in n?mo(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var we=(n,t,e)=>po(n,typeof t!="symbol"?t+"":t,e);import{D as oe,d as se,bX as fo,a4 as vo,aj as ho,k as D,o as S,w as y,E as Ke,g as d,p as vs,dK as xn,dJ as go,$ as yo,a0 as xo,a1 as bo,a2 as So,es as Co,S as hs,e8 as ra,et as wo,c as $,bJ as _o,a5 as pt,j as _t,m as C,n as xe,f as h,bK as Ro,ck as Za,e as k,z,l as K,bO as Ja,bU as en,bP as tn,bQ as an,A as be,bR as To,t as U,bT as gs,N as Le,bf as nn,F as ae,s as ue,J as Oe,L as Ve,O as Pe,r as j,i as _e,eu as Eo,ev as No,ew as ys,ex as xs,ey as Ao,bh as bs,ez as Mo,eA as Io,e2 as Lo,e3 as ko,e4 as zo,eB as zt,da as $o,am as ce,an as ha,aI as sn,aK as dt,q as Oo,aJ as Vo,M as Ct,ar as Po,aq as Rt,cB as Ss,ad as ga,cE as Me,_ as We,h as je,bS as Qe,x as Ye,y as Do,eC as Fo,B as pe,cF as ia,bk as bn,bm as Sn,ai as Bt,aH as at,d4 as Bo,at as wa,bi as Ho,bA as qo,bB as Uo,bC as Ko,eD as Go,H as Wo,au as jo,az as Qo,eE as Cn,ag as Cs,eF as Yo,e7 as on,eG as Xo,eH as Zo,eI as Jo,eJ as er,eK as tr,T as ar,eL as ws,a$ as rn,b0 as _a,eM as nr,b2 as sr,b1 as or,eN as rr,b3 as ir,b4 as lr,eO as ur,b5 as cr,eP as wn,eQ as dr,eR as mr,b7 as pr,eS as fr,bz as vr,Z as _s,ed as hr,V as gr,K as lt,G as yr,bg as xr,b8 as br,ae as ln,b9 as Sr,ba as Cr,bb as wr,bc as _r,bd as Rr,be as Tr,a_ as Rs,aD as Er,a as Nr,aC as Ar,co as Mr}from"./C6teO48Y.js";import{_ as Ir,u as Lr}from"./DyjsVMbv.js";import{_ as kr}from"./DkX74xDd.js";import{_ as zr}from"./CeXnSKvd.js";import{_ as vt}from"./D5GonnbJ.js";import{b as Ts,c as Es,d as Ns,C as ye,f as $r,e as Jt,g as Or,h as Vr,i as Pr,j as Dr}from"./C6K-C4_d.js";import{_ as Fr,a as Br,b as Hr}from"./CMI-3q_e.js";import{a as Fa,f as Dt,b as Ut}from"./D9Ycznwo.js";import{D as qr,g as Ur,h as Kr,j as Gr,_ as Ba,e as Ha,f as qa}from"./BMVgfiQu.js";import{M as Wr}from"./WGDY9i_Q.js";import{p as jr,D as Qr,o as Yr,q as Ra,r as Xr,a as Zr,s as As,t as Jr,v as ei,w as ti,x as ai,_ as ni}from"./zndqWf9s.js";import{_ as Vt}from"./BK-6CJ0A.js";import{b as Ta,c as Ea}from"./Cqk0ImDE.js";import{_ as si}from"./DZ4xLzJg.js";import{s as oi}from"./Dtry_3Qa.js";import{e as Y,ao as ri,i as ke,_ as De,ap as un,a as Ms,q as _n,M as Tt,t as Rn,u as Tn,d as Et,v as En,aq as cn,j as Is,ar as He,x as Ls,y as Ua,w as ks,C as zs,a0 as qe,as as ii,at as li,Q as la,E as Ie,au as ui,av as Nn,J as $s,aw as ua,a5 as ya,ax as Os,ay as ci,az as di,aA as mi,aB as pi,af as Vs,aC as fi,aD as vi,aE as hi,aF as An,ag as Ps,aG as gi,p as Kt,aH as Mn,aI as yi,f as xi,V as ca,a1 as bi,Y as gt,aJ as Na,aK as Aa,aL as Si,aM as Ci,l as yt,aN as wi,aO as _i,aP as Ma,aQ as In,aR as Ri,aS as Ti,aT as da,L as Ei,aU as Ni,aV as Ai,aW as Mi,a8 as Ii,aX as Ds,aY as Fs,aZ as Li,a_ as ki,g as zi,Z as Pt,a$ as ea,b0 as Ln,b1 as Ka,b2 as $i,b3 as Oi,b4 as Ia,b5 as La,b6 as Vi,b7 as Pi,R as Di,b8 as Fi,b9 as Bi,ba as kn,bb as Hi,bc as qi,ai as Ui,ak as Ki,aj as Gi,al as Wi,am as ji,an as Qi,ah as Yi}from"./vEHvfalB.js";import{_ as ka,a as za}from"./DQRyK9Io.js";import{_ as $a}from"./BC82eJHt.js";import{L as Xi,c as Zi,d as Ji,i as el,a as tl}from"./LU_a7qLd.js";import{_ as Bs,n as al,i as nl,j as sl,k as ol,l as rl,s as il,m as ll,a as ul}from"./C0jXhwNq.js";import{_ as xa}from"./Cv9v5fHN.js";import{i as cl}from"./CCC5u9Ni.js";import{f as dl,H as ml}from"./BHr4_sbs.js";import{r as pl}from"./DpsqSAMo.js";import{c as fl,a as vl,m as hl}from"./BYaoWfSN.js";import"./B5rxJs06.js";import"./CvbYm0uB.js";import"./Dpkaavgs.js";import"./soHTUlpn.js";import"./CFi6G8Aj.js";import"./BzqjH2-H.js";import"./BuTCm7Bo.js";import"./BRCvv3op.js";import"./BVmBXPoG.js";import"./DG9CsZCx.js";import"./7H5y5euK.js";import"./D_kY6P5P.js";import"./eQskTKIU.js";import"./CKlMKmo6.js";var ta=(n=>(n.CSV_WITH_HEADER="csv-with-header",n.CSV_NO_HEADER="csv-no-header",n.JSON="json",n.SQL="sql",n.TSV="tsv",n))(ta||{});class gl{constructor(t){this.rawError=t}get nomaltliztionErrror(){var e;const t=((e=this.rawError)==null?void 0:e.message)||"Error parsing SQL execution.";if(!this.rawError)return{message:t};switch(this.rawError.dbType){case oe.POSTGRES:return this.normalizePostgresError(t);case oe.MYSQL:return this.normalizeMysqlError(t);case oe.SQLITE3:return this.normalizeSqliteError(t);case oe.MARIADB:return this.normalizeMysqlError(t);case oe.ORACLE:return this.normalizeOracleError(t);default:return{message:t}}}normalizePostgresError(t){let e;return this.rawError.position&&(e=typeof this.rawError.position=="string"?Number(this.rawError.position):this.rawError.position,Number.isNaN(e)&&(e=void 0)),{message:this.rawError.message||t,position:e,hint:this.rawError.hint}}normalizeMysqlError(t){return{message:this.rawError.sqlMessage||this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeSqliteError(t){return{message:this.rawError.message||t,hint:this.rawError.code?`Error Code: ${this.rawError.code}`:void 0}}normalizeOracleError(t){return{message:this.rawError.message||t,hint:this.rawError.errorNum?`ORA-${String(this.rawError.errorNum).padStart(5,"0")}`:void 0}}}var yl=se({__name:"MenuCheckboxItem",props:{modelValue:{type:[Boolean,String],required:!1,default:!1},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select","update:modelValue"],setup(n,{emit:t}){const e=n,a=t,s=fo(e,["modelValue"]),o=vo(s),r=ho(e,"modelValue",a);return jr({modelValue:r}),(i,l)=>(S(),D(Wr,vs({role:"menuitemcheckbox"},d(o),{"aria-checked":d(xn)(d(r))?"mixed":d(r),"data-state":d(go)(d(r)),onSelect:l[0]||(l[0]=async c=>{a("select",c),d(xn)(d(r))?r.value=!0:r.value=!d(r)})}),{default:y(()=>[Ke(i.$slots,"default",{modelValue:d(r)})]),_:3},16,["aria-checked","data-state"]))}}),xl=yl,bl=se({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String],required:!1},disabled:{type:Boolean,required:!1},textValue:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select","update:modelValue"],setup(n,{emit:t}){const e=n,s=yo(t);return xo(),(o,r)=>(S(),D(d(xl),bo(So({...e,...d(s)})),{default:y(()=>[Ke(o.$slots,"default")]),_:3},16))}}),Sl=bl;function dn(n,t){n.dispatch(Co(n.state,t))}function Cl(n){return n===oe.POSTGRES?"postgres-positional":n===oe.ORACLE?"oracle-positional":"question-mark"}function wl(n,t,e,a={}){if(!Object.keys(t).length)return n;const s=a.style??Cl(e);let o=a.startIndex??1,r="",i=0;for(;i<n.length;){const l=n[i];if(l==="'"){const c=i++;for(;i<n.length;)if(n[i]==="'"&&n[i+1]==="'")i+=2;else if(n[i]==="'"){i++;break}else i++;r+=n.slice(c,i);continue}if(l==='"'){const c=i++;for(;i<n.length&&n[i]!=='"';)i++;i++,r+=n.slice(c,i);continue}if(l==="$"&&e===oe.POSTGRES){const c=i;let m="$",u=i+1;for(;u<n.length&&n[u]!=="$"&&/[a-zA-Z0-9_]/.test(n[u]);)m+=n[u++];if(u<n.length&&n[u]==="$"){m+="$",u++;const p=n.indexOf(m,u);if(p!==-1){i=p+m.length,r+=n.slice(c,i);continue}}}if(l===":"&&i+1<n.length&&/[a-zA-Z_]/.test(n[i+1])){const c=i++;let m="";for(;i<n.length&&/[a-zA-Z0-9_]/.test(n[i]);)m+=n[i++];m in t?s==="postgres-positional"?r+=`$${o++}`:s==="oracle-positional"?r+=`:${o++}`:r+="?":r+=n.slice(c,i);continue}r+=l,i++}return r}function _l(n,t,e){if(n===t)return e;let a=0,s=0;for(;s<e&&a<n.length;){const o=n[a],r=t[s],i=/\s/.test(o),l=/\s/.test(r);if(i&&l){a++,s++;continue}if(o===":"&&(r==="$"||r==="?"||r===":")){for(;a<n.length&&/[:a-zA-Z0-9_]/.test(n[a]);)a++;if(r==="$")for(;s<t.length&&/[$0-9]/.test(t[s]);)s++;else if(r===":")for(;s<t.length&&/[:0-9]/.test(t[s]);)s++;else s++;if(s>=e)return a;continue}o===r?(a++,s++):a++}return a}function zn({editorView:n,originalSql:t,statementFrom:e,fileParameters:a={},errorDetail:s,clientType:o,queryPrefix:r}){if(!n||!s)return;const{message:i,position:l}=s.normalizeError||new gl(s).nomaltliztionErrror;if(!l){Tl(n,e,t,i);return}const c=`${r}${t}`,m=wl(c,a,o),u=_l(c,m,l),p=Math.max(u-1,0)-((r==null?void 0:r.length)||0),{from:f,to:g}=Rl(t,e,p);dn(n,[{from:f,to:g,severity:"error",message:i}])}function Rl(n,t,e){let a=e;for(;a<n.length&&!/[\s\n\r\t]/.test(n[a]);)a++;return{from:t+e,to:t+a}}function Tl(n,t,e,a){const s=[{from:t,to:t+e.length,severity:"error",message:a}];dn(n,s)}function El(n){dn(n,[])}const Nl=n=>hs.of([{key:"Mod-Enter",mac:"Cmd-Enter",run:t=>{const{currentStatements:e}=ra(t),a=wo(t);return e.length&&n({currentStatements:e,treeNodes:a||[]}),!0},preventDefault:!0}]),Al=se({__name:"DropdownMenuCheckboxItem",props:{modelValue:{type:[Boolean,String]},disabled:{type:Boolean},textValue:{},asChild:{type:Boolean},as:{},class:{}},emits:["select","update:modelValue"],setup(n,{emit:t}){const e=n,a=t,s=$(()=>{const{class:i,...l}=e;return l}),o=_o(s,a),r=pt(qr,$(()=>"default"));return(i,l)=>(S(),D(d(Sl),vs({"data-slot":"dropdown-menu-checkbox-item","data-size":d(r)},d(o),{class:d(_t)("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",d(Ur)[d(r)],e.class)}),{default:y(()=>[C("span",{class:xe(d(_t)("pointer-events-none absolute flex items-center justify-center",d(Kr)[d(r)]))},[h(d(Qr),null,{default:y(()=>[h(d(Ro),{class:xe(d(Gr)[d(r)])},null,8,["class"])]),_:1})],2),Ke(i.$slots,"default")]),_:3},16,["data-size","class"]))}}),Ml={},Il={class:"p-4 flex flex-col items-center justify-center h-full text-center space-y-4"},Ll={class:"text-muted-foreground space-y-3"},kl={class:"list-disc text-sm list-inside text-left space-y-2"};function zl(n,t){const e=zr,a=kr,s=vt;return S(),k("div",Il,[h(a,{class:"rounded-2xl size-20 shadow-md"},{default:y(()=>[h(e,{src:"/logo.png",alt:"@unovue"})]),_:1}),C("div",Ll,[t[7]||(t[7]=C("h2",{class:"text-md font-normal text-foreground"},"Getting Started",-1)),C("ol",kl,[t[5]||(t[5]=C("li",null,[C("span",{class:"font-normal text-foreground"},"Write your query"),z(" in the editor. ")],-1)),t[6]||(t[6]=C("li",null,[C("span",{class:"font-normal text-foreground"},"Click inside your query"),z(" to select it. ")],-1)),C("li",null,[t[1]||(t[1]=z(" Click ")),t[2]||(t[2]=C("span",{class:"text-foreground font-normal"},"'Execute current'",-1)),t[3]||(t[3]=z(" or use shortcut ")),h(s,{class:"font-normal border rounded-md p-1 px-1.5 text-foreground"},{default:y(()=>t[0]||(t[0]=[z("⌘↵")])),_:1}),t[4]||(t[4]=z(" to run the query. "))])])])])}const $l=Za(Ml,[["render",zl]]),Ol={class:"font-medium text-foreground"},Vl={class:"font-medium text-foreground"},Pl=se({__name:"RawQueryConnectionConfirmDialog",props:{open:{type:Boolean},targetConnectionName:{},currentConnectionName:{}},emits:["confirm","cancel"],setup(n,{emit:t}){const e=t,a=()=>{e("confirm")},s=()=>{e("cancel")};return(o,r)=>{const i=be;return o.open?(S(),D(d(Ja),{key:0,open:o.open,"onUpdate:open":r[0]||(r[0]=l=>!l&&s())},{default:y(()=>[h(d(en),{class:"max-w-md"},{default:y(()=>[h(d(tn),null,{default:y(()=>[h(d(an),{class:"flex items-center gap-2"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-5 text-amber-500"}),r[1]||(r[1]=z(" Confirm query execution "))]),_:1}),h(d(To),null,{default:y(()=>[r[2]||(r[2]=z(" This query will execute on ")),C("span",Ol,U(o.targetConnectionName),1),r[3]||(r[3]=z(" . The current connection is ")),C("span",Vl,U(o.currentConnectionName),1),r[4]||(r[4]=z(" . Make sure before executing. "))]),_:1})]),_:1}),h(d(gs),null,{default:y(()=>[h(d(Le),{variant:"outline",onClick:s},{default:y(()=>r[5]||(r[5]=[z("Cancel")])),_:1}),h(d(Le),{class:"gap-1",onClick:a},{default:y(()=>[h(i,{name:"lucide:play",class:"size-4"}),r[6]||(r[6]=z(" Execute "))]),_:1})]),_:1})]),_:1})]),_:1},8,["open"])):K("",!0)}}}),Dl={key:1,class:"text-xs text-muted-foreground ml-2"},Fl=se({__name:"RawQueryEditorContextMenu",props:{contextMenuItems:{}},emits:["update:open"],setup(n,{emit:t}){const e=t,a=o=>typeof o>"u"?!0:!!o,s=o=>{e("update:open",o)};return(o,r)=>{const i=Es,l=$r,c=be,m=vt,u=Jt,p=Or,f=Pr,g=Dr,x=Vr,v=Ns,_=Ts;return S(),D(_,{"onUpdate:open":s},{default:y(()=>[h(i,{"as-child":""},{default:y(()=>[Ke(o.$slots,"default")]),_:3}),h(v,{class:"min-w-56",onCloseAutoFocus:r[0]||(r[0]=nn(()=>{},["prevent"]))},{default:y(()=>[(S(!0),k(ae,null,ue(o.contextMenuItems,(b,N)=>(S(),k(ae,{key:N},[b.type===d(ye).LABEL&&a(b.condition)?(S(),D(l,{key:0,class:"font-medium text-xs text-muted-foreground"},{default:y(()=>[z(U(b.title),1)]),_:2},1024)):b.type===d(ye).ACTION&&a(b.condition)?(S(),D(u,{key:1,onSelect:b.select,disabled:b.disabled},{default:y(()=>[b.icon?(S(),D(c,{key:0,name:b.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):K("",!0),z(" "+U(b.title)+" ",1),b.shortcut?(S(),D(m,{key:1},{default:y(()=>[z(U(b.shortcut),1)]),_:2},1024)):K("",!0)]),_:2},1032,["onSelect","disabled"])):b.type===d(ye).SEPARATOR&&a(b.condition)?(S(),D(p,{key:2})):b.type===d(ye).SUBMENU&&a(b.condition)?(S(),D(x,{key:3,disabled:!b.items||b.items.length===0},{default:y(()=>[h(f,null,{default:y(()=>[b.icon?(S(),D(c,{key:0,name:b.icon,class:"size-4! min-w-4 text-muted-foreground mr-2"},null,8,["name"])):K("",!0),z(" "+U(b.title)+" ",1),b.desc?(S(),k("span",Dl,U(b.desc),1)):K("",!0)]),_:2},1024),h(g,{class:xe("min-w-52")},{default:y(()=>[(S(!0),k(ae,null,ue(b.items,(R,w)=>(S(),k(ae,{key:w},[R.type===d(ye).ACTION&&a(R.condition)?(S(),D(u,{key:0,onSelect:R.select},{default:y(()=>[R.icon?(S(),D(c,{key:0,name:R.icon,class:"size-4! min-w-4 text-muted-foreground"},null,8,["name"])):K("",!0),z(" "+U(R.title)+" ",1),R.shortcut?(S(),D(m,{key:1},{default:y(()=>[z(U(R.shortcut),1)]),_:2},1024)):K("",!0)]),_:2},1032,["onSelect"])):R.type===d(ye).LABEL&&a(R.condition)?(S(),D(l,{key:1,class:"font-medium text-xs text-muted-foreground"},{default:y(()=>[z(U(R.title),1)]),_:2},1024)):R.type===d(ye).SEPARATOR&&a(R.condition)?(S(),D(p,{key:2})):K("",!0)],64))),128))]),_:2},1024)]),_:2},1032,["disabled"])):K("",!0)],64))),128))]),_:1})]),_:3})}}}),Bl={},Hl={class:"mb-2 flex items-center gap-1.5 text-sm font-semibold"};function ql(n,t){const e=be,a=Le,s=Br,o=Oe,r=Ve,i=Hr,l=Fr,c=Pe;return S(),D(c,null,{default:y(()=>[h(l,null,{default:y(()=>[h(o,{"as-child":""},{default:y(()=>[h(s,{"as-child":""},{default:y(()=>[h(a,{size:"iconSm",variant:"ghost",class:"h-4 w-4 p-0 text-muted-foreground hover:text-foreground",title:"How to use query variables","aria-label":"How to use query variables"},{default:y(()=>[h(e,{name:"hugeicons:help-circle",class:"size-3.5!"})]),_:1})]),_:1})]),_:1}),h(r,null,{default:y(()=>t[0]||(t[0]=[C("p",null,"How to use query variables",-1)])),_:1}),h(i,{side:"top",align:"start",class:"w-[440px] p-4 text-xs"},{default:y(()=>[C("p",Hl,[h(e,{name:"hugeicons:help-circle",class:"size-4!"}),t[1]||(t[1]=z(" Passing variables in queries "))]),t[2]||(t[2]=C("p",{class:"mb-3 text-muted-foreground"},[z(" Use "),C("code",{class:"rounded bg-muted px-1"},":variable_name"),z(" syntax to bind parameters. For array operators, cast to the correct type: ")],-1)),t[3]||(t[3]=C("div",{class:"space-y-3"},[C("div",null,[C("p",{class:"mb-1 font-medium text-foreground"},[C("code",{class:"rounded bg-muted px-1"},"= ANY()")]),C("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE id = ANY (ARRAY[:your_variable]::integer[])
|
|
3
|
+
WHERE status = ANY (ARRAY[:statuses]::text[])`)]),C("div",null,[C("p",{class:"mb-1 font-medium text-foreground"},[C("code",{class:"rounded bg-muted px-1"},"IN()")]),C("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE id IN (:your_variable)
|
|
4
|
+
WHERE name IN (:names)`)]),C("div",null,[C("p",{class:"mb-1 font-medium text-foreground"},"Scalar variable"),C("pre",{class:"overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2 text-xs"},`WHERE created_at > :start_date
|
|
5
|
+
WHERE user_id = :user_id`)])],-1)),t[4]||(t[4]=C("p",{class:"mt-3 border-t pt-2 text-muted-foreground"},[z(" Replace "),C("code",{class:"rounded bg-muted px-1"},"alias_type"),z(" with the actual PostgreSQL type, e.g. "),C("code",{class:"rounded bg-muted px-1"},"integer"),z(", "),C("code",{class:"rounded bg-muted px-1"},"uuid"),z(", "),C("code",{class:"rounded bg-muted px-1"},"text"),z(". ")],-1))]),_:1})]),_:1})]),_:1})}const Ul=Za(Bl,[["render",ql]]),Kl={class:"h-fit py-1 flex items-center justify-between px-2"},Gl={class:"flex items-center gap-2"},Wl={class:"font-normal text-xs text-muted-foreground"},jl={key:0,class:"font-normal text-xs text-muted-foreground"},Ql={key:0,class:"flex items-center gap-1"},Yl={key:1,class:"flex items-center gap-1"},Xl={key:2},Zl={key:0},Jl={key:1},eu={class:"flex gap-1"},tu={class:"flex items-center"},au={class:"flex items-center"},nu={key:0},su={key:1},ou=se({__name:"RawQueryEditorFooter",props:{cursorInfo:{},isHaveOneExecute:{type:Boolean},executeLoading:{type:Boolean},executeErrors:{type:Boolean},isStreaming:{type:Boolean},streamingRowCount:{},queryTime:{},rawQueryResultsLength:{},isRawViewMode:{type:Boolean},explainAnalyzeOptionItems:{},serializeMode:{},isSupportFormat:{type:Boolean},isSupportVariable:{type:Boolean},isExplainSupported:{type:Boolean}},emits:["onFormatCurrentStatement","onFormatAll","onExplainAnalyzeCurrent","toggleExplainOption","update:serializeMode","onExecuteCurrent","update:isRawViewMode","onCancelQuery"],setup(n){const t=j(!1);return(e,a)=>{const s=Ul,o=be,r=vt,i=Le;return S(),k("div",Kl,[C("div",Gl,[C("div",Wl," Ln "+U(e.cursorInfo.line)+", Col "+U(e.cursorInfo.column),1),e.isSupportVariable?(S(),D(s,{key:0})):K("",!0)]),e.isHaveOneExecute?(S(),k("div",jl,[e.isStreaming?(S(),k("span",Ql,[h(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"}),z(" Streaming... "+U(d(Fa)(e.streamingRowCount))+" rows ",1)])):e.executeLoading?(S(),k("span",Yl,[a[9]||(a[9]=z("Processing ")),h(o,{name:"hugeicons:loading-03",class:"size-4! animate-spin"})])):(S(),k("span",Xl,[e.executeErrors?(S(),k("span",Zl," Query: 1 error in "+U(d(Dt)(e.queryTime)),1)):(S(),k("span",Jl," Query success: "+U(d(Fa)(e.rawQueryResultsLength))+" rows in "+U(d(Dt)(e.queryTime)),1))]))])):K("",!0),C("div",eu,[e.isSupportFormat?(S(),D(d(Pe),{key:0},{default:y(()=>[h(d(Oe),null,{default:y(()=>[C("div",tu,[h(i,{onClick:a[0]||(a[0]=l=>e.$emit("onFormatCurrentStatement")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:y(()=>[h(o,{name:"hugeicons:magic-wand-01"}),a[11]||(a[11]=z(" Format ")),h(r,null,{default:y(()=>a[10]||(a[10]=[z("⌘S")])),_:1})]),_:1}),h(d(Ba),null,{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:y(()=>[h(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),h(d(qa),{align:"end",class:"min-w-44"},{default:y(()=>[h(d(Ta),{class:"py-0"},{default:y(()=>a[12]||(a[12]=[z("Format Options ")])),_:1}),h(d(Ea)),h(d(Vt),{onClick:a[1]||(a[1]=l=>e.$emit("onFormatCurrentStatement")),class:"h-6 cursor-pointer"},{default:y(()=>[a[14]||(a[14]=z(" Current Statement ")),h(r,null,{default:y(()=>a[13]||(a[13]=[z("⌘S")])),_:1})]),_:1}),h(d(Vt),{onClick:a[2]||(a[2]=l=>e.$emit("onFormatAll")),class:"h-6 cursor-pointer"},{default:y(()=>[a[16]||(a[16]=z(" All Statement ")),h(r,null,{default:y(()=>a[15]||(a[15]=[z("⇧⌥F")])),_:1})]),_:1})]),_:1})]),_:1})])]),_:1}),h(d(Ve),null,{default:y(()=>a[17]||(a[17]=[C("p",null,"Format current statement (⌘S)",-1)])),_:1})]),_:1})):K("",!0),e.isExplainSupported?(S(),D(d(Pe),{key:1},{default:y(()=>[h(d(Oe),null,{default:y(()=>[C("div",au,[h(i,{onClick:a[3]||(a[3]=l=>e.$emit("onExplainAnalyzeCurrent")),variant:"outline",size:"xxs",class:"rounded-r-none"},{default:y(()=>[h(o,{name:"hugeicons:analytics-up"}),a[19]||(a[19]=z(" Explain ")),h(r,null,{default:y(()=>a[18]||(a[18]=[z("⌘E")])),_:1})]),_:1}),h(d(Ba),{open:d(t),"onUpdate:open":a[6]||(a[6]=l=>_e(t)?t.value=l:null)},{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(i,{variant:"outline",size:"iconSm",class:"rounded-l-none border-l-0 px-2"},{default:y(()=>[h(o,{name:"hugeicons:arrow-down-01",class:"size-4! min-w-4"})]),_:1})]),_:1}),h(d(qa),{align:"end",class:"min-w-52"},{default:y(()=>[h(d(Ta),{class:"py-0"},{default:y(()=>a[20]||(a[20]=[z("Explain Analyze Options")])),_:1}),h(d(Ea)),(S(!0),k(ae,null,ue(e.explainAnalyzeOptionItems,l=>(S(),D(d(Al),{key:l.key,"model-value":l.checked,onSelect:a[4]||(a[4]=nn(()=>{},["prevent"])),"onUpdate:modelValue":c=>e.$emit("toggleExplainOption",l.key),class:"h-6 cursor-pointer"},{default:y(()=>[z(U(l.label),1)]),_:2},1032,["model-value","onUpdate:modelValue"]))),128)),h(d(Ea)),h(d(Ta),{class:"py-0"},{default:y(()=>a[21]||(a[21]=[z("Serialize")])),_:1}),h(d(Yr),{"model-value":e.serializeMode,"onUpdate:modelValue":a[5]||(a[5]=l=>e.$emit("update:serializeMode",l))},{default:y(()=>[h(d(Ra),{value:"NONE",class:"h-6 cursor-pointer"},{default:y(()=>a[22]||(a[22]=[z("None")])),_:1}),h(d(Ra),{value:"TEXT",class:"h-6 cursor-pointer"},{default:y(()=>a[23]||(a[23]=[z("Text")])),_:1}),h(d(Ra),{value:"BINARY",class:"h-6 cursor-pointer"},{default:y(()=>a[24]||(a[24]=[z("Binary")])),_:1})]),_:1},8,["model-value"])]),_:1})]),_:1},8,["open"])])]),_:1}),h(d(Ve),null,{default:y(()=>a[25]||(a[25]=[C("p",null,"Run Explain Analyze (⌘E) or open options",-1)])),_:1})]),_:1})):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[e.isStreaming||e.executeLoading?(S(),D(i,{key:0,onClick:a[7]||(a[7]=l=>e.$emit("onCancelQuery")),variant:"outline",size:"xxs"},{default:y(()=>[h(o,{name:"hugeicons:stop",class:"size-4! text-red-500"}),a[26]||(a[26]=z(" Cancel query "))]),_:1})):(S(),D(i,{key:1,onClick:a[8]||(a[8]=l=>e.$emit("onExecuteCurrent")),variant:"outline",size:"xxs"},{default:y(()=>[h(o,{name:"hugeicons:play"}),a[28]||(a[28]=z(" Execute current ")),h(r,null,{default:y(()=>a[27]||(a[27]=[z("⌘↵")])),_:1})]),_:1}))]),_:1}),h(d(Ve),null,{default:y(()=>[e.isStreaming||e.executeLoading?(S(),k("p",nu,"Cancel query")):(S(),k("p",su,"Execute Query (⌘↵)"))]),_:1})]),_:1})])])}}}),Hs=se({__name:"VariableEditor",props:{fileVariables:{}},emits:["updateVariables"],setup(n,{emit:t}){const e=t,a=j({line:1,column:1}),s=[Eo(`Please input your json variable
|
|
6
|
+
{
|
|
7
|
+
"key": "value"
|
|
8
|
+
}`),oi(r=>{try{return Ao(r,{type:"space",size:2})}catch{return r}}),No(),ys(),xs(Mo())],o=r=>{e("updateVariables",r)};return(r,i)=>(S(),D(bs,{"onUpdate:modelValue":o,"onUpdate:cursorInfo":i[0]||(i[0]=l=>a.value=l),modelValue:r.fileVariables,extensions:s,disabled:!1,ref:"codeEditorRef"},null,8,["modelValue"]))}}),ru={class:"h-full flex flex-col overflow-y-auto"},iu=se({__name:"AddVariableModal",props:{open:{},fileVariables:{}},emits:["update:open","updateVariables"],setup(n,{emit:t}){const e=t,a=async s=>{e("updateVariables",s)};return(s,o)=>(S(),D(d(Ja),{class:"",open:!!s.open,"onUpdate:open":o[1]||(o[1]=r=>e("update:open",r))},{default:y(()=>[h(d(en),{class:"w-[60vw] h-[50vh] flex flex-col justify-between min-w-[60vw]"},{default:y(()=>[h(d(tn),null,{default:y(()=>[h(d(an),null,{default:y(()=>o[2]||(o[2]=[z(" Add Variable "),C("a",{class:"underline",href:"https://www.w3schools.com/js/js_json_syntax.asp",target:"_blank"}," (JSON format)",-1)])),_:1})]),_:1}),C("div",ru,[h(Hs,{onUpdateVariables:a,fileVariables:s.fileVariables},null,8,["fileVariables"])]),h(d(gs),{class:"mt-2"},{default:y(()=>[h(d(Le),{onClick:o[0]||(o[0]=r=>e("update:open",!1))},{default:y(()=>o[3]||(o[3]=[z(" Save ")])),_:1})]),_:1})]),_:1})]),_:1},8,["open"]))}}),lu=se({__name:"RawQueryConfigModal",props:{open:{}},emits:["update:open"],setup(n,{emit:t}){const e=t;return(a,s)=>(S(),D(d(Ja),{class:"",open:!!a.open,"onUpdate:open":s[0]||(s[0]=o=>e("update:open",o))},{default:y(()=>[h(d(en),{class:"w-[50vw] h-[70vh] flex flex-col justify-between min-w-[50vw]"},{default:y(()=>[h(d(tn),null,{default:y(()=>[h(d(an),null,{default:y(()=>s[1]||(s[1]=[z(" Editor configs ")])),_:1})]),_:1}),h(Io)]),_:1})]),_:1},8,["open"]))}}),uu={class:"flex items-center justify-between p-1 rounded-md bg-muted"},cu={class:"flex gap-2 items-center"},du={key:0},mu={key:1},pu=se({__name:"RawQueryEditorHeader",props:{currentFileInfo:{},fileVariables:{},workspaceId:{},selectedConnectionId:{},disableConnectionSwitch:{type:Boolean},connections:{},connection:{},isRedisConnection:{type:Boolean},isSupportVariable:{type:Boolean},redisDatabases:{},redisDatabaseIndex:{},codeEditorLayout:{}},emits:["update:connectionId","update:redisDatabaseIndex","update:updateFileVariables"],setup(n){const t=j(!1),e=j(!1),a=j(!1),s=()=>{t.value=!0},o=()=>{e.value=!0};return(r,i)=>{const l=be,c=Xr,m=zo,u=ko,p=Lo,f=Le;return S(),k(ae,null,[h(iu,{onUpdateVariables:i[0]||(i[0]=g=>r.$emit("update:updateFileVariables",g)),"file-variables":r.fileVariables,open:d(t),"onUpdate:open":i[1]||(i[1]=g=>_e(t)?t.value=g:null)},null,8,["file-variables","open"]),h(lu,{open:d(e),"onUpdate:open":i[2]||(i[2]=g=>_e(e)?e.value=g:null)},null,8,["open"]),C("div",uu,[C("div",null,[h(p,null,{default:y(()=>[h(u,{class:"gap-0!"},{default:y(()=>[h(m,null,{default:y(()=>[h(c,{class:"flex items-center gap-0.5"},{default:y(()=>{var g,x;return[h(l,{name:(g=r.currentFileInfo)==null?void 0:g.icon},null,8,["name"]),z(" "+U((x=r.currentFileInfo)==null?void 0:x.title),1)]}),_:1})]),_:1})]),_:1})]),_:1})]),C("div",cu,[r.isSupportVariable&&r.codeEditorLayout===d(zt).horizontal?(S(),D(d(Pe),{key:0},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(f,{onClick:s,variant:"outline",size:"xxs",class:"relative"},{default:y(()=>[d(a)?(S(),D(l,{key:0,name:"lucide:triangle-alert",class:"absolute -top-1 -right-1 text-red-400"})):K("",!0),h(l,{name:"hugeicons:absolute"}),i[5]||(i[5]=z(" Add variables "))]),_:1})]),_:1}),h(d(Ve),null,{default:y(()=>i[6]||(i[6]=[C("p",null,"Add variables",-1)])),_:1})]),_:1})):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(si,{connectionId:r.selectedConnectionId,"onUpdate:connectionId":i[3]||(i[3]=g=>r.$emit("update:connectionId",g)),connections:r.connections,connection:r.connection,disabled:r.disableConnectionSwitch,class:"w-fit h-6! px-1.5",workspaceId:r.workspaceId},null,8,["connectionId","connections","connection","disabled","workspaceId"])]),_:1}),h(d(Ve),null,{default:y(()=>[r.disableConnectionSwitch?(S(),k("p",du," Connection switch is locked because the current connection has a strict mode tag ")):(S(),k("p",mu,"Select connection"))]),_:1})]),_:1}),r.isRedisConnection?(S(),D(Ir,{key:1,compact:"","trigger-id":"raw-query-redis-db-index","trigger-class":"bg-background",databases:r.redisDatabases||[],"database-index":r.redisDatabaseIndex??0,"onUpdate:databaseIndex":i[4]||(i[4]=g=>r.$emit("update:redisDatabaseIndex",g))},null,8,["databases","database-index"])):K("",!0),h(d(Pe),null,{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(f,{onClick:o,variant:"outline",size:"iconSm"},{default:y(()=>[h(l,{name:"hugeicons:dashboard-square-02"})]),_:1})]),_:1}),h(d(Ve),null,{default:y(()=>i[7]||(i[7]=[C("p",null,"Query Settings",-1)])),_:1})]),_:1})])])],64)}}}),Gt={__name:"splitpanes",props:{horizontal:{type:Boolean,default:!1},pushOtherPanes:{type:Boolean,default:!0},maximizePanes:{type:Boolean,default:!0},rtl:{type:Boolean,default:!1},firstSplitter:{type:Boolean,default:!1}},emits:["ready","resize","resized","pane-click","pane-maximize","pane-add","pane-remove","splitter-click","splitter-dblclick"],setup(n,{emit:t}){const e=t,a=n,s=$o(),o=j([]),r=$(()=>o.value.reduce((M,V)=>(M[~~V.id]=V)&&M,{})),i=$(()=>o.value.length),l=j(null),c=j(!1),m=j({mouseDown:!1,dragging:!1,activeSplitter:null,cursorOffset:0}),u=j({splitter:null,timeoutId:null}),p=$(()=>({[`splitpanes splitpanes--${a.horizontal?"horizontal":"vertical"}`]:!0,"splitpanes--dragging":m.value.dragging})),f=()=>{document.addEventListener("mousemove",v,{passive:!1}),document.addEventListener("mouseup",_),"ontouchstart"in window&&(document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("touchend",_))},g=()=>{document.removeEventListener("mousemove",v,{passive:!1}),document.removeEventListener("mouseup",_),"ontouchstart"in window&&(document.removeEventListener("touchmove",v,{passive:!1}),document.removeEventListener("touchend",_))},x=(M,V)=>{const H=M.target.closest(".splitpanes__splitter");if(H){const{left:B,top:q}=H.getBoundingClientRect(),{clientX:O,clientY:Q}="ontouchstart"in window&&M.touches?M.touches[0]:M;m.value.cursorOffset=a.horizontal?Q-q:O-B}f(),m.value.mouseDown=!0,m.value.activeSplitter=V},v=M=>{m.value.mouseDown&&(M.preventDefault(),m.value.dragging=!0,requestAnimationFrame(()=>{E(w(M)),he("resize",{event:M},!0)}))},_=M=>{m.value.dragging&&(window.getSelection().removeAllRanges(),he("resized",{event:M},!0)),m.value.mouseDown=!1,m.value.activeSplitter=null,setTimeout(()=>{m.value.dragging=!1,g()},100)},b=(M,V)=>{"ontouchstart"in window&&(M.preventDefault(),u.value.splitter===V?(clearTimeout(u.value.timeoutId),u.value.timeoutId=null,N(M,V),u.value.splitter=null):(u.value.splitter=V,u.value.timeoutId=setTimeout(()=>u.value.splitter=null,500))),m.value.dragging||he("splitter-click",{event:M,index:V},!0)},N=(M,V)=>{if(he("splitter-dblclick",{event:M,index:V},!0),a.maximizePanes){let H=0;o.value=o.value.map((B,q)=>(B.size=q===V?B.max:B.min,q!==V&&(H+=B.min),B)),o.value[V].size-=H,he("pane-maximize",{event:M,index:V,pane:o.value[V]}),he("resized",{event:M,index:V},!0)}},R=(M,V)=>{he("pane-click",{event:M,index:r.value[V].index,pane:r.value[V]})},w=M=>{const V=l.value.getBoundingClientRect(),{clientX:H,clientY:B}="ontouchstart"in window&&M.touches?M.touches[0]:M;return{x:H-(a.horizontal?0:m.value.cursorOffset)-V.left,y:B-(a.horizontal?m.value.cursorOffset:0)-V.top}},T=M=>{M=M[a.horizontal?"y":"x"];const V=l.value[a.horizontal?"clientHeight":"clientWidth"];return a.rtl&&!a.horizontal&&(M=V-M),M*100/V},E=M=>{const V=m.value.activeSplitter;let H={prevPanesSize:F(V),nextPanesSize:P(V),prevReachedMinPanes:0,nextReachedMinPanes:0};const B=0+(a.pushOtherPanes?0:H.prevPanesSize),q=100-(a.pushOtherPanes?0:H.nextPanesSize),O=Math.max(Math.min(T(M),q),B);let Q=[V,V+1],J=o.value[Q[0]]||null,ie=o.value[Q[1]]||null;const Be=J.max<100&&O>=J.max+H.prevPanesSize,rt=ie.max<100&&O<=100-(ie.max+P(V+1));if(Be||rt){Be?(J.size=J.max,ie.size=Math.max(100-J.max-H.prevPanesSize-H.nextPanesSize,0)):(J.size=Math.max(100-ie.max-H.prevPanesSize-P(V+1),0),ie.size=ie.max);return}if(a.pushOtherPanes){const ut=A(H,O);if(!ut)return;({sums:H,panesToResize:Q}=ut),J=o.value[Q[0]]||null,ie=o.value[Q[1]]||null}J!==null&&(J.size=Math.min(Math.max(O-H.prevPanesSize-H.prevReachedMinPanes,J.min),J.max)),ie!==null&&(ie.size=Math.min(Math.max(100-O-H.nextPanesSize-H.nextReachedMinPanes,ie.min),ie.max))},A=(M,V)=>{const H=m.value.activeSplitter,B=[H,H+1];return V<M.prevPanesSize+o.value[B[0]].min&&(B[0]=L(H).index,M.prevReachedMinPanes=0,B[0]<H&&o.value.forEach((q,O)=>{O>B[0]&&O<=H&&(q.size=q.min,M.prevReachedMinPanes+=q.min)}),M.prevPanesSize=F(B[0]),B[0]===void 0)?(M.prevReachedMinPanes=0,o.value[0].size=o.value[0].min,o.value.forEach((q,O)=>{O>0&&O<=H&&(q.size=q.min,M.prevReachedMinPanes+=q.min)}),o.value[B[1]].size=100-M.prevReachedMinPanes-o.value[0].min-M.prevPanesSize-M.nextPanesSize,null):V>100-M.nextPanesSize-o.value[B[1]].min&&(B[1]=I(H).index,M.nextReachedMinPanes=0,B[1]>H+1&&o.value.forEach((q,O)=>{O>H&&O<B[1]&&(q.size=q.min,M.nextReachedMinPanes+=q.min)}),M.nextPanesSize=P(B[1]-1),B[1]===void 0)?(M.nextReachedMinPanes=0,o.value.forEach((q,O)=>{O<i.value-1&&O>=H+1&&(q.size=q.min,M.nextReachedMinPanes+=q.min)}),o.value[B[0]].size=100-M.prevPanesSize-P(B[0]-1),null):{sums:M,panesToResize:B}},F=M=>o.value.reduce((V,H,B)=>V+(B<M?H.size:0),0),P=M=>o.value.reduce((V,H,B)=>V+(B>M+1?H.size:0),0),L=M=>[...o.value].reverse().find(V=>V.index<M&&V.size>V.min)||{},I=M=>o.value.find(V=>V.index>M+1&&V.size>V.min)||{},W=()=>{var M;const V=Array.from(((M=l.value)==null?void 0:M.children)||[]);for(const H of V){const B=H.classList.contains("splitpanes__pane"),q=H.classList.contains("splitpanes__splitter");!B&&!q&&(H.remove(),console.warn("Splitpanes: Only <pane> elements are allowed at the root of <splitpanes>. One of your DOM nodes was removed."))}},Z=(M,V,H=!1)=>{const B=M-1,q=document.createElement("div");q.classList.add("splitpanes__splitter"),H||(q.onmousedown=O=>x(O,B),typeof window<"u"&&"ontouchstart"in window&&(q.ontouchstart=O=>x(O,B)),q.onclick=O=>b(O,B+1)),q.ondblclick=O=>N(O,B+1),V.parentNode.insertBefore(q,V)},re=M=>{M.onmousedown=void 0,M.onclick=void 0,M.ondblclick=void 0,M.remove()},le=()=>{var M;const V=Array.from(((M=l.value)==null?void 0:M.children)||[]);for(const B of V)B.className.includes("splitpanes__splitter")&&re(B);let H=0;for(const B of V)B.className.includes("splitpanes__pane")&&(!H&&a.firstSplitter?Z(H,B,!0):H&&Z(H,B),H++)},de=({uid:M,...V})=>{const H=r.value[M];for(const[B,q]of Object.entries(V))H[B]=q},me=M=>{var V;let H=-1;Array.from(((V=l.value)==null?void 0:V.children)||[]).some(B=>(B.className.includes("splitpanes__pane")&&H++,B.isSameNode(M.el))),o.value.splice(H,0,{...M,index:H}),o.value.forEach((B,q)=>B.index=q),c.value&&Rt(()=>{le(),ze({addedPane:o.value[H]}),he("pane-add",{pane:o.value[H]})})},Fe=M=>{const V=o.value.findIndex(B=>B.id===M);o.value[V].el=null;const H=o.value.splice(V,1)[0];o.value.forEach((B,q)=>B.index=q),Rt(()=>{le(),he("pane-remove",{pane:H}),ze({removedPane:{...H}})})},ze=(M={})=>{!M.addedPane&&!M.removedPane?ve():o.value.some(V=>V.givenSize!==null||V.min||V.max<100)?Je(M):st(),c.value&&he("resized")},st=()=>{const M=100/i.value;let V=0;const H=[],B=[];for(const q of o.value)q.size=Math.max(Math.min(M,q.max),q.min),V-=q.size,q.size>=q.max&&H.push(q.id),q.size<=q.min&&B.push(q.id);V>.1&&Ge(V,H,B)},ve=()=>{let M=100;const V=[],H=[];let B=0;for(const O of o.value)M-=O.size,O.givenSize!==null&&B++,O.size>=O.max&&V.push(O.id),O.size<=O.min&&H.push(O.id);let q=100;if(M>.1){for(const O of o.value)O.givenSize===null&&(O.size=Math.max(Math.min(M/(i.value-B),O.max),O.min)),q-=O.size;q>.1&&Ge(q,V,H)}},Je=({addedPane:M,removedPane:V}={})=>{let H=100/i.value,B=0;const q=[],O=[];((M==null?void 0:M.givenSize)??null)!==null&&(H=(100-M.givenSize)/(i.value-1));for(const Q of o.value)B-=Q.size,Q.size>=Q.max&&q.push(Q.id),Q.size<=Q.min&&O.push(Q.id);if(!(Math.abs(B)<.1)){for(const Q of o.value)(M==null?void 0:M.givenSize)!==null&&(M==null?void 0:M.id)===Q.id||(Q.size=Math.max(Math.min(H,Q.max),Q.min)),B-=Q.size,Q.size>=Q.max&&q.push(Q.id),Q.size<=Q.min&&O.push(Q.id);B>.1&&Ge(B,q,O)}},Ge=(M,V,H)=>{let B;M>0?B=M/(i.value-V.length):B=M/(i.value-H.length),o.value.forEach((q,O)=>{if(M>0&&!V.includes(q.id)){const Q=Math.max(Math.min(q.size+B,q.max),q.min),J=Q-q.size;M-=J,q.size=Q}else if(!H.includes(q.id)){const Q=Math.max(Math.min(q.size+B,q.max),q.min),J=Q-q.size;M-=J,q.size=Q}}),Math.abs(M)>.1&&Rt(()=>{c.value&&console.warn("Splitpanes: Could not resize panes correctly due to their constraints.")})},he=(M,V=void 0,H=!1)=>{const B=(V==null?void 0:V.index)??m.value.activeSplitter??null;e(M,{...V,...B!==null&&{index:B},...H&&B!==null&&{prevPane:o.value[B-(a.firstSplitter?1:0)],nextPane:o.value[B+(a.firstSplitter?0:1)]},panes:o.value.map(q=>({min:q.min,max:q.max,size:q.size}))})};ce(()=>a.firstSplitter,()=>le()),ha(()=>{W(),le(),ze(),he("ready"),c.value=!0}),sn(()=>c.value=!1);const ot=()=>{var M;return Po("div",{ref:l,class:p.value},(M=s.default)==null?void 0:M.call(s))};return dt("panes",o),dt("indexedPanes",r),dt("horizontal",$(()=>a.horizontal)),dt("requestUpdate",de),dt("onPaneAdd",me),dt("onPaneRemove",Fe),dt("onPaneClick",R),(M,V)=>(S(),D(Oo(ot)))}},mt={__name:"pane",props:{size:{type:[Number,String]},minSize:{type:[Number,String],default:0},maxSize:{type:[Number,String],default:100}},setup(n){var t;const e=n,a=pt("requestUpdate"),s=pt("onPaneAdd"),o=pt("horizontal"),r=pt("onPaneRemove"),i=pt("onPaneClick"),l=(t=Vo())==null?void 0:t.uid,c=pt("indexedPanes"),m=$(()=>c.value[l]),u=j(null),p=$(()=>{const v=isNaN(e.size)||e.size===void 0?0:parseFloat(e.size);return Math.max(Math.min(v,g.value),f.value)}),f=$(()=>{const v=parseFloat(e.minSize);return isNaN(v)?0:v}),g=$(()=>{const v=parseFloat(e.maxSize);return isNaN(v)?100:v}),x=$(()=>{var v;return`${o.value?"height":"width"}: ${(v=m.value)==null?void 0:v.size}%`});return ce(()=>p.value,v=>a({uid:l,size:v})),ce(()=>f.value,v=>a({uid:l,min:v})),ce(()=>g.value,v=>a({uid:l,max:v})),ha(()=>{s({id:l,el:u.value,min:f.value,max:g.value,givenSize:e.size===void 0?null:p.value,size:p.value})}),sn(()=>r(l)),(v,_)=>(S(),k("div",{ref_key:"paneEl",ref:u,class:"splitpanes__pane",onClick:_[0]||(_[0]=b=>d(i)(b,v._.uid)),style:Ct(x.value)},[Ke(v.$slots,"default")],4))}},fu={class:"w-full h-full"},vu={class:"flex flex-col w-full h-full overflow-y-auto"},hu={class:"flex flex-col flex-1 h-full p-1"},gu={class:"flex flex-col flex-1 h-full p-1 pl-0 relative"},yu=se({__name:"RawQueryLayout",props:{layout:{},customLayout:{},showResultPanel:{type:Boolean}},setup(n){const t=n,e=Ss(),{editorLayoutSizes:a,editorLayoutInnerVariableSizes:s}=ga(e),o=w=>{a.value=[w[0].size,w[1].size]},r=w=>{s.value=[w[0].size,w[1].size]},i=$(()=>a.value[0]),l=$(()=>s.value[0]),c=$(()=>s.value[1]),m=$(()=>a.value[1]),u=$(()=>t.layout===zt.horizontalWithVariables||t.layout===zt.vertical),p=$(()=>t.layout===zt.horizontalWithVariables),f=$(()=>!!t.customLayout),g=$(()=>{var w;return((w=t.customLayout)==null?void 0:w.direction)==="vertical"}),x=$(()=>{var w,T;return((T=(w=t.customLayout)==null?void 0:w.innerSplit)==null?void 0:T.direction)==="vertical"}),v=w=>{var A,F,P,L,I;const T=(A=t.customLayout)==null?void 0:A.id;if(!T)return((P=(F=t.customLayout)==null?void 0:F.panels[w])==null?void 0:P.defaultSize)??50;const E=e.customLayoutSizes[T];return(E==null?void 0:E.panels[w])??((I=(L=t.customLayout)==null?void 0:L.panels[w])==null?void 0:I.defaultSize)??50},_=w=>{var A,F,P,L,I,W,Z;const T=(A=t.customLayout)==null?void 0:A.id;if(!T)return((L=(P=(F=t.customLayout)==null?void 0:F.innerSplit)==null?void 0:P.panels[w])==null?void 0:L.defaultSize)??50;const E=e.customLayoutSizes[T];return(E==null?void 0:E.innerPanels[w])??((Z=(W=(I=t.customLayout)==null?void 0:I.innerSplit)==null?void 0:W.panels[w])==null?void 0:Z.defaultSize)??50},b=w=>{var E;const T=(E=t.customLayout)==null?void 0:E.id;T&&e.updateCustomLayoutSizes(T,w.map(A=>A.size))},N=w=>{var A,F,P;const T=(A=t.customLayout)==null?void 0:A.id;if(!T)return;const E=((F=e.customLayoutSizes[T])==null?void 0:F.panels)??((P=t.customLayout)==null?void 0:P.panels.map(L=>L.defaultSize))??[];e.updateCustomLayoutSizes(T,E,w.map(L=>L.size))},R={content:"flex flex-col w-full h-full overflow-y-auto",variables:"flex flex-col flex-1 h-full p-1",result:"flex flex-col flex-1 h-full p-1 pl-0 relative"};return(w,T)=>(S(),k("div",fu,[d(f)&&w.customLayout?(S(),D(d(Gt),{key:0,class:"default-theme",horizontal:d(g),onResize:T[1]||(T[1]=E=>b(E.panes))},{default:y(()=>[(S(!0),k(ae,null,ue(w.customLayout.panels,(E,A)=>(S(),k(ae,{key:A},[w.customLayout.innerSplit&&w.customLayout.innerSplit.panelIndex===A?(S(),D(d(mt),{key:0,size:v(A),"min-size":E.minSize,"max-size":E.maxSize},{default:y(()=>[h(d(Gt),{horizontal:d(x),class:"default-theme",onResize:T[0]||(T[0]=F=>N(F.panes))},{default:y(()=>[(S(!0),k(ae,null,ue(w.customLayout.innerSplit.panels,(F,P)=>(S(),D(d(mt),{key:`inner-${P}`,size:_(P),"min-size":F.minSize,"max-size":F.maxSize},{default:y(()=>[C("div",{class:xe(R[F.slot])},[Ke(w.$slots,F.slot)],2)]),_:2},1032,["size","min-size","max-size"]))),128))]),_:3},8,["horizontal"])]),_:2},1032,["size","min-size","max-size"])):(S(),D(d(mt),{key:1,size:v(A),"min-size":E.minSize,"max-size":E.maxSize},{default:y(()=>[C("div",{class:xe(R[E.slot])},[Ke(w.$slots,E.slot)],2)]),_:2},1032,["size","min-size","max-size"]))],64))),128))]),_:3},8,["horizontal"])):(S(),D(d(Gt),{key:1,onResize:T[3]||(T[3]=E=>o(E.panes)),class:"default-theme",horizontal:w.layout===d(zt).vertical},{default:y(()=>[h(d(mt),{size:d(i)},{default:y(()=>[h(d(Gt),{horizontal:d(p),onResize:T[2]||(T[2]=E=>d(u)?r(E.panes):null)},{default:y(()=>[h(d(mt),{size:d(u)?d(l):100,"min-size":"30"},{default:y(()=>[C("div",vu,[Ke(w.$slots,"content")])]),_:3},8,["size"]),d(u)?(S(),D(d(mt),{key:0,size:d(c),"min-size":"0","max-size":"70"},{default:y(()=>[C("div",hu,[Ke(w.$slots,"variables")])]),_:3},8,["size"])):K("",!0)]),_:3},8,["horizontal"])]),_:3},8,["size"]),t.showResultPanel!==!1?(S(),D(d(mt),{key:0,size:d(m),"min-size":"0","max-size":"80"},{default:y(()=>[C("div",gu,[Ke(w.$slots,"result")])]),_:3},8,["size"])):K("",!0)]),_:3},8,["horizontal"]))]))}});var ee=(n=>(n.RESULT="result",n.ERROR="error",n.INFO="info",n.RAW="raw",n.EXPLAIN="explain",n.CHART="chart",n))(ee||{}),G=(n=>(n.LINE="line",n.BAR="bar",n.HORIZONTAL_BAR="horizontal-bar",n.AREA="area",n.STACKED_BAR="stacked-bar",n.PIE="pie",n.DONUT="donut",n.SCATTER="scatter",n.HEATMAP="heatmap",n.RADAR="radar",n))(G||{}),ne=(n=>(n.NONE="none",n.SUM="sum",n.AVG="avg",n.COUNT="count",n.MIN="min",n.MAX="max",n))(ne||{}),fe=(n=>(n.NONE="none",n.X_ASC="x-asc",n.X_DESC="x-desc",n.Y_ASC="y-asc",n.Y_DESC="y-desc",n))(fe||{}),Re=(n=>(n.COMPARISON="comparison",n.COMPOSITION="composition",n.DISTRIBUTION="distribution",n.RELATIONSHIP="relationship",n.SPATIAL="spatial",n))(Re||{});G.LINE,G.BAR,G.HORIZONTAL_BAR,G.AREA,G.STACKED_BAR,G.PIE,G.DONUT,G.SCATTER,G.HEATMAP,G.RADAR;const wt={xAxisLabel:!1,xAxisNumeric:!1,yAxis:!1,yAxisHiddenOnCount:!1,categoryX:!1,categoryY:!1,valueColumn:!1,aggregation:!1,groupBy:!1,groupByRequired:!1,sortBy:!1,limitRows:!1,smoothLine:!1,showLabels:!1,showLegend:!1},It={...wt,xAxisLabel:!0,yAxis:!0,aggregation:!0,groupBy:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0},$e=new Map([[G.LINE,{value:G.LINE,label:"Line",icon:"hugeicons:chart-line-data-01",category:Re.COMPARISON,description:"Show trends over time or ordered categories",fields:{...It,smoothLine:!0}}],[G.BAR,{value:G.BAR,label:"Bar",icon:"hugeicons:chart-column",category:Re.COMPARISON,description:"Compare values across categories",fields:{...It}}],[G.HORIZONTAL_BAR,{value:G.HORIZONTAL_BAR,label:"Horizontal Bar",icon:"hugeicons:chart-histogram",category:Re.COMPARISON,description:"Compare values with long category labels",fields:{...It}}],[G.AREA,{value:G.AREA,label:"Area",icon:"hugeicons:chart-area",category:Re.COMPARISON,description:"Show volume and trends over time",fields:{...It,smoothLine:!0}}],[G.STACKED_BAR,{value:G.STACKED_BAR,label:"Stacked Bar",icon:"hugeicons:chart-histogram",category:Re.COMPOSITION,description:"Show part-to-whole across categories",fields:{...It,groupByRequired:!0}}],[G.PIE,{value:G.PIE,label:"Pie",icon:"hugeicons:pie-chart",category:Re.COMPOSITION,description:"Show proportions of a whole",fields:{...wt,xAxisLabel:!0,yAxis:!0,yAxisHiddenOnCount:!0,aggregation:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0}}],[G.DONUT,{value:G.DONUT,label:"Donut",icon:"hugeicons:circle",category:Re.COMPOSITION,description:"Show proportions with center metric",fields:{...wt,xAxisLabel:!0,yAxis:!0,yAxisHiddenOnCount:!0,aggregation:!0,sortBy:!0,limitRows:!0,showLabels:!0,showLegend:!0}}],[G.SCATTER,{value:G.SCATTER,label:"Scatter",icon:"hugeicons:chart-scatter",category:Re.RELATIONSHIP,description:"Discover correlations between two numeric fields",fields:{...wt,xAxisNumeric:!0,yAxis:!0,limitRows:!0,showLabels:!0}}],[G.HEATMAP,{value:G.HEATMAP,label:"Heatmap",icon:"hugeicons:grid",category:Re.SPATIAL,description:"Visualise density across two category dimensions",fields:{...wt,categoryX:!0,categoryY:!0,valueColumn:!0,showLabels:!0}}],[G.RADAR,{value:G.RADAR,label:"Radar",icon:"hugeicons:chart-relationship",category:Re.COMPARISON,description:"Compare multiple metrics on a radial grid",fields:{...wt,xAxisLabel:!0,yAxis:!0,aggregation:!0,limitRows:!0,showLabels:!0}}]]),xu=[{category:Re.COMPARISON,label:"Comparison",types:[$e.get(G.LINE),$e.get(G.BAR),$e.get(G.HORIZONTAL_BAR),$e.get(G.AREA),$e.get(G.RADAR)]},{category:Re.COMPOSITION,label:"Composition",types:[$e.get(G.STACKED_BAR),$e.get(G.PIE),$e.get(G.DONUT)]},{category:Re.RELATIONSHIP,label:"Relationship",types:[$e.get(G.SCATTER)]},{category:Re.SPATIAL,label:"Spatial",types:[$e.get(G.HEATMAP)]}],bu={class:"flex items-center gap-2"},Su={class:"text-[10px] text-muted-foreground/50 ml-auto"},Cu=se({__name:"ChartTypeSelector",props:{modelValue:{required:!0},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=Me(n,"modelValue");return(e,a)=>{const s=be;return S(),D(d(We),{modelValue:t.value,"onUpdate:modelValue":a[0]||(a[0]=o=>t.value=o),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Chart Type"})]),_:1}),h(d(Ye),{class:"max-h-72"},{default:y(()=>[(S(!0),k(ae,null,ue(d(xu),o=>(S(),D(d(Do),{key:o.category},{default:y(()=>[h(d(Fo),{class:"text-[10px] uppercase tracking-wider text-muted-foreground/60"},{default:y(()=>[z(U(o.label),1)]),_:2},1024),(S(!0),k(ae,null,ue(o.types,r=>(S(),D(d(pe),{key:r.value,value:r.value,class:"cursor-pointer"},{default:y(()=>[C("div",bu,[h(s,{name:r.icon,class:"size-3.5"},null,8,["name"]),C("span",null,U(r.label),1),C("span",Su,U(r.description),1)])]),_:2},1032,["value"]))),128))]),_:2},1024))),128))]),_:1})]),_:1},8,["modelValue"])}}}),wu={class:"w-80 border-l border-border flex h-full shrink-0 flex-col overflow-y-auto bg-background"},_u={class:"flex items-center justify-between border-b border-border px-3 py-2.5"},Ru={class:"flex items-center gap-2"},Tu={class:"flex items-center gap-1.5"},Eu={class:"flex-1 space-y-3 p-3"},Nu={class:"space-y-2"},Au={class:"space-y-1.5"},Mu={class:"space-y-1.5"},Iu={key:0,class:"space-y-2"},Lu={key:0,class:"space-y-1.5"},ku={key:1,class:"space-y-1.5"},zu={key:2,class:"space-y-1.5"},$u={key:3,class:"space-y-1.5"},Ou={key:4,class:"space-y-1.5"},Vu={key:5,class:"space-y-1.5"},Pu={key:1,class:"space-y-2"},Du={key:0,class:"space-y-1.5"},Fu={key:1,class:"space-y-1.5"},Bu={class:"text-xs font-medium text-muted-foreground"},Hu={key:0,class:"text-amber-500 text-xs ml-1"},qu={key:2,class:"space-y-1.5"},Uu={key:3,class:"space-y-1.5"},Ku={key:2,class:"space-y-2"},Gu={key:0,class:"flex items-center justify-between"},Wu={key:1,class:"flex items-center justify-between"},ju=se({__name:"ChartSettingsSidebar",props:ia({activeTabColumns:{}},{chartTitle:{required:!0},chartTitleModifiers:{},chartType:{required:!0},chartTypeModifiers:{},xAxisField:{required:!0},xAxisFieldModifiers:{},yAxisField:{required:!0},yAxisFieldModifiers:{},valueField:{required:!0},valueFieldModifiers:{},categoryYField:{required:!0},categoryYFieldModifiers:{},aggregation:{required:!0},aggregationModifiers:{},groupByField:{required:!0},groupByFieldModifiers:{},sortBy:{required:!0},sortByModifiers:{},limitRows:{required:!0},limitRowsModifiers:{},showLabels:{type:Boolean,required:!0},showLabelsModifiers:{},smoothLine:{type:Boolean,required:!0},smoothLineModifiers:{}}),emits:ia(["reset","export"],["update:chartTitle","update:chartType","update:xAxisField","update:yAxisField","update:valueField","update:categoryYField","update:aggregation","update:groupByField","update:sortBy","update:limitRows","update:showLabels","update:smoothLine"]),setup(n){const t=Me(n,"chartTitle"),e=Me(n,"chartType"),a=Me(n,"xAxisField"),s=Me(n,"yAxisField"),o=Me(n,"valueField"),r=Me(n,"categoryYField"),i=Me(n,"aggregation"),l=Me(n,"groupByField"),c=Me(n,"sortBy"),m=Me(n,"limitRows"),u=Me(n,"showLabels"),p=Me(n,"smoothLine"),f=$(()=>{const x=$e.get(e.value);return(x==null?void 0:x.fields)??null}),g=$(()=>{var x;return!(!((x=f.value)!=null&&x.yAxis)||f.value.yAxisHiddenOnCount&&i.value===ne.COUNT)});return(x,v)=>{const _=be;return S(),k("div",wu,[C("div",_u,[C("div",Ru,[h(_,{name:"hugeicons:chart-column",class:"size-4! text-muted-foreground"}),v[16]||(v[16]=C("span",{class:"text-sm font-medium"},"Chart Settings",-1))]),C("div",Tu,[a.value?(S(),D(d(Le),{key:0,variant:"ghost",size:"iconSm",onClick:v[0]||(v[0]=b=>x.$emit("export")),title:"Export chart as image"},{default:y(()=>[h(_,{name:"hugeicons:download-04",class:"size-4!"})]),_:1})):K("",!0),h(d(Le),{variant:"ghost",size:"iconSm",onClick:v[1]||(v[1]=b=>x.$emit("reset")),title:"Reset configuration"},{default:y(()=>[h(_,{name:"hugeicons:reload",class:"size-4!"})]),_:1})])]),C("div",Eu,[C("div",Nu,[C("div",Au,[v[17]||(v[17]=C("p",{class:"text-xs font-medium text-muted-foreground"},"Chart Title",-1)),h(d(bn),{modelValue:t.value,"onUpdate:modelValue":v[2]||(v[2]=b=>t.value=b),size:"sm",type:"text",placeholder:"Chart Title"},null,8,["modelValue"])]),C("div",Mu,[v[18]||(v[18]=C("p",{class:"text-xs font-medium text-muted-foreground"},"Chart Type",-1)),h(Cu,{modelValue:e.value,"onUpdate:modelValue":v[3]||(v[3]=b=>e.value=b)},null,8,["modelValue"])])]),f.value?(S(),k("div",Iu,[v[25]||(v[25]=C("p",{class:"text-sm font-medium"},"Data Mapping",-1)),f.value.xAxisLabel?(S(),k("div",Lu,[v[19]||(v[19]=C("p",{class:"text-xs font-medium text-muted-foreground"}," X-Axis (Label) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[4]||(v[4]=b=>a.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.xAxisNumeric?(S(),k("div",ku,[v[20]||(v[20]=C("p",{class:"text-xs font-medium text-muted-foreground"}," X-Axis (Numeric) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[5]||(v[5]=b=>a.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),g.value?(S(),k("div",zu,[v[21]||(v[21]=C("p",{class:"text-xs font-medium text-muted-foreground"}," Y-Axis (Values) ",-1)),h(d(We),{modelValue:s.value,"onUpdate:modelValue":v[6]||(v[6]=b=>s.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Y-Axis Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.categoryX?(S(),k("div",$u,[v[22]||(v[22]=C("p",{class:"text-xs font-medium text-muted-foreground"}," Category X (Columns) ",-1)),h(d(We),{modelValue:a.value,"onUpdate:modelValue":v[7]||(v[7]=b=>a.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select X Category Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.categoryY?(S(),k("div",Ou,[v[23]||(v[23]=C("p",{class:"text-xs font-medium text-muted-foreground"}," Category Y (Rows) ",-1)),h(d(We),{modelValue:r.value,"onUpdate:modelValue":v[8]||(v[8]=b=>r.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Y Category Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.valueColumn?(S(),k("div",Vu,[v[24]||(v[24]=C("p",{class:"text-xs font-medium text-muted-foreground"}," Value Column (Numeric) ",-1)),h(d(We),{modelValue:o.value,"onUpdate:modelValue":v[9]||(v[9]=b=>o.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Value Column"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0)])):K("",!0),f.value?(S(),k("div",Pu,[v[42]||(v[42]=C("p",{class:"text-sm font-medium"},"Transform",-1)),f.value.aggregation?(S(),k("div",Du,[v[32]||(v[32]=C("p",{class:"text-xs font-medium text-muted-foreground"},"Aggregation",-1)),h(d(We),{modelValue:i.value,"onUpdate:modelValue":v[10]||(v[10]=b=>i.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"Select Aggregation"})]),_:1}),h(d(Ye),null,{default:y(()=>[h(d(pe),{value:d(ne).NONE,class:"cursor-pointer"},{default:y(()=>v[26]||(v[26]=[z("None (Raw Rows)")])),_:1},8,["value"]),h(d(pe),{value:d(ne).SUM,class:"cursor-pointer"},{default:y(()=>v[27]||(v[27]=[z("Sum")])),_:1},8,["value"]),h(d(pe),{value:d(ne).AVG,class:"cursor-pointer"},{default:y(()=>v[28]||(v[28]=[z("Average")])),_:1},8,["value"]),h(d(pe),{value:d(ne).COUNT,class:"cursor-pointer"},{default:y(()=>v[29]||(v[29]=[z("Count")])),_:1},8,["value"]),h(d(pe),{value:d(ne).MIN,class:"cursor-pointer"},{default:y(()=>v[30]||(v[30]=[z("Min")])),_:1},8,["value"]),h(d(pe),{value:d(ne).MAX,class:"cursor-pointer"},{default:y(()=>v[31]||(v[31]=[z("Max")])),_:1},8,["value"])]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.groupBy?(S(),k("div",Fu,[C("p",Bu,[v[33]||(v[33]=z(" Group By (Legend) ")),f.value.groupByRequired?(S(),k("span",Hu,"(Required)")):K("",!0)]),h(d(We),{modelValue:l.value,"onUpdate:modelValue":v[11]||(v[11]=b=>l.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"No Grouping"})]),_:1}),h(d(Ye),{class:"max-h-60"},{default:y(()=>[h(d(pe),{value:"",class:"cursor-pointer"},{default:y(()=>v[34]||(v[34]=[z("No Grouping")])),_:1}),(S(!0),k(ae,null,ue(x.activeTabColumns,b=>(S(),D(d(pe),{key:b.queryFieldName,value:b.queryFieldName,class:"cursor-pointer"},{default:y(()=>[z(U(b.queryFieldName),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.sortBy?(S(),k("div",qu,[v[40]||(v[40]=C("p",{class:"text-xs font-medium text-muted-foreground"},"Sorting",-1)),h(d(We),{modelValue:c.value,"onUpdate:modelValue":v[12]||(v[12]=b=>c.value=b),size:"xs"},{default:y(()=>[h(d(je),{class:"w-full cursor-pointer"},{default:y(()=>[h(d(Qe),{placeholder:"No Sorting"})]),_:1}),h(d(Ye),null,{default:y(()=>[h(d(pe),{value:d(fe).NONE,class:"cursor-pointer"},{default:y(()=>v[35]||(v[35]=[z("No Sorting")])),_:1},8,["value"]),h(d(pe),{value:d(fe).X_ASC,class:"cursor-pointer"},{default:y(()=>v[36]||(v[36]=[z("X-Axis (Ascending)")])),_:1},8,["value"]),h(d(pe),{value:d(fe).X_DESC,class:"cursor-pointer"},{default:y(()=>v[37]||(v[37]=[z("X-Axis (Descending)")])),_:1},8,["value"]),h(d(pe),{value:d(fe).Y_ASC,class:"cursor-pointer"},{default:y(()=>v[38]||(v[38]=[z("Y-Axis (Ascending)")])),_:1},8,["value"]),h(d(pe),{value:d(fe).Y_DESC,class:"cursor-pointer"},{default:y(()=>v[39]||(v[39]=[z("Y-Axis (Descending)")])),_:1},8,["value"])]),_:1})]),_:1},8,["modelValue"])])):K("",!0),f.value.limitRows?(S(),k("div",Uu,[v[41]||(v[41]=C("p",{class:"text-xs font-medium text-muted-foreground"},"Limit Rows",-1)),h(d(bn),{"model-value":m.value===null?"":m.value,"onUpdate:modelValue":v[13]||(v[13]=b=>{const N=String(b);m.value=N===""?null:Math.max(1,parseInt(N,10)||1)}),size:"sm",type:"number",min:"1",placeholder:"All"},null,8,["model-value"])])):K("",!0)])):K("",!0),f.value?(S(),k("div",Ku,[v[45]||(v[45]=C("p",{class:"text-sm font-medium"},"Display",-1)),f.value.showLabels?(S(),k("div",Gu,[v[43]||(v[43]=C("div",{class:"flex flex-col gap-0.5"},[C("p",{class:"text-xs font-medium text-muted-foreground"}," Show Value Labels "),C("span",{class:"text-xs text-muted-foreground"},"Render values directly on series")],-1)),h(d(Sn),{modelValue:u.value,"onUpdate:modelValue":v[14]||(v[14]=b=>u.value=b),class:"cursor-pointer"},null,8,["modelValue"])])):K("",!0),f.value.smoothLine?(S(),k("div",Wu,[v[44]||(v[44]=C("div",{class:"flex flex-col gap-0.5"},[C("p",{class:"text-xs font-medium text-muted-foreground"},"Smooth Line"),C("span",{class:"text-xs text-muted-foreground"},"Curved lines instead of straight")],-1)),h(d(Sn),{modelValue:p.value,"onUpdate:modelValue":v[15]||(v[15]=b=>p.value=b),class:"cursor-pointer"},null,8,["modelValue"])])):K("",!0)])):K("",!0)])])}}});function Qu(n){n.eachSeriesByType("radar",function(t){var e=t.getData(),a=[],s=t.coordinateSystem;if(s){var o=s.getIndicatorAxes();Y(o,function(r,i){e.each(e.mapDimension(o[i].dim),function(l,c){a[c]=a[c]||[];var m=s.dataToPoint(l,i);a[c][i]=$n(m)?m:On(s)})}),e.each(function(r){var i=ri(a[r],function(l){return $n(l)})||On(s);a[r].push(i.slice()),e.setItemLayout(r,a[r])})}})}function $n(n){return!isNaN(n[0])&&!isNaN(n[1])}function On(n){return[n.cx,n.cy]}function Yu(n){var t=n.polar;if(t){ke(t)||(t=[t]);var e=[];Y(t,function(a,s){a.indicator?(a.type&&!a.shape&&(a.shape=a.type),n.radar=n.radar||[],ke(n.radar)||(n.radar=[n.radar]),n.radar.push(a)):e.push(a)}),n.polar=e}Y(n.series,function(a){a&&a.type==="radar"&&a.polarIndex&&(a.radarIndex=a.polarIndex)})}var Xu=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o=e.coordinateSystem,r=this.group,i=e.getData(),l=this._data;function c(p,f){var g=p.getItemVisual(f,"symbol")||"circle";if(g!=="none"){var x=li(p.getItemVisual(f,"symbolSize")),v=la(g,-1,-1,2,2),_=p.getItemVisual(f,"symbolRotate")||0;return v.attr({style:{strokeNoScale:!0},z2:100,scaleX:x[0]/2,scaleY:x[1]/2,rotation:_*Math.PI/180||0}),v}}function m(p,f,g,x,v,_){g.removeAll();for(var b=0;b<f.length-1;b++){var N=c(x,v);N&&(N.__dimIdx=b,p[b]?(N.setPosition(p[b]),ii[_?"initProps":"updateProps"](N,{x:f[b][0],y:f[b][1]},e,v)):N.setPosition(f[b]),g.add(N))}}function u(p){return qe(p,function(f){return[o.cx,o.cy]})}i.diff(l).add(function(p){var f=i.getItemLayout(p);if(f){var g=new un,x=new Ms,v={shape:{points:f}};g.shape.points=u(f),x.shape.points=u(f),_n(g,v,e,p),_n(x,v,e,p);var _=new Tt,b=new Tt;_.add(x),_.add(g),_.add(b),m(x.shape.points,f,b,i,p,!0),i.setItemGraphicEl(p,_)}}).update(function(p,f){var g=l.getItemGraphicEl(f),x=g.childAt(0),v=g.childAt(1),_=g.childAt(2),b={shape:{points:i.getItemLayout(p)}};b.shape.points&&(m(x.shape.points,b.shape.points,_,i,p,!1),Rn(v),Rn(x),Tn(x,b,e),Tn(v,b,e),i.setItemGraphicEl(p,g))}).remove(function(p){r.remove(l.getItemGraphicEl(p))}).execute(),i.eachItemGraphicEl(function(p,f){var g=i.getItemModel(f),x=p.childAt(0),v=p.childAt(1),_=p.childAt(2),b=i.getItemVisual(f,"style"),N=b.fill;r.add(p),x.useStyle(Et(g.getModel("lineStyle").getLineStyle(),{fill:"none",stroke:N})),En(x,g,"lineStyle"),En(v,g,"areaStyle");var R=g.getModel("areaStyle"),w=R.isEmpty()&&R.parentModel.isEmpty();v.ignore=w,Y(["emphasis","select","blur"],function(A){var F=g.getModel([A,"areaStyle"]),P=F.isEmpty()&&F.parentModel.isEmpty();v.ensureState(A).ignore=P&&w}),v.useStyle(Et(R.getAreaStyle(),{fill:N,opacity:.7,decal:b.decal}));var T=g.getModel("emphasis"),E=T.getModel("itemStyle").getItemStyle();_.eachChild(function(A){if(A instanceof cn){var F=A.style;A.useStyle(Is({image:F.image,x:F.x,y:F.y,width:F.width,height:F.height},b))}else A.useStyle(b),A.setColor(N),A.style.strokeNoScale=!0;var P=A.ensureState("emphasis");P.style=He(E);var L=i.getStore().get(i.getDimensionIndex(A.__dimIdx),f);(L==null||isNaN(L))&&(L=""),Ls(A,Ua(g),{labelFetcher:i.hostModel,labelDataIndex:f,labelDimIndex:A.__dimIdx,defaultText:L,inheritColor:N,defaultOpacity:b.opacity})}),ks(p,T.get("focus"),T.get("blurScope"),T.get("disabled"))}),this._data=i},t.prototype.remove=function(){this.group.removeAll(),this._data=null},t.type="radar",t}(zs),Zu=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.hasSymbolVisual=!0,e}return t.prototype.init=function(e){n.prototype.init.apply(this,arguments),this.legendVisualProvider=new Xi(Ie(this.getData,this),Ie(this.getRawData,this))},t.prototype.getInitialData=function(e,a){return Zi(this,{generateCoord:"indicator_",generateCoordCount:1/0})},t.prototype.formatTooltip=function(e,a,s){var o=this.getData(),r=this.coordinateSystem,i=r.getIndicatorAxes(),l=this.getData().getName(e),c=l===""?this.name:l,m=ui(this,e);return Nn("section",{header:c,sortBlocks:!0,blocks:qe(i,function(u){var p=o.get(o.mapDimension(u.dim),e);return Nn("nameValue",{markerType:"subItem",markerColor:m,name:u.name,value:p,sortParam:p})})})},t.prototype.getTooltipPosition=function(e){if(e!=null){for(var a=this.getData(),s=this.coordinateSystem,o=a.getValues(qe(s.dimensions,function(c){return a.mapDimension(c)}),e),r=0,i=o.length;r<i;r++)if(!isNaN(o[r])){var l=s.getIndicatorAxes();return s.coordToPoint(l[r].dataToCoord(o[r]),r)}}},t.type="series.radar",t.dependencies=["radar"],t.defaultOption={z:2,colorBy:"data",coordinateSystem:"radar",legendHoverLink:!0,radarIndex:0,lineStyle:{width:2,type:"solid",join:"round"},label:{position:"top"},symbolSize:8},t}($s),Lt=pi.value;function Wt(n,t){return Et({show:t},n)}var Ju=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.optionUpdated=function(){var e=this.get("boundaryGap"),a=this.get("splitNumber"),s=this.get("scale"),o=this.get("axisLine"),r=this.get("axisTick"),i=this.get("axisLabel"),l=this.get("axisName"),c=this.get(["axisName","show"]),m=this.get(["axisName","formatter"]),u=this.get("axisNameGap"),p=this.get("triggerEvent"),f=qe(this.get("indicator")||[],function(g){g.max!=null&&g.max>0&&!g.min?g.min=0:g.min!=null&&g.min<0&&!g.max&&(g.max=0);var x=l;g.color!=null&&(x=Et({color:g.color},l));var v=ua(He(g),{boundaryGap:e,splitNumber:a,scale:s,axisLine:o,axisTick:r,axisLabel:i,name:g.text,showName:c,nameLocation:"end",nameGap:u,nameTextStyle:x,triggerEvent:p},!1);if(ya(m)){var _=v.name;v.name=m.replace("{value}",_??"")}else Os(m)&&(v.name=m(v.name,v));var b=new ci(v,null,this.ecModel);return di(b,mi.prototype),b.mainType="radar",b.componentIndex=this.componentIndex,b},this);this._indicatorModels=f},t.prototype.getIndicatorModels=function(){return this._indicatorModels},t.type="radar",t.defaultOption={z:0,center:["50%","50%"],radius:"75%",startAngle:90,axisName:{show:!0},boundaryGap:[0,0],splitNumber:5,axisNameGap:15,scale:!1,shape:"polygon",axisLine:ua({lineStyle:{color:"#bbb"}},Lt.axisLine),axisLabel:Wt(Lt.axisLabel,!1),axisTick:Wt(Lt.axisTick,!1),splitLine:Wt(Lt.splitLine,!0),splitArea:Wt(Lt.splitArea,!0),indicator:[]},t}(Vs),ec=["axisLine","axisTickLabel","axisName"],tc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o=this.group;o.removeAll(),this._buildAxes(e),this._buildSplitLineAndArea(e)},t.prototype._buildAxes=function(e){var a=e.coordinateSystem,s=a.getIndicatorAxes(),o=qe(s,function(r){var i=r.model.get("showName")?r.name:"",l=new fi(r.model,{axisName:i,position:[a.cx,a.cy],rotation:r.angle,labelDirection:-1,tickDirection:-1,nameDirection:1});return l});Y(o,function(r){Y(ec,r.add,r),this.group.add(r.getGroup())},this)},t.prototype._buildSplitLineAndArea=function(e){var a=e.coordinateSystem,s=a.getIndicatorAxes();if(!s.length)return;var o=e.get("shape"),r=e.getModel("splitLine"),i=e.getModel("splitArea"),l=r.getModel("lineStyle"),c=i.getModel("areaStyle"),m=r.get("show"),u=i.get("show"),p=l.get("color"),f=c.get("color"),g=ke(p)?p:[p],x=ke(f)?f:[f],v=[],_=[];function b(re,le,de){var me=de%le.length;return re[me]=re[me]||[],me}if(o==="circle")for(var N=s[0].getTicksCoords(),R=a.cx,w=a.cy,T=0;T<N.length;T++){if(m){var E=b(v,g,T);v[E].push(new vi({shape:{cx:R,cy:w,r:N[T].coord}}))}if(u&&T<N.length-1){var E=b(_,x,T);_[E].push(new hi({shape:{cx:R,cy:w,r0:N[T].coord,r:N[T+1].coord}}))}}else for(var A,F=qe(s,function(re,le){var de=re.getTicksCoords();return A=A==null?de.length-1:Math.min(de.length-1,A),qe(de,function(me){return a.coordToPoint(me.coord,le)})}),P=[],T=0;T<=A;T++){for(var L=[],I=0;I<s.length;I++)L.push(F[I][T]);if(L[0]&&L.push(L[0].slice()),m){var E=b(v,g,T);v[E].push(new Ms({shape:{points:L}}))}if(u&&P){var E=b(_,x,T-1);_[E].push(new un({shape:{points:L.concat(P)}}))}P=L.slice().reverse()}var W=l.getLineStyle(),Z=c.getAreaStyle();Y(_,function(re,le){this.group.add(An(re,{style:Et({stroke:"none",fill:x[le%x.length]},Z),silent:!0}))},this),Y(v,function(re,le){this.group.add(An(re,{style:Et({fill:"none",stroke:g[le%g.length]},W),silent:!0}))},this)},t.type="radar",t}(Ps),ac=function(n){De(t,n);function t(e,a,s){var o=n.call(this,e,a,s)||this;return o.type="value",o.angle=0,o.name="",o}return t}(gi),nc=function(){function n(t,e,a){this.dimensions=[],this._model=t,this._indicatorAxes=qe(t.getIndicatorModels(),function(s,o){var r="indicator_"+o,i=new ac(r,new Mn);return i.name=s.get("name"),i.model=s,s.axis=i,this.dimensions.push(r),i},this),this.resize(t,a)}return n.prototype.getIndicatorAxes=function(){return this._indicatorAxes},n.prototype.dataToPoint=function(t,e){var a=this._indicatorAxes[e];return this.coordToPoint(a.dataToCoord(t),e)},n.prototype.coordToPoint=function(t,e){var a=this._indicatorAxes[e],s=a.angle,o=this.cx+t*Math.cos(s),r=this.cy-t*Math.sin(s);return[o,r]},n.prototype.pointToData=function(t){var e=t[0]-this.cx,a=t[1]-this.cy,s=Math.sqrt(e*e+a*a);e/=s,a/=s;for(var o=Math.atan2(-a,e),r=1/0,i,l=-1,c=0;c<this._indicatorAxes.length;c++){var m=this._indicatorAxes[c],u=Math.abs(o-m.angle);u<r&&(i=m,l=c,r=u)}return[l,+(i&&i.coordToData(s))]},n.prototype.resize=function(t,e){var a=t.get("center"),s=e.getWidth(),o=e.getHeight(),r=Math.min(s,o)/2;this.cx=Kt(a[0],s),this.cy=Kt(a[1],o),this.startAngle=t.get("startAngle")*Math.PI/180;var i=t.get("radius");(ya(i)||xi(i))&&(i=[0,i]),this.r0=Kt(i[0],r),this.r=Kt(i[1],r),Y(this._indicatorAxes,function(l,c){l.setExtent(this.r0,this.r);var m=this.startAngle+c*Math.PI*2/this._indicatorAxes.length;m=Math.atan2(Math.sin(m),Math.cos(m)),l.angle=m},this)},n.prototype.update=function(t,e){var a=this._indicatorAxes,s=this._model;Y(a,function(i){i.scale.setExtent(1/0,-1/0)}),t.eachSeriesByType("radar",function(i,l){if(!(i.get("coordinateSystem")!=="radar"||t.getComponent("radar",i.get("radarIndex"))!==s)){var c=i.getData();Y(a,function(m){m.scale.unionExtentFromData(c,c.mapDimension(m.dim))})}},this);var o=s.get("splitNumber"),r=new Mn;r.setExtent(0,o),r.setInterval(1),Y(a,function(i,l){yi(i.scale,i.model,r)})},n.prototype.convertToPixel=function(t,e,a){return console.warn("Not implemented."),null},n.prototype.convertFromPixel=function(t,e,a){return console.warn("Not implemented."),null},n.prototype.containPoint=function(t){return console.warn("Not implemented."),!1},n.create=function(t,e){var a=[];return t.eachComponent("radar",function(s){var o=new n(s,t,e);a.push(o),s.coordinateSystem=o}),t.eachSeriesByType("radar",function(s){s.get("coordinateSystem")==="radar"&&(s.coordinateSystem=a[s.get("radarIndex")||0])}),a},n.dimensions=[],n}();function qs(n){n.registerCoordinateSystem("radar",nc),n.registerComponentModel(Ju),n.registerComponentView(tc),n.registerVisual({seriesType:"radar",reset:function(t){var e=t.getData();e.each(function(a){e.setItemVisual(a,"legendIcon","roundRect")}),e.setVisual("legendIcon","roundRect")}})}function sc(n){ca(qs),n.registerChartView(Xu),n.registerSeriesModel(Zu),n.registerLayout(Qu),n.registerProcessor(Ji("radar")),n.registerPreprocessor(Yu)}var Ft=Y,oc=gt,ma=-1,Ce=function(){function n(t){var e=t.mappingMethod,a=t.type,s=this.option=He(t);this.type=a,this.mappingMethod=e,this._normalizeData=lc[e];var o=n.visualHandlers[a];this.applyVisual=o.applyVisual,this.getColorMapper=o.getColorMapper,this._normalizedToVisual=o._normalizedToVisual[e],e==="piecewise"?(Oa(s),rc(s)):e==="category"?s.categories?ic(s):Oa(s,!0):(Ci(e!=="linear"||s.dataExtent),Oa(s))}return n.prototype.mapValueToVisual=function(t){var e=this._normalizeData(t);return this._normalizedToVisual(e,t)},n.prototype.getNormalizer=function(){return Ie(this._normalizeData,this)},n.listVisualTypes=function(){return bi(n.visualHandlers)},n.isValidType=function(t){return n.visualHandlers.hasOwnProperty(t)},n.eachVisual=function(t,e,a){gt(t)?Y(t,e,a):e.call(a,t)},n.mapVisual=function(t,e,a){var s,o=ke(t)?[]:gt(t)?{}:(s=!0,null);return n.eachVisual(t,function(r,i){var l=e.call(a,r,i);s?o=l:o[i]=l}),o},n.retrieveVisuals=function(t){var e={},a;return t&&Ft(n.visualHandlers,function(s,o){t.hasOwnProperty(o)&&(e[o]=t[o],a=!0)}),a?e:null},n.prepareVisualTypes=function(t){if(ke(t))t=t.slice();else if(oc(t)){var e=[];Ft(t,function(a,s){e.push(s)}),t=e}else return[];return t.sort(function(a,s){return s==="color"&&a!=="color"&&a.indexOf("color")===0?1:-1}),t},n.dependsOn=function(t,e){return e==="color"?!!(t&&t.indexOf(e)===0):t===e},n.findPieceIndex=function(t,e,a){for(var s,o=1/0,r=0,i=e.length;r<i;r++){var l=e[r].value;if(l!=null){if(l===t||ya(l)&&l===t+"")return r;a&&p(l,r)}}for(var r=0,i=e.length;r<i;r++){var c=e[r],m=c.interval,u=c.close;if(m){if(m[0]===-1/0){if(Qt(u[1],t,m[1]))return r}else if(m[1]===1/0){if(Qt(u[0],m[0],t))return r}else if(Qt(u[0],m[0],t)&&Qt(u[1],t,m[1]))return r;a&&p(m[0],r),a&&p(m[1],r)}}if(a)return t===1/0?e.length-1:t===-1/0?0:s;function p(f,g){var x=Math.abs(f-t);x<o&&(o=x,s=g)}},n.visualHandlers={color:{applyVisual:kt("color"),getColorMapper:function(){var t=this.option;return Ie(t.mappingMethod==="category"?function(e,a){return!a&&(e=this._normalizeData(e)),$t.call(this,e)}:function(e,a,s){var o=!!s;return!a&&(e=this._normalizeData(e)),s=Aa(e,t.parsedVisual,s),o?s:Na(s,"rgba")},this)},_normalizedToVisual:{linear:function(t){return Na(Aa(t,this.option.parsedVisual),"rgba")},category:$t,piecewise:function(t,e){var a=Wa.call(this,e);return a==null&&(a=Na(Aa(t,this.option.parsedVisual),"rgba")),a},fixed:ft}},colorHue:jt(function(t,e){return Ma(t,e)}),colorSaturation:jt(function(t,e){return Ma(t,null,e)}),colorLightness:jt(function(t,e){return Ma(t,null,null,e)}),colorAlpha:jt(function(t,e){return _i(t,e)}),decal:{applyVisual:kt("decal"),_normalizedToVisual:{linear:null,category:$t,piecewise:null,fixed:null}},opacity:{applyVisual:kt("opacity"),_normalizedToVisual:Ga([0,1])},liftZ:{applyVisual:kt("liftZ"),_normalizedToVisual:{linear:ft,category:ft,piecewise:ft,fixed:ft}},symbol:{applyVisual:function(t,e,a){var s=this.mapValueToVisual(t);a("symbol",s)},_normalizedToVisual:{linear:Vn,category:$t,piecewise:function(t,e){var a=Wa.call(this,e);return a==null&&(a=Vn.call(this,t)),a},fixed:ft}},symbolSize:{applyVisual:kt("symbolSize"),_normalizedToVisual:Ga([0,1])}},n}();function rc(n){var t=n.pieceList;n.hasSpecialVisual=!1,Y(t,function(e,a){e.originIndex=a,e.visual!=null&&(n.hasSpecialVisual=!0)})}function ic(n){var t=n.categories,e=n.categoryMap={},a=n.visual;if(Ft(t,function(r,i){e[r]=i}),!ke(a)){var s=[];gt(a)?Ft(a,function(r,i){var l=e[i];s[l??ma]=r}):s[ma]=a,a=Us(n,s)}for(var o=t.length-1;o>=0;o--)a[o]==null&&(delete e[t[o]],t.pop())}function Oa(n,t){var e=n.visual,a=[];gt(e)?Ft(e,function(o){a.push(o)}):e!=null&&a.push(e);var s={color:1,symbol:1};!t&&a.length===1&&!s.hasOwnProperty(n.type)&&(a[1]=a[0]),Us(n,a)}function jt(n){return{applyVisual:function(t,e,a){var s=this.mapValueToVisual(t);a("color",n(e("color"),s))},_normalizedToVisual:Ga([0,1])}}function Vn(n){var t=this.option.visual;return t[Math.round(yt(n,[0,1],[0,t.length-1],!0))]||{}}function kt(n){return function(t,e,a){a(n,this.mapValueToVisual(t))}}function $t(n){var t=this.option.visual;return t[this.option.loop&&n!==ma?n%t.length:n]}function ft(){return this.option.visual[0]}function Ga(n){return{linear:function(t){return yt(t,n,this.option.visual,!0)},category:$t,piecewise:function(t,e){var a=Wa.call(this,e);return a==null&&(a=yt(t,n,this.option.visual,!0)),a},fixed:ft}}function Wa(n){var t=this.option,e=t.pieceList;if(t.hasSpecialVisual){var a=Ce.findPieceIndex(n,e),s=e[a];if(s&&s.visual)return s.visual[this.type]}}function Us(n,t){return n.visual=t,n.type==="color"&&(n.parsedVisual=qe(t,function(e){var a=wi(e);return a||[0,0,0,1]})),t}var lc={linear:function(n){return yt(n,this.option.dataExtent,[0,1],!0)},piecewise:function(n){var t=this.option.pieceList,e=Ce.findPieceIndex(n,t,!0);if(e!=null)return yt(e,[0,t.length-1],[0,1],!0)},category:function(n){var t=this.option.categories?this.option.categoryMap[n]:n;return t??ma},fixed:Si};function Qt(n,t,e){return n?t<=e:t<e}function uc(n,t,e,a,s,o){n=n||0;var r=e[1]-e[0];if(s!=null&&(s=bt(s,[0,r])),o!=null&&(o=Math.max(o,s??0)),a==="all"){var i=Math.abs(t[1]-t[0]);i=bt(i,[0,r]),s=o=bt(i,[s,o]),a=0}t[0]=bt(t[0],e),t[1]=bt(t[1],e);var l=Va(t,a);t[a]+=n;var c=s||0,m=e.slice();l.sign<0?m[0]+=c:m[1]-=c,t[a]=bt(t[a],m);var u;return u=Va(t,a),s!=null&&(u.sign!==l.sign||u.span<s)&&(t[1-a]=t[a]+l.sign*s),u=Va(t,a),o!=null&&u.span>o&&(t[1-a]=t[a]+u.sign*o),t}function Va(n,t){var e=n[t]-n[1-t];return{span:Math.abs(e),sign:e>0?-1:e<0?1:t?-1:1}}function bt(n,t){return Math.min(t[1]!=null?t[1]:1/0,Math.max(t[0]!=null?t[0]:-1/0,n))}var cc=256,dc=function(){function n(){this.blurSize=30,this.pointSize=20,this.maxOpacity=1,this.minOpacity=0,this._gradientPixels={inRange:null,outOfRange:null};var t=In.createCanvas();this.canvas=t}return n.prototype.update=function(t,e,a,s,o,r){var i=this._getBrush(),l=this._getGradient(o,"inRange"),c=this._getGradient(o,"outOfRange"),m=this.pointSize+this.blurSize,u=this.canvas,p=u.getContext("2d"),f=t.length;u.width=e,u.height=a;for(var g=0;g<f;++g){var x=t[g],v=x[0],_=x[1],b=x[2],N=s(b);p.globalAlpha=N,p.drawImage(i,v-m,_-m)}if(!u.width||!u.height)return u;for(var R=p.getImageData(0,0,u.width,u.height),w=R.data,T=0,E=w.length,A=this.minOpacity,F=this.maxOpacity,P=F-A;T<E;){var N=w[T+3]/256,L=Math.floor(N*(cc-1))*4;if(N>0){var I=r(N)?l:c;N>0&&(N=N*P+A),w[T++]=I[L],w[T++]=I[L+1],w[T++]=I[L+2],w[T++]=I[L+3]*N*256}else T+=4}return p.putImageData(R,0,0),u},n.prototype._getBrush=function(){var t=this._brushCanvas||(this._brushCanvas=In.createCanvas()),e=this.pointSize+this.blurSize,a=e*2;t.width=a,t.height=a;var s=t.getContext("2d");return s.clearRect(0,0,a,a),s.shadowOffsetX=a,s.shadowBlur=this.blurSize,s.shadowColor="#000",s.beginPath(),s.arc(-e,e,this.pointSize,0,Math.PI*2,!0),s.closePath(),s.fill(),t},n.prototype._getGradient=function(t,e){for(var a=this._gradientPixels,s=a[e]||(a[e]=new Uint8ClampedArray(256*4)),o=[0,0,0,0],r=0,i=0;i<256;i++)t[e](i/255,!0,o),s[r++]=o[0],s[r++]=o[1],s[r++]=o[2],s[r++]=o[3];return s},n}();function mc(n,t,e){var a=n[1]-n[0];t=qe(t,function(r){return{interval:[(r.interval[0]-n[0])/a,(r.interval[1]-n[0])/a]}});var s=t.length,o=0;return function(r){var i;for(i=o;i<s;i++){var l=t[i].interval;if(l[0]<=r&&r<=l[1]){o=i;break}}if(i===s)for(i=o-1;i>=0;i--){var l=t[i].interval;if(l[0]<=r&&r<=l[1]){o=i;break}}return i>=0&&i<s&&e[i]}}function pc(n,t){var e=n[1]-n[0];return t=[(t[0]-n[0])/e,(t[1]-n[0])/e],function(a){return a>=t[0]&&a<=t[1]}}function Pn(n){var t=n.dimensions;return t[0]==="lng"&&t[1]==="lat"}var fc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,a,s){var o;a.eachComponent("visualMap",function(i){i.eachTargetSeries(function(l){l===e&&(o=i)})}),this._progressiveEls=null,this.group.removeAll();var r=e.coordinateSystem;r.type==="cartesian2d"||r.type==="calendar"?this._renderOnCartesianAndCalendar(e,s,0,e.getData().count()):Pn(r)&&this._renderOnGeo(r,e,o,s)},t.prototype.incrementalPrepareRender=function(e,a,s){this.group.removeAll()},t.prototype.incrementalRender=function(e,a,s,o){var r=a.coordinateSystem;r&&(Pn(r)?this.render(a,s,o):(this._progressiveEls=[],this._renderOnCartesianAndCalendar(a,o,e.start,e.end,!0)))},t.prototype.eachRendered=function(e){Ri(this._progressiveEls||this.group,e)},t.prototype._renderOnCartesianAndCalendar=function(e,a,s,o,r){var i=e.coordinateSystem,l=Ti(i,"cartesian2d"),c,m,u,p;if(l){var f=i.getAxis("x"),g=i.getAxis("y");c=f.getBandWidth()+.5,m=g.getBandWidth()+.5,u=f.scale.getExtent(),p=g.scale.getExtent()}for(var x=this.group,v=e.getData(),_=e.getModel(["emphasis","itemStyle"]).getItemStyle(),b=e.getModel(["blur","itemStyle"]).getItemStyle(),N=e.getModel(["select","itemStyle"]).getItemStyle(),R=e.get(["itemStyle","borderRadius"]),w=Ua(e),T=e.getModel("emphasis"),E=T.get("focus"),A=T.get("blurScope"),F=T.get("disabled"),P=l?[v.mapDimension("x"),v.mapDimension("y"),v.mapDimension("value")]:[v.mapDimension("time"),v.mapDimension("value")],L=s;L<o;L++){var I=void 0,W=v.getItemVisual(L,"style");if(l){var Z=v.get(P[0],L),re=v.get(P[1],L);if(isNaN(v.get(P[2],L))||isNaN(Z)||isNaN(re)||Z<u[0]||Z>u[1]||re<p[0]||re>p[1])continue;var le=i.dataToPoint([Z,re]);I=new da({shape:{x:le[0]-c/2,y:le[1]-m/2,width:c,height:m},style:W})}else{if(isNaN(v.get(P[1],L)))continue;I=new da({z2:1,shape:i.dataToRect([v.get(P[0],L)]).contentShape,style:W})}if(v.hasItemOption){var de=v.getItemModel(L),me=de.getModel("emphasis");_=me.getModel("itemStyle").getItemStyle(),b=de.getModel(["blur","itemStyle"]).getItemStyle(),N=de.getModel(["select","itemStyle"]).getItemStyle(),R=de.get(["itemStyle","borderRadius"]),E=me.get("focus"),A=me.get("blurScope"),F=me.get("disabled"),w=Ua(de)}I.shape.r=R;var Fe=e.getRawValue(L),ze="-";Fe&&Fe[2]!=null&&(ze=Fe[2]+""),Ls(I,w,{labelFetcher:e,labelDataIndex:L,defaultOpacity:W.opacity,defaultText:ze}),I.ensureState("emphasis").style=_,I.ensureState("blur").style=b,I.ensureState("select").style=N,ks(I,E,A,F),I.incremental=r,r&&(I.states.emphasis.hoverLayer=!0),x.add(I),v.setItemGraphicEl(L,I),this._progressiveEls&&this._progressiveEls.push(I)}},t.prototype._renderOnGeo=function(e,a,s,o){var r=s.targetVisuals.inRange,i=s.targetVisuals.outOfRange,l=a.getData(),c=this._hmLayer||this._hmLayer||new dc;c.blurSize=a.get("blurSize"),c.pointSize=a.get("pointSize"),c.minOpacity=a.get("minOpacity"),c.maxOpacity=a.get("maxOpacity");var m=e.getViewRect().clone(),u=e.getRoamTransform();m.applyTransform(u);var p=Math.max(m.x,0),f=Math.max(m.y,0),g=Math.min(m.width+m.x,o.getWidth()),x=Math.min(m.height+m.y,o.getHeight()),v=g-p,_=x-f,b=[l.mapDimension("lng"),l.mapDimension("lat"),l.mapDimension("value")],N=l.mapArray(b,function(E,A,F){var P=e.dataToPoint([E,A]);return P[0]-=p,P[1]-=f,P.push(F),P}),R=s.getExtent(),w=s.type==="visualMap.continuous"?pc(R,s.option.range):mc(R,s.getPieceList(),s.option.selected);c.update(N,v,_,r.color.getNormalizer(),{inRange:r.color.getColorMapper(),outOfRange:i.color.getColorMapper()},w);var T=new cn({style:{width:v,height:_,x:p,y:f,image:c.canvas},silent:!0});this.group.add(T)},t.type="heatmap",t}(zs),vc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(e,a){return Ei(null,this,{generateCoord:"value"})},t.prototype.preventIncremental=function(){var e=Ni.get(this.get("coordinateSystem"));if(e&&e.dimensions)return e.dimensions[0]==="lng"&&e.dimensions[1]==="lat"},t.type="series.heatmap",t.dependencies=["grid","geo","calendar"],t.defaultOption={coordinateSystem:"cartesian2d",z:2,geoIndex:0,blurSize:30,pointSize:20,maxOpacity:1,minOpacity:0,select:{itemStyle:{borderColor:"#212121"}}},t}($s);function hc(n){n.registerChartView(fc),n.registerSeriesModel(vc)}var Dn=Y;function Fn(n){if(n){for(var t in n)if(n.hasOwnProperty(t))return!0}}function Bn(n,t,e){var a={};return Dn(t,function(o){var r=a[o]=s();Dn(n[o],function(i,l){if(Ce.isValidType(l)){var c={type:l,visual:i};e&&e(c,o),r[l]=new Ce(c),l==="opacity"&&(c=He(c),c.type="colorAlpha",r.__hidden.__alphaForOpacity=new Ce(c))}})}),a;function s(){var o=function(){};o.prototype.__hidden=o.prototype;var r=new o;return r}}function gc(n,t,e){var a;Y(e,function(s){t.hasOwnProperty(s)&&Fn(t[s])&&(a=!0)}),a&&Y(e,function(s){t.hasOwnProperty(s)&&Fn(t[s])?n[s]=He(t[s]):delete n[s]})}function yc(n,t,e,a){var s={};return Y(n,function(o){var r=Ce.prepareVisualTypes(t[o]);s[o]=r}),{progress:function(r,i){var l;a!=null&&(l=i.getDimensionIndex(a));function c(w){return Ai(i,u,w)}function m(w,T){Mi(i,u,w,T)}for(var u,p=i.getStore();(u=r.next())!=null;){var f=i.getRawDataItem(u);if(!(f&&f.visualMap===!1))for(var g=a!=null?p.get(l,u):u,x=e(g),v=t[x],_=s[x],b=0,N=_.length;b<N;b++){var R=_[b];v[R]&&v[R].applyVisual(g,c,m)}}}}}var Ks={get:function(n,t,e){var a=He((xc[n]||{})[t]);return e&&ke(a)?a[a.length-1]:a}},xc={color:{active:["#006edd","#e0ffff"],inactive:["rgba(0,0,0,0)"]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},Hn=Ce.mapVisual,bc=Ce.eachVisual,Sc=ke,qn=Y,Cc=Ds,wc=yt,pa=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.stateList=["inRange","outOfRange"],e.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],e.layoutMode={type:"box",ignoreSize:!0},e.dataBound=[-1/0,1/0],e.targetVisuals={},e.controllerVisuals={},e}return t.prototype.init=function(e,a,s){this.mergeDefaultAndTheme(e,s)},t.prototype.optionUpdated=function(e,a){var s=this.option;!a&&gc(s,e,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(e){var a=this.stateList;e=Ie(e,this),this.controllerVisuals=Bn(this.option.controller,a,e),this.targetVisuals=Bn(this.option.target,a,e)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var e=this.option.seriesIndex,a=[];return e==null||e==="all"?this.ecModel.eachSeries(function(s,o){a.push(o)}):a=Ii(e),a},t.prototype.eachTargetSeries=function(e,a){Y(this.getTargetSeriesIndices(),function(s){var o=this.ecModel.getSeriesByIndex(s);o&&e.call(a,o)},this)},t.prototype.isTargetSeries=function(e){var a=!1;return this.eachTargetSeries(function(s){s===e&&(a=!0)}),a},t.prototype.formatValueText=function(e,a,s){var o=this.option,r=o.precision,i=this.dataBound,l=o.formatter,c;s=s||["<",">"],ke(e)&&(e=e.slice(),c=!0);var m=a?e:c?[u(e[0]),u(e[1])]:u(e);if(ya(l))return l.replace("{value}",c?m[0]:m).replace("{value2}",c?m[1]:m);if(Os(l))return c?l(e[0],e[1]):l(e);if(c)return e[0]===i[0]?s[0]+" "+m[1]:e[1]===i[1]?s[1]+" "+m[0]:m[0]+" - "+m[1];return m;function u(p){return p===i[0]?"min":p===i[1]?"max":(+p).toFixed(Math.min(r,20))}},t.prototype.resetExtent=function(){var e=this.option,a=Cc([e.min,e.max]);this._dataExtent=a},t.prototype.getDataDimensionIndex=function(e){var a=this.option.dimension;if(a!=null)return e.getDimensionIndex(a);for(var s=e.dimensions,o=s.length-1;o>=0;o--){var r=s[o],i=e.getDimensionInfo(r);if(!i.isCalculationCoord)return i.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var e=this.ecModel,a=this.option,s={inRange:a.inRange,outOfRange:a.outOfRange},o=a.target||(a.target={}),r=a.controller||(a.controller={});ua(o,s),ua(r,s);var i=this.isCategory();l.call(this,o),l.call(this,r),c.call(this,o,"inRange","outOfRange"),m.call(this,r);function l(u){Sc(a.color)&&!u.inRange&&(u.inRange={color:a.color.slice().reverse()}),u.inRange=u.inRange||{color:e.get("gradientColor")}}function c(u,p,f){var g=u[p],x=u[f];g&&!x&&(x=u[f]={},qn(g,function(v,_){if(Ce.isValidType(_)){var b=Ks.get(_,"inactive",i);b!=null&&(x[_]=b,_==="color"&&!x.hasOwnProperty("opacity")&&!x.hasOwnProperty("colorAlpha")&&(x.opacity=[0,0]))}}))}function m(u){var p=(u.inRange||{}).symbol||(u.outOfRange||{}).symbol,f=(u.inRange||{}).symbolSize||(u.outOfRange||{}).symbolSize,g=this.get("inactiveColor"),x=this.getItemSymbol(),v=x||"roundRect";qn(this.stateList,function(_){var b=this.itemSize,N=u[_];N||(N=u[_]={color:i?g:[g]}),N.symbol==null&&(N.symbol=p&&He(p)||(i?v:[v])),N.symbolSize==null&&(N.symbolSize=f&&He(f)||(i?b[0]:[b[0],b[0]])),N.symbol=Hn(N.symbol,function(T){return T==="none"?v:T});var R=N.symbolSize;if(R!=null){var w=-1/0;bc(R,function(T){T>w&&(w=T)}),N.symbolSize=Hn(R,function(T){return wc(T,[0,w],[0,b[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(e){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(e){return null},t.prototype.getVisualMeta=function(e){return null},t.type="visualMap",t.dependencies=["series"],t.defaultOption={show:!0,z:4,seriesIndex:"all",min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",contentColor:"#5793f3",inactiveColor:"#aaa",borderWidth:0,padding:5,textGap:10,precision:0,textStyle:{color:"#333"}},t}(Vs),Un=[20,140],_c=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.optionUpdated=function(e,a){n.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(s){s.mappingMethod="linear",s.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){n.prototype.resetItemSize.apply(this,arguments);var e=this.itemSize;(e[0]==null||isNaN(e[0]))&&(e[0]=Un[0]),(e[1]==null||isNaN(e[1]))&&(e[1]=Un[1])},t.prototype._resetRange=function(){var e=this.getExtent(),a=this.option.range;!a||a.auto?(e.auto=1,this.option.range=e):ke(a)&&(a[0]>a[1]&&a.reverse(),a[0]=Math.max(a[0],e[0]),a[1]=Math.min(a[1],e[1]))},t.prototype.completeVisualOption=function(){n.prototype.completeVisualOption.apply(this,arguments),Y(this.stateList,function(e){var a=this.option.controller[e].symbolSize;a&&a[0]!==a[1]&&(a[0]=a[1]/3)},this)},t.prototype.setSelected=function(e){this.option.range=e.slice(),this._resetRange()},t.prototype.getSelected=function(){var e=this.getExtent(),a=Ds((this.get("range")||[]).slice());return a[0]>e[1]&&(a[0]=e[1]),a[1]>e[1]&&(a[1]=e[1]),a[0]<e[0]&&(a[0]=e[0]),a[1]<e[0]&&(a[1]=e[0]),a},t.prototype.getValueState=function(e){var a=this.option.range,s=this.getExtent();return(a[0]<=s[0]||a[0]<=e)&&(a[1]>=s[1]||e<=a[1])?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var a=[];return this.eachTargetSeries(function(s){var o=[],r=s.getData();r.each(this.getDataDimensionIndex(r),function(i,l){e[0]<=i&&i<=e[1]&&o.push(l)},this),a.push({seriesId:s.id,dataIndex:o})},this),a},t.prototype.getVisualMeta=function(e){var a=Kn(this,"outOfRange",this.getExtent()),s=Kn(this,"inRange",this.option.range.slice()),o=[];function r(f,g){o.push({value:f,color:e(f,g)})}for(var i=0,l=0,c=s.length,m=a.length;l<m&&(!s.length||a[l]<=s[0]);l++)a[l]<s[i]&&r(a[l],"outOfRange");for(var u=1;i<c;i++,u=0)u&&o.length&&r(s[i],"outOfRange"),r(s[i],"inRange");for(var u=1;l<m;l++)(!s.length||s[s.length-1]<a[l])&&(u&&(o.length&&r(o[o.length-1].value,"outOfRange"),u=0),r(a[l],"outOfRange"));var p=o.length;return{stops:o,outerColors:[p?o[0].color:"transparent",p?o[p-1].color:"transparent"]}},t.type="visualMap.continuous",t.defaultOption=Fs(pa.defaultOption,{align:"auto",calculable:!1,hoverLink:!0,realtime:!0,handleIcon:"path://M-11.39,9.77h0a3.5,3.5,0,0,1-3.5,3.5h-22a3.5,3.5,0,0,1-3.5-3.5h0a3.5,3.5,0,0,1,3.5-3.5h22A3.5,3.5,0,0,1-11.39,9.77Z",handleSize:"120%",handleStyle:{borderColor:"#fff",borderWidth:1},indicatorIcon:"circle",indicatorSize:"50%",indicatorStyle:{borderColor:"#fff",borderWidth:2,shadowBlur:2,shadowOffsetX:1,shadowOffsetY:1,shadowColor:"rgba(0,0,0,0.2)"}}),t}(pa);function Kn(n,t,e){if(e[0]===e[1])return e.slice();for(var a=200,s=(e[1]-e[0])/a,o=e[0],r=[],i=0;i<=a&&o<e[1];i++)r.push(o),o+=s;return r.push(e[1]),r}var Gs=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e.autoPositionValues={left:1,right:1,top:1,bottom:1},e}return t.prototype.init=function(e,a){this.ecModel=e,this.api=a},t.prototype.render=function(e,a,s,o){if(this.visualMapModel=e,e.get("show")===!1){this.group.removeAll();return}this.doRender(e,a,s,o)},t.prototype.renderBackground=function(e){var a=this.visualMapModel,s=Li(a.get("padding")||0),o=e.getBoundingRect();e.add(new da({z2:-1,silent:!0,shape:{x:o.x-s[3],y:o.y-s[0],width:o.width+s[3]+s[1],height:o.height+s[0]+s[2]},style:{fill:a.get("backgroundColor"),stroke:a.get("borderColor"),lineWidth:a.get("borderWidth")}}))},t.prototype.getControllerVisual=function(e,a,s){s=s||{};var o=s.forceState,r=this.visualMapModel,i={};if(a==="color"){var l=r.get("contentColor");i.color=l}function c(f){return i[f]}function m(f,g){i[f]=g}var u=r.controllerVisuals[o||r.getValueState(e)],p=Ce.prepareVisualTypes(u);return Y(p,function(f){var g=u[f];s.convertOpacityToAlpha&&f==="opacity"&&(f="colorAlpha",g=u.__alphaForOpacity),Ce.dependsOn(f,a)&&g&&g.applyVisual(e,c,m)}),i[a]},t.prototype.positionGroup=function(e){var a=this.visualMapModel,s=this.api;ki(e,a.getBoxLayoutParams(),{width:s.getWidth(),height:s.getHeight()})},t.prototype.doRender=function(e,a,s,o){},t.type="visualMap",t}(Ps),Gn=[["left","right","width"],["top","bottom","height"]];function Ws(n,t,e){var a=n.option,s=a.align;if(s!=null&&s!=="auto")return s;for(var o={width:t.getWidth(),height:t.getHeight()},r=a.orient==="horizontal"?1:0,i=Gn[r],l=[0,null,10],c={},m=0;m<3;m++)c[Gn[1-r][m]]=l[m],c[i[m]]=m===2?e[0]:a[i[m]];var u=[["x","width",3],["y","height",0]][r],p=zi(c,o,a.padding);return i[(p.margin[u[2]]||0)+p[u[0]]+p[u[1]]*.5<o[u[1]]*.5?0:1]}function aa(n,t){return Y(n||[],function(e){e.dataIndex!=null&&(e.dataIndexInside=e.dataIndex,e.dataIndex=null),e.highlightKey="visualMap"+(t?t.componentIndex:"")}),n}var Xe=yt,Rc=Y,Wn=Math.min,Pa=Math.max,Tc=12,Ec=6,Nc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e._shapes={},e._dataInterval=[],e._handleEnds=[],e._hoverLinkDataIndices=[],e}return t.prototype.init=function(e,a){n.prototype.init.call(this,e,a),this._hoverLinkFromSeriesMouseOver=Ie(this._hoverLinkFromSeriesMouseOver,this),this._hideIndicator=Ie(this._hideIndicator,this)},t.prototype.doRender=function(e,a,s,o){(!o||o.type!=="selectDataRange"||o.from!==this.uid)&&this._buildView()},t.prototype._buildView=function(){this.group.removeAll();var e=this.visualMapModel,a=this.group;this._orient=e.get("orient"),this._useHandle=e.get("calculable"),this._resetInterval(),this._renderBar(a);var s=e.get("text");this._renderEndsText(a,s,0),this._renderEndsText(a,s,1),this._updateView(!0),this.renderBackground(a),this._updateView(),this._enableHoverLinkToSeries(),this._enableHoverLinkFromSeries(),this.positionGroup(a)},t.prototype._renderEndsText=function(e,a,s){if(a){var o=a[1-s];o=o!=null?o+"":"";var r=this.visualMapModel,i=r.get("textGap"),l=r.itemSize,c=this._shapes.mainGroup,m=this._applyTransform([l[0]/2,s===0?-i:l[1]+i],c),u=this._applyTransform(s===0?"bottom":"top",c),p=this._orient,f=this.visualMapModel.textStyleModel;this.group.add(new Pt({style:ea(f,{x:m[0],y:m[1],verticalAlign:p==="horizontal"?"middle":u,align:p==="horizontal"?u:"center",text:o})}))}},t.prototype._renderBar=function(e){var a=this.visualMapModel,s=this._shapes,o=a.itemSize,r=this._orient,i=this._useHandle,l=Ws(a,this.api,o),c=s.mainGroup=this._createBarGroup(l),m=new Tt;c.add(m),m.add(s.outOfRange=jn()),m.add(s.inRange=jn(null,i?Yn(this._orient):null,Ie(this._dragHandle,this,"all",!1),Ie(this._dragHandle,this,"all",!0))),m.setClipPath(new da({shape:{x:0,y:0,width:o[0],height:o[1],r:3}}));var u=a.textStyleModel.getTextRect("国"),p=Pa(u.width,u.height);i&&(s.handleThumbs=[],s.handleLabels=[],s.handleLabelPoints=[],this._createHandle(a,c,0,o,p,r),this._createHandle(a,c,1,o,p,r)),this._createIndicator(a,c,o,p,r),e.add(c)},t.prototype._createHandle=function(e,a,s,o,r,i){var l=Ie(this._dragHandle,this,s,!1),c=Ie(this._dragHandle,this,s,!0),m=Ln(e.get("handleSize"),o[0]),u=la(e.get("handleIcon"),-m/2,-m/2,m,m,null,!0),p=Yn(this._orient);u.attr({cursor:p,draggable:!0,drift:l,ondragend:c,onmousemove:function(_){Ka(_.event)}}),u.x=o[0]/2,u.useStyle(e.getModel("handleStyle").getItemStyle()),u.setStyle({strokeNoScale:!0,strokeFirst:!0}),u.style.lineWidth*=2,u.ensureState("emphasis").style=e.getModel(["emphasis","handleStyle"]).getItemStyle(),$i(u,!0),a.add(u);var f=this.visualMapModel.textStyleModel,g=new Pt({cursor:p,draggable:!0,drift:l,onmousemove:function(_){Ka(_.event)},ondragend:c,style:ea(f,{x:0,y:0,text:""})});g.ensureState("blur").style={opacity:.1},g.stateTransition={duration:200},this.group.add(g);var x=[m,0],v=this._shapes;v.handleThumbs[s]=u,v.handleLabelPoints[s]=x,v.handleLabels[s]=g},t.prototype._createIndicator=function(e,a,s,o,r){var i=Ln(e.get("indicatorSize"),s[0]),l=la(e.get("indicatorIcon"),-i/2,-i/2,i,i,null,!0);l.attr({cursor:"move",invisible:!0,silent:!0,x:s[0]/2});var c=e.getModel("indicatorStyle").getItemStyle();if(l instanceof cn){var m=l.style;l.useStyle(Is({image:m.image,x:m.x,y:m.y,width:m.width,height:m.height},c))}else l.useStyle(c);a.add(l);var u=this.visualMapModel.textStyleModel,p=new Pt({silent:!0,invisible:!0,style:ea(u,{x:0,y:0,text:""})});this.group.add(p);var f=[(r==="horizontal"?o/2:Ec)+s[0]/2,0],g=this._shapes;g.indicator=l,g.indicatorLabel=p,g.indicatorLabelPoint=f,this._firstShowIndicator=!0},t.prototype._dragHandle=function(e,a,s,o){if(this._useHandle){if(this._dragging=!a,!a){var r=this._applyTransform([s,o],this._shapes.mainGroup,!0);this._updateInterval(e,r[1]),this._hideIndicator(),this._updateView()}a===!this.visualMapModel.get("realtime")&&this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()}),a?!this._hovering&&this._clearHoverLinkToSeries():Qn(this.visualMapModel)&&this._doHoverLinkToSeries(this._handleEnds[e],!1)}},t.prototype._resetInterval=function(){var e=this.visualMapModel,a=this._dataInterval=e.getSelected(),s=e.getExtent(),o=[0,e.itemSize[1]];this._handleEnds=[Xe(a[0],s,o,!0),Xe(a[1],s,o,!0)]},t.prototype._updateInterval=function(e,a){a=a||0;var s=this.visualMapModel,o=this._handleEnds,r=[0,s.itemSize[1]];uc(a,o,r,e,0);var i=s.getExtent();this._dataInterval=[Xe(o[0],r,i,!0),Xe(o[1],r,i,!0)]},t.prototype._updateView=function(e){var a=this.visualMapModel,s=a.getExtent(),o=this._shapes,r=[0,a.itemSize[1]],i=e?r:this._handleEnds,l=this._createBarVisual(this._dataInterval,s,i,"inRange"),c=this._createBarVisual(s,s,r,"outOfRange");o.inRange.setStyle({fill:l.barColor}).setShape("points",l.barPoints),o.outOfRange.setStyle({fill:c.barColor}).setShape("points",c.barPoints),this._updateHandle(i,l)},t.prototype._createBarVisual=function(e,a,s,o){var r={forceState:o,convertOpacityToAlpha:!0},i=this._makeColorGradient(e,r),l=[this.getControllerVisual(e[0],"symbolSize",r),this.getControllerVisual(e[1],"symbolSize",r)],c=this._createBarPoints(s,l);return{barColor:new Oi(0,0,0,1,i),barPoints:c,handlesColor:[i[0].color,i[i.length-1].color]}},t.prototype._makeColorGradient=function(e,a){var s=100,o=[],r=(e[1]-e[0])/s;o.push({color:this.getControllerVisual(e[0],"color",a),offset:0});for(var i=1;i<s;i++){var l=e[0]+r*i;if(l>e[1])break;o.push({color:this.getControllerVisual(l,"color",a),offset:i/s})}return o.push({color:this.getControllerVisual(e[1],"color",a),offset:1}),o},t.prototype._createBarPoints=function(e,a){var s=this.visualMapModel.itemSize;return[[s[0]-a[0],e[0]],[s[0],e[0]],[s[0],e[1]],[s[0]-a[1],e[1]]]},t.prototype._createBarGroup=function(e){var a=this._orient,s=this.visualMapModel.get("inverse");return new Tt(a==="horizontal"&&!s?{scaleX:e==="bottom"?1:-1,rotation:Math.PI/2}:a==="horizontal"&&s?{scaleX:e==="bottom"?-1:1,rotation:-Math.PI/2}:a==="vertical"&&!s?{scaleX:e==="left"?1:-1,scaleY:-1}:{scaleX:e==="left"?1:-1})},t.prototype._updateHandle=function(e,a){if(this._useHandle){var s=this._shapes,o=this.visualMapModel,r=s.handleThumbs,i=s.handleLabels,l=o.itemSize,c=o.getExtent(),m=this._applyTransform("left",s.mainGroup);Rc([0,1],function(u){var p=r[u];p.setStyle("fill",a.handlesColor[u]),p.y=e[u];var f=Xe(e[u],[0,l[1]],c,!0),g=this.getControllerVisual(f,"symbolSize");p.scaleX=p.scaleY=g/l[0],p.x=l[0]-g/2;var x=Ia(s.handleLabelPoints[u],La(p,this.group));if(this._orient==="horizontal"){var v=m==="left"||m==="top"?(l[0]-g)/2:(l[0]-g)/-2;x[1]+=v}i[u].setStyle({x:x[0],y:x[1],text:o.formatValueText(this._dataInterval[u]),verticalAlign:"middle",align:this._orient==="vertical"?this._applyTransform("left",s.mainGroup):"center"})},this)}},t.prototype._showIndicator=function(e,a,s,o){var r=this.visualMapModel,i=r.getExtent(),l=r.itemSize,c=[0,l[1]],m=this._shapes,u=m.indicator;if(u){u.attr("invisible",!1);var p={convertOpacityToAlpha:!0},f=this.getControllerVisual(e,"color",p),g=this.getControllerVisual(e,"symbolSize"),x=Xe(e,i,c,!0),v=l[0]-g/2,_={x:u.x,y:u.y};u.y=x,u.x=v;var b=Ia(m.indicatorLabelPoint,La(u,this.group)),N=m.indicatorLabel;N.attr("invisible",!1);var R=this._applyTransform("left",m.mainGroup),w=this._orient,T=w==="horizontal";N.setStyle({text:(s||"")+r.formatValueText(a),verticalAlign:T?R:"middle",align:T?"center":R});var E={x:v,y:x,style:{fill:f}},A={style:{x:b[0],y:b[1]}};if(r.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var F={duration:100,easing:"cubicInOut",additive:!0};u.x=_.x,u.y=_.y,u.animateTo(E,F),N.animateTo(A,F)}else u.attr(E),N.attr(A);this._firstShowIndicator=!1;var P=this._shapes.handleLabels;if(P)for(var L=0;L<P.length;L++)this.api.enterBlur(P[L])}},t.prototype._enableHoverLinkToSeries=function(){var e=this;this._shapes.mainGroup.on("mousemove",function(a){if(e._hovering=!0,!e._dragging){var s=e.visualMapModel.itemSize,o=e._applyTransform([a.offsetX,a.offsetY],e._shapes.mainGroup,!0,!0);o[1]=Wn(Pa(0,o[1]),s[1]),e._doHoverLinkToSeries(o[1],0<=o[0]&&o[0]<=s[0])}}).on("mouseout",function(){e._hovering=!1,!e._dragging&&e._clearHoverLinkToSeries()})},t.prototype._enableHoverLinkFromSeries=function(){var e=this.api.getZr();this.visualMapModel.option.hoverLink?(e.on("mouseover",this._hoverLinkFromSeriesMouseOver,this),e.on("mouseout",this._hideIndicator,this)):this._clearHoverLinkFromSeries()},t.prototype._doHoverLinkToSeries=function(e,a){var s=this.visualMapModel,o=s.itemSize;if(s.option.hoverLink){var r=[0,o[1]],i=s.getExtent();e=Wn(Pa(r[0],e),r[1]);var l=Ac(s,i,r),c=[e-l,e+l],m=Xe(e,r,i,!0),u=[Xe(c[0],r,i,!0),Xe(c[1],r,i,!0)];c[0]<r[0]&&(u[0]=-1/0),c[1]>r[1]&&(u[1]=1/0),a&&(u[0]===-1/0?this._showIndicator(m,u[1],"< ",l):u[1]===1/0?this._showIndicator(m,u[0],"> ",l):this._showIndicator(m,m,"≈ ",l));var p=this._hoverLinkDataIndices,f=[];(a||Qn(s))&&(f=this._hoverLinkDataIndices=s.findTargetDataIndices(u));var g=Vi(p,f);this._dispatchHighDown("downplay",aa(g[0],s)),this._dispatchHighDown("highlight",aa(g[1],s))}},t.prototype._hoverLinkFromSeriesMouseOver=function(e){var a;if(Pi(e.target,function(l){var c=Di(l);if(c.dataIndex!=null)return a=c,!0},!0),!!a){var s=this.ecModel.getSeriesByIndex(a.seriesIndex),o=this.visualMapModel;if(o.isTargetSeries(s)){var r=s.getData(a.dataType),i=r.getStore().get(o.getDataDimensionIndex(r),a.dataIndex);isNaN(i)||this._showIndicator(i,i)}}},t.prototype._hideIndicator=function(){var e=this._shapes;e.indicator&&e.indicator.attr("invisible",!0),e.indicatorLabel&&e.indicatorLabel.attr("invisible",!0);var a=this._shapes.handleLabels;if(a)for(var s=0;s<a.length;s++)this.api.leaveBlur(a[s])},t.prototype._clearHoverLinkToSeries=function(){this._hideIndicator();var e=this._hoverLinkDataIndices;this._dispatchHighDown("downplay",aa(e,this.visualMapModel)),e.length=0},t.prototype._clearHoverLinkFromSeries=function(){this._hideIndicator();var e=this.api.getZr();e.off("mouseover",this._hoverLinkFromSeriesMouseOver),e.off("mouseout",this._hideIndicator)},t.prototype._applyTransform=function(e,a,s,o){var r=La(a,o?null:this.group);return ke(e)?Ia(e,r,s):Fi(e,r,s)},t.prototype._dispatchHighDown=function(e,a){a&&a.length&&this.api.dispatchAction({type:e,batch:a})},t.prototype.dispose=function(){this._clearHoverLinkFromSeries(),this._clearHoverLinkToSeries()},t.type="visualMap.continuous",t}(Gs);function jn(n,t,e,a){return new un({shape:{points:n},draggable:!!e,cursor:t,drift:e,onmousemove:function(s){Ka(s.event)},ondragend:a})}function Ac(n,t,e){var a=Tc/2,s=n.get("hoverLinkDataSize");return s&&(a=Xe(s,t,e,!0)/2),a}function Qn(n){var t=n.get("hoverLinkOnHandle");return!!(t??n.get("realtime"))}function Yn(n){return n==="vertical"?"ns-resize":"ew-resize"}var Mc={type:"selectDataRange",event:"dataRangeSelected",update:"update"},Ic=function(n,t){t.eachComponent({mainType:"visualMap",query:n},function(e){e.setSelected(n.selected)})},Lc=[{createOnAllSeries:!0,reset:function(n,t){var e=[];return t.eachComponent("visualMap",function(a){var s=n.pipelineContext;!a.isTargetSeries(n)||s&&s.large||e.push(yc(a.stateList,a.targetVisuals,Ie(a.getValueState,a),a.getDataDimensionIndex(n.getData())))}),e}},{createOnAllSeries:!0,reset:function(n,t){var e=n.getData(),a=[];t.eachComponent("visualMap",function(s){if(s.isTargetSeries(n)){var o=s.getVisualMeta(Ie(kc,null,n,s))||{stops:[],outerColors:[]},r=s.getDataDimensionIndex(e);r>=0&&(o.dimension=r,a.push(o))}}),n.getData().setVisual("visualMeta",a)}}];function kc(n,t,e,a){for(var s=t.targetVisuals[a],o=Ce.prepareVisualTypes(s),r={color:Bi(n.getData(),"color")},i=0,l=o.length;i<l;i++){var c=o[i],m=s[c==="opacity"?"__alphaForOpacity":c];m&&m.applyVisual(e,u,p)}return r.color;function u(f){return r[f]}function p(f,g){r[f]=g}}var Xn=Y;function zc(n){var t=n&&n.visualMap;ke(t)||(t=t?[t]:[]),Xn(t,function(e){if(e){St(e,"splitList")&&!St(e,"pieces")&&(e.pieces=e.splitList,delete e.splitList);var a=e.pieces;a&&ke(a)&&Xn(a,function(s){gt(s)&&(St(s,"start")&&!St(s,"min")&&(s.min=s.start),St(s,"end")&&!St(s,"max")&&(s.max=s.end))})}})}function St(n,t){return n&&n.hasOwnProperty&&n.hasOwnProperty(t)}var Zn=!1;function js(n){Zn||(Zn=!0,n.registerSubTypeDefaulter("visualMap",function(t){return!t.categories&&(!(t.pieces?t.pieces.length>0:t.splitNumber>0)||t.calculable)?"continuous":"piecewise"}),n.registerAction(Mc,Ic),Y(Lc,function(t){n.registerVisual(n.PRIORITY.VISUAL.COMPONENT,t)}),n.registerPreprocessor(zc))}function $c(n){n.registerComponentModel(_c),n.registerComponentView(Nc),js(n)}var Oc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e._pieceList=[],e}return t.prototype.optionUpdated=function(e,a){n.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var s=this._mode=this._determineMode();this._pieceList=[],Vc[this._mode].call(this,this._pieceList),this._resetSelected(e,a);var o=this.option.categories;this.resetVisual(function(r,i){s==="categories"?(r.mappingMethod="category",r.categories=He(o)):(r.dataExtent=this.getExtent(),r.mappingMethod="piecewise",r.pieceList=qe(this._pieceList,function(l){return l=He(l),i!=="inRange"&&(l.visual=null),l}))})},t.prototype.completeVisualOption=function(){var e=this.option,a={},s=Ce.listVisualTypes(),o=this.isCategory();Y(e.pieces,function(i){Y(s,function(l){i.hasOwnProperty(l)&&(a[l]=1)})}),Y(a,function(i,l){var c=!1;Y(this.stateList,function(m){c=c||r(e,m,l)||r(e.target,m,l)},this),!c&&Y(this.stateList,function(m){(e[m]||(e[m]={}))[l]=Ks.get(l,m==="inRange"?"active":"inactive",o)})},this);function r(i,l,c){return i&&i[l]&&i[l].hasOwnProperty(c)}n.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(e,a){var s=this.option,o=this._pieceList,r=(a?s:e).selected||{};if(s.selected=r,Y(o,function(l,c){var m=this.getSelectedMapKey(l);r.hasOwnProperty(m)||(r[m]=!0)},this),s.selectedMode==="single"){var i=!1;Y(o,function(l,c){var m=this.getSelectedMapKey(l);r[m]&&(i?r[m]=!1:i=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get("itemSymbol")},t.prototype.getSelectedMapKey=function(e){return this._mode==="categories"?e.value+"":e.index+""},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var e=this.option;return e.pieces&&e.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},t.prototype.setSelected=function(e){this.option.selected=He(e)},t.prototype.getValueState=function(e){var a=Ce.findPieceIndex(e,this._pieceList);return a!=null&&this.option.selected[this.getSelectedMapKey(this._pieceList[a])]?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(e){var a=[],s=this._pieceList;return this.eachTargetSeries(function(o){var r=[],i=o.getData();i.each(this.getDataDimensionIndex(i),function(l,c){var m=Ce.findPieceIndex(l,s);m===e&&r.push(c)},this),a.push({seriesId:o.id,dataIndex:r})},this),a},t.prototype.getRepresentValue=function(e){var a;if(this.isCategory())a=e.value;else if(e.value!=null)a=e.value;else{var s=e.interval||[];a=s[0]===-1/0&&s[1]===1/0?0:(s[0]+s[1])/2}return a},t.prototype.getVisualMeta=function(e){if(this.isCategory())return;var a=[],s=["",""],o=this;function r(m,u){var p=o.getRepresentValue({interval:m});u||(u=o.getValueState(p));var f=e(p,u);m[0]===-1/0?s[0]=f:m[1]===1/0?s[1]=f:a.push({value:m[0],color:f},{value:m[1],color:f})}var i=this._pieceList.slice();if(!i.length)i.push({interval:[-1/0,1/0]});else{var l=i[0].interval[0];l!==-1/0&&i.unshift({interval:[-1/0,l]}),l=i[i.length-1].interval[1],l!==1/0&&i.push({interval:[l,1/0]})}var c=-1/0;return Y(i,function(m){var u=m.interval;u&&(u[0]>c&&r([c,u[0]],"outOfRange"),r(u.slice()),c=u[1])},this),{stops:a,outerColors:s}},t.type="visualMap.piecewise",t.defaultOption=Fs(pa.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),t}(pa),Vc={splitNumber:function(n){var t=this.option,e=Math.min(t.precision,20),a=this.getExtent(),s=t.splitNumber;s=Math.max(parseInt(s,10),1),t.splitNumber=s;for(var o=(a[1]-a[0])/s;+o.toFixed(e)!==o&&e<5;)e++;t.precision=e,o=+o.toFixed(e),t.minOpen&&n.push({interval:[-1/0,a[0]],close:[0,0]});for(var r=0,i=a[0];r<s;i+=o,r++){var l=r===s-1?a[1]:i+o;n.push({interval:[i,l],close:[1,1]})}t.maxOpen&&n.push({interval:[a[1],1/0],close:[0,0]}),kn(n),Y(n,function(c,m){c.index=m,c.text=this.formatValueText(c.interval)},this)},categories:function(n){var t=this.option;Y(t.categories,function(e){n.push({text:this.formatValueText(e,!0),value:e})},this),Jn(t,n)},pieces:function(n){var t=this.option;Y(t.pieces,function(e,a){gt(e)||(e={value:e});var s={text:"",index:a};if(e.label!=null&&(s.text=e.label),e.hasOwnProperty("value")){var o=s.value=e.value;s.interval=[o,o],s.close=[1,1]}else{for(var r=s.interval=[],i=s.close=[0,0],l=[1,0,1],c=[-1/0,1/0],m=[],u=0;u<2;u++){for(var p=[["gte","gt","min"],["lte","lt","max"]][u],f=0;f<3&&r[u]==null;f++)r[u]=e[p[f]],i[u]=l[f],m[u]=f===2;r[u]==null&&(r[u]=c[u])}m[0]&&r[1]===1/0&&(i[0]=0),m[1]&&r[0]===-1/0&&(i[1]=0),r[0]===r[1]&&i[0]&&i[1]&&(s.value=r[0])}s.visual=Ce.retrieveVisuals(e),n.push(s)},this),Jn(t,n),kn(n),Y(n,function(e){var a=e.close,s=[["<","≤"][a[1]],[">","≥"][a[0]]];e.text=e.text||this.formatValueText(e.value!=null?e.value:e.interval,!1,s)},this)}};function Jn(n,t){var e=n.inverse;(n.orient==="vertical"?!e:e)&&t.reverse()}var Pc=function(n){De(t,n);function t(){var e=n!==null&&n.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.doRender=function(){var e=this.group;e.removeAll();var a=this.visualMapModel,s=a.get("textGap"),o=a.textStyleModel,r=o.getFont(),i=o.getTextColor(),l=this._getItemAlign(),c=a.itemSize,m=this._getViewData(),u=m.endsText,p=Hi(a.get("showLabel",!0),!u),f=!a.get("selectedMode");u&&this._renderEndsText(e,u[0],c,p,l),Y(m.viewPieceList,function(g){var x=g.piece,v=new Tt;v.onclick=Ie(this._onItemClick,this,x),this._enableHoverLink(v,g.indexInModelPieceList);var _=a.getRepresentValue(x);if(this._createItemSymbol(v,_,[0,0,c[0],c[1]],f),p){var b=this.visualMapModel.getValueState(_);v.add(new Pt({style:{x:l==="right"?-s:c[0]+s,y:c[1]/2,text:x.text,verticalAlign:"middle",align:l,font:r,fill:i,opacity:b==="outOfRange"?.5:1},silent:f}))}e.add(v)},this),u&&this._renderEndsText(e,u[1],c,p,l),qi(a.get("orient"),e,a.get("itemGap")),this.renderBackground(e),this.positionGroup(e)},t.prototype._enableHoverLink=function(e,a){var s=this;e.on("mouseover",function(){return o("highlight")}).on("mouseout",function(){return o("downplay")});var o=function(r){var i=s.visualMapModel;i.option.hoverLink&&s.api.dispatchAction({type:r,batch:aa(i.findTargetDataIndices(a),i)})}},t.prototype._getItemAlign=function(){var e=this.visualMapModel,a=e.option;if(a.orient==="vertical")return Ws(e,this.api,e.itemSize);var s=a.align;return(!s||s==="auto")&&(s="left"),s},t.prototype._renderEndsText=function(e,a,s,o,r){if(a){var i=new Tt,l=this.visualMapModel.textStyleModel;i.add(new Pt({style:ea(l,{x:o?r==="right"?s[0]:0:s[0]/2,y:s[1]/2,verticalAlign:"middle",align:o?r:"center",text:a})})),e.add(i)}},t.prototype._getViewData=function(){var e=this.visualMapModel,a=qe(e.getPieceList(),function(i,l){return{piece:i,indexInModelPieceList:l}}),s=e.get("text"),o=e.get("orient"),r=e.get("inverse");return(o==="horizontal"?r:!r)?a.reverse():s&&(s=s.slice().reverse()),{viewPieceList:a,endsText:s}},t.prototype._createItemSymbol=function(e,a,s,o){var r=la(this.getControllerVisual(a,"symbol"),s[0],s[1],s[2],s[3],this.getControllerVisual(a,"color"));r.silent=o,e.add(r)},t.prototype._onItemClick=function(e){var a=this.visualMapModel,s=a.option,o=s.selectedMode;if(o){var r=He(s.selected),i=a.getSelectedMapKey(e);o==="single"||o===!0?(r[i]=!0,Y(r,function(l,c){r[c]=c===i})):r[i]=!r[i],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:r})}},t.type="visualMap.piecewise",t}(Gs);function Dc(n){n.registerComponentModel(Oc),n.registerComponentView(Pc),js(n)}function Fc(n){ca($c),ca(Dc)}const Bc={class:"flex-grow flex flex-col h-full bg-background relative p-3"},Hc={key:0,class:"mb-4"},qc={key:1,class:"mb-4"},Uc={key:2,class:"mb-4"},Kc={key:3,class:"flex-grow flex items-center justify-center"},Gc={key:4,class:"flex-grow w-full relative min-h-0"},Wc=se({__name:"ChartRenderer",props:{chartOption:{},chartType:{},xAxisField:{},categoryYField:{},groupByField:{},hasDataMismatchWarning:{type:Boolean},isScatterNumericWarning:{type:Boolean}},setup(n,{expose:t}){ca([Ui,Ki,Gi,el,tl,hc,sc,Wi,ji,Qi,Fc,qs]);const e=n,a=j(null),s=$(()=>{const o=$e.get(e.chartType);if(!o)return!1;const r=o.fields;return r.categoryX?!!e.xAxisField&&!!e.categoryYField:r.xAxisLabel||r.xAxisNumeric?!!e.xAxisField:!1});return t({chartRef:a}),(o,r)=>{const i=be,l=Bt;return S(),k("div",Bc,[o.hasDataMismatchWarning?(S(),k("div",Hc,[h(d(ka),{variant:"destructive",class:"py-2.5 px-4"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-4 text-destructive absolute left-4 top-3"}),h(d($a),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[0]||(r[0]=[z("Data Mismatch Warning")])),_:1}),h(d(za),{class:"text-[11px] text-muted-foreground pl-6 mt-1"},{default:y(()=>r[1]||(r[1]=[z(" The selected Y-Axis / Value column contains non-numeric strings. ECharts might not render these values correctly. ")])),_:1})]),_:1})])):K("",!0),o.isScatterNumericWarning?(S(),k("div",qc,[h(d(ka),{variant:"destructive",class:"py-2.5 px-4"},{default:y(()=>[h(i,{name:"hugeicons:alert-02",class:"size-4 text-destructive absolute left-4 top-3"}),h(d($a),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[2]||(r[2]=[z("Numeric X-Axis Required")])),_:1}),h(d(za),{class:"text-[11px] text-muted-foreground pl-6 mt-1"},{default:y(()=>r[3]||(r[3]=[z(" Scatter plot requires numeric data for the X-Axis. Some string values in your selected column could prevent correct rendering. ")])),_:1})]),_:1})])):K("",!0),o.chartType===d(G).STACKED_BAR&&!o.groupByField?(S(),k("div",Uc,[h(d(ka),{class:"py-2.5 px-4 bg-amber-500/10 border-amber-500/20 text-amber-500"},{default:y(()=>[h(i,{name:"hugeicons:information-circle",class:"size-4 text-amber-500 absolute left-4 top-3"}),h(d($a),{class:"text-xs font-semibold pl-6"},{default:y(()=>r[4]||(r[4]=[z("Group By Field Recommended")])),_:1}),h(d(za),{class:"text-[11px] text-amber-500/90 pl-6 mt-1"},{default:y(()=>r[5]||(r[5]=[z(' Stacked Bar charts are best utilized when a "Group By" field is specified to create segment stacks. ')])),_:1})]),_:1})])):K("",!0),s.value?(S(),k("div",Gc,[o.chartOption?(S(),D(d(Yi),{key:0,ref_key:"chartRef",ref:a,option:o.chartOption,class:"w-full h-full",autoresize:!0},null,8,["option"])):K("",!0)])):(S(),k("div",Kc,[h(l,{title:"Setup your Chart",desc:"Select the required columns in the settings pane to start visualising your data."},{icon:y(()=>[h(i,{name:"hugeicons:chart-column",class:"size-12 text-muted-foreground/40"})]),_:1})]))])}}});function jc(n,t){const e=j(G.BAR),a=j(""),s=j(""),o=j(""),r=j(""),i=j(ne.NONE),l=j(""),c=j(fe.NONE),m=j(null),u=j(!1),p=j(!0),f=j(""),g=()=>{var x,v;e.value=G.BAR,a.value=((x=t.value[0])==null?void 0:x.queryFieldName)||"",s.value=((v=t.value[1])==null?void 0:v.queryFieldName)||"",o.value="",r.value="",i.value=ne.NONE,l.value="",c.value=fe.NONE,m.value=null,u.value=!1,p.value=!0,f.value=`Query ${n.value.seqIndex} Chart`};return ce(e,(x,v)=>{var R;if(x===v)return;const _=$e.get(x);if(!_)return;const b=_.fields;b.categoryX||(a.value=a.value),b.categoryY||(r.value=""),b.valueColumn||(o.value=""),b.groupBy||(l.value=""),b.sortBy||(c.value=fe.NONE);const N=t.value;!a.value&&N.length>0&&(a.value=((R=N[0])==null?void 0:R.queryFieldName)||"")}),ce(t,x=>{var v,_;x&&x.length>0&&(a.value||(a.value=((v=x[0])==null?void 0:v.queryFieldName)||""),!s.value&&x.length>1&&(s.value=((_=x[1])==null?void 0:_.queryFieldName)||""))},{immediate:!0}),ce(n,x=>{f.value=`Query ${x.seqIndex} Chart`},{immediate:!0}),{chartType:e,xAxisField:a,yAxisField:s,valueField:o,categoryYField:r,aggregation:i,groupByField:l,sortBy:c,limitRows:m,showLabels:u,smoothLine:p,chartTitle:f,resetConfig:g}}function Qc({rows:n,xAxisField:t,yAxisField:e,groupByField:a,aggregation:s,sortBy:o=fe.NONE,limitRows:r}){if(!t||!n)return[];const i={};n.forEach(c=>{const m=String(c[t]??"Null"),u=a?String(c[a]??"Default"):void 0;let p=0;if(s===ne.COUNT)p=1;else if(e){const g=Number(c[e]);p=isNaN(g)?0:g}const f=a?`${m}||${u}`:m;i[f]||(i[f]={x:m,group:u,values:[]}),i[f].values.push(p)});let l=Object.values(i).map(c=>{let m=0;if(s===ne.NONE)return c.values.map(u=>({x:c.x,y:u,group:c.group}));if(s===ne.SUM)m=c.values.reduce((u,p)=>u+p,0);else if(s===ne.COUNT)m=c.values.length;else if(s===ne.AVG){const u=c.values.reduce((p,f)=>p+f,0);m=c.values.length?u/c.values.length:0}else s===ne.MIN?m=Math.min(...c.values):s===ne.MAX&&(m=Math.max(...c.values));return{x:c.x,y:parseFloat(m.toFixed(4)),group:c.group}}).flat();return o===fe.X_ASC?l.sort((c,m)=>c.x.localeCompare(m.x)):o===fe.X_DESC?l.sort((c,m)=>m.x.localeCompare(c.x)):o===fe.Y_ASC?l.sort((c,m)=>c.y-m.y):o===fe.Y_DESC&&l.sort((c,m)=>m.y-c.y),r&&(l=l.slice(0,r)),l}function Yc({rows:n,xAxisField:t,yAxisField:e,aggregation:a,sortBy:s=fe.NONE,limitRows:o}){if(!t||!n)return[];const r={};n.forEach(l=>{const c=String(l[t]??"Null");let m=0;if(a===ne.COUNT)m=1;else if(e){const u=Number(l[e]);m=isNaN(u)?0:u}r[c]||(r[c]=[]),r[c].push(m)});let i=Object.entries(r).map(([l,c])=>{let m=0;if(a===ne.NONE||a===ne.SUM)m=c.reduce((u,p)=>u+p,0);else if(a===ne.COUNT)m=c.length;else if(a===ne.AVG){const u=c.reduce((p,f)=>p+f,0);m=c.length?u/c.length:0}else a===ne.MIN?m=Math.min(...c):a===ne.MAX&&(m=Math.max(...c));return{name:l,value:parseFloat(m.toFixed(4))}});return s===fe.X_ASC?i.sort((l,c)=>l.name.localeCompare(c.name)):s===fe.X_DESC?i.sort((l,c)=>c.name.localeCompare(l.name)):s===fe.Y_ASC?i.sort((l,c)=>l.value-c.value):s===fe.Y_DESC&&i.sort((l,c)=>c.value-l.value),o&&(i=i.slice(0,o)),i}function Xc({rows:n,xAxisField:t,categoryYField:e,valueField:a}){if(!t||!e||!n)return{xData:[],yData:[],data:[]};const s=new Set,o=new Set,r=new Map;n.forEach(m=>{const u=String(m[t]??"Null"),p=String(m[e]??"Null"),f=a?Number(m[a]??0):1;s.add(u),o.add(p);const g=`${u}||${p}`;r.set(g,(r.get(g)||0)+(isNaN(f)?0:f))});const i=Array.from(s),l=Array.from(o),c=[];return i.forEach((m,u)=>{l.forEach((p,f)=>{const g=`${m}||${p}`;r.has(g)?c.push([u,f,parseFloat(r.get(g).toFixed(2))]):c.push([u,f,0])})}),{xData:i,yData:l,data:c}}function Zc({rows:n,xAxisField:t,yAxisField:e,aggregation:a,limitRows:s}){if(!t||!n)return{categories:[],values:[],maxVal:1};const o={};n.forEach(m=>{const u=String(m[t]??"Null");let p=0;if(a===ne.COUNT)p=1;else if(e){const f=Number(m[e]);p=isNaN(f)?0:f}o[u]||(o[u]=[]),o[u].push(p)});let r=Object.entries(o).map(([m,u])=>{let p=0;if(a===ne.NONE||a===ne.SUM)p=u.reduce((f,g)=>f+g,0);else if(a===ne.COUNT)p=u.length;else if(a===ne.AVG){const f=u.reduce((g,x)=>g+x,0);p=u.length?f/u.length:0}else a===ne.MIN?p=Math.min(...u):a===ne.MAX&&(p=Math.max(...u));return{name:m,value:parseFloat(p.toFixed(4))}});s&&(r=r.slice(0,s));const i=r.map(m=>m.name),l=r.map(m=>m.value),c=Math.max(...l,1)*1.1;return{categories:i,values:l,maxVal:c}}const es=n=>String(n??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Jc=n=>Number.isInteger(n)?n.toLocaleString():n.toLocaleString(void 0,{minimumFractionDigits:0,maximumFractionDigits:2}),Ee=(n,t,e)=>{const a=typeof t=="number"?Jc(t):es(t),s=e!=null&&e.colorDot?`<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${e.colorDot};margin-right:6px;"></span>`:"",o=e!=null&&e.bold?"font-weight:600;":"";return`<div style="display:flex;align-items:center;justify-content:space-between;gap:16px;font-weight:400;line-height:1.7;">
|
|
9
|
+
<span style="opacity:.72;">${s}${es(n)}</span>
|
|
10
|
+
<span style="${o}">${a}</span>
|
|
11
|
+
</div>`},Nt=n=>`<div style="min-width:140px;">${n.join("")}</div>`;function ed(n,t,e,a){const s=Array.isArray(n)?n:[n],o=s[0]??{},r=o.axisValueLabel??o.axisValue??o.name??"",i=[Ee(t||"X",r)];return s.forEach(l=>{const c=Array.isArray(l.data)?l.data[1]:l.value??l.data;a&&l.seriesName?i.push(Ee(String(l.seriesName),c,{colorDot:l.color})):i.push(Ee(e||"Value",c))}),Nt(i)}function td(n,t){const e=Array.isArray(n)?n:[n],a=e[0]??{},s=a.axisValueLabel??a.axisValue??a.name??"",o=[Ee(t||"Category",s)];let r=0;return e.forEach(i=>{const l=Array.isArray(i.data)?i.data[1]:i.value??i.data,c=typeof l=="number"?l:Number(l)||0;r+=c,o.push(Ee(String(i.seriesName??""),l,{colorDot:i.color}))}),o.push(Ee("Total",r,{bold:!0})),Nt(o)}function ad(n,t,e){const a=[Ee(t||"Category",n.name,{colorDot:n.color}),Ee(e||"Value",n.value),Ee("Percent",`${n.percent}%`,{bold:!0})];return Nt(a)}function nd(n,t,e){const a=n.data??[],s=[Ee(t||"X",a[0]),Ee(e||"Y",a[1])];return Nt(s)}function sd(n,t,e,a,s,o){const[r,i,l]=n.data??[],c=[Ee(a||"X",t[r]),Ee(s||"Y",e[i]),Ee(o||"Value",l,{bold:!0})];return Nt(c)}function od(n,t,e){const a=t.map((s,o)=>{var r;return Ee(s,((r=n.value)==null?void 0:r[o])??e[o])});return Nt(a)}const ts=[],as=[],ns={xData:[],yData:[],data:[]},ss={categories:[],values:[],maxVal:1};function Yt(n,t){let e=null;return(...a)=>{e&&clearTimeout(e),e=setTimeout(()=>n(...a),t)}}function rd(n,t,e,a,s,o,r,i,l,c){const m=$(()=>{const T=t.value,E=T===G.HEATMAP?s.value:a.value,A=r.value;return(T===G.PIE||T===G.DONUT||T===G.RADAR)&&A===ne.COUNT||!E?!1:n.value.some(F=>{const P=F[E];return P==null||P===""?!1:isNaN(Number(P))})}),u=$(()=>t.value!==G.SCATTER||!e.value?!1:n.value.some(T=>{const E=T[e.value];return E==null||E===""?!1:isNaN(Number(E))})),p=new Set([G.LINE,G.BAR,G.HORIZONTAL_BAR,G.AREA,G.STACKED_BAR,G.SCATTER]),f=new Set([G.PIE,G.DONUT]),g=at(ts),x=Yt(()=>{if(!p.has(t.value)){g.value=ts;return}g.value=Qc({rows:n.value,xAxisField:e.value,yAxisField:a.value,groupByField:i.value,aggregation:r.value,sortBy:l.value,limitRows:c.value??void 0})},80);ce([n,t,e,a,i,r,l,c],x,{immediate:!0});const v=at(as),_=Yt(()=>{if(!f.has(t.value)){v.value=as;return}v.value=Yc({rows:n.value,xAxisField:e.value,yAxisField:a.value,aggregation:r.value,sortBy:l.value,limitRows:c.value??void 0})},80);ce([n,t,e,a,r,l,c],_,{immediate:!0});const b=at(ns),N=Yt(()=>{if(t.value!==G.HEATMAP){b.value=ns;return}b.value=Xc({rows:n.value,xAxisField:e.value,categoryYField:o.value,valueField:s.value})},80);ce([n,t,e,o,s],N,{immediate:!0});const R=at(ss),w=Yt(()=>{if(t.value!==G.RADAR){R.value=ss;return}R.value=Zc({rows:n.value,xAxisField:e.value,yAxisField:a.value,aggregation:r.value,limitRows:c.value??void 0})},80);return ce([n,t,e,a,r,c],w,{immediate:!0}),{hasDataMismatchWarning:m,isScatterNumericWarning:u,processedData:g,pieData:v,processedHeatmapData:b,processedRadarData:R}}function id(n){const t=n?"#e2e8f0":"#1e293b";return{isDark:n,labelColor:t,lineColor:n?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.06)",tooltipBg:n?"#1e293b":"#ffffff",tooltipBorderColor:n?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",tooltipTextStyle:{color:t,fontWeight:400}}}function Ht(n){return{backgroundColor:"transparent",textStyle:{fontFamily:"Outfit, Inter, system-ui, sans-serif",color:n.labelColor},legend:{textStyle:{color:n.labelColor},bottom:5}}}function ld(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,groupByField:o,showLabels:r,smoothLine:i,chartTitle:l,isArea:c=!1,isStacked:m=!1,isHorizontal:u=!1,isLine:p=!1}=n,f=Ht(t),g=Array.from(new Set(e.map(w=>w.group).filter(Boolean))),x=Array.from(new Set(e.map(w=>w.x))),v=()=>m||u?"bar":c||p?"line":"bar";let _=[];if(g.length>0)g.forEach(w=>{const T=x.map(A=>{const F=e.find(P=>P.x===A&&P.group===w);return F?F.y:0}),E=v();_.push({name:String(w),type:E,stack:m?"total":void 0,smooth:i&&E==="line",areaStyle:c?{opacity:.3}:void 0,label:{show:r,position:u?"right":"top",color:t.labelColor},data:T})});else{const w=v();_.push({name:l||s||"Values",type:w,smooth:i&&w==="line",areaStyle:c?{opacity:.3}:void 0,label:{show:r,position:u?"right":"top",color:t.labelColor},data:e.map(T=>T.y)})}let b,N;u?(b={type:"value",axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},N={type:"category",data:x,axisLabel:{color:t.labelColor},splitLine:{show:!1}}):(b={type:"category",data:x,axisLabel:{color:t.labelColor},splitLine:{show:!1}},N={type:"value",name:s,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}});const R=m?w=>td(w,a):w=>ed(w,a,s,o);return{...f,tooltip:{trigger:"axis",backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle,formatter:R},grid:{left:"10px",right:"15px",top:"30px",bottom:"40px",containLabel:!0},xAxis:b,yAxis:N,series:_}}function ud(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,showLabels:o,isDonut:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>ad(l,a,s),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},series:[{type:"pie",radius:r?["50%","80%"]:"80%",avoidLabelOverlap:!0,label:{show:o,position:"outside",color:t.labelColor},data:e}]}}function cd(n){const{theme:t,data:e,xAxisField:a,yAxisField:s,showLabels:o,chartTitle:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>nd(l,a,s),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},grid:{left:"10px",right:"15px",top:"30px",bottom:"40px",containLabel:!0},xAxis:{type:"value",name:a,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},yAxis:{type:"value",name:s,nameTextStyle:{color:t.labelColor},axisLabel:{color:t.labelColor},splitLine:{lineStyle:{color:t.lineColor}}},series:[{name:r||s||"Values",type:"scatter",label:{show:o,position:"top",color:t.labelColor},data:e.map(l=>[Number(l.x),l.y])}]}}function dd(n){const{theme:t,xData:e,yData:a,data:s,xAxisField:o,categoryYField:r,valueField:i,showLabels:l,chartTitle:c}=n,m=Ht(t),u=s.length?Math.min(...s.map(f=>f[2])):0,p=s.length?Math.max(...s.map(f=>f[2])):100;return{...m,tooltip:{trigger:"item",formatter:f=>sd(f,e,a,o,r,i),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},grid:{left:"10px",right:"15px",top:"20px",bottom:"60px",containLabel:!0},xAxis:{type:"category",data:e,splitArea:{show:!0},axisLabel:{color:t.labelColor}},yAxis:{type:"category",data:a,splitArea:{show:!0},axisLabel:{color:t.labelColor}},visualMap:{min:u,max:p,calculable:!0,orient:"horizontal",left:"center",bottom:25,textStyle:{color:t.labelColor},inRange:{color:t.isDark?["#1e3a8a","#3b82f6","#60a5fa","#93c5fd"]:["#eff6ff","#bfdbfe","#60a5fa","#1d4ed8"]}},series:[{name:c||"Heatmap Value",type:"heatmap",data:s,label:{show:l,color:t.isDark?"#fff":"#000"},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}}function md(n){const{theme:t,categories:e,values:a,maxVal:s,showLabels:o,chartTitle:r}=n;return{...Ht(t),tooltip:{trigger:"item",formatter:l=>od(l,e,a),backgroundColor:t.tooltipBg,borderColor:t.tooltipBorderColor,borderWidth:1,borderRadius:8,textStyle:t.tooltipTextStyle},radar:{indicator:e.map(l=>({name:l,max:s})),splitArea:{show:!0,areaStyle:{color:t.isDark?["rgba(255,255,255,0.02)","rgba(255,255,255,0.04)"]:["rgba(0,0,0,0.01)","rgba(0,0,0,0.02)"]}},axisLine:{lineStyle:{color:t.lineColor}},splitLine:{lineStyle:{color:t.lineColor}}},series:[{name:r||"Radar Chart",type:"radar",data:[{value:a,name:r||"Radar Data"}],label:{show:o,color:t.labelColor},areaStyle:{opacity:.2}}]}}function pd(n,t,e,a,s,o,r,i,l,c,m,u,p,f){return{chartOption:$(()=>{const x=id(c.value),v=n.value;if(v===G.PIE||v===G.DONUT)return ud({theme:x,data:u.value,xAxisField:t.value,yAxisField:e.value,showLabels:r.value,isDonut:v===G.DONUT});if(v===G.HEATMAP){const{xData:_,yData:b,data:N}=p.value;return dd({theme:x,xData:_,yData:b,data:N,xAxisField:t.value,categoryYField:s.value,valueField:a.value,showLabels:r.value,chartTitle:l.value})}if(v===G.RADAR){const{categories:_,values:b,maxVal:N}=f.value;return md({theme:x,categories:_,values:b,maxVal:N,showLabels:r.value,chartTitle:l.value})}return v===G.SCATTER?cd({theme:x,data:m.value,xAxisField:t.value,yAxisField:e.value,showLabels:r.value,chartTitle:l.value}):ld({theme:x,data:m.value,xAxisField:t.value,yAxisField:e.value,groupByField:o.value,showLabels:r.value,smoothLine:i.value,chartTitle:l.value,isLine:v===G.LINE,isArea:v===G.AREA,isStacked:v===G.STACKED_BAR,isHorizontal:v===G.HORIZONTAL_BAR})})}}const fd={class:"h-full flex w-full overflow-hidden text-sm"},vd=se({__name:"ChartBuilderContainer",props:{activeTab:{},activeTabColumns:{},formattedData:{}},setup(n){const t=n,e=Bo(),a=$(()=>e.value==="dark"),{chartType:s,xAxisField:o,yAxisField:r,valueField:i,categoryYField:l,aggregation:c,groupByField:m,sortBy:u,limitRows:p,showLabels:f,smoothLine:g,chartTitle:x,resetConfig:v}=jc(wa(t,"activeTab"),wa(t,"activeTabColumns")),{hasDataMismatchWarning:_,isScatterNumericWarning:b,processedData:N,pieData:R,processedHeatmapData:w,processedRadarData:T}=rd(wa(t,"formattedData"),s,o,r,i,l,c,m,u,p),{chartOption:E}=pd(s,o,r,i,l,m,f,g,x,a,N,R,w,T),A=j(null),F=()=>{var Z;const P=(Z=A.value)==null?void 0:Z.chartRef;if(!P)return;const L=P.getDataURL({type:"png",pixelRatio:2,backgroundColor:a.value?"#1e293b":"#ffffff"}),I=document.createElement("a"),W=new Date().toISOString().slice(0,19).replace(/:/g,"-");I.download=`chart_${x.value||"builder"}_${W}.png`,I.href=L,I.click()};return(P,L)=>(S(),k("div",fd,[h(d(Wc),{ref_key:"chartRendererRef",ref:A,"chart-option":d(E),"chart-type":d(s),"x-axis-field":d(o),"category-y-field":d(l),"group-by-field":d(m),"has-data-mismatch-warning":d(_),"is-scatter-numeric-warning":d(b)},null,8,["chart-option","chart-type","x-axis-field","category-y-field","group-by-field","has-data-mismatch-warning","is-scatter-numeric-warning"]),h(d(ju),{chartTitle:d(x),"onUpdate:chartTitle":L[0]||(L[0]=I=>_e(x)?x.value=I:null),chartType:d(s),"onUpdate:chartType":L[1]||(L[1]=I=>_e(s)?s.value=I:null),xAxisField:d(o),"onUpdate:xAxisField":L[2]||(L[2]=I=>_e(o)?o.value=I:null),yAxisField:d(r),"onUpdate:yAxisField":L[3]||(L[3]=I=>_e(r)?r.value=I:null),valueField:d(i),"onUpdate:valueField":L[4]||(L[4]=I=>_e(i)?i.value=I:null),categoryYField:d(l),"onUpdate:categoryYField":L[5]||(L[5]=I=>_e(l)?l.value=I:null),aggregation:d(c),"onUpdate:aggregation":L[6]||(L[6]=I=>_e(c)?c.value=I:null),groupByField:d(m),"onUpdate:groupByField":L[7]||(L[7]=I=>_e(m)?m.value=I:null),sortBy:d(u),"onUpdate:sortBy":L[8]||(L[8]=I=>_e(u)?u.value=I:null),limitRows:d(p),"onUpdate:limitRows":L[9]||(L[9]=I=>_e(p)?p.value=I:null),showLabels:d(f),"onUpdate:showLabels":L[10]||(L[10]=I=>_e(f)?f.value=I:null),smoothLine:d(g),"onUpdate:smoothLine":L[11]||(L[11]=I=>_e(g)?g.value=I:null),"active-tab-columns":P.activeTabColumns,onReset:d(v),onExport:F},null,8,["chartTitle","chartType","xAxisField","yAxisField","valueField","categoryYField","aggregation","groupByField","sortBy","limitRows","showLabels","smoothLine","active-tab-columns","onReset"])]))}});let fa=0;const hd=()=>(fa+=1,`ep-${fa}`),os=n=>n==null?"":typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):JSON.stringify(n),gd=n=>{const t=(n["Shared Hit Blocks"]??0)+(n["Local Hit Blocks"]??0),e=(n["Shared Read Blocks"]??0)+(n["Local Read Blocks"]??0),a=t+e;if(!(a<=0))return Number((t/a).toFixed(4))},yd=(n,t)=>{const e=t["Plan Rows"],a=t["Actual Rows"];if(e!==void 0&&a!==void 0&&e>0&&a>=0){n.estimateRatio=Number((a/e).toFixed(2));const s=a/e;s>10?n.rowEstimateAccuracy="underestimate":s<.1?n.rowEstimateAccuracy="overestimate":n.rowEstimateAccuracy="accurate"}n.hitReadRatio=gd(t),(t["Total Cost"]!==void 0&&t["Total Cost"]>1e3||t["Actual Total Time"]!==void 0&&t["Actual Total Time"]>100)&&(n.isExpensive=!0)},xd=n=>{let t=0,e="";for(const s of n){const o=s.children.reduce((i,l)=>i+(l["Actual Total Time"]??0)*(l["Actual Loops"]??1),0)/(s["Actual Loops"]??1),r=Math.max(0,(s["Actual Total Time"]??0)-o);r>t&&(t=r,e=s.id)}const a=n.find(s=>s.id===e);a&&(a.isSlowest=!0)},Qs=(n,t,e)=>{const{Plans:a,...s}=n,o=n["Node Type"]||"Unknown Node",r=n["Relation Name"],i={...s,id:hd(),index:fa,label:r?`${o} on ${r}`:o,estimateRatio:void 0,hitReadRatio:void 0,isExpensive:!1,isSlowest:!1,rowEstimateAccuracy:void 0,depth:t,children:(a??[]).map(l=>Qs(l,t+1,e))};return e.push(i),yd(i,n),i},bd=(n,t)=>{fa=0;const e=[],a=Qs(n.Plan,0,e),s={"Planning Time":n["Planning Time"],"Execution Time":n["Execution Time"],totalCost:a["Total Cost"],triggersInfo:(n.Triggers??[]).map(os),jitInfo:[],settingsInfo:n.Settings?Object.entries(n.Settings).map(([r,i])=>`${r}: ${os(i)}`):[],rawText:t};xd(e);const o=[...e].sort((r,i)=>r.index-i.index);return{root:a,summary:s,allNodes:o}},Sd=n=>{const t={triggersInfo:[],jitInfo:[],settingsInfo:[],rawText:n},e=n.match(/Planning Time:\s*(\d+\.?\d*)\s*ms/i),a=n.match(/Execution Time:\s*(\d+\.?\d*)\s*ms/i);return e&&(t["Planning Time"]=Number.parseFloat(e[1])),a&&(t["Execution Time"]=Number.parseFloat(a[1])),{root:null,summary:t,allNodes:[]}},ja=n=>{if(!n)return null;if(typeof n=="string")try{return ja(JSON.parse(n))}catch{return null}return Array.isArray(n)?n.length?ja(n[0]):null:typeof n=="object"&&n!==null&&"Plan"in n&&typeof n.Plan=="object"?n:null},Ys=(n,t)=>{var e;if(!(n!=null&&n.length))return null;if(Array.isArray(n[0]))return n[0][0]??null;if(typeof n[0]=="object"&&n[0]!==null){const a=n[0],s=Object.keys(a).find(o=>o.toUpperCase()==="QUERY PLAN")||((e=t==null?void 0:t[0])==null?void 0:e.name)||Object.keys(a)[0];return s?a[s]??null:null}return n[0]??null},Cd=(n,t)=>{const e=Ys(n,t);return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)},wd=n=>{const t=typeof n=="string"?n:JSON.stringify(n,null,2),e=ja(n);return e?bd(e,t):Sd(t)},rs={"Seq Scan":"scan","Index Scan":"scan","Index Only Scan":"scan","Bitmap Index Scan":"scan","Bitmap Heap Scan":"scan","CTE Scan":"scan","Function Scan":"scan","Values Scan":"scan","Subquery Scan":"scan",Aggregate:"agg",HashAggregate:"agg",GroupAggregate:"agg",Sort:"sort","Incremental Sort":"sort",Hash:"hash","Hash Join":"join","Merge Join":"join","Nested Loop":"join"},Ae=n=>n?String(n).replace(/^[\[]|[\]]$/g,"").replace(/"/g,"").trim():"",_d=n=>n==="Seq Scan"?"bad":rs[n]?rs[n]:n.includes("Join")?"join":n.includes("Scan")?"scan":n.includes("Aggregate")?"agg":n.includes("Sort")?"sort":"other",is=(n,t,e)=>{for(let a=t+1;a<n.length;a++){const s=n[a].depth??0;if(s<e)return!1;if(s===e)return!0}return!1},Rd=(n,t)=>{const a=n[t].depth??0;if(a===0)return"";const s=[];for(let r=1;r<a;r++)s.push(is(n,t,r)?"│ ":" ");const o=!is(n,t,a);return s.push(o?"└─ ":"├─ "),s.join("")},Td=n=>{const t=Ae(n.hashCond),e=Ae(n.mergeCond),a=Ae(n.joinFilter),s=Ae(n.joinType).toLowerCase();if(s||t||e||a){const x=t||e||a,v=s?`${s} `:"";return{label:x?`${v}on ${x}`.trim():`${v}join`.trim(),kind:"join"}}const o=Ae(n.indexCond),r=Ae(n.recheckCond),i=Ae(n.tidCond);if(o)return{label:`on ${o}`,kind:"relation"};if(r)return{label:`recheck: ${r}`,kind:"relation"};if(i)return{label:`tid: ${i}`,kind:"relation"};const l=Ae(n.sortKey);if(l)return{label:`by ${l}`,kind:"sort"};const c=Ae(n.groupKey),m=Ae(n.hashKey);if(c||m)return{label:`by ${c||m}`,kind:"group"};const u=Ae(n.oneTimeFilter);if(u)return{label:`one-time: ${u}`,kind:"relation"};const p=Ae(n.filter);if(p)return{label:`filter: ${p}`,kind:"relation"};const f=Ae(n.cteName);if(f)return{label:`cte: ${f}`,kind:"relation"};const g=Ae(n.subplanName);if(g)return{label:`subplan: ${g}`,kind:"relation"};if(n.relation){const x=n.alias&&n.alias!==n.relation?` (${n.alias})`:"";return{label:`on ${n.relation}${x}`,kind:"relation"}}return{label:"",kind:""}},Ed=n=>[...n].map(t=>{var c,m;const e=t["Plan Rows"]||0,a=t["Actual Rows"]||0,s=t.estimateRatio,o=t["Actual Startup Time"]||0,r=t["Plan Width"]||0,i=t.rowEstimateAccuracy||"accurate",l=[`Node: ${t["Node Type"]}`,t["Relation Name"]?`Relation: ${t["Relation Name"]}`:"",`Depth: ${t.depth}`,`Startup time: ${o.toFixed(3)} ms`,`Total time: ${(t["Actual Total Time"]||0).toFixed(3)} ms`,`Actual rows: ${a.toLocaleString()}`,`Plan rows: ${e.toLocaleString()}`,s!==void 0?`Estimate ratio: ${s}x (${i})`:"Estimate ratio: -",`Total cost: ${(t["Total Cost"]||0).toFixed(2)}`,`Plan width: ${r}`,`Loops: ${(t["Actual Loops"]||0).toLocaleString()}`,`Slowest: ${t.isSlowest?"yes":"no"}`,`Expensive: ${t.isExpensive?"yes":"no"}`].filter(Boolean).join(`
|
|
12
|
+
`);return{id:t.id,order:t.index,nodeType:t["Node Type"],relation:t["Relation Name"],alias:t.Alias,sortKey:((c=t["Sort Key"])==null?void 0:c.join(", "))??"",joinType:t["Join Type"]??"",groupKey:((m=t["Group Key"])==null?void 0:m.join(", "))??"",hashKey:"",filter:t.Filter??"",joinFilter:"",oneTimeFilter:"",indexCond:"",hashCond:t["Hash Cond"]??"",mergeCond:t["Merge Cond"]??"",recheckCond:"",tidCond:"",cteName:"",subplanName:"",timeMs:t["Actual Total Time"]||0,rows:a,planRows:e,estimateRatio:s,cost:t["Total Cost"]||0,width:r,loops:t["Actual Loops"]||0,depth:t.depth,indentPx:t.depth*16,hitReadRatio:t.hitReadRatio,isSlowest:t.isSlowest,isExpensive:t.isExpensive,tooltipLines:l}}),Nd=n=>{const t=n.reduce((e,a)=>e+(a.timeMs||0),0)||1;return n.map((e,a)=>{const s=Rd(n,a),{label:o,kind:r}=Td(e),i=e.isSlowest?"slowest":e.isExpensive?"expensive":"normal";return{order:e.order,timeMs:e.timeMs,rows:e.rows,planRows:e.planRows,estimateRatioValue:e.estimateRatio,cost:e.cost,width:e.width,loops:e.loops,hitReadRatio:e.hitReadRatio,isSlowest:e.isSlowest,isExpensive:e.isExpensive,orderLabel:`${e.order}`,queryPercentLabel:`${(e.timeMs/t*100).toFixed(2)}%`,timeSpentLabel:`${e.timeMs.toFixed(3)} ms`,rowsLabel:e.rows.toLocaleString(),planRowsLabel:e.planRows.toLocaleString(),estimateLabel:e.estimateRatio!==void 0?`${e.estimateRatio}×`:"-",costLabel:e.cost.toFixed(2),widthLabel:e.width,loopsLabel:e.loops.toLocaleString(),hitReadRatioLabel:e.hitReadRatio!==void 0?`${(e.hitReadRatio*100).toFixed(2)}%`:"-",statusLabel:i,treePrefix:s,nodeType:e.nodeType,nodeTypeCategory:_d(e.nodeType),contextLabel:o,contextKind:r}})},Ad={class:"flex items-center text-xs h-full w-full overflow-hidden whitespace-nowrap"},Md={key:0,class:"text-muted-foreground shrink-0 whitespace-pre",style:{"font-family":"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important"}},Id={key:1,class:"font-normal shrink-0"},Ld={key:2,class:"text-xxs pl-0.5 text-muted-foreground truncate shrink min-w-0"},kd=se({__name:"ExplainOperationCell",props:{params:{}},setup(n){const t=n,e=$(()=>{var a;return((a=t.params)==null?void 0:a.data)??{}});return(a,s)=>(S(),k("div",Ad,[e.value.treePrefix?(S(),k("span",Md,U(e.value.treePrefix),1)):K("",!0),e.value.nodeType?(S(),k("span",Id,U(e.value.nodeType),1)):K("",!0),e.value.contextLabel?(S(),k("span",Ld,U(e.value.contextLabel),1)):K("",!0)]))}}),zd={class:"h-full p-2"},$d=se({__name:"ExplainGridPane",props:{nodes:{}},setup(n){const t=n,e=$(()=>Ed(t.nodes)),a=$(()=>Nd(e.value)),s=$(()=>[{headerName:"#",field:"orderLabel",width:30,sortable:!0,resizable:!0,filter:!1,cellClass:"cellCenter"},{headerName:"Operation",field:"operationLabel",width:350,sortable:!1,resizable:!0,filter:!0,cellRenderer:"ExplainOperationCell",cellClass:"operation-cell",valueGetter:r=>`${r.data.treePrefix}${r.data.nodeType} ${r.data.contextLabel}`},{headerName:"Status",field:"statusLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:r=>{const i=r.value;return i==="slowest"?"cellCenter bg-red-300! dark:bg-red-900":i==="expensive"?"cellCenter bg-orange-100! dark:bg-orange-900":"cellCenter"}},{headerName:"Time Spent",field:"timeSpentLabel",width:110,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"% of Query",field:"queryPercentLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Actual Rows",field:"rowsLabel",width:96,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Plan Rows",field:"planRowsLabel",width:88,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Estim",field:"estimateLabel",width:76,sortable:!0,resizable:!0,filter:!0,cellClass:r=>{var l;const i=Number((l=r.data)==null?void 0:l.estimateRatioValue);return Number.isFinite(i)?i<.1||i>10?"cellCenter bg-red-200 dark:bg-red-900":i>=.1&&i<.5||i>2&&i<=10?"cellCenter bg-orange-100 dark:bg-orange-900":"cellCenter ":"cellCenter "}},{headerName:"Cost",field:"costLabel",width:88,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Hit Read Ratio",field:"hitReadRatioLabel",width:110,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Width",field:"widthLabel",width:72,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "},{headerName:"Loops",field:"loopsLabel",width:72,sortable:!0,resizable:!0,filter:!0,cellClass:"cellCenter "}]),o={ExplainOperationCell:kd};return(r,i)=>{const l=Bs;return S(),k("div",zd,[h(l,{class:"h-full","column-defs":s.value,"row-data":a.value,components:o,"enable-copy-hotkey":!1},null,8,["column-defs","row-data"])])}}});var ht=(n=>(n.GRID="grid",n.TIMELINE="time-line",n.RAW="raw",n))(ht||{});const Od=[{value:ht.TIMELINE,label:"Timeline",icon:"hugeicons:chart-line-data-01"},{value:ht.GRID,label:"Grid",icon:"hugeicons:grid-table"},{value:ht.RAW,label:"Raw",icon:"hugeicons:3rd-bracket"}],Vd={class:"flex items-center justify-between px-3 py-2 border-b shrink-0"},Pd={class:"flex items-center gap-3 min-w-0"},Dd={class:"flex items-center gap-2 flex-wrap"},Fd={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Bd={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Hd={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},qd={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Ud={class:"flex flex-col gap-1 max-w-[250px] sm:max-w-xs"},Kd={class:"text-[11px] text-muted-foreground list-disc pl-3 break-words whitespace-normal"},Gd={class:"flex items-center gap-2 shrink-0"},Wd=se({__name:"ExplainPlanHeader",props:ia({summaryStats:{},isExpanded:{type:Boolean}},{modelValue:{required:!0},modelModifiers:{}}),emits:ia(["toggle-expand"],["update:modelValue"]),setup(n,{emit:t}){const e=t,a=Me(n,"modelValue");return(s,o)=>{const r=be,i=Ho,l=Oe,c=Ve,m=Pe,u=Ko,p=Uo,f=qo,g=Le;return S(),k("div",Vd,[C("div",Pd,[h(r,{name:"hugeicons:analytics-up",class:"size-4 text-muted-foreground"}),o[6]||(o[6]=C("span",{class:"text-sm font-medium"},"Execution Plan",-1)),C("div",Dd,[s.summaryStats.executionTime!==void 0?(S(),D(i,{key:0,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>[h(r,{name:"hugeicons:clock-01",class:"size-3"}),z(" "+U(d(Dt)(s.summaryStats.executionTime)),1)]),_:1})):K("",!0),s.summaryStats.planningTime!==void 0?(S(),D(i,{key:1,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>[z(" Planning: "+U(d(Dt)(s.summaryStats.planningTime)),1)]),_:1})):K("",!0),s.summaryStats.nodeCount>0?(S(),D(m,{key:2},{default:y(()=>{var x;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 cursor-help"},{default:y(()=>[z(U(s.summaryStats.nodeCount)+" nodes ",1)]),_:1})]),_:1}),(x=s.summaryStats.allNodes)!=null&&x.length?(S(),D(c,{key:0},{default:y(()=>[C("div",Fd,[o[2]||(o[2]=C("span",{class:"font-medium text-xs"},"Nodes:",-1)),C("ul",Bd,[(S(!0),k(ae,null,ue(s.summaryStats.allNodes,v=>(S(),k("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):(S(),D(i,{key:3,variant:"outline",class:"text-[11px] h-5 gap-1"},{default:y(()=>o[3]||(o[3]=[z(" 0 nodes ")])),_:1})),s.summaryStats.expensiveCount>0?(S(),D(m,{key:4},{default:y(()=>{var x;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-amber-300 text-amber-700 dark:text-amber-400 cursor-help"},{default:y(()=>[z(U(s.summaryStats.expensiveCount)+" expensive ",1)]),_:1})]),_:1}),(x=s.summaryStats.expensiveNodes)!=null&&x.length?(S(),D(c,{key:0},{default:y(()=>[C("div",Hd,[o[4]||(o[4]=C("span",{class:"font-medium text-xs"},"Expensive Nodes:",-1)),C("ul",qd,[(S(!0),k(ae,null,ue(s.summaryStats.expensiveNodes,v=>(S(),k("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):K("",!0),s.summaryStats.slowCount>0?(S(),D(m,{key:5},{default:y(()=>{var x;return[h(l,{"as-child":""},{default:y(()=>[h(i,{variant:"outline",class:"text-[11px] h-5 gap-1 border-red-300 text-red-700 dark:text-red-400 cursor-help"},{default:y(()=>[z(U(s.summaryStats.slowCount)+" slowest ",1)]),_:1})]),_:1}),(x=s.summaryStats.slowNodes)!=null&&x.length?(S(),D(c,{key:0},{default:y(()=>[C("div",Ud,[o[5]||(o[5]=C("span",{class:"font-medium text-xs"},"Slowest Node(s):",-1)),C("ul",Kd,[(S(!0),k(ae,null,ue(s.summaryStats.slowNodes,v=>(S(),k("li",{key:v.id},U(v.label),1))),128))])])]),_:1})):K("",!0)]}),_:1})):K("",!0)])]),C("div",Gd,[h(f,{modelValue:a.value,"onUpdate:modelValue":o[0]||(o[0]=x=>a.value=x),class:"gap-0"},{default:y(()=>[h(p,{size:"xxs"},{default:y(()=>[(S(!0),k(ae,null,ue(d(Od),x=>(S(),D(u,{size:"xxs",key:x.value,value:x.value,class:"rounded-sm cursor-pointer"},{default:y(()=>[h(r,{name:x.icon,class:"size-3.5!"},null,8,["name"]),z(" "+U(x.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1},8,["modelValue"]),h(g,{variant:"outline",size:"iconSm",onClick:o[1]||(o[1]=x=>e("toggle-expand"))},{default:y(()=>[h(r,{name:s.isExpanded?"hugeicons:arrow-shrink":"hugeicons:arrow-expand",class:"size-3.5"},null,8,["name"])]),_:1})])])}}}),jd={class:"h-full overflow-auto p-2"},Qd=se({__name:"ExplainRawPane",props:{rawText:{}},setup(n){const t=n,e=$(()=>{const a=t.rawText.trim();return a.startsWith("{")||a.startsWith("[")?"json":"sql"});return(a,s)=>{const o=xa;return S(),k("div",jd,[h(o,{code:a.rawText,language:e.value,"max-height":"100%"},null,8,["code","language"])])}}}),Yd={class:"h-full p-2"},Xd={class:"rounded-lg border p-2 flex flex-col h-full min-h-0"},Zd={class:"flex justify-between items-center mb-4"},Jd={class:"text-sm font-bold text-muted-foreground uppercase flex items-center gap-2"},em={key:0,class:"h-full grid place-items-center text-sm text-muted-foreground"},tm={key:1,class:"flex-1 overflow-auto relative"},am={class:"min-w-[680px] text-xs"},nm={class:"flex border-b pb-2 mb-2 sticky top-0 bg-background z-10 font-medium text-muted-foreground"},sm={class:"flex-1 relative h-4"},om={class:"absolute right-0"},rm={class:"pb-2"},im=["onMouseenter"],lm={class:"w-[28%] min-w-[190px] max-w-[260px] px-2 flex items-center overflow-hidden"},um={class:"truncate flex items-center gap-1"},cm={class:"font-mono text-xxs text-right shrink-0 text-muted-foreground"},dm={class:"flex flex-col truncate"},mm=["title"],pm={key:0,class:"text-muted-foreground text-xxs truncate"},fm={key:0},vm={class:"flex-1 relative h-6 mx-2"},hm={class:"space-y-2 text-xs"},gm={class:"font-semibold flex items-center gap-1"},ym={class:"grid grid-cols-2 gap-x-3 gap-y-1 text-[11px]"},xm={class:"font-mono"},bm={class:"font-mono"},Sm={class:"font-mono"},Cm={class:"font-mono"},wm={class:"font-mono"},_m={class:"font-mono"},Rm={class:"font-mono"},Tm={class:"font-mono"},Em={key:0,class:"text-[11px] text-muted-foreground"},Nm={key:0},Xt=14,Am=se({__name:"ExplainTimelineChartPane",props:{nodes:{},totalTime:{}},setup(n){const t=n,e=j(null),a=$(()=>{const u=[...t.nodes].filter(f=>typeof f["Actual Startup Time"]=="number"&&typeof f["Actual Total Time"]=="number").map(f=>{const g=f["Actual Startup Time"]||0,x=f["Actual Total Time"]||0,v=Math.max(0,x-g);return{id:f.id,nodeType:f["Node Type"],relation:f["Relation Name"],alias:f.Alias,depth:f.depth,actualRows:f["Actual Rows"],actualLoops:f["Actual Loops"],planRows:f["Plan Rows"],totalCost:f["Total Cost"],start:g,end:x,duration:v}}),p=(f,g)=>{for(let x=f+1;x<u.length;x+=1){const v=u[x].depth;if(v<g)return!1;if(v===g)return!0}return!1};return u.map((f,g)=>{const x=[];for(let v=1;v<f.depth;v+=1)p(g,v)&&x.push(v);return{...f,continuationLevels:x,hasNextSibling:f.depth>0?p(g,f.depth):!1}})}),s=$(()=>{const u=a.value.length?Math.max(...a.value.map(p=>p.end)):0;return Math.max(t.totalTime||0,u,1)}),o=(u,p)=>{const f=s.value>0?s.value:1,g=u/f*100,x=Math.max(p/f*100,.5);return{left:`${g}%`,width:`${x}%`}},r=u=>{const p=s.value>0?s.value:1;return(u/p*100).toFixed(2)},i=u=>`${Math.max(u,0)*Xt}px`,l=u=>`${(u-1)*Xt+Xt/2}px`,c=`${Xt/2}px`,m=u=>u==="Seq Scan"?"bg-gray-400 dark:bg-gray-600":u.includes("Scan")?"bg-gray-300 dark:bg-gray-700":u.includes("Join")?"bg-gray-500 dark:bg-gray-500":u==="Sort"?"bg-gray-300 dark:bg-gray-600":(u.includes("Aggregate"),"bg-gray-400 dark:bg-gray-600");return(u,p)=>{const f=be,g=Oe,x=Ve,v=Pe;return S(),k("div",Yd,[C("div",Xd,[C("div",Zd,[C("h3",Jd,[h(f,{name:"hugeicons:clock-01",class:"size-4"}),p[1]||(p[1]=z(" Execution Plan Timeline "))]),p[2]||(p[2]=C("span",{class:"text-xs text-muted-foreground"},"Hover for details",-1))]),a.value.length===0?(S(),k("div",em," No timeline data available ")):(S(),k("div",tm,[C("div",am,[C("div",nm,[p[7]||(p[7]=C("div",{class:"w-[28%] min-w-[190px] max-w-[260px] pl-2"}," Node Hierarchy ",-1)),C("div",sm,[p[3]||(p[3]=C("div",{class:"absolute left-0"},"0ms",-1)),C("div",om,U(d(Ut)(s.value)),1),p[4]||(p[4]=C("div",{class:"absolute left-1/4 border-l h-full"},null,-1)),p[5]||(p[5]=C("div",{class:"absolute left-1/2 border-l h-full"},null,-1)),p[6]||(p[6]=C("div",{class:"absolute left-3/4 border-l h-full"},null,-1))])]),C("div",rm,[(S(!0),k(ae,null,ue(a.value,_=>(S(),k("div",{key:_.id,class:xe(["flex items-center group rounded transition-colors hover:bg-muted",e.value===_.id?"bg-muted/40":""]),onMouseenter:b=>e.value=_.id,onMouseleave:p[0]||(p[0]=b=>e.value=null)},[C("div",lm,[C("div",{class:"relative shrink-0 h-7",style:Ct({width:i(_.depth)})},[(S(!0),k(ae,null,ue(_.continuationLevels,b=>(S(),k("div",{key:`${_.id}-v-${b}`,class:"absolute top-0 bottom-0 border-l border-dashed border-muted-foreground/35",style:Ct({left:l(b)})},null,4))),128)),_.depth>0?(S(),k(ae,{key:0},[C("div",{class:"absolute top-0 border-l border-dashed border-muted-foreground/45",style:Ct({left:l(_.depth),height:_.hasNextSibling?"100%":"50%"})},null,4),C("div",{class:"absolute top-1/2 -translate-y-1/2 border-t border-dashed border-muted-foreground/45",style:Ct({left:l(_.depth),width:c})},null,4)],64)):K("",!0)],4),C("div",um,[C("span",cm," #"+U(_.id.replace("ep-","")),1),C("div",dm,[C("span",{class:"truncate font-medium text-sm",title:_.nodeType},U(_.nodeType),9,mm),_.relation?(S(),k("span",pm,[z(U(_.relation)+" ",1),_.alias&&_.alias!==_.relation?(S(),k("span",fm,"("+U(_.alias)+")",1)):K("",!0)])):K("",!0)])])]),C("div",vm,[p[16]||(p[16]=Go('<div class="absolute top-0 bottom-0 left-0 w-px bg-muted"></div><div class="absolute top-0 bottom-0 right-0 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-1/4 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-1/2 w-px bg-muted"></div><div class="absolute top-0 bottom-0 left-3/4 w-px bg-muted"></div>',5)),h(v,null,{default:y(()=>[h(g,{"as-child":""},{default:y(()=>[C("div",{class:xe(["absolute top-1 bottom-1 rounded-sm transition-all shadow-sm opacity-90 cursor-default",[m(_.nodeType),e.value===_.id?"brightness-105 ring-2 ring-border z-10":""]]),style:Ct(o(_.start,_.duration))},null,6)]),_:2},1024),h(x,{side:"top","side-offset":8,class:"max-w-[360px]"},{default:y(()=>{var b,N,R,w;return[C("div",hm,[C("div",gm,[h(f,{name:"hugeicons:flow-square",class:"size-3.5"}),z(" "+U(_.nodeType),1)]),C("div",ym,[p[8]||(p[8]=C("span",{class:"text-muted-foreground"},"Start",-1)),C("span",xm,U(d(Ut)(_.start)),1),p[9]||(p[9]=C("span",{class:"text-muted-foreground"},"End",-1)),C("span",bm,U(d(Ut)(_.end)),1),p[10]||(p[10]=C("span",{class:"text-muted-foreground"},"Duration",-1)),C("span",Sm,U(d(Ut)(_.duration)),1),p[11]||(p[11]=C("span",{class:"text-muted-foreground"},"Share",-1)),C("span",Cm,U(r(_.duration))+"%",1),p[12]||(p[12]=C("span",{class:"text-muted-foreground"},"Rows",-1)),C("span",wm,U(((b=_.actualRows)==null?void 0:b.toLocaleString())??"-"),1),p[13]||(p[13]=C("span",{class:"text-muted-foreground"},"Plan Rows",-1)),C("span",_m,U(((N=_.planRows)==null?void 0:N.toLocaleString())??"-"),1),p[14]||(p[14]=C("span",{class:"text-muted-foreground"},"Loops",-1)),C("span",Rm,U(((R=_.actualLoops)==null?void 0:R.toLocaleString())??"-"),1),p[15]||(p[15]=C("span",{class:"text-muted-foreground"},"Total Cost",-1)),C("span",Tm,U(((w=_.totalCost)==null?void 0:w.toFixed(2))??"-"),1)]),_.relation?(S(),k("div",Em,[z(" Relation: "+U(_.relation)+" ",1),_.alias&&_.alias!==_.relation?(S(),k("span",Nm,"("+U(_.alias)+")",1)):K("",!0)])):K("",!0)])]}),_:2},1024)]),_:2},1024)])],42,im))),128))])])]))])])}}}),Mm={class:"h-full min-h-0"},Im={key:0,class:"h-full flex flex-col items-center justify-center gap-2 text-muted-foreground"},Lm=se({__name:"ExplainQueryContainer",props:{activeTab:{}},setup(n){const t=n,e=j(ht.GRID),a=j(!1),s=$(()=>Ys(t.activeTab.result,t.activeTab.metadata.fieldDefs)),o=$(()=>Cd(t.activeTab.result,t.activeTab.metadata.fieldDefs)),r=$(()=>wd(s.value)),i=$(()=>{const l=r.value.allNodes,c=l.filter(u=>u.isExpensive),m=l.filter(u=>u.isSlowest);return{planningTime:r.value.summary["Planning Time"],executionTime:r.value.summary["Execution Time"],nodeCount:l.length,expensiveCount:c.length,slowCount:m.length,allNodes:l,expensiveNodes:c,slowNodes:m}});return(l,c)=>{const m=be;return S(),k("div",Mm,[a.value?(S(),k("div",{key:0,class:"fixed inset-0 z-40 bg-background/70 backdrop-blur-[1px]",onClick:c[0]||(c[0]=u=>a.value=!1)})):K("",!0),C("div",{class:xe(["flex flex-col",a.value?"fixed z-50 left-1/2 top-1/2 h-[90vh] w-[95vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border bg-background shadow-2xl":"h-full min-h-0 overflow-hidden"])},[h(d(Wd),{modelValue:e.value,"onUpdate:modelValue":c[1]||(c[1]=u=>e.value=u),"summary-stats":i.value,"is-expanded":a.value,onToggleExpand:c[2]||(c[2]=u=>a.value=!a.value)},null,8,["modelValue","summary-stats","is-expanded"]),C("div",{class:xe(["flex-1 min-h-0",a.value?"overflow-hidden":"overflow-y-auto"])},[r.value.root?e.value===d(ht).GRID?(S(),D(d($d),{key:1,nodes:r.value.allNodes},null,8,["nodes"])):e.value===d(ht).TIMELINE?(S(),D(d(Am),{key:2,nodes:r.value.allNodes,"total-time":i.value.executionTime},null,8,["nodes","total-time"])):(S(),D(d(Qd),{key:3,"raw-text":o.value},null,8,["raw-text"])):(S(),k("div",Im,[h(m,{name:"hugeicons:alert-02",class:"size-8 opacity-50"}),c[3]||(c[3]=C("p",{class:"text-sm"},"Could not parse execution plan",-1))]))],2)],2)])}}}),Ze='(?:`[^`]+`|"(?:[^"]|"")+"|[A-Za-z_][A-Za-z0-9_$]*)',km=`\\b(?:FROM|JOIN)\\s+(${Ze}(?:\\s*\\.\\s*${Ze})*)(?:\\s+(?:AS\\s+)?(${Ze}))?`,Xs=new Set(["all","cross","except","fetch","for","from","full","group","having","inner","intersect","join","left","limit","offset","on","order","outer","right","select","union","where"]);function zm(n){return Xs.has(Se(n))}function va(n){const t=n.trim();return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/""/g,'"'):t.startsWith("`")&&t.endsWith("`")?t.slice(1,-1).replace(/``/g,"`"):t}function Se(n){if(!n)return"";const t=n.trim(),e=va(t);return t.startsWith('"')&&t.endsWith('"')||t.startsWith("`")&&t.endsWith("`")?e:e.toLowerCase()}function ba(n){if(!n)return[];const t=[];let e="",a=null;for(let s=0;s<n.length;s++){const o=n[s];if(a){if(e+=o,o===a&&n[s+1]===a){e+=n[s+1],s++;continue}o===a&&(a=null);continue}if(o==='"'||o==="`"){a=o,e+=o;continue}if(o==="."){e.trim()&&t.push(e.trim()),e="";continue}e+=o}return e.trim()&&t.push(e.trim()),t}function na({schemas:n,tableName:t,schemaName:e}){if(!(n!=null&&n.length)||!t)return;const a=Se(t),s=e?Se(e):void 0;for(const o of n)if(!(s&&Se(o.name)!==s)){for(const[r,i]of Object.entries(o.tableDetails||{}))if(Se(r)===a)return{schemaName:o.name,tableName:r,tableInfo:i}}}function Sa({tableReference:n,schemas:t,defaultSchemaName:e}){if(!(t!=null&&t.length))return;const a=ba(n).map(r=>Se(r));if(!a.length)return;const s=a[a.length-1],o=a.length>1?a[a.length-2]:void 0;if(o){const r=na({schemas:t,tableName:s,schemaName:o});if(r)return r}if(e){const r=na({schemas:t,tableName:s,schemaName:e});if(r)return r}return na({schemas:t,tableName:s})}function Zs(n,t){var s;const e=new RegExp(km,"gi");let a=e.exec(n);for(;a!==null;)t({tableReference:(s=a[1])==null?void 0:s.trim(),rawAlias:a[2]}),a=e.exec(n)}function Js(n){const t=new Map;return Zs(n,({tableReference:e,rawAlias:a})=>{if(!e)return;const o=ba(e).at(-1);if(o&&t.set(Se(o),e),!a)return;const r=Se(a);Xs.has(r)||t.set(r,e)}),t}function $m(n){const t=[],e=new Set;return Zs(n,({tableReference:a})=>{!a||e.has(a)||(e.add(a),t.push(a))}),t}const eo=new RegExp(`^${Ze}(?:\\s*\\.\\s*${Ze}){0,2}$`,"i"),Om=new RegExp(`^([\\s\\S]*?)(?:\\s+AS\\s+)(${Ze})$`,"i"),Vm=new RegExp(`^([\\s\\S]*\\S)\\s+(${Ze})$`,"i"),mn=new RegExp(`^(${Ze}(?:\\s*\\.\\s*${Ze}){0,2})\\s*\\.\\s*\\*$`,"i");function ls(n){return!n||!/[A-Za-z0-9_$]/.test(n)}function Pm(n,t,e){const a=e.toUpperCase();return n.slice(t,t+a.length).toUpperCase()!==a?!1:ls(n[t-1])&&ls(n[t+e.length])}function to(n,t){const e=n[t],a=n[t+1];if(e==="-"&&a==="-"){let s=t+2;for(;s<n.length&&n[s]!==`
|
|
13
|
+
`;)s++;return s}if(e==="/"&&a==="*"){const s=n.indexOf("*/",t+2);return s===-1?n.length:s+2}if(e==="'"||e==='"'||e==="`"){let s=t+1;for(;s<n.length;){if(n[s]===e){if(n[s+1]===e){s+=2;continue}return s+1}s++}return n.length}return t+1}function us(n,t,e=0){let a=0;for(let s=e;s<n.length;){const o=n[s],r=n[s+1];if(o==="'"||o==='"'||o==="`"||o==="-"&&r==="-"||o==="/"&&r==="*"){s=to(n,s);continue}if(o==="("){a++,s++;continue}if(o===")"){a=Math.max(0,a-1),s++;continue}if(a===0&&Pm(n,s,t))return s;s++}return-1}function Dm(n){const t=[];let e=0,a=0;for(let o=0;o<n.length;){const r=n[o],i=n[o+1];if(r==="'"||r==='"'||r==="`"||r==="-"&&i==="-"||r==="/"&&i==="*"){o=to(n,o);continue}if(r==="("){e++,o++;continue}if(r===")"){e=Math.max(0,e-1),o++;continue}if(e===0&&r===","){const l=n.slice(a,o).trim();l&&t.push(l),a=o+1}o++}const s=n.slice(a).trim();return s&&t.push(s),t}function Fm(n){const t=us(n,"SELECT");if(t===-1)return[];const e=us(n,"FROM",t+6);if(e===-1)return[];const a=n.slice(t+6,e);return Dm(a)}function ao(n){return[...n.columns||[]].sort((t,e)=>(t.ordinal_position||0)-(e.ordinal_position||0))}function Bm(n,t){const e=Se(t);return n.find(a=>Se(a.name)===e)}function Hm(n){const t=n.trim(),e=Om.exec(t);if(e)return{expression:e[1].trim(),outputName:va(e[2])};if(t==="*"||mn.test(t)||eo.test(t))return{expression:t,outputName:void 0};const a=Vm.exec(t);if(a){const s=Se(a[2]);if(!zm(s))return{expression:a[1].trim(),outputName:va(a[2])}}return{expression:t,outputName:void 0}}function no({resolvedTableDetails:n,columnName:t,outputName:e}){const a=Bm(n.tableInfo.columns||[],t);if(a)return{outputName:e,schemaName:n.schemaName,tableName:n.tableName,sourceColumnName:a.name}}function qm({sourceColumnName:n,resolvedTables:t,outputName:e}){const a=t.map(s=>no({resolvedTableDetails:s,columnName:n,outputName:e})).filter(Boolean);if(a.length===1)return a[0]}function Um({expression:n,outputName:t,aliasMappings:e,resolvedTables:a,schemas:s}){if(!eo.test(n))return;const o=ba(n);if(!o.length)return;const r=va(o[o.length-1]);if(o.length===1)return qm({sourceColumnName:r,resolvedTables:a,outputName:t});const i=o.slice(0,-1).join("."),l=Se(o[o.length-2]||o[0]),c=e.get(l)||i,m=Sa({tableReference:c,schemas:s});if(m)return no({resolvedTableDetails:m,columnName:r,outputName:t})}function Km({expression:n,aliasMappings:t,schemas:e}){const a=mn.exec(n);if(!a)return[];const s=a[1].trim(),o=ba(s),r=Se(o[o.length-1]||s),i=t.get(r)||s,l=Sa({tableReference:i,schemas:e});return l?ao(l.tableInfo).map(c=>({outputName:c.name,schemaName:l.schemaName,tableName:l.tableName,sourceColumnName:c.name})):[]}function Gm({statementQuery:n,schemas:t}){const e=Js(n),a=$m(n).map(s=>Sa({tableReference:s,schemas:t})).filter(Boolean);return Fm(n).flatMap(s=>{const{expression:o,outputName:r}=Hm(s);if(o==="*")return a.flatMap(l=>ao(l.tableInfo).map(c=>({outputName:c.name,schemaName:l.schemaName,tableName:l.tableName,sourceColumnName:c.name})));if(mn.test(o))return Km({expression:o,aliasMappings:e,schemas:t});const i=Um({expression:o,outputName:r,aliasMappings:e,resolvedTables:a,schemas:t});return i?[{...i,outputName:r||i.sourceColumnName}]:r?[{outputName:r}]:[]})}function cs(n,t){return t?{...n,schemaName:n.schemaName??t.schemaName,tableName:n.tableName??t.tableName,sourceColumnName:n.sourceColumnName??t.sourceColumnName}:n}function Wm({fieldDefs:n,statementQuery:t,schemas:e}){if(!n.length||!t||!e.length)return n;const a=Gm({statementQuery:t,schemas:e});if(!a.length)return n;if(a.length===n.length)return n.map((o,r)=>cs(o,a[r]));const s=new Map;return a.forEach(o=>{const r=o.outputName;if(!r)return;const i=Se(r),l=s.get(i)||[];l.push(o),s.set(i,l)}),n.map(o=>{const r=Se(o.name),i=s.get(r),l=i==null?void 0:i.shift();return cs(o,l)})}const jm=({fieldDefs:n,statementQuery:t,schemas:e,getTableInfoById:a})=>{const s=Wm({fieldDefs:n,statementQuery:t,schemas:e}),o=new Map,r=new Set;return s.map(i=>{var R,w;const l=`${i.tableID}`,c=i.tableID&&i.tableID>0?`id:${l}`:`name:${i.schemaName||""}.${i.tableName||""}`,m=i.name,u=i.sourceColumnName||i.name;let p=o.get(c);const f=r.has(m);if(r.add(m),!p){if(i.tableName&&(p=na({schemas:e,tableName:i.tableName,schemaName:i.schemaName})),!p&&i.tableID)for(const T of e){const E=a(l,T);if(E){p={schemaName:T.name,tableName:E.tableName,tableInfo:E.tableInfo};break}}p&&o.set(c,p)}const g=((p==null?void 0:p.tableInfo.columns)||[]).find(T=>T.name===u),x=!!((R=p==null?void 0:p.tableInfo.primary_keys)!=null&&R.find(T=>T.column===u)),v=(w=p==null?void 0:p.tableInfo.foreign_keys)==null?void 0:w.find(T=>T.column===u),_=!!v,b=f?`${(p==null?void 0:p.tableName)||i.tableName||"table"}.${i.name}`:i.name;return{tableName:(p==null?void 0:p.tableName)||i.tableName||"",schemaName:(p==null?void 0:p.schemaName)||i.schemaName,...g,aliasFieldName:b,queryFieldName:i.name,originalName:i.name,sourceColumnName:u,canMutate:!!g,isPrimaryKey:x,isForeignKey:_,foreignKey:v}})};function ds(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function Qm(n,t){if(Array.isArray(n))return Object.fromEntries(t.map((o,r)=>[o.name,n[r]]));const e=n;if(!t.length)return{...e};const a={};let s=!1;return t.forEach((o,r)=>{if(ds(e,o.name)){a[o.name]=e[o.name],s=!0;return}const i=String(r);ds(e,i)&&(a[o.name]=e[i],s=!0)}),s?a:{...e}}function Ym(n,t){return(n||[]).map(e=>Qm(e,t))}const Xm={class:"h-full p-2 overflow-y-auto"},Zm={key:0,class:"space-y-2"},Jm={class:"flex items-center justify-between gap-2"},ep={class:"flex items-center gap-1"},tp={class:"text-sm pl-5 text-muted-foreground decoration-wavy underline decoration-red-600"},ap={key:0,class:"pl-5 mt-1 text-sm text-amber-600/90 font-medium"},np={class:"pt-2 border-t"},sp={class:"error-query-container"},op={key:0,class:"pt-2 border-t"},rp=se({__name:"ResultTabErrorView",props:{activeTab:{}},emits:["onChangeView"],setup(n,{emit:t}){const e=n,a=u=>!!u.metadata.executeErrors,s=$(()=>{var p,f;const u=(p=e.activeTab.metadata.executeErrors)==null?void 0:p.data;return((f=u==null?void 0:u.normalizeError)==null?void 0:f.position)||null}),o=$(()=>{var f;const u=e.activeTab.metadata.executeErrors,p=u==null?void 0:u.data;return((f=p==null?void 0:p.normalizeError)==null?void 0:f.message)||(u==null?void 0:u.message)||""}),r=$(()=>{var p,f;const u=(p=e.activeTab.metadata.executeErrors)==null?void 0:p.data;return((f=u==null?void 0:u.normalizeError)==null?void 0:f.hint)||null}),i=$(()=>{const u=e.activeTab.metadata.statementQuery;if(!u)return[];const p=s.value,f=[];if(p&&p>0){const g=p-1;let x=g;for(;x<u.length&&u[x]!==`
|
|
14
|
+
`&&u[x]!=="\r"&&u[x]!==" "&&u[x]!==" ";)x++;x<=g&&(x=Math.min(g+1,u.length)),f.push({start:g,end:x,properties:{class:"error-highlight"}})}return f}),l=async()=>{if(typeof window>"u")return;await Rt();const u=document.querySelector(".error-query-container .error-highlight");u&&u.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};ce(()=>i.value,()=>{l()},{flush:"post"});const c=$(()=>{var p;const u={...((p=e.activeTab.metadata.executeErrors)==null?void 0:p.data)||{}};return u==null||delete u.normalizeError,u?typeof u=="string"?u:JSON.stringify(u,null,2):""}),m=$(()=>e.activeTab.metadata.statementQuery||"");return(u,p)=>{var x;const f=be,g=xa;return S(),k("div",Xm,[a(u.activeTab)?(S(),k("div",Zm,[C("div",Jm,[C("div",null,[C("div",ep,[h(f,{name:"hugeicons:alert-02",class:"size-4 text-red-500 mt-0.5"}),p[0]||(p[0]=C("div",{class:"font-medium text-red-600"},"Error Message",-1))]),C("span",tp,U(o.value),1),r.value?(S(),k("div",ap," Hint: "+U(r.value),1)):K("",!0)])]),C("div",np,[p[1]||(p[1]=C("div",{class:"mb-2"},[C("span",{class:"font-normal text-sm text-muted-foreground flex items-center gap-1"}," View executed query : ")],-1)),C("div",sp,[h(g,{code:m.value,decorations:i.value,"show-copy-button":""},null,8,["code","decorations"])])]),(x=u.activeTab.metadata.executeErrors)!=null&&x.data?(S(),k("div",op,[p[2]||(p[2]=C("div",{class:"flex items-center justify-between mb-2"},[C("div",{class:"text-sm text-muted-foreground"},"Error Details:")],-1)),h(g,{code:c.value,language:"json"},null,8,["code"])])):K("",!0)])):K("",!0)])}}}),ip=Za(rp,[["__scopeId","data-v-3dcef677"]]),lp={class:"h-full p-4 space-y-3 overflow-y-auto"},up={class:"space-y-2"},cp={class:"flex items-center gap-2 text-sm"},dp={class:"font-medium"},mp={class:"flex items-center gap-2 text-sm"},pp={class:"font-medium"},fp={class:"flex items-center gap-2 text-sm"},vp={class:"font-medium"},hp={class:"flex items-center gap-2 text-sm"},gp={class:"font-medium"},yp={class:"flex items-center gap-2 text-sm"},xp={class:"font-medium"},bp={key:0,class:"flex items-center gap-2 text-sm"},Sp={class:"font-medium"},Cp={class:"pt-3 border-t"},wp={key:0,class:"pt-3 border-t"},_p={class:"flex flex-wrap gap-1"},Rp=se({__name:"ResultTabInfoView",props:{activeTab:{}},setup(n){const t=n,e=typeof TextEncoder<"u"?new TextEncoder:null,a=$(()=>{var o;const s=((o=t.activeTab)==null?void 0:o.result)??[];if(!e)return{bytes:0,formatted:"N/A"};try{const r=JSON.stringify(s),i=r?e.encode(r).length:0;return{bytes:i,formatted:Wo(i)}}catch{return{bytes:0,formatted:"N/A"}}});return(s,o)=>{var l,c,m,u;const r=be,i=xa;return S(),k("div",lp,[C("div",up,[C("div",cp,[h(r,{name:"hugeicons:clock-01",class:"size-4 text-muted-foreground"}),o[0]||(o[0]=C("span",{class:"text-muted-foreground"},"Query Time:",-1)),C("span",dp,U(d(Dt)(s.activeTab.metadata.queryTime)),1)]),C("div",mp,[h(r,{name:"hugeicons:summation-01",class:"size-4 text-muted-foreground"}),o[1]||(o[1]=C("span",{class:"text-muted-foreground"},"Rows:",-1)),C("span",pp,U(d(Fa)(((l=s.activeTab.result)==null?void 0:l.length)||0)),1)]),C("div",fp,[h(r,{name:"hugeicons:file-02",class:"size-4 text-muted-foreground"}),o[2]||(o[2]=C("span",{class:"text-muted-foreground"},"Result Size:",-1)),C("span",vp,U(a.value.formatted),1)]),C("div",hp,[h(r,{name:"hugeicons:chart-column",class:"size-4 text-muted-foreground"}),o[3]||(o[3]=C("span",{class:"text-muted-foreground"},"Columns:",-1)),C("span",gp,U(((c=s.activeTab.metadata.fieldDefs)==null?void 0:c.length)||0),1)]),C("div",yp,[h(r,{name:"hugeicons:calendar-03",class:"size-4 text-muted-foreground"}),o[4]||(o[4]=C("span",{class:"text-muted-foreground"},"Executed At:",-1)),C("span",xp,U(((m=s.activeTab.metadata.executedAt)==null?void 0:m.toLocaleString())||"N/A"),1)]),s.activeTab.metadata.connection?(S(),k("div",bp,[h(r,{name:"hugeicons:plug-socket",class:"size-4 text-muted-foreground"}),o[5]||(o[5]=C("span",{class:"text-muted-foreground"},"Connection:",-1)),C("span",Sp,U(s.activeTab.metadata.connection.name||"Unknown"),1)])):K("",!0)]),C("div",Cp,[o[6]||(o[6]=C("div",{class:"text-sm text-muted-foreground mb-2"},"Query:",-1)),h(i,{code:s.activeTab.metadata.statementQuery||""},null,8,["code"])]),(u=s.activeTab.metadata.fieldDefs)!=null&&u.length?(S(),k("div",wp,[o[7]||(o[7]=C("div",{class:"text-sm text-muted-foreground mb-2"},"Fields:",-1)),C("div",_p,[(S(!0),k(ae,null,ue(s.activeTab.metadata.fieldDefs,p=>(S(),k("span",{key:p.name,class:"text-xs bg-muted px-2 py-1 rounded"},U(p.name),1))),128))])])):K("",!0)])}}}),Tp={class:"h-full flex flex-col flex-1 overflow-hidden"},Ep=se({__name:"ResultTabRawView",props:{formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(n){const t=n;return(e,a)=>{const s=Bt;return S(),k("div",Tp,[t.formattedData.length===0&&!e.executeLoading&&!e.isStreaming?(S(),D(s,{key:0,title:"No Raw Data",desc:"The query returned no records to display as JSON."})):(S(),D(d(cl),{key:1,modelValue:t.formattedData,mode:"text",readOnly:!0,navigationBar:!1,class:"h-full"},null,8,["modelValue"]))])}}});function Np({query:n,dbConnectionString:t,type:e,providerKind:a,managedSqlite:s,params:o,onMeta:r,onRows:i,onDone:l,onError:c}){const m=new AbortController;let u=0;return(async()=>{var f;try{const g=await fetch("/api/query/raw-execute-stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n,dbConnectionString:t,type:e,providerKind:a,managedSqlite:s,params:o||{}}),signal:m.signal});if(!g.ok){const b=await g.text();c==null||c(b||`HTTP ${g.status}`);return}const x=(f=g.body)==null?void 0:f.getReader();if(!x){c==null||c("No readable stream available");return}const v=new TextDecoder;let _="";for(;;){const{done:b,value:N}=await x.read();if(b)break;_+=v.decode(N,{stream:!0});const R=_.split(`
|
|
15
|
+
`);_=R.pop()||"";for(const w of R){const T=w.trim();if(T)try{const E=JSON.parse(T);switch(E.type){case"meta":r==null||r(E.fields,E.command);break;case"rows":u+=E.data.length,i==null||i(E.data,u);break;case"done":l==null||l(E.rowCount,E.queryTime);break;case"error":c==null||c(E.message,E.error);break}}catch{console.warn("[StreamingQuery] Malformed NDJSON line:",T)}}}if(_.trim())try{const b=JSON.parse(_.trim());b.type==="done"?l==null||l(b.rowCount,b.queryTime):b.type==="error"&&(c==null||c(b.message))}catch{}}catch(g){if(g.name==="AbortError")return;c==null||c(g.message||"Stream connection failed")}})(),{abort:()=>m.abort()}}const ms=n=>{if(n===null||typeof n!="object")return!1;const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null},Zt=n=>n.map(t=>({name:t})),Ap=n=>{if(Array.isArray(n)){if(n.every(t=>ms(t))){const t=n,e=Array.from(new Set(t.flatMap(a=>Object.keys(a))));return{rows:t,fields:Zt(e)}}return{rows:n.map((t,e)=>({index:e,value:t})),fields:Zt(["index","value"])}}return ms(n)?{rows:[n],fields:Zt(Object.keys(n))}:{rows:[{value:n}],fields:Zt(["value"])}};function Mp({getEditorView:n,connection:t,redisDatabaseIndex:e,fileVariables:a,fieldDefs:s,resultTabs:o,buildExplainAnalyzePrefix:r,beforeExecute:i}){const l=at([]),c=at({}),m=at(0),u=jo({isHaveOneExecute:!1,executeLoading:!1,isStreaming:!1,streamingRowCount:0,queryTime:0,executeErrors:void 0,currentStatementQuery:""});let p=null;const f=async({currentStatements:_,queryPrefix:b})=>{var L,I,W,Z,re,le,de,me,Fe,ze,st,ve,Je,Ge,he,ot,M,V,H,B,q;if(!_.length)return;const N=_[0];if(i&&!await i())return;u.isHaveOneExecute=!0,u.currentStatementQuery=N.text;let R=N.text,w={};try{w=JSON.parse(a.value||"{}")}catch(O){console.log("fileParameters error::",O)}let T=ee.RESULT;const E=((L=t.value)==null?void 0:L.type)===oe.REDIS;b&&!E&&(R=`${b} ${R}`,b.startsWith("EXPLAIN")&&(T=ee.EXPLAIN)),s.value=[],l.value=[],c.value={},u.executeLoading=!0,u.isStreaming=!1,u.streamingRowCount=0,p&&(p(),p=null),m.value++;const A={id:Qo(),metadata:{queryTime:0,statementQuery:R,executedAt:new Date,executeErrors:void 0,fieldDefs:void 0,connection:void 0},result:[],view:T,seqIndex:m.value};o.addResultTab(A),El(n());const F=[];if(E){try{const O=Date.now(),Q=await $fetch("/api/redis/workbench/execute",{method:"POST",body:{method:(I=t.value)==null?void 0:I.method,stringConnection:(W=t.value)==null?void 0:W.connectionString,host:(Z=t.value)==null?void 0:Z.host,port:(re=t.value)==null?void 0:re.port,username:(le=t.value)==null?void 0:le.username,password:(de=t.value)==null?void 0:de.password,database:(me=t.value)==null?void 0:me.database,databaseIndex:e==null?void 0:e.value,ssl:(Fe=t.value)==null?void 0:Fe.ssl,ssh:(ze=t.value)==null?void 0:ze.ssh,command:R}}),J=Ap(Q.result),ie=Date.now()-O;s.value=J.fields,A.metadata.fieldDefs=J.fields,A.metadata.connection=t.value,A.metadata.command=((st=Q.command)==null?void 0:st[0])||((ve=R.trim().split(/\s+/)[0])==null?void 0:ve.toUpperCase())||"REDIS",A.metadata.queryTime=ie,A.metadata.rowCount=J.rows.length,A.result=J.rows,c.value={rows:J.rows,fields:J.fields,queryTime:ie},l.value=J.rows,u.executeLoading=!1,u.isStreaming=!1,u.streamingRowCount=J.rows.length,u.queryTime=ie,u.executeErrors=void 0,o.refreshResultTab(A.id,A)}catch(O){const Q=((Je=O==null?void 0:O.data)==null?void 0:Je.message)||(O==null?void 0:O.message)||"Failed to execute Redis command.";u.executeLoading=!1,u.isStreaming=!1,u.executeErrors={message:Q,data:(O==null?void 0:O.data)||{message:Q}},A.metadata.executeErrors=u.executeErrors,A.view=ee.ERROR,o.refreshResultTab(A.id,A)}return}if(b&&T===ee.EXPLAIN){try{const O=await $fetch("/api/query/raw-execute",{method:"POST",body:{dbConnectionString:(Ge=t.value)==null?void 0:Ge.connectionString,type:(he=t.value)==null?void 0:he.type,providerKind:(ot=t.value)==null?void 0:ot.providerKind,managedSqlite:(M=t.value)==null?void 0:M.managedSqlite,query:R,params:w},onResponseError:({response:Q})=>{var Be,rt;const J=(Be=Q._data)==null?void 0:Be.data,ie=n();ie&&J&&zn({editorView:ie,originalSql:N.text,statementFrom:Number(N.from),fileParameters:w,errorDetail:J,clientType:((rt=t.value)==null?void 0:rt.type)||oe.POSTGRES,queryPrefix:b})}});s.value=O.fields,A.metadata.fieldDefs=O.fields,A.result=O.rows,A.metadata.queryTime=O.queryTime||0,A.metadata.connection=t.value,c.value=O,l.value=O.rows,u.executeErrors=void 0,u.queryTime=O.queryTime||0}catch(O){u.executeErrors=O.data,A.metadata.executeErrors=O.data,A.view=ee.ERROR}u.executeLoading=!1,o.refreshResultTab(A.id,A);return}u.isStreaming=!0,u.executeLoading=!1;const{abort:P}=Np({query:R,dbConnectionString:((V=t.value)==null?void 0:V.connectionString)||"",type:(H=t.value)==null?void 0:H.type,providerKind:(B=t.value)==null?void 0:B.providerKind,managedSqlite:(q=t.value)==null?void 0:q.managedSqlite,params:w,onMeta:(O,Q)=>{s.value=O,A.metadata.fieldDefs=O,A.metadata.connection=t.value,A.metadata.command=Q,o.refreshResultTab(A.id,A)},onRows:(O,Q)=>{F.push(...O),u.streamingRowCount=Q,A.result=F,A.metadata.rowCount=Q,l.value=F,o.refreshResultTab(A.id,A)},onDone:(O,Q)=>{u.executeLoading=!1,u.isStreaming=!1,u.queryTime=Q,u.executeErrors=void 0,u.streamingRowCount=O,A.metadata.queryTime=Q,A.metadata.rowCount=O,c.value={rows:A.result,fields:s.value,queryTime:Q},o.refreshResultTab(A.id,A),p=null},onError:(O,Q)=>{var Be;const J={message:O,data:Q||{message:O}};u.executeLoading=!1,u.isStreaming=!1,u.executeErrors=J,A.metadata.executeErrors=J,A.view=ee.ERROR;const ie=n();ie&&Q&&zn({editorView:ie,originalSql:N.text,statementFrom:Number(N.from),fileParameters:w,errorDetail:Q,clientType:((Be=t.value)==null?void 0:Be.type)||oe.POSTGRES}),o.refreshResultTab(A.id,A),p=null}});p=P};return{currentRawQueryResult:l,rawResponse:c,queryProcessState:u,executeCurrentStatement:f,onExecuteCurrent:()=>{const _=n();if(!_)return;const{currentStatements:b}=ra(_);f({currentStatements:b})},onExplainAnalyzeCurrent:()=>{const _=n();if(!_)return;const{currentStatements:b}=ra(_);f({currentStatements:b,queryPrefix:r()})},cancelStreamingQuery:()=>{p&&(p(),p=null,u.executeLoading=!1,u.isStreaming=!1)}}}function Ip(){const n=j({BUFFERS:!0,COSTS:!0,GENERIC_PLAN:!1,MEMORY:!1,SETTINGS:!0,SUMMARY:!0,TIMING:!0,VERBOSE:!0,WAL:!0}),t=j("NONE"),e=r=>{n.value[r]=!n.value[r]},a=r=>{t.value=r};return{explainAnalyzeOptionItems:$(()=>Cn.filter(r=>r.key!=="SERIALIZE").map(r=>({key:r.key,label:r.label,checked:n.value[r.key]}))),serializeMode:t,toggleExplainOption:e,setSerializeMode:a,buildExplainAnalyzePrefix:()=>{const r=Cn.filter(c=>c.key!=="SERIALIZE"&&n.value[c.key]).map(c=>c.key).flatMap(c=>c==="GENERIC_PLAN"?[]:[c]),i=t.value==="NONE"?[]:[`SERIALIZE ${t.value}`];return`EXPLAIN (${["ANALYZE","FORMAT JSON",...r,...i].join(", ")})`}}}function Lp(){const n=at(new Map),t=j(null),e=m=>{const u=new Map;u.set(m.id,m),n.value.forEach((p,f)=>{u.set(f,p)}),n.value=u,t.value=m.id},a=(m,u)=>{const p=new Map(n.value);p.set(m,{...u}),n.value=p};return{executedResults:n,activeResultTabId:t,addResultTab:e,refreshResultTab:a,setActiveResultTab:m=>{n.value.has(m)&&(t.value=m)},closeResultTab:m=>{const u=new Map(n.value);if(u.delete(m),n.value=u,t.value===m){const p=Array.from(u.keys());t.value=p.length>0?p[p.length-1]:null}},updateResultTabView:(m,u)=>{const p=n.value.get(m);p&&a(m,{...p,view:u})},closeOtherResultTabs:m=>{const u=n.value.get(m);if(!u)return;const p=new Map;p.set(m,u),n.value=p,t.value=m},closeResultTabsToRight:m=>{const u=Array.from(n.value.keys()),p=u.indexOf(m);if(p<0)return;const f=new Map;for(let g=0;g<=p;g++){const x=u[g],v=n.value.get(x);v&&f.set(x,v)}n.value=f,f.has(t.value||"")||(t.value=m)},updateResultTabResult:(m,u)=>{const f=new Map(n.value).get(m);f&&(f.result=u)}}}function Ot(n,...t){}const kp=n=>{let t;return async()=>(t||(t=n()),await t)};class pn{constructor(t={}){we(this,"opts");we(this,"parser",null);we(this,"offsetRecord",{});we(this,"getParser",kp(async()=>{if(this.parser)return this.parser;const t=await Cs(()=>import("./XjywAggc.js").then(a=>a.i),__vite__mapDeps([0,1,2]),import.meta.url),{Parser:e}=t.default||t;return this.parser=new e,this.parser}));this.opts=t}async parse(t,e){var o,r;this.offsetRecord={};const a=(r=(o=this.opts).getParserOptions)==null?void 0:r.call(o,e.state),s=await this.sanitizeSql(t,a);try{const i=await this.getParser();if((a==null?void 0:a.database)==="DuckDB")return this.parseWithDuckDBSupport(s,a);const l=i.astify(s,a);return{success:!0,errors:[],ast:l}}catch(i){return{success:!1,errors:[this.extractErrorInfo(i,s)]}}}async sanitizeSql(t,e){if(e!=null&&e.ignoreBrackets){const{sql:a,offsetRecord:s}=Op(t);return this.offsetRecord=s,a}return t}async parseWithDuckDBSupport(t,e){const a=await this.getParser(),s=zp(t).trimStart().toLowerCase();if(s.startsWith("from")||s.includes("macro"))return Ot(),{success:!0,errors:[]};let o=t;s.includes("create or replace table")&&(this.offsetRecord[t.indexOf("create or replace table")]=-11,o=t.replace(/create or replace table/i,"create table"));try{const r={...e,database:"PostgreSQL"},i=a.astify(o,r);return{success:!0,errors:[],ast:i}}catch(r){return{success:!1,errors:[this.extractErrorInfo(r,t)]}}}extractErrorInfo(t,e){var i,l,c;let a=1,s=1;const o=(t==null?void 0:t.message)||"SQL parsing error",r=t;if(r!=null&&r.location)a=((i=r.location.start)==null?void 0:i.line)||1,s=((l=r.location.start)==null?void 0:l.column)||1;else if(r!=null&&r.hash)a=r.hash.line||1,s=((c=r.hash.loc)==null?void 0:c.first_column)||1;else{const m=o.match(/line (\d+)/i),u=o.match(/column (\d+)/i);m!=null&&m[1]&&(a=parseInt(m[1],10)),u!=null&&u[1]&&(s=parseInt(u[1],10))}for(const[m,u]of Object.entries(this.offsetRecord))s>parseInt(m,10)&&(s-=u);return s>e.length&&(s=e.length),{message:this.cleanErrorMessage(o),line:Math.max(1,a),column:s,severity:"error"}}cleanErrorMessage(t){return t.replace(/^Error: /,"").replace(/Expected .* but .* found\./i,e=>e.replace(/but .* found/,"found unexpected token")).trim()}async validateSql(t,e){return(await this.parse(t,e)).errors}async extractTableReferences(t,e){var s,o;const a=e?(o=(s=this.opts).getParserOptions)==null?void 0:o.call(s,e.state):void 0;try{return(await this.getParser()).tableList(t,a).map(l=>{const c=l.split("::");return c[c.length-1]||l})}catch{return[]}}async extractColumnReferences(t,e){var s,o;const a=e!=null&&e.state?(o=(s=this.opts).getParserOptions)==null?void 0:o.call(s,e.state):void 0;try{return(await this.getParser()).columnList(t,a).map(c=>{const m=c.split("::");return m[m.length-1]||c})}catch{return[]}}}function zp(n,t=["/*","--"]){const e=[];if(t.includes("/*")&&e.push("/\\*[\\s\\S]*?\\*/"),t.includes("--")&&e.push("--[^\\n]*"),e.length===0)return n;const a=new RegExp(`^\\s*(${e.join("|")})\\s*`,"");let s=n,o="";for(;s!==o;)o=s,s=s.replace(a,"");return s}const $p=2;function Op(n){const t={};return{sql:n.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(\{[^}]*\})/g,(a,s,o,r,i)=>s||o?a:r?(t[i]=$p,`'${r}'`):a),offsetRecord:t}}const Vp=750;function Pp(n,t){const a=t.line(n.line).from+Math.max(0,n.column-1),s=a+1;return{from:a,to:s,severity:n.severity,message:n.message,source:"sql-parser"}}function Dp(n={}){const t=n.parser||new pn;return xs(async e=>{const a=e.state.doc,s=a.toString();return s.trim()?(await t.validateSql(s,{state:e.state})).map(r=>Pp(r,a)):[]},{delay:n.delay||Vp})}function xt(n){return typeof n=="object"&&!Array.isArray(n)&&!("self"in n)}function nt(n){return typeof n=="object"&&!Array.isArray(n)&&"self"in n&&"children"in n}function Ue(n){return Array.isArray(n)}function Te(n,t,e,a){const s=n.length;if(t==="string"||t==="completion"&&a&&Ue(a))return"column";if(t==="namespace"&&e){if(Ue(e))return"table";if(xt(e))return Object.values(e).some(r=>Ue(r)||nt(r)&&Ue(r.children))?s<=1?"database":"schema":s===0?"database":"namespace"}if(t==="completion"&&e)return Ue(e)?"table":(xt(e)&&Object.values(e).some(r=>Ue(r)||nt(r)&&Ue(r.children)),s<=1?"database":"schema");switch(s){case 0:return"database";case 1:return"schema";default:return"namespace"}}function so(n,t,e={}){const{maxDepth:a=10}=e;if(t===""&&nt(n)){const o=Te([],"completion",n.children);return{completion:n.self,path:[],type:"completion",semanticType:o,namespace:n.children}}const s=t.split(".").filter(o=>o.length>0);return s.length===0||s.length>a?null:Qa(n,s,[],e)}function Qa(n,t,e,a,s){if(t.length===0){if(nt(n)){const c=Te(e,"completion",n.children,s);return{completion:n.self,path:e,type:"completion",semanticType:c,namespace:n.children}}const l=Te(e,"namespace",n,s);return{path:e,type:"namespace",semanticType:l,namespace:n}}const[o,...r]=t,{caseSensitive:i=!1}=a;if(!o)return null;if(xt(n)){const l=i?Object.keys(n).find(c=>c===o):Object.keys(n).find(c=>c.toLowerCase()===o.toLowerCase());if(l){const c=n[l];if(c)return Qa(c,r,[...e,l],a,n)}}else{if(nt(n))return Qa(n.children,t,e,a,n);if(Ue(n)){for(const l of n)if(typeof l=="string"){if((i?l===o:l.toLowerCase()===o.toLowerCase())&&r.length===0){const m=Te([...e,l],"string",void 0,n);return{value:l,path:[...e,l],type:"string",semanticType:m}}}else if((i?l.label===o:l.label.toLowerCase()===o.toLowerCase())&&r.length===0){const m=Te([...e,l.label],"completion",void 0,n);return{completion:l,path:[...e,l.label],type:"completion",semanticType:m}}}}return null}function Fp(n,t,e={}){const a=[];if(t.includes(".")){const s=t.lastIndexOf("."),o=t.substring(0,s),r=t.substring(s+1),i=so(n,o,e);if(i!=null&&i.namespace)return Ya(i.namespace,r,i.path,e)}else return Ya(n,t,[],e);return a}function Ya(n,t,e,a){const s=[],{caseSensitive:o=!1,allowPartialMatch:r=!0}=a;if(xt(n)){for(const[i,l]of Object.entries(n))if(r?o?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):o?i===t:i.toLowerCase()===t.toLowerCase())if(nt(l)){const m=Te([...e,i],"completion",l.children,n);s.push({completion:l.self,path:[...e,i],type:"completion",semanticType:m,namespace:l.children})}else{const m=Te([...e,i],"namespace",l,n);s.push({path:[...e,i],type:"namespace",semanticType:m,namespace:l})}}else if(nt(n)){if(r?o?n.self.label.startsWith(t):n.self.label.toLowerCase().startsWith(t.toLowerCase()):o?n.self.label===t:n.self.label.toLowerCase()===t.toLowerCase()){const l=Te([...e,n.self.label],"completion",n.children);s.push({completion:n.self,path:[...e,n.self.label],type:"completion",semanticType:l,namespace:n.children})}s.push(...Ya(n.children,t,e,a))}else if(Ue(n)){for(const i of n)if(typeof i=="string"){if(r?o?i.startsWith(t):i.toLowerCase().startsWith(t.toLowerCase()):o?i===t:i.toLowerCase()===t.toLowerCase()){const c=Te([...e,i],"string",void 0,n);s.push({value:i,path:[...e,i],type:"string",semanticType:c})}}else if(r?o?i.label.startsWith(t):i.label.toLowerCase().startsWith(t.toLowerCase()):o?i.label===t:i.label.toLowerCase()===t.toLowerCase()){const c=Te([...e,i.label],"completion",void 0,n);s.push({completion:i,path:[...e,i.label],type:"completion",semanticType:c})}}return s}function Bp(n,t,e={}){const a=[],{maxDepth:s=10}=e;sa(n,[],a,s);const{caseSensitive:o=!1}=e;return a.filter(i=>i.path.some(l=>o?l===t:l.toLowerCase()===t.toLowerCase())).sort((i,l)=>{var u,p;const c=o?i.path[i.path.length-1]===t:((u=i.path[i.path.length-1])==null?void 0:u.toLowerCase())===t.toLowerCase(),m=o?l.path[l.path.length-1]===t:((p=l.path[l.path.length-1])==null?void 0:p.toLowerCase())===t.toLowerCase();return c&&!m?-1:!c&&m?1:i.path.length-l.path.length})}function sa(n,t,e,a){if(!(t.length>=a)){if(xt(n))for(const[s,o]of Object.entries(n)){const r=[...t,s];if(nt(o)){const i=Te(r,"completion",o.children,n);e.push({completion:o.self,path:r,type:"completion",semanticType:i,namespace:o.children}),sa(o.children,r,e,a)}else{const i=Te(r,"namespace",o,n);e.push({path:r,type:"namespace",semanticType:i,namespace:o}),sa(o,r,e,a)}}else if(nt(n)){const s=Te(t,"completion",n.children);e.push({completion:n.self,path:t,type:"completion",semanticType:s,namespace:n.children}),sa(n.children,t,e,a)}else if(Ue(n))for(const s of n)if(typeof s=="string"){const o=Te([...t,s],"string",void 0,n);e.push({value:s,path:[...t,s],type:"string",semanticType:o})}else{const o=Te([...t,s.label],"completion",void 0,n);e.push({completion:s,path:[...t,s.label],type:"completion",semanticType:o})}}}function ps(n,t,e={}){const{enableFuzzySearch:a=!1}=e,s=so(n,t,e);if(s)return s;const o=Fp(n,t,e);if(o.length>0)return o[0]||null;if(a){const r=Bp(n,t,e);if(r.length>0)return r[0]||null}return null}function oo(n,t){if(t.size===0)return{};if(xt(n)){const e={};for(const[a,s]of Object.entries(n))if(Array.from(t).some(r=>r.toLowerCase()===a.toLowerCase()))e[a]=s;else if(xt(s)){const r=oo(s,t);Object.keys(r).length>0&&(e[a]=r)}return e}return n}function Hp(n={}){const{schema:t={},keywords:e={},hoverTime:a=300,enableKeywords:s=!0,enableTables:o=!0,enableColumns:r=!0,enableFuzzySearch:i=!0,parser:l=new pn,tooltipRender:c,tooltipRenderers:m={}}=n;let u=null;return Yo(async(p,f,g)=>{const{from:x,to:v,text:_}=p.state.doc.lineAt(f);let b=f,N=f;u===null&&(u=typeof e=="function"?e(p):Promise.resolve(e));const R=await u;for(;b>x&&/[\w.]/.test(_[b-x-1]??"");)b--;for(;N<v&&/[\w.]/.test(_[N-x]??"");)N++;if(b===f&&g<0||N===f&&g>0)return null;const w=_.slice(b-x,N-x).toLowerCase();if(!w||w.length===0)return null;const T=typeof t=="function"?t(p):t;let E=null;if(Ot(),!E&&s&&R[w]){Ot("keywordResult",w,R[w]);const A={keyword:w,info:R[w]};E={word:w,view:p,pos:f,tooltipType:"keyword",keywordData:A}}if(!E&&(o||r)&&T){const A=p.state.doc.toString(),F=await l.extractTableReferences(A),P=new Set(F.map(W=>W.toLowerCase())),L=oo(T,P);let I=ps(L,w,{enableFuzzySearch:i});if(!I&&P.size===0&&(I=ps(T,w,{enableFuzzySearch:i})),I){Ot("namespaceResult (query-aware)",w,I,"tableRefs:",Array.from(P));const W={item:I,word:w,resolvedSchema:P.size>0?L:T};E={word:w,view:p,pos:f,tooltipType:"namespace",namespaceData:W}}else Ot("No namespace item found for:",w)}return E?{pos:b,end:N,above:!0,create(A){if(c){const L=c(w,A,f);if(L)return{dom:L}}let F=null;if(E.tooltipType==="keyword"&&E.keywordData)F=m.keyword?m.keyword(E.keywordData):Up(E.keywordData);else if(E.tooltipType==="namespace"&&E.namespaceData){const L=E.namespaceData,{semanticType:I}=L.item;I==="table"&&m.table?F=m.table(L):I==="column"&&m.column?F=m.column(L):(I==="database"||I==="schema"||I==="namespace")&&m.namespace?F=m.namespace(L):F=qp(L.item)}if(!F)return{dom:document.createElement("div")};const P=document.createElement("div");return P.className="cm-sql-hover-tooltip",P.innerHTML=F,{dom:P}}}:null},{hoverTime:a})}function qp(n){var s,o,r,i,l,c,m;const t=n.path.join("."),e=((s=n.completion)==null?void 0:s.label)||n.value||n.path[n.path.length-1]||"unknown";let a=`<div class="sql-hover-${n.semanticType}">`;switch(a+=`<div class="sql-hover-header"><strong>${e}</strong> <span class="sql-hover-type">${n.semanticType}</span></div>`,n.semanticType){case"database":if(a+=`<div class="sql-hover-description">Database${(o=n.completion)!=null&&o.detail?`: ${n.completion.detail}`:""}</div>`,n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} schema${u!==1?"s":""}</div>`)}break;case"schema":if(a+=`<div class="sql-hover-description">Schema${(r=n.completion)!=null&&r.detail?`: ${n.completion.detail}`:""}</div>`,t&&(a+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} table${u!==1?"s":""}</div>`)}break;case"table":if(a+=`<div class="sql-hover-description">Table${(i=n.completion)!=null&&i.detail?`: ${n.completion.detail}`:""}</div>`,t){const u=n.path;u.length>1&&(a+=`<div class="sql-hover-path"><strong>Schema:</strong> <code>${u.slice(0,-1).join(".")}</code></div>`)}if(n.namespace&&Ue(n.namespace)){const u=n.namespace;if(u.length>0){a+=`<div class="sql-hover-columns"><strong>Columns (${u.length}):</strong><br>`;const f=u.slice(0,8).map(g=>typeof g=="string"?g:g.label);a+=f.map(g=>`<code>${g}</code>`).join(", "),u.length>8&&(a+=`, <em>and ${u.length-8} more...</em>`),a+="</div>"}}break;case"column":if(a+=`<div class="sql-hover-description">Column${(l=n.completion)!=null&&l.detail?`: ${n.completion.detail}`:""}</div>`,t){const u=n.path;u.length>1&&(a+=`<div class="sql-hover-path"><strong>Table:</strong> <code>${u.slice(0,-1).join(".")}</code></div>`)}break;default:if(a+=`<div class="sql-hover-description">Namespace${(c=n.completion)!=null&&c.detail?`: ${n.completion.detail}`:""}</div>`,t&&(a+=`<div class="sql-hover-path"><strong>Path:</strong> <code>${t}</code></div>`),n.namespace){const u=oa(n.namespace);u>0&&(a+=`<div class="sql-hover-children">Contains ${u} item${u!==1?"s":""}</div>`)}break}return(m=n.completion)!=null&&m.info&&typeof n.completion.info=="string"&&(a+=`<div class="sql-hover-info">${n.completion.info}</div>`),a+="</div>",a}function oa(n){return Array.isArray(n)?n.length:typeof n=="object"&&n!==null?"self"in n&&"children"in n?1+oa(n.children):Object.keys(n).length:0}function Up(n){const{keyword:t,info:e}=n;let a='<div class="sql-hover-keyword">';if(a+=`<div class="sql-hover-header"><strong>${t.toUpperCase()}</strong> <span class="sql-hover-type">keyword</span></div>`,a+=`<div class="sql-hover-description">${e.description}</div>`,e.syntax&&(a+=`<div class="sql-hover-syntax"><strong>Syntax:</strong> <code>${e.syntax}</code></div>`),e.example&&(a+=`<div class="sql-hover-example"><strong>Example:</strong><br><code>${e.example}</code></div>`),e.metadata&&typeof e.metadata=="object"&&Object.keys(e.metadata).length>0){a+='<div class="sql-hover-metadata">';for(const[s,o]of Object.entries(e.metadata))a+=`<span class="sql-hover-tag" title="${s}">${o}</span> `;a+="</div>"}return a+="</div>",a}const Kp=(n="light")=>{const a=n==="dark"?{tooltipBg:"#1f2937",tooltipBorder:"#374151",tooltipText:"#f9fafb",tooltipTypeBg:"#374151",tooltipTypeText:"#9ca3af",tooltipChildren:"#9ca3af",codeBg:"#374151",codeText:"#f3f4f6",strong:"#ffffff",em:"#9ca3af",header:"#ffffff",info:"#d1d5db",related:"#d1d5db",path:"#d1d5db",example:"#d1d5db",columns:"#d1d5db",syntax:"#d1d5db"}:{tooltipBg:"#ffffff",tooltipBorder:"#e5e7eb",tooltipText:"#374151",tooltipTypeBg:"#f3f4f6",tooltipTypeText:"#6b7280",tooltipChildren:"#6b7280",codeBg:"#f9fafb",codeText:"#1f2937",strong:"#111827",em:"#6b7280",header:"#111827",info:"#374151",related:"#374151",path:"#374151",example:"#374151",columns:"#374151",syntax:"#374151"};return on.theme({".cm-sql-hover-tooltip":{padding:"8px 12px",backgroundColor:a.tooltipBg,border:`1px solid ${a.tooltipBorder}`,borderRadius:"6px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",fontSize:"13px",lineHeight:"1.4",maxWidth:"320px",fontFamily:"system-ui, -apple-system, sans-serif",color:a.tooltipText},".cm-sql-hover-tooltip .sql-hover-header":{marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px",color:a.header},".cm-sql-hover-tooltip .sql-hover-type":{fontSize:"11px",padding:"2px 6px",backgroundColor:a.tooltipTypeBg,color:a.tooltipTypeText,borderRadius:"4px",fontWeight:"500"},".cm-sql-hover-tooltip .sql-hover-description":{color:a.info,marginBottom:"8px"},".cm-sql-hover-tooltip .sql-hover-syntax":{marginBottom:"8px",color:a.syntax},".cm-sql-hover-tooltip .sql-hover-example":{marginBottom:"4px",color:a.example},".cm-sql-hover-tooltip .sql-hover-columns":{marginBottom:"4px",color:a.columns},".cm-sql-hover-tooltip .sql-hover-related":{marginBottom:"4px",color:a.related},".cm-sql-hover-tooltip .sql-hover-path":{marginBottom:"4px",color:a.path},".cm-sql-hover-tooltip .sql-hover-info":{marginBottom:"4px",color:a.info},".cm-sql-hover-tooltip .sql-hover-children":{marginBottom:"4px",color:a.tooltipChildren,fontSize:"12px"},".cm-sql-hover-tooltip code":{backgroundColor:a.codeBg,padding:"1px 4px",borderRadius:"3px",fontSize:"12px",fontFamily:"ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace",color:a.codeText},".cm-sql-hover-tooltip strong":{fontWeight:"600",color:a.strong},".cm-sql-hover-tooltip em":{fontStyle:"italic",color:a.em}})};class Gp{constructor(t){we(this,"parser");we(this,"cache",new Map);we(this,"MAX_CACHE_SIZE",10);this.parser=t}async analyzeDocument(t){const e=t.doc.toString(),a=this.generateCacheKey(e),s=this.cache.get(a);if(s)return s;const o=await this.extractStatements(e,t);if(this.cache.set(a,o),this.cache.size>this.MAX_CACHE_SIZE){const r=this.cache.keys().next().value;r!==void 0&&this.cache.delete(r)}return o}async getStatementAtPosition(t,e){return(await this.analyzeDocument(t)).find(s=>e>=s.from&&e<=s.to)||null}async getStatementsInRange(t,e,a){return(await this.analyzeDocument(t)).filter(o=>o.from<=a&&o.to>=e)}async extractStatements(t,e){const a=[],s=this.splitByStatementSeparators(t);let o=0;for(const r of s){const i=r.trim();if(i.length===0){o+=r.length;continue}const l=o+r.indexOf(i),c=l+i.length,m=e.doc.lineAt(l),u=e.doc.lineAt(c),p=this.stripComments(i);if(p.trim().length===0||p.trim()===";"){o+=r.length;continue}const f=await this.parser.parse(p,{state:e}),g=this.determineStatementType(p),x=p.endsWith(";")?p.slice(0,-1).trim():p.trim();a.push({from:l,to:c,lineFrom:m.number,lineTo:u.number,content:x,type:g,isValid:f.success}),o+=r.length}return a}splitByStatementSeparators(t){const e=[];let a="",s=!1,o="",r=!1,i=!1,l=0;for(;l<t.length;){const c=t[l],m=t[l+1];if(!s&&!i&&c==="-"&&m==="-"){r=!0,a+=c+m,l+=2;continue}if(!s&&!r&&c==="/"&&m==="*"){i=!0,a+=c+m,l+=2;continue}if(i&&c==="*"&&m==="/"){i=!1,a+=c+m,l+=2;continue}if(r&&(c===`
|
|
16
|
+
`||c==="\r")){r=!1,a+=c,l++;continue}if(r||i){a+=c,l++;continue}if(!s&&(c==="'"||c==='"'||c==="`"))s=!0,o=c,a+=c;else if(s&&c===o){if(m===o){a+=c+m,l+=2;continue}s=!1,o="",a+=c}else!s&&c===";"?(a+=c,e.push(a),a=""):a+=c;l++}return a.trim()&&e.push(a),e}determineStatementType(t){const e=t.trim().toLowerCase();return e.startsWith("select")?"select":e.startsWith("insert")?"insert":e.startsWith("update")?"update":e.startsWith("delete")?"delete":e.startsWith("create")?"create":e.startsWith("drop")?"drop":e.startsWith("alter")?"alter":e.startsWith("use")?"use":"other"}stripComments(t){let e="",a=!1,s="",o=!1,r=!1,i=0;for(;i<t.length;){const l=t[i],c=t[i+1];if(!a&&!r&&l==="-"&&c==="-"){o=!0,i+=2;continue}if(!a&&!o&&l==="/"&&c==="*"){r=!0,i+=2;continue}if(r&&l==="*"&&c==="/"){r=!1,i+=2;continue}if(o&&(l===`
|
|
17
|
+
`||l==="\r")){o=!1,e+=l,i++;continue}if(o||r){i++;continue}if(!a&&(l==="'"||l==='"'||l==="`"))a=!0,s=l,e+=l;else if(a&&l===s){if(c===s){e+=l+c,i+=2;continue}a=!1,s="",e+=l}else e+=l;i++}return e}generateCacheKey(t){let e=0;for(let a=0;a<t.length;a++){const s=t.charCodeAt(a);e=(e<<5)-e+s,e=e&e}return e.toString()}clearCache(){this.cache.clear()}}const ro=Zo.define(),io=Xo.define({create(){return{currentStatement:null,allStatements:[],cursorPosition:0,isFocused:!0}},update(n,t){for(const e of t.effects)if(e.is(ro))return e.value;return n}});class Wp extends tr{constructor(e,a,s=!0,o=!0){super();we(this,"config");we(this,"isCurrent");we(this,"isValid");we(this,"isFocused");this.config=e,this.isCurrent=a,this.isValid=s,this.isFocused=o}toDOM(){const e=document.createElement("div");e.className="cm-sql-gutter-marker";let a=this.config.backgroundColor||"#3b82f6";!this.isValid&&this.config.showInvalid!==!1&&(a=this.config.errorBackgroundColor||"#ef4444");let s;return this.isFocused?s=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString():this.config.unfocusedOpacity!==void 0?s=this.config.unfocusedOpacity.toString():this.config.hideWhenNotFocused?s="0":s=this.isCurrent?"1":(this.config.inactiveOpacity||"0.3").toString(),e.style.cssText=`
|
|
18
|
+
background: ${a};
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
opacity: ${s};
|
|
22
|
+
transition: opacity 150ms ease-in-out;
|
|
23
|
+
border-radius: 1px;
|
|
24
|
+
`,e}eq(e){return this.isCurrent===e.isCurrent&&this.isValid===e.isValid&&this.isFocused===e.isFocused&&this.config===e.config}}function jp(n,t){var i;let e=er.empty;if((i=t.whenHide)!=null&&i.call(t,n))return e;const a=n.state.field(io,!1);if(!a)return e;const{currentStatement:s,allStatements:o,isFocused:r}=a;try{for(const l of o){const c=(s==null?void 0:s.from)===l.from&&(s==null?void 0:s.to)===l.to;if(!l.isValid&&t.showInvalid===!1)continue;const m=new Wp(t,c,l.isValid,r);for(let u=l.lineFrom;u<=l.lineTo;u++)try{if(u<1||u>n.state.doc.lines)continue;const p=n.state.doc.line(u);e=e.update({add:[m.range(p.from)]})}catch(p){console.warn("SqlGutter: Invalid line number",u,p)}}}catch(l){console.warn("SqlGutter: Error creating markers",l)}return e}function Qp(n){return on.updateListener.of(async t=>{if(!t.docChanged&&!t.selectionSet&&!t.focusChanged)return;const{state:e}=t.view,{main:a}=e.selection,s=a.head,o=await n.analyzeDocument(e),i={currentStatement:await n.getStatementAtPosition(e,s),allStatements:o,cursorPosition:s,isFocused:t.view.hasFocus};t.view.dispatch({effects:ro.of(i)})})}function Yp(n){const t=n.width||3;return on.baseTheme({".cm-sql-gutter":{width:`${t}px`,minWidth:`${t}px`},".cm-sql-gutter .cm-gutterElement":{width:`${t}px`,padding:"0",margin:"0"},".cm-sql-gutter-marker":{width:"100%",height:"100%",display:"block"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"8px"}})}function Xp(n){return Jo({class:`cm-sql-gutter ${n.className||""}`,markers:t=>jp(t,n)})}function Zp(n={}){const t=n.parser||new pn,e=new Gp(t);return[io,Qp(e),Yp(n),Xp(n)]}function Jp(n={}){const t=[],{enableLinting:e=!0,enableGutterMarkers:a=!0,enableHover:s=!0,linterConfig:o,gutterConfig:r,hoverConfig:i}=n;return e&&t.push(Dp(o)),a&&t.push(Zp(r)),s&&(t.push(Hp(i)),i!=null&&i.theme?t.push(i.theme):t.push(Kp())),t}const ef=new RegExp(`(${Ze})\\s*\\.\\s*([A-Za-z_][A-Za-z0-9_$]*)?$`);function tf(n,t){let a=ws(n).resolveInner(t,-1);for(;a;){if(a.type.name==="Statement")return a;a=a.parent}return null}function af(n){return/Comment|String/.test(n.type.name)}function nf({tableReference:n,tableName:t,schemaName:e,tableInfo:a}){var s,o;return{tableName:t,schemaName:e,tableReference:n,columns:a.columns||[],primaryKeyColumns:new Set(((s=a.primary_keys)==null?void 0:s.map(r=>r.column))||[]),foreignKeysByColumn:new Map(((o=a.foreign_keys)==null?void 0:o.map(r=>[r.column,r]))||[])}}function sf({tableReference:n,schemas:t,defaultSchemaName:e}){const a=Sa({tableReference:n,schemas:t,defaultSchemaName:e});return a?nf({tableReference:n,tableName:a.tableName,schemaName:a.schemaName,tableInfo:a.tableInfo}):null}function of(n){return[...n.columns].sort((e,a)=>(e.ordinal_position||0)-(a.ordinal_position||0)).map(e=>vl({column:e,tableName:n.tableName,schemaName:n.schemaName,isPrimaryKey:n.primaryKeyColumns.has(e.name),foreignKey:n.foreignKeysByColumn.get(e.name)}))}function rf(n,t){const e=ws(n.state).resolveInner(n.pos,-1);if(af(e))return null;const a=tf(n.state,n.pos);if(!a)return null;const s=n.state.doc.sliceString(a.from,n.pos),o=ef.exec(s);if(!o)return null;const r=o[1],i=o[2]||"",l=Se(r),c=n.state.doc.sliceString(a.from,a.to),u=Js(c).get(l)||r,p=sf({tableReference:u,schemas:t.schemas,defaultSchemaName:t.defaultSchemaName});return p?{from:n.pos-i.length,options:of(p),validFor:/^[A-Za-z0-9_$]*$/}:null}function lf(n,t){if(!t.fileVariables)return null;const e=n.matchBefore(/:\w*$/);if(!e)return null;try{const a=JSON.parse(t.fileVariables),s=[];for(const o in a)s.push({label:`:${o}`,type:ar.Variable,boost:120,detail:"variable",info:()=>fl(o,a[o]),apply(r,i,l,c){const u=r.state.doc.sliceString(l-1,l)===":"?l-1:l;r.dispatch({changes:{from:u,to:c,insert:i.label}})}});return{from:e.from,options:s,validFor:/^:\w*$/}}catch{return null}}function uf(n){return t=>{const e=lf(t,n);return e||rf(t,n)}}const cf=async()=>(await Cs(()=>import("./BiOIaWuc.js"),[],import.meta.url)).default.keywords;function df({codeEditorRef:n,fileVariables:t,connection:e,onExecuteStatement:a,onExplainAnalyzeCurrent:s}){const o=rn(),{schemasByContext:r,activeSchema:i}=ga(o),l=j({line:1,column:1}),c=()=>{var W;return(W=n.value)==null?void 0:W.editorView},m=$(()=>{var W,Z,re;return((W=i.value)==null?void 0:W.name)||((re=(Z=r.value)==null?void 0:Z[0])==null?void 0:re.name)}),u=$(()=>{var W;return((W=e==null?void 0:e.value)==null?void 0:W.type)===oe.REDIS}),p=$(()=>!u.value),f=$(()=>{var W;return((W=e==null?void 0:e.value)==null?void 0:W.type)===oe.POSTGRES}),g=$(()=>hl({schemas:r.value,defaultSchemaName:m.value,fileVariables:t.value})),x=new _a,v=new _a,_=new _a,b=()=>{var W,Z;return cr({dialect:wn((W=e==null?void 0:e.value)==null?void 0:W.type),upperCaseKeywords:!0,keywordCompletion:!((Z=e==null?void 0:e.value)!=null&&Z.type)||e.value.type===oe.POSTGRES?pr:void 0,schema:g.value.schema,defaultSchema:g.value.defaultSchema})},N=()=>u.value?ur():b(),R=()=>{var W;return u.value?[]:wn((W=e==null?void 0:e.value)==null?void 0:W.type).language.data.of({autocomplete:T()})},w=()=>u.value?[]:Jp({enableLinting:!1,enableGutterMarkers:!1,enableHover:!0,hoverConfig:{hoverTime:250,enableKeywords:!0,keywords:async()=>await cf(),enableTables:!1,enableColumns:!1,enableFuzzySearch:!1}}),T=()=>uf({schemas:r.value,defaultSchemaName:m.value,fileVariables:t.value}),{onHandleFormatCurrentStatement:E,onHandleFormatCode:A}=pl({getEditorView:()=>c()}),F=()=>{p.value&&E()},P=()=>{p.value&&A()},L=[Nl(a),hs.of([{key:"Mod-s",run:()=>(F(),!0),preventDefault:!0},{key:"Shift-Alt-f",run:()=>(P(),!0),preventDefault:!0},{key:"Mod-e",run:()=>(f.value&&s(),!0),preventDefault:!0},{key:"Mod-i",run:ir},{key:"Tab",run:lr}]),x.of(N()),v.of(R()),nr,sr,...or(),ys(),_.of(w()),rr],I=()=>{var le;const W=c();if(!W)return;const Z=dr((le=e==null?void 0:e.value)==null?void 0:le.type),re=u.value?"line":"sql";W.dispatch({effects:[mr.of({dialect:Z,isEnable:!u.value,statementMode:re}),x.reconfigure(N()),v.reconfigure(R()),_.reconfigure(w())]})};return ce(()=>{var W;return[(W=i.value)==null?void 0:W.name,r.value]},()=>{var W;(W=i.value)!=null&&W.name&&I()},{deep:!0,immediate:!0}),e&&ce(()=>{var W;return(W=e.value)==null?void 0:W.type},()=>{I()}),ce(()=>{var W;return(W=n.value)==null?void 0:W.editorView},W=>{W&&I()},{immediate:!0}),{extensions:L,sqlCompartment:x,cursorInfo:l,onHandleFormatCode:P,onHandleFormatCurrentStatement:F,reloadSqlCompartment:I}}function mf({fileVariables:n,connection:t,redisDatabaseIndex:e,fieldDefs:a,beforeExecute:s}){const o=j(null),{explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:l,setSerializeMode:c,buildExplainAnalyzePrefix:m}=Ip(),u=Lp(),f=Mp({getEditorView:()=>{var x;return((x=o.value)==null?void 0:x.editorView)??null},connection:t,redisDatabaseIndex:e,fileVariables:n,fieldDefs:a,resultTabs:u,buildExplainAnalyzePrefix:m,beforeExecute:s}),g=df({codeEditorRef:o,fileVariables:n,connection:t,onExecuteStatement:f.executeCurrentStatement,onExplainAnalyzeCurrent:f.onExplainAnalyzeCurrent});return{codeEditorRef:o,currentRawQueryResult:f.currentRawQueryResult,rawResponse:f.rawResponse,queryProcessState:f.queryProcessState,onExecuteCurrent:f.onExecuteCurrent,extensions:g.extensions,sqlCompartment:g.sqlCompartment,cursorInfo:g.cursorInfo,onHandleFormatCode:g.onHandleFormatCode,onHandleFormatCurrentStatement:g.onHandleFormatCurrentStatement,onExplainAnalyzeCurrent:f.onExplainAnalyzeCurrent,explainAnalyzeOptionItems:r,serializeMode:i,toggleExplainOption:l,setSerializeMode:c,reloadSqlCompartment:g.reloadSqlCompartment,cancelStreamingQuery:f.cancelStreamingQuery,executedResults:u.executedResults,activeResultTabId:u.activeResultTabId,setActiveResultTab:u.setActiveResultTab,closeResultTab:u.closeResultTab,closeOtherResultTabs:u.closeOtherResultTabs,closeResultTabsToRight:u.closeResultTabsToRight,updateResultTabView:u.updateResultTabView}}const Da=n=>{const{currentStatements:t}=ra(n);if(!t.length)return null;const e=Math.min(...t.map(o=>o.from)),a=Math.max(...t.map(o=>o.to));return{text:t.map(o=>o.text).join(`
|
|
25
|
+
`),from:e,to:a}};function pf(n){const t=j(!1),e=j(!1),a=()=>{const l=n.getEditorView();if(!l)return;const c=Da(l);c&&navigator.clipboard.writeText(c.text)},s=()=>{const l=n.getEditorView();if(!l)return;const c=l.state.doc.toString();c&&navigator.clipboard.writeText(c)},o=()=>{const l=n.getEditorView();if(!l)return;const c=Da(l);if(!c)return;let m=c.to;const u=l.state.doc.length;for(;m<u;){const p=l.state.sliceDoc(m,m+1);if(p===`
|
|
26
|
+
`||p==="\r"){m++;break}if(p===" "||p===" ")m++;else break}l.dispatch({changes:{from:c.from,to:m,insert:""},annotations:[fr.addToHistory.of(!0)]}),l.focus()};return{contextMenuItems:$(()=>{var m,u;const l=!t.value,c=!e.value;return[{type:ye.ACTION,title:"Execute",icon:"hugeicons:play",shortcut:"⌘↵",select:n.onExecuteCurrent,disabled:l},...(m=n.isExplainSupported)!=null&&m.value?[{type:ye.ACTION,title:"Analyze Query",icon:"hugeicons:analytics-01",shortcut:"⌘E",select:n.onExplainAnalyzeCurrent,disabled:l}]:[],{type:ye.SEPARATOR},...(u=n.isSupportFormat)!=null&&u.value?[{type:ye.ACTION,title:"Format Current",icon:"hugeicons:magic-wand-01",shortcut:"⌘S",select:n.onHandleFormatCurrentStatement,disabled:l},{type:ye.ACTION,title:"Format All",icon:"hugeicons:text-align-left",shortcut:"⇧⌥F",select:n.onHandleFormatCode,disabled:c}]:[],{type:ye.SEPARATOR},{type:ye.ACTION,title:"Copy Statement",icon:"hugeicons:copy-02",select:a,disabled:l},{type:ye.ACTION,title:"Copy All",icon:"hugeicons:copy-01",select:s,disabled:c},{type:ye.SEPARATOR},{type:ye.ACTION,title:"Delete Statement",icon:"hugeicons:delete-02",select:o,disabled:l}]}),onContextMenuOpen:l=>{if(!l)return;const c=n.getEditorView();if(!c){t.value=!1,e.value=!1;return}e.value=c.state.doc.length>0,t.value=!!Da(c)}}}function ff(){const{workspaceId:n,connectionId:t}=vr(),e=_s(),a=hr(),s=gr(),o=a.getFileContentByIdSync(e.params.fileId),r=j((o==null?void 0:o.contents)??""),i=j(""),l=j(""),c=j([]),m=$(()=>{var R;return(R=a==null?void 0:a.flatNodes)==null?void 0:R.find(w=>w.id===e.params.fileId)});ce(()=>{var R;return(R=m.value)==null?void 0:R.variables},R=>{i.value=R||""},{immediate:!0});const u=$(()=>s.getConnectionsByWorkspaceId(n.value)),p=$(()=>u.value.find(R=>R.id===t.value));ce([()=>e.params.fileId,t],()=>{l.value=t.value},{immediate:!0});const f=$(()=>u.value.find(R=>R.id===l.value));return{fieldDefs:c,fileContents:r,fileVariables:i,currentFile:m,selectedConnectionId:l,updateSelectedConnection:R=>{l.value=R},updateFileContent:async R=>{var w;(w=m.value)!=null&&w.id&&(r.value=R,a.updateFileContent({contents:R,id:m.value.id}))},updateFileVariables:async R=>{var w;(w=m.value)!=null&&w.id&&(i.value=R,a.updateFile({id:m.value.id,variables:R}))},connection:f,currentOpenedConnection:p,connectionsByWsId:u,updateFileCursorPos:R=>{var w;(w=m.value)!=null&&w.id&&a.updateFile({id:m.value.id,cursorPos:R})},loadFileContent:async()=>{var w;const{contents:R}=await a.getFileContentById(e.params.fileId);r.value=R,i.value=((w=m.value)==null?void 0:w.variables)||""},isFromCache:o!==null}}const vf=()=>{const n=j(null),{previewRelationBreadcrumbs:t,onOpenBackReferencedTableModal:e,onOpenForwardReferencedTableModal:a,onUpdateSelectedTabInBreadcrumb:s,onClearBreadcrumbs:o,onBackPreviousBreadcrumb:r,onBackPreviousBreadcrumbByIndex:i}=Zr();return{relationRoot:n,previewRelationBreadcrumbs:t,openRelationPreview:(m,u)=>{if(u==null||u==="")return;const{schemaName:p,tableName:f}=m;if(!p||!f)return;n.value={schemaName:p,tableName:f};const g=String(u);if(m.isForeignKey&&m.foreignKey){a({id:g,tableName:m.foreignKey.referenced_table,columnName:m.foreignKey.referenced_column,schemaName:m.foreignKey.referenced_table_schema});return}e({id:g,tableName:f,schemaName:p,columnName:m.sourceColumnName||m.originalName})},clearRelationPreview:()=>{o(),n.value=null},onOpenBackReferencedTableModal:e,onOpenForwardReferencedTableModal:a,onUpdateSelectedTabInBreadcrumb:s,onBackPreviousBreadcrumb:r,onBackPreviousBreadcrumbByIndex:i}},hf=({columns:n,originalRows:t})=>{const e=j([]),a=$(()=>new Map(n.value.map(l=>[l.originalName,l]))),s=l=>{var c,m;return((c=a.value.get(l))==null?void 0:c.short_type_name)||((m=a.value.get(l))==null?void 0:m.type)||""},o=l=>{var w;const{colDef:c,newValue:m,node:u}=l,p=c.field,f=u.rowIndex;if(!p||f===null||f===void 0||!a.value.get(p))return;const x=s(p),v=As(x),_=(w=t.value[f])==null?void 0:w[p],{hasChanged:b,normalizedValue:N}=al({fieldType:x,isObjectColumn:v,oldValue:_,newValue:m}),R=e.value.findIndex(T=>T.rowId===f&&T.fieldId===p);if(!b){R>=0&&(e.value=e.value.filter((T,E)=>E!==R));return}if(R>=0){const T=e.value.slice();T[R]={rowId:f,fieldId:p,newValue:N},e.value=T;return}e.value=[...e.value,{rowId:f,fieldId:p,newValue:N}]},r=()=>{e.value=[]},i=$(()=>e.value.length>0);return{editedCells:e,hasEditedCells:i,onCellValueChanged:o,clearEditedCells:r}},Ca=n=>{const t=new Map;for(const e of n){if(!e.tableName||!e.schemaName)continue;const a=`${e.schemaName}.${e.tableName}`;let s=t.get(a);s||(s={schemaName:e.schemaName,tableName:e.tableName,primaryKeyColumns:[],primaryKeyFields:[]},t.set(a,s)),e.isPrimaryKey&&(s.primaryKeyColumns.push(e),s.primaryKeyFields.push(e.originalName))}return t},lo=({column:n,row:t,tableGroups:e})=>{if(!t||!n.tableName||!n.schemaName||n.isPrimaryKey)return!1;const a=e.get(`${n.schemaName}.${n.tableName}`);return!a||a.primaryKeyFields.length===0?!1:a.primaryKeyFields.every(s=>{const o=t[s];return o!=null})},gf=({column:n,tableGroups:t})=>{if(!n.tableName||!n.schemaName||n.isPrimaryKey)return!1;const e=t.get(`${n.schemaName}.${n.tableName}`);return!!e&&e.primaryKeyFields.length>0},yf=({editedCells:n,columns:t,rows:e,dbType:a})=>{const s=new Map(t.map(c=>[c.originalName,c])),o=Ca(t),r=[],i=new Map;for(const c of n){const m=s.get(c.fieldId),u=e[c.rowId];if(!m||!u){r.push(c);continue}if(!lo({column:m,row:u,tableGroups:o})){r.push(c);continue}const p=`${m.schemaName}.${m.tableName}`,f=o.get(p);if(!f){r.push(c);continue}let g=i.get(p);g||(g={table:f,rows:new Map},i.set(p,g));let x=g.rows.get(c.rowId);x||(x={},g.rows.set(c.rowId,x)),x[m.originalName]=c.newValue}const l=[];for(const[,c]of i){const m={schemaName:c.table.schemaName,tableName:c.table.tableName,pKeys:c.table.primaryKeyFields,updates:[],sqlStatements:[],hasNoPkWarning:!1};for(const[u,p]of c.rows){const f=e[u];if(!f)continue;const g={};for(const _ of c.table.primaryKeyFields)g[_]=f[_];const{sql:x,noPkWarning:v}=Jr({schemaName:c.table.schemaName,tableName:c.table.tableName,pKeys:c.table.primaryKeyFields,pKeyValue:g,update:p,dbType:a});m.updates.push({pKeyValue:g,update:p}),m.sqlStatements.push(x),v&&(m.hasNoPkWarning=!0)}m.updates.length&&l.push(m)}return{groups:l,skipped:r}},xf=({selectedRows:n,columns:t,dbType:e})=>{const a=Ca(t),s=[];for(const[,o]of a){if(!o.primaryKeyFields.length)continue;const r={schemaName:o.schemaName,tableName:o.tableName,pKeys:o.primaryKeyFields,pKeyValues:[],sqlStatements:[],hasNoPkWarning:!1};for(const i of n){if(!o.primaryKeyFields.every(p=>i[p]!==null&&i[p]!==void 0))continue;const c={};for(const p of o.primaryKeyFields)c[p]=i[p];const{sql:m,noPkWarning:u}=ei({schemaName:o.schemaName,tableName:o.tableName,pKeys:o.primaryKeyFields,pKeyValue:c,dbType:e});r.pKeyValues.push(c),r.sqlStatements.push(m),u&&(r.hasNoPkWarning=!0)}r.pKeyValues.length&&s.push(r)}return{groups:s}},bf=({connection:n,columns:t,rows:e,editedCells:a,selectedRows:s,onSaved:o,onDeleted:r})=>{const i=j(!1),l=j(!1),c=j("update"),m=$(()=>{var E;return yf({editedCells:a.value,columns:t.value,rows:e.value,dbType:(E=n.value)==null?void 0:E.type})}),u=$(()=>m.value.groups),p=$(()=>u.value.flatMap(E=>E.sqlStatements).join(`
|
|
27
|
+
`)),f=$(()=>u.value.some(E=>E.hasNoPkWarning)),g=$(()=>u.value.reduce((E,A)=>E+A.updates.length,0)),x=()=>{if(!a.value.length){lt.info("No changes to save.");return}if(!u.value.length){lt.warning("No safely updatable rows detected. Edits target columns that lack primary keys in the result.");return}c.value="update",i.value=!0},v=$(()=>{var E;return xf({selectedRows:s.value,columns:t.value,dbType:(E=n.value)==null?void 0:E.type})}),_=$(()=>v.value.groups),b=$(()=>_.value.some(E=>E.hasNoPkWarning)),N=$(()=>_.value.reduce((E,A)=>E+A.pKeyValues.length,0)),R=()=>{if(!s.value.length){lt.info("No rows selected for deletion.");return}if(!_.value.length){lt.warning("Selected rows cannot be safely deleted — columns lack primary-key metadata.");return}c.value="delete",i.value=!0},w=()=>{i.value=!1},T=async()=>{var A;if(!n.value){lt.error("No active connection.");return}l.value=!0;const E=yr(n.value);try{if(c.value==="update"){const F=u.value.map(P=>$fetch("/api/tables/bulk-update",{method:"POST",body:{tableName:P.tableName,schemaName:P.schemaName,pKeys:P.pKeys,updates:P.updates,...E}}));await Promise.all(F),lt.success(`Saved ${g.value} row${g.value===1?"":"s"} successfully.`),i.value=!1,o()}else{const F=_.value.map(P=>$fetch("/api/tables/bulk-delete",{method:"POST",body:{tableName:P.tableName,schemaName:P.schemaName,pKeys:P.pKeys,pKeyValues:P.pKeyValues,...E}}));await Promise.all(F),lt.success(`Deleted ${N.value} row${N.value===1?"":"s"} successfully.`),i.value=!1,r()}}catch(F){const P=((A=F==null?void 0:F.data)==null?void 0:A.message)||(F==null?void 0:F.message)||"Unknown error while executing.";console.error("Raw query mutation failed:",F),lt.error(P)}finally{l.value=!1}};return{isPreviewOpen:i,isMutating:l,pendingAction:c,previewGroups:u,previewSql:p,hasNoPkWarning:f,totalUpdateCount:g,skippedEdits:$(()=>m.value.skipped),requestSave:x,deleteGroups:_,deleteHasNoPkWarning:b,totalDeleteCount:N,requestDelete:R,cancelPreview:w,confirmAndExecute:T}},Sf=(n,t)=>{if(!n.tableName||!n.schemaName)return!1;const e=n.sourceColumnName||n.originalName;return t.some(a=>{var s;return a.schema===n.schemaName&&a.table===n.tableName&&((s=a.used_by)==null?void 0:s.some(o=>o.referenced_column===e))})},Cf=(n,t)=>!n.tableName||!n.schemaName?!1:n.isForeignKey&&n.foreignKey?!0:Sf(n,t),wf=10,_f=({columns:n,rows:t,reservedTables:e,isEditingEnabled:a,dirtyTracker:s,onOpenRelationPreview:o})=>{if(!n.length)return[];const r=Ca(n),i=t.slice(0,wf),l=[nl()];for(const c of n){const m=Cf(c,e),u=a&&gf({column:c,tableGroups:r}),p=sl({headerName:c.aliasFieldName,rows:i,field:c.originalName,isKey:m||c.isPrimaryKey}),f=u?x=>lo({column:c,row:x.data,tableGroups:r}):!1,g=x=>{const v=x.colDef.field??"";if(!v)return;const _=Number(x.node.id??x.node.rowIndex),b=u&&s.cells.some(R=>R.rowId===_&&R.fieldId===v),N={backgroundColor:"unset"};return b?(N.backgroundColor="var(--color-orange-200)",N):(x.value===null&&(N.color="var(--muted-foreground)"),N)};l.push({headerName:c.aliasFieldName,field:c.originalName,colId:c.originalName,filter:!0,resizable:!0,sortable:!0,type:"editableColumn",editable:f,cellStyle:g,cellEditorSelector:x=>{var b;const v=(b=x.data)==null?void 0:b[c.originalName],_=c.short_type_name||c.type||"";if(ai(_)||typeof v=="object"&&v!==null)return{component:"AgJsonCellEditor",popup:!0,popupPosition:"under"}},valueSetter:x=>{const v=c.short_type_name||c.type||"";return il({params:x,fieldId:c.originalName,isObjectColumn:As(v),emptyAsNull:!0})},headerComponentParams:{innerHeaderComponent:rl,isPrimaryKey:c.isPrimaryKey,isForeignKey:c.isForeignKey},cellRenderer:m?ti:void 0,cellRendererParams:m?{isPrimaryKey:!0,onOpenPreviewReverseTableModal:x=>o(c,x)}:void 0,valueFormatter:ol,width:p})}return l},fn={SELECT:"DML",INSERT:"DML",UPDATE:"DML",DELETE:"DML",MERGE:"DML",VALUES:"DML",TRUNCATE:"DML",COPY:"DML",CREATE:"DDL",ALTER:"DDL",DROP:"DDL",COMMENT:"DDL",ANALYZE:"DDL",VACUUM:"DDL",REINDEX:"DDL",CLUSTER:"DDL","REFRESH MATERIALIZED VIEW":"DDL","IMPORT FOREIGN SCHEMA":"DDL","SECURITY LABEL":"DDL",GRANT:"DCL",REVOKE:"DCL",BEGIN:"TCL",COMMIT:"TCL",ROLLBACK:"TCL",SAVEPOINT:"TCL","RELEASE SAVEPOINT":"TCL","ROLLBACK TO SAVEPOINT":"TCL","PREPARE TRANSACTION":"TCL","COMMIT PREPARED":"TCL","ROLLBACK PREPARED":"TCL","SET TRANSACTION":"TCL",SET:"SYSTEM",SHOW:"SYSTEM",RESET:"SYSTEM",DISCARD:"SYSTEM",EXPLAIN:"SYSTEM",LOAD:"SYSTEM",LOCK:"SYSTEM",MOVE:"SYSTEM",FETCH:"SYSTEM",CLOSE:"SYSTEM",DECLARE:"SYSTEM",DEALLOCATE:"SYSTEM",PREPARE:"SYSTEM",EXECUTE:"SYSTEM",LISTEN:"SYSTEM",UNLISTEN:"SYSTEM",NOTIFY:"SYSTEM",DO:"SYSTEM",ABORT:"SYSTEM",CHECKPOINT:"SYSTEM"},Rf=Object.keys(fn).sort((n,t)=>t.length-n.length),uo=n=>{if(!n)return"";const t=n.toUpperCase().trim().replace(/;$/,"");for(const e of Rf)if(t===e||t.startsWith(`${e} `))return e;return t.split(/\s+/)[0]||t},Tf=n=>{if(!n)return!1;const t=n.toUpperCase().trim(),e=uo(t);if(["SELECT","VALUES","SHOW","EXPLAIN","TABLE"].includes(e))return!1;const s=fn[e];return!!(["INSERT","UPDATE","DELETE","TRUNCATE","COPY","MERGE","CALL","DO"].includes(e)||s==="DDL"||s==="DCL"||["SET","RESET","GRANT","REVOKE","COMMENT","ANALYZE","VACUUM","REINDEX","CLUSTER"].includes(e)||["CREATE","DROP","ALTER"].includes(e))},Ef=(n,t)=>{const e=n||"Query",a=t??0;return["INSERT","UPDATE","DELETE"].includes(e.toUpperCase())?`${e} successful. ${a} rows affected.`:`${e} successful.`};class At{constructor(t,e){we(this,"cmd");we(this,"commandKey");we(this,"rowCount");this.cmd=(t||"").toUpperCase().trim(),this.commandKey=uo(this.cmd),this.rowCount=e}isMutation(){return Tf(this.cmd)}getMessage(t){return t?Ef(this.cmd,this.rowCount):""}getCategory(){return fn[this.commandKey]??"UNKNOWN"}build(){const t=this.isMutation();return{isMutation:t,message:this.getMessage(t),category:this.getCategory()}}}class Nf extends At{isMutation(){return["VACUUM","ANALYZE","REINDEX","CLUSTER"].includes(this.commandKey)?!0:super.isMutation()}}class Xa extends At{isMutation(){return this.commandKey==="OPTIMIZE"?!0:super.isMutation()}getMessage(t){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":super.getMessage(t)}}class Af extends Xa{}class co extends At{isMutation(){return this.commandKey==="TRUNCATE"?!0:super.isMutation()}getMessage(t){return this.commandKey==="INSERT"?`INSERT successful. ${this.rowCount} row(s) affected.`:super.getMessage(t)}}class Mf extends co{}class fs extends At{}class If extends At{getMessage(t){return this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}class Lf extends At{getMessage(t){return this.commandKey==="TRUNCATE"?"TRUNCATE successful.":this.commandKey==="MERGE"?`MERGE successful. ${this.rowCount} rows affected.`:super.getMessage(t)}}const kf={[oe.POSTGRES]:Nf,[oe.MARIADB]:Xa,[oe.MYSQL]:Xa,[oe.MYSQL2]:Af,[oe.REDIS]:fs,[oe.SQLITE3]:co,[oe.SNOWFLAKE]:fs,[oe.BETTER_SQLITE3]:Mf,[oe.MSSQL]:If,[oe.ORACLE]:Lf},zf=(n,t=0,e=oe.POSTGRES)=>{const a=kf[e];if(!a)throw new Error(`Unsupported database client type: "${e}"`);return new a(n,t).build()},$f=se({__name:"RawQueryContextMenu",props:{cellContextMenu:{},cellHeaderContextMenu:{},data:{},selectedRows:{},tableName:{},schemaName:{}},emits:["onClearContextMenu"],setup(n,{emit:t}){const e=t;return(a,s)=>(S(),D(ll,{"cell-context-menu":a.cellContextMenu,"cell-header-context-menu":a.cellHeaderContextMenu,data:a.data,"selected-rows":a.selectedRows,"table-name":a.tableName,"schema-name":a.schemaName,"enable-copy-as-sql":"",onOnClearContextMenu:s[0]||(s[0]=o=>e("onClearContextMenu"))},{default:y(()=>[Ke(a.$slots,"default")]),_:3},8,["cell-context-menu","cell-header-context-menu","data","selected-rows","table-name","schema-name"]))}}),Of={class:"w-full select-none h-9 flex items-center justify-between px-1"},Vf={class:"flex items-center gap-1"},Pf={class:"absolute -right-1.5 -top-1.5 min-w-4 rounded-full bg-green-700 px-1 text-xxs font-medium leading-4 text-white"},Df={class:"flex items-center gap-2"},Ff={class:"flex items-center gap-2"},Bf={key:3,class:"font-normal text-xs text-primary/60"},Hf={key:4,class:"font-normal text-sm text-primary"},qf={class:"flex items-center gap-2"},Uf={class:"flex items-center gap-1"},Kf=se({__name:"RawQueryResultControlBar",props:{pendingCount:{},isMutating:{type:Boolean},isEditingEnabled:{type:Boolean},totalSelectedRows:{}},emits:["save","discard","delete","download"],setup(n,{emit:t}){const e=t;return(a,s)=>{const o=be;return S(),k("div",Of,[C("div",Vf,[a.isEditingEnabled?(S(),k(ae,{key:0},[a.pendingCount>0?(S(),D(d(Pe),{key:0},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"relative overflow-visible font-normal",disabled:a.isMutating,onClick:s[0]||(s[0]=r=>e("save"))},{default:y(()=>[a.isMutating?(S(),D(o,{key:0,name:"lucide:loader-circle",class:"animate-spin"})):(S(),D(o,{key:1,name:"lucide:save"})),C("span",Pf,U(a.pendingCount),1),h(d(vt),null,{default:y(()=>s[6]||(s[6]=[z("⌘S")])),_:1})]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>[C("p",Df,[s[8]||(s[8]=z(" Preview & execute UPDATE statements ")),h(d(vt),null,{default:y(()=>s[7]||(s[7]=[z("⌘S")])),_:1})])]),_:1})]),_:1})):K("",!0),a.pendingCount>0?(S(),D(d(Pe),{key:1},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"font-normal",disabled:a.isMutating,onClick:s[1]||(s[1]=r=>e("discard"))},{default:y(()=>[h(o,{name:"hugeicons:undo-02"}),s[9]||(s[9]=z(" Discard "))]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>s[10]||(s[10]=[C("p",null,"Discard pending edits",-1)])),_:1})]),_:1})):K("",!0),a.totalSelectedRows>0?(S(),D(d(Pe),{key:2},{default:y(()=>[h(d(Oe),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",disabled:a.isMutating,onClick:s[2]||(s[2]=r=>e("delete"))},{default:y(()=>[h(o,{name:"lucide:trash"}),h(d(vt),null,{default:y(()=>s[11]||(s[11]=[z("⌥⌘⌫")])),_:1})]),_:1},8,["disabled"])]),_:1}),h(d(Ve),null,{default:y(()=>[C("p",Ff,[z(" Delete "+U(a.totalSelectedRows)+" selected row"+U(a.totalSelectedRows===1?"":"s")+" ",1),h(d(vt),null,{default:y(()=>s[12]||(s[12]=[z("⌥⌘⌫")])),_:1})])]),_:1})]),_:1})):K("",!0),a.totalSelectedRows>0?(S(),k("p",Bf," Selected ")):K("",!0),a.totalSelectedRows>0?(S(),k("p",Hf,U(a.totalSelectedRows),1)):K("",!0)],64)):K("",!0)]),C("div",qf,[C("div",Uf,[a.isEditingEnabled?(S(),k(ae,{key:0},[h(o,{name:"hugeicons:pencil-edit-02",class:"size-3.5 text-muted-foreground"}),s[13]||(s[13]=C("span",{class:"font-normal text-xs text-primary/60"},"Editable",-1))],64)):(S(),k(ae,{key:1},[h(o,{name:"hugeicons:lock-01",class:"size-3.5 text-muted-foreground"}),s[14]||(s[14]=C("span",{class:"font-normal text-xs text-primary/60"},"Read-only",-1))],64))]),h(d(Ba),null,{default:y(()=>[h(d(Ha),{"as-child":""},{default:y(()=>[h(d(Le),{variant:"outline",size:"xxs",class:"font-normal flex items-center gap-1 cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:download-04",class:"size-3.5"}),s[15]||(s[15]=C("span",null,"Export",-1))]),_:1})]),_:1}),h(d(qa),{align:"end",class:"w-36"},{default:y(()=>[h(d(Vt),{onClick:s[3]||(s[3]=r=>e("download","csv")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:file-01",class:"mr-2 size-3.5"}),s[16]||(s[16]=z(" Export CSV "))]),_:1}),h(d(Vt),{onClick:s[4]||(s[4]=r=>e("download","json")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:code",class:"mr-2 size-3.5"}),s[17]||(s[17]=z(" Export JSON "))]),_:1}),h(d(Vt),{onClick:s[5]||(s[5]=r=>e("download","text")),class:"text-xs cursor-pointer"},{default:y(()=>[h(o,{name:"hugeicons:file-01",class:"mr-2 size-3.5"}),s[18]||(s[18]=z(" Export TSV "))]),_:1})]),_:1})]),_:1})])])}}}),Gf=se({__name:"RawQueryUpdatePreviewDialog",props:{open:{type:Boolean},action:{},updateGroups:{},totalUpdates:{},updateHasNoPkWarning:{type:Boolean},deleteGroups:{},totalDeletes:{},deleteHasNoPkWarning:{type:Boolean},isMutating:{type:Boolean}},emits:["confirm","cancel"],setup(n,{emit:t}){const e=n,a=t,s=$(()=>e.action==="delete"),o=$(()=>s.value?e.deleteHasNoPkWarning??!1:e.updateHasNoPkWarning??!1),r=$(()=>o.value?s.value?"High-Risk: Confirm Delete":"High-Risk: Confirm Save":s.value?"Confirm Delete":"Confirm Save"),i=$(()=>o.value?"Caution: No primary key detected. To identify the record, this operation will match all columns in the WHERE clause. This carries a risk of affecting multiple rows if they share identical data. Please verify the SQL below carefully before proceeding:":s.value?"The following SQL will be executed to delete the selected rows:":"The following SQL will be executed to save your changes:"),l=$(()=>s.value?"Delete":"Save"),c=$(()=>{const p=s.value?e.deleteGroups??[]:e.updateGroups??[];return p.length===0?"":p.map(f=>`${`-- ${f.schemaName}.${f.tableName}`}
|
|
28
|
+
${f.sqlStatements.join(`
|
|
29
|
+
`)}`).join(`
|
|
30
|
+
|
|
31
|
+
`)}),m=()=>{a("confirm")},u=()=>{a("cancel")};return(p,f)=>{const g=be;return S(),D(d(xr),{open:p.open,"onUpdate:open":f[0]||(f[0]=x=>!x&&!p.isMutating&&a("cancel"))},{default:y(()=>[h(d(br),{size:"preview"},{default:y(()=>[h(d(ln),{visible:!!p.isMutating},null,8,["visible"]),h(d(Sr),null,{default:y(()=>[h(d(Cr),{class:xe(["flex items-center gap-2 text-base font-medium",{"text-destructive":d(o)||d(s)}])},{default:y(()=>[d(o)||d(s)?(S(),D(g,{key:0,name:d(o)?"lucide:alert-triangle":"lucide:trash-2",class:xe(["size-5",(d(o),"text-destructive")])},null,8,["name","class"])):K("",!0),z(" "+U(d(r)),1)]),_:1},8,["class"]),h(d(wr),{class:xe({"text-destructive font-normal":d(o)})},{default:y(()=>[z(U(d(i)),1)]),_:1},8,["class"])]),_:1}),h(d(xa),{code:d(c),language:"sql","show-copy-button":"","max-height":"24rem"},null,8,["code"]),h(d(_r),null,{default:y(()=>[h(d(Rr),{class:"border font-normal",onClick:u},{default:y(()=>f[1]||(f[1]=[z(" Cancel ")])),_:1}),h(d(Tr),{class:xe(["border font-normal flex gap-1",{"bg-destructive text-destructive-foreground hover:bg-destructive/90":d(s)}]),onClick:m},{default:y(()=>[h(g,{name:d(s)?"lucide:trash-2":"lucide:save",class:"size-4"},null,8,["name"]),z(" "+U(d(l)),1)]),_:1},8,["class"])]),_:1})]),_:1})]),_:1},8,["open"])}}}),Wf=se({__name:"ResultTabResultView",props:{activeTab:{},activeTabColumns:{},formattedData:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},setup(n){const t=n,e=j(),a=j(),s=rn(),{reservedSchemas:o}=ga(s),r=j([]),i=X=>{r.value=X},l=X=>{const ge=t.formattedData,ct=new Date().toISOString().slice(0,19).replace(/:/g,"-"),tt=`query_result_tab_${t.activeTab.seqIndex}_${ct}`,qt={csv:ta.CSV_WITH_HEADER,json:ta.JSON,text:ta.TSV};dl(ge,`query_result_tab_${t.activeTab.seqIndex}`,qt[X],"all",void 0,tt)},c=$(()=>{var X;return zf(t.activeTab.metadata.command||"",t.activeTab.metadata.rowCount||0,(X=t.activeTab.metadata.connection)==null?void 0:X.type)}),m=$(()=>c.value.isMutation),u=$(()=>c.value.message),p=$(()=>t.activeTabColumns.length>0),f=$(()=>t.activeTab.result.length===0&&!p.value&&!t.executeLoading&&!t.isStreaming),g=$(()=>{var ge;const X=(ge=t.activeTab.metadata.connection)==null?void 0:ge.id;return X?o.value[X]||[]:[]}),x=$(()=>Ca(t.activeTabColumns)),v=$(()=>{if(t.isStreaming)return!1;for(const[,X]of x.value)if(X.primaryKeyFields.length>0)return!0;return!1}),_=X=>X.map(ge=>({...ge})),b=X=>ul(X),N=X=>X.map(ge=>{const{[ml]:ct,...tt}=ge;return{...tt}}),R=(...X)=>{const ge=new Map;for(const ct of X)for(const tt of ct)ge.set(`${tt.rowId}:${tt.fieldId}`,tt);return[...ge.values()]},w=$(()=>t.activeTabColumns),T=$(()=>t.formattedData||[]),E=j(_(T.value)),A=j(b(E.value)),F=j([]),{editedCells:P,onCellValueChanged:L,clearEditedCells:I}=hf({columns:w,originalRows:E});function W(){var X,ge;(ge=(X=e.value)==null?void 0:X.gridApi)==null||ge.refreshCells({force:!0})}const Z=$(()=>R(F.value,P.value)),re=()=>{A.value=b(E.value)},le=()=>{P.value.slice().length&&(E.value=N(A.value),F.value=[],I())},de=()=>{I(),re(),W()};ce([T,()=>t.activeTab.id],([X])=>{E.value=_(X),F.value=[],I(),re()});const me={cells:[]};ce(Z,X=>{me.cells=X,W()},{immediate:!0});const Fe=$(()=>t.activeTab.metadata.connection),ze=$(()=>r.value),{isPreviewOpen:st,isMutating:ve,pendingAction:Je,previewGroups:Ge,hasNoPkWarning:he,totalUpdateCount:ot,requestSave:M,deleteGroups:V,deleteHasNoPkWarning:H,totalDeleteCount:B,requestDelete:q,cancelPreview:O,confirmAndExecute:Q}=bf({connection:Fe,columns:w,rows:E,editedCells:P,selectedRows:ze,onSaved:le,onDeleted:()=>{r.value=[]}}),{relationRoot:J,previewRelationBreadcrumbs:ie,openRelationPreview:Be,clearRelationPreview:rt,onOpenBackReferencedTableModal:ut,onOpenForwardReferencedTableModal:Mt,onUpdateSelectedTabInBreadcrumb:te,onBackPreviousBreadcrumb:Ne,onBackPreviousBreadcrumbByIndex:et}=vf(),it=$(()=>_f({columns:t.activeTabColumns,rows:E.value,reservedTables:g.value,isEditingEnabled:v.value,dirtyTracker:me,onOpenRelationPreview:Be}));return Rs([{key:"meta+s",callback:()=>{!v.value||ve.value||M()},isPreventDefault:!0},{key:"meta+alt+backspace",callback:()=>{!v.value||ve.value||q()},isPreventDefault:!0}],{target:a}),(X,ge)=>{var qt,vn,hn,gn;const ct=Bt,tt=Bs;return S(),k("div",{ref_key:"containerRef",ref:a,class:"h-full w-full flex flex-col"},[d(J)&&d(ie).length?(S(),D(ni,{key:0,open:d(ie).length>0,breadcrumbs:d(ie),currentTableName:d(J).tableName,connectionId:((qt=X.activeTab.metadata.connection)==null?void 0:qt.id)||"",workspaceId:((vn=X.activeTab.metadata.connection)==null?void 0:vn.workspaceId)||"",rootSchemaName:d(J).schemaName,onClearBreadcrumb:d(rt),onOnOpenBackReferencedTableModal:d(ut),onOnOpenForwardReferencedTableModal:d(Mt),onOnUpdateSelectedTabInBreadcrumb:d(te),onOnBackPreviousBreadcrumb:d(Ne),onOnBackPreviousBreadcrumbByIndex:d(et)},null,8,["open","breadcrumbs","currentTableName","connectionId","workspaceId","rootSchemaName","onClearBreadcrumb","onOnOpenBackReferencedTableModal","onOnOpenForwardReferencedTableModal","onOnUpdateSelectedTabInBreadcrumb","onOnBackPreviousBreadcrumb","onOnBackPreviousBreadcrumbByIndex"])):K("",!0),h(Gf,{open:d(st),action:d(Je),"update-groups":d(Ge),"total-updates":d(ot),"update-has-no-pk-warning":d(he),"delete-groups":d(V),"total-deletes":d(B),"delete-has-no-pk-warning":d(H),"is-mutating":d(ve),onConfirm:d(Q),onCancel:d(O)},null,8,["open","action","update-groups","total-updates","update-has-no-pk-warning","delete-groups","total-deletes","delete-has-no-pk-warning","is-mutating","onConfirm","onCancel"]),X.activeTab.result.length===0&&d(m)&&!X.executeLoading&&!X.isStreaming?(S(),D(ct,{key:1,desc:d(u),hiddenIcon:"",class:"h-full"},null,8,["desc"])):d(f)?(S(),D(ct,{key:2,title:"No Results",desc:"The query returned no records.",class:"h-full"})):(S(),k(ae,{key:3},[d(A).length?(S(),D(Kf,{key:0,"pending-count":d(P).length,"is-mutating":d(ve),"is-editing-enabled":d(v),"total-selected-rows":d(r).length,onSave:d(M),onDiscard:de,onDelete:d(q),onDownload:l},null,8,["pending-count","is-mutating","is-editing-enabled","total-selected-rows","onSave","onDelete"])):K("",!0),h($f,{data:X.formattedData||[],selectedRows:d(r),cellContextMenu:(hn=d(e))==null?void 0:hn.cellContextMenu,cellHeaderContextMenu:(gn=d(e))==null?void 0:gn.cellHeaderContextMenu,onOnClearContextMenu:ge[0]||(ge[0]=mv=>{var yn;return(yn=d(e))==null?void 0:yn.clearCellContextMenu()}),class:"flex-1 min-h-0"},{default:y(()=>[h(tt,{ref_key:"rawQueryTableRef",ref:e,"column-defs":d(it),"row-data":d(A),"selected-rows":d(r),"enable-simple-copy-context-menu":!1,"empty-title":"No Results","empty-description":"The query returned no records.",class:"h-full","allow-editing":d(v),"suppress-scroll-on-new-data":!0,onSelectionChanged:i,onCellValueChanged:d(L)},null,8,["column-defs","row-data","selected-rows","allow-editing","onCellValueChanged"])]),_:1},8,["data","selectedRows","cellContextMenu","cellHeaderContextMenu"])],64))],512)}}}),jf={key:0,class:"flex mt-7 [writing-mode:vertical-rl]"},Qf=["onClick"],Yf={class:"h-full w-full flex flex-col min-w-0"},Xf={class:"flex items-end justify-between flex-shrink-0 w-full"},Zf={class:"flex items-end overflow-x-auto pt-0.5 flex-1 min-w-0 pr-4"},Jf=["onClick","onContextmenu"],ev={class:"truncate text-xs font-medium"},tv=["onClick"],av={class:"flex items-center gap-1.5 px-2 pb-1.5 flex-shrink-0"},nv={class:"h-full w-full border rounded-md rounded-tl-none overflow-hidden"},sv=se({__name:"RawQueryResultTabs",props:{executedResults:{},activeTabId:{},executeLoading:{type:Boolean},isStreaming:{type:Boolean}},emits:["update:activeTab","close-tab","close-other-tabs","close-tabs-to-right","update:view"],setup(n,{emit:t}){const e=n,a=rn(),{schemas:s}=ga(a),o=t,r=j(null),i=j(!1),l=R=>{R.key==="Escape"&&i.value&&(i.value=!1)},c=$(()=>{if(!r.value)return!1;const R=Array.from(e.executedResults.keys()),w=R.indexOf(r.value);return w>=0&&w<R.length-1}),m=[{value:ee.RESULT,label:"Result"},{value:ee.EXPLAIN,label:"Explain"},{value:ee.RAW,label:"Raw"},{value:ee.INFO,label:"Info"},{value:ee.CHART,label:"Chart"},{value:ee.ERROR,label:"Errors"}],u=new Map,p=at([]);let f=null;const g=$(()=>e.activeTabId&&e.executedResults.get(e.activeTabId)||null);ce(()=>{var R;return(R=g.value)==null?void 0:R.metadata.connection},async R=>{var w;if(R)try{(w=s.value[R.id])!=null&&w.length||await a.fetchSchemas({connectionId:R.id,workspaceId:R.workspaceId,connection:R}),await a.fetchReservedSchemas({connectionId:R.id,connection:R})}catch(T){console.error("[RawQueryResultTabs] Failed to load schema metadata",T)}},{immediate:!0});const x=$(()=>{var R;return((R=g.value)==null?void 0:R.view)||ee.RESULT}),v=$(()=>{var w,T;if(!((w=g.value)!=null&&w.metadata.fieldDefs))return[];const R=(T=g.value.metadata.connection)==null?void 0:T.id;return jm({fieldDefs:g.value.metadata.fieldDefs,statementQuery:g.value.metadata.statementQuery,schemas:R?s.value[R]||[]:[],getTableInfoById:a.getTableInfoById})}),_=R=>{var F;const w=((F=R.result)==null?void 0:F.length)||0,T=`${R.id}_${w}`;if(u.has(T))return u.get(T);const E=R.metadata.fieldDefs||[],A=Ym(R.result||[],E);u.set(T,A);for(const P of u.keys())P.startsWith(`${R.id}_`)&&P!==T&&u.delete(P);return A};ce(g,R=>{f&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{p.value=R?_(R):[],f=null})},{immediate:!0}),ha(()=>{window.addEventListener("keydown",l)}),Er(()=>{window.removeEventListener("keydown",l),f&&cancelAnimationFrame(f)});const b=R=>{e.activeTabId&&o("update:view",e.activeTabId,R)},N=R=>!!R.metadata.executeErrors;return(R,w)=>{const T=be,E=Oe,A=Ve,F=Pe,P=ln,L=Bt;return S(),k("div",{class:xe(d(_t)("h-full flex w-full bg-background transition-all duration-200",d(i)?"fixed inset-0 z-[999] pt-10 px-0 pb-0":""))},[d(g)?(S(),k("div",jf,[(S(),k(ae,null,ue(m,I=>C("div",{key:I.value,onClick:W=>N(d(g))&&(I.value===d(ee).RESULT||I.value===d(ee).RAW||I.value===d(ee).CHART)||I.value===d(ee).ERROR&&!N(d(g))?null:b(I.value),class:xe(d(_t)("border px-1 text-xs font-normal transition-colors",d(x)===I.value?"bg-muted border-transparent border-r-border":"border-transparent",I.value===d(ee).ERROR&&N(d(g))?"hover:bg-muted cursor-pointer":I.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?null:"",I.value===d(ee).ERROR&&!N(d(g))?"opacity-40 cursor-not-allowed":"",(I.value===d(ee).RESULT||I.value===d(ee).RAW||I.value===d(ee).CHART)&&N(d(g))?"opacity-40 cursor-not-allowed":"",I.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?"opacity-40 cursor-not-allowed":"",I.value===d(ee).ERROR&&!N(d(g))||(I.value===d(ee).RESULT||I.value===d(ee).RAW||I.value===d(ee).CHART)&&N(d(g))||I.value===d(ee).EXPLAIN&&!d(g).metadata.statementQuery.startsWith("EXPLAIN")?"":"hover:bg-muted cursor-pointer"))},U(I.label),11,Qf)),64))])):K("",!0),C("div",Yf,[C("div",Xf,[C("div",Zf,[h(d(Ts),null,{default:y(()=>[h(d(Es),{class:"flex items-end"},{default:y(()=>[(S(!0),k(ae,null,ue(R.executedResults,([I,W])=>(S(),D(F,{key:I},{default:y(()=>[h(E,{"as-child":""},{default:y(()=>[C("div",{onClick:Z=>R.$emit("update:activeTab",I),onContextmenu:Z=>r.value=I,class:xe(d(_t)("h-6! flex gap-0.5 rounded-t-md max-w-44 justify-start! items-center font-normal p-1! hover:[&>div]:opacity-100 transition-all duration-200 border rounded-b-none cursor-pointer relative",I===R.activeTabId?"border-b-transparent bg-background dark:bg-accent":"border-transparent bg-muted/30"))},[h(T,{name:N(W)?"hugeicons:alert-02":"hugeicons:sql",class:xe(d(_t)("min-w-4",N(W)?"text-red-500":""))},null,8,["name","class"]),C("div",ev," Query "+U(W.seqIndex)+" - "+U(W.metadata.statementQuery),1),C("div",{onClick:nn(Z=>R.$emit("close-tab",I),["stop"]),class:"hover:bg-accent h-5 w-5 flex items-center justify-center rounded-full opacity-0"},[h(T,{name:"lucide:x",class:"stroke-[2.5]! size-3!"})],8,tv)],42,Jf)]),_:2},1024),h(A,{class:"max-w-xl"},{default:y(()=>[C("p",null,U(W.metadata.statementQuery),1)]),_:2},1024)]),_:2},1024))),128))]),_:1}),d(r)?(S(),D(d(Ns),{key:0,hideWhenDetached:"",class:"w-56"},{default:y(()=>[h(d(Jt),{onSelect:w[0]||(w[0]=I=>R.$emit("close-tab",d(r)))},{default:y(()=>w[5]||(w[5]=[z(" Close ")])),_:1}),h(d(Jt),{onSelect:w[1]||(w[1]=I=>R.$emit("close-other-tabs",d(r)))},{default:y(()=>w[6]||(w[6]=[z(" Close Others ")])),_:1}),h(d(Jt),{disabled:!d(c),onSelect:w[2]||(w[2]=I=>R.$emit("close-tabs-to-right",d(r)))},{default:y(()=>w[7]||(w[7]=[z(" Close to the Right ")])),_:1},8,["disabled"])]),_:1})):K("",!0)]),_:1})]),C("div",av,[h(F,null,{default:y(()=>[h(E,{"as-child":""},{default:y(()=>[h(d(Le),{onClick:w[3]||(w[3]=I=>i.value=!d(i)),variant:d(i)?"secondary":"ghost",size:"icon",class:"size-5 rounded border border-border cursor-pointer"},{default:y(()=>[h(T,{name:"hugeicons:full-screen",class:"size-3.5!"})]),_:1},8,["variant"])]),_:1}),h(A,{align:"end",side:"top"},{default:y(()=>[z(U(d(i)?"Zoom In (Restore Normal)":"Zoom Out (Full Screen)"),1)]),_:1})]),_:1})])]),C("div",nv,[R.executeLoading&&R.activeTabId?(S(),D(P,{key:0,visible:""})):K("",!0),d(g)?d(g)&&d(x)===d(ee).RESULT?(S(),D(Wf,{"active-tab":d(g),"active-tab-columns":d(v),"formatted-data":d(p),"execute-loading":R.executeLoading,"is-streaming":R.isStreaming,key:d(g).id},null,8,["active-tab","active-tab-columns","formatted-data","execute-loading","is-streaming"])):d(g)&&d(x)===d(ee).EXPLAIN?(S(),D(d(Lm),{key:3,"active-tab":d(g)},null,8,["active-tab"])):d(g)&&d(x)===d(ee).RAW?(S(),D(Ep,{key:4,"formatted-data":d(p),"execute-loading":R.executeLoading,"is-streaming":R.isStreaming},null,8,["formatted-data","execute-loading","is-streaming"])):d(g)&&d(x)===d(ee).CHART?(S(),D(d(vd),{key:5,"active-tab":d(g),"active-tab-columns":d(v),"formatted-data":d(p)},null,8,["active-tab","active-tab-columns","formatted-data"])):d(g)&&d(x)===d(ee).INFO?(S(),D(Rp,{key:6,"active-tab":d(g)},null,8,["active-tab"])):d(g)&&d(x)===d(ee).ERROR?(S(),D(ip,{key:7,"active-tab":d(g),onOnChangeView:w[4]||(w[4]=I=>b(I))},null,8,["active-tab"])):K("",!0):(S(),D(L,{key:1,title:"No results",desc:"Execute a query to see results"}))])])],2)}}}),ov={class:"flex flex-col h-full p-1"},rv={class:"flex flex-col h-full border rounded-md"},iv={class:"h-full flex flex-col overflow-y-auto"},lv={class:"flex flex-col h-full border rounded-md bg-muted"},uv={class:"flex items-center gap-1 font-normal text-sm px-2 py-1"},cv={class:"h-full flex flex-col overflow-y-auto"},dv=se({__name:"RawQuery",props:{isSupportVariable:{type:Boolean,default:!0}},setup(n){const t=n,e=_s(),a=$(()=>{const te=e.params.workspaceId;return Array.isArray(te)?te[0]??"":te??""}),s=Ss(),o=Nr(),r=ff(),{connection:i,currentFile:l,currentOpenedConnection:c,fileContents:m,fileVariables:u,selectedConnectionId:p,updateSelectedConnection:f,updateFileContent:g,updateFileVariables:x,connectionsByWsId:v,fieldDefs:_}=r,b=$(()=>{var te;return((te=i.value)==null?void 0:te.type)===oe.REDIS}),N=$(()=>!b.value),R=$(()=>{var te;return[oe.SQLITE3,oe.BETTER_SQLITE3].includes((te=i.value)==null?void 0:te.type)}),w=$(()=>t.isSupportVariable&&!b.value&&!R.value),T=$(()=>{var te;return((te=i.value)==null?void 0:te.type)===oe.POSTGRES}),E=j("");Ar(()=>{E.value=w.value?u.value:""});const A=$(()=>b.value?i.value:void 0),F=Lr({connection:A,mode:"meta"}),P=te=>{F.selectedDatabaseIndex.value=te},L=mf({connection:i,redisDatabaseIndex:F.selectedDatabaseIndex,fieldDefs:_,fileVariables:E,beforeExecute:()=>J()}),{cursorInfo:I,extensions:W,codeEditorRef:Z,onExecuteCurrent:re,onHandleFormatCode:le,onHandleFormatCurrentStatement:de,onExplainAnalyzeCurrent:me,explainAnalyzeOptionItems:Fe,serializeMode:ze,currentRawQueryResult:st,queryProcessState:ve,executedResults:Je,activeResultTabId:Ge}=L,{contextMenuItems:he,onContextMenuOpen:ot}=pf({onExecuteCurrent:L.onExecuteCurrent,onExplainAnalyzeCurrent:L.onExplainAnalyzeCurrent,onHandleFormatCurrentStatement:L.onHandleFormatCurrentStatement,onHandleFormatCode:L.onHandleFormatCode,isSupportFormat:N,isExplainSupported:T,getEditorView:()=>{var te;return(te=Z.value)==null?void 0:te.editorView}}),M=j(0),V=j(!0),H=j(!1),B=j(""),q=j("");let O=null;const Q=$(()=>c.value?o.getTagsByIds(c.value.tagIds??[]).some(te=>te.strictMode):!1),J=()=>{const te=i.value,Ne=c.value;return!te||!Ne||te.id===Ne.id?Promise.resolve(!0):H.value?Promise.resolve(!1):(B.value=te.name,q.value=Ne.name,H.value=!0,new Promise(et=>{O=et}))},ie=()=>{H.value=!1,O==null||O(!0),O=null},Be=()=>{H.value=!1,O==null||O(!1),O=null};Rs([{key:"mod+j",callback:()=>{V.value=!V.value}},{key:"ctrl+j",callback:()=>{V.value=!V.value}}]),ce(E,()=>{L.reloadSqlCompartment()});const rt=({column:te,from:Ne,line:et,to:it})=>{I.value={column:te,line:et},r.updateFileCursorPos({from:Ne,to:it})},ut=(te=!0)=>{var it,X;if(!((it=l.value)!=null&&it.cursorPos)||!((X=Z.value)!=null&&X.editorView))return;const Ne=l.value.cursorPos.from??0,et=l.value.cursorPos.to||0;Z.value.setCursorPosition({from:Ne,to:et,allowScroll:te})},Mt=j(!r.isFromCache);return ha(async()=>{Mt.value&&(await r.loadFileContent(),Mt.value=!1,await Rt()),ut()}),Mr(async()=>{var te;await Rt(),ut(!1),(te=Z.value)!=null&&te.editorView&&(Z.value.editorView.scrollDOM.scrollTop=M.value)}),sn(()=>{O&&(O(!1),O=null)}),(te,Ne)=>{const et=be,it=Bt;return S(),k(ae,null,[h(Pl,{open:d(H),"target-connection-name":d(B),"current-connection-name":d(q),onConfirm:ie,onCancel:Be},null,8,["open","target-connection-name","current-connection-name"]),h(yu,{layout:d(s).codeEditorLayout,customLayout:d(s).activeCustomLayout,"show-result-panel":d(V)},{content:y(()=>[C("div",ov,[C("div",rv,[h(pu,{"onUpdate:connectionId":d(f),connections:d(v),connection:d(i),"selected-connection-id":d(p),"disable-connection-switch":d(Q),"is-redis-connection":d(b),"redis-databases":d(F).databases.value,"redis-database-index":d(F).selectedDatabaseIndex.value,workspaceId:d(a),"file-variables":d(u),"code-editor-layout":d(s).codeEditorLayout,currentFileInfo:d(l),"is-support-variable":d(w),"onUpdate:redisDatabaseIndex":P,"onUpdate:updateFileVariables":d(x)},null,8,["onUpdate:connectionId","connections","connection","selected-connection-id","disable-connection-switch","is-redis-connection","redis-databases","redis-database-index","workspaceId","file-variables","code-editor-layout","currentFileInfo","is-support-variable","onUpdate:updateFileVariables"]),C("div",iv,[h(Fl,{"context-menu-items":d(he),"onUpdate:open":d(ot)},{default:y(()=>[d(Mt)?(S(),D(d(ln),{key:0,visible:""})):(S(),D(bs,{key:1,"onUpdate:modelValue":d(g),"onUpdate:cursorInfo":rt,"onUpdate:onScrollTop":Ne[0]||(Ne[0]=X=>M.value=X),modelValue:d(m),extensions:d(W),ref_key:"codeEditorRef",ref:Z},null,8,["onUpdate:modelValue","modelValue","extensions"]))]),_:1},8,["context-menu-items","onUpdate:open"])]),h(ou,{"cursor-info":d(I),"execute-loading":d(ve).executeLoading,"execute-errors":!!d(ve).executeErrors,"is-have-one-execute":d(ve).isHaveOneExecute,"is-streaming":d(ve).isStreaming,"streaming-row-count":d(ve).streamingRowCount,queryTime:d(ve).queryTime,"raw-query-results-length":d(st).length,"explain-analyze-option-items":d(Fe),"serialize-mode":d(ze),"is-support-format":d(N),"is-support-variable":d(w),"is-explain-supported":d(T),onOnFormatCurrentStatement:d(de),onOnFormatAll:d(le),onOnExplainAnalyzeCurrent:d(me),onToggleExplainOption:d(L).toggleExplainOption,"onUpdate:serializeMode":d(L).setSerializeMode,onOnExecuteCurrent:d(re),onOnCancelQuery:d(L).cancelStreamingQuery},null,8,["cursor-info","execute-loading","execute-errors","is-have-one-execute","is-streaming","streaming-row-count","queryTime","raw-query-results-length","explain-analyze-option-items","serialize-mode","is-support-format","is-support-variable","is-explain-supported","onOnFormatCurrentStatement","onOnFormatAll","onOnExplainAnalyzeCurrent","onToggleExplainOption","onUpdate:serializeMode","onOnExecuteCurrent","onOnCancelQuery"])])])]),variables:y(()=>[C("div",lv,[C("div",uv,[h(et,{name:"hugeicons:absolute"}),Ne[1]||(Ne[1]=z(" Variables "))]),C("div",cv,[d(w)?(S(),D(Hs,{key:1,variables:d(u),"onUpdate:variables":d(x),onUpdateVariables:d(x),"file-variables":d(u)},null,8,["variables","onUpdate:variables","onUpdateVariables","file-variables"])):(S(),D(it,{key:0,title:"Variables not supported",desc:"Variables are not available for Redis and SQLite connections.",icon:"icons:ghost"}))])])]),result:y(()=>[d(Je).size===0?(S(),D($l,{key:0})):(S(),D(sv,{key:1,"executed-results":d(Je),"active-tab-id":d(Ge),"execute-loading":d(ve).executeLoading,"is-streaming":d(ve).isStreaming,"onUpdate:activeTab":d(L).setActiveResultTab,onCloseTab:d(L).closeResultTab,onCloseOtherTabs:d(L).closeOtherResultTabs,onCloseTabsToRight:d(L).closeResultTabsToRight,"onUpdate:view":d(L).updateResultTabView},null,8,["executed-results","active-tab-id","execute-loading","is-streaming","onUpdate:activeTab","onCloseTab","onCloseOtherTabs","onCloseTabsToRight","onUpdate:view"]))]),_:1},8,["layout","customLayout","show-result-panel"])],64)}}}),Jv=se({__name:"[fileId]",setup(n){return(t,e)=>(S(),D(dv))}});export{Jv as default};
|