import{f as d,eH as I,d as x,eD as k,L as q,z as D,r as i,o as B,b as p,ev as _,w as m,u,c as A,ex as P,e as O,bF as R,ar as h,aD as V,eE as j,eG as E,cD as L,eB as N,eC as z,v as F}from"./outputWidgets.be3472c2.js";import{e as M}from"./toggleHighContrast.926dd46d.js";import"./router.87bf43b6.js";import"./index.86288308.js";import{P as Q}from"./project.8bc67c1c.js";import{A as $}from"./index.ba676107.js";import{A as T}from"./index.1db198b0.js";import"./Form.254a7379.js";import"./hasIn.bddd0a1a.js";import"./popupNotifcation.9025cc7b.js";import"./record.820df198.js";import"./pubsub.1063a0da.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3ebe0d47-1a4f-4483-a721-394ad403ce14",e._sentryDebugIdIdentifier="sentry-dbid-3ebe0d47-1a4f-4483-a721-394ad403ce14")}catch{}})();var H={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M715.8 493.5L335 165.1c-14.2-12.2-35-1.2-35 18.5v656.8c0 19.7 20.8 30.7 35 18.5l380.8-328.4c10.9-9.4 10.9-27.6 0-37z"}}]},name:"caret-right",theme:"outlined"};const G=H;function w(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?Object(arguments[t]):{},r=Object.keys(a);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(a).filter(function(n){return Object.getOwnPropertyDescriptor(a,n).enumerable}))),r.forEach(function(n){J(e,n,a[n])})}return e}function J(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var v=function(t,a){var r=w({},t,a.attrs);return d(I,w({},r,{icon:G}),null)};v.displayName="CaretRightOutlined";v.inheritAttrs=!1;const U=v;function W(e){const t={};for(const a in e)e.hasOwnProperty(a)&&(t[a]=String(e[a]));return t}const X=e=>(N("data-v-1a40f6be"),e=e(),z(),e),Y={class:"container"},Z=X(()=>O("br",null,null,-1)),K=x({__name:"Sql",setup(e){const a=k().params.projectId,r=new q(D.string(),"lastQuery"),n=i(null),l=i(""),y=i([]),b=i([]),g=i([]),S=async()=>{const o=await Q.executeQuery(a,l.value,[]);if(r.set(l.value),!o)return;const{returns:s,errors:f}=o;g.value=f,b.value=s.fields.map(c=>({title:c.name,key:c.name,dataIndex:c.name})),y.value=s.result.map((c,C)=>W({key:`${C+1}`,...c}))};return B(()=>{const o=M.create(n.value,{language:"sql",value:l.value,fontFamily:"monospace",lineNumbers:"on",minimap:{enabled:!1},scrollbar:{vertical:"hidden",horizontal:"visible"},fontSize:14,scrollBeyondLastLine:!1,lineHeight:20});o.onDidChangeModelContent(()=>{l.value=o.getValue()});const s=r.get();s&&(l.value=s,o.setValue(s))}),(o,s)=>(p(),_("div",Y,[d(u($),{gap:"large",class:"sql-container",align:"center"},{default:m(()=>[O("div",{ref_key:"sqlEditor",ref:n,class:"sql-editor"},null,512),d(u(R),{type:"primary",onClick:S},{icon:m(()=>[d(u(U))]),default:m(()=>[h(" Run ")]),_:1})]),_:1}),g.value.length?(p(),A(u(T),{key:0,type:"error","show-icon":""},{message:m(()=>[(p(!0),_(V,null,j(g.value,f=>(p(),_("span",{key:f},[h(E(f)+" ",1),Z]))),128))]),_:1})):P("",!0),d(u(L),{style:{width:"100%"},scroll:{x:100},"data-source":y.value,columns:b.value},null,8,["data-source","columns"])]))}});const fe=F(K,[["__scopeId","data-v-1a40f6be"]]);export{fe as default};
//# sourceMappingURL=Sql.a9eded98.js.map
