import{d as e,m as t,s as n,y as r}from"./hooks.module-5xe-uC6c.js";import{n as i,s as a}from"./options-CDt8ZGCW.js";import{t as o}from"./jsxRuntime.module--xb8gfv5.js";import{U as s}from"./hooks-CSTgmcXO.js";import{t as c}from"./Dropdown-CzkWLbhy.js";import{t as l}from"./Button-XVZ6KZoL.js";import{t as u}from"./NoItems-CjX4hzvd.js";import{_ as d,a as f,c as p,g as m,h,i as g,n as _,o as v,p as y,s as b,t as x,u as S,v as C}from"./tabulator-CAA7dWB4.js";import{n as w}from"./SplitEditor-Co_gxtsd.js";e();function T(e){return o(w,{noteType:`code`,...e,editorBefore:o(O,{...e}),previewContent:o(E,{...e},e.note.noteId),forceOrientation:`vertical`,splitOptions:{sizes:[70,30]}})}function E({ntxId:e}){let[t,r]=n();return s(`sqlQueryResults`,({ntxId:t,response:n})=>{t===e&&r(n)}),t===void 0?o(u,{icon:`bx bx-data`,text:a(`sql_result.not_executed`),children:o(l,{text:a(`sql_result.execute_now`),triggerCommand:`runActiveNote`})}):t&&!t.success?o(u,{icon:`bx bx-error`,text:a(`sql_result.failed`),children:o(`pre`,{className:`sql-error-message selectable-text`,children:t.error})}):t?.results.length===1&&Array.isArray(t.results[0])&&t.results[0].length===0?o(u,{icon:`bx bx-rectangle`,text:a(`sql_result.no_rows`)}):o(`div`,{className:`sql-result-widget`,children:o(`div`,{className:`sql-console-result-container selectable-text`,children:t?.results.map((e,t)=>typeof e==`object`&&!Array.isArray(e)?o(u,{icon:`bx bx-play`,text:a(`sql_result.statement_result`),children:o(`pre`,{children:JSON.stringify(e,null,`	`)},t)},t):o(D,{rows:e},t))})})}function D({rows:e}){if(e.length)return o(x,{layout:`fitDataFill`,modules:[h,C,m,_,S,g,f,d,b,p,v,y],selectableRange:!0,clipboard:`copy`,clipboardCopyRowRange:`range`,clipboardCopyConfig:{rowHeaders:!1,columnHeaders:!1},pagination:!0,paginationSize:15,paginationSizeSelector:!0,paginationCounter:`rows`,height:`100%`,columns:[{title:`#`,formatter:`rownum`,width:60,hozAlign:`right`,frozen:!0},...Object.keys(e[0]).map(e=>({title:e,field:e,width:250,minWidth:100,widthGrow:1,resizable:!0,headerFilter:!0}))],data:e})}function O({note:e}){let[s,l]=n();t(()=>{i.get(`sql/schema`).then(l)},[]);let u=e.isTriliumSqlite()&&s;return o(`div`,{className:`sql-table-schemas-widget ${u?``:`hidden-ext`}`,children:u&&o(r,{children:[a(`sql_table_schemas.tables`),`: `,o(`span`,{class:`sql-table-schemas`,children:s.map(({name:e,columns:t})=>o(c,{text:e,noSelectButtonStyle:!0,hideToggleArrow:!0,children:o(`table`,{className:`table-schema`,children:t.map(e=>o(`tr`,{children:[o(`td`,{children:e.name}),o(`td`,{children:e.type})]},e.name))})},e))})]})})}export{O as SqlTableSchemas,T as default};