@duckcodeailabs/dql-cli 0.1.6 → 0.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.
@@ -0,0 +1,158 @@
1
+ import{r as ge,a as Me,g as Le}from"./react-CRB3T2We.js";import{k as Be,i as Te,d as Ae,E as V,o as $e,s as De,l as Re,h as Oe,a as _e}from"./codemirror-CHXCUnwU.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var K={exports:{}},z={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var re;function Fe(){if(re)return z;re=1;var e=ge(),r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(a,c,x){var d,u={},p=null,m=null;x!==void 0&&(p=""+x),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)o.call(c,d)&&!l.hasOwnProperty(d)&&(u[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)u[d]===void 0&&(u[d]=c[d]);return{$$typeof:r,type:a,key:p,ref:m,props:u,_owner:i.current}}return z.Fragment=n,z.jsx=s,z.jsxs=s,z}var ie;function Ne(){return ie||(ie=1,K.exports=Fe()),K.exports}var t=Ne(),q={},le;function He(){if(le)return q;le=1;var e=Me();return q.createRoot=e.createRoot,q.hydrateRoot=e.hydrateRoot,q}var Ie=He(),f=ge();const U=Le(f),ze={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 Pe(e,r){switch(r.type){case"SET_THEME":return{...e,themeMode:r.mode};case"SET_SIDEBAR_PANEL":return{...e,sidebarPanel:r.panel,sidebarOpen:r.panel!==null};case"TOGGLE_SIDEBAR":return{...e,sidebarOpen:!e.sidebarOpen};case"SET_FILES":return{...e,files:r.files};case"SET_FILES_LOADING":return{...e,filesLoading:r.loading};case"OPEN_FILE":return{...e,activeFile:r.file,cells:r.cells,notebookTitle:r.title,notebookDirty:!1};case"SET_CELLS":return{...e,cells:r.cells,notebookDirty:!0};case"ADD_CELL":{if(!r.afterId)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const n=e.cells.findIndex(i=>i.id===r.afterId);if(n===-1)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const o=[...e.cells];return o.splice(n+1,0,r.cell),{...e,cells:o,notebookDirty:!0}}case"UPDATE_CELL":{const n=e.cells.map(i=>i.id===r.id?{...i,...r.updates}:i),o=r.updates.executionCount!==void 0?e.executionCounter+1:e.executionCounter;return{...e,cells:n,notebookDirty:!0,executionCounter:o}}case"DELETE_CELL":return{...e,cells:e.cells.filter(n=>n.id!==r.id),notebookDirty:!0};case"MOVE_CELL":{const n=e.cells.findIndex(i=>i.id===r.id);if(n===-1)return e;const o=[...e.cells];return r.direction==="up"&&n>0?[o[n-1],o[n]]=[o[n],o[n-1]]:r.direction==="down"&&n<o.length-1&&([o[n],o[n+1]]=[o[n+1],o[n]]),{...e,cells:o,notebookDirty:!0}}case"SET_SCHEMA":return{...e,schemaTables:r.tables};case"SET_SCHEMA_LOADING":return{...e,schemaLoading:r.loading};case"TOGGLE_SCHEMA_TABLE":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,expanded:!n.expanded}:n)};case"TOGGLE_DEV_PANEL":return{...e,devPanelOpen:!e.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...e,devPanelTab:r.tab};case"APPEND_QUERY_LOG":return{...e,queryLog:[...e.queryLog,r.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:r.dirty};case"SET_SAVING":return{...e,savingFile:r.saving};case"FILE_ADDED":return{...e,files:[...e.files,r.file]};case"SET_TABLE_COLUMNS":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,columns:r.columns}:n)};case"SET_PARAM_VALUE":return{...e,cells:e.cells.map(n=>n.id===r.id?{...n,paramValue:r.value}:n),notebookDirty:!0};default:return e}}const me=f.createContext(null);function We({children:e}){const[r,n]=f.useReducer(Pe,ze);return t.jsx(me.Provider,{value:{state:r,dispatch:n},children:e})}function w(){const e=f.useContext(me);if(!e)throw new Error("useNotebook must be used within NotebookProvider");return e}function R(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function A(e,r=""){const n={id:R(),type:e,content:r,status:"idle"};return e==="param"&&(n.content="",n.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),n}const Ze={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"},Ve={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"},S={dark:Ze,light:Ve};function P({title:e,active:r,onClick:n,children:o,t:i}){const[l,s]=f.useState(!1);return t.jsx("button",{title:e,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderLeft:r?`2px solid ${i.accent}`:"2px solid transparent",cursor:"pointer",color:r?i.textPrimary:l?i.textSecondary:i.textMuted,transition:"color 0.15s, border-color 0.15s",padding:0,flexShrink:0},children:o})}function qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Ue(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Ge(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Ke(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Ye(){const{state:e,dispatch:r}=w(),n=S[e.themeMode];function o(i){e.sidebarPanel===i&&e.sidebarOpen?r({type:"TOGGLE_SIDEBAR"}):r({type:"SET_SIDEBAR_PANEL",panel:i})}return t.jsxs("div",{style:{width:32,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,paddingBottom:8,gap:2,userSelect:"none"},children:[t.jsx(P,{title:"Files",active:e.sidebarPanel==="files"&&e.sidebarOpen,onClick:()=>o("files"),t:n,children:t.jsx(qe,{})}),t.jsx(P,{title:"Schema",active:e.sidebarPanel==="schema"&&e.sidebarOpen,onClick:()=>o("schema"),t:n,children:t.jsx(Ue,{})}),t.jsx(P,{title:"Outline",active:e.sidebarPanel==="outline"&&e.sidebarOpen,onClick:()=>o("outline"),t:n,children:t.jsx(Ge,{})}),t.jsx("div",{style:{flex:1}}),t.jsx(P,{title:"Help",active:!1,onClick:()=>{},t:n,children:t.jsx(Ke,{})}),t.jsx(P,{title:"Settings",active:!1,onClick:()=>{},t:n,children:t.jsx(Qe,{})})]})}const Q={notebooks:"Notebooks",workbooks:"Workbooks",blocks:"Blocks",dashboards:"Dashboards"};function Je({type:e}){switch(e){case"notebook":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.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 Xe({expanded:e}){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:e?t.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"}):t.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 et(e){return e.name.replace(/\.(dqlnb|dql)$/,"")}function tt({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState({notebooks:!0,workbooks:!0,blocks:!1,dashboards:!1}),[s,a]=f.useState(!1),c={notebooks:[],workbooks:[],blocks:[],dashboards:[]};for(const d of r.files){const u=d.folder.toLowerCase();u in c&&c[u].push(d)}const x=d=>{l(u=>({...u,[d]:!u[d]}))};return t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px 0",display:"flex",flexDirection:"column",gap:0},children:[t.jsx("div",{style:{padding:"0 8px 8px"},children:t.jsxs("button",{onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:"100%",height:30,background:"transparent",border:`1px dashed ${s?o.accent:o.cellBorder}`,borderRadius:6,color:s?o.accent:o.textSecondary,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[t.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"New Notebook"]})}),r.filesLoading&&t.jsx("div",{style:{padding:"8px 14px",color:o.textMuted,fontSize:12,fontFamily:o.font},children:"Loading files…"}),Object.keys(Q).map(d=>{const u=c[d],p=i[d];return t.jsxs("div",{children:[t.jsx(nt,{label:Q[d],count:u.length,expanded:p,onToggle:()=>x(d),t:o}),p&&t.jsx("div",{children:u.length===0?t.jsxs("div",{style:{padding:"4px 14px 4px 32px",fontSize:12,color:o.textMuted,fontFamily:o.font,fontStyle:"italic"},children:["No ",Q[d].toLowerCase()]}):u.map(m=>{var g;return t.jsx(ot,{file:m,active:((g=r.activeFile)==null?void 0:g.path)===m.path,onClick:()=>e(m),t:o},m.path)})})]},d)})]})}function nt({label:e,count:r,expanded:n,onToggle:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 10px",background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:i.textSecondary,fontSize:11,fontWeight:600,fontFamily:i.font,letterSpacing:"0.04em",textTransform:"uppercase",textAlign:"left",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx(Xe,{expanded:n}),t.jsx("span",{style:{flex:1},children:e}),r>0&&t.jsx("span",{style:{background:i.pillBg,color:i.textMuted,borderRadius:10,padding:"0 5px",fontSize:10,fontWeight:500},children:r})]})}function ot({file:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"4px 8px 4px 26px",background:r?o.sidebarItemActive:i?o.sidebarItemHover:"transparent",border:"none",borderLeft:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r||i?o.textPrimary:o.textSecondary,fontSize:13,fontFamily:o.font,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx("span",{style:{flexShrink:0,color:r?o.accent:o.textMuted},children:t.jsx(Je,{type:e.type})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:et(e)}),e.isNew&&t.jsx("span",{style:{fontSize:9,fontWeight:600,color:o.accent,background:o.sidebarItemActive,borderRadius:4,padding:"1px 4px",flexShrink:0},children:"NEW"})]})}const rt=window.location.origin;async function H(e,r){const n=await fetch(`${rt}${e}`,{headers:{"Content-Type":"application/json"},...r});if(!n.ok){const o=await n.text().catch(()=>n.statusText);throw new Error(o||`HTTP ${n.status}`)}if(n.status!==204)return n.json()}const $={async listNotebooks(){try{return await H("/api/notebooks")}catch{return[]}},async readNotebook(e){return H(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async createNotebook(e,r){return H("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:r})})},async saveNotebook(e,r){return H("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:r})})},async executeQuery(e){return H("/api/query",{method:"POST",body:JSON.stringify({sql:e})})},async getSchema(){try{return await H("/api/schema")}catch{return[]}},async describeTable(e){const n=`DESCRIBE SELECT * FROM read_csv_auto('${e.replace(/'/g,"''")}') LIMIT 0`;try{return(await H("/api/query",{method:"POST",body:JSON.stringify({sql:n})})).rows.map(i=>({name:String(i.column_name??i.Field??""),type:String(i.column_type??i.Type??"")}))}catch{return[]}}},it={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 se(e,r){const n=e.toLowerCase().split("(")[0].trim();return it[n]??r}function lt({t:e}){return t.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:8},children:[[1,2,3].map(r=>t.jsx("div",{style:{height:28,borderRadius:4,background:e.pillBg,opacity:.6,animation:"pulse 1.5s ease-in-out infinite"}},r)),t.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:.3} }"})]})}function st(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],[o,i]=f.useState(!1),l=async()=>{r({type:"SET_SCHEMA_LOADING",loading:!0});try{const s=await $.getSchema();r({type:"SET_SCHEMA",tables:s})}catch(s){console.error("Schema refresh failed:",s)}finally{r({type:"SET_SCHEMA_LOADING",loading:!1})}};return t.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:6,borderBottom:`1px solid ${n.headerBorder}`},children:[t.jsxs("span",{style:{flex:1,fontSize:11,color:n.textMuted,fontFamily:n.font},children:[e.schemaTables.length," tables"]}),t.jsxs("button",{onClick:l,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:"Refresh schema",style:{background:o?n.btnHover:"transparent",border:`1px solid ${o?n.btnBorder:"transparent"}`,borderRadius:4,cursor:"pointer",color:o?n.textSecondary:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},children:[t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:t.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?t.jsx(lt,{t:n}):e.schemaTables.length===0?t.jsxs("div",{style:{padding:"24px 14px",color:n.textMuted,fontSize:12,fontFamily:n.font,textAlign:"center",fontStyle:"italic"},children:["No tables found.",t.jsx("br",{}),"Connect a data source to explore schema."]}):t.jsx("div",{style:{overflow:"auto",flex:1},children:e.schemaTables.map(s=>t.jsx(at,{table:s,t:n},s.name))})]})}function at({table:e,t:r}){const{dispatch:n}=w(),[o,i]=f.useState(!1),[l,s]=f.useState(!1),a=async()=>{if(n({type:"TOGGLE_SCHEMA_TABLE",tableName:e.name}),!e.expanded&&e.columns.length===0){s(!0);try{const c=await $.describeTable(e.path);c.length>0&&n({type:"SET_TABLE_COLUMNS",tableName:e.name,columns:c})}catch(c){console.error("describeTable failed:",c)}finally{s(!1)}}};return t.jsxs("div",{children:[t.jsxs("button",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:a,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:o?r.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:r.textPrimary,fontSize:12,fontFamily:r.font,fontWeight:500,textAlign:"left",transition:"background 0.1s"},children:[t.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:r.textMuted},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.accent,flexShrink:0},children:t.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"})}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.columns.length>0&&t.jsx("span",{style:{fontSize:10,color:r.textMuted,background:r.pillBg,borderRadius:8,padding:"1px 5px",flexShrink:0},children:e.columns.length})]}),e.expanded&&t.jsx("div",{style:{paddingLeft:26},children:l?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"..."}):e.columns.length===0?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"No columns"}):e.columns.map(c=>t.jsx(dt,{col:c,t:r},c.name))})]})}function dt({col:e,t:r}){const[n,o]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px 3px 8px",background:n?r.sidebarItemHover:"transparent",cursor:"default",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:t.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"})}),t.jsx("span",{style:{flex:1,fontSize:11,fontFamily:r.fontMono,color:r.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx("span",{style:{fontSize:10,fontFamily:r.fontMono,color:se(e.type,r.accent),background:`${se(e.type,r.accent)}18`,borderRadius:4,padding:"1px 5px",flexShrink:0},children:e.type.toLowerCase()})]})}function ct(e){if(e.type==="markdown"){const r=e.content.match(/^#{1,6}\s+(.+)$/m);if(r)return r[1];const n=e.content.split(`
10
+ `).find(o=>o.trim());return(n==null?void 0:n.trim())||null}return e.name?e.name:null}function ye(e){if(e.type!=="markdown")return 0;const r=e.content.match(/^(#{1,6})\s/m);return r?r[1].length:0}function ut({cell:e,t:r}){if(e.type==="markdown")return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:[t.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"}),t.jsx("path",{d:"M2 2h12v12H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});const n=e.type==="sql"?r.accent:r.warning;return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n,flexShrink:0},children:t.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 pt({onNavigate:e}){const{state:r}=w(),n=S[r.themeMode];if(!r.activeFile)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,textAlign:"center"},children:t.jsxs("div",{children:[t.jsx("svg",{width:"32",height:"32",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n.textMuted,marginBottom:8},children:t.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"})}),t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,lineHeight:1.5},children:"Open a notebook to see its outline."})]})});const o=r.cells.map(i=>({cell:i,label:ct(i)})).filter(i=>i.label!==null);return o.length===0?t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic",textAlign:"center"},children:["No named cells or headings yet.",t.jsx("br",{}),"Name your cells or add markdown headings."]}):t.jsx("div",{style:{flex:1,overflow:"auto",padding:"6px 0"},children:o.map(({cell:i,label:l})=>{const s=ye(i),a=i.type==="markdown"?Math.max(0,(s-1)*12):0;return t.jsx(ft,{cell:i,label:l,indent:a,onClick:()=>e(i.id),t:n},i.id)})})}function ft({cell:e,label:r,indent:n,onClick:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:`4px 10px 4px ${14+n}px`,background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textSecondary,fontSize:12,fontFamily:e.type==="markdown"?i.font:i.fontMono,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx(ut,{cell:e,t:i}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontWeight:e.type==="markdown"&&ye(e)===1?600:400},children:r})]})}const xt={files:"Explorer",schema:"Schema",outline:"Outline"};function ht({onOpenFile:e,onNavigateToCell:r}){const{state:n,dispatch:o}=w(),i=S[n.themeMode],[l,s]=f.useState(!1),a=n.sidebarPanel;return t.jsxs("div",{style:{width:240,flexShrink:0,background:i.sidebarBg,borderRight:`1px solid ${i.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px 0 14px",borderBottom:`1px solid ${i.headerBorder}`},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:i.textSecondary,fontFamily:i.font},children:xt[a??""]??""}),t.jsx("button",{title:"Collapse sidebar",onClick:()=>o({type:"TOGGLE_SIDEBAR"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textMuted,padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,transition:"color 0.15s",display:"flex",alignItems:"center"},children:"‹"})]}),t.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[a==="files"&&t.jsx(tt,{onOpenFile:e}),a==="schema"&&t.jsx(st,{}),a==="outline"&&t.jsx(pt,{onNavigate:r})]})]})}function gt(e){try{const r=e.match(/workbook\s+"([^"]+)"/i),n=r?r[1]:"Untitled Workbook",o=[],i=/page\s+"([^"]+)"\s*\{([\s\S]*?)\}/gi;let l;for(;(l=i.exec(e))!==null;){const s=l[1],a=l[2].trim();o.push({id:R(),type:"markdown",content:`# ${s}`,status:"idle"}),a&&o.push({id:R(),type:"dql",name:s.toLowerCase().replace(/\s+/g,"_"),content:a,status:"idle"})}return o.length===0&&o.push({id:R(),type:"dql",content:e.trim(),status:"idle"}),{title:n,cells:o}}catch{return{title:"Untitled Workbook",cells:[{id:R(),type:"dql",content:e.trim(),status:"idle"}]}}}function mt(e){try{const r=JSON.parse(e),n=(r.cells||[]).map(o=>({id:o.id||R(),type:o.type||"sql",content:o.content||"",name:o.name,status:"idle",...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{}}));return{title:r.title||"Untitled",cells:n}}catch{return{title:"Untitled",cells:[{id:R(),type:"sql",content:e,status:"idle"}]}}}function yt(e,r){const n={version:1,title:e,cells:r.map(o=>({id:o.id,type:o.type,content:o.content,...o.name?{name:o.name}:{},...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{}}))};return JSON.stringify(n,null,2)}function bt(e,r){return e.endsWith(".dql")?gt(r):mt(r)}function vt(e,r){if(!r.columns.length||!r.rows.length)return`${e} AS (SELECT 1 WHERE 1=0)`;const n=r.columns,i=r.rows.slice(0,5e3).map(s=>`(${n.map(c=>{const x=s[c];return x==null?"NULL":typeof x=="number"?String(x):typeof x=="boolean"?x?"TRUE":"FALSE":`'${String(x).replace(/'/g,"''")}'`}).join(", ")})`).join(`,
11
+ `),l=n.map(s=>`"${s.replace(/"/g,'""')}"`).join(", ");return`${e} AS (
12
+ SELECT * FROM (VALUES
13
+ ${i}
14
+ ) AS _t(${l})
15
+ )`}function St(e,r){if(r==="number"){const n=Number(e);return isNaN(n)?`'${e.replace(/'/g,"''")}'`:String(n)}return`'${e.replace(/'/g,"''")}'`}function jt(){const{state:e}=w();return{substituteVariables:f.useCallback(n=>{var d;const o=/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,i=[...n.matchAll(o)];if(i.length===0)return{sql:n,substituted:[]};const l=[],s=[];let a=n;const c=new Map,x=new Map;for(const u of e.cells){const p=(d=u.name)==null?void 0:d.trim();p&&(u.type==="param"?c.set(p,u):u.status==="success"&&u.result&&x.set(p,u.result))}for(const u of i){const p=u[1];if(c.has(p)){const m=c.get(p),g=m.paramConfig,h=m.paramValue??(g==null?void 0:g.defaultValue)??"",y=(g==null?void 0:g.paramType)??"text",C=St(h,y);a=a.replace(u[0],C),l.push(p)}else x.has(p)&&(s.push(vt(p,x.get(p))),a=a.replace(u[0],`"${p}"`),l.push(p))}if(s.length===0&&l.length===0)return{sql:n,substituted:[]};if(s.length>0){const u=a.trimStart();/^WITH\s+/i.test(u)?a=a.replace(/^(\s*WITH\s+)/i,`$1${s.join(`,
16
+ `)},
17
+ `):a=`WITH ${s.join(`,
18
+ `)}
19
+ ${a}`}return{sql:a,substituted:l}},[e.cells])}}function wt(e){if(e.type==="markdown")return null;if(e.type==="sql")return e.content.trim()||null;const r=e.content.trim();if(!r)return null;const n=r.match(/\b(SELECT|WITH|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|SHOW|DESCRIBE|EXPLAIN)\b[\s\S]*/i);return n?n[0].trim():r}function oe(){const{state:e,dispatch:r}=w(),{substituteVariables:n}=jt(),o=f.useCallback(async l=>{const s=e.cells.find(d=>d.id===l);if(!s)return;const a=wt(s);if(!a)return;const{sql:c}=n(a),x=Date.now();r({type:"UPDATE_CELL",id:l,updates:{status:"running",error:void 0,result:void 0}});try{const d=await $.executeQuery(c),u=Date.now()-x,p=(s.executionCount??0)+1;r({type:"UPDATE_CELL",id:l,updates:{status:"success",result:{...d,executionTime:d.executionTime??u,rowCount:d.rowCount??d.rows.length},executionCount:p}}),r({type:"APPEND_QUERY_LOG",entry:{id:R(),cellName:s.name??s.id,rows:d.rowCount??d.rows.length,time:d.executionTime??u,ts:new Date}}),setTimeout(()=>{r({type:"UPDATE_CELL",id:l,updates:{status:"idle"}})},2e3)}catch(d){const u=Date.now()-x,p=d instanceof Error?d.message:String(d);r({type:"UPDATE_CELL",id:l,updates:{status:"error",error:p,executionCount:(s.executionCount??0)+1}}),r({type:"APPEND_QUERY_LOG",entry:{id:R(),cellName:s.name??s.id,rows:0,time:u,ts:new Date,error:p}})}},[e.cells,r]),i=f.useCallback(async()=>{for(const l of e.cells)l.type!=="markdown"&&await o(l.id)},[e.cells,o]);return{executeCell:o,executeAll:i}}function L(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function kt(e){return typeof e=="number"?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(2):""}function Et(e){const r=e.split(`
20
+ `),n=[];let o=!1,i=!1;for(const l of r){const s=l;if(s.startsWith("```")){i&&(n.push("</ul>"),i=!1),o?(n.push("</code></pre>"),o=!1):(n.push("<pre><code>"),o=!0);continue}if(o){n.push(L(s));continue}if(s.startsWith("### ")){i&&(n.push("</ul>"),i=!1),n.push(`<h3>${L(s.slice(4))}</h3>`);continue}if(s.startsWith("## ")){i&&(n.push("</ul>"),i=!1),n.push(`<h2>${L(s.slice(3))}</h2>`);continue}if(s.startsWith("# ")){i&&(n.push("</ul>"),i=!1),n.push(`<h1>${L(s.slice(2))}</h1>`);continue}if(s.startsWith("> ")){i&&(n.push("</ul>"),i=!1),n.push(`<blockquote><p>${L(s.slice(2))}</p></blockquote>`);continue}if(s.startsWith("- ")||s.startsWith("* ")){i||(n.push("<ul>"),i=!0),n.push(`<li>${ae(s.slice(2))}</li>`);continue}if(i&&(n.push("</ul>"),i=!1),s.trim()===""){n.push("<br>");continue}n.push(`<p>${ae(s)}</p>`)}return i&&n.push("</ul>"),o&&n.push("</code></pre>"),n.join(`
21
+ `)}function ae(e){return L(e).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>")}function Ct(e){const{columns:r,rows:n}=e,o=n.slice(0,200),i=n.length>200,l=r.map(a=>`<th>${L(a)}</th>`).join(""),s=o.map(a=>`<tr>${r.map(x=>{const d=a[x],u=typeof d=="number",p=d==null?"—":String(d);return`<td${u?' class="num"':""}>${L(p)}</td>`}).join("")}</tr>`).join("");return`
22
+ <div class="table-wrap">
23
+ <table>
24
+ <thead><tr>${l}</tr></thead>
25
+ <tbody>${s}</tbody>
26
+ </table>
27
+ ${i?`<p class="truncated">Showing first 200 of ${n.length.toLocaleString()} rows</p>`:""}
28
+ </div>`}function Mt(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return null;const o=r.find(l=>typeof n[0][l]=="number"),i=r.find(l=>l!==o);return!o||!i?null:{labelCol:i,valueCol:o}}function Lt(e){const r=Mt(e);if(!r)return null;const n=e.rows.slice(0,20).map(d=>({label:String(d[r.labelCol]??""),value:Number(d[r.valueCol]??0)})),o=Math.max(...n.map(d=>d.value),1),i=28,l=6,s=140,a=440,c=n.length*(i+l)+40,x=n.map((d,u)=>{const p=u*(i+l)+20,m=Math.max(d.value/o*a,2);return`
29
+ <text x="${s-6}" y="${p+i/2+4}" text-anchor="end" font-size="11" fill="#8b949e">${L(d.label.slice(0,20))}</text>
30
+ <rect x="${s}" y="${p}" width="${m}" height="${i}" rx="3" fill="#388bfd" />
31
+ <text x="${s+m+5}" y="${p+i/2+4}" font-size="11" fill="#e6edf3">${kt(d.value)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${s+a+80}" height="${c}" style="max-width:100%">${x}</svg>`}function Bt(e,r){const n=r.map(o=>{if(o.type==="markdown")return`<section class="cell md-cell">${Et(o.content)}</section>`;const i=o.name?`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span><span class="cell-name">${L(o.name)}</span></div>`:`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span></div>`,l=`<pre class="cell-code"><code>${L(o.content)}</code></pre>`;let s="";if(o.result&&o.result.rows.length>0){const a=Lt(o.result),c=Ct(o.result);s=`<div class="cell-output">${`<div class="output-meta">${o.result.rows.length.toLocaleString()} rows${o.result.executionTime?` · ${o.result.executionTime}ms`:""}</div>`}${a??""}${a?"":c}</div>`}else o.error&&(s=`<div class="cell-error">⚠ ${L(o.error)}</div>`);return`<section class="cell sql-cell">${i}${l}${s}</section>`}).join(`
32
+ `);return`<!DOCTYPE html>
33
+ <html lang="en">
34
+ <head>
35
+ <meta charset="UTF-8">
36
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
37
+ <title>${L(e)}</title>
38
+ <style>
39
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
40
+ body {
41
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
42
+ background: #0d1117; color: #e6edf3;
43
+ line-height: 1.6; padding: 0;
44
+ }
45
+ .page-header {
46
+ background: #161b22; border-bottom: 1px solid #21262d;
47
+ padding: 16px 32px; display: flex; align-items: center; gap: 12px;
48
+ }
49
+ .logo {
50
+ width: 28px; height: 28px; border-radius: 6px;
51
+ background: linear-gradient(135deg, #388bfd, #1f6feb);
52
+ display: flex; align-items: center; justify-content: center;
53
+ font-size: 10px; font-weight: 700; color: #fff;
54
+ font-family: monospace; letter-spacing: -0.5px; flex-shrink: 0;
55
+ }
56
+ .page-title { font-size: 18px; font-weight: 600; color: #e6edf3; }
57
+ .page-meta { font-size: 12px; color: #8b949e; margin-left: auto; }
58
+ .content { max-width: 900px; margin: 0 auto; padding: 32px 24px; display: flex; flex-direction: column; gap: 24px; }
59
+ .cell { border-radius: 8px; overflow: hidden; }
60
+ .md-cell { padding: 4px 0; }
61
+ .md-cell h1 { font-size: 26px; font-weight: 700; color: #e6edf3; margin: 0 0 12px; }
62
+ .md-cell h2 { font-size: 20px; font-weight: 600; color: #e6edf3; margin: 20px 0 10px; }
63
+ .md-cell h3 { font-size: 16px; font-weight: 600; color: #e6edf3; margin: 16px 0 8px; }
64
+ .md-cell p { color: #c9d1d9; margin-bottom: 8px; }
65
+ .md-cell ul { padding-left: 20px; color: #c9d1d9; margin-bottom: 8px; }
66
+ .md-cell code { background: #21262d; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: 13px; }
67
+ .md-cell pre { background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 14px; overflow-x: auto; margin-bottom: 8px; }
68
+ .md-cell pre code { background: none; padding: 0; }
69
+ .md-cell blockquote { border-left: 3px solid #388bfd; padding-left: 14px; color: #8b949e; }
70
+ .sql-cell { background: #161b22; border: 1px solid #30363d; }
71
+ .cell-header { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid #21262d; background: #1c2128; }
72
+ .cell-type { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; color: #8b949e; background: #21262d; padding: 2px 6px; border-radius: 4px; font-family: monospace; }
73
+ .cell-name { font-size: 12px; color: #388bfd; font-family: monospace; }
74
+ .cell-code { background: #0d1117; padding: 14px; font-size: 12px; font-family: 'JetBrains Mono', monospace; color: #c9d1d9; overflow-x: auto; border-bottom: 1px solid #21262d; line-height: 1.55; white-space: pre; }
75
+ .cell-output { padding: 14px; }
76
+ .output-meta { font-size: 11px; color: #8b949e; margin-bottom: 10px; }
77
+ .table-wrap { overflow-x: auto; }
78
+ table { width: 100%; border-collapse: collapse; font-size: 12px; }
79
+ th { background: #1c2128; color: #8b949e; font-weight: 600; text-align: left; padding: 7px 12px; border-bottom: 1px solid #30363d; white-space: nowrap; }
80
+ td { padding: 6px 12px; border-bottom: 1px solid #21262d; color: #e6edf3; }
81
+ td.num { text-align: right; font-family: monospace; }
82
+ tr:last-child td { border-bottom: none; }
83
+ .truncated { font-size: 11px; color: #8b949e; margin-top: 8px; }
84
+ .cell-error { padding: 12px 14px; background: #3d1a1a; border-top: 1px solid #f85149; color: #f85149; font-size: 13px; }
85
+ .exported-by { text-align: center; color: #484f58; font-size: 11px; padding: 40px 0 24px; }
86
+ </style>
87
+ </head>
88
+ <body>
89
+ <div class="page-header">
90
+ <div class="logo">DQL</div>
91
+ <span class="page-title">${L(e)}</span>
92
+ <span class="page-meta">Exported ${new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}</span>
93
+ </div>
94
+ <div class="content">
95
+ ${n}
96
+ </div>
97
+ <p class="exported-by">Built with DQL Notebook</p>
98
+ </body>
99
+ </html>`}function Tt(e,r){const n=Bt(e,r),o=new Blob([n],{type:"text/html;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function At(e,r){var l,s;const n=[];n.push(`workbook "${e}" {`);let o=0,i=0;for(const a of r)if(a.type!=="param"){if(a.type==="markdown"){i++;const c=`Markdown ${i}`;n.push(""),n.push(` page "${c}" {`);const x=a.content.split(`
100
+ `);for(const d of x)n.push(` // ${d}`);n.push(" }")}else if(a.type==="sql"){o++;const c=((l=a.name)==null?void 0:l.trim())||`Query ${o}`;n.push(""),n.push(` page "${c}" {`);const d=a.content.trim().split(`
101
+ `).map(u=>` ${u}`).join(`
102
+ `);n.push(" chart.table("),n.push(d+","),n.push(` title = "${c}"`),n.push(" )"),n.push(" }")}else if(a.type==="dql"){o++;const c=((s=a.name)==null?void 0:s.trim())||`Query ${o}`;n.push(""),n.push(` page "${c}" {`);const x=a.content.trim().split(`
103
+ `);for(const d of x)n.push(` ${d}`);n.push(" }")}}return n.push("}"),n.join(`
104
+ `)}function $t(e,r){const n=At(e,r),o=new Blob([n],{type:"text/plain;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a"),s=e.replace(/[^a-zA-Z0-9_-]/g,"_")+".dql";l.href=i,l.download=s,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function Dt({t:e}){return t.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function Rt(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],{executeAll:o}=oe(),[i,l]=f.useState(!1),[s,a]=f.useState(""),[c,x]=f.useState(!1),[d,u]=f.useState(!1),[p,m]=f.useState(!1),[g,h]=f.useState(!1),[y,C]=f.useState(!1),[E,k]=f.useState(!1),B=f.useRef(null),T=f.useRef(null);f.useEffect(()=>{i&&T.current&&(T.current.focus(),T.current.select())},[i]),f.useEffect(()=>{if(!E)return;function M(G){B.current&&!B.current.contains(G.target)&&k(!1)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[E]);const D=()=>{a(e.notebookTitle),l(!0)},O=()=>{l(!1),s.trim()&&s!==e.notebookTitle&&r({type:"SET_NOTEBOOK_DIRTY",dirty:!0})},I=f.useCallback(async()=>{if(e.activeFile){r({type:"SET_SAVING",saving:!0});try{const M=yt(e.notebookTitle,e.cells);await $.saveNotebook(e.activeFile.path,M),r({type:"SET_NOTEBOOK_DIRTY",dirty:!1}),x(!0),setTimeout(()=>x(!1),2e3)}catch(M){console.error("Save failed:",M)}finally{r({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.notebookTitle,e.cells,r]),_=()=>{r({type:"SET_THEME",mode:e.themeMode==="dark"?"light":"dark"})},v={height:28,padding:"0 10px",borderRadius:6,border:`1px solid ${n.btnBorder}`,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s",whiteSpace:"nowrap"};return t.jsxs("div",{style:{height:48,flexShrink:0,background:n.headerBg,borderBottom:`1px solid ${n.headerBorder}`,display:"flex",alignItems:"center",padding:"0 12px",gap:8,userSelect:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(Dt,{t:n}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile?i?t.jsx("input",{ref:T,value:s,onChange:M=>a(M.target.value),onBlur:O,onKeyDown:M=>{M.key==="Enter"&&O(),M.key==="Escape"&&l(!1)},style:{background:"transparent",border:`1px solid ${n.cellBorderActive}`,borderRadius:4,color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,padding:"2px 6px",outline:"none",minWidth:120,maxWidth:320}}):t.jsxs("span",{onClick:D,title:"Click to rename",style:{color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,cursor:"text",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"2px 4px",borderRadius:4,border:"1px solid transparent"},children:[e.notebookTitle||"Untitled",e.notebookDirty&&t.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):t.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:"DQL Notebook"})]}),t.jsx("div",{style:{flex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsxs("button",{onClick:o,disabled:!e.activeFile,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...v,background:(d&&e.activeFile,n.accent),color:"#ffffff",border:`1px solid ${n.accent}`,opacity:e.activeFile?d?.9:1:.4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run All"]}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsx("button",{onClick:_,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),title:e.themeMode==="dark"?"Switch to light mode":"Switch to dark mode",style:{...v,background:g?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 8px",fontSize:14},children:e.themeMode==="dark"?"☀":"☾"}),t.jsx("button",{onClick:I,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{...v,background:p&&e.activeFile?n.btnHover:n.btnBg,color:c?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?t.jsxs(t.Fragment,{children:[t.jsx(Ot,{}),"Saving…"]}):c?t.jsx(t.Fragment,{children:"✓ Saved"}):t.jsx(t.Fragment,{children:"Save"})}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsxs("div",{ref:B,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>{e.activeFile&&k(M=>!M)},disabled:!e.activeFile,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),title:"Export options",style:{...v,background:(y||E)&&e.activeFile?n.btnHover:n.btnBg,color:n.textSecondary,opacity:e.activeFile?1:.4},children:[t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"}),t.jsx("path",{d:"M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.779a.749.749 0 1 1 1.06-1.06l1.97 1.97Z"})]}),"Export",t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1},children:t.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),E&&t.jsxs("div",{style:{position:"absolute",top:32,right:0,zIndex:200,background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,minWidth:160,display:"flex",flexDirection:"column",gap:2},children:[t.jsx(de,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{Tt(e.notebookTitle||"dashboard",e.cells),k(!1)}}),t.jsx(de,{label:"Export .dql",description:"DQL workbook file",t:n,onClick:()=>{$t(e.notebookTitle||"notebook",e.cells),k(!1)}})]})]})]})]})}function de({label:e,description:r,t:n,onClick:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?n.btnHover:"transparent",border:"none",borderRadius:5,cursor:"pointer",padding:"6px 10px",textAlign:"left",display:"flex",flexDirection:"column",gap:1,transition:"background 0.12s"},children:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:r})]})}function Ot(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[t.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),t.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function _t(e){return e.toTimeString().slice(0,8)}function Ft(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function Nt(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],[o,i]=f.useState(!1),l=e.queryLog.filter(a=>a.error),s=a=>r({type:"SET_DEV_PANEL_TAB",tab:a});return t.jsxs("div",{style:{height:e.devPanelOpen?180:0,flexShrink:0,background:n.sidebarBg,borderTop:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden",transition:"height 0.2s ease",position:"relative"},children:[e.devPanelOpen&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{height:32,flexShrink:0,display:"flex",alignItems:"center",borderBottom:`1px solid ${n.headerBorder}`,padding:"0 8px",gap:2},children:[["logs","errors"].map(a=>t.jsx(Ht,{label:a==="errors"?`Errors${l.length>0?` (${l.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>s(a),t:n},a)),t.jsx("div",{style:{flex:1}}),t.jsx("button",{onClick:()=>r({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",border:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?t.jsx(ce,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(l.length===0?t.jsx(ce,{t:n,message:"No errors."}):[...l].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id)))]})]}),t.jsxs("button",{onClick:()=>r({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:e.devPanelOpen?"Close panel":"Open dev panel",style:{position:"absolute",bottom:e.devPanelOpen?4:-28,right:8,height:22,padding:"0 8px",borderRadius:"4px 4px 0 0",border:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:void 0,background:o?n.btnHover:n.sidebarBg,color:n.textMuted,cursor:"pointer",fontSize:11,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, bottom 0.2s ease",zIndex:10},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function Ht({label:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:"transparent",border:"none",borderBottom:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r?o.textPrimary:i?o.textSecondary:o.textMuted,fontSize:12,fontFamily:o.font,fontWeight:r?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function ce({t:e,message:r}){return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:r})}function ue({entry:e,t:r}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:r.fontMono,color:e.error?r.error:r.textSecondary,borderLeft:e.error?`2px solid ${r.error}`:"2px solid transparent"},children:[t.jsx("span",{style:{color:r.textMuted,flexShrink:0},children:_t(e.ts)}),t.jsx("span",{style:{flexShrink:0,color:r.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?t.jsx("span",{style:{color:r.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{style:{color:r.textMuted},children:[e.rows.toLocaleString()," rows"]}),t.jsx("span",{style:{color:r.textMuted},children:Ft(e.time)})]})]})}function It({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],i=r.files.slice(0,3);return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:o.appBg,padding:40,overflow:"auto"},children:t.jsxs("div",{style:{maxWidth:720,width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:48},children:[t.jsxs("div",{style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{style:{width:72,height:72,borderRadius:16,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 60%, #0d419d 100%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 32px rgba(56,139,253,0.3)"},children:t.jsx("span",{style:{color:"#fff",fontSize:26,fontWeight:800,fontFamily:o.fontMono,letterSpacing:"-1px"},children:"DQL"})}),t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:32,fontWeight:700,color:o.textPrimary,fontFamily:o.font,marginBottom:8,letterSpacing:"-0.5px"},children:"DQL Notebook"}),t.jsx("p",{style:{fontSize:15,color:o.textSecondary,fontFamily:o.font,letterSpacing:"0.02em"},children:"Analytics as Code"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16,width:"100%"},children:[t.jsx(pe,{title:"New Notebook",description:"Start a fresh analysis with an empty notebook.",icon:t.jsx(Wt,{}),accent:o.accent,onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),t:o}),t.jsx(zt,{recentFiles:i,onOpenFile:e,t:o}),t.jsx(pe,{title:"Browse Examples",description:"Explore sample notebooks and DQL workbooks.",icon:t.jsx(Vt,{}),accent:o.success,onClick:()=>{const l=r.files.find(s=>s.folder.toLowerCase()==="notebooks");l&&e(l)},t:o})]}),t.jsxs("div",{style:{width:"100%",borderRadius:10,border:`1px solid ${o.cellBorder}`,padding:"16px 20px",background:o.cellBg},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:o.textMuted,fontFamily:o.font,marginBottom:12},children:"Quick Tips"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[["Shift + Enter","Run cell"],["Click +","Add a new cell"],["Double-click MD cell","Edit markdown"],["Header title","Click to rename notebook"]].map(([l,s])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("kbd",{style:{background:o.pillBg,border:`1px solid ${o.cellBorder}`,borderRadius:4,padding:"2px 6px",fontSize:11,fontFamily:o.fontMono,color:o.textSecondary,whiteSpace:"nowrap"},children:l}),t.jsx("span",{style:{fontSize:12,color:o.textMuted,fontFamily:o.font},children:s})]},l))})]})]})})}function pe({title:e,description:r,icon:n,accent:o,onClick:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("button",{onClick:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{background:s?l.cellBg:"transparent",border:`1px solid ${s?o:l.cellBorder}`,borderRadius:10,padding:"20px 16px",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s, box-shadow 0.2s",boxShadow:s?`0 0 0 1px ${o}30, 0 4px 16px rgba(0,0,0,0.15)`:"none"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${o}18`,display:"flex",alignItems:"center",justifyContent:"center",color:o},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font,lineHeight:1.5},children:r})]})]})}function zt({recentFiles:e,onOpenFile:r,t:n}){const[o,i]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.cellBg:"transparent",border:`1px solid ${o?n.textMuted:n.cellBorder}`,borderRadius:10,padding:"20px 16px",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${n.warning}18`,display:"flex",alignItems:"center",justifyContent:"center",color:n.warning},children:t.jsx(Zt,{})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:n.font,marginBottom:8},children:"Open Recent"}),e.length===0?t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,fontStyle:"italic"},children:"No recent files."}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map(l=>t.jsx(Pt,{file:l,onClick:()=>r(l),t:n},l.path))})]})]})}function Pt({file:e,onClick:r,t:n}){const[o,i]=f.useState(!1);return t.jsx("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:o?n.accent:n.textSecondary,fontSize:12,fontFamily:n.font,textAlign:"left",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"color 0.15s"},children:e.name.replace(/\.(dqlnb|dql)$/,"")})}function Wt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Zm.5 3.25a.75.75 0 0 1 .75.75v.75h.75a.75.75 0 0 1 0 1.5H10v.75a.75.75 0 0 1-1.5 0V11.5H7.75a.75.75 0 0 1 0-1.5H8.5V9.5a.75.75 0 0 1 .75-.75Z"})})}function Zt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.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"})})}function Vt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.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.41 1.376a.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 be({value:e,onChange:r,onRun:n,themeMode:o,autoFocus:i}){const l=S[o],s=f.useRef(null),a=f.useRef(null),c=f.useRef(n),x=f.useRef(r);return c.current=n,x.current=r,f.useEffect(()=>{if(!s.current)return;const d=Be.of([{key:"Shift-Enter",run:()=>(c.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(c.current(),!0)},Te,...Ae]),u=V.updateListener.of(y=>{y.docChanged&&x.current(y.state.doc.toString())}),p=V.theme({"&":{background:l.editorBg,fontFamily:l.fontMono,fontSize:"13px",minHeight:"80px",maxHeight:"400px"},".cm-scroller":{overflow:"auto",fontFamily:"inherit"},".cm-content":{padding:"10px 0",minHeight:"80px"},".cm-focused":{outline:"none"},".cm-editor":{border:"none"}}),m=[d,u,p,De(),Re(),Oe(),V.lineWrapping,...o==="dark"?[$e]:[]],g=_e.create({doc:e,extensions:m}),h=new V({state:g,parent:s.current});return a.current=h,i&&h.focus(),()=>{h.destroy(),a.current=null}},[o]),f.useEffect(()=>{const d=a.current;if(!d)return;const u=d.state.doc.toString();u!==e&&d.dispatch({changes:{from:0,to:u.length,insert:e}})},[e]),t.jsx("div",{ref:s,style:{background:l.editorBg,minHeight:80}})}be.displayName="SQLCellEditor";function qt(e,r){const n=e.split(`
105
+ `),o=[];let i=0;for(;i<n.length;){const l=n[i],s=l.match(/^(#{1,6})\s+(.+)$/);if(s){const a=s[1].length,c=s[2],d=[28,22,18,16,14,13][a-1];o.push(t.jsx("div",{style:{fontSize:d,fontWeight:a<=2?700:600,color:r.textPrimary,fontFamily:r.font,lineHeight:1.3,marginBottom:a===1?12:8,marginTop:i>0?a===1?16:10:0,borderBottom:a===1?`1px solid ${r.cellBorder}`:void 0,paddingBottom:a===1?8:void 0},children:W(c,r)},i)),i++;continue}if(/^[-*_]{3,}$/.test(l.trim())){o.push(t.jsx("hr",{style:{border:"none",borderTop:`1px solid ${r.cellBorder}`,margin:"12px 0"}},i)),i++;continue}if(l.startsWith("> ")){o.push(t.jsx("div",{style:{borderLeft:`3px solid ${r.textMuted}`,paddingLeft:12,marginLeft:4,color:r.textSecondary,fontStyle:"italic",fontFamily:r.fontSerif,fontSize:14},children:W(l.slice(2),r)},i)),i++;continue}if(l.startsWith("```")){const a=[];for(i++;i<n.length&&!n[i].startsWith("```");)a.push(n[i]),i++;o.push(t.jsx("pre",{style:{background:r.editorBg,border:`1px solid ${r.cellBorder}`,borderRadius:6,padding:"10px 12px",fontSize:12,fontFamily:r.fontMono,color:r.textPrimary,overflow:"auto",margin:"8px 0",lineHeight:1.6},children:a.join(`
106
+ `)},i)),i++;continue}if(/^[-*+]\s/.test(l)){const a=[];for(;i<n.length&&/^[-*+]\s/.test(n[i]);)a.push(n[i].replace(/^[-*+]\s/,"")),i++;o.push(t.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(/^\d+\.\s/.test(l)){const a=[];for(;i<n.length&&/^\d+\.\s/.test(n[i]);)a.push(n[i].replace(/^\d+\.\s/,"")),i++;o.push(t.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(!l.trim()){o.push(t.jsx("div",{style:{height:8}},i)),i++;continue}o.push(t.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:r.fontSerif,color:r.textSecondary,marginBottom:6},children:W(l,r)},i)),i++}return o}function W(e,r){const n=[];let o=e,i=0;for(;o.length>0;){const l=o.match(/\*{3}(.+?)\*{3}/),s=o.match(/\*{2}(.+?)\*{2}/),a=o.match(/\*(.+?)\*/),c=o.match(/`(.+?)`/),x=o.match(/\[(.+?)\]\((.+?)\)/),d=[l?{match:l,type:"boldItalic"}:null,s?{match:s,type:"bold"}:null,a?{match:a,type:"italic"}:null,c?{match:c,type:"code"}:null,x?{match:x,type:"link"}:null].filter(Boolean);if(d.length===0){n.push(t.jsx(U.Fragment,{children:o},i++));break}const u=d.reduce((m,g)=>(m.match.index??0)<(g.match.index??0)?m:g),p=u.match.index??0;switch(p>0&&n.push(t.jsx(U.Fragment,{children:o.slice(0,p)},i++)),u.type){case"boldItalic":n.push(t.jsx("strong",{style:{fontStyle:"italic"},children:u.match[1]},i++));break;case"bold":n.push(t.jsx("strong",{children:u.match[1]},i++));break;case"italic":n.push(t.jsx("em",{children:u.match[1]},i++));break;case"code":n.push(t.jsx("code",{style:{background:r.editorBg,border:`1px solid ${r.cellBorder}`,borderRadius:4,padding:"1px 5px",fontSize:"0.9em",fontFamily:r.fontMono,color:r.accent},children:u.match[1]},i++));break;case"link":n.push(t.jsx("a",{href:u.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:r.accent,textDecoration:"underline"},children:u.match[1]},i++));break}o=o.slice(p+u.match[0].length)}return t.jsx(t.Fragment,{children:n})}function Ut({value:e,onChange:r,onRun:n,themeMode:o}){const i=S[o],[l,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(l&&a.current){a.current.focus();const u=a.current;u.style.height="auto",u.style.height=`${Math.max(u.scrollHeight,80)}px`}},[l]);const c=()=>{s(!1)},x=u=>{if(u.key==="Escape"&&s(!1),u.key==="Enter"&&u.shiftKey&&(u.preventDefault(),s(!1),n==null||n()),u.key==="Tab"){u.preventDefault();const p=u.currentTarget,m=p.selectionStart,g=p.selectionEnd,h=e.slice(0,m)+" "+e.slice(g);r(h),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=m+2})}},d=u=>{r(u.target.value);const p=u.target;p.style.height="auto",p.style.height=`${Math.max(p.scrollHeight,80)}px`};return l?t.jsx("textarea",{ref:a,value:e,onChange:d,onBlur:c,onKeyDown:x,placeholder:"Write markdown here...",spellCheck:!1,style:{display:"block",width:"100%",minHeight:80,padding:"12px 16px",background:i.editorBg,color:i.textPrimary,border:"none",outline:"none",resize:"none",fontFamily:i.fontMono,fontSize:13,lineHeight:"20px",borderRadius:0,caretColor:i.accent}}):e.trim()?t.jsx("div",{onDoubleClick:()=>s(!0),title:"Double-click to edit",style:{padding:"12px 16px",cursor:"text",minHeight:48},children:qt(e,i)}):t.jsx("div",{onDoubleClick:()=>s(!0),style:{padding:"12px 16px",color:i.textMuted,fontFamily:i.font,fontSize:13,fontStyle:"italic",cursor:"text",minHeight:48,display:"flex",alignItems:"center"},children:"Double-click to add markdown..."})}function Gt({cell:e,themeMode:r}){const{dispatch:n}=w(),o=S[r],[i,l]=f.useState(!1),s=e.paramConfig??{paramType:"text",label:"Parameter",defaultValue:"",options:[]},a=e.paramValue??s.defaultValue,c=p=>{n({type:"UPDATE_CELL",id:e.id,updates:{paramConfig:{...s,...p}}})},x=p=>{n({type:"SET_PARAM_VALUE",id:e.id,value:p})},d=(s.options??[]).map(p=>p.trim()).filter(Boolean),u=e.name?`{{${e.name}}}`:null;return t.jsxs("div",{style:{background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderLeft:"3px solid #e3b341",borderRadius:8,overflow:"hidden"},children:[i&&t.jsxs("div",{style:{background:o.tableHeaderBg,borderBottom:`1px solid ${o.cellBorder}`,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",color:"#e3b341",fontFamily:o.fontMono,textTransform:"uppercase"},children:"Configure Parameter"}),t.jsx("button",{onClick:()=>l(!1),title:"Done",style:{background:"#e3b341",border:"none",borderRadius:5,cursor:"pointer",color:"#000",fontSize:11,fontWeight:700,fontFamily:o.font,padding:"3px 10px",display:"flex",alignItems:"center",gap:4},children:"✓ Done"})]}),t.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Variable name"}),t.jsx("input",{value:e.name??"",onChange:p=>n({type:"UPDATE_CELL",id:e.id,updates:{name:p.target.value||void 0}}),placeholder:"e.g. start_date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Display label"}),t.jsx("input",{value:s.label,onChange:p=>c({label:p.target.value}),placeholder:"e.g. Start Date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 100px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Type"}),t.jsxs("select",{value:s.paramType,onChange:p=>c({paramType:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"},children:[t.jsx("option",{value:"text",children:"Text"}),t.jsx("option",{value:"number",children:"Number"}),t.jsx("option",{value:"date",children:"Date"}),t.jsx("option",{value:"select",children:"Select"})]})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Default value"}),t.jsx("input",{type:s.paramType==="number"?"number":s.paramType==="date"?"date":"text",value:s.defaultValue,onChange:p=>c({defaultValue:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]})]}),s.paramType==="select"&&t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Options (one per line)"}),t.jsx("textarea",{value:(s.options??[]).join(`
107
+ `),onChange:p=>c({options:p.target.value.split(`
108
+ `)}),rows:4,placeholder:`Option A
109
+ Option B
110
+ Option C`,style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"5px 7px",outline:"none",resize:"vertical"}})]})]}),t.jsxs("div",{style:{padding:"12px 14px",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[t.jsx("button",{onClick:()=>l(p=>!p),title:i?"Close config":"Configure parameter",style:{background:i?"#e3b34118":"transparent",border:`1px solid ${i?"#e3b341":o.cellBorder}`,borderRadius:5,cursor:"pointer",color:i?"#e3b341":o.textMuted,width:26,height:26,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s"},children:i?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.749.749 0 1 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"})}):t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.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.102-.302c-.067-.019-.177-.011-.3.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.102.302c.067.019.177.011.3-.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-.146a6.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"})})}),t.jsx("span",{style:{fontSize:13,fontWeight:500,fontFamily:o.font,color:o.textSecondary,flexShrink:0},children:s.label}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[s.paramType==="select"?t.jsx("select",{value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"5px 10px",outline:"none",minWidth:160},children:d.length===0?t.jsx("option",{value:"",children:"— no options configured —"}):d.map(p=>t.jsx("option",{value:p,children:p},p))}):t.jsx("input",{type:s.paramType,value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:s.paramType==="number"?o.fontMono:o.font,padding:"5px 10px",outline:"none",minWidth:160}}),u&&t.jsx("span",{style:{fontSize:10,fontFamily:o.fontMono,color:"#e3b341",opacity:.8},children:u})]}),a&&t.jsx("span",{style:{fontSize:12,fontFamily:o.fontMono,color:o.textPrimary,background:"#e3b34118",border:"1px solid #e3b34140",borderRadius:4,padding:"2px 8px",flexShrink:0},children:a})]})]})}const Y=500;function Kt(e){return typeof e=="number"?!0:typeof e=="string"?!isNaN(Number(e))&&e.trim()!=="":!1}function Qt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function ve({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.rows.slice(0,Y),s=e.rows.length>Y;return e.columns.length===0?t.jsx("div",{style:{padding:"12px 16px",color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):t.jsxs("div",{style:{maxHeight:400,overflow:"auto",position:"relative"},children:[t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"auto",fontSize:12,fontFamily:n.fontMono},children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(a=>t.jsx("th",{style:{background:n.tableHeaderBg,color:n.textSecondary,fontWeight:600,fontSize:11,textAlign:"left",padding:"6px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,minWidth:80,maxWidth:300,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:n.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis"},children:a},a))})}),t.jsx("tbody",{children:l.map((a,c)=>t.jsx("tr",{onMouseEnter:()=>i(c),onMouseLeave:()=>i(null),style:{background:o===c?n.tableRowHover:"transparent",transition:"background 0.1s"},children:e.columns.map(x=>{const d=a[x],u=d==null,p=Kt(d);return t.jsx("td",{style:{padding:"5px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,color:u?n.textMuted:n.textPrimary,fontStyle:u?"italic":"normal",textAlign:p?"right":"left",whiteSpace:"nowrap",maxWidth:300,overflow:"hidden",textOverflow:"ellipsis"},children:u?"—":Qt(d)},x)})},c))})]}),s&&t.jsxs("div",{style:{padding:"8px 12px",color:n.textMuted,fontSize:11,fontFamily:n.font,borderTop:`1px solid ${n.tableBorder}`,background:n.tableHeaderBg,fontStyle:"italic"},children:["Showing ",Y.toLocaleString()," of ",e.rows.length.toLocaleString()," rows"]})]})}const Yt=/date|time|at|day|month|year/i,Se=/^(label|name|category)$/i,je=/^(value|count|total|revenue|amount)$/i;function fe(e){return typeof e=="number"?!0:typeof e=="string"?e.trim()!==""&&!isNaN(Number(e)):!1}function Jt(e){return typeof e=="string"||typeof e=="number"}function te(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return"table";const o=r[0],i=r[1],l=n.slice(0,5),s=l.every(d=>fe(d[i])),a=l.every(d=>Jt(d[o]));if(Yt.test(o)&&s&&a)return"line";const c=r.find(d=>Se.test(d)),x=r.find(d=>je.test(d));return c&&x&&l.every(u=>fe(u[x]))||r.length===2&&a&&s?"bar":"table"}function ne(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}const J=20;function Xt({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.columns.find(y=>Se.test(y))??e.columns[0],s=e.columns.find(y=>je.test(y))??e.columns[1],a=e.rows.slice(0,J).map(y=>({label:String(y[l]??""),value:Number(y[s]??0)})),c=e.rows.length>J,x=Math.max(...a.map(y=>y.value),1),d=28,u=120,p=60,m=6,g=12,h=a.length*(d+m)+g*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("svg",{width:"100%",height:h,style:{display:"block",overflow:"visible"},viewBox:`0 0 600 ${h}`,preserveAspectRatio:"xMidYMid meet",children:a.map((y,C)=>{const E=g+C*(d+m),k=600-u-p-24,B=Math.max(y.value/x*k,2),T=o===C;return t.jsxs("g",{onMouseEnter:()=>i(C),onMouseLeave:()=>i(null),style:{cursor:"default"},children:[t.jsx("text",{x:u-8,y:E+d/2+4,textAnchor:"end",fontSize:11,fontFamily:n.font,fill:n.textSecondary,children:y.label.length>16?y.label.slice(0,15)+"…":y.label}),t.jsx("rect",{x:u,y:E,width:B,height:d,rx:3,fill:T?n.accentHover:n.accent,style:{transition:"fill 0.15s"}}),t.jsx("text",{x:u+B+6,y:E+d/2+4,textAnchor:"start",fontSize:11,fontFamily:n.fontMono,fill:n.textMuted,children:ne(y.value)})]},C)})}),c&&t.jsxs("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",J," of ",e.rows.length," rows"]})]})}function en(e){const r=new Date(e);if(!isNaN(r.getTime())){if(/^\d{4}-\d{2}-\d{2}/.test(e))return r.toLocaleDateString("en-US",{month:"short",day:"numeric"});if(/^\d{4}-\d{2}$/.test(e))return r.toLocaleDateString("en-US",{year:"numeric",month:"short"})}return String(e).length>8?String(e).slice(0,8):String(e)}function tn({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.columns[0],s=e.columns[1],a=e.rows.map(b=>({label:String(b[l]??""),value:Number(b[s]??0)}));if(a.length<2)return null;const c=560,x=200,d=52,u=16,p=16,m=36,g=c-d-u,h=x-p-m,y=Math.min(...a.map(b=>b.value)),E=Math.max(...a.map(b=>b.value))-y||1,k=g/(a.length-1),B=b=>d+b*k,T=b=>p+h-(b-y)/E*h,D=a.map((b,j)=>({x:B(j),y:T(b.value)})),O=D.reduce((b,j,F)=>{if(F===0)return`M ${j.x},${j.y}`;const N=D[F-1],we=N.x+(j.x-N.x)/2,ke=N.y,Ee=N.x+(j.x-N.x)/2,Ce=j.y;return`${b} C ${we},${ke} ${Ee},${Ce} ${j.x},${j.y}`},""),I=`${O} L ${D[D.length-1].x},${p+h} L ${d},${p+h} Z`,_=5,v=Array.from({length:_+1},(b,j)=>{const F=y+E*j/_,N=T(F);return{val:F,y:N}}),M=Math.ceil(a.length/8),G=a.filter((b,j)=>j%M===0||j===a.length-1);return t.jsx("div",{style:{position:"relative",padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:x,viewBox:`0 0 ${c} ${x}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[v.map((b,j)=>t.jsxs("g",{children:[t.jsx("line",{x1:d,y1:b.y,x2:d+g,y2:b.y,stroke:n.tableBorder,strokeWidth:.5}),t.jsx("text",{x:d-6,y:b.y+4,textAnchor:"end",fontSize:10,fontFamily:n.fontMono,fill:n.textMuted,children:ne(b.val)})]},j)),t.jsx("path",{d:I,fill:n.accent,opacity:.15}),t.jsx("path",{d:O,fill:"none",stroke:n.accent,strokeWidth:2,strokeLinejoin:"round"}),D.map((b,j)=>t.jsx("circle",{cx:b.x,cy:b.y,r:3,fill:n.accent,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:b.x,y:b.y,label:a[j].label,value:a[j].value})},j)),G.map((b,j)=>{const F=a.indexOf(b);return t.jsx("text",{x:B(F),y:p+h+16,textAnchor:"middle",fontSize:10,fontFamily:n.font,fill:n.textMuted,children:en(b.label)},j)}),t.jsx("line",{x1:d,y1:p,x2:d,y2:p+h,stroke:n.tableBorder,strokeWidth:1}),t.jsx("line",{x1:d,y1:p+h,x2:d+g,y2:p+h,stroke:n.tableBorder,strokeWidth:1}),o&&t.jsxs("g",{children:[t.jsx("rect",{x:o.x+8,y:o.y-20,width:90,height:32,rx:4,fill:n.cellBg,stroke:n.cellBorder,strokeWidth:1}),t.jsx("text",{x:o.x+13,y:o.y-8,fontSize:10,fontFamily:n.font,fill:n.textSecondary,children:o.label.length>10?o.label.slice(0,10)+"…":o.label}),t.jsx("text",{x:o.x+13,y:o.y+6,fontSize:11,fontFamily:n.fontMono,fill:n.textPrimary,fontWeight:600,children:ne(o.value)})]})]})})}function nn({result:e,themeMode:r}){const n=S[r],o=te(e),[i,l]=f.useState(o!=="table"?"chart":"table"),s=o!=="table";return t.jsxs("div",{children:[s&&t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"4px 12px",gap:4,borderBottom:`1px solid ${n.cellBorder}`,background:`${n.tableHeaderBg}60`},children:[t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font,marginRight:4},children:"View:"}),["chart","table"].map(a=>t.jsx("button",{onClick:()=>l(a),style:{padding:"2px 8px",fontSize:10,fontFamily:n.font,borderRadius:4,border:`1px solid ${i===a?n.accent:n.btnBorder}`,background:i===a?`${n.accent}20`:"transparent",color:i===a?n.accent:n.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:a==="chart"?o==="line"?"Line":"Chart":"Table"},a))]}),i==="table"||!s?t.jsx(ve,{result:e,themeMode:r}):o==="line"?t.jsx(tn,{result:e,themeMode:r}):t.jsx(Xt,{result:e,themeMode:r})]})}function on({message:e,themeMode:r}){const n=S[r];return t.jsxs("div",{style:{padding:"10px 14px",background:`${n.error}10`,borderLeft:`3px solid ${n.error}`,display:"flex",alignItems:"flex-start",gap:10},children:[t.jsx("div",{style:{flexShrink:0,marginTop:1,color:n.error},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}),t.jsx("pre",{style:{flex:1,margin:0,fontFamily:n.fontMono,fontSize:12,color:n.error,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}const rn={sql:"SQL",markdown:"MD",dql:"DQL",param:"PARAM"},X={sql:"#388bfd",markdown:"#56d364",dql:"#e3b341",param:"#e3b341"};function ln(e,r){switch(e.status){case"running":return r.cellBorderRunning;case"success":return r.success;case"error":return r.error;default:return r.cellBorder}}function sn({cell:e,t:r}){let n="",o=r.textMuted;return e.status==="running"?(n="[*]",o=r.cellBorderRunning):e.status==="error"?(n="[!]",o=r.error):e.executionCount!==void 0?(n=`[${e.executionCount}]`,o=r.textMuted):(n="[ ]",o=r.textMuted),t.jsx("div",{style:{width:40,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:12,flexShrink:0},children:t.jsx("span",{style:{fontFamily:r.fontMono,fontSize:11,color:o,lineHeight:1.4,userSelect:"none",transition:"color 0.2s"},children:n})})}function an({cell:e,index:r}){const{state:n,dispatch:o}=w(),i=S[n.themeMode],{executeCell:l}=oe(),[s,a]=f.useState(!1),[c,x]=f.useState(!1),[d,u]=f.useState(e.name??""),[p,m]=f.useState(!0),[g,h]=f.useState("table"),y=ln(e,i),C=e.type!=="markdown"&&e.type!=="param";if(e.type==="param")return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx("div",{style:{width:40,flexShrink:0}}),t.jsx("div",{style:{flex:1,minWidth:0},children:t.jsx(Gt,{cell:e,themeMode:n.themeMode})})]});f.useEffect(()=>{if(e.status==="success"&&e.result){const v=te(e.result);h(v!=="table"?"chart":"table")}},[e.status,e.result]);const E=f.useCallback(()=>{C&&l(e.id)},[e.id,l,C]),k=f.useCallback(v=>{o({type:"UPDATE_CELL",id:e.id,updates:{content:v}})},[e.id,o]),B=()=>{o({type:"DELETE_CELL",id:e.id})},T=()=>{o({type:"MOVE_CELL",id:e.id,direction:"up"})},D=()=>{o({type:"MOVE_CELL",id:e.id,direction:"down"})},O=()=>{x(!1),o({type:"UPDATE_CELL",id:e.id,updates:{name:d.trim()||void 0}})},I=(e.result||e.error)&&e.type!=="markdown",_=e.result?te(e.result)!=="table":!1;return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx(sn,{cell:e,t:i}),t.jsxs("div",{style:{flex:1,minWidth:0,borderRadius:8,border:`1px solid ${s||e.status!=="idle"?y:i.cellBorder}`,borderLeft:`2px solid ${y}`,background:i.cellBg,overflow:"hidden",transition:"border-color 0.2s"},children:[t.jsxs("div",{style:{height:32,display:"flex",alignItems:"center",padding:"0 8px 0 10px",gap:8,borderBottom:`1px solid ${i.cellBorder}`,background:`${i.tableHeaderBg}80`},children:[t.jsx("span",{style:{fontSize:10,fontWeight:700,fontFamily:i.fontMono,letterSpacing:"0.08em",color:X[e.type]??i.accent,background:`${X[e.type]??i.accent}18`,border:`1px solid ${X[e.type]??i.accent}40`,borderRadius:4,padding:"1px 6px",flexShrink:0,textTransform:"uppercase"},children:rn[e.type]}),c?t.jsx("input",{autoFocus:!0,value:d,onChange:v=>u(v.target.value),onBlur:O,onKeyDown:v=>{v.key==="Enter"&&O(),v.key==="Escape"&&x(!1)},style:{background:"transparent",border:`1px solid ${i.cellBorderActive}`,borderRadius:4,color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,padding:"1px 6px",outline:"none",width:140}}):e.name&&t.jsx("span",{onClick:()=>{u(e.name??""),x(!0)},title:"Click to rename",style:{color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:200},children:e.name}),t.jsx("div",{style:{flex:1}}),s&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[!e.name&&!c&&t.jsx(Z,{title:"Name this cell",onClick:()=>{u(""),x(!0)},t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"})})}),C&&t.jsx(Z,{title:"Run cell (Shift+Enter)",onClick:E,t:i,accent:!0,children:t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})})}),t.jsx(Z,{title:"Move up",onClick:T,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M3.47 7.78a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1-1.06 1.06L8.75 4.81v7.44a.75.75 0 0 1-1.5 0V4.81L4.53 7.78a.75.75 0 0 1-1.06 0Z"})})}),t.jsx(Z,{title:"Move down",onClick:D,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M12.53 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L2.97 9.28a.75.75 0 0 1 1.06-1.06l2.72 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.72-2.97a.75.75 0 0 1 1.06 0Z"})})}),t.jsx(Z,{title:"Delete cell",onClick:B,t:i,danger:!0,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"})})})]})]}),e.type==="markdown"?t.jsx(Ut,{value:e.content,onChange:k,themeMode:n.themeMode}):t.jsx(be,{value:e.content,onChange:k,onRun:E,themeMode:n.themeMode}),I&&t.jsxs("div",{style:{borderTop:`1px solid ${i.cellBorder}`},children:[t.jsxs("div",{style:{height:28,display:"flex",alignItems:"center",padding:"0 12px",gap:10,borderBottom:e.result&&p?`1px solid ${i.cellBorder}`:"none",background:`${i.tableHeaderBg}60`},children:[e.result&&t.jsxs("span",{style:{fontSize:11,fontFamily:i.font,color:i.textMuted},children:[(e.result.rowCount??e.result.rows.length).toLocaleString()," rows",e.result.executionTime!==void 0&&t.jsxs(t.Fragment,{children:[" · ",e.result.executionTime<1e3?`${e.result.executionTime}ms`:`${(e.result.executionTime/1e3).toFixed(2)}s`]})]}),e.error&&t.jsx("span",{style:{fontSize:11,fontFamily:i.font,color:i.error},children:"Error"}),t.jsx("div",{style:{flex:1}}),e.result&&_&&p&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:3},children:["chart","table"].map(v=>t.jsx("button",{onClick:()=>h(v),style:{padding:"1px 7px",fontSize:10,fontFamily:i.font,borderRadius:3,border:`1px solid ${g===v?i.accent:i.btnBorder}`,background:g===v?`${i.accent}20`:"transparent",color:g===v?i.accent:i.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:v==="chart"?"Chart":"Table"},v))}),t.jsxs("button",{onClick:()=>m(v=>!v),style:{background:"transparent",border:"none",cursor:"pointer",color:i.textMuted,fontSize:11,fontFamily:i.font,padding:"2px 4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:p?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s"},children:t.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",fill:"none",strokeWidth:"1.5"})}),p?"Hide":"Show"]})]}),p&&t.jsxs(t.Fragment,{children:[e.error&&t.jsx(on,{message:e.error,themeMode:n.themeMode}),e.result&&!e.error&&(g==="chart"&&_?t.jsx(nn,{result:e.result,themeMode:n.themeMode}):t.jsx(ve,{result:e.result,themeMode:n.themeMode}))]})]})]})]})}function Z({title:e,onClick:r,children:n,t:o,accent:i,danger:l}){const[s,a]=f.useState(!1);return t.jsx("button",{title:e,onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:s?l?`${o.error}18`:i?`${o.accent}18`:o.btnHover:"transparent",border:"none",borderRadius:4,cursor:"pointer",color:s?l?o.error:i?o.accent:o.textSecondary:o.textMuted,transition:"all 0.15s",padding:0},children:n})}const dn=[{type:"sql",label:"SQL",color:"#388bfd"},{type:"markdown",label:"Markdown",color:"#56d364"},{type:"dql",label:"DQL",color:"#e3b341"},{type:"param",label:"Param",color:"#e3b341"}];function ee({afterId:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState(!1),[s,a]=f.useState(!1),c=f.useRef(null);f.useEffect(()=>{if(!s)return;function d(u){c.current&&!c.current.contains(u.target)&&a(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const x=d=>{const u=A(d);n({type:"ADD_CELL",cell:u,afterId:e}),a(!1)};return t.jsxs("div",{ref:c,onMouseEnter:()=>l(!0),onMouseLeave:()=>{l(!1)},style:{position:"relative",height:28,display:"flex",alignItems:"center",justifyContent:"center",cursor:"default"},children:[t.jsx("div",{style:{position:"absolute",left:0,right:0,height:1,background:i||s?o.cellBorderActive:"transparent",transition:"background 0.15s"}}),(i||s)&&t.jsxs("button",{onClick:()=>a(d=>!d),style:{position:"relative",zIndex:2,height:22,padding:"0 10px",borderRadius:11,border:`1px solid ${o.cellBorderActive}`,background:`${o.accent}18`,color:o.accent,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s"},children:[t.jsx("span",{style:{fontSize:14,lineHeight:1,marginTop:-1},children:"+"}),"Add cell"]}),s&&t.jsx("div",{style:{position:"absolute",top:26,left:"50%",transform:"translateX(-50%)",zIndex:100,background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,display:"flex",gap:4},children:dn.map(({type:d,label:u,color:p})=>t.jsx(cn,{label:u,color:p,onClick:()=>x(d),t:o},d))})]})}function cn({label:e,color:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?`${r}18`:"transparent",border:`1px solid ${i?r:o.cellBorder}`,borderRadius:6,cursor:"pointer",color:i?r:o.textSecondary,fontSize:11,fontFamily:o.fontMono,fontWeight:600,padding:"4px 10px",letterSpacing:"0.04em",transition:"all 0.15s",whiteSpace:"nowrap"},children:e})}function un({registerCellRef:e}){const{state:r,dispatch:n}=w(),{executeCell:o}=oe(),i=S[r.themeMode],[l,s]=f.useState(null),a=f.useRef(0);return f.useCallback(c=>{s(c)},[]),f.useEffect(()=>{function c(x){var m;if(!l)return;const d=x.target;if(d.tagName==="TEXTAREA"||d.tagName==="INPUT"||d.isContentEditable||d.closest(".cm-editor")){s(null);return}const u=r.cells,p=u.findIndex(g=>g.id===l);if(p!==-1)switch(x.key){case"a":{x.preventDefault();const g=A("sql");if(p===0)n({type:"ADD_CELL",cell:g,afterId:u[0].id}),n({type:"MOVE_CELL",id:g.id,direction:"up"});else{const h=u[p-1].id;n({type:"ADD_CELL",cell:g,afterId:h})}s(g.id);break}case"b":{x.preventDefault();const g=A("sql");n({type:"ADD_CELL",cell:g,afterId:l}),s(g.id);break}case"d":{x.preventDefault();const g=Date.now();if(g-a.current<=500){if(n({type:"DELETE_CELL",id:l}),u.length>1){const h=p>0?p-1:1;s(((m=u[h])==null?void 0:m.id)??null)}else s(null);a.current=0}else a.current=g;break}case"Enter":{if(x.shiftKey){x.preventDefault();const g=u[p];g&&g.type!=="markdown"&&o(g.id)}break}}}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l,r.cells,n,o]),f.useEffect(()=>{function c(x){x.target.closest("[data-cell-id]")||s(null)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),r.cells.length===0?t.jsxs("div",{style:{maxWidth:860,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{}),t.jsx(pn,{t:i})]}):t.jsxs("div",{style:{maxWidth:860,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{afterId:void 0}),r.cells.map((c,x)=>t.jsxs(U.Fragment,{children:[t.jsx("div",{ref:d=>e(c.id,d),"data-cell-id":c.id,onClick:d=>{const u=d.target;!u.closest(".cm-editor")&&!u.closest("textarea")&&!u.closest("input")&&s(c.id)},style:{outline:l===c.id?`2px solid ${i.accent}40`:"none",outlineOffset:2,borderRadius:10,transition:"outline 0.1s"},children:t.jsx(an,{cell:c,index:x})}),t.jsx(ee,{afterId:c.id})]},c.id))]})}function pn({t:e}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 0",gap:12,color:e.textMuted},children:[t.jsx("svg",{width:"40",height:"40",viewBox:"0 0 16 16",fill:"currentColor",style:{opacity:.3},children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Z"})}),t.jsx("span",{style:{fontSize:13,fontFamily:e.font},children:"Empty notebook. Click + to add your first cell."})]})}function fn({onOpenFile:e,registerCellRef:r}){const{state:n}=w(),o=S[n.themeMode];return n.activeFile?t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:o.appBg},children:[t.jsx(xn,{t:o}),t.jsx("div",{style:{flex:1,overflow:"auto",padding:"24px 0 40px"},children:t.jsx(un,{registerCellRef:r})})]}):t.jsx(It,{onOpenFile:e})}function xn({t:e}){const{state:r}=w(),n=r.cells.length;return t.jsxs("div",{style:{height:32,flexShrink:0,borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",alignItems:"center",padding:"0 16px",gap:12},children:[t.jsx(hn,{t:e}),t.jsx("div",{style:{flex:1}}),t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font,display:"flex",alignItems:"center",gap:12},children:[t.jsxs("span",{children:[n," ",n===1?"cell":"cells"]}),r.notebookDirty&&t.jsx("span",{style:{color:e.warning},children:"● unsaved"})]})]})}function hn({t:e}){const{state:r}=w();if(!r.activeFile)return null;const n=r.activeFile.path.split("/").filter(Boolean);return t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontFamily:e.fontMono,color:e.textMuted,overflow:"hidden"},children:n.map((o,i)=>t.jsxs(U.Fragment,{children:[i>0&&t.jsx("span",{style:{color:e.textMuted,opacity:.5},children:"/"}),t.jsx("span",{style:{color:i===n.length-1?e.textSecondary:e.textMuted,fontWeight:i===n.length-1?500:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:i===n.length-1?200:100},children:o})]},i))})}const xe={blank:"Blank",revenue:"Revenue Analysis",pipeline:"Pipeline Health"},gn={blank:"Start with an empty notebook.",revenue:"Pre-built queries for revenue metrics and trends.",pipeline:"Templates for data pipeline health monitoring."};function he(e){return e.toLowerCase().replace(/[^a-z0-9\-_\s]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,64)}function mn(e){return e.trim()?/^[a-zA-Z0-9\-_ ]+$/.test(e)?null:"Only letters, numbers, hyphens, underscores, and spaces allowed.":"Name is required."}function yn(e){switch(e){case"revenue":return[A("markdown",`# Revenue Analysis
111
+
112
+ This notebook analyzes revenue metrics and trends over time.`),{...A("sql",`SELECT
113
+ DATE_TRUNC('month', order_date) AS month,
114
+ SUM(amount) AS revenue
115
+ FROM orders
116
+ GROUP BY 1
117
+ ORDER BY 1`),name:"monthly_revenue"},{...A("sql",`SELECT
118
+ product_category,
119
+ SUM(amount) AS total_revenue,
120
+ COUNT(*) AS orders
121
+ FROM orders
122
+ GROUP BY 1
123
+ ORDER BY 2 DESC`),name:"revenue_by_category"}];case"pipeline":return[A("markdown",`# Pipeline Health
124
+
125
+ Monitor data pipeline performance, SLA compliance, and error rates.`),{...A("sql",`SELECT
126
+ pipeline_name,
127
+ COUNT(*) AS runs,
128
+ AVG(duration_seconds) AS avg_duration,
129
+ SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failures
130
+ FROM pipeline_runs
131
+ GROUP BY 1
132
+ ORDER BY 4 DESC`),name:"pipeline_summary"},{...A("sql",`SELECT
133
+ *
134
+ FROM pipeline_runs
135
+ WHERE status = 'failed'
136
+ AND run_date >= CURRENT_DATE - INTERVAL '7 days'
137
+ ORDER BY run_date DESC`),name:"recent_failures"}];default:return[A("sql")]}}function bn({onFileOpened:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState(""),[s,a]=f.useState("blank"),[c,x]=f.useState(null),[d,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{var h;(h=p.current)==null||h.focus()},[]),f.useEffect(()=>{const h=y=>{y.key==="Escape"&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[n]);const m=async()=>{const h=mn(i);if(h){x(h);return}u(!0),x(null);const y=he(i),C=yn(s);try{const E=await $.createNotebook(y,s),k={name:`${y}.dqlnb`,path:E.path,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:k}),n({type:"OPEN_FILE",file:k,cells:C,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(k)}catch{const E=`notebooks/${y}.dqlnb`,k={name:`${y}.dqlnb`,path:E,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:k}),n({type:"OPEN_FILE",file:k,cells:C,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(k)}finally{u(!1)}},g=h=>{h.target===h.currentTarget&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return t.jsx("div",{onClick:g,style:{position:"fixed",inset:0,background:o.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:12,width:480,maxWidth:"calc(100vw - 48px)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h2",{style:{fontSize:16,fontWeight:600,color:o.textPrimary,fontFamily:o.font,margin:0},children:"New Notebook"}),t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:"transparent",border:"none",cursor:"pointer",color:o.textMuted,fontSize:18,lineHeight:1,padding:"2px 4px",borderRadius:4},children:"×"})]}),t.jsxs("div",{style:{padding:"20px 24px 24px",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Name"}),t.jsx("input",{ref:p,value:i,onChange:h=>{l(h.target.value),x(null)},onKeyDown:h=>{h.key==="Enter"&&m()},placeholder:"my-analysis",style:{background:o.inputBg,border:`1px solid ${c?o.error:o.inputBorder}`,borderRadius:6,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"8px 12px",outline:"none",transition:"border-color 0.15s"}}),c&&t.jsx("span",{style:{fontSize:11,color:o.error,fontFamily:o.font},children:c}),i&&!c&&t.jsxs("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono},children:["File: ",he(i),".dqlnb"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Template"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Object.keys(xe).map(h=>t.jsx(vn,{value:h,selected:s===h,onSelect:()=>a(h),label:xe[h],description:gn[h],t:o},h))})]})]}),t.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${o.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10},children:[t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:o.btnBg,border:`1px solid ${o.btnBorder}`,borderRadius:6,color:o.textSecondary,cursor:"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 16px"},children:"Cancel"}),t.jsx("button",{onClick:m,disabled:d||!i.trim(),style:{background:o.accent,border:`1px solid ${o.accent}`,borderRadius:6,color:"#ffffff",cursor:d||!i.trim()?"not-allowed":"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 20px",opacity:d||!i.trim()?.6:1,display:"flex",alignItems:"center",gap:6},children:d?"Creating…":"Create Notebook"})]})]})})}function vn({value:e,selected:r,onSelect:n,label:o,description:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${r?l.cellBorderActive:s?l.textMuted:l.inputBorder}`,background:r?`${l.cellBorderActive}10`:s?l.sidebarItemHover:"transparent",cursor:"pointer",transition:"all 0.15s"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:8,border:`2px solid ${r?l.accent:l.textMuted}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,transition:"border-color 0.15s"},children:r&&t.jsx("div",{style:{width:8,height:8,borderRadius:4,background:l.accent}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:500,color:l.textPrimary,fontFamily:l.font,marginBottom:2},children:o}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font},children:i})]})]})}function Sn(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],o=f.useRef({}),i=f.useCallback(async a=>{try{const{content:c}=await $.readNotebook(a.path),{title:x,cells:d}=bt(a.path,c);r({type:"OPEN_FILE",file:a,cells:d,title:x}),e.sidebarPanel!=="files"&&r({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(c){console.error("Failed to open file:",c),r({type:"OPEN_FILE",file:a,cells:[A("sql")],title:a.name})}},[r,e.sidebarPanel]),l=f.useCallback(a=>{const c=o.current[a];c&&c.scrollIntoView({behavior:"smooth",block:"start"})},[]),s=f.useCallback((a,c)=>{c?o.current[a]=c:delete o.current[a]},[]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[t.jsx(Rt,{}),t.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[t.jsx(Ye,{}),e.sidebarOpen&&t.jsx(ht,{onOpenFile:i,onNavigateToCell:l}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[t.jsx(fn,{onOpenFile:i,registerCellRef:s}),t.jsx(Nt,{})]})]}),e.newNotebookModalOpen&&t.jsx(bn,{onFileOpened:i})]})}function jn(){const{state:e,dispatch:r}=w(),n=f.useRef(null),o=f.useRef(null);f.useEffect(()=>{var i;n.current=((i=e.activeFile)==null?void 0:i.path)??null},[e.activeFile]),f.useEffect(()=>{if(typeof EventSource>"u")return;const i=()=>{const l=new EventSource(`${window.location.origin}/api/watch`);o.current=l,l.addEventListener("change",s=>{try{const a=JSON.parse(s.data);(a.type==="file-added"||a.type==="file-deleted")&&$.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})}),a.type==="file-changed"&&$.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})})}catch{}}),l.addEventListener("error",()=>{l.close(),setTimeout(i,5e3)})};return i(),()=>{var l;(l=o.current)==null||l.close(),o.current=null}},[r])}function wn(){const{state:e,dispatch:r}=w(),n=S[e.themeMode];return f.useEffect(()=>{const o="dql-global-styles";let i=document.getElementById(o);i||(i=document.createElement("style"),i.id=o,document.head.appendChild(i)),i.textContent=`
138
+ * { margin: 0; padding: 0; box-sizing: border-box; }
139
+ body {
140
+ font-family: ${n.font};
141
+ overflow: hidden;
142
+ background: ${n.appBg};
143
+ color: ${n.textPrimary};
144
+ }
145
+ ::-webkit-scrollbar { width: 6px; height: 6px; }
146
+ ::-webkit-scrollbar-track { background: transparent; }
147
+ ::-webkit-scrollbar-thumb {
148
+ background: ${n.scrollbarThumb};
149
+ border-radius: 3px;
150
+ }
151
+ ::-webkit-scrollbar-thumb:hover {
152
+ background: ${n.textMuted};
153
+ }
154
+ ::selection {
155
+ background: ${n.accent}40;
156
+ color: ${n.textPrimary};
157
+ }
158
+ `},[n]),f.useEffect(()=>{r({type:"SET_FILES_LOADING",loading:!0}),$.listNotebooks().then(o=>{r({type:"SET_FILES",files:o}),r({type:"SET_FILES_LOADING",loading:!1})})},[r]),f.useEffect(()=>{r({type:"SET_SCHEMA_LOADING",loading:!0}),$.getSchema().then(o=>{r({type:"SET_SCHEMA",tables:o}),r({type:"SET_SCHEMA_LOADING",loading:!1})})},[r]),jn(),t.jsx(Sn,{})}function kn(){return t.jsx(We,{children:t.jsx(wn,{})})}Ie.createRoot(document.getElementById("root")).render(t.jsx(kn,{}));