@duckcodeailabs/dql-cli 0.2.3 → 0.2.4
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.
|
@@ -6,7 +6,7 @@ import{r as ut,a as ST,g as Ut}from"./react-CRB3T2We.js";import{S as dE,g as pt,
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var GE;function VT(){if(GE)return le;GE=1;var E=ut(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),T=Object.prototype.hasOwnProperty,R=E.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function s(S,a,I){var n,o={},O=null,_=null;I!==void 0&&(O=""+I),a.key!==void 0&&(O=""+a.key),a.ref!==void 0&&(_=a.ref);for(n in a)T.call(a,n)&&!r.hasOwnProperty(n)&&(o[n]=a[n]);if(S&&S.defaultProps)for(n in a=S.defaultProps,a)o[n]===void 0&&(o[n]=a[n]);return{$$typeof:e,type:S,key:O,ref:_,props:o,_owner:R.current}}return le.Fragment=t,le.jsx=s,le.jsxs=s,le}var BE;function WT(){return BE||(BE=1,be.exports=VT()),be.exports}var A=WT(),Me={},HE;function vT(){if(HE)return Me;HE=1;var E=ST();return Me.createRoot=E.createRoot,Me.hydrateRoot=E.hydrateRoot,Me}var XT=vT(),L=ut();const Ge=Ut(L),KT={themeMode:"dark",sidebarPanel:"files",sidebarOpen:!0,files:[],filesLoading:!1,activeFile:null,cells:[],notebookTitle:"",notebookDirty:!1,schemaTables:[],schemaLoading:!1,devPanelOpen:!1,devPanelTab:"logs",queryLog:[],newNotebookModalOpen:!1,executionCounter:0,savingFile:!1};function wT(E,e){switch(e.type){case"SET_THEME":return{...E,themeMode:e.mode};case"SET_SIDEBAR_PANEL":return{...E,sidebarPanel:e.panel,sidebarOpen:e.panel!==null};case"TOGGLE_SIDEBAR":return{...E,sidebarOpen:!E.sidebarOpen};case"SET_FILES":return{...E,files:e.files};case"SET_FILES_LOADING":return{...E,filesLoading:e.loading};case"OPEN_FILE":return{...E,activeFile:e.file,cells:e.cells,notebookTitle:e.title,notebookDirty:!1};case"SET_CELLS":return{...E,cells:e.cells,notebookDirty:!0};case"ADD_CELL":{if(!e.afterId)return{...E,cells:[...E.cells,e.cell],notebookDirty:!0};const t=E.cells.findIndex(R=>R.id===e.afterId);if(t===-1)return{...E,cells:[...E.cells,e.cell],notebookDirty:!0};const T=[...E.cells];return T.splice(t+1,0,e.cell),{...E,cells:T,notebookDirty:!0}}case"UPDATE_CELL":{const t=E.cells.map(R=>R.id===e.id?{...R,...e.updates}:R),T=e.updates.executionCount!==void 0?E.executionCounter+1:E.executionCounter;return{...E,cells:t,notebookDirty:!0,executionCounter:T}}case"DELETE_CELL":return{...E,cells:E.cells.filter(t=>t.id!==e.id),notebookDirty:!0};case"MOVE_CELL":{const t=E.cells.findIndex(R=>R.id===e.id);if(t===-1)return E;const T=[...E.cells];return e.direction==="up"&&t>0?[T[t-1],T[t]]=[T[t],T[t-1]]:e.direction==="down"&&t<T.length-1&&([T[t],T[t+1]]=[T[t+1],T[t]]),{...E,cells:T,notebookDirty:!0}}case"SET_SCHEMA":return{...E,schemaTables:e.tables};case"SET_SCHEMA_LOADING":return{...E,schemaLoading:e.loading};case"TOGGLE_SCHEMA_TABLE":return{...E,schemaTables:E.schemaTables.map(t=>t.name===e.tableName?{...t,expanded:!t.expanded}:t)};case"TOGGLE_DEV_PANEL":return{...E,devPanelOpen:!E.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...E,devPanelTab:e.tab};case"APPEND_QUERY_LOG":return{...E,queryLog:[...E.queryLog,e.entry]};case"OPEN_NEW_NOTEBOOK_MODAL":return{...E,newNotebookModalOpen:!0};case"CLOSE_NEW_NOTEBOOK_MODAL":return{...E,newNotebookModalOpen:!1};case"SET_NOTEBOOK_DIRTY":return{...E,notebookDirty:e.dirty};case"SET_SAVING":return{...E,savingFile:e.saving};case"FILE_ADDED":return{...E,files:[...E.files,e.file]};case"SET_TABLE_COLUMNS":return{...E,schemaTables:E.schemaTables.map(t=>t.name===e.tableName?{...t,columns:e.columns}:t)};case"SET_PARAM_VALUE":return{...E,cells:E.cells.map(t=>t.id===e.id?{...t,paramValue:e.value}:t),notebookDirty:!0};default:return E}}const ft=L.createContext(null);function $T({children:E}){const[e,t]=L.useReducer(wT,KT);return A.jsx(ft.Provider,{value:{state:e,dispatch:t},children:E})}function f(){const E=L.useContext(ft);if(!E)throw new Error("useNotebook must be used within NotebookProvider");return E}function Q(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function X(E,e=""){const t={id:Q(),type:E,content:e,status:"idle"};return E==="param"&&(t.content="",t.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),t}const kT={appBg:"#0d1117",sidebarBg:"#161b22",activityBarBg:"#0d1117",headerBg:"#161b22",headerBorder:"#21262d",cellBg:"#161b22",cellBorder:"#30363d",cellBorderActive:"#388bfd",cellBorderRunning:"#56d364",textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",editorBg:"#0d1117",editorBorder:"#30363d",tableBorder:"#30363d",tableHeaderBg:"#1c2128",tableRowHover:"#21262d",accent:"#388bfd",accentHover:"#58a6ff",success:"#56d364",error:"#f85149",warning:"#e3b341",btnBg:"#21262d",btnBorder:"#30363d",btnHover:"#30363d",sidebarItemHover:"#21262d",sidebarItemActive:"#1f2d3d",scrollbarThumb:"#30363d",modalBg:"#161b22",modalOverlay:"rgba(0,0,0,0.7)",inputBg:"#0d1117",inputBorder:"#30363d",pillBg:"#21262d",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},JT={appBg:"#ffffff",sidebarBg:"#f6f8fa",activityBarBg:"#eff1f3",headerBg:"#ffffff",headerBorder:"#d0d7de",cellBg:"#ffffff",cellBorder:"#d0d7de",cellBorderActive:"#0969da",cellBorderRunning:"#1f883d",textPrimary:"#1f2328",textSecondary:"#57606a",textMuted:"#8c959f",editorBg:"#f6f8fa",editorBorder:"#d0d7de",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableRowHover:"#f6f8fa",accent:"#0969da",accentHover:"#0550ae",success:"#1f883d",error:"#cf222e",warning:"#9a6700",btnBg:"#f6f8fa",btnBorder:"#d0d7de",btnHover:"#eaeef2",sidebarItemHover:"#eaeef2",sidebarItemActive:"#dbeafe",scrollbarThumb:"#d0d7de",modalBg:"#ffffff",modalOverlay:"rgba(0,0,0,0.4)",inputBg:"#ffffff",inputBorder:"#d0d7de",pillBg:"#eaeef2",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},h={dark:kT,light:JT};function Te({title:E,active:e,onClick:t,children:T,t:R}){const[r,s]=L.useState(!1);return A.jsx("button",{title:E,onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderLeft:e?`2px solid ${R.accent}`:"2px solid transparent",cursor:"pointer",color:e?R.textPrimary:r?R.textSecondary:R.textMuted,transition:"color 0.15s, border-color 0.15s",padding:0,flexShrink:0},children:T})}function jT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"})})}function QT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M8 0C3.58 0 0 1.567 0 3.5v9C0 14.433 3.58 16 8 16s8-1.567 8-3.5v-9C16 1.567 12.42 0 8 0ZM1.5 7.784V5.716C3.05 6.51 5.404 7 8 7s4.95-.49 6.5-1.284v2.068C12.95 8.578 10.596 9 8 9s-4.95-.422-6.5-1.216ZM8 1.5c3.17 0 5.854 1.116 6.357 2.5H1.643C2.146 2.616 4.83 1.5 8 1.5Zm0 13c-3.17 0-5.854-1.116-6.357-2.5h12.714C13.854 13.384 11.17 14.5 8 14.5Zm6.5-3.284C12.95 11.01 10.596 11.5 8 11.5s-4.95-.49-6.5-1.284V8.216C3.05 9.01 5.404 9.5 8 9.5s4.95-.49 6.5-1.284v2.5Z"})})}function ZT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M2 2h12a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h8a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h10a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Z"})})}function qT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1 2.75C1 1.784 1.784 1 2.75 1h2.5C6.216 1 7 1.784 7 2.75v2.5C7 6.216 6.216 7 5.25 7h-2.5C1.784 7 1 6.216 1 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5A.25.25 0 0 0 6 5.25v-2.5A.25.25 0 0 0 5.25 2.5ZM9 2.75C9 1.784 9.784 1 10.75 1h2.5C14.216 1 15 1.784 15 2.75v2.5C15 6.216 14.216 7 13.25 7h-2.5C9.784 7 9 6.216 9 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM1 10.75C1 9.784 1.784 9 2.75 9h2.5C6.216 9 7 9.784 7 10.75v2.5C7 14.216 6.216 15 5.25 15h-2.5C1.784 15 1 14.216 1 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM13 9.75a.75.75 0 0 1 .75.75v1.75H15.5a.75.75 0 0 1 0 1.5h-1.75V15.5a.75.75 0 0 1-1.5 0v-1.75H10.5a.75.75 0 0 1 0-1.5h1.75V10.5A.75.75 0 0 1 13 9.75Z"})})}function zT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"})})}function eR(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67C6.03 4.26 6.88 3.75 8 3.75c1.463 0 2.5 1.008 2.5 2.25 0 1.133-.67 1.8-1.4 2.25-.487.3-.6.47-.6.75V9.5a.75.75 0 0 1-1.5 0v-.5c0-.833.585-1.33 1.1-1.65.387-.24.9-.597.9-1.35 0-.65-.53-1.25-1.5-1.25-.74 0-1.163.353-1.58.835ZM8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}function ER(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.103-.303c-.066-.019-.176-.011-.299.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.103.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.147a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}function tR(){const{state:E,dispatch:e}=f(),t=h[E.themeMode];function T(R){E.sidebarPanel===R&&E.sidebarOpen?e({type:"TOGGLE_SIDEBAR"}):e({type:"SET_SIDEBAR_PANEL",panel:R})}return A.jsxs("div",{style:{width:32,flexShrink:0,background:t.activityBarBg,borderRight:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,paddingBottom:8,gap:2,userSelect:"none"},children:[A.jsx(Te,{title:"Files",active:E.sidebarPanel==="files"&&E.sidebarOpen,onClick:()=>T("files"),t,children:A.jsx(jT,{})}),A.jsx(Te,{title:"Schema",active:E.sidebarPanel==="schema"&&E.sidebarOpen,onClick:()=>T("schema"),t,children:A.jsx(QT,{})}),A.jsx(Te,{title:"Outline",active:E.sidebarPanel==="outline"&&E.sidebarOpen,onClick:()=>T("outline"),t,children:A.jsx(ZT,{})}),A.jsx(Te,{title:"Connection",active:E.sidebarPanel==="connection"&&E.sidebarOpen,onClick:()=>T("connection"),t,children:A.jsx(qT,{})}),A.jsx(Te,{title:"Reference",active:E.sidebarPanel==="reference"&&E.sidebarOpen,onClick:()=>T("reference"),t,children:A.jsx(zT,{})}),A.jsx("div",{style:{flex:1}}),A.jsx(Te,{title:"Help",active:!1,onClick:()=>{},t,children:A.jsx(eR,{})}),A.jsx(Te,{title:"Settings",active:!1,onClick:()=>{},t,children:A.jsx(ER,{})})]})}const Ve={notebooks:"Notebooks",workbooks:"Workbooks",blocks:"Blocks",dashboards:"Dashboards"};function TR({type:E}){switch(E){case"notebook":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.063 0L7.597 13.66A2.25 2.25 0 0 0 6.007 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h4.507c.656 0 1.287.169 1.744.324Zm1.499.004c.457-.155 1.088-.324 1.744-.324H15v-9h-3.495a2.25 2.25 0 0 0-2.252 2.247l-.002 9.077Z"})});case"workbook":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm2 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75ZM6.5 7.25a.75.75 0 0 0 0 1.5h3a.75.75 0 0 0 0-1.5Zm-.75 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75Z"})});case"block":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M10.5 0l5.25 4-5.25 4V6H9.25A1.75 1.75 0 0 0 7.5 7.75v2.5A1.75 1.75 0 0 0 9.25 12h1.25v8H9v-6.5A3.25 3.25 0 0 1 5.75 10h-2A3.25 3.25 0 0 1 .5 6.75v-2.5A3.25 3.25 0 0 1 3.75 1h2A3.25 3.25 0 0 1 9 4.5V6h1.5V0z"})});default:return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625Zm2.169-1a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}}function RR({expanded:E}){return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:E?A.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"}):A.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"})})}function AR(E){return E.name.replace(/\.(dqlnb|dql)$/,"")}function rR({onOpenFile:E}){const{state:e,dispatch:t}=f(),T=h[e.themeMode],[R,r]=L.useState({notebooks:!0,workbooks:!0,blocks:!1,dashboards:!1}),[s,S]=L.useState(!1),a={notebooks:[],workbooks:[],blocks:[],dashboards:[]};for(const n of e.files){const o=n.folder.toLowerCase();o in a&&a[o].push(n)}const I=n=>{r(o=>({...o,[n]:!o[n]}))};return A.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px 0",display:"flex",flexDirection:"column",gap:0},children:[A.jsx("div",{style:{padding:"0 8px 8px"},children:A.jsxs("button",{onClick:()=>t({type:"OPEN_NEW_NOTEBOOK_MODAL"}),onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),style:{width:"100%",height:30,background:"transparent",border:`1px dashed ${s?T.accent:T.cellBorder}`,borderRadius:6,color:s?T.accent:T.textSecondary,cursor:"pointer",fontSize:12,fontFamily:T.font,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[A.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"New Notebook"]})}),e.filesLoading&&A.jsx("div",{style:{padding:"8px 14px",color:T.textMuted,fontSize:12,fontFamily:T.font},children:"Loading files…"}),Object.keys(Ve).map(n=>{const o=a[n],O=R[n];return A.jsxs("div",{children:[A.jsx(sR,{label:Ve[n],count:o.length,expanded:O,onToggle:()=>I(n),t:T}),O&&A.jsx("div",{children:o.length===0?A.jsxs("div",{style:{padding:"4px 14px 4px 32px",fontSize:12,color:T.textMuted,fontFamily:T.font,fontStyle:"italic"},children:["No ",Ve[n].toLowerCase()]}):o.map(_=>{var C;return A.jsx(SR,{file:_,active:((C=e.activeFile)==null?void 0:C.path)===_.path,onClick:()=>E(_),t:T},_.path)})})]},n)})]})}function sR({label:E,count:e,expanded:t,onToggle:T,t:R}){const[r,s]=L.useState(!1);return A.jsxs("button",{onClick:T,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 10px",background:r?R.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:R.textSecondary,fontSize:11,fontWeight:600,fontFamily:R.font,letterSpacing:"0.04em",textTransform:"uppercase",textAlign:"left",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:A.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),A.jsx(RR,{expanded:t}),A.jsx("span",{style:{flex:1},children:E}),e>0&&A.jsx("span",{style:{background:R.pillBg,color:R.textMuted,borderRadius:10,padding:"0 5px",fontSize:10,fontWeight:500},children:e})]})}function SR({file:E,active:e,onClick:t,t:T}){const[R,r]=L.useState(!1);return A.jsxs("button",{onClick:t,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"4px 8px 4px 26px",background:e?T.sidebarItemActive:R?T.sidebarItemHover:"transparent",border:"none",borderLeft:e?`2px solid ${T.accent}`:"2px solid transparent",cursor:"pointer",color:e||R?T.textPrimary:T.textSecondary,fontSize:13,fontFamily:T.font,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[A.jsx("span",{style:{flexShrink:0,color:e?T.accent:T.textMuted},children:A.jsx(TR,{type:E.type})}),A.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:AR(E)}),E.isNew&&A.jsx("span",{style:{fontSize:9,fontWeight:600,color:T.accent,background:T.sidebarItemActive,borderRadius:4,padding:"1px 4px",flexShrink:0},children:"NEW"})]})}const nR=window.location.origin;async function J(E,e){const t=await fetch(`${nR}${E}`,{headers:{"Content-Type":"application/json"},...e});if(!t.ok){const T=await t.text().catch(()=>t.statusText);throw new Error(T||`HTTP ${t.status}`)}if(t.status!==204)return t.json()}const W={async listNotebooks(){try{return await J("/api/notebooks")}catch{return[]}},async readNotebook(E){return J(`/api/notebook-content?path=${encodeURIComponent(E)}`)},async createNotebook(E,e){return J("/api/notebooks",{method:"POST",body:JSON.stringify({name:E,template:e})})},async saveNotebook(E,e){return J("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:E,content:e})})},async executeQuery(E){return J("/api/query",{method:"POST",body:JSON.stringify({sql:E})})},async getSchema(){try{return await J("/api/schema")}catch{return[]}},async getConnections(){try{return await J("/api/connections")}catch{return{default:"unknown",connections:{}}}},async testConnection(){try{return await J("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(E){return{ok:!1,message:E.message??"Connection failed"}}},async describeTable(E){const t=`DESCRIBE SELECT * FROM read_csv_auto('${E.replace(/'/g,"''")}') LIMIT 0`;try{return(await J("/api/query",{method:"POST",body:JSON.stringify({sql:t})})).rows.map(R=>({name:String(R.column_name??R.Field??""),type:String(R.column_type??R.Type??"")}))}catch{return[]}}},IR={varchar:"#388bfd",text:"#388bfd",string:"#388bfd",char:"#388bfd",integer:"#56d364",int:"#56d364",bigint:"#56d364",smallint:"#56d364",float:"#56d364",double:"#56d364",decimal:"#56d364",numeric:"#56d364",real:"#56d364",date:"#e3b341",timestamp:"#e3b341",datetime:"#e3b341",time:"#e3b341",boolean:"#f778ba",bool:"#f778ba",json:"#79c0ff",jsonb:"#79c0ff",uuid:"#d2a8ff",bytea:"#ffa657",binary:"#ffa657"};function FE(E,e){const t=E.toLowerCase().split("(")[0].trim();return IR[t]??e}function oR({t:E}){return A.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:8},children:[[1,2,3].map(e=>A.jsx("div",{style:{height:28,borderRadius:4,background:E.pillBg,opacity:.6,animation:"pulse 1.5s ease-in-out infinite"}},e)),A.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:.3} }"})]})}function aR(){const{state:E,dispatch:e}=f(),t=h[E.themeMode],[T,R]=L.useState(!1),r=async()=>{e({type:"SET_SCHEMA_LOADING",loading:!0});try{const s=await W.getSchema();e({type:"SET_SCHEMA",tables:s})}catch(s){console.error("Schema refresh failed:",s)}finally{e({type:"SET_SCHEMA_LOADING",loading:!1})}};return A.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[A.jsxs("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:6,borderBottom:`1px solid ${t.headerBorder}`},children:[A.jsxs("span",{style:{flex:1,fontSize:11,color:t.textMuted,fontFamily:t.font},children:[E.schemaTables.length," tables"]}),A.jsxs("button",{onClick:r,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),title:"Refresh schema",style:{background:T?t.btnHover:"transparent",border:`1px solid ${T?t.btnBorder:"transparent"}`,borderRadius:4,cursor:"pointer",color:T?t.textSecondary:t.textMuted,fontSize:11,fontFamily:t.font,padding:"2px 6px",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},children:[A.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z"})}),"Refresh"]})]}),E.schemaLoading?A.jsx(oR,{t}):E.schemaTables.length===0?A.jsxs("div",{style:{padding:"24px 14px",color:t.textMuted,fontSize:12,fontFamily:t.font,textAlign:"center",fontStyle:"italic"},children:["No tables found.",A.jsx("br",{}),"Connect a data source to explore schema."]}):A.jsx("div",{style:{overflow:"auto",flex:1},children:E.schemaTables.map(s=>A.jsx(NR,{table:s,t},s.name))})]})}function NR({table:E,t:e}){const{dispatch:t}=f(),[T,R]=L.useState(!1),[r,s]=L.useState(!1),S=async()=>{if(t({type:"TOGGLE_SCHEMA_TABLE",tableName:E.name}),!E.expanded&&E.columns.length===0){s(!0);try{const a=await W.describeTable(E.path);a.length>0&&t({type:"SET_TABLE_COLUMNS",tableName:E.name,columns:a})}catch(a){console.error("describeTable failed:",a)}finally{s(!1)}}};return A.jsxs("div",{children:[A.jsxs("button",{onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onClick:S,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:T?e.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:e.textPrimary,fontSize:12,fontFamily:e.font,fontWeight:500,textAlign:"left",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:E.expanded?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0,color:e.textMuted},children:A.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{color:e.accent,flexShrink:0},children:A.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v1.5A1.75 1.75 0 0 1 14.25 5H1.75A1.75 1.75 0 0 1 0 3.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6C0 6.784.784 6 1.75 6h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 11H1.75A1.75 1.75 0 0 1 0 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Z"})}),A.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),E.columns.length>0&&A.jsx("span",{style:{fontSize:10,color:e.textMuted,background:e.pillBg,borderRadius:8,padding:"1px 5px",flexShrink:0},children:E.columns.length})]}),E.expanded&&A.jsx("div",{style:{paddingLeft:26},children:r?A.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:e.textMuted,fontFamily:e.font,fontStyle:"italic"},children:"..."}):E.columns.length===0?A.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:e.textMuted,fontFamily:e.font,fontStyle:"italic"},children:"No columns"}):E.columns.map(a=>A.jsx(iR,{col:a,t:e},a.name))})]})}function iR({col:E,t:e}){const[t,T]=L.useState(!1);return A.jsxs("div",{onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px 3px 8px",background:t?e.sidebarItemHover:"transparent",cursor:"default",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",style:{color:e.textMuted,flexShrink:0},children:A.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})}),A.jsx("span",{style:{flex:1,fontSize:11,fontFamily:e.fontMono,color:e.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),A.jsx("span",{style:{fontSize:10,fontFamily:e.fontMono,color:FE(E.type,e.accent),background:`${FE(E.type,e.accent)}18`,borderRadius:4,padding:"1px 5px",flexShrink:0},children:E.type.toLowerCase()})]})}function lR(E){if(E.type==="markdown"){const e=E.content.match(/^#{1,6}\s+(.+)$/m);if(e)return e[1];const t=E.content.split(`
|
|
9
|
+
*/var GE;function VT(){if(GE)return le;GE=1;var E=ut(),e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),T=Object.prototype.hasOwnProperty,R=E.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function s(S,a,I){var n,o={},O=null,_=null;I!==void 0&&(O=""+I),a.key!==void 0&&(O=""+a.key),a.ref!==void 0&&(_=a.ref);for(n in a)T.call(a,n)&&!r.hasOwnProperty(n)&&(o[n]=a[n]);if(S&&S.defaultProps)for(n in a=S.defaultProps,a)o[n]===void 0&&(o[n]=a[n]);return{$$typeof:e,type:S,key:O,ref:_,props:o,_owner:R.current}}return le.Fragment=t,le.jsx=s,le.jsxs=s,le}var BE;function WT(){return BE||(BE=1,be.exports=VT()),be.exports}var A=WT(),Me={},HE;function vT(){if(HE)return Me;HE=1;var E=ST();return Me.createRoot=E.createRoot,Me.hydrateRoot=E.hydrateRoot,Me}var XT=vT(),L=ut();const Ge=Ut(L),KT={themeMode:"dark",sidebarPanel:"files",sidebarOpen:!0,files:[],filesLoading:!1,activeFile:null,cells:[],notebookTitle:"",notebookDirty:!1,schemaTables:[],schemaLoading:!1,devPanelOpen:!1,devPanelTab:"logs",queryLog:[],newNotebookModalOpen:!1,executionCounter:0,savingFile:!1};function wT(E,e){switch(e.type){case"SET_THEME":return{...E,themeMode:e.mode};case"SET_SIDEBAR_PANEL":return{...E,sidebarPanel:e.panel,sidebarOpen:e.panel!==null};case"TOGGLE_SIDEBAR":return{...E,sidebarOpen:!E.sidebarOpen};case"SET_FILES":return{...E,files:e.files};case"SET_FILES_LOADING":return{...E,filesLoading:e.loading};case"OPEN_FILE":return{...E,activeFile:e.file,cells:e.cells,notebookTitle:e.title,notebookDirty:!1};case"SET_CELLS":return{...E,cells:e.cells,notebookDirty:!0};case"ADD_CELL":{if(!e.afterId)return{...E,cells:[...E.cells,e.cell],notebookDirty:!0};const t=E.cells.findIndex(R=>R.id===e.afterId);if(t===-1)return{...E,cells:[...E.cells,e.cell],notebookDirty:!0};const T=[...E.cells];return T.splice(t+1,0,e.cell),{...E,cells:T,notebookDirty:!0}}case"UPDATE_CELL":{const t=E.cells.map(R=>R.id===e.id?{...R,...e.updates}:R),T=e.updates.executionCount!==void 0?E.executionCounter+1:E.executionCounter;return{...E,cells:t,notebookDirty:!0,executionCounter:T}}case"DELETE_CELL":return{...E,cells:E.cells.filter(t=>t.id!==e.id),notebookDirty:!0};case"MOVE_CELL":{const t=E.cells.findIndex(R=>R.id===e.id);if(t===-1)return E;const T=[...E.cells];return e.direction==="up"&&t>0?[T[t-1],T[t]]=[T[t],T[t-1]]:e.direction==="down"&&t<T.length-1&&([T[t],T[t+1]]=[T[t+1],T[t]]),{...E,cells:T,notebookDirty:!0}}case"SET_SCHEMA":return{...E,schemaTables:e.tables};case"SET_SCHEMA_LOADING":return{...E,schemaLoading:e.loading};case"TOGGLE_SCHEMA_TABLE":return{...E,schemaTables:E.schemaTables.map(t=>t.name===e.tableName?{...t,expanded:!t.expanded}:t)};case"TOGGLE_DEV_PANEL":return{...E,devPanelOpen:!E.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...E,devPanelTab:e.tab};case"APPEND_QUERY_LOG":return{...E,queryLog:[...E.queryLog,e.entry]};case"OPEN_NEW_NOTEBOOK_MODAL":return{...E,newNotebookModalOpen:!0};case"CLOSE_NEW_NOTEBOOK_MODAL":return{...E,newNotebookModalOpen:!1};case"SET_NOTEBOOK_DIRTY":return{...E,notebookDirty:e.dirty};case"SET_SAVING":return{...E,savingFile:e.saving};case"FILE_ADDED":return{...E,files:[...E.files,e.file]};case"SET_TABLE_COLUMNS":return{...E,schemaTables:E.schemaTables.map(t=>t.name===e.tableName?{...t,columns:e.columns}:t)};case"SET_PARAM_VALUE":return{...E,cells:E.cells.map(t=>t.id===e.id?{...t,paramValue:e.value}:t),notebookDirty:!0};default:return E}}const ft=L.createContext(null);function $T({children:E}){const[e,t]=L.useReducer(wT,KT);return A.jsx(ft.Provider,{value:{state:e,dispatch:t},children:E})}function f(){const E=L.useContext(ft);if(!E)throw new Error("useNotebook must be used within NotebookProvider");return E}function Q(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function X(E,e=""){const t={id:Q(),type:E,content:e,status:"idle"};return E==="param"&&(t.content="",t.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),t}const kT={appBg:"#0d1117",sidebarBg:"#161b22",activityBarBg:"#0d1117",headerBg:"#161b22",headerBorder:"#21262d",cellBg:"#161b22",cellBorder:"#30363d",cellBorderActive:"#388bfd",cellBorderRunning:"#56d364",textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",editorBg:"#0d1117",editorBorder:"#30363d",tableBorder:"#30363d",tableHeaderBg:"#1c2128",tableRowHover:"#21262d",accent:"#388bfd",accentHover:"#58a6ff",success:"#56d364",error:"#f85149",warning:"#e3b341",btnBg:"#21262d",btnBorder:"#30363d",btnHover:"#30363d",sidebarItemHover:"#21262d",sidebarItemActive:"#1f2d3d",scrollbarThumb:"#30363d",modalBg:"#161b22",modalOverlay:"rgba(0,0,0,0.7)",inputBg:"#0d1117",inputBorder:"#30363d",pillBg:"#21262d",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},JT={appBg:"#ffffff",sidebarBg:"#f6f8fa",activityBarBg:"#eff1f3",headerBg:"#ffffff",headerBorder:"#d0d7de",cellBg:"#ffffff",cellBorder:"#d0d7de",cellBorderActive:"#0969da",cellBorderRunning:"#1f883d",textPrimary:"#1f2328",textSecondary:"#57606a",textMuted:"#8c959f",editorBg:"#f6f8fa",editorBorder:"#d0d7de",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableRowHover:"#f6f8fa",accent:"#0969da",accentHover:"#0550ae",success:"#1f883d",error:"#cf222e",warning:"#9a6700",btnBg:"#f6f8fa",btnBorder:"#d0d7de",btnHover:"#eaeef2",sidebarItemHover:"#eaeef2",sidebarItemActive:"#dbeafe",scrollbarThumb:"#d0d7de",modalBg:"#ffffff",modalOverlay:"rgba(0,0,0,0.4)",inputBg:"#ffffff",inputBorder:"#d0d7de",pillBg:"#eaeef2",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},h={dark:kT,light:JT};function Te({title:E,active:e,onClick:t,children:T,t:R}){const[r,s]=L.useState(!1);return A.jsx("button",{title:E,onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderLeft:e?`2px solid ${R.accent}`:"2px solid transparent",cursor:"pointer",color:e?R.textPrimary:r?R.textSecondary:R.textMuted,transition:"color 0.15s, border-color 0.15s",padding:0,flexShrink:0},children:T})}function jT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"})})}function QT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M8 0C3.58 0 0 1.567 0 3.5v9C0 14.433 3.58 16 8 16s8-1.567 8-3.5v-9C16 1.567 12.42 0 8 0ZM1.5 7.784V5.716C3.05 6.51 5.404 7 8 7s4.95-.49 6.5-1.284v2.068C12.95 8.578 10.596 9 8 9s-4.95-.422-6.5-1.216ZM8 1.5c3.17 0 5.854 1.116 6.357 2.5H1.643C2.146 2.616 4.83 1.5 8 1.5Zm0 13c-3.17 0-5.854-1.116-6.357-2.5h12.714C13.854 13.384 11.17 14.5 8 14.5Zm6.5-3.284C12.95 11.01 10.596 11.5 8 11.5s-4.95-.49-6.5-1.284V8.216C3.05 9.01 5.404 9.5 8 9.5s4.95-.49 6.5-1.284v2.5Z"})})}function ZT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M2 2h12a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h8a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h10a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Z"})})}function qT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1 2.75C1 1.784 1.784 1 2.75 1h2.5C6.216 1 7 1.784 7 2.75v2.5C7 6.216 6.216 7 5.25 7h-2.5C1.784 7 1 6.216 1 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5A.25.25 0 0 0 6 5.25v-2.5A.25.25 0 0 0 5.25 2.5ZM9 2.75C9 1.784 9.784 1 10.75 1h2.5C14.216 1 15 1.784 15 2.75v2.5C15 6.216 14.216 7 13.25 7h-2.5C9.784 7 9 6.216 9 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM1 10.75C1 9.784 1.784 9 2.75 9h2.5C6.216 9 7 9.784 7 10.75v2.5C7 14.216 6.216 15 5.25 15h-2.5C1.784 15 1 14.216 1 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM13 9.75a.75.75 0 0 1 .75.75v1.75H15.5a.75.75 0 0 1 0 1.5h-1.75V15.5a.75.75 0 0 1-1.5 0v-1.75H10.5a.75.75 0 0 1 0-1.5h1.75V10.5A.75.75 0 0 1 13 9.75Z"})})}function zT(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"})})}function eR(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67C6.03 4.26 6.88 3.75 8 3.75c1.463 0 2.5 1.008 2.5 2.25 0 1.133-.67 1.8-1.4 2.25-.487.3-.6.47-.6.75V9.5a.75.75 0 0 1-1.5 0v-.5c0-.833.585-1.33 1.1-1.65.387-.24.9-.597.9-1.35 0-.65-.53-1.25-1.5-1.25-.74 0-1.163.353-1.58.835ZM8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}function ER(){return A.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.103-.303c-.066-.019-.176-.011-.299.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.103.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.147a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}function tR(){const{state:E,dispatch:e}=f(),t=h[E.themeMode];function T(R){E.sidebarPanel===R&&E.sidebarOpen?e({type:"TOGGLE_SIDEBAR"}):e({type:"SET_SIDEBAR_PANEL",panel:R})}return A.jsxs("div",{style:{width:32,flexShrink:0,background:t.activityBarBg,borderRight:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,paddingBottom:8,gap:2,userSelect:"none"},children:[A.jsx(Te,{title:"Files",active:E.sidebarPanel==="files"&&E.sidebarOpen,onClick:()=>T("files"),t,children:A.jsx(jT,{})}),A.jsx(Te,{title:"Schema",active:E.sidebarPanel==="schema"&&E.sidebarOpen,onClick:()=>T("schema"),t,children:A.jsx(QT,{})}),A.jsx(Te,{title:"Outline",active:E.sidebarPanel==="outline"&&E.sidebarOpen,onClick:()=>T("outline"),t,children:A.jsx(ZT,{})}),A.jsx(Te,{title:"Connection",active:E.sidebarPanel==="connection"&&E.sidebarOpen,onClick:()=>T("connection"),t,children:A.jsx(qT,{})}),A.jsx(Te,{title:"Reference",active:E.sidebarPanel==="reference"&&E.sidebarOpen,onClick:()=>T("reference"),t,children:A.jsx(zT,{})}),A.jsx("div",{style:{flex:1}}),A.jsx(Te,{title:"Help",active:!1,onClick:()=>{},t,children:A.jsx(eR,{})}),A.jsx(Te,{title:"Settings",active:!1,onClick:()=>{},t,children:A.jsx(ER,{})})]})}const Ve={notebooks:"Notebooks",workbooks:"Workbooks",blocks:"Blocks",dashboards:"Dashboards"};function TR({type:E}){switch(E){case"notebook":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.063 0L7.597 13.66A2.25 2.25 0 0 0 6.007 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h4.507c.656 0 1.287.169 1.744.324Zm1.499.004c.457-.155 1.088-.324 1.744-.324H15v-9h-3.495a2.25 2.25 0 0 0-2.252 2.247l-.002 9.077Z"})});case"workbook":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm2 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75ZM6.5 7.25a.75.75 0 0 0 0 1.5h3a.75.75 0 0 0 0-1.5Zm-.75 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75Z"})});case"block":return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M10.5 0l5.25 4-5.25 4V6H9.25A1.75 1.75 0 0 0 7.5 7.75v2.5A1.75 1.75 0 0 0 9.25 12h1.25v8H9v-6.5A3.25 3.25 0 0 1 5.75 10h-2A3.25 3.25 0 0 1 .5 6.75v-2.5A3.25 3.25 0 0 1 3.75 1h2A3.25 3.25 0 0 1 9 4.5V6h1.5V0z"})});default:return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625Zm2.169-1a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}}function RR({expanded:E}){return A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:E?A.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"}):A.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"})})}function AR(E){return E.name.replace(/\.(dqlnb|dql)$/,"")}function rR({onOpenFile:E}){const{state:e,dispatch:t}=f(),T=h[e.themeMode],[R,r]=L.useState({notebooks:!0,workbooks:!0,blocks:!1,dashboards:!1}),[s,S]=L.useState(!1),a={notebooks:[],workbooks:[],blocks:[],dashboards:[]};for(const n of e.files){const o=n.folder.toLowerCase();o in a&&a[o].push(n)}const I=n=>{r(o=>({...o,[n]:!o[n]}))};return A.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px 0",display:"flex",flexDirection:"column",gap:0},children:[A.jsx("div",{style:{padding:"0 8px 8px"},children:A.jsxs("button",{onClick:()=>t({type:"OPEN_NEW_NOTEBOOK_MODAL"}),onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),style:{width:"100%",height:30,background:"transparent",border:`1px dashed ${s?T.accent:T.cellBorder}`,borderRadius:6,color:s?T.accent:T.textSecondary,cursor:"pointer",fontSize:12,fontFamily:T.font,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[A.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"New Notebook"]})}),e.filesLoading&&A.jsx("div",{style:{padding:"8px 14px",color:T.textMuted,fontSize:12,fontFamily:T.font},children:"Loading files…"}),Object.keys(Ve).map(n=>{const o=a[n],O=R[n];return A.jsxs("div",{children:[A.jsx(sR,{label:Ve[n],count:o.length,expanded:O,onToggle:()=>I(n),t:T}),O&&A.jsx("div",{children:o.length===0?A.jsxs("div",{style:{padding:"4px 14px 4px 32px",fontSize:12,color:T.textMuted,fontFamily:T.font,fontStyle:"italic"},children:["No ",Ve[n].toLowerCase()]}):o.map(_=>{var C;return A.jsx(SR,{file:_,active:((C=e.activeFile)==null?void 0:C.path)===_.path,onClick:()=>E(_),t:T},_.path)})})]},n)})]})}function sR({label:E,count:e,expanded:t,onToggle:T,t:R}){const[r,s]=L.useState(!1);return A.jsxs("button",{onClick:T,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 10px",background:r?R.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:R.textSecondary,fontSize:11,fontWeight:600,fontFamily:R.font,letterSpacing:"0.04em",textTransform:"uppercase",textAlign:"left",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:A.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),A.jsx(RR,{expanded:t}),A.jsx("span",{style:{flex:1},children:E}),e>0&&A.jsx("span",{style:{background:R.pillBg,color:R.textMuted,borderRadius:10,padding:"0 5px",fontSize:10,fontWeight:500},children:e})]})}function SR({file:E,active:e,onClick:t,t:T}){const[R,r]=L.useState(!1);return A.jsxs("button",{onClick:t,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"4px 8px 4px 26px",background:e?T.sidebarItemActive:R?T.sidebarItemHover:"transparent",border:"none",borderLeft:e?`2px solid ${T.accent}`:"2px solid transparent",cursor:"pointer",color:e||R?T.textPrimary:T.textSecondary,fontSize:13,fontFamily:T.font,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[A.jsx("span",{style:{flexShrink:0,color:e?T.accent:T.textMuted},children:A.jsx(TR,{type:E.type})}),A.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:AR(E)}),E.isNew&&A.jsx("span",{style:{fontSize:9,fontWeight:600,color:T.accent,background:T.sidebarItemActive,borderRadius:4,padding:"1px 4px",flexShrink:0},children:"NEW"})]})}const nR=window.location.origin;async function J(E,e){const t=await fetch(`${nR}${E}`,{headers:{"Content-Type":"application/json"},...e});if(!t.ok){const T=await t.text().catch(()=>t.statusText);throw new Error(T||`HTTP ${t.status}`)}if(t.status!==204)return t.json()}const W={async listNotebooks(){try{return await J("/api/notebooks")}catch{return[]}},async readNotebook(E){return J(`/api/notebook-content?path=${encodeURIComponent(E)}`)},async createNotebook(E,e){return J("/api/notebooks",{method:"POST",body:JSON.stringify({name:E,template:e})})},async saveNotebook(E,e){return J("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:E,content:e})})},async executeQuery(E){var T;const e=await J("/api/query",{method:"POST",body:JSON.stringify({sql:E})});return{columns:Array.isArray(e==null?void 0:e.columns)?e.columns.map(R=>typeof R=="string"?R:typeof(R==null?void 0:R.name)=="string"?R.name:String(R)):[],rows:Array.isArray(e==null?void 0:e.rows)?e.rows:[],rowCount:(e==null?void 0:e.rowCount)??((T=e==null?void 0:e.rows)==null?void 0:T.length)??0,executionTime:(e==null?void 0:e.executionTime)??(e==null?void 0:e.executionTimeMs)??0}},async getSchema(){try{return await J("/api/schema")}catch{return[]}},async getConnections(){try{return await J("/api/connections")}catch{return{default:"unknown",connections:{}}}},async testConnection(){try{return await J("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(E){return{ok:!1,message:E.message??"Connection failed"}}},async describeTable(E){const t=`DESCRIBE SELECT * FROM read_csv_auto('${E.replace(/'/g,"''")}') LIMIT 0`;try{return(await J("/api/query",{method:"POST",body:JSON.stringify({sql:t})})).rows.map(R=>({name:String(R.column_name??R.Field??""),type:String(R.column_type??R.Type??"")}))}catch{return[]}}},IR={varchar:"#388bfd",text:"#388bfd",string:"#388bfd",char:"#388bfd",integer:"#56d364",int:"#56d364",bigint:"#56d364",smallint:"#56d364",float:"#56d364",double:"#56d364",decimal:"#56d364",numeric:"#56d364",real:"#56d364",date:"#e3b341",timestamp:"#e3b341",datetime:"#e3b341",time:"#e3b341",boolean:"#f778ba",bool:"#f778ba",json:"#79c0ff",jsonb:"#79c0ff",uuid:"#d2a8ff",bytea:"#ffa657",binary:"#ffa657"};function FE(E,e){const t=E.toLowerCase().split("(")[0].trim();return IR[t]??e}function oR({t:E}){return A.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:8},children:[[1,2,3].map(e=>A.jsx("div",{style:{height:28,borderRadius:4,background:E.pillBg,opacity:.6,animation:"pulse 1.5s ease-in-out infinite"}},e)),A.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:.3} }"})]})}function aR(){const{state:E,dispatch:e}=f(),t=h[E.themeMode],[T,R]=L.useState(!1),r=async()=>{e({type:"SET_SCHEMA_LOADING",loading:!0});try{const s=await W.getSchema();e({type:"SET_SCHEMA",tables:s})}catch(s){console.error("Schema refresh failed:",s)}finally{e({type:"SET_SCHEMA_LOADING",loading:!1})}};return A.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[A.jsxs("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:6,borderBottom:`1px solid ${t.headerBorder}`},children:[A.jsxs("span",{style:{flex:1,fontSize:11,color:t.textMuted,fontFamily:t.font},children:[E.schemaTables.length," tables"]}),A.jsxs("button",{onClick:r,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),title:"Refresh schema",style:{background:T?t.btnHover:"transparent",border:`1px solid ${T?t.btnBorder:"transparent"}`,borderRadius:4,cursor:"pointer",color:T?t.textSecondary:t.textMuted,fontSize:11,fontFamily:t.font,padding:"2px 6px",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},children:[A.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:A.jsx("path",{d:"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z"})}),"Refresh"]})]}),E.schemaLoading?A.jsx(oR,{t}):E.schemaTables.length===0?A.jsxs("div",{style:{padding:"24px 14px",color:t.textMuted,fontSize:12,fontFamily:t.font,textAlign:"center",fontStyle:"italic"},children:["No tables found.",A.jsx("br",{}),"Connect a data source to explore schema."]}):A.jsx("div",{style:{overflow:"auto",flex:1},children:E.schemaTables.map(s=>A.jsx(NR,{table:s,t},s.name))})]})}function NR({table:E,t:e}){const{dispatch:t}=f(),[T,R]=L.useState(!1),[r,s]=L.useState(!1),S=async()=>{if(t({type:"TOGGLE_SCHEMA_TABLE",tableName:E.name}),!E.expanded&&E.columns.length===0){s(!0);try{const a=await W.describeTable(E.path);a.length>0&&t({type:"SET_TABLE_COLUMNS",tableName:E.name,columns:a})}catch(a){console.error("describeTable failed:",a)}finally{s(!1)}}};return A.jsxs("div",{children:[A.jsxs("button",{onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),onClick:S,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:T?e.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:e.textPrimary,fontSize:12,fontFamily:e.font,fontWeight:500,textAlign:"left",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:E.expanded?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0,color:e.textMuted},children:A.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),A.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{color:e.accent,flexShrink:0},children:A.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v1.5A1.75 1.75 0 0 1 14.25 5H1.75A1.75 1.75 0 0 1 0 3.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6C0 6.784.784 6 1.75 6h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 11H1.75A1.75 1.75 0 0 1 0 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Z"})}),A.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),E.columns.length>0&&A.jsx("span",{style:{fontSize:10,color:e.textMuted,background:e.pillBg,borderRadius:8,padding:"1px 5px",flexShrink:0},children:E.columns.length})]}),E.expanded&&A.jsx("div",{style:{paddingLeft:26},children:r?A.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:e.textMuted,fontFamily:e.font,fontStyle:"italic"},children:"..."}):E.columns.length===0?A.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:e.textMuted,fontFamily:e.font,fontStyle:"italic"},children:"No columns"}):E.columns.map(a=>A.jsx(iR,{col:a,t:e},a.name))})]})}function iR({col:E,t:e}){const[t,T]=L.useState(!1);return A.jsxs("div",{onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px 3px 8px",background:t?e.sidebarItemHover:"transparent",cursor:"default",transition:"background 0.1s"},children:[A.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",style:{color:e.textMuted,flexShrink:0},children:A.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})}),A.jsx("span",{style:{flex:1,fontSize:11,fontFamily:e.fontMono,color:e.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),A.jsx("span",{style:{fontSize:10,fontFamily:e.fontMono,color:FE(E.type,e.accent),background:`${FE(E.type,e.accent)}18`,borderRadius:4,padding:"1px 5px",flexShrink:0},children:E.type.toLowerCase()})]})}function lR(E){if(E.type==="markdown"){const e=E.content.match(/^#{1,6}\s+(.+)$/m);if(e)return e[1];const t=E.content.split(`
|
|
10
10
|
`).find(T=>T.trim());return(t==null?void 0:t.trim())||null}return E.name?E.name:null}function Gt(E){if(E.type!=="markdown")return 0;const e=E.content.match(/^(#{1,6})\s/m);return e?e[1].length:0}function LR({cell:E,t:e}){if(E.type==="markdown")return A.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:e.textMuted,flexShrink:0},children:[A.jsx("path",{d:"M14.85 3H7.39L6.74.translateX(.5.25C6.45.11 6.23 0 6 0H1.75A1.75 1.75 0 0 0 0 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0 0 16 14.25V4.75A1.75 1.75 0 0 0 14.25 3ZM1.5 1.75a.25.25 0 0 1 .25-.25H6l.5 1.5H1.5Z"}),A.jsx("path",{d:"M2 2h12v12H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});const t=E.type==="sql"?e.accent:e.warning;return A.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:t,flexShrink:0},children:A.jsx("path",{d:"M0 5.75C0 4.784.784 4 1.75 4h12.5c.966 0 1.75.784 1.75 1.75v4.5A1.75 1.75 0 0 1 14.25 12H1.75A1.75 1.75 0 0 1 0 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v4.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4.5a.25.25 0 0 0-.25-.25Z"})})}function CR({onNavigate:E}){const{state:e}=f(),t=h[e.themeMode];if(!e.activeFile)return A.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,textAlign:"center"},children:A.jsxs("div",{children:[A.jsx("svg",{width:"32",height:"32",viewBox:"0 0 16 16",fill:"currentColor",style:{color:t.textMuted,marginBottom:8},children:A.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM1.75 1.5a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"})}),A.jsx("div",{style:{fontSize:12,color:t.textMuted,fontFamily:t.font,lineHeight:1.5},children:"Open a notebook to see its outline."})]})});const T=e.cells.map(R=>({cell:R,label:lR(R)})).filter(R=>R.label!==null);return T.length===0?A.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,color:t.textMuted,fontSize:12,fontFamily:t.font,fontStyle:"italic",textAlign:"center"},children:["No named cells or headings yet.",A.jsx("br",{}),"Name your cells or add markdown headings."]}):A.jsx("div",{style:{flex:1,overflow:"auto",padding:"6px 0"},children:T.map(({cell:R,label:r})=>{const s=Gt(R),S=R.type==="markdown"?Math.max(0,(s-1)*12):0;return A.jsx(_R,{cell:R,label:r,indent:S,onClick:()=>E(R.id),t},R.id)})})}function _R({cell:E,label:e,indent:t,onClick:T,t:R}){const[r,s]=L.useState(!1);return A.jsxs("button",{onClick:T,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:`4px 10px 4px ${14+t}px`,background:r?R.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:r?R.textPrimary:R.textSecondary,fontSize:12,fontFamily:E.type==="markdown"?R.font:R.fontMono,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[A.jsx(LR,{cell:E,t:R}),A.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontWeight:E.type==="markdown"&&Gt(E)===1?600:400},children:e})]})}const cR={duckdb:"DuckDB",file:"Local File / DuckDB",postgres:"PostgreSQL",bigquery:"BigQuery",snowflake:"Snowflake",sqlite:"SQLite"},DR={duckdb:"#f4bc00",file:"#f4bc00",postgres:"#336791",bigquery:"#4285f4",snowflake:"#29b5e8",sqlite:"#003b57"};function dR(){const{state:E}=f(),e=h[E.themeMode],[t,T]=L.useState(null),[R,r]=L.useState(!1),[s,S]=L.useState(null);L.useEffect(()=>{W.getConnections().then(T)},[]);const a=async()=>{r(!0),S(null);const _=await W.testConnection();S(_),r(!1)},I={fontSize:10,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font,marginBottom:6},n={background:e.cellBg,border:`1px solid ${e.cellBorder}`,borderRadius:7,padding:"10px 12px",marginBottom:10},o=(t==null?void 0:t.connections)??{},O=(t==null?void 0:t.default)??"";return A.jsxs("div",{style:{flex:1,overflow:"auto",padding:"12px 12px 20px"},children:[A.jsx("div",{style:I,children:"Active Connection"}),t===null?A.jsx("div",{style:{fontSize:12,color:e.textMuted,fontFamily:e.font},children:"Loading…"}):Object.entries(o).map(([_,C])=>{const c=(C==null?void 0:C.driver)??(C==null?void 0:C.type)??"unknown",D=_===O||Object.keys(o).length===1,U=DR[c]??e.accent;return A.jsxs("div",{style:{...n,borderLeft:D?`3px solid ${U}`:`1px solid ${e.cellBorder}`},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[A.jsx("span",{style:{fontSize:10,fontWeight:700,fontFamily:e.fontMono,color:U,background:`${U}18`,border:`1px solid ${U}40`,borderRadius:4,padding:"1px 6px",letterSpacing:"0.05em",textTransform:"uppercase"},children:cR[c]??c}),D&&A.jsx("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font},children:"default"})]}),A.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:Object.entries(C??{}).filter(([u])=>u!=="driver"&&u!=="type").map(([u,p])=>A.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[A.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.fontMono,minWidth:70,flexShrink:0},children:u}),A.jsx("span",{style:{fontSize:11,color:e.textSecondary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.toLowerCase().includes("password")?"••••••••":String(p)})]},u))})]},_)}),A.jsx("button",{onClick:a,disabled:R,style:{width:"100%",padding:"7px 0",borderRadius:6,border:`1px solid ${e.btnBorder}`,background:e.btnBg,color:e.textSecondary,fontSize:12,fontFamily:e.font,fontWeight:500,cursor:R?"not-allowed":"pointer",marginBottom:8,opacity:R?.7:1,transition:"all 0.15s"},children:R?"Testing…":"Test Connection"}),s&&A.jsxs("div",{style:{fontSize:12,fontFamily:e.font,color:s.ok?e.success:e.error,background:s.ok?`${e.success}12`:`${e.error}12`,border:`1px solid ${s.ok?e.success:e.error}40`,borderRadius:6,padding:"7px 10px",marginBottom:12},children:[s.ok?"✓ ":"✗ ",s.message]}),A.jsx("div",{style:{...I,marginTop:4},children:"Change Connection"}),A.jsxs("div",{style:{...n,fontSize:12,fontFamily:e.font,color:e.textSecondary,lineHeight:1.6},children:["Edit ",A.jsx("code",{style:{fontFamily:e.fontMono,color:e.accent,fontSize:11},children:"dql.config.json"})," in your project root to add or switch connections. Supported drivers:",A.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:[{driver:"duckdb / file",desc:"Local CSV, Parquet, DuckDB"},{driver:"postgres",desc:"PostgreSQL / Supabase / RDS"},{driver:"bigquery",desc:"Google BigQuery"},{driver:"snowflake",desc:"Snowflake"}].map(({driver:_,desc:C})=>A.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[A.jsx("code",{style:{fontSize:10,fontFamily:e.fontMono,color:e.textMuted,minWidth:80,flexShrink:0},children:_}),A.jsx("span",{style:{fontSize:11,color:e.textMuted},children:C})]},_))})]}),A.jsx("div",{style:{...I,marginTop:4},children:"Example Config"}),A.jsx("pre",{style:{background:e.cellBg,border:`1px solid ${e.cellBorder}`,borderRadius:7,padding:"10px 12px",fontSize:11,fontFamily:e.fontMono,color:e.textSecondary,overflow:"auto",lineHeight:1.6,margin:0},children:`{
|
|
11
11
|
"connections": {
|
|
12
12
|
"default": {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-Bs6rpYwW.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/react-CRB3T2We.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-BeLuuzED.js">
|
|
13
13
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"directory": "apps/cli"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@duckcodeailabs/dql-connectors": "0.1.4",
|
|
22
23
|
"@duckcodeailabs/dql-core": "0.1.4",
|
|
23
24
|
"@duckcodeailabs/dql-compiler": "0.1.5",
|
|
24
|
-
"@duckcodeailabs/dql-governance": "0.1.5",
|
|
25
|
-
"@duckcodeailabs/dql-connectors": "0.1.4",
|
|
26
25
|
"@duckcodeailabs/dql-project": "0.1.5",
|
|
26
|
+
"@duckcodeailabs/dql-governance": "0.1.5",
|
|
27
27
|
"@duckcodeailabs/dql-notebook": "0.1.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|