@marimo-team/frontend 0.22.6-dev9 → 0.23.1-dev1

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.
Files changed (29) hide show
  1. package/dist/assets/{JsonOutput-9XtRRx5l.js → JsonOutput-D_ORGqdz.js} +1 -1
  2. package/dist/assets/{add-connection-dialog-ux7eCDRM.js → add-connection-dialog-DGgtN73u.js} +1 -1
  3. package/dist/assets/{agent-panel-CdOqi3vb.js → agent-panel-D7gqlew5.js} +1 -1
  4. package/dist/assets/{cell-editor-CuHdpTsy.js → cell-editor-B2IIBFCB.js} +1 -1
  5. package/dist/assets/{column-preview-DrU255Z3.js → column-preview-DQBtRWJG.js} +1 -1
  6. package/dist/assets/{command-palette-DaEVrXkC.js → command-palette-BCrWwbIt.js} +1 -1
  7. package/dist/assets/{edit-page-DOK2VJe6.js → edit-page-fl9KJOcI.js} +3 -3
  8. package/dist/assets/{file-explorer-panel-CzYUz358.js → file-explorer-panel-bcSqGkbZ.js} +1 -1
  9. package/dist/assets/{form-BiDLPu7R.js → form-30oC5z9y.js} +1 -1
  10. package/dist/assets/{hooks-BgwM3Mb2.js → hooks-DLUrd-jH.js} +1 -1
  11. package/dist/assets/{index-DXwhLiKr.js → index-DTBKKey_.js} +11 -11
  12. package/dist/assets/{index-Dbq6ugUC.css → index-qO0a4zuT.css} +1 -1
  13. package/dist/assets/{layout-CF-7BNtf.js → layout-cq-nxDfO.js} +1 -1
  14. package/dist/assets/{panels-7-kbDRzv.js → panels-B5BFPT3k.js} +1 -1
  15. package/dist/assets/{run-page-9OQqe8IY.js → run-page-CI2eOA-G.js} +1 -1
  16. package/dist/assets/{scratchpad-panel-C8dGg-F9.js → scratchpad-panel-Dwp8-2S1.js} +1 -1
  17. package/dist/assets/{session-panel-BuzMiMf3.js → session-panel-ryqVmqVd.js} +1 -1
  18. package/dist/assets/{state-6D_2UAw3.js → state-CMxx6hcP.js} +1 -1
  19. package/dist/assets/{useNotebookActions-aodoqUGd.js → useNotebookActions-D8Dm93y8.js} +1 -1
  20. package/dist/index.html +6 -6
  21. package/package.json +1 -1
  22. package/src/components/data-table/TableTopBar.tsx +1 -1
  23. package/src/components/data-table/table-explorer-panel/table-explorer-panel.tsx +1 -1
  24. package/src/css/table.css +4 -0
  25. package/src/plugins/impl/common/labeled.tsx +5 -3
  26. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +4 -2
  27. package/src/plugins/impl/plotly/__tests__/PlotlyPlugin.test.tsx +50 -0
  28. package/src/plugins/impl/plotly/__tests__/selection.test.ts +73 -0
  29. package/src/plugins/impl/plotly/selection.ts +35 -3
@@ -42,7 +42,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
42
42
  `),o;return r&&(o=`<table>${l.map(i=>`<tr>${i.map(c=>`<td>${c.html??yy(c.text)}</td>`).join("")}</tr>`).join("")}</table>`),{text:a,html:o}}function yy(e){let t=document.createElement("div");return t.textContent=e,t.innerHTML}function xy(e){let t=0;for(let n of e)n.includes("__select__")||(t+=1);return t}function by(e,t){let n=[];for(let r of t){if(r.includes("__select__"))continue;let{rowId:l,columnId:a}=tu(r),o=e.getRow(l);if(!o)continue;let i=Pa(e,o.index,a)??o.getValue(a),c;if(typeof i=="number")c=i;else if(typeof i=="string"){if(i.trim()==="")continue;c=Number(i)}else continue;Number.isFinite(c)&&n.push(c)}return n}function Pr(e,t,n){var y,S;let r=e.getRow(t.rowId),l=e.getRow(n.rowId);if(!r||!l)return[];let a=r.index,o=l.index,i=(y=e.getColumn(t.columnId))==null?void 0:y.getIndex(),c=(S=e.getColumn(n.columnId))==null?void 0:S.getIndex();if(i===void 0||c===void 0)return[];let u=Math.min(a,o),m=Math.max(a,o),p=Math.min(i,c),d=Math.max(i,c),g=[];g.length=(m-u+1)*(d-p+1);let f=0,x=e.getAllColumns().map(v=>v.id),w=e.getRowModel().rows;for(let v=u;v<=m;v++){let j=w[v].id;for(let k=p;k<=d;k++){let C=x[k];g[f++]=vy(j,C)}}return g.length=f,g}function vy(e,t){return`${e}_${t}`}function tu(e){let t=e.indexOf("_");return{rowId:e.slice(0,t),columnId:e.slice(t+1)}}function wy(){return{selectedCells:new Set,copiedCells:new Set,selectedStartCell:null,focusedCell:null,isSelecting:!1}}var{valueAtom:Pt,useActions:Sy,createActions:Ow,reducer:$w}=wv(wy,{setSelectedCells:(e,t)=>({...e,selectedCells:t}),setSelectedStartCell:(e,t)=>({...e,selectedStartCell:t}),setFocusedCell:(e,t)=>({...e,focusedCell:t}),setIsSelecting:(e,t)=>({...e,isSelecting:t}),setCopiedCells:(e,t)=>({...e,copiedCells:t}),clearSelection:e=>({...e,selectedCells:new Set,selectedStartCell:null,focusedCell:null}),selectAllCells:(e,t)=>{let n=t.getRowModel().rows.flatMap(r=>r.getAllCells().map(l=>l.id));return{...e,selectedCells:new Set(n)}},toggleCurrentRowSelection:(e,t)=>{var r,l;let n=e.focusedCell;return n!=null&&n.rowId&&((l=(r=t.getRow(n==null?void 0:n.rowId))==null?void 0:r.toggleSelected)==null||l.call(r)),e},updateSelection:(e,{newCell:t,isShiftKey:n,table:r})=>{if(n&&e.selectedStartCell){let l=Pr(r,e.selectedStartCell,t);return{...e,selectedCells:new Set(l),focusedCell:t}}else return{...e,selectedCells:new Set([t.cellId]),selectedStartCell:t,focusedCell:t}},updateRangeSelection:(e,{cell:t,table:n})=>{if(!e.selectedStartCell)return e;let r={rowId:t.row.id,columnId:t.column.id,cellId:t.id},l=Pr(n,e.selectedStartCell,r);return l.length>1&&ky(),{...e,selectedCells:new Set(l)}},handleCopy:(e,{table:t,onCopyComplete:n})=>{let r=window.getSelection();if(r&&r.toString().length>0)return e;let{text:l,html:a}=hy(t,e.selectedCells);return an(l,a),n(),{...e,copiedCells:e.selectedCells}},navigate:(e,{direction:t,isShiftKey:n,table:r})=>{let l=e.focusedCell??e.selectedStartCell;if(!l)return e;let a;if(t==="up"||t==="down"){let i=r.getRowModel().rows,c=i.findIndex(m=>m.id===l.rowId);if(c<0)return e;let u=t==="up"?i[c-1]:i[c+1];if(!u)return e;a=u.getAllCells().find(m=>m.column.id===l.columnId)}if(t==="left"||t==="right"){let i=r.getRow(l.rowId).getAllCells(),c=i.findIndex(u=>u.id===l.cellId);if(c<0)return e;a=t==="left"?i[c-1]:i[c+1]}if(!a)return e;let o={rowId:a.row.id,columnId:a.column.id,cellId:a.id};if(n&&e.selectedStartCell){let i=Pr(r,e.selectedStartCell,o);return{...e,selectedCells:new Set(i),focusedCell:o}}else return{...e,selectedCells:new Set([o.cellId]),selectedStartCell:o,focusedCell:o}},handleCellMouseDown:(e,{cell:t,isShiftKey:n,isCtrlKey:r,table:l})=>{let a={rowId:t.row.id,columnId:t.column.id,cellId:t.id};if(n&&e.selectedStartCell){let o=Pr(l,e.selectedStartCell,a);return{...e,selectedCells:new Set(o),isSelecting:!0}}return r?e:e.selectedCells.size===1&&e.selectedCells.has(a.cellId)?{...e,selectedCells:new Set,selectedStartCell:null,focusedCell:null}:{...e,selectedCells:new Set([a.cellId]),selectedStartCell:a,focusedCell:a,isSelecting:!0}}});const Ha=Pe(e=>e(Pt).selectedCells),Cy=Pe(e=>e(Pt).copiedCells);Pe(e=>e(Pt).selectedStartCell),Pe(e=>e(Pt).focusedCell),Pe(e=>e(Pt).isSelecting);const jy=e=>Pe(t=>{let n=t(Ha),r=t(Cy);return{isSelected:n.has(e),isCopied:r.has(e)}}),ky=()=>{var e;window.getSelection&&((e=window.getSelection())==null||e.empty())};var _y=L();const Ry=e=>{let t=(0,_y.c)(3),{children:n}=e,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[Pt],t[0]=r):r=t[0];let l;return t[1]===n?l=t[2]:(l=(0,s.jsx)(gy,{atoms:r,children:n}),t[1]=n,t[2]=l),l};function Yt(e,t,n){let r=n.initialDeps??[],l,a=!0;function o(){var m,p,d;let i;n.key&&((m=n.debug)!=null&&m.call(n))&&(i=Date.now());let c=e();if(!(c.length!==r.length||c.some((g,f)=>r[f]!==g)))return l;r=c;let u;if(n.key&&((p=n.debug)!=null&&p.call(n))&&(u=Date.now()),l=t(...c),n.key&&((d=n.debug)==null?void 0:d.call(n))){let g=Math.round((Date.now()-i)*100)/100,f=Math.round((Date.now()-u)*100)/100,x=f/16,w=(y,S)=>{for(y=String(y);y.length<S;)y=" "+y;return y};console.info(`%c\u23F1 ${w(f,5)} /${w(g,5)} ms`,`
43
43
  font-size: .6rem;
44
44
  font-weight: bold;
45
- color: hsl(${Math.max(0,Math.min(120-120*x,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(l),a=!1,l}return o.updateDeps=i=>{r=i},o}function nu(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var My=(e,t)=>Math.abs(e-t)<1.01,Ny=(e,t,n)=>{let r;return function(...l){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,l),n)}},ru=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Fy=e=>e,Ay=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let l=t;l<=n;l++)r.push(l);return r},Iy=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let l=o=>{let{width:i,height:c}=o;t({width:Math.round(i),height:Math.round(c)})};if(l(ru(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(o=>{let i=()=>{let c=o[0];if(c!=null&&c.borderBoxSize){let u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(ru(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},lu={passive:!0},au=typeof window>"u"?!0:"onscrollend"in window,Ey=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let l=0,a=e.options.useScrollendEvent&&au?()=>{}:Ny(r,()=>{t(l,!1)},e.options.isScrollingResetDelay),o=m=>()=>{let{horizontal:p,isRtl:d}=e.options;l=p?n.scrollLeft*(d&&-1||1):n.scrollTop,a(),t(l,m)},i=o(!0),c=o(!1);n.addEventListener("scroll",i,lu);let u=e.options.useScrollendEvent&&au;return u&&n.addEventListener("scrollend",c,lu),()=>{n.removeEventListener("scroll",i),u&&n.removeEventListener("scrollend",c)}},Py=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Oy=(e,{adjustments:t=0,behavior:n},r)=>{var i;var l,a;let o=e+t;(a=(i=l=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})},$y=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,l;var t;return((l=(r=t=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:l.call(t))??Date.now()},this.observer=(()=>{let t=null,n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(l=>{let a=()=>{let o=l.target,i=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(o,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var l;return(l=n())==null?void 0:l.observe(r,{box:"border-box"})},unobserve:r=>{var l;return(l=n())==null?void 0:l.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([n,r])=>{r===void 0&&delete t[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Fy,rangeExtractor:Ay,onChange:()=>{},measureElement:Py,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=Yt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,n)=>{let r=new Map,l=new Map;for(let a=n-1;a>=0;a--){let o=t[a];if(r.has(o.lane))continue;let i=l.get(o.lane);if(i==null||o.end>i.end?l.set(o.lane,o):o.end<i.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Yt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,n,r,l,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=Yt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(let p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,c),m=Array(o).fill(void 0);for(let p=0;p<c;p++){let d=u[p];d&&(m[d.lane]=p)}for(let p=c;p<t;p++){let d=l(p),g=this.laneAssignments.get(p),f,x;if(g!==void 0&&this.options.lanes>1){f=g;let v=m[f],j=v===void 0?void 0:u[v];x=j?j.end+this.options.gap:n+r}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);x=v?v.end+this.options.gap:n+r,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let w=i.get(d),y=typeof w=="number"?w:this.options.estimateSize(p),S=x+y;u[p]={index:p,start:x,size:y,end:S,key:d,lane:f},m[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,l)=>this.range=t.length>0&&n>0?Ty({measurements:t,outerSize:n,scrollOffset:r,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yt(()=>{let t=null,n=null,r=this.calculateRange();return r&&(t=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,n]},(t,n,r,l,a)=>l===null||a===null?[]:t({startIndex:l,endIndex:a,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{let n=this.options.indexAttribute,r=t.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let n=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(n!==void 0&&this.range){let l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,n-l),o=Math.min(this.options.count-1,n+l);return t>=a&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}let n=this.indexFromElement(t),r=this.options.getItemKey(n),l=this.elementsCache.get(r);l!==t&&(l&&this.observer.unobserve(l),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,n)=>{var a;let r=this.measurementsCache[t];if(!r)return;let l=n-(this.itemSizeCache.get(r.key)??r.size);l!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,n)),this.notify(!1))},this.getVirtualItems=Yt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{let r=[];for(let l=0,a=t.length;l<a;l++){let o=n[t[l]];r.push(o)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{let n=this.getMeasurements();if(n.length!==0)return nu(n[ou(0,n.length-1,r=>nu(n[r]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,n,r=0)=>{if(!this.scrollElement)return 0;let l=this.getSize(),a=this.getScrollOffset();n==="auto"&&(n=t>=a+l?"end":"start"),n==="center"?t+=(r-l)/2:n==="end"&&(t-=l);let o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,n="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));let r=this.getSize(),l=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(n==="auto")if(a.end>=l+r-this.options.scrollPaddingEnd)n="end";else if(a.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];let o=n==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,a.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{let l=this.getOffsetForAlignment(t,n);this.scrollState={index:null,align:n,behavior:r,startedAt:this.now(),lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:n="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));let l=this.getOffsetForIndex(t,n);if(!l)return;let[a,o]=l,i=this.now();this.scrollState={index:t,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{let r=this.getScrollOffset()+t;this.scrollState={index:null,align:"start",behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((r=t[t.length-1])==null?void 0:r.end)??0;else{let l=Array(this.options.lanes).fill(null),a=t.length-1;for(;a>=0&&l.some(o=>o===null);){let o=t[a];l[o.lane]===null&&(l[o.lane]=o.end),a--}n=Math.max(...l.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:n,behavior:r})=>{this.options.scrollToFn(t,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&My(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior="auto",this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},ou=(e,t,n,r)=>{for(;e<=t;){let l=(e+t)/2|0,a=n(l);if(a<r)e=l+1;else if(a>r)t=l-1;else return l}return e>0?e-1:0};function Ty({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let l=e.length-1,a=c=>e[c].start;if(e.length<=r)return{startIndex:0,endIndex:l};let o=ou(0,l,a,n),i=o;if(r===1)for(;i<l&&e[i].end<n+t;)i++;else if(r>1){let c=Array(r).fill(0);for(;i<l&&c.some(m=>m<n+t);){let m=e[i];c[m.lane]=m.end,i++}let u=Array(r).fill(n+t);for(;o>=0&&u.some(m=>m>=n);){let m=e[o];u[m.lane]=m.start,o--}o=Math.max(0,o-o%r),i=Math.min(l,i+(r-1-i%r))}return{startIndex:o,endIndex:i}}var zy=wb(),iu=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Vy({useFlushSync:e=!0,...t}){let n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(a,o)=>{var i;e&&o?(0,zy.flushSync)(n):n(),(i=t.onChange)==null||i.call(t,a,o)}},[l]=b.useState(()=>new $y(r));return l.setOptions(r),iu(()=>l._didMount(),[]),iu(()=>l._willUpdate()),l}function Dy(e){return Vy({observeElementRect:Iy,observeElementOffset:Ey,scrollToFn:Oy,...e})}let mt,Ba,su,cu,uu;mt=L(),Oo=Hd,So=Bd,Ba=Ab(Wd),su=Lu(ni),cu=Lu(ui),uu=b.forwardRef((e,t)=>{let n=(0,mt.c)(14),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:l,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==l||n[6]!==a?(i=Ob({className:l,inset:a}),n[5]=l,n[6]=a,n[7]=i):i=n[7];let c;n[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(fw,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==i?(u=(0,s.jsxs)(ci,{ref:t,className:i,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=i,n[13]=u):u=n[13],u}),uu.displayName=ci.displayName;var du="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",Ly=b.forwardRef((e,t)=>{let n=(0,mt.c)(9),r,l;n[0]===e?(r=n[1],l=n[2]):({className:r,...l}=e,n[0]=e,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=$(Bu({subcontent:!0}),du,r),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==t||n[7]!==a?(o=(0,s.jsx)(cu,{ref:t,className:a,...l}),n[5]=l,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ly.displayName=ui.displayName,ul=b.forwardRef((e,t)=>{let n=(0,mt.c)(15),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:r,scrollable:a,...l}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o=a===void 0?!0:a,i;n[4]!==r||n[5]!==o?(i=$(Bu(),du,o&&"overflow-auto",r),n[4]=r,n[5]=o,n[6]=i):i=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${Ib}px)`:void 0,u;n[7]!==l.style||n[8]!==c?(u={...l.style,maxHeight:c},n[7]=l.style,n[8]=c,n[9]=u):u=n[9];let m;return n[10]!==l||n[11]!==t||n[12]!==i||n[13]!==u?(m=(0,s.jsx)(Ba,{children:(0,s.jsx)(Nb,{children:(0,s.jsx)(su,{ref:t,className:i,style:u,...l})})}),n[10]=l,n[11]=t,n[12]=i,n[13]=u,n[14]=m):m=n[14],m}),ul.displayName=ni.displayName,Vt=b.forwardRef((e,t)=>{let n=(0,mt.c)(13),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:r,inset:l,variant:o,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==r||n[6]!==l||n[7]!==o?(i=$b({className:r,inset:l,variant:o}),n[5]=r,n[6]=l,n[7]=o,n[8]=i):i=n[8];let c;return n[9]!==a||n[10]!==t||n[11]!==i?(c=(0,s.jsx)(li,{ref:t,className:i,...a}),n[9]=a,n[10]=t,n[11]=i,n[12]=c):c=n[12],c}),Vt.displayName=li.displayName,bo=b.forwardRef((e,t)=>{let n=(0,mt.c)(15),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:a,children:l,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]===a?i=n[6]:(i=Eb({className:a}),n[5]=a,n[6]=i);let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=Ua(),n[7]=c):c=n[7];let u;n[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("span",{className:c,children:(0,s.jsx)(ii,{children:(0,s.jsx)(mw,{className:"h-4 w-4"})})}),n[8]=u):u=n[8];let m;return n[9]!==r||n[10]!==l||n[11]!==o||n[12]!==t||n[13]!==i?(m=(0,s.jsxs)(ai,{ref:t,className:i,checked:r,...o,children:[u,l]}),n[9]=r,n[10]=l,n[11]=o,n[12]=t,n[13]=i,n[14]=m):m=n[14],m}),bo.displayName=ai.displayName;var Hy=b.forwardRef((e,t)=>{let n=(0,mt.c)(13),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:l,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o;n[4]===l?o=n[5]:(o=Ua({className:l}),n[4]=l,n[5]=o);let i;n[6]===Symbol.for("react.memo_cache_sentinel")?(i=Ua(),n[6]=i):i=n[6];let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:i,children:(0,s.jsx)(ii,{children:(0,s.jsx)(dw,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7];let u;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==o?(u=(0,s.jsxs)(oi,{ref:t,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=t,n[11]=o,n[12]=u):u=n[12],u});Hy.displayName=oi.displayName;var By=b.forwardRef((e,t)=>{let n=(0,mt.c)(11),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:r,inset:l,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o;n[4]!==r||n[5]!==l?(o=Tb({className:r,inset:l}),n[4]=r,n[5]=l,n[6]=o):o=n[6];let i;return n[7]!==a||n[8]!==t||n[9]!==o?(i=(0,s.jsx)(ri,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=i):i=n[10],i});By.displayName=ri.displayName,ml=b.forwardRef((e,t)=>{let n=(0,mt.c)(9),r,l;n[0]===e?(r=n[1],l=n[2]):({className:r,...l}=e,n[0]=e,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=$(Pb({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==t||n[7]!==a?(o=(0,s.jsx)(si,{ref:t,className:a,...l}),n[5]=l,n[6]=t,n[7]=a,n[8]=o):o=n[8],o}),ml.displayName=si.displayName;var Wy=L();const Gy=e=>{let t=(0,Wy.c)(12),{contextMenuRef:n,tableBody:r,tableRef:l,copyAllCells:a}=e,o;t[0]!==n||t[1]!==l?(o=p=>{var f;let d=n.current;if(!d)return;let g=(f=l.current)==null?void 0:f.querySelector(`[${cb}="${d.id}"]`);if(!g){ot.error("Context menu cell not found in table");return}p?g.classList.add("bg-(--green-4)"):g.classList.remove("bg-(--green-4)")},t[0]=n,t[1]=l,t[2]=o):o=t[2];let i=at(o),c;t[3]===r?c=t[4]:(c=(0,s.jsx)(So,{asChild:!0,children:r}),t[3]=r,t[4]=c);let u;t[5]!==n||t[6]!==a?(u=(0,s.jsx)(Ba,{children:(0,s.jsx)(qy,{cellRef:n,copySelectedCells:a})}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let m;return t[8]!==i||t[9]!==c||t[10]!==u?(m=(0,s.jsxs)(Oo,{onOpenChange:i,children:[c,u]}),t[8]=i,t[9]=c,t[10]=u,t[11]=m):m=t[11],m},qy=({cellRef:e,copySelectedCells:t})=>{var p;let n=$n(Ha).size>1,r=e.current;if(!r){ot.error("No cell found in context menu");return}let l=r.getContext().table,a=r.getValue(),o=Pa(l,r.row.index,r.column.id)??a,i=()=>{try{let{text:d,html:g}=Ac(o,a);an(d,g)}catch(d){ot.error("Failed to copy context menu cell",d)}},c=r.column,u=c.getCanFilter()&&((p=c.columnDef.meta)==null?void 0:p.filterType),m=d=>{c.setFilterValue(tt.select({options:[o],operator:d}))};return(0,s.jsxs)(ul,{children:[(0,s.jsxs)(Vt,{onClick:i,children:[(0,s.jsx)(el,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),n&&(0,s.jsxs)(Vt,{onClick:t,children:[(0,s.jsx)(Ri,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ml,{}),(0,s.jsxs)(Vt,{onClick:()=>m("in"),children:[(0,s.jsx)(Dn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,s.jsxs)(Vt,{onClick:()=>m("not_in"),children:[(0,s.jsx)(Dn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var Ky=L();const mu=(0,b.memo)(e=>{let t=(0,Ky.c)(9),{cellId:n,className:r}=e,l;t[0]===n?l=t[1]:(l=jy(n),t[0]=n,t[1]=l);let{isSelected:a,isCopied:o}=$n(l);if(!a&&!o)return null;let i=a&&"bg-(--green-3)",c=o&&"bg-(--green-4) transition-colors duration-150",u;t[2]!==r||t[3]!==i||t[4]!==c?(u=$("absolute inset-0 pointer-events-none",i,c,r),t[2]=r,t[3]=i,t[4]=c,t[5]=u):u=t[5];let m;return t[6]!==n||t[7]!==u?(m=(0,s.jsx)("div",{"data-cell-id":n,className:u}),t[6]=n,t[7]=u,t[8]=m):m=t[8],m});mu.displayName="CellRangeSelectionIndicator";var Uy=L();const Xy=e=>{let t=(0,Uy.c)(30),{table:n}=e,r=Sy(),l;t[0]!==r||t[1]!==n?(l=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},t[0]=r,t[1]=n,t[2]=l):l=t[2];let a=at(l),o;t[3]!==r||t[4]!==n?(o=(v,j)=>{r.updateSelection({newCell:v,isShiftKey:j,table:n})},t[3]=r,t[4]=n,t[5]=o):o=t[5];let i=at(o),c;t[6]!==r||t[7]!==n?(c=(v,j)=>{r.navigate({direction:j,isShiftKey:v.shiftKey,table:n})},t[6]=r,t[7]=n,t[8]=c):c=t[8];let u=at(c),m;t[9]!==r||t[10]!==a||t[11]!==u||t[12]!==n?(m=v=>{e:switch(v.key){case"c":qe.isMetaOrCtrl(v)&&a();break e;case"ArrowDown":v.preventDefault(),u(v,"down");break e;case"ArrowUp":v.preventDefault(),u(v,"up");break e;case"ArrowLeft":v.preventDefault(),u(v,"left");break e;case"ArrowRight":v.preventDefault(),u(v,"right");break e;case"Enter":v.preventDefault(),r.toggleCurrentRowSelection(n);break e;case"Escape":r.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),r.selectAllCells(n))}},t[9]=r,t[10]=a,t[11]=u,t[12]=n,t[13]=m):m=t[13];let p=at(m),d;t[14]!==r||t[15]!==n?(d=(v,j)=>{v.buttons!==2&&(Yy(v)||r.handleCellMouseDown({cell:j,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:n}))},t[14]=r,t[15]=n,t[16]=d):d=t[16];let g=at(d),f;t[17]===r?f=t[18]:(f=()=>{r.setIsSelecting(!1)},t[17]=r,t[18]=f);let x=at(f),w;t[19]!==r||t[20]!==n?(w=(v,j)=>{v.buttons===1&&r.updateRangeSelection({cell:j,table:n})},t[19]=r,t[20]=n,t[21]=w):w=t[21];let y=at(w),S;return t[22]!==r.clearSelection||t[23]!==g||t[24]!==y||t[25]!==x||t[26]!==p||t[27]!==a||t[28]!==i?(S={handleCellMouseDown:g,handleCellMouseUp:x,handleCellMouseOver:y,handleCopy:a,handleCellsKeyDown:p,updateSelection:i,clearSelection:r.clearSelection},t[22]=r.clearSelection,t[23]=g,t[24]=y,t[25]=x,t[26]=p,t[27]=a,t[28]=i,t[29]=S):S=t[29],S};var Jy='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element';function Yy(e){let t=e.target;return t===e.currentTarget||!(t instanceof Element)?!1:t.closest(Jy)!==null}var Qy=L(),Zy=Pe(e=>e(Pt).focusedCell);function ex(e){let t=(0,Qy.c)(2),n;t[0]===e?n=t[1]:(n=r=>{r!=null&&r.cellId&&setTimeout(()=>{var a;let l=(a=e.current)==null?void 0:a.querySelector(`[data-cell-id="${r.cellId}"]`);if(!l){ot.warn("[ScrollIntoView] Could not find cell with ID:",r.cellId);return}l.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},t[0]=e,t[1]=n),tb(Zy,n)}function tx(e,t){var r;if(!((r=e.getRowModel().rows)!=null&&r.length))return null;let n=l=>l.map(a=>a.headers.map(o=>{let{className:i,style:c}=pu(o.column);return(0,s.jsx)(_w,{className:$("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",i),style:c,ref:u=>{rx({table:e,column:o.column,thead:u})},children:o.isPlaceholder?null:al(o.column.columnDef.header,o.getContext())},o.id)}));return(0,s.jsx)(kw,{className:$(t&&"sticky top-0 z-10"),children:(0,s.jsxs)(to,{children:[n(e.getLeftHeaderGroups()),n(e.getCenterHeaderGroups()),n(e.getRightHeaderGroups()),e.getAllColumns().length<=4&&(0,s.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const nx=({table:e,columns:t,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:l,virtualize:a=!1})=>{let o=e.getRowModel().rows,[i,c]=(0,b.useState)(null),u=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>{var _,h;c(((h=(_=u.current)==null?void 0:_.parentElement)==null?void 0:h.parentElement)??null)},[]);let m=Dy({count:a?o.length:0,getScrollElement:()=>i,estimateSize:()=>24,overscan:10});ex(u);let{handleCellMouseDown:p,handleCellMouseUp:d,handleCellMouseOver:g,handleCellsKeyDown:f,handleCopy:x}=Xy({table:e}),w=(0,b.useRef)(null),y=at(_=>{w.current=_});function S(_,h){let M=/{{(\w+)}}/g,A=new Map;for(let I of h){let z=Mn({value:I.getValue(),nullAsEmptyString:!0});A.set(I.column.id,z)}return _.replaceAll(M,(I,z)=>{let V=A.get(z);return V===void 0?`{{${z}}}`:V})}let v=_=>_.map(h=>{var V,U,ee,Y;let{className:M,style:A}=pu(h.column),I=Object.assign({},((V=h.getUserStyling)==null?void 0:V.call(h))||{},A),z=((U=h.getHoverTitle)==null?void 0:U.call(h))??void 0;return(0,b.createElement)(od,{tabIndex:0,...ib(h.id),key:h.id,className:$("whitespace-pre truncate max-w-[300px] outline-hidden border-r border-r-border/75",h.column.getColumnWrapping&&((Y=(ee=h.column).getColumnWrapping)==null?void 0:Y.call(ee))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",M),style:I,title:z,onMouseDown:se=>p(se,h),onMouseUp:d,onMouseOver:se=>g(se,h),onContextMenu:()=>y(h)},(0,s.jsx)(mu,{cellId:h.id}),(0,s.jsx)("div",{className:"relative",children:al(h.column.columnDef.cell,h.getContext())}))}),j=_=>{var h;if(n){let M=(r==null?void 0:r(_.original,_.index))??_.index;(h=_.focusRow)==null||h.call(_,M)}},k=e.getState().cellHoverTemplate||null,C=_=>{var I;let h=n?(r==null?void 0:r(_.original,_.index))??_.index:void 0,M=n&&l===h,A;return k&&(A=S(k,((I=_.getVisibleCells)==null?void 0:I.call(_))??[..._.getLeftVisibleCells(),..._.getCenterVisibleCells(),..._.getRightVisibleCells()])),(0,s.jsxs)(to,{"data-state":_.getIsSelected()&&"selected",title:A,className:$("border-t h-6",n&&"cursor-pointer",M&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>j(_),children:[v(_.getLeftVisibleCells()),v(_.getCenterVisibleCells()),v(_.getRightVisibleCells()),t.length<=4&&(0,s.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},_.id)},N=t.length<=4,R=t.length+(N?1:0);return(0,s.jsx)(Gy,{tableBody:(0,s.jsx)(Rw,{onKeyDown:f,ref:u,children:(()=>{var _,h;if(o.length===0)return(0,s.jsx)(to,{children:(0,s.jsx)(od,{colSpan:R,className:"h-24 text-center",children:"No results."})});if(a){let M=m.getVirtualItems(),A=m.getTotalSize();return(0,s.jsxs)(s.Fragment,{children:[((_=M[0])==null?void 0:_.start)>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:M[0].start},children:(0,s.jsx)("td",{colSpan:R})}),M.map(I=>C(o[I.index])),M.length>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:A-(((h=M.at(-1))==null?void 0:h.end)??A)},children:(0,s.jsx)("td",{colSpan:R})})]})}return o.map(M=>C(M))})()}),contextMenuRef:w,tableRef:u,copyAllCells:x})};function pu(e){let t=e.getIsPinned(),n=t==="left"&&e.getIsLastColumn("left"),r=t==="right"&&e.getIsFirstColumn("right");return{className:$(t&&"bg-inherit","shadow-r z-10"),style:{boxShadow:n&&e.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":r?"4px 0 4px -4px var(--slate-8) inset":void 0,left:t==="left"?`${e.getStart("left")}px`:void 0,right:t==="right"?`${e.getAfter("right")}px`:void 0,opacity:1,position:t?"sticky":"relative",zIndex:t?1:0,width:e.getSize()}}}function rx({table:e,column:t,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);e.getState().columnSizing[t.id]!==r&&e.setColumnSizing(l=>({...l,[t.id]:r}))}var lx=100;const ax=({table:e,tableLoading:t,showPageSizeSelector:n})=>{let{locale:r}=Ke(),l=Math.min(e.getState().pagination.pageIndex+1,e.getPageCount()),a=e.getPageCount(),o=e.getState().pagination.pageSize,i=u=>{t||u()},c=[...new Set([5,10,25,50,100,o])].toSorted((u,m)=>u-m);return(0,s.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,s.jsx)("div",{className:"order-2 lg:order-first",children:n&&(0,s.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,s.jsxs)(Jr,{children:[(0,s.jsx)(Kr,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5",children:[o," / page",(0,s.jsx)(Yr,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsxs)(Ur,{align:"center",sideOffset:6,children:[(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...c].map(u=>(0,s.jsx)(Z,{className:$("text-xs cursor-pointer",u===o&&"font-semibold bg-accent"),onSelect:()=>e.setPageSize(u),onMouseDown:qe.preventFocus,children:u},u))]})]})})}),(0,s.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,s.jsx)(Ce,{content:"First page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>e.setPageIndex(0)),onMouseDown:qe.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,s.jsx)($o,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Previous page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>e.previousPage()),onMouseDown:qe.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,s.jsx)(gv,{className:"h-4 w-4"})})}),(0,s.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,s.jsx)("span",{children:"Page"}),(0,s.jsx)(ox,{currentPage:l,totalPages:a,onPageChange:u=>i(()=>e.setPageIndex(u))}),(0,s.jsxs)("span",{className:"shrink-0",children:["of ",Oe(a,r)]})]}),(0,s.jsx)(Ce,{content:"Next page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>e.nextPage()),onMouseDown:qe.preventFocus,disabled:!e.getCanNextPage(),children:(0,s.jsx)(Fv,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Last page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>e.setPageIndex(e.getPageCount()-1)),onMouseDown:qe.preventFocus,disabled:!e.getCanNextPage(),children:(0,s.jsx)(ho,{className:"h-4 w-4"})})})]})]})},ox=({currentPage:e,totalPages:t,onPageChange:n})=>{let[r,l]=b.useState(!1),a=b.useMemo(()=>ix(e,t),[e,t]),o=i=>{n(i-1),l(!1)};return(0,s.jsxs)(Gr,{open:t>1?r:!1,onOpenChange:l,children:[(0,s.jsx)(Br,{asChild:!0,disabled:t<=1,children:(0,s.jsxs)("button",{type:"button",className:$("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",t>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:t<=1,children:[e,(0,s.jsx)(Yr,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsx)(Wr,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,s.jsxs)(ad,{shouldFilter:!0,filter:(i,c)=>i.startsWith(c)?1:0,children:[(0,s.jsx)(nd,{placeholder:`Page (1\u2013${t})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,onKeyDown:i=>{!["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(i.key)&&!/^\d$/.test(i.key)&&i.preventDefault()}}),(0,s.jsxs)(ld,{className:"max-h-60",children:[a.map(i=>i.type==="ellipsis"?null:(0,s.jsx)(eo,{value:String(i.page),"data-testid":"page-option",className:$("text-xs cursor-pointer",i.page===e&&"font-semibold bg-accent"),onSelect:()=>o(i.page),onMouseDown:qe.preventFocus,children:i.page},i.page)),(0,s.jsx)(rd,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"})]})]})})]})};function ix(e,t){if(t<=lx)return Sb(t).map(a=>({type:"page",page:a+1}));let n=Math.floor(t/2),r=[],l=(a,o)=>{for(let i=0;i<o;i++)r.push({type:"page",page:a+i})};return l(1,10),r.push({type:"ellipsis",key:"e1"}),e>10&&e<=n-5&&r.push({type:"page",page:e},{type:"ellipsis",key:"e1b"}),l(n-4,10),r.push({type:"ellipsis",key:"e2"}),e>n+5&&e<=t-10&&r.push({type:"page",page:e},{type:"ellipsis",key:"e2b"}),l(t-9,10),r}ko=function(e,t){return`${Oe(e,t)} ${new Tu("row").pluralize(e)}`},xo=(e,t,n)=>[e==="too_many"?"Unknown":ko(e,n),`${Oe(t,n)} ${new Tu("column").pluralize(t)}`].join(", ");var An=L(),Wa=3;const fu=e=>{let t=(0,An.c)(21),{table:n,className:r}=e,{locale:l}=Ke(),a=$n(Ha),o=xy(a);if(o<2){let f;t[0]===r?f=t[1]:(f=$("text-xs text-muted-foreground/80 italic",r),t[0]=r,t[1]=f);let x;return t[2]===f?x=t[3]:(x=(0,s.jsx)(Ce,{content:"Select multiple cells to see stats",children:(0,s.jsx)("span",{className:f,children:"No selection"})}),t[2]=f,t[3]=x),x}let i;t[4]!==a||t[5]!==n?(i=by(n,a),t[4]=a,t[5]=n,t[6]=i):i=t[6];let c=i,u;t[7]===r?u=t[8]:(u=$("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",r),t[7]=r,t[8]=u);let m;t[9]!==o||t[10]!==l?(m=(0,s.jsx)(cx,{count:o,locale:l}),t[9]=o,t[10]=l,t[11]=m):m=t[11];let p,d;t[12]!==l||t[13]!==c?(p=(0,s.jsx)(ux,{numericValues:c,locale:l}),d=(0,s.jsx)(dx,{numericValues:c,locale:l}),t[12]=l,t[13]=c,t[14]=p,t[15]=d):(p=t[14],d=t[15]);let g;return t[16]!==u||t[17]!==m||t[18]!==p||t[19]!==d?(g=(0,s.jsxs)("div",{className:u,children:[m,p,d]}),t[16]=u,t[17]=m,t[18]=p,t[19]=d,t[20]=g):g=t[20],g};var sx=(e,t)=>e.toLocaleString(t,{maximumFractionDigits:Wa}),Ga=e=>{let t=(0,An.c)(6),{name:n,value:r,locale:l}=e,a;t[0]!==l||t[1]!==r?(a=sx(r,l),t[0]=l,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,s.jsxs)("span",{children:[n,": ",a]}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o},cx=e=>{let t=(0,An.c)(3),{count:n,locale:r}=e,l;return t[0]!==n||t[1]!==r?(l=(0,s.jsx)(Ga,{name:"Count",value:n,locale:r}),t[0]=n,t[1]=r,t[2]=l):l=t[2],l},ux=e=>{let t=(0,An.c)(6),{numericValues:n,locale:r}=e;if(n.length===0)return null;let l,a;if(t[0]!==n){let c=n.reduce(mx,0);l=Number,a=c.toFixed(Wa),t[0]=n,t[1]=l,t[2]=a}else l=t[1],a=t[2];let o=l(a),i;return t[3]!==r||t[4]!==o?(i=(0,s.jsx)(Ga,{name:"Sum",value:o,locale:r}),t[3]=r,t[4]=o,t[5]=i):i=t[5],i},dx=e=>{let t=(0,An.c)(5),{numericValues:n,locale:r}=e;if(n.length===0)return null;let l=n.reduce(px,0)/n.length,a;t[0]===l?a=t[1]:(a=l.toFixed(Wa),t[0]=l,t[1]=a);let o=Number(a),i;return t[2]!==o||t[3]!==r?(i=(0,s.jsx)(Ga,{name:"Average",value:o,locale:r}),t[2]=o,t[3]=r,t[4]=i):i=t[4],i};function mx(e,t){return e+t}function px(e,t){return e+t}const fx=({pagination:e,totalColumns:t,selection:n,onRowSelectionChange:r,table:l,getRowIds:a,showPageSizeSelector:o,tableLoading:i,part:c,className:u})=>{let{locale:m}=Ke(),p=d=>{if(!r)return;if(!d){r({});return}let g=()=>{let f=Array.from({length:l.getRowCount()},(x,w)=>[w,!0]);r(Object.fromEntries(f))};if(!a){g();return}a({}).then(f=>{if(f.error){tl({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?g():r(Object.fromEntries(f.row_ids.map(x=>[x,!0])))})};return(0,s.jsxs)("div",{part:c,className:$("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,s.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:d,cellSelection:g}=l.getState(),f=Object.keys(d).length,x=l.getIsAllPageRowsSelected(),w=l.getRowCount(),y=f===w,S=n==="single-cell"||n==="multi-cell";return S&&(f=g.length,x=!1,y=!1),x&&!y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,m)," selected"]}),(0,s.jsxs)(de,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>p(!0),children:["Select all ",Oe(w,m)]})]}):f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,m)," selected"]}),(0,s.jsx)(de,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>{S?l.resetCellSelection&&l.resetCellSelection():p(!1)},children:"Clear selection"})]}):(0,s.jsx)("span",{children:xo(l.getRowCount(),t,m)})})()}),(0,s.jsx)(fu,{table:l,className:"lg:hidden"})]}),(0,s.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:e&&(0,s.jsx)(ax,{table:l,tableLoading:i,showPageSizeSelector:o})}),(0,s.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,s.jsx)(fu,{table:l,className:"px-2"})})]})};var gx=L(),Ot={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:Xu},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:hb},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:yi},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:Xu},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:mb}},hx=[Ot.CSV,Ot.JSON,Ot.PARQUET],yx=[Ot.TSV,Ot.JSON,Ot.CSV,Ot.MARKDOWN];const xx=e=>{let t=(0,gx.c)(29),{locale:n}=Ke(),[r,l]=b.useState(!1),a=r?"text-primary":"text-muted-foreground",o;t[0]===a?o=t[1]:(o=$("print:hidden text-xs gap-1",a),t[0]=a,t[1]=o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(wo,{className:"w-3.5 h-3.5"}),t[2]=i):i=t[2];let c;t[3]===o?c=t[4]:(c=(0,s.jsxs)(de,{"data-testid":"export-button",size:"xs",variant:"text",className:o,children:[i,"Export"]}),t[3]=o,t[4]=c);let u=c,m;t[5]===e?m=t[6]:(m=R=>e.downloadAs({format:R}).catch(bx),t[5]=e,t[6]=m);let p=m,d;t[7]!==p||t[8]!==n?(d=async R=>{let _;e:switch(R){case"tsv":{let{url:h}=await p("json");_=ub(await qa(h),n);break e}case"json":{let{url:h}=await p("json"),M=await qa(h);_=JSON.stringify(M,null,2);break e}case"csv":{let{url:h}=await p("csv");_=await gu(h);break e}case"markdown":{let{url:h}=await p("json");_=sb(await qa(h));break e}default:kt(R);return}await an(_),tl({title:"Copied to clipboard"})},t[7]=p,t[8]=n,t[9]=d):d=t[9];let g=d,f=r?!1:void 0,x;t[10]===u?x=t[11]:(x=(0,s.jsx)(Kr,{asChild:!0,children:u}),t[10]=u,t[11]=x);let w;t[12]!==f||t[13]!==x?(w=(0,s.jsx)(Ce,{content:"Export",open:f,children:x}),t[12]=f,t[13]=x,t[14]=w):w=t[14];let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Download"}),t[15]=y):y=t[15];let S;t[16]===p?S=t[17]:(S=hx.map(R=>(0,s.jsxs)(Z,{onSelect:async()=>{let{url:_,filename:h}=await p(R.format),M=R.format,A=(h??"").trim();hv(_,`${fv.withoutExtension(A)||"download"}.${M}`)},children:[(0,s.jsx)(R.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:R.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:R.description})]})]},R.label)),t[16]=p,t[17]=S);let v,j;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(ln,{}),j=(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),t[18]=v,t[19]=j):(v=t[18],j=t[19]);let k;t[20]===g?k=t[21]:(k=yx.map(R=>(0,s.jsxs)(Z,{onSelect:async()=>{try{await g(R.format)}catch(_){tl({title:"Failed to copy to clipboard",description:aw(_),variant:"danger"})}},children:[(0,s.jsx)(R.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:R.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:R.description})]})]},R.label)),t[20]=g,t[21]=k);let C;t[22]!==S||t[23]!==k?(C=(0,s.jsxs)(Ur,{side:"bottom",className:"print:hidden",children:[y,S,v,j,k]}),t[22]=S,t[23]=k,t[24]=C):C=t[24];let N;return t[25]!==r||t[26]!==C||t[27]!==w?(N=(0,s.jsxs)(Jr,{modal:!1,open:r,onOpenChange:l,children:[w,C]}),t[25]=r,t[26]=C,t[27]=w,t[28]=N):N=t[28],N};function qa(e){return gu(e).then(Ou)}function gu(e){return fetch(e).then(t=>{if(!t.ok)throw Error(t.statusText);return t.text()})}function bx(e){throw tl({title:"Failed to download",description:"message"in e?e.message:String(e)}),e}var vx=()=>{};let hu;hu=({enableSearch:e,searchQuery:t,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:a,toggleDisplayHeader:o,showTableExplorer:i,togglePanel:c,isAnyPanelOpen:u,downloadAs:m})=>{let[p,d]=(0,b.useState)(t||""),g=y1(p,500),f=at(n??vx),x=b.useRef(null);return(0,b.useEffect)(()=>{f(g)},[g,f]),e&&n||l||i||m?(0,s.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&e&&(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-1 px-2 rounded-sm focus-within:ring-1 focus-within:ring-border transition-shadow",children:[(0,s.jsx)(Qu,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,s.jsx)("input",{ref:x,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:p,onKeyDown:w=>{var y;w.key==="Escape"&&(d(""),(y=x.current)==null||y.blur())},onChange:w=>d(w.target.value),placeholder:"Search..."}),r&&(0,s.jsx)(Yu,{size:"small"}),p&&(0,s.jsx)(de,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>d(""),children:(0,s.jsx)(Qr,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,s.jsxs)("div",{className:"flex items-center shrink-0",children:[l&&(0,s.jsxs)(de,{variant:"text",size:"xs",className:$("print:hidden text-xs gap-1",a?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,s.jsx)(xi,{className:"w-3.5 h-3.5"}),"Visualize"]}),i&&c&&(0,s.jsxs)(de,{variant:"text",size:"xs",className:$("print:hidden text-xs gap-1",u?"text-primary":"text-muted-foreground"),onClick:()=>c(pl.ROW_VIEWER),children:[(0,s.jsx)(ki,{className:"w-3.5 h-3.5"}),"Explorer"]}),m&&(0,s.jsx)(xx,{downloadAs:m})]})]}):null},Eo=(0,b.memo)(({wrapperClassName:e,className:t,maxHeight:n,columns:r,data:l,rawData:a,selection:o,totalColumns:i,totalRows:c,manualSorting:u=!1,sorting:m,setSorting:p,rowSelection:d,cellSelection:g,cellStyling:f,hoverTemplate:x,cellHoverTexts:w,paginationState:y,setPaginationState:S,downloadAs:v,manualPagination:j=!1,pagination:k=!1,onRowSelectionChange:C,onCellSelectionChange:N,getRowIds:R,enableSearch:_=!1,searchQuery:h,onSearchQueryChange:M,showFilters:A=!1,filters:I,onFiltersChange:z,reloading:V,freezeColumnsLeft:U,freezeColumnsRight:ee,toggleDisplayHeader:Y,showChartBuilder:se,isChartBuilderOpen:W,showPageSizeSelector:X,showTableExplorer:Se,togglePanel:ue,isPanelOpen:je,isAnyPanelOpen:Ae,viewedRowIdx:ze,onViewedRowChange:Be})=>{let[Ie,lt]=b.useState(!1),{locale:pt}=Ke(),{columnPinning:Ee,setColumnPinning:We}=iy(U,ee);b.useEffect(()=>{let pe;return V?pe=setTimeout(()=>{lt(!0)},300):lt(!1),()=>{pe&&clearTimeout(pe)}},[V]);function G(pe,Re){return y?Re+(j?y.pageIndex*y.pageSize:0):Re}let te=io({_features:[kc,$1,K0,Z1,ty,Q1,J1,ny,ay],data:l,columns:r,meta:{rawData:a},getCoreRowModel:Ao(),rowCount:c==="too_many"?void 0:c,...S?{onPaginationChange:S,getRowId:(pe,Re)=>{let E=_r(pe);if(E)return E;let Ve=G(pe,Re);return String(Ve)}}:{},locale:pt,manualPagination:j,getPaginationRowModel:B0(),...p?{onSortingChange:p}:{},manualSorting:u,enableMultiSort:!0,getSortedRowModel:go(),manualFiltering:!0,enableColumnFilters:A,getFilteredRowModel:oo(),onColumnFiltersChange:z,onRowSelectionChange:C,onCellSelectionChange:N,enableCellSelection:o==="single-cell"||o==="multi-cell",enableMultiCellSelection:o==="multi-cell",onColumnPinningChange:We,enableFocusRow:!0,onFocusRowChange:Be,state:{...m?{sorting:m}:{},columnFilters:I,...y?{pagination:y}:k&&!y?{}:{pagination:{pageIndex:0,pageSize:l.length}},rowSelection:d??{},cellSelection:g??[],cellStyling:f,columnPinning:Ee,cellHoverTemplate:x,cellHoverTexts:w??{}}}),_e=(je==null?void 0:je(pl.ROW_VIEWER))??!1,Q=!k&&l.length>100,me=cy({maxHeight:n,virtualize:Q});return(0,s.jsxs)("div",{className:$(e,"flex flex-col space-y-1"),children:[(0,s.jsx)(ry,{filters:I,table:te}),(0,s.jsx)(Ry,{children:(0,s.jsxs)("div",{part:"table-wrapper",className:$(t||"rounded-md border overflow-hidden"),children:[(0,s.jsx)(hu,{enableSearch:_,searchQuery:h,onSearchQueryChange:M,reloading:V,showChartBuilder:se,isChartBuilderOpen:W,toggleDisplayHeader:Y,showTableExplorer:Se,togglePanel:ue,isAnyPanelOpen:Ae,downloadAs:v}),(0,s.jsxs)(Mw,{className:$("relative",r.length<=4?"w-auto":"w-full"),ref:me,children:[Ie&&(0,s.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),tx(te,Q||!!n),(0,s.jsx)(nx,{table:te,columns:r,rowViewerPanelOpen:_e,getRowIndex:G,viewedRowIdx:ze,virtualize:Q})]}),(0,s.jsx)(fx,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:i,pagination:k,selection:o,onRowSelectionChange:C,table:te,getRowIds:R,showPageSizeSelector:X,tableLoading:V})]})})]})});var Qt=L(),wx=25;No=function(e){return e?e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")||e.startsWith("application/pdf"):!1},il={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};function Or(e){return e.url==null?Ov(e.base64,e.mime):e.url}let Ka,yu,xu,bu,vu,wu;Ka=({contents:e})=>{let t=(0,b.useMemo)(()=>Za(e),[e]),[n,r]=(0,b.useState)({pageIndex:0,pageSize:wx}),l=(0,b.useMemo)(()=>jo(t),[t]),a=(0,b.useMemo)(()=>uo({rowHeaders:xv.EMPTY,selection:null,fieldTypes:l}),[l]);return(0,s.jsx)(Eo,{data:t,totalRows:t.length,columns:a,totalColumns:a.length,manualPagination:!1,paginationState:n,setPaginationState:r,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex overflow-hidden",rowSelection:Lr.EMPTY})},yu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("img",{src:n,alt:"Preview"}),t[2]=n,t[3]=r),r},xu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("audio",{controls:!0,src:n}),t[2]=n,t[3]=r),r},bu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("video",{controls:!0,src:n}),t[2]=n,t[3]=r),r},vu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("iframe",{src:n,title:"PDF Viewer",className:"w-full h-full"}),t[2]=n,t[3]=r),r},wu=e=>{let t=(0,Qt.c)(11),n,r;if(t[0]===e?(n=t[1],r=t[2]):({mimeType:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n.startsWith("image/")){let l;return t[3]===r?l=t[4]:(l=(0,s.jsx)(yu,{...r}),t[3]=r,t[4]=l),l}if(n.startsWith("audio/")){let l;return t[5]===r?l=t[6]:(l=(0,s.jsx)(xu,{...r}),t[5]=r,t[6]=l),l}if(n.startsWith("video/")){let l;return t[7]===r?l=t[8]:(l=(0,s.jsx)(bu,{...r}),t[7]=r,t[8]=l),l}if(n.startsWith("application/pdf")){let l;return t[9]===r?l=t[10]:(l=(0,s.jsx)(vu,{...r}),t[9]=r,t[10]=l),l}return null},vd=e=>{let t=(0,Qt.c)(17),{mimeType:n,contents:r,mediaSource:l,readOnly:a,onChange:o,extensions:i}=e,c=a===void 0?!0:a,u;t[0]===i?u=t[1]:(u=i===void 0?[]:i,t[0]=i,t[1]=u);let m=u,{theme:p}=nl();if(n==="text/csv"&&r!=null){let d;return t[2]===r?d=t[3]:(d=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(Ka,{contents:r})}),t[2]=r,t[3]=d),d}if(No(n)&&l){let d;return t[4]!==l||t[5]!==n?(d=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(wu,{...l,mimeType:n})}),t[4]=l,t[5]=n,t[6]=d):d=t[6],d}if(r!=null){let d=il[n]||il.default,g=p==="dark"?"dark":"light",f;t[7]===m?f=t[8]:(f=[Ku.lineWrapping,...m],t[7]=m,t[8]=f);let x=c?!1:void 0,w=c?void 0:o,y;return t[9]!==r||t[10]!==d||t[11]!==c||t[12]!==g||t[13]!==f||t[14]!==x||t[15]!==w?(y=(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(b.Suspense,{children:(0,s.jsx)(kv,{theme:g,language:d,className:"border-b",extensions:f,value:r,readOnly:c,editable:x,onChange:w})})}),t[9]=r,t[10]=d,t[11]=c,t[12]=g,t[13]=f,t[14]=x,t[15]=w,t[16]=y):y=t[16],y}return null};function Sx(e,t){let{state:n}=e,r=n.doc;if(t<=0||t>r.lines)return ot.warn(`Invalid line number: ${t}. Document has ${r.lines} lines.`),!1;let l=r.line(t);if(l.text.includes("breakpoint()"))return!0;let a=l.text.match(/^(\s*)/),o=`${a?a[1]:""}breakpoint()
45
+ color: hsl(${Math.max(0,Math.min(120-120*x,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(l),a=!1,l}return o.updateDeps=i=>{r=i},o}function nu(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}var My=(e,t)=>Math.abs(e-t)<1.01,Ny=(e,t,n)=>{let r;return function(...l){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,l),n)}},ru=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Fy=e=>e,Ay=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let l=t;l<=n;l++)r.push(l);return r},Iy=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let l=o=>{let{width:i,height:c}=o;t({width:Math.round(i),height:Math.round(c)})};if(l(ru(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(o=>{let i=()=>{let c=o[0];if(c!=null&&c.borderBoxSize){let u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(ru(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},lu={passive:!0},au=typeof window>"u"?!0:"onscrollend"in window,Ey=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let l=0,a=e.options.useScrollendEvent&&au?()=>{}:Ny(r,()=>{t(l,!1)},e.options.isScrollingResetDelay),o=m=>()=>{let{horizontal:p,isRtl:d}=e.options;l=p?n.scrollLeft*(d&&-1||1):n.scrollTop,a(),t(l,m)},i=o(!0),c=o(!1);n.addEventListener("scroll",i,lu);let u=e.options.useScrollendEvent&&au;return u&&n.addEventListener("scrollend",c,lu),()=>{n.removeEventListener("scroll",i),u&&n.removeEventListener("scrollend",c)}},Py=(e,t,n)=>{if(t!=null&&t.borderBoxSize){let r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Oy=(e,{adjustments:t=0,behavior:n},r)=>{var i;var l,a;let o=e+t;(a=(i=l=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})},$y=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,l;var t;return((l=(r=t=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:l.call(t))??Date.now()},this.observer=(()=>{let t=null,n=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(r=>{r.forEach(l=>{let a=()=>{let o=l.target,i=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(o,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),t=null},observe:r=>{var l;return(l=n())==null?void 0:l.observe(r,{box:"border-box"})},unobserve:r=>{var l;return(l=n())==null?void 0:l.unobserve(r)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([n,r])=>{r===void 0&&delete t[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Fy,rangeExtractor:Ay,onChange:()=>{},measureElement:Py,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,t)},this.maybeNotify=Yt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t){this.maybeNotify();return}this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,n)=>{let r=new Map,l=new Map;for(let a=n-1;a>=0;a--){let o=t[a];if(r.has(o.lane))continue;let i=l.get(o.lane);if(i==null||o.end>i.end?l.set(o.lane,o):o.end<i.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Yt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,n,r,l,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=Yt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(let p of this.laneAssignments.keys())p>=t&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,c),m=Array(o).fill(void 0);for(let p=0;p<c;p++){let d=u[p];d&&(m[d.lane]=p)}for(let p=c;p<t;p++){let d=l(p),g=this.laneAssignments.get(p),f,x;if(g!==void 0&&this.options.lanes>1){f=g;let v=m[f],j=v===void 0?void 0:u[v];x=j?j.end+this.options.gap:n+r}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);x=v?v.end+this.options.gap:n+r,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let w=i.get(d),y=typeof w=="number"?w:this.options.estimateSize(p),S=x+y;u[p]={index:p,start:x,size:y,end:S,key:d,lane:f},m[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,n,r,l)=>this.range=t.length>0&&n>0?Ty({measurements:t,outerSize:n,scrollOffset:r,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yt(()=>{let t=null,n=null,r=this.calculateRange();return r&&(t=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,n]},(t,n,r,l,a)=>l===null||a===null?[]:t({startIndex:l,endIndex:a,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=t=>{let n=this.options.indexAttribute,r=t.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let n=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(n!==void 0&&this.range){let l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,n-l),o=Math.min(this.options.count-1,n+l);return t>=a&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}let n=this.indexFromElement(t),r=this.options.getItemKey(n),l=this.elementsCache.get(r);l!==t&&(l&&this.observer.unobserve(l),this.observer.observe(t),this.elementsCache.set(r,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,n)=>{var a;let r=this.measurementsCache[t];if(!r)return;let l=n-(this.itemSizeCache.get(r.key)??r.size);l!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,n)),this.notify(!1))},this.getVirtualItems=Yt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,n)=>{let r=[];for(let l=0,a=t.length;l<a;l++){let o=n[t[l]];r.push(o)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{let n=this.getMeasurements();if(n.length!==0)return nu(n[ou(0,n.length-1,r=>nu(n[r]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,n,r=0)=>{if(!this.scrollElement)return 0;let l=this.getSize(),a=this.getScrollOffset();n==="auto"&&(n=t>=a+l?"end":"start"),n==="center"?t+=(r-l)/2:n==="end"&&(t-=l);let o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,n="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));let r=this.getSize(),l=this.getScrollOffset(),a=this.measurementsCache[t];if(!a)return;if(n==="auto")if(a.end>=l+r-this.options.scrollPaddingEnd)n="end";else if(a.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),n];let o=n==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,a.size),n]},this.scrollToOffset=(t,{align:n="start",behavior:r="auto"}={})=>{let l=this.getOffsetForAlignment(t,n);this.scrollState={index:null,align:n,behavior:r,startedAt:this.now(),lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:n="auto",behavior:r="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));let l=this.getOffsetForIndex(t,n);if(!l)return;let[a,o]=l,i=this.now();this.scrollState={index:t,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:n="auto"}={})=>{let r=this.getScrollOffset()+t;this.scrollState={index:null,align:"start",behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;let t=this.getMeasurements(),n;if(t.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((r=t[t.length-1])==null?void 0:r.end)??0;else{let l=Array(this.options.lanes).fill(null),a=t.length-1;for(;a>=0&&l.some(o=>o===null);){let o=t[a];l[o.lane]===null&&(l[o.lane]=o.end),a--}n=Math.max(...l.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:n,behavior:r})=>{this.options.scrollToFn(t,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&My(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior="auto",this._scrollToOffset(t,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},ou=(e,t,n,r)=>{for(;e<=t;){let l=(e+t)/2|0,a=n(l);if(a<r)e=l+1;else if(a>r)t=l-1;else return l}return e>0?e-1:0};function Ty({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let l=e.length-1,a=c=>e[c].start;if(e.length<=r)return{startIndex:0,endIndex:l};let o=ou(0,l,a,n),i=o;if(r===1)for(;i<l&&e[i].end<n+t;)i++;else if(r>1){let c=Array(r).fill(0);for(;i<l&&c.some(m=>m<n+t);){let m=e[i];c[m.lane]=m.end,i++}let u=Array(r).fill(n+t);for(;o>=0&&u.some(m=>m>=n);){let m=e[o];u[m.lane]=m.start,o--}o=Math.max(0,o-o%r),i=Math.min(l,i+(r-1-i%r))}return{startIndex:o,endIndex:i}}var zy=wb(),iu=typeof document<"u"?b.useLayoutEffect:b.useEffect;function Vy({useFlushSync:e=!0,...t}){let n=b.useReducer(()=>({}),{})[1],r={...t,onChange:(a,o)=>{var i;e&&o?(0,zy.flushSync)(n):n(),(i=t.onChange)==null||i.call(t,a,o)}},[l]=b.useState(()=>new $y(r));return l.setOptions(r),iu(()=>l._didMount(),[]),iu(()=>l._willUpdate()),l}function Dy(e){return Vy({observeElementRect:Iy,observeElementOffset:Ey,scrollToFn:Oy,...e})}let mt,Ba,su,cu,uu;mt=L(),Oo=Hd,So=Bd,Ba=Ab(Wd),su=Lu(ni),cu=Lu(ui),uu=b.forwardRef((e,t)=>{let n=(0,mt.c)(14),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:l,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==l||n[6]!==a?(i=Ob({className:l,inset:a}),n[5]=l,n[6]=a,n[7]=i):i=n[7];let c;n[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(fw,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==i?(u=(0,s.jsxs)(ci,{ref:t,className:i,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=i,n[13]=u):u=n[13],u}),uu.displayName=ci.displayName;var du="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",Ly=b.forwardRef((e,t)=>{let n=(0,mt.c)(9),r,l;n[0]===e?(r=n[1],l=n[2]):({className:r,...l}=e,n[0]=e,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=$(Bu({subcontent:!0}),du,r),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==t||n[7]!==a?(o=(0,s.jsx)(cu,{ref:t,className:a,...l}),n[5]=l,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});Ly.displayName=ui.displayName,ul=b.forwardRef((e,t)=>{let n=(0,mt.c)(15),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:r,scrollable:a,...l}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o=a===void 0?!0:a,i;n[4]!==r||n[5]!==o?(i=$(Bu(),du,o&&"overflow-auto",r),n[4]=r,n[5]=o,n[6]=i):i=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${Ib}px)`:void 0,u;n[7]!==l.style||n[8]!==c?(u={...l.style,maxHeight:c},n[7]=l.style,n[8]=c,n[9]=u):u=n[9];let m;return n[10]!==l||n[11]!==t||n[12]!==i||n[13]!==u?(m=(0,s.jsx)(Ba,{children:(0,s.jsx)(Nb,{children:(0,s.jsx)(su,{ref:t,className:i,style:u,...l})})}),n[10]=l,n[11]=t,n[12]=i,n[13]=u,n[14]=m):m=n[14],m}),ul.displayName=ni.displayName,Vt=b.forwardRef((e,t)=>{let n=(0,mt.c)(13),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:r,inset:l,variant:o,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==r||n[6]!==l||n[7]!==o?(i=$b({className:r,inset:l,variant:o}),n[5]=r,n[6]=l,n[7]=o,n[8]=i):i=n[8];let c;return n[9]!==a||n[10]!==t||n[11]!==i?(c=(0,s.jsx)(li,{ref:t,className:i,...a}),n[9]=a,n[10]=t,n[11]=i,n[12]=c):c=n[12],c}),Vt.displayName=li.displayName,bo=b.forwardRef((e,t)=>{let n=(0,mt.c)(15),r,l,a,o;n[0]===e?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:a,children:l,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]===a?i=n[6]:(i=Eb({className:a}),n[5]=a,n[6]=i);let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=Ua(),n[7]=c):c=n[7];let u;n[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("span",{className:c,children:(0,s.jsx)(ii,{children:(0,s.jsx)(mw,{className:"h-4 w-4"})})}),n[8]=u):u=n[8];let m;return n[9]!==r||n[10]!==l||n[11]!==o||n[12]!==t||n[13]!==i?(m=(0,s.jsxs)(ai,{ref:t,className:i,checked:r,...o,children:[u,l]}),n[9]=r,n[10]=l,n[11]=o,n[12]=t,n[13]=i,n[14]=m):m=n[14],m}),bo.displayName=ai.displayName;var Hy=b.forwardRef((e,t)=>{let n=(0,mt.c)(13),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:l,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o;n[4]===l?o=n[5]:(o=Ua({className:l}),n[4]=l,n[5]=o);let i;n[6]===Symbol.for("react.memo_cache_sentinel")?(i=Ua(),n[6]=i):i=n[6];let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:i,children:(0,s.jsx)(ii,{children:(0,s.jsx)(dw,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7];let u;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==o?(u=(0,s.jsxs)(oi,{ref:t,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=t,n[11]=o,n[12]=u):u=n[12],u});Hy.displayName=oi.displayName;var By=b.forwardRef((e,t)=>{let n=(0,mt.c)(11),r,l,a;n[0]===e?(r=n[1],l=n[2],a=n[3]):({className:r,inset:l,...a}=e,n[0]=e,n[1]=r,n[2]=l,n[3]=a);let o;n[4]!==r||n[5]!==l?(o=Tb({className:r,inset:l}),n[4]=r,n[5]=l,n[6]=o):o=n[6];let i;return n[7]!==a||n[8]!==t||n[9]!==o?(i=(0,s.jsx)(ri,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=i):i=n[10],i});By.displayName=ri.displayName,ml=b.forwardRef((e,t)=>{let n=(0,mt.c)(9),r,l;n[0]===e?(r=n[1],l=n[2]):({className:r,...l}=e,n[0]=e,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=$(Pb({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==t||n[7]!==a?(o=(0,s.jsx)(si,{ref:t,className:a,...l}),n[5]=l,n[6]=t,n[7]=a,n[8]=o):o=n[8],o}),ml.displayName=si.displayName;var Wy=L();const Gy=e=>{let t=(0,Wy.c)(12),{contextMenuRef:n,tableBody:r,tableRef:l,copyAllCells:a}=e,o;t[0]!==n||t[1]!==l?(o=p=>{var f;let d=n.current;if(!d)return;let g=(f=l.current)==null?void 0:f.querySelector(`[${cb}="${d.id}"]`);if(!g){ot.error("Context menu cell not found in table");return}p?g.classList.add("bg-(--green-4)"):g.classList.remove("bg-(--green-4)")},t[0]=n,t[1]=l,t[2]=o):o=t[2];let i=at(o),c;t[3]===r?c=t[4]:(c=(0,s.jsx)(So,{asChild:!0,children:r}),t[3]=r,t[4]=c);let u;t[5]!==n||t[6]!==a?(u=(0,s.jsx)(Ba,{children:(0,s.jsx)(qy,{cellRef:n,copySelectedCells:a})}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let m;return t[8]!==i||t[9]!==c||t[10]!==u?(m=(0,s.jsxs)(Oo,{onOpenChange:i,children:[c,u]}),t[8]=i,t[9]=c,t[10]=u,t[11]=m):m=t[11],m},qy=({cellRef:e,copySelectedCells:t})=>{var p;let n=$n(Ha).size>1,r=e.current;if(!r){ot.error("No cell found in context menu");return}let l=r.getContext().table,a=r.getValue(),o=Pa(l,r.row.index,r.column.id)??a,i=()=>{try{let{text:d,html:g}=Ac(o,a);an(d,g)}catch(d){ot.error("Failed to copy context menu cell",d)}},c=r.column,u=c.getCanFilter()&&((p=c.columnDef.meta)==null?void 0:p.filterType),m=d=>{c.setFilterValue(tt.select({options:[o],operator:d}))};return(0,s.jsxs)(ul,{children:[(0,s.jsxs)(Vt,{onClick:i,children:[(0,s.jsx)(el,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),n&&(0,s.jsxs)(Vt,{onClick:t,children:[(0,s.jsx)(Ri,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ml,{}),(0,s.jsxs)(Vt,{onClick:()=>m("in"),children:[(0,s.jsx)(Dn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,s.jsxs)(Vt,{onClick:()=>m("not_in"),children:[(0,s.jsx)(Dn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var Ky=L();const mu=(0,b.memo)(e=>{let t=(0,Ky.c)(9),{cellId:n,className:r}=e,l;t[0]===n?l=t[1]:(l=jy(n),t[0]=n,t[1]=l);let{isSelected:a,isCopied:o}=$n(l);if(!a&&!o)return null;let i=a&&"bg-(--green-3)",c=o&&"bg-(--green-4) transition-colors duration-150",u;t[2]!==r||t[3]!==i||t[4]!==c?(u=$("absolute inset-0 pointer-events-none",i,c,r),t[2]=r,t[3]=i,t[4]=c,t[5]=u):u=t[5];let m;return t[6]!==n||t[7]!==u?(m=(0,s.jsx)("div",{"data-cell-id":n,className:u}),t[6]=n,t[7]=u,t[8]=m):m=t[8],m});mu.displayName="CellRangeSelectionIndicator";var Uy=L();const Xy=e=>{let t=(0,Uy.c)(30),{table:n}=e,r=Sy(),l;t[0]!==r||t[1]!==n?(l=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},t[0]=r,t[1]=n,t[2]=l):l=t[2];let a=at(l),o;t[3]!==r||t[4]!==n?(o=(v,j)=>{r.updateSelection({newCell:v,isShiftKey:j,table:n})},t[3]=r,t[4]=n,t[5]=o):o=t[5];let i=at(o),c;t[6]!==r||t[7]!==n?(c=(v,j)=>{r.navigate({direction:j,isShiftKey:v.shiftKey,table:n})},t[6]=r,t[7]=n,t[8]=c):c=t[8];let u=at(c),m;t[9]!==r||t[10]!==a||t[11]!==u||t[12]!==n?(m=v=>{e:switch(v.key){case"c":qe.isMetaOrCtrl(v)&&a();break e;case"ArrowDown":v.preventDefault(),u(v,"down");break e;case"ArrowUp":v.preventDefault(),u(v,"up");break e;case"ArrowLeft":v.preventDefault(),u(v,"left");break e;case"ArrowRight":v.preventDefault(),u(v,"right");break e;case"Enter":v.preventDefault(),r.toggleCurrentRowSelection(n);break e;case"Escape":r.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),r.selectAllCells(n))}},t[9]=r,t[10]=a,t[11]=u,t[12]=n,t[13]=m):m=t[13];let p=at(m),d;t[14]!==r||t[15]!==n?(d=(v,j)=>{v.buttons!==2&&(Yy(v)||r.handleCellMouseDown({cell:j,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:n}))},t[14]=r,t[15]=n,t[16]=d):d=t[16];let g=at(d),f;t[17]===r?f=t[18]:(f=()=>{r.setIsSelecting(!1)},t[17]=r,t[18]=f);let x=at(f),w;t[19]!==r||t[20]!==n?(w=(v,j)=>{v.buttons===1&&r.updateRangeSelection({cell:j,table:n})},t[19]=r,t[20]=n,t[21]=w):w=t[21];let y=at(w),S;return t[22]!==r.clearSelection||t[23]!==g||t[24]!==y||t[25]!==x||t[26]!==p||t[27]!==a||t[28]!==i?(S={handleCellMouseDown:g,handleCellMouseUp:x,handleCellMouseOver:y,handleCopy:a,handleCellsKeyDown:p,updateSelection:i,clearSelection:r.clearSelection},t[22]=r.clearSelection,t[23]=g,t[24]=y,t[25]=x,t[26]=p,t[27]=a,t[28]=i,t[29]=S):S=t[29],S};var Jy='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element';function Yy(e){let t=e.target;return t===e.currentTarget||!(t instanceof Element)?!1:t.closest(Jy)!==null}var Qy=L(),Zy=Pe(e=>e(Pt).focusedCell);function ex(e){let t=(0,Qy.c)(2),n;t[0]===e?n=t[1]:(n=r=>{r!=null&&r.cellId&&setTimeout(()=>{var a;let l=(a=e.current)==null?void 0:a.querySelector(`[data-cell-id="${r.cellId}"]`);if(!l){ot.warn("[ScrollIntoView] Could not find cell with ID:",r.cellId);return}l.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},t[0]=e,t[1]=n),tb(Zy,n)}function tx(e,t){var r;if(!((r=e.getRowModel().rows)!=null&&r.length))return null;let n=l=>l.map(a=>a.headers.map(o=>{let{className:i,style:c}=pu(o.column);return(0,s.jsx)(_w,{className:$("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",i),style:c,ref:u=>{rx({table:e,column:o.column,thead:u})},children:o.isPlaceholder?null:al(o.column.columnDef.header,o.getContext())},o.id)}));return(0,s.jsx)(kw,{className:$(t&&"sticky top-0 z-10"),children:(0,s.jsxs)(to,{children:[n(e.getLeftHeaderGroups()),n(e.getCenterHeaderGroups()),n(e.getRightHeaderGroups()),e.getAllColumns().length<=4&&(0,s.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const nx=({table:e,columns:t,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:l,virtualize:a=!1})=>{let o=e.getRowModel().rows,[i,c]=(0,b.useState)(null),u=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>{var _,h;c(((h=(_=u.current)==null?void 0:_.parentElement)==null?void 0:h.parentElement)??null)},[]);let m=Dy({count:a?o.length:0,getScrollElement:()=>i,estimateSize:()=>24,overscan:10});ex(u);let{handleCellMouseDown:p,handleCellMouseUp:d,handleCellMouseOver:g,handleCellsKeyDown:f,handleCopy:x}=Xy({table:e}),w=(0,b.useRef)(null),y=at(_=>{w.current=_});function S(_,h){let M=/{{(\w+)}}/g,A=new Map;for(let I of h){let z=Mn({value:I.getValue(),nullAsEmptyString:!0});A.set(I.column.id,z)}return _.replaceAll(M,(I,z)=>{let V=A.get(z);return V===void 0?`{{${z}}}`:V})}let v=_=>_.map(h=>{var V,U,ee,Y;let{className:M,style:A}=pu(h.column),I=Object.assign({},((V=h.getUserStyling)==null?void 0:V.call(h))||{},A),z=((U=h.getHoverTitle)==null?void 0:U.call(h))??void 0;return(0,b.createElement)(od,{tabIndex:0,...ib(h.id),key:h.id,className:$("whitespace-pre truncate max-w-[300px] outline-hidden border-r border-r-border/75",h.column.getColumnWrapping&&((Y=(ee=h.column).getColumnWrapping)==null?void 0:Y.call(ee))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",M),style:I,title:z,onMouseDown:se=>p(se,h),onMouseUp:d,onMouseOver:se=>g(se,h),onContextMenu:()=>y(h)},(0,s.jsx)(mu,{cellId:h.id}),(0,s.jsx)("div",{className:"relative",children:al(h.column.columnDef.cell,h.getContext())}))}),j=_=>{var h;if(n){let M=(r==null?void 0:r(_.original,_.index))??_.index;(h=_.focusRow)==null||h.call(_,M)}},k=e.getState().cellHoverTemplate||null,C=_=>{var I;let h=n?(r==null?void 0:r(_.original,_.index))??_.index:void 0,M=n&&l===h,A;return k&&(A=S(k,((I=_.getVisibleCells)==null?void 0:I.call(_))??[..._.getLeftVisibleCells(),..._.getCenterVisibleCells(),..._.getRightVisibleCells()])),(0,s.jsxs)(to,{"data-state":_.getIsSelected()&&"selected",title:A,className:$("border-t h-6",n&&"cursor-pointer",M&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>j(_),children:[v(_.getLeftVisibleCells()),v(_.getCenterVisibleCells()),v(_.getRightVisibleCells()),t.length<=4&&(0,s.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},_.id)},N=t.length<=4,R=t.length+(N?1:0);return(0,s.jsx)(Gy,{tableBody:(0,s.jsx)(Rw,{onKeyDown:f,ref:u,children:(()=>{var _,h;if(o.length===0)return(0,s.jsx)(to,{children:(0,s.jsx)(od,{colSpan:R,className:"h-24 text-center",children:"No results."})});if(a){let M=m.getVirtualItems(),A=m.getTotalSize();return(0,s.jsxs)(s.Fragment,{children:[((_=M[0])==null?void 0:_.start)>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:M[0].start},children:(0,s.jsx)("td",{colSpan:R})}),M.map(I=>C(o[I.index])),M.length>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:A-(((h=M.at(-1))==null?void 0:h.end)??A)},children:(0,s.jsx)("td",{colSpan:R})})]})}return o.map(M=>C(M))})()}),contextMenuRef:w,tableRef:u,copyAllCells:x})};function pu(e){let t=e.getIsPinned(),n=t==="left"&&e.getIsLastColumn("left"),r=t==="right"&&e.getIsFirstColumn("right");return{className:$(t&&"bg-inherit","shadow-r z-10"),style:{boxShadow:n&&e.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":r?"4px 0 4px -4px var(--slate-8) inset":void 0,left:t==="left"?`${e.getStart("left")}px`:void 0,right:t==="right"?`${e.getAfter("right")}px`:void 0,opacity:1,position:t?"sticky":"relative",zIndex:t?1:0,width:e.getSize()}}}function rx({table:e,column:t,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);e.getState().columnSizing[t.id]!==r&&e.setColumnSizing(l=>({...l,[t.id]:r}))}var lx=100;const ax=({table:e,tableLoading:t,showPageSizeSelector:n})=>{let{locale:r}=Ke(),l=Math.min(e.getState().pagination.pageIndex+1,e.getPageCount()),a=e.getPageCount(),o=e.getState().pagination.pageSize,i=u=>{t||u()},c=[...new Set([5,10,25,50,100,o])].toSorted((u,m)=>u-m);return(0,s.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,s.jsx)("div",{className:"order-2 lg:order-first",children:n&&(0,s.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,s.jsxs)(Jr,{children:[(0,s.jsx)(Kr,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5",children:[o," / page",(0,s.jsx)(Yr,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsxs)(Ur,{align:"center",sideOffset:6,children:[(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...c].map(u=>(0,s.jsx)(Z,{className:$("text-xs cursor-pointer",u===o&&"font-semibold bg-accent"),onSelect:()=>e.setPageSize(u),onMouseDown:qe.preventFocus,children:u},u))]})]})})}),(0,s.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,s.jsx)(Ce,{content:"First page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>e.setPageIndex(0)),onMouseDown:qe.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,s.jsx)($o,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Previous page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>e.previousPage()),onMouseDown:qe.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,s.jsx)(gv,{className:"h-4 w-4"})})}),(0,s.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,s.jsx)("span",{children:"Page"}),(0,s.jsx)(ox,{currentPage:l,totalPages:a,onPageChange:u=>i(()=>e.setPageIndex(u))}),(0,s.jsxs)("span",{className:"shrink-0",children:["of ",Oe(a,r)]})]}),(0,s.jsx)(Ce,{content:"Next page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>e.nextPage()),onMouseDown:qe.preventFocus,disabled:!e.getCanNextPage(),children:(0,s.jsx)(Fv,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Last page",children:(0,s.jsx)(de,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>e.setPageIndex(e.getPageCount()-1)),onMouseDown:qe.preventFocus,disabled:!e.getCanNextPage(),children:(0,s.jsx)(ho,{className:"h-4 w-4"})})})]})]})},ox=({currentPage:e,totalPages:t,onPageChange:n})=>{let[r,l]=b.useState(!1),a=b.useMemo(()=>ix(e,t),[e,t]),o=i=>{n(i-1),l(!1)};return(0,s.jsxs)(Gr,{open:t>1?r:!1,onOpenChange:l,children:[(0,s.jsx)(Br,{asChild:!0,disabled:t<=1,children:(0,s.jsxs)("button",{type:"button",className:$("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",t>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:t<=1,children:[e,(0,s.jsx)(Yr,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsx)(Wr,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,s.jsxs)(ad,{shouldFilter:!0,filter:(i,c)=>i.startsWith(c)?1:0,children:[(0,s.jsx)(nd,{placeholder:`Page (1\u2013${t})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,onKeyDown:i=>{!["Backspace","Delete","ArrowLeft","ArrowRight","Tab","Enter","Escape"].includes(i.key)&&!/^\d$/.test(i.key)&&i.preventDefault()}}),(0,s.jsxs)(ld,{className:"max-h-60",children:[a.map(i=>i.type==="ellipsis"?null:(0,s.jsx)(eo,{value:String(i.page),"data-testid":"page-option",className:$("text-xs cursor-pointer",i.page===e&&"font-semibold bg-accent"),onSelect:()=>o(i.page),onMouseDown:qe.preventFocus,children:i.page},i.page)),(0,s.jsx)(rd,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"})]})]})})]})};function ix(e,t){if(t<=lx)return Sb(t).map(a=>({type:"page",page:a+1}));let n=Math.floor(t/2),r=[],l=(a,o)=>{for(let i=0;i<o;i++)r.push({type:"page",page:a+i})};return l(1,10),r.push({type:"ellipsis",key:"e1"}),e>10&&e<=n-5&&r.push({type:"page",page:e},{type:"ellipsis",key:"e1b"}),l(n-4,10),r.push({type:"ellipsis",key:"e2"}),e>n+5&&e<=t-10&&r.push({type:"page",page:e},{type:"ellipsis",key:"e2b"}),l(t-9,10),r}ko=function(e,t){return`${Oe(e,t)} ${new Tu("row").pluralize(e)}`},xo=(e,t,n)=>[e==="too_many"?"Unknown":ko(e,n),`${Oe(t,n)} ${new Tu("column").pluralize(t)}`].join(", ");var An=L(),Wa=3;const fu=e=>{let t=(0,An.c)(21),{table:n,className:r}=e,{locale:l}=Ke(),a=$n(Ha),o=xy(a);if(o<2){let f;t[0]===r?f=t[1]:(f=$("text-xs text-muted-foreground/80 italic",r),t[0]=r,t[1]=f);let x;return t[2]===f?x=t[3]:(x=(0,s.jsx)(Ce,{content:"Select multiple cells to see stats",children:(0,s.jsx)("span",{className:f,children:"No selection"})}),t[2]=f,t[3]=x),x}let i;t[4]!==a||t[5]!==n?(i=by(n,a),t[4]=a,t[5]=n,t[6]=i):i=t[6];let c=i,u;t[7]===r?u=t[8]:(u=$("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",r),t[7]=r,t[8]=u);let m;t[9]!==o||t[10]!==l?(m=(0,s.jsx)(cx,{count:o,locale:l}),t[9]=o,t[10]=l,t[11]=m):m=t[11];let p,d;t[12]!==l||t[13]!==c?(p=(0,s.jsx)(ux,{numericValues:c,locale:l}),d=(0,s.jsx)(dx,{numericValues:c,locale:l}),t[12]=l,t[13]=c,t[14]=p,t[15]=d):(p=t[14],d=t[15]);let g;return t[16]!==u||t[17]!==m||t[18]!==p||t[19]!==d?(g=(0,s.jsxs)("div",{className:u,children:[m,p,d]}),t[16]=u,t[17]=m,t[18]=p,t[19]=d,t[20]=g):g=t[20],g};var sx=(e,t)=>e.toLocaleString(t,{maximumFractionDigits:Wa}),Ga=e=>{let t=(0,An.c)(6),{name:n,value:r,locale:l}=e,a;t[0]!==l||t[1]!==r?(a=sx(r,l),t[0]=l,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,s.jsxs)("span",{children:[n,": ",a]}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o},cx=e=>{let t=(0,An.c)(3),{count:n,locale:r}=e,l;return t[0]!==n||t[1]!==r?(l=(0,s.jsx)(Ga,{name:"Count",value:n,locale:r}),t[0]=n,t[1]=r,t[2]=l):l=t[2],l},ux=e=>{let t=(0,An.c)(6),{numericValues:n,locale:r}=e;if(n.length===0)return null;let l,a;if(t[0]!==n){let c=n.reduce(mx,0);l=Number,a=c.toFixed(Wa),t[0]=n,t[1]=l,t[2]=a}else l=t[1],a=t[2];let o=l(a),i;return t[3]!==r||t[4]!==o?(i=(0,s.jsx)(Ga,{name:"Sum",value:o,locale:r}),t[3]=r,t[4]=o,t[5]=i):i=t[5],i},dx=e=>{let t=(0,An.c)(5),{numericValues:n,locale:r}=e;if(n.length===0)return null;let l=n.reduce(px,0)/n.length,a;t[0]===l?a=t[1]:(a=l.toFixed(Wa),t[0]=l,t[1]=a);let o=Number(a),i;return t[2]!==o||t[3]!==r?(i=(0,s.jsx)(Ga,{name:"Average",value:o,locale:r}),t[2]=o,t[3]=r,t[4]=i):i=t[4],i};function mx(e,t){return e+t}function px(e,t){return e+t}const fx=({pagination:e,totalColumns:t,selection:n,onRowSelectionChange:r,table:l,getRowIds:a,showPageSizeSelector:o,tableLoading:i,part:c,className:u})=>{let{locale:m}=Ke(),p=d=>{if(!r)return;if(!d){r({});return}let g=()=>{let f=Array.from({length:l.getRowCount()},(x,w)=>[w,!0]);r(Object.fromEntries(f))};if(!a){g();return}a({}).then(f=>{if(f.error){tl({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?g():r(Object.fromEntries(f.row_ids.map(x=>[x,!0])))})};return(0,s.jsxs)("div",{part:c,className:$("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,s.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:d,cellSelection:g}=l.getState(),f=Object.keys(d).length,x=l.getIsAllPageRowsSelected(),w=l.getRowCount(),y=f===w,S=n==="single-cell"||n==="multi-cell";return S&&(f=g.length,x=!1,y=!1),x&&!y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,m)," selected"]}),(0,s.jsxs)(de,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>p(!0),children:["Select all ",Oe(w,m)]})]}):f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,m)," selected"]}),(0,s.jsx)(de,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>{S?l.resetCellSelection&&l.resetCellSelection():p(!1)},children:"Clear selection"})]}):(0,s.jsx)("span",{children:xo(l.getRowCount(),t,m)})})()}),(0,s.jsx)(fu,{table:l,className:"lg:hidden"})]}),(0,s.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:e&&(0,s.jsx)(ax,{table:l,tableLoading:i,showPageSizeSelector:o})}),(0,s.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,s.jsx)(fu,{table:l,className:"px-2"})})]})};var gx=L(),Ot={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:Xu},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:hb},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:yi},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:Xu},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:mb}},hx=[Ot.CSV,Ot.JSON,Ot.PARQUET],yx=[Ot.TSV,Ot.JSON,Ot.CSV,Ot.MARKDOWN];const xx=e=>{let t=(0,gx.c)(29),{locale:n}=Ke(),[r,l]=b.useState(!1),a=r?"text-primary":"text-muted-foreground",o;t[0]===a?o=t[1]:(o=$("print:hidden text-xs gap-1",a),t[0]=a,t[1]=o);let i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(wo,{className:"w-3.5 h-3.5"}),t[2]=i):i=t[2];let c;t[3]===o?c=t[4]:(c=(0,s.jsxs)(de,{"data-testid":"export-button",size:"xs",variant:"text",className:o,children:[i,"Export"]}),t[3]=o,t[4]=c);let u=c,m;t[5]===e?m=t[6]:(m=R=>e.downloadAs({format:R}).catch(bx),t[5]=e,t[6]=m);let p=m,d;t[7]!==p||t[8]!==n?(d=async R=>{let _;e:switch(R){case"tsv":{let{url:h}=await p("json");_=ub(await qa(h),n);break e}case"json":{let{url:h}=await p("json"),M=await qa(h);_=JSON.stringify(M,null,2);break e}case"csv":{let{url:h}=await p("csv");_=await gu(h);break e}case"markdown":{let{url:h}=await p("json");_=sb(await qa(h));break e}default:kt(R);return}await an(_),tl({title:"Copied to clipboard"})},t[7]=p,t[8]=n,t[9]=d):d=t[9];let g=d,f=r?!1:void 0,x;t[10]===u?x=t[11]:(x=(0,s.jsx)(Kr,{asChild:!0,children:u}),t[10]=u,t[11]=x);let w;t[12]!==f||t[13]!==x?(w=(0,s.jsx)(Ce,{content:"Export",open:f,children:x}),t[12]=f,t[13]=x,t[14]=w):w=t[14];let y;t[15]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Download"}),t[15]=y):y=t[15];let S;t[16]===p?S=t[17]:(S=hx.map(R=>(0,s.jsxs)(Z,{onSelect:async()=>{let{url:_,filename:h}=await p(R.format),M=R.format,A=(h??"").trim();hv(_,`${fv.withoutExtension(A)||"download"}.${M}`)},children:[(0,s.jsx)(R.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:R.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:R.description})]})]},R.label)),t[16]=p,t[17]=S);let v,j;t[18]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(ln,{}),j=(0,s.jsx)(Ja,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),t[18]=v,t[19]=j):(v=t[18],j=t[19]);let k;t[20]===g?k=t[21]:(k=yx.map(R=>(0,s.jsxs)(Z,{onSelect:async()=>{try{await g(R.format)}catch(_){tl({title:"Failed to copy to clipboard",description:aw(_),variant:"danger"})}},children:[(0,s.jsx)(R.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:R.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:R.description})]})]},R.label)),t[20]=g,t[21]=k);let C;t[22]!==S||t[23]!==k?(C=(0,s.jsxs)(Ur,{side:"bottom",className:"print:hidden",children:[y,S,v,j,k]}),t[22]=S,t[23]=k,t[24]=C):C=t[24];let N;return t[25]!==r||t[26]!==C||t[27]!==w?(N=(0,s.jsxs)(Jr,{modal:!1,open:r,onOpenChange:l,children:[w,C]}),t[25]=r,t[26]=C,t[27]=w,t[28]=N):N=t[28],N};function qa(e){return gu(e).then(Ou)}function gu(e){return fetch(e).then(t=>{if(!t.ok)throw Error(t.statusText);return t.text()})}function bx(e){throw tl({title:"Failed to download",description:"message"in e?e.message:String(e)}),e}var vx=()=>{};let hu;hu=({enableSearch:e,searchQuery:t,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:a,toggleDisplayHeader:o,showTableExplorer:i,togglePanel:c,isAnyPanelOpen:u,downloadAs:m})=>{let[p,d]=(0,b.useState)(t||""),g=y1(p,500),f=at(n??vx),x=b.useRef(null);return(0,b.useEffect)(()=>{f(g)},[g,f]),e&&n||l||i||m?(0,s.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&e&&(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-1 px-2 rounded-sm focus-within:ring-1 focus-within:ring-border transition-shadow",children:[(0,s.jsx)(Qu,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,s.jsx)("input",{ref:x,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:p,onKeyDown:w=>{var y;w.key==="Escape"&&(d(""),(y=x.current)==null||y.blur())},onChange:w=>d(w.target.value),placeholder:"Search..."}),r&&(0,s.jsx)(Yu,{size:"small"}),p&&(0,s.jsx)(de,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>d(""),children:(0,s.jsx)(Qr,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,s.jsxs)("div",{className:"flex items-center shrink-0",children:[l&&(0,s.jsxs)(de,{variant:"text",size:"xs",className:$("print:hidden text-xs gap-1",a?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,s.jsx)(xi,{className:"w-3.5 h-3.5"}),"Visualize"]}),i&&c&&(0,s.jsxs)(de,{variant:"text",size:"xs",className:$("print:hidden text-xs gap-1",u?"text-primary":"text-muted-foreground"),onClick:()=>c(pl.ROW_VIEWER),children:[(0,s.jsx)(ki,{className:"w-3.5 h-3.5"}),"Explore"]}),m&&(0,s.jsx)(xx,{downloadAs:m})]})]}):null},Eo=(0,b.memo)(({wrapperClassName:e,className:t,maxHeight:n,columns:r,data:l,rawData:a,selection:o,totalColumns:i,totalRows:c,manualSorting:u=!1,sorting:m,setSorting:p,rowSelection:d,cellSelection:g,cellStyling:f,hoverTemplate:x,cellHoverTexts:w,paginationState:y,setPaginationState:S,downloadAs:v,manualPagination:j=!1,pagination:k=!1,onRowSelectionChange:C,onCellSelectionChange:N,getRowIds:R,enableSearch:_=!1,searchQuery:h,onSearchQueryChange:M,showFilters:A=!1,filters:I,onFiltersChange:z,reloading:V,freezeColumnsLeft:U,freezeColumnsRight:ee,toggleDisplayHeader:Y,showChartBuilder:se,isChartBuilderOpen:W,showPageSizeSelector:X,showTableExplorer:Se,togglePanel:ue,isPanelOpen:je,isAnyPanelOpen:Ae,viewedRowIdx:ze,onViewedRowChange:Be})=>{let[Ie,lt]=b.useState(!1),{locale:pt}=Ke(),{columnPinning:Ee,setColumnPinning:We}=iy(U,ee);b.useEffect(()=>{let pe;return V?pe=setTimeout(()=>{lt(!0)},300):lt(!1),()=>{pe&&clearTimeout(pe)}},[V]);function G(pe,Re){return y?Re+(j?y.pageIndex*y.pageSize:0):Re}let te=io({_features:[kc,$1,K0,Z1,ty,Q1,J1,ny,ay],data:l,columns:r,meta:{rawData:a},getCoreRowModel:Ao(),rowCount:c==="too_many"?void 0:c,...S?{onPaginationChange:S,getRowId:(pe,Re)=>{let E=_r(pe);if(E)return E;let Ve=G(pe,Re);return String(Ve)}}:{},locale:pt,manualPagination:j,getPaginationRowModel:B0(),...p?{onSortingChange:p}:{},manualSorting:u,enableMultiSort:!0,getSortedRowModel:go(),manualFiltering:!0,enableColumnFilters:A,getFilteredRowModel:oo(),onColumnFiltersChange:z,onRowSelectionChange:C,onCellSelectionChange:N,enableCellSelection:o==="single-cell"||o==="multi-cell",enableMultiCellSelection:o==="multi-cell",onColumnPinningChange:We,enableFocusRow:!0,onFocusRowChange:Be,state:{...m?{sorting:m}:{},columnFilters:I,...y?{pagination:y}:k&&!y?{}:{pagination:{pageIndex:0,pageSize:l.length}},rowSelection:d??{},cellSelection:g??[],cellStyling:f,columnPinning:Ee,cellHoverTemplate:x,cellHoverTexts:w??{}}}),_e=(je==null?void 0:je(pl.ROW_VIEWER))??!1,Q=!k&&l.length>100,me=cy({maxHeight:n,virtualize:Q});return(0,s.jsxs)("div",{className:$(e,"flex flex-col space-y-1"),children:[(0,s.jsx)(ry,{filters:I,table:te}),(0,s.jsx)(Ry,{children:(0,s.jsxs)("div",{part:"table-wrapper",className:$(t||"rounded-md border overflow-hidden"),children:[(0,s.jsx)(hu,{enableSearch:_,searchQuery:h,onSearchQueryChange:M,reloading:V,showChartBuilder:se,isChartBuilderOpen:W,toggleDisplayHeader:Y,showTableExplorer:Se,togglePanel:ue,isAnyPanelOpen:Ae,downloadAs:v}),(0,s.jsxs)(Mw,{className:$("relative",r.length<=4?"w-auto":"w-full"),ref:me,children:[Ie&&(0,s.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),tx(te,Q||!!n),(0,s.jsx)(nx,{table:te,columns:r,rowViewerPanelOpen:_e,getRowIndex:G,viewedRowIdx:ze,virtualize:Q})]}),(0,s.jsx)(fx,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:i,pagination:k,selection:o,onRowSelectionChange:C,table:te,getRowIds:R,showPageSizeSelector:X,tableLoading:V})]})})]})});var Qt=L(),wx=25;No=function(e){return e?e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")||e.startsWith("application/pdf"):!1},il={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};function Or(e){return e.url==null?Ov(e.base64,e.mime):e.url}let Ka,yu,xu,bu,vu,wu;Ka=({contents:e})=>{let t=(0,b.useMemo)(()=>Za(e),[e]),[n,r]=(0,b.useState)({pageIndex:0,pageSize:wx}),l=(0,b.useMemo)(()=>jo(t),[t]),a=(0,b.useMemo)(()=>uo({rowHeaders:xv.EMPTY,selection:null,fieldTypes:l}),[l]);return(0,s.jsx)(Eo,{data:t,totalRows:t.length,columns:a,totalColumns:a.length,manualPagination:!1,paginationState:n,setPaginationState:r,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex overflow-hidden",rowSelection:Lr.EMPTY})},yu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("img",{src:n,alt:"Preview"}),t[2]=n,t[3]=r),r},xu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("audio",{controls:!0,src:n}),t[2]=n,t[3]=r),r},bu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("video",{controls:!0,src:n}),t[2]=n,t[3]=r),r},vu=e=>{let t=(0,Qt.c)(4),n;t[0]===e?n=t[1]:(n=Or(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,s.jsx)("iframe",{src:n,title:"PDF Viewer",className:"w-full h-full"}),t[2]=n,t[3]=r),r},wu=e=>{let t=(0,Qt.c)(11),n,r;if(t[0]===e?(n=t[1],r=t[2]):({mimeType:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n.startsWith("image/")){let l;return t[3]===r?l=t[4]:(l=(0,s.jsx)(yu,{...r}),t[3]=r,t[4]=l),l}if(n.startsWith("audio/")){let l;return t[5]===r?l=t[6]:(l=(0,s.jsx)(xu,{...r}),t[5]=r,t[6]=l),l}if(n.startsWith("video/")){let l;return t[7]===r?l=t[8]:(l=(0,s.jsx)(bu,{...r}),t[7]=r,t[8]=l),l}if(n.startsWith("application/pdf")){let l;return t[9]===r?l=t[10]:(l=(0,s.jsx)(vu,{...r}),t[9]=r,t[10]=l),l}return null},vd=e=>{let t=(0,Qt.c)(17),{mimeType:n,contents:r,mediaSource:l,readOnly:a,onChange:o,extensions:i}=e,c=a===void 0?!0:a,u;t[0]===i?u=t[1]:(u=i===void 0?[]:i,t[0]=i,t[1]=u);let m=u,{theme:p}=nl();if(n==="text/csv"&&r!=null){let d;return t[2]===r?d=t[3]:(d=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(Ka,{contents:r})}),t[2]=r,t[3]=d),d}if(No(n)&&l){let d;return t[4]!==l||t[5]!==n?(d=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(wu,{...l,mimeType:n})}),t[4]=l,t[5]=n,t[6]=d):d=t[6],d}if(r!=null){let d=il[n]||il.default,g=p==="dark"?"dark":"light",f;t[7]===m?f=t[8]:(f=[Ku.lineWrapping,...m],t[7]=m,t[8]=f);let x=c?!1:void 0,w=c?void 0:o,y;return t[9]!==r||t[10]!==d||t[11]!==c||t[12]!==g||t[13]!==f||t[14]!==x||t[15]!==w?(y=(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(b.Suspense,{children:(0,s.jsx)(kv,{theme:g,language:d,className:"border-b",extensions:f,value:r,readOnly:c,editable:x,onChange:w})})}),t[9]=r,t[10]=d,t[11]=c,t[12]=g,t[13]=f,t[14]=x,t[15]=w,t[16]=y):y=t[16],y}return null};function Sx(e,t){let{state:n}=e,r=n.doc;if(t<=0||t>r.lines)return ot.warn(`Invalid line number: ${t}. Document has ${r.lines} lines.`),!1;let l=r.line(t);if(l.text.includes("breakpoint()"))return!0;let a=l.text.match(/^(\s*)/),o=`${a?a[1]:""}breakpoint()
46
46
  `,i=l.from;return e.dispatch({changes:{from:i,to:i,insert:o},selection:{anchor:i+o.length-1,head:i+o.length-1},scrollIntoView:!0,effects:[Ku.scrollIntoView(i,{y:"center"})]}),e.focus(),!0}var Su=L(),Cu="item";const Cx=e=>{var Se;let t=(0,Su.c)(47),{onRefactorWithAI:n,traceback:r,cellId:l}=e,a;t[0]===r?a=t[1]:(a=Ya({html:r,additionalReplacements:[kx,_x]}),t[0]=r,t[1]=a);let o=a,[i,c]=(0,b.useState)(!0),u=jx(r),m=$n(jb),p;t[2]===r?p=t[3]:(p=(Se=xb(r))==null?void 0:Se.at(0),t[2]=r,t[3]=p);let d=p,g;t[4]!==l||t[5]!==d?(g=d&&d.kind==="cell"&&!Vu()&&!Ln()&&l!=="__scratch__",t[4]=l,t[5]=d,t[6]=g):g=t[6];let f=g,x;t[7]!==m||t[8]!==n?(x=n&&m&&!Ln(),t[7]=m,t[8]=n,t[9]=x):x=t[9];let w=x,y=!Ln(),S=ue=>{n==null||n({prompt:`My code gives the following error:
47
47
 
48
48
  ${u}`,triggerImmediately:ue})},[v,j]=u.split(":",2),k=i?Cu:"",C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=()=>c(Mx),t[10]=C):C=t[10];let N=i?"rotate-180":"rotate-0",R;t[11]===N?R=t[12]:(R=$("h-4 w-4 text-muted-foreground transition-transform duration-200 shrink-0",N),t[11]=N,t[12]=R);let _;t[13]===R?_=t[14]:(_=(0,s.jsx)(Yr,{className:R}),t[13]=R,t[14]=_);let h=v||"Error",M;t[15]===h?M=t[16]:(M=(0,s.jsxs)("span",{className:"text-destructive",children:[h,":"]}),t[15]=h,t[16]=M);let A;t[17]!==j||t[18]!==M?(A=(0,s.jsxs)("div",{className:"text-sm inline font-mono",children:[M," ",j]}),t[17]=j,t[18]=M,t[19]=A):A=t[19];let I;t[20]!==A||t[21]!==_?(I=(0,s.jsxs)("div",{className:"flex gap-2 h-10 px-2 hover:bg-muted rounded-sm select-none items-center cursor-pointer transition-all",onClick:C,children:[_,A]}),t[20]=A,t[21]=_,t[22]=I):I=t[22];let z;t[23]===o?z=t[24]:(z=(0,s.jsx)(Db,{className:"text-muted-foreground px-4 pt-2 text-xs overflow-auto",children:o}),t[23]=o,t[24]=z);let V;t[25]!==I||t[26]!==z?(V=(0,s.jsxs)(zb,{value:Cu,className:"border-none",children:[I,z]}),t[25]=I,t[26]=z,t[27]=V):V=t[27];let U;t[28]!==V||t[29]!==k?(U=(0,s.jsx)(Vb,{type:"single",collapsible:!0,value:k,children:V}),t[28]=V,t[29]=k,t[30]=U):U=t[30];let ee;t[31]!==S||t[32]!==w?(ee=w&&(0,s.jsx)(Bv,{tooltip:"Fix with AI",openPrompt:()=>S(!1),applyAutofix:()=>S(!0)}),t[31]=S,t[32]=w,t[33]=ee):ee=t[33];let Y;t[34]!==f||t[35]!==d?(Y=f&&(0,s.jsx)(Ce,{content:"Attach pdb to the exception point.",children:(0,s.jsxs)(de,{size:"xs",variant:"outline",onClick:()=>{Uu().sendPdb({cellId:d.cellId})},children:[(0,s.jsx)(fl,{className:"h-3 w-3 mr-2"}),"Launch debugger"]})}),t[34]=f,t[35]=d,t[36]=Y):Y=t[36];let se;t[37]!==u||t[38]!==r?(se=y&&(0,s.jsxs)(Jr,{children:[(0,s.jsx)(Kr,{asChild:!0,children:(0,s.jsxs)(de,{size:"xs",variant:"text",children:["Get help",(0,s.jsx)(Yr,{className:"h-3 w-3 ml-1"})]})}),(0,s.jsxs)(Ur,{align:"end",className:"w-56",children:[(0,s.jsx)(Z,{asChild:!0,children:(0,s.jsxs)("a",{target:"_blank",href:`https://www.google.com/search?q=${encodeURIComponent(u)}`,rel:"noreferrer",children:[(0,s.jsx)(Qu,{className:"h-4 w-4 mr-2"}),"Search on Google",(0,s.jsx)(Ju,{className:"h-3 w-3 ml-auto"})]})}),(0,s.jsx)(Z,{asChild:!0,children:(0,s.jsxs)("a",{target:"_blank",href:"https://marimo.io/discord?ref=notebook",rel:"noopener",children:[(0,s.jsx)(Hv,{className:"h-4 w-4 mr-2"}),"Ask in Discord",(0,s.jsx)(Ju,{className:"h-3 w-3 ml-auto"})]})}),(0,s.jsxs)(Z,{onClick:()=>{let ue=document.createElement("div");ue.innerHTML=zu(r),an(ue.textContent||"")},children:[(0,s.jsx)(el,{className:"h-4 w-4 mr-2"}),"Copy to clipboard"]})]})]}),t[37]=u,t[38]=r,t[39]=se):se=t[39];let W;t[40]!==ee||t[41]!==Y||t[42]!==se?(W=(0,s.jsxs)("div",{className:"flex gap-2",children:[ee,Y,se]}),t[40]=ee,t[41]=Y,t[42]=se,t[43]=W):W=t[43];let X;return t[44]!==U||t[45]!==W?(X=(0,s.jsxs)("div",{className:"flex flex-col gap-2 min-w-full w-fit",children:[U,W]}),t[44]=U,t[45]=W,t[46]=X):X=t[46],X};function jx(e){var n,r;let t=document.createElement("div");return t.innerHTML=zu(e),((r=(n=t.textContent)==null?void 0:n.split(`
@@ -1,4 +1,4 @@
1
- var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as oe}from"./chunk-LvLJmgfZ.js";import{t as Ze}from"./react-Bj1aDYRI.js";import{Dt as ce,E as Qe,Un as g}from"./cells-EJo3u4za.js";import{D as M,P as y,R as u,T as D,_ as ae,i as Je,k as _,m as Ye}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as Xe}from"./useEventListener-DGjKht0c.js";import{t as G}from"./cn-DYvqRARy.js";import{t as et}from"./jsx-runtime-Blw4afVn.js";import{a as tt,c as ie,o as le,s as st}from"./popover-AtoFZ7i4.js";import{c as rt,i as nt,n as ot,r as ct,s as at,t as it}from"./select--zcABebs.js";import{a as J,c as de,o as lt,p as dt,r as pt,t as ht}from"./dropdown-menu-DrHAuMTb.js";import{m as mt,o as ut,t as bt,u as a}from"./form-BiDLPu7R.js";import{t as Y}from"./button-BKVLeSTX.js";import{l as ft}from"./arrays-DAC2orgH.js";import{r as U}from"./strings-pfr2N700.js";import{t as gt}from"./createLucideIcon-w-Qo9n0R.js";import{t as yt}from"./circle-plus-ifSmVHqa.js";import{t as _t}from"./database-zap-BxfYZ6ML.js";import{t as St}from"./github-C3N4cuN4.js";import{n as wt}from"./DeferredRequestRegistry-BLWK1eKa.js";import{o as xt,r as kt}from"./input-Bg12i6qY.js";import{a as vt,c as $t,d as jt,g as At,l as Ct,o as Rt,p as Tt,s as Lt,u as Dt}from"./textarea-Cfp3upzK.js";import{r as It}from"./useTheme-DCDmxPD0.js";import{a as Pt,c as qt,l as Nt,n as Ft,r as Et,t as Bt}from"./dialog-BYjetQgE.js";import{n as Ot}from"./ImperativeModal-DoGv2BXV.js";import{t as V}from"./links-DOybeRem.js";import{n as Mt}from"./useAsyncData-aCoWDe-l.js";import{o as Ut}from"./focus-DXeddo75.js";import{n as Kt,t as Ht}from"./azure-C2phEgLq.js";import{t as Wt}from"./request-registry-1QRLEb_0.js";import{n as zt,t as Gt}from"./write-secret-modal-CHfFN0H8.js";var X=gt("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Ir(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Vt=B(),N=oe(Ze(),1),o=oe(et(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Xe.NOOP});const Zt=()=>(0,N.use)(he),Qt=t=>{let e=(0,Vt.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:d,error:i,refetch:c}=Mt(ts,n),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let h;e[3]===(r==null?void 0:r.providerNames)?h=e[4]:(h=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=h);let p;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==l||e[9]!==h?(p={secretKeys:l,providerNames:h,loading:d,error:i,refreshSecrets:c},e[5]=i,e[6]=d,e[7]=c,e[8]=l,e[9]=h,e[10]=p):p=e[10];let f;return e[11]!==s||e[12]!==p?(f=(0,o.jsx)(he,{value:p,children:s}),e[11]=s,e[12]=p,e[13]=f):f=e[13],f},Jt={isMatch:t=>{if(t instanceof ae||t instanceof Ye){let{optionRegex:e}=a.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:d}=Zt(),{openModal:i,closeModal:c}=Ot(),{label:l,description:h,optionRegex:p=""}=a.parse(t.description||""),[f,b]=ft(n,m=>new RegExp(p,"i").test(m));return(0,o.jsx)($t,{control:e.control,name:s,render:({field:m})=>(0,o.jsxs)(Ct,{children:[(0,o.jsx)(Dt,{children:l}),(0,o.jsx)(Rt,{children:h}),(0,o.jsx)(vt,{children:(0,o.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,o.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,o.jsx)(xt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,o.jsxs)(ht,{children:[(0,o.jsx)(dt,{asChild:!0,children:(0,o.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,o.jsx)(wt,{className:"h-3 w-3"})})}),(0,o.jsxs)(pt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,o.jsxs)(J,{onSelect:()=>{i((0,o.jsx)(Gt,{providerNames:r,onSuccess:S=>{d(),m.onChange(te(S)),c()},onClose:c}))},children:[(0,o.jsx)(yt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(de,{}),(0,o.jsx)(lt,{children:"Recommended"})]}),f.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S)),b.length>0&&(0,o.jsx)(de,{}),b.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S))]})]})]})}),(0,o.jsx)(jt,{})]})})}};function Yt(t){return t.provider!=="env"}function Xt(t){return t.name}function es(t){return t.keys}async function ts(){let t=await Wt.request({}),e=zt(t.secrets).filter(Yt).map(Xt);return{secretKeys:t.secrets.flatMap(es).toSorted(),providerNames:e}}var H=B(),ss=[Jt];const se=t=>{let e=(0,H.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},re=t=>{let e=(0,H.c)(9),{name:s,color:n,icon:r,onSelect:d}=t,i;e[0]===n?i=e[1]:(i={backgroundColor:n},e[0]=n,e[1]=i);let c;e[2]===s?c=e[3]:(c=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=c);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==c?(l=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,c]}),e[4]=r,e[5]=d,e[6]=i,e[7]=c,e[8]=l):l=e[8],l},rs=t=>{let e=(0,H.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:c,libraryLabel:l}=t,h=l===void 0?"Preferred library":l,p;e[0]===s?p=e[1]:(p=(0,o.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=p);let f=!n,b;e[2]===f?b=e[3]:(b=(0,o.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==p||e[5]!==b?(m=(0,o.jsxs)("div",{className:"flex gap-2",children:[p,b]}),e[4]=p,e[5]=b,e[6]=m):m=e[6];let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=(0,o.jsx)(at,{children:(0,o.jsx)(rt,{placeholder:"Select a library"})}),e[7]=S):S=e[7];let w;e[8]===h?w=e[9]:(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[S,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:h})]}),e[8]=h,e[9]=w);let $;if(e[10]!==c||e[11]!==r){let j;e[13]===c?j=e[14]:(j=T=>(0,o.jsx)(nt,{value:T,children:c[T]??T},T),e[13]=c,e[14]=j),$=r.map(j),e[10]=c,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,o.jsx)(ot,{children:(0,o.jsx)(ct,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==w||e[20]!==x?(v=(0,o.jsx)("div",{children:(0,o.jsxs)(it,{value:d,onValueChange:i,children:[w,x]})}),e[17]=i,e[18]=d,e[19]=w,e[20]=x,e[21]=v):v=e[21];let A;return e[22]!==v||e[23]!==m?(A=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=A):A=e[24],A};function ns(){let t=(0,H.c)(3),{createNewCell:e}=Qe(),s=Ut(),n;return t[0]!==e||t[1]!==s?(n=r=>{e({code:r,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:c,onSubmit:l,onBack:h}=t,p;e[0]===s?p=e[1]:(p=ut(s),e[0]=s,e[1]=p);let f=p,b;e[2]===s?b=e[3]:(b=Tt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let S=At(m),[w,$]=N.useState(r),x=ns(),v;e[7]!==c||e[8]!==x||e[9]!==l||e[10]!==w?(v=ze=>{x(c(ze,w)),l()},e[7]=c,e[8]=x,e[9]=l,e[10]=w,e[11]=v):v=e[11];let A=v,j;e[12]!==S||e[13]!==A?(j=S.handleSubmit(A),e[12]=S,e[13]=A,e[14]=j):j=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=(0,o.jsx)(Lt,{}),e[15]=T):T=e[15];let F;e[16]!==S||e[17]!==s?(F=(0,o.jsx)(Qt,{children:(0,o.jsx)(bt,{schema:s,form:S,renderers:ss,children:T})}),e[16]=S,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==S.formState.isValid||e[21]!==n||e[22]!==i||e[23]!==h||e[24]!==w?(E=(0,o.jsx)(rs,{onBack:h,isValid:S.formState.isValid,libraries:n,preferredLibrary:w,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=S.formState.isValid,e[21]=n,e[22]=i,e[23]=h,e[24]=w,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=W):W=e[29],W};function I(){return u().optional().describe(a.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(a.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(a.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function ne(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(a.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(a.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function C(){return u().describe(a.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function os(){return u().describe(a.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function R(){return u().nonempty().describe(a.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Je().describe(a.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(a.of({label:"Read Only"}))}const be=y({type:_("postgres"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),fe=y({type:_("mysql"),host:L(),port:P(3306),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),ge=y({type:_("sqlite"),database:C().describe(a.of({label:"Database Path"}))}).describe(a.of({direction:"two-columns"})),ye=y({type:_("duckdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),_e=y({type:_("motherduck"),database:C().default("my_db").describe(a.of({label:"Database Name"})),token:Z()}).describe(a.of({direction:"two-columns"})),Se=y({type:_("snowflake"),account:u().nonempty().describe(a.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(a.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:C(),schema:u().optional().describe(a.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(a.of({label:"Role"})),authType:M("type",[y({type:_("Password"),username:R(),password:I(),enable_mfa:D().default(!1).describe(a.of({label:"Enable MFA (Duo Push)"}))}),y({type:_("SSO (Browser)"),username:R()}),y({type:_("Key Pair"),username:R(),private_key_path:u().nonempty().describe(a.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(a.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),y({type:_("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(a.of({special:"tabs"}))}).describe(a.of({direction:"two-columns"})),we=y({type:_("bigquery"),project:u().nonempty().describe(a.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(a.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(a.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(a.of({direction:"two-columns"})),xe=y({type:_("clickhouse_connect"),host:L(),port:P(8123).optional(),username:R(),password:I(),secure:D().default(!1).describe(a.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(a.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(a.of({direction:"two-columns"})),ke=y({type:_("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:R().default("default"),password:I().default("")}).describe(a.of({direction:"two-columns"})),ve=y({type:_("chdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),$e=y({type:_("trino"),host:L(),port:P(8080),database:C(),schema:os().optional(),username:R(),password:I(),async_support:D().default(!1).describe(a.of({label:"Async Support"}))}).describe(a.of({direction:"two-columns"})),je=y({type:_("iceberg"),name:u().describe(a.of({label:"Catalog Name"})),catalog:M("type",[y({type:_("REST"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),y({type:_("SQL"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),y({type:_("Hive"),warehouse:Q(),uri:ne()}),y({type:_("Glue"),warehouse:Q(),uri:ne()}),y({type:_("DynamoDB"),"dynamodb.profile-name":u().optional().describe(a.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(a.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(a.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(a.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(a.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(a.of({special:"tabs"}))}),Ae=y({type:_("datafusion"),sessionContext:D().optional().describe(a.of({label:"Use Session Context"}))}),Ce=y({type:_("pyspark"),host:L().optional(),port:P().optional()}),Re=y({type:_("redshift"),host:L(),port:P(5439),connectionType:M("type",[y({type:_("IAM credentials"),region:u().describe(a.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(a.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(a.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(a.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),y({type:_("DB credentials"),user:R(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:C()}).describe(a.of({direction:"two-columns"})),Te=y({type:_("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:ne("HTTP Path",!0),catalog:u().optional().describe(a.of({label:"Catalog"})),schema:u().optional().describe(a.of({label:"Schema"}))}).describe(a.of({direction:"two-columns"})),Le=y({type:_("supabase"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),disable_client_pooling:D().default(!1).describe(a.of({label:"Disable Client-Side Pooling"}))}).describe(a.of({direction:"two-columns"})),cs=M("type",[be,fe,ge,ye,_e,Se,we,xe,ke,ve,$e,je,Ae,Ce,Re,Te,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},as=t=>`_${t}`,is=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=as(t),K(e)){let n=pe(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
1
+ var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as oe}from"./chunk-LvLJmgfZ.js";import{t as Ze}from"./react-Bj1aDYRI.js";import{Dt as ce,E as Qe,Un as g}from"./cells-EJo3u4za.js";import{D as M,P as y,R as u,T as D,_ as ae,i as Je,k as _,m as Ye}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as Xe}from"./useEventListener-DGjKht0c.js";import{t as G}from"./cn-DYvqRARy.js";import{t as et}from"./jsx-runtime-Blw4afVn.js";import{a as tt,c as ie,o as le,s as st}from"./popover-AtoFZ7i4.js";import{c as rt,i as nt,n as ot,r as ct,s as at,t as it}from"./select--zcABebs.js";import{a as J,c as de,o as lt,p as dt,r as pt,t as ht}from"./dropdown-menu-DrHAuMTb.js";import{m as mt,o as ut,t as bt,u as a}from"./form-30oC5z9y.js";import{t as Y}from"./button-BKVLeSTX.js";import{l as ft}from"./arrays-DAC2orgH.js";import{r as U}from"./strings-pfr2N700.js";import{t as gt}from"./createLucideIcon-w-Qo9n0R.js";import{t as yt}from"./circle-plus-ifSmVHqa.js";import{t as _t}from"./database-zap-BxfYZ6ML.js";import{t as St}from"./github-C3N4cuN4.js";import{n as wt}from"./DeferredRequestRegistry-BLWK1eKa.js";import{o as xt,r as kt}from"./input-Bg12i6qY.js";import{a as vt,c as $t,d as jt,g as At,l as Ct,o as Rt,p as Tt,s as Lt,u as Dt}from"./textarea-Cfp3upzK.js";import{r as It}from"./useTheme-DCDmxPD0.js";import{a as Pt,c as qt,l as Nt,n as Ft,r as Et,t as Bt}from"./dialog-BYjetQgE.js";import{n as Ot}from"./ImperativeModal-DoGv2BXV.js";import{t as V}from"./links-DOybeRem.js";import{n as Mt}from"./useAsyncData-aCoWDe-l.js";import{o as Ut}from"./focus-DXeddo75.js";import{n as Kt,t as Ht}from"./azure-C2phEgLq.js";import{t as Wt}from"./request-registry-1QRLEb_0.js";import{n as zt,t as Gt}from"./write-secret-modal-CHfFN0H8.js";var X=gt("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Ir(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Vt=B(),N=oe(Ze(),1),o=oe(et(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Xe.NOOP});const Zt=()=>(0,N.use)(he),Qt=t=>{let e=(0,Vt.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:d,error:i,refetch:c}=Mt(ts,n),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let h;e[3]===(r==null?void 0:r.providerNames)?h=e[4]:(h=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=h);let p;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==l||e[9]!==h?(p={secretKeys:l,providerNames:h,loading:d,error:i,refreshSecrets:c},e[5]=i,e[6]=d,e[7]=c,e[8]=l,e[9]=h,e[10]=p):p=e[10];let f;return e[11]!==s||e[12]!==p?(f=(0,o.jsx)(he,{value:p,children:s}),e[11]=s,e[12]=p,e[13]=f):f=e[13],f},Jt={isMatch:t=>{if(t instanceof ae||t instanceof Ye){let{optionRegex:e}=a.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:d}=Zt(),{openModal:i,closeModal:c}=Ot(),{label:l,description:h,optionRegex:p=""}=a.parse(t.description||""),[f,b]=ft(n,m=>new RegExp(p,"i").test(m));return(0,o.jsx)($t,{control:e.control,name:s,render:({field:m})=>(0,o.jsxs)(Ct,{children:[(0,o.jsx)(Dt,{children:l}),(0,o.jsx)(Rt,{children:h}),(0,o.jsx)(vt,{children:(0,o.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,o.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,o.jsx)(xt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,o.jsxs)(ht,{children:[(0,o.jsx)(dt,{asChild:!0,children:(0,o.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,o.jsx)(wt,{className:"h-3 w-3"})})}),(0,o.jsxs)(pt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,o.jsxs)(J,{onSelect:()=>{i((0,o.jsx)(Gt,{providerNames:r,onSuccess:S=>{d(),m.onChange(te(S)),c()},onClose:c}))},children:[(0,o.jsx)(yt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(de,{}),(0,o.jsx)(lt,{children:"Recommended"})]}),f.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S)),b.length>0&&(0,o.jsx)(de,{}),b.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S))]})]})]})}),(0,o.jsx)(jt,{})]})})}};function Yt(t){return t.provider!=="env"}function Xt(t){return t.name}function es(t){return t.keys}async function ts(){let t=await Wt.request({}),e=zt(t.secrets).filter(Yt).map(Xt);return{secretKeys:t.secrets.flatMap(es).toSorted(),providerNames:e}}var H=B(),ss=[Jt];const se=t=>{let e=(0,H.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},re=t=>{let e=(0,H.c)(9),{name:s,color:n,icon:r,onSelect:d}=t,i;e[0]===n?i=e[1]:(i={backgroundColor:n},e[0]=n,e[1]=i);let c;e[2]===s?c=e[3]:(c=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=c);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==c?(l=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,c]}),e[4]=r,e[5]=d,e[6]=i,e[7]=c,e[8]=l):l=e[8],l},rs=t=>{let e=(0,H.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:c,libraryLabel:l}=t,h=l===void 0?"Preferred library":l,p;e[0]===s?p=e[1]:(p=(0,o.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=p);let f=!n,b;e[2]===f?b=e[3]:(b=(0,o.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==p||e[5]!==b?(m=(0,o.jsxs)("div",{className:"flex gap-2",children:[p,b]}),e[4]=p,e[5]=b,e[6]=m):m=e[6];let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=(0,o.jsx)(at,{children:(0,o.jsx)(rt,{placeholder:"Select a library"})}),e[7]=S):S=e[7];let w;e[8]===h?w=e[9]:(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[S,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:h})]}),e[8]=h,e[9]=w);let $;if(e[10]!==c||e[11]!==r){let j;e[13]===c?j=e[14]:(j=T=>(0,o.jsx)(nt,{value:T,children:c[T]??T},T),e[13]=c,e[14]=j),$=r.map(j),e[10]=c,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,o.jsx)(ot,{children:(0,o.jsx)(ct,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==w||e[20]!==x?(v=(0,o.jsx)("div",{children:(0,o.jsxs)(it,{value:d,onValueChange:i,children:[w,x]})}),e[17]=i,e[18]=d,e[19]=w,e[20]=x,e[21]=v):v=e[21];let A;return e[22]!==v||e[23]!==m?(A=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=A):A=e[24],A};function ns(){let t=(0,H.c)(3),{createNewCell:e}=Qe(),s=Ut(),n;return t[0]!==e||t[1]!==s?(n=r=>{e({code:r,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:c,onSubmit:l,onBack:h}=t,p;e[0]===s?p=e[1]:(p=ut(s),e[0]=s,e[1]=p);let f=p,b;e[2]===s?b=e[3]:(b=Tt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let S=At(m),[w,$]=N.useState(r),x=ns(),v;e[7]!==c||e[8]!==x||e[9]!==l||e[10]!==w?(v=ze=>{x(c(ze,w)),l()},e[7]=c,e[8]=x,e[9]=l,e[10]=w,e[11]=v):v=e[11];let A=v,j;e[12]!==S||e[13]!==A?(j=S.handleSubmit(A),e[12]=S,e[13]=A,e[14]=j):j=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=(0,o.jsx)(Lt,{}),e[15]=T):T=e[15];let F;e[16]!==S||e[17]!==s?(F=(0,o.jsx)(Qt,{children:(0,o.jsx)(bt,{schema:s,form:S,renderers:ss,children:T})}),e[16]=S,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==S.formState.isValid||e[21]!==n||e[22]!==i||e[23]!==h||e[24]!==w?(E=(0,o.jsx)(rs,{onBack:h,isValid:S.formState.isValid,libraries:n,preferredLibrary:w,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=S.formState.isValid,e[21]=n,e[22]=i,e[23]=h,e[24]=w,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=W):W=e[29],W};function I(){return u().optional().describe(a.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(a.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(a.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function ne(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(a.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(a.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function C(){return u().describe(a.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function os(){return u().describe(a.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function R(){return u().nonempty().describe(a.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Je().describe(a.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(a.of({label:"Read Only"}))}const be=y({type:_("postgres"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),fe=y({type:_("mysql"),host:L(),port:P(3306),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),ge=y({type:_("sqlite"),database:C().describe(a.of({label:"Database Path"}))}).describe(a.of({direction:"two-columns"})),ye=y({type:_("duckdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),_e=y({type:_("motherduck"),database:C().default("my_db").describe(a.of({label:"Database Name"})),token:Z()}).describe(a.of({direction:"two-columns"})),Se=y({type:_("snowflake"),account:u().nonempty().describe(a.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(a.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:C(),schema:u().optional().describe(a.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(a.of({label:"Role"})),authType:M("type",[y({type:_("Password"),username:R(),password:I(),enable_mfa:D().default(!1).describe(a.of({label:"Enable MFA (Duo Push)"}))}),y({type:_("SSO (Browser)"),username:R()}),y({type:_("Key Pair"),username:R(),private_key_path:u().nonempty().describe(a.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(a.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),y({type:_("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(a.of({special:"tabs"}))}).describe(a.of({direction:"two-columns"})),we=y({type:_("bigquery"),project:u().nonempty().describe(a.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(a.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(a.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(a.of({direction:"two-columns"})),xe=y({type:_("clickhouse_connect"),host:L(),port:P(8123).optional(),username:R(),password:I(),secure:D().default(!1).describe(a.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(a.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(a.of({direction:"two-columns"})),ke=y({type:_("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:R().default("default"),password:I().default("")}).describe(a.of({direction:"two-columns"})),ve=y({type:_("chdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),$e=y({type:_("trino"),host:L(),port:P(8080),database:C(),schema:os().optional(),username:R(),password:I(),async_support:D().default(!1).describe(a.of({label:"Async Support"}))}).describe(a.of({direction:"two-columns"})),je=y({type:_("iceberg"),name:u().describe(a.of({label:"Catalog Name"})),catalog:M("type",[y({type:_("REST"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),y({type:_("SQL"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),y({type:_("Hive"),warehouse:Q(),uri:ne()}),y({type:_("Glue"),warehouse:Q(),uri:ne()}),y({type:_("DynamoDB"),"dynamodb.profile-name":u().optional().describe(a.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(a.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(a.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(a.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(a.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(a.of({special:"tabs"}))}),Ae=y({type:_("datafusion"),sessionContext:D().optional().describe(a.of({label:"Use Session Context"}))}),Ce=y({type:_("pyspark"),host:L().optional(),port:P().optional()}),Re=y({type:_("redshift"),host:L(),port:P(5439),connectionType:M("type",[y({type:_("IAM credentials"),region:u().describe(a.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(a.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(a.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(a.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),y({type:_("DB credentials"),user:R(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:C()}).describe(a.of({direction:"two-columns"})),Te=y({type:_("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:ne("HTTP Path",!0),catalog:u().optional().describe(a.of({label:"Catalog"})),schema:u().optional().describe(a.of({label:"Schema"}))}).describe(a.of({direction:"two-columns"})),Le=y({type:_("supabase"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),disable_client_pooling:D().default(!1).describe(a.of({label:"Disable Client-Side Pooling"}))}).describe(a.of({direction:"two-columns"})),cs=M("type",[be,fe,ge,ye,_e,Se,we,xe,ke,ve,$e,je,Ae,Ce,Re,Te,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},as=t=>`_${t}`,is=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=as(t),K(e)){let n=pe(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
2
2
  `)}},ls=class extends k{generateImports(){return[]}generateConnectionCode(){let t=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",e=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0);return g(`
3
3
  DATABASE_URL = f"postgresql://${this.secrets.printInFString("username",this.connection.username)}:${e}@${this.secrets.printInFString("host",this.connection.host)}:${this.secrets.printInFString("port",this.connection.port)}/${this.secrets.printInFString("database",this.connection.database)}"
4
4
  engine = ${this.orm}.create_engine(DATABASE_URL${t})