import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{b as t,x as n}from"./vendor-markdown-0Mxgxy0L.js";import{a as r,i,r as a}from"./glide-data-grid-hHATgYX0.js";import{n as o,t as s}from"./use-monaco-theme-DAPyqocR.js";var c=e(n(),1),l=t();function u({onExecute:e,loading:t,defaultValue:n=`SELECT * FROM `,schemaInfo:u,onSqlChange:d,persistedSql:f}){let[p,m]=(0,c.useState)(()=>f??n),h=(0,c.useRef)(!!f),g=(0,c.useRef)(null),_=(0,c.useRef)(null),v=(0,c.useRef)(null),y=(0,c.useRef)(e);y.current=e;let b=s();(0,c.useEffect)(()=>{if(!(!_.current||!u))return v.current?.dispose(),a(),v.current=_.current.languages.registerCompletionItemProvider(`sql`,i(_.current,u)),()=>{v.current?.dispose()}},[u]);let x=(0,c.useCallback)((e,t)=>{g.current=e,_.current=t,e.addAction({id:`run-query-at-cursor`,label:`Run Statement at Cursor`,keybindings:[t.KeyMod.CtrlCmd|t.KeyCode.Enter],run:e=>{let t=e.getPosition();if(!t)return;let n=r(e.getValue(),t.lineNumber);n&&y.current(n)}}),u&&(v.current?.dispose(),v.current=t.languages.registerCompletionItemProvider(`sql`,i(t,u)))},[u]);return(0,c.useEffect)(()=>{h.current||m(n)},[n]),(0,l.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,l.jsx)(o,{height:`100%`,language:`sql`,theme:b,value:p,onChange:e=>{let t=e??``;m(t),h.current=!0,d?.(t)},onMount:x,options:{minimap:{enabled:!1},lineNumbers:`off`,scrollBeyondLastLine:!1,wordWrap:`on`,fontSize:12,tabSize:2,renderLineHighlight:`none`,overviewRulerLanes:0,hideCursorInOverviewRuler:!0,scrollbar:{vertical:`auto`,horizontal:`auto`,verticalScrollbarSize:6,horizontalScrollbarSize:6},padding:{top:4,bottom:4},lineDecorationsWidth:4,lineNumbersMinChars:0,glyphMargin:!1,folding:!1,fixedOverflowWidgets:!0}})})}export{u as t};