@marimo-team/frontend 0.23.11-dev28 → 0.23.11-dev29

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 (26) hide show
  1. package/dist/assets/{JsonOutput-DlWKYXMe.js → JsonOutput-DJAO0jFq.js} +1 -1
  2. package/dist/assets/{add-connection-dialog-JJXymrap.js → add-connection-dialog-CM_kt7C2.js} +1 -1
  3. package/dist/assets/{agent-panel-EqJ4dU-o.js → agent-panel-4zQEW_a7.js} +1 -1
  4. package/dist/assets/{cell-editor-CWqkcdu3.js → cell-editor-BdOnyLVO.js} +1 -1
  5. package/dist/assets/{column-preview-DojzlcWG.js → column-preview-Dh5fJBal.js} +1 -1
  6. package/dist/assets/{command-palette-aogPQAVJ.js → command-palette-DARFAIVZ.js} +1 -1
  7. package/dist/assets/{edit-page--VXTezSw.js → edit-page-Dx6LoSdu.js} +4 -4
  8. package/dist/assets/{file-explorer-panel-CRHak8Uc.js → file-explorer-panel-Cwo8ZKc7.js} +1 -1
  9. package/dist/assets/{form-BDERMNxH.js → form-F1rvnx2z.js} +1 -1
  10. package/dist/assets/{hooks-Cbnt6qlO.js → hooks-C7xnEmmf.js} +1 -1
  11. package/dist/assets/{index-B0jzDeio.js → index-sI3TGmYS.js} +3 -3
  12. package/dist/assets/{layout-Di7Q7AGl.js → layout-B3JZ0wo2.js} +3 -3
  13. package/dist/assets/{panels-BRu9rFtP.js → panels-ByU2RchZ.js} +1 -1
  14. package/dist/assets/{reveal-component-CCRpEni9.js → reveal-component-JI9duvxo.js} +1 -1
  15. package/dist/assets/{run-page-CBEWg7PP.js → run-page-DOm8XZ9M.js} +1 -1
  16. package/dist/assets/{scratchpad-panel-DsnwQ3Z_.js → scratchpad-panel-MTv_j3Jw.js} +1 -1
  17. package/dist/assets/{session-panel-t9agY1hh.js → session-panel-TdcBmmLZ.js} +1 -1
  18. package/dist/assets/{useNotebookActions-BX_dD3ya.js → useNotebookActions-zmdBPNp-.js} +1 -1
  19. package/dist/index.html +4 -4
  20. package/package.json +1 -1
  21. package/src/components/data-table/TableTopBar.tsx +4 -4
  22. package/src/components/data-table/__tests__/data-table.test.tsx +28 -0
  23. package/src/components/data-table/data-table.tsx +3 -3
  24. package/src/plugins/impl/DataTablePlugin.tsx +4 -5
  25. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +1 -1
  26. package/src/plugins/impl/data-frames/DataFramePlugin.tsx +1 -1
@@ -46,7 +46,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${e}Chann
46
46
  `),i;return n&&(i=`<table>${r.map(o=>`<tr>${o.map(s=>`<td>${s.html??Ok(s.text)}</td>`).join("")}</tr>`).join("")}</table>`),{text:l,html:i}}function Ok(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}function Tk(t){let e=0;for(let a of t)a.includes("__select__")||(e+=1);return e}function Vk(t,e){let a=[];for(let n of e){if(n.includes("__select__"))continue;let{rowId:r,columnId:l}=ly(n),i=t.getRow(r);if(!i)continue;let o=Js(t,i.index,l)??i.getValue(l),s;if(typeof o=="number")s=o;else if(typeof o=="string"){if(o.trim()==="")continue;s=Number(o)}else continue;Number.isFinite(s)&&a.push(s)}return a}function li(t,e,a){var x,b;let n=t.getRow(e.rowId),r=t.getRow(a.rowId);if(!n||!r)return[];let l=n.index,i=r.index,o=(x=t.getColumn(e.columnId))==null?void 0:x.getIndex(),s=(b=t.getColumn(a.columnId))==null?void 0:b.getIndex();if(o===void 0||s===void 0)return[];let u=Math.min(l,i),c=Math.max(l,i),p=Math.min(o,s),m=Math.max(o,s),h=[];h.length=(c-u+1)*(m-p+1);let f=0,y=t.getAllColumns().map(v=>v.id),w=t.getRowModel().rows;for(let v=u;v<=c;v++){let C=w[v].id;for(let j=p;j<=m;j++){let D=y[j];h[f++]=zk(C,D)}}return h.length=f,h}function zk(t,e){return`${t}_${e}`}function ly(t){let e=t.indexOf("_");return{rowId:t.slice(0,e),columnId:t.slice(e+1)}}function Bk(){return{selectedCells:new Set,copiedCells:new Set,selectedStartCell:null,focusedCell:null,isSelecting:!1}}var{valueAtom:Pa,useActions:Lk,createActions:LE,reducer:HE}=rM(Bk,{setSelectedCells:(t,e)=>({...t,selectedCells:e}),setSelectedStartCell:(t,e)=>({...t,selectedStartCell:e}),setFocusedCell:(t,e)=>({...t,focusedCell:e}),setIsSelecting:(t,e)=>({...t,isSelecting:e}),setCopiedCells:(t,e)=>({...t,copiedCells:e}),clearSelection:t=>({...t,selectedCells:new Set,selectedStartCell:null,focusedCell:null}),selectAllCells:(t,e)=>{let a=e.getRowModel().rows.flatMap(n=>n.getAllCells().map(r=>r.id));return{...t,selectedCells:new Set(a)}},toggleCurrentRowSelection:(t,e)=>{var n,r;let a=t.focusedCell;return a!=null&&a.rowId&&((r=(n=e.getRow(a==null?void 0:a.rowId))==null?void 0:n.toggleSelected)==null||r.call(n)),t},updateSelection:(t,{newCell:e,isShiftKey:a,table:n})=>{if(a&&t.selectedStartCell){let r=li(n,t.selectedStartCell,e);return{...t,selectedCells:new Set(r),focusedCell:e}}else return{...t,selectedCells:new Set([e.cellId]),selectedStartCell:e,focusedCell:e}},updateRangeSelection:(t,{cell:e,table:a})=>{if(!t.selectedStartCell)return t;let n={rowId:e.row.id,columnId:e.column.id,cellId:e.id},r=li(a,t.selectedStartCell,n);return r.length>1&&Uk(),{...t,selectedCells:new Set(r)}},handleCopy:(t,{table:e,onCopyComplete:a})=>{let n=window.getSelection();if(n&&n.toString().length>0)return t;let{text:r,html:l}=Ik(e,t.selectedCells);return Sn(r,l),a(),{...t,copiedCells:t.selectedCells}},navigate:(t,{direction:e,isShiftKey:a,table:n})=>{let r=t.focusedCell??t.selectedStartCell;if(!r)return t;let l;if(e==="up"||e==="down"){let o=n.getRowModel().rows,s=o.findIndex(c=>c.id===r.rowId);if(s<0)return t;let u=e==="up"?o[s-1]:o[s+1];if(!u)return t;l=u.getAllCells().find(c=>c.column.id===r.columnId)}if(e==="left"||e==="right"){let o=n.getRow(r.rowId).getAllCells(),s=o.findIndex(u=>u.id===r.cellId);if(s<0)return t;l=e==="left"?o[s-1]:o[s+1]}if(!l)return t;let i={rowId:l.row.id,columnId:l.column.id,cellId:l.id};if(a&&t.selectedStartCell){let o=li(n,t.selectedStartCell,i);return{...t,selectedCells:new Set(o),focusedCell:i}}else return{...t,selectedCells:new Set([i.cellId]),selectedStartCell:i,focusedCell:i}},handleCellMouseDown:(t,{cell:e,isShiftKey:a,isCtrlKey:n,table:r})=>{let l={rowId:e.row.id,columnId:e.column.id,cellId:e.id};if(a&&t.selectedStartCell){let i=li(r,t.selectedStartCell,l);return{...t,selectedCells:new Set(i),isSelecting:!0}}return n?t:t.selectedCells.size===1&&t.selectedCells.has(l.cellId)?{...t,selectedCells:new Set,selectedStartCell:null,focusedCell:null}:{...t,selectedCells:new Set([l.cellId]),selectedStartCell:l,focusedCell:l,isSelecting:!0}}});const Eu=tt(t=>t(Pa).selectedCells),Hk=tt(t=>t(Pa).copiedCells);tt(t=>t(Pa).selectedStartCell),tt(t=>t(Pa).focusedCell),tt(t=>t(Pa).isSelecting);const Wk=t=>tt(e=>{let a=e(Eu),n=e(Hk);return{isSelected:a.has(t),isCopied:n.has(t)}}),Uk=()=>{var t;window.getSelection&&((t=window.getSelection())==null||t.empty())};var Kk=q();const Gk=t=>{let e=(0,Kk.c)(3),{children:a}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[Pa],e[0]=n):n=e[0];let r;return e[1]===a?r=e[2]:(r=(0,d.jsx)(_k,{atoms:n,children:a}),e[1]=a,e[2]=r),r};function un(t,e,a){let n=a.initialDeps??[],r,l=!0;function i(){var c,p,m;let o;a.key&&((c=a.debug)!=null&&c.call(a))&&(o=Date.now());let s=t();if(!(s.length!==n.length||s.some((h,f)=>n[f]!==h)))return r;n=s;let u;if(a.key&&((p=a.debug)!=null&&p.call(a))&&(u=Date.now()),r=e(...s),a.key&&((m=a.debug)==null?void 0:m.call(a))){let h=Math.round((Date.now()-o)*100)/100,f=Math.round((Date.now()-u)*100)/100,y=f/16,w=(x,b)=>{for(x=String(x);x.length<b;)x=" "+x;return x};console.info(`%c\u23F1 ${w(f,5)} /${w(h,5)} ms`,`
47
47
  font-size: .6rem;
48
48
  font-weight: bold;
49
- color: hsl(${Math.max(0,Math.min(120-120*y,120))}deg 100% 31%);`,a==null?void 0:a.key)}return a!=null&&a.onChange&&!(l&&a.skipInitialOnChange)&&a.onChange(r),l=!1,r}return i.updateDeps=o=>{n=o},i}function iy(t,e){if(t===void 0)throw Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}var qk=(t,e)=>Math.abs(t-e)<1.01,Zk=(t,e,a)=>{let n;return function(...r){t.clearTimeout(n),n=t.setTimeout(()=>e.apply(this,r),a)}},oy=t=>{let{offsetWidth:e,offsetHeight:a}=t;return{width:e,height:a}},Jk=t=>t,Yk=t=>{let e=Math.max(t.startIndex-t.overscan,0),a=Math.min(t.endIndex+t.overscan,t.count-1),n=[];for(let r=e;r<=a;r++)n.push(r);return n},Qk=(t,e)=>{let a=t.scrollElement;if(!a)return;let n=t.targetWindow;if(!n)return;let r=i=>{let{width:o,height:s}=i;e({width:Math.round(o),height:Math.round(s)})};if(r(oy(a)),!n.ResizeObserver)return()=>{};let l=new n.ResizeObserver(i=>{let o=()=>{let s=i[0];if(s!=null&&s.borderBoxSize){let u=s.borderBoxSize[0];if(u){r({width:u.inlineSize,height:u.blockSize});return}}r(oy(a))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return l.observe(a,{box:"border-box"}),()=>{l.unobserve(a)}},sy={passive:!0},uy=typeof window>"u"?!0:"onscrollend"in window,Xk=(t,e)=>{let a=t.scrollElement;if(!a)return;let n=t.targetWindow;if(!n)return;let r=0,l=t.options.useScrollendEvent&&uy?()=>{}:Zk(n,()=>{e(r,!1)},t.options.isScrollingResetDelay),i=c=>()=>{let{horizontal:p,isRtl:m}=t.options;r=p?a.scrollLeft*(m&&-1||1):a.scrollTop,l(),e(r,c)},o=i(!0),s=i(!1);a.addEventListener("scroll",o,sy);let u=t.options.useScrollendEvent&&uy;return u&&a.addEventListener("scrollend",s,sy),()=>{a.removeEventListener("scroll",o),u&&a.removeEventListener("scrollend",s)}},eR=(t,e,a)=>{if(e!=null&&e.borderBoxSize){let n=e.borderBoxSize[0];if(n)return Math.round(n[a.options.horizontal?"inlineSize":"blockSize"])}return t[a.options.horizontal?"offsetWidth":"offsetHeight"]},tR=(t,{adjustments:e=0,behavior:a},n)=>{var o;var r,l;let i=t+e;(l=(o=r=n.scrollElement)==null?void 0:o.scrollTo)==null||l.call(r,{[n.options.horizontal?"left":"top"]:i,behavior:a})},aR=class{constructor(t){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 a,n,r;var e;return((r=(n=e=(a=this.targetWindow)==null?void 0:a.performance)==null?void 0:n.now)==null?void 0:r.call(e))??Date.now()},this.observer=(()=>{let e=null,a=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(n=>{n.forEach(r=>{let l=()=>{let i=r.target,o=this.indexFromElement(i);if(!i.isConnected){this.observer.unobserve(i);return}this.shouldMeasureDuringScroll(o)&&this.resizeItem(o,this.options.measureElement(i,r,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var n;(n=a())==null||n.disconnect(),e=null},observe:n=>{var r;return(r=a())==null?void 0:r.observe(n,{box:"border-box"})},unobserve:n=>{var r;return(r=a())==null?void 0:r.unobserve(n)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([a,n])=>{n===void 0&&delete e[a]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Jk,rangeExtractor:Yk,onChange:()=>{},measureElement:eR,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,...e}},this.notify=e=>{var a,n;(n=(a=this.options).onChange)==null||n.call(a,this,e)},this.maybeNotify=un(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{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(e=>e()),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 a;let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((a=this.scrollElement)==null?void 0:a.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=r,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=(e,a)=>{let n=new Map,r=new Map;for(let l=a-1;l>=0;l--){let i=e[l];if(n.has(i.lane))continue;let o=r.get(i.lane);if(o==null||i.end>o.end?r.set(i.lane,i):i.end<o.end&&n.set(i.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((l,i)=>l.end===i.end?l.index-i.index:l.end-i.end)[0]:void 0},this.getMeasurementOptions=un(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,a,n,r,l,i)=>(this.prevLanes!==void 0&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:a,scrollMargin:n,getItemKey:r,enabled:l,lanes:i}),{key:!1}),this.getMeasurements=un(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:a,scrollMargin:n,getItemKey:r,enabled:l,lanes:i},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let p of this.laneAssignments.keys())p>=e&&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 s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,s),c=Array(i).fill(void 0);for(let p=0;p<s;p++){let m=u[p];m&&(c[m.lane]=p)}for(let p=s;p<e;p++){let m=r(p),h=this.laneAssignments.get(p),f,y;if(h!==void 0&&this.options.lanes>1){f=h;let v=c[f],C=v===void 0?void 0:u[v];y=C?C.end+this.options.gap:a+n}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);y=v?v.end+this.options.gap:a+n,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let w=o.get(m),x=typeof w=="number"?w:this.options.estimateSize(p),b=y+x;u[p]={index:p,start:y,size:x,end:b,key:m,lane:f},c[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=un(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,a,n,r)=>this.range=e.length>0&&a>0?nR({measurements:e,outerSize:a,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=un(()=>{let e=null,a=null,n=this.calculateRange();return n&&(e=n.startIndex,a=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,a]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,a]},(e,a,n,r,l)=>r===null||l===null?[]:e({startIndex:r,endIndex:l,overscan:a,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let a=this.options.indexAttribute,n=e.getAttribute(a);return n?parseInt(n,10):(console.warn(`Missing attribute name '${a}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let a=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(a!==void 0&&this.range){let r=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,a-r),i=Math.min(this.options.count-1,a+r);return e>=l&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((l,i)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(i))});return}let a=this.indexFromElement(e),n=this.options.getItemKey(a),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(a)&&this.resizeItem(a,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,a)=>{var l;let n=this.measurementsCache[e];if(!n)return;let r=a-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(((l=this.scrollState)==null?void 0:l.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,a)),this.notify(!1))},this.getVirtualItems=un(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,a)=>{let n=[];for(let r=0,l=e.length;r<l;r++){let i=a[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let a=this.getMeasurements();if(a.length!==0)return iy(a[dy(0,a.length-1,n=>iy(a[n]).start,e)])},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 e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,a,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),l=this.getScrollOffset();a==="auto"&&(a=e>=l+r?"end":"start"),a==="center"?e+=(n-r)/2:a==="end"&&(e-=r);let i=this.getMaxScrollOffset();return Math.max(Math.min(i,e),0)},this.getOffsetForIndex=(e,a="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),l=this.measurementsCache[e];if(!l)return;if(a==="auto")if(l.end>=r+n-this.options.scrollPaddingEnd)a="end";else if(l.start<=r+this.options.scrollPaddingStart)a="start";else return[r,a];if(a==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),a];let i=a==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,a,l.size),a]},this.scrollToOffset=(e,{align:a="start",behavior:n="auto"}={})=>{let r=this.getOffsetForAlignment(e,a);this.scrollState={index:null,align:a,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:a="auto",behavior:n="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,a);if(!r)return;let[l,i]=r,o=this.now();this.scrollState={index:e,align:i,behavior:n,startedAt:o,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:a="auto"}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:"start",behavior:a,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;let e=this.getMeasurements(),a;if(e.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=e[e.length-1])==null?void 0:n.end)??0;else{let r=Array(this.options.lanes).fill(null),l=e.length-1;for(;l>=0&&r.some(i=>i===null);){let i=e[l];r[i.lane]===null&&(r[i.lane]=i.end),l--}a=Math.max(...r.filter(i=>i!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:a,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:a},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}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 t=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),e=t?t[0]:this.scrollState.lastTargetOffset,a=e!==this.scrollState.lastTargetOffset;if(!a&&qk(e,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=e,this.scrollState.behavior="auto",this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},dy=(t,e,a,n)=>{for(;t<=e;){let r=(t+e)/2|0,l=a(r);if(l<n)t=r+1;else if(l>n)e=r-1;else return r}return t>0?t-1:0};function nR({measurements:t,outerSize:e,scrollOffset:a,lanes:n}){let r=t.length-1,l=s=>t[s].start;if(t.length<=n)return{startIndex:0,endIndex:r};let i=dy(0,r,l,a),o=i;if(n===1)for(;o<r&&t[o].end<a+e;)o++;else if(n>1){let s=Array(n).fill(0);for(;o<r&&s.some(c=>c<a+e);){let c=t[o];s[c.lane]=c.end,o++}let u=Array(n).fill(a+e);for(;i>=0&&u.some(c=>c>=a);){let c=t[i];u[c.lane]=c.start,i--}i=Math.max(0,i-i%n),o=Math.min(r,o+(n-1-o%n))}return{startIndex:i,endIndex:o}}var rR=Bu(),cy=typeof document<"u"?g.useLayoutEffect:g.useEffect;function lR({useFlushSync:t=!0,...e}){let a=g.useReducer(()=>({}),{})[1],n={...e,onChange:(l,i)=>{var o;t&&i?(0,rR.flushSync)(a):a(),(o=e.onChange)==null||o.call(e,l,i)}},[r]=g.useState(()=>new aR(n));return r.setOptions(n),cy(()=>r._didMount(),[]),cy(()=>r._willUpdate()),r}function my(t){return lR({observeElementRect:Qk,observeElementOffset:Xk,scrollToFn:tR,...t})}let Lt,Pu,py,fy,hy;Lt=q(),Id=Mv,Nd=Ev,Pu=dN(Pv),py=ex(Sc),fy=ex(Ec),hy=g.forwardRef((t,e)=>{let a=(0,Lt.c)(14),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:r,inset:l,children:n,...i}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]!==r||a[6]!==l?(o=fN({className:r,inset:l}),a[5]=r,a[6]=l,a[7]=o):o=a[7];let s;a[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,d.jsx)(vE,{className:"ml-auto h-4 w-4"}),a[8]=s):s=a[8];let u;return a[9]!==n||a[10]!==i||a[11]!==e||a[12]!==o?(u=(0,d.jsxs)(Mc,{ref:e,className:o,...i,children:[n,s]}),a[9]=n,a[10]=i,a[11]=e,a[12]=o,a[13]=u):u=a[13],u}),hy.displayName=Mc.displayName;var gy="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",iR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(9),n,r;a[0]===t?(n=a[1],r=a[2]):({className:n,...r}=t,a[0]=t,a[1]=n,a[2]=r);let l;a[3]===n?l=a[4]:(l=V(ax({subcontent:!0}),gy,n),a[3]=n,a[4]=l);let i;return a[5]!==r||a[6]!==e||a[7]!==l?(i=(0,d.jsx)(fy,{ref:e,className:l,...r}),a[5]=r,a[6]=e,a[7]=l,a[8]=i):i=a[8],i});iR.displayName=Ec.displayName,Zi=g.forwardRef((t,e)=>{let a=(0,Lt.c)(15),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:n,scrollable:l,...r}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i=l===void 0?!0:l,o;a[4]!==n||a[5]!==i?(o=V(ax(),gy,i&&"overflow-auto",n),a[4]=n,a[5]=i,a[6]=o):o=a[6];let s=i?`calc(var(--radix-context-menu-content-available-height) - ${cN}px)`:void 0,u;a[7]!==r.style||a[8]!==s?(u={...r.style,maxHeight:s},a[7]=r.style,a[8]=s,a[9]=u):u=a[9];let c;return a[10]!==r||a[11]!==e||a[12]!==o||a[13]!==u?(c=(0,d.jsx)(Pu,{children:(0,d.jsx)(uN,{children:(0,d.jsx)(py,{ref:e,className:o,style:u,...r})})}),a[10]=r,a[11]=e,a[12]=o,a[13]=u,a[14]=c):c=a[14],c}),Zi.displayName=Sc.displayName,Va=g.forwardRef((t,e)=>{let a=(0,Lt.c)(13),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:n,inset:r,variant:i,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]!==n||a[6]!==r||a[7]!==i?(o=hN({className:n,inset:r,variant:i}),a[5]=n,a[6]=r,a[7]=i,a[8]=o):o=a[8];let s;return a[9]!==l||a[10]!==e||a[11]!==o?(s=(0,d.jsx)(Dc,{ref:e,className:o,...l}),a[9]=l,a[10]=e,a[11]=o,a[12]=s):s=a[12],s}),Va.displayName=Dc.displayName,Xd=g.forwardRef((t,e)=>{let a=(0,Lt.c)(15),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:l,children:r,checked:n,...i}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]===l?o=a[6]:(o=mN({className:l}),a[5]=l,a[6]=o);let s;a[7]===Symbol.for("react.memo_cache_sentinel")?(s=Wu(),a[7]=s):s=a[7];let u;a[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,d.jsx)("span",{className:s,children:(0,d.jsx)(Rc,{children:(0,d.jsx)(yE,{className:"h-4 w-4"})})}),a[8]=u):u=a[8];let c;return a[9]!==n||a[10]!==r||a[11]!==i||a[12]!==e||a[13]!==o?(c=(0,d.jsxs)(jc,{ref:e,className:o,checked:n,...i,children:[u,r]}),a[9]=n,a[10]=r,a[11]=i,a[12]=e,a[13]=o,a[14]=c):c=a[14],c}),Xd.displayName=jc.displayName;var oR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(13),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:r,children:n,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i;a[4]===r?i=a[5]:(i=Wu({className:r}),a[4]=r,a[5]=i);let o;a[6]===Symbol.for("react.memo_cache_sentinel")?(o=Wu(),a[6]=o):o=a[6];let s;a[7]===Symbol.for("react.memo_cache_sentinel")?(s=(0,d.jsx)("span",{className:o,children:(0,d.jsx)(Rc,{children:(0,d.jsx)(gE,{className:"h-4 w-4 fill-current"})})}),a[7]=s):s=a[7];let u;return a[8]!==n||a[9]!==l||a[10]!==e||a[11]!==i?(u=(0,d.jsxs)(kc,{ref:e,className:i,...l,children:[s,n]}),a[8]=n,a[9]=l,a[10]=e,a[11]=i,a[12]=u):u=a[12],u});oR.displayName=kc.displayName;var sR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(11),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:n,inset:r,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i;a[4]!==n||a[5]!==r?(i=gN({className:n,inset:r}),a[4]=n,a[5]=r,a[6]=i):i=a[6];let o;return a[7]!==l||a[8]!==e||a[9]!==i?(o=(0,d.jsx)(Cc,{ref:e,className:i,...l}),a[7]=l,a[8]=e,a[9]=i,a[10]=o):o=a[10],o});sR.displayName=Cc.displayName,to=g.forwardRef((t,e)=>{let a=(0,Lt.c)(9),n,r;a[0]===t?(n=a[1],r=a[2]):({className:n,...r}=t,a[0]=t,a[1]=n,a[2]=r);let l;a[3]===n?l=a[4]:(l=V(pN({className:n})),a[3]=n,a[4]=l);let i;return a[5]!==r||a[6]!==e||a[7]!==l?(i=(0,d.jsx)(Nc,{ref:e,className:l,...r}),a[5]=r,a[6]=e,a[7]=l,a[8]=i):i=a[8],i}),to.displayName=Nc.displayName;var uR=q();const dR=t=>{let e=(0,uR.c)(12),{contextMenuRef:a,tableBody:n,tableRef:r,copyAllCells:l}=t,i;e[0]!==a||e[1]!==r?(i=p=>{var f;let m=a.current;if(!m)return;let h=(f=r.current)==null?void 0:f.querySelector(`[${U6}="${m.id}"]`);if(!h){Ht.error("Context menu cell not found in table");return}p?h.classList.add("bg-(--green-4)"):h.classList.remove("bg-(--green-4)")},e[0]=a,e[1]=r,e[2]=i):i=e[2];let o=Je(i),s;e[3]===n?s=e[4]:(s=(0,d.jsx)(Nd,{asChild:!0,children:n}),e[3]=n,e[4]=s);let u;e[5]!==a||e[6]!==l?(u=(0,d.jsx)(Pu,{children:(0,d.jsx)(cR,{cellRef:a,copySelectedCells:l})}),e[5]=a,e[6]=l,e[7]=u):u=e[7];let c;return e[8]!==o||e[9]!==s||e[10]!==u?(c=(0,d.jsxs)(Id,{onOpenChange:o,children:[s,u]}),e[8]=o,e[9]=s,e[10]=u,e[11]=c):c=e[11],c},cR=({cellRef:t,copySelectedCells:e})=>{var m;let a=fn(Eu).size>1,n=t.current;if(!n){Ht.error("No cell found in context menu");return}let r=n.getContext().table,l=n.getValue(),i=Js(r,n.row.index,n.column.id)??l,o=()=>{try{let{text:h,html:f}=n1(i,l);Sn(h,f)}catch(h){Ht.error("Failed to copy context menu cell",h)}},s=n.column,u=(m=s.columnDef.meta)==null?void 0:m.filterType,c=s.getCanFilter()&&u&&Ks(u)?u:void 0,p=(h,f)=>{let y=h==="number"?it.number({operator:f,values:[i]}):it.text({operator:f,values:[i]});s.setFilterValue(y)};return(0,d.jsxs)(Zi,{children:[(0,d.jsxs)(Va,{onClick:o,children:[(0,d.jsx)(bi,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),a&&(0,d.jsxs)(Va,{onClick:e,children:[(0,d.jsx)(Wc,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),c&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(to,{}),(0,d.jsxs)(Va,{onClick:()=>p(c,"in"),children:[(0,d.jsx)(jn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,d.jsxs)(Va,{onClick:()=>p(c,"not_in"),children:[(0,d.jsx)(jn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var mR=q();const pR=t=>{let e=(0,mR.c)(15),{state:a,contentId:n,onClose:r}=t,l=a!=null,i;e[0]===r?i=e[1]:(i=y=>{y||r()},e[0]=r,e[1]=i);let o=(a==null?void 0:a.rect.top)??0,s=(a==null?void 0:a.rect.left)??0,u=(a==null?void 0:a.rect.width)??0,c=(a==null?void 0:a.rect.height)??0,p;e[2]!==o||e[3]!==s||e[4]!==u||e[5]!==c?(p=(0,d.jsx)(XN,{asChild:!0,children:(0,d.jsx)("div",{"aria-hidden":!0,style:{position:"fixed",top:o,left:s,width:u,height:c,pointerEvents:"none"}})}),e[2]=o,e[3]=s,e[4]=u,e[5]=c,e[6]=p):p=e[6];let m=a==null?void 0:a.content,h;e[7]!==n||e[8]!==m?(h=(0,d.jsx)(eM,{children:(0,d.jsx)(QN,{id:n,children:m})}),e[7]=n,e[8]=m,e[9]=h):h=e[9];let f;return e[10]!==l||e[11]!==i||e[12]!==p||e[13]!==h?(f=(0,d.jsxs)(YN,{open:l,onOpenChange:i,delayDuration:0,disableHoverableContent:!0,children:[p,h]}),e[10]=l,e[11]=i,e[12]=p,e[13]=h,e[14]=f):f=e[14],f};function fR(t,e){let a=/{{(\w+)}}/g,n=new Map;for(let r of e){let l=Ma({value:r.getValue(),nullAsEmptyString:!0});n.set(r.column.id,l)}return t.replaceAll(a,(r,l)=>{let i=n.get(l);return i===void 0?`{{${l}}}`:i})}function yy(t,e){var n;let a=(n=t.getHoverTitle)==null?void 0:n.call(t);if(a!=null&&a!=="")return a;if(e)return fR(e,t.row.getVisibleCells())}var hR=q(),gR=400;function yR(t){let e=(0,hR.c)(33),{table:a}=t,n;e[0]===a?n=e[1]:(n=a.getState().cellHoverTemplate||null,e[0]=a,e[1]=n);let r=n,[l,i]=(0,g.useState)(null),o=(0,g.useRef)(null),s=(0,g.useId)(),u=(0,g.useRef)(null),c=(0,g.useRef)(!1),p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},e[2]=p):p=e[2];let m=p,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{m(),i(null)},e[3]=h):h=e[3];let f=Je(h),y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=(E,O)=>{u.current=E;let I=E.getBoundingClientRect();i({rect:{top:I.top,left:I.left,width:I.width,height:I.height},content:O})},e[4]=y):y=e[4];let w=y,x,b;e[5]!==s||e[6]!==l?(x=()=>{if(!l)return;let E=u.current;return E==null||E.setAttribute("aria-describedby",s),()=>E==null?void 0:E.removeAttribute("aria-describedby")},b=[l,s],e[5]=s,e[6]=l,e[7]=x,e[8]=b):(x=e[7],b=e[8]),(0,g.useLayoutEffect)(x,b);let v,C;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{let E=()=>{c.current=!0},O=()=>{c.current=!1};return window.addEventListener("mousedown",E,{capture:!0}),window.addEventListener("mouseup",O,{capture:!0}),()=>{window.removeEventListener("mousedown",E,{capture:!0}),window.removeEventListener("mouseup",O,{capture:!0})}},C=[],e[9]=v,e[10]=C):(v=e[9],C=e[10]),(0,g.useEffect)(v,C);let j;e[11]!==f||e[12]!==r?(j=(E,O)=>{if(E.buttons!==0)return;let I=E.currentTarget,L=yy(O,r);if(L==null||L===""){f();return}m(),o.current=window.setTimeout(()=>w(I,L),gR)},e[11]=f,e[12]=r,e[13]=j):j=e[13];let D=Je(j),N;e[14]===f?N=e[15]:(N=()=>f(),e[14]=f,e[15]=N);let k=Je(N),M;e[16]===r?M=e[17]:(M=(E,O)=>{if(m(),c.current)return;let I=yy(O,r);I==null||I===""||w(E.currentTarget,I)},e[16]=r,e[17]=M);let S=Je(M),R;e[18]===f?R=e[19]:(R=()=>f(),e[18]=f,e[19]=R);let P=Je(R),T,z;e[20]===f?(T=e[21],z=e[22]):(T=()=>(window.addEventListener("scroll",f,{passive:!0,capture:!0}),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,{capture:!0}),window.removeEventListener("resize",f)}),z=[f],e[20]=f,e[21]=T,e[22]=z),(0,g.useEffect)(T,z);let $,F;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>m,F=[],e[23]=$,e[24]=F):($=e[23],F=e[24]),(0,g.useEffect)($,F);let _;return e[25]!==P||e[26]!==S||e[27]!==k||e[28]!==D||e[29]!==f||e[30]!==s||e[31]!==l?(_={tooltipState:l,tooltipContentId:s,hideTooltip:f,handleCellMouseOver:D,handleCellMouseLeave:k,handleCellFocus:S,handleCellBlur:P},e[25]=P,e[26]=S,e[27]=k,e[28]=D,e[29]=f,e[30]=s,e[31]=l,e[32]=_):_=e[32],_}var xR=q();const xy=(0,g.memo)(t=>{let e=(0,xR.c)(9),{cellId:a,className:n}=t,r;e[0]===a?r=e[1]:(r=Wk(a),e[0]=a,e[1]=r);let{isSelected:l,isCopied:i}=fn(r);if(!l&&!i)return null;let o=l&&"bg-(--green-3)",s=i&&"bg-(--green-4) transition-colors duration-150",u;e[2]!==n||e[3]!==o||e[4]!==s?(u=V("absolute inset-0 pointer-events-none",o,s,n),e[2]=n,e[3]=o,e[4]=s,e[5]=u):u=e[5];let c;return e[6]!==a||e[7]!==u?(c=(0,d.jsx)("div",{"data-cell-id":a,className:u}),e[6]=a,e[7]=u,e[8]=c):c=e[8],c});xy.displayName="CellRangeSelectionIndicator";var vR=q();const bR=t=>{let e=(0,vR.c)(30),{table:a}=t,n=Lk(),r;e[0]!==n||e[1]!==a?(r=()=>{n.handleCopy({table:a,onCopyComplete:()=>{setTimeout(()=>{n.setCopiedCells(new Set)},500)}})},e[0]=n,e[1]=a,e[2]=r):r=e[2];let l=Je(r),i;e[3]!==n||e[4]!==a?(i=(v,C)=>{n.updateSelection({newCell:v,isShiftKey:C,table:a})},e[3]=n,e[4]=a,e[5]=i):i=e[5];let o=Je(i),s;e[6]!==n||e[7]!==a?(s=(v,C)=>{n.navigate({direction:C,isShiftKey:v.shiftKey,table:a})},e[6]=n,e[7]=a,e[8]=s):s=e[8];let u=Je(s),c;e[9]!==n||e[10]!==l||e[11]!==u||e[12]!==a?(c=v=>{e:switch(v.key){case"c":ht.isMetaOrCtrl(v)&&l();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(),n.toggleCurrentRowSelection(a);break e;case"Escape":n.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),n.selectAllCells(a))}},e[9]=n,e[10]=l,e[11]=u,e[12]=a,e[13]=c):c=e[13];let p=Je(c),m;e[14]!==n||e[15]!==a?(m=(v,C)=>{v.buttons!==2&&(CR(v)||n.handleCellMouseDown({cell:C,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:a}))},e[14]=n,e[15]=a,e[16]=m):m=e[16];let h=Je(m),f;e[17]===n?f=e[18]:(f=()=>{n.setIsSelecting(!1)},e[17]=n,e[18]=f);let y=Je(f),w;e[19]!==n||e[20]!==a?(w=(v,C)=>{v.buttons===1&&n.updateRangeSelection({cell:C,table:a})},e[19]=n,e[20]=a,e[21]=w):w=e[21];let x=Je(w),b;return e[22]!==n.clearSelection||e[23]!==h||e[24]!==x||e[25]!==y||e[26]!==p||e[27]!==l||e[28]!==o?(b={handleCellMouseDown:h,handleCellMouseUp:y,handleCellMouseOver:x,handleCopy:l,handleCellsKeyDown:p,updateSelection:o,clearSelection:n.clearSelection},e[22]=n.clearSelection,e[23]=h,e[24]=x,e[25]=y,e[26]=p,e[27]=l,e[28]=o,e[29]=b):b=e[29],b};var wR='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element',SR=new Set(["marimo-lazy","marimo-routes"]);function CR(t){var a;let e=typeof((a=t.nativeEvent)==null?void 0:a.composedPath)=="function"?t.nativeEvent.composedPath():[t.target];for(let n of e){if(n===t.currentTarget)break;if(!(!(n instanceof Element)||!n.matches(wR))){if(n.localName==="marimo-ui-element"){let r=n.firstElementChild;if(r&&SR.has(r.localName))continue}return!0}}return!1}var DR=q(),jR=tt(t=>t(Pa).focusedCell);function kR(t){let e=(0,DR.c)(2),a;e[0]===t?a=e[1]:(a=n=>{n!=null&&n.cellId&&setTimeout(()=>{var l;let r=(l=t.current)==null?void 0:l.querySelector(`[data-cell-id="${n.cellId}"]`);if(!r){Ht.warn("[ScrollIntoView] Could not find cell with ID:",n.cellId);return}r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},e[0]=t,e[1]=a),T6(jR,a)}function RR(t,e){var n;if(!((n=t.getRowModel().rows)!=null&&n.length))return null;let a=r=>r.map(l=>l.headers.map(i=>{let{className:o,style:s}=vy(i.column);return(0,d.jsx)(PE,{className:V("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",o),style:s,ref:u=>{MR({table:t,column:i.column,thead:u})},children:i.isPlaceholder?null:Vi(i.column.columnDef.header,i.getContext())},i.id)}));return(0,d.jsx)(EE,{className:V(e&&"sticky top-0 z-10"),children:(0,d.jsxs)(dd,{children:[a(t.getLeftHeaderGroups()),a(t.getCenterHeaderGroups()),a(t.getRightHeaderGroups()),t.getAllColumns().length<=4&&(0,d.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const NR=({table:t,columns:e,rowViewerPanelOpen:a,getRowIndex:n,viewedRowIdx:r,virtualize:l=!1})=>{let i=t.getRowModel().rows,[o,s]=(0,g.useState)(null),u=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{var k,M;s(((M=(k=u.current)==null?void 0:k.parentElement)==null?void 0:M.parentElement)??null)},[]);let c=my({count:l?i.length:0,getScrollElement:()=>o,estimateSize:()=>24,overscan:10});kR(u);let{handleCellMouseDown:p,handleCellMouseUp:m,handleCellMouseOver:h,handleCellsKeyDown:f,handleCopy:y}=bR({table:t}),w=(0,g.useRef)(null),x=Je(k=>{w.current=k}),b=yR({table:t}),v=k=>k.map(M=>{var z,$,F,_;let{className:S,style:R}=vy(M.column),P=(z=M.column.columnDef.meta)==null?void 0:z.width,T=Object.assign({},(($=M.getUserStyling)==null?void 0:$.call(M))||{},R);return(0,g.createElement)(Vx,{tabIndex:0,...K6(M.id),key:M.id,className:V("whitespace-pre truncate outline-hidden border-r border-r-border/75",!P&&"max-w-[300px]",M.column.getColumnWrapping&&((_=(F=M.column).getColumnWrapping)==null?void 0:_.call(F))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",S),style:T,onMouseDown:E=>{p(E,M),b.hideTooltip()},onMouseUp:m,onMouseOver:E=>{h(E,M),b.handleCellMouseOver(E,M)},onMouseLeave:b.handleCellMouseLeave,onFocus:E=>b.handleCellFocus(E,M),onBlur:b.handleCellBlur,onContextMenu:()=>x(M)},(0,d.jsx)(xy,{cellId:M.id}),(0,d.jsx)("div",{className:"relative",children:Vi(M.column.columnDef.cell,M.getContext())}))}),C=k=>{var M;if(a){let S=(n==null?void 0:n(k.original,k.index))??k.index;(M=k.focusRow)==null||M.call(k,S)}},j=k=>{let M=a?(n==null?void 0:n(k.original,k.index))??k.index:void 0,S=a&&r===M;return(0,d.jsxs)(dd,{"data-state":k.getIsSelected()&&"selected",className:V("border-t h-6",a&&"cursor-pointer",S&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>C(k),children:[v(k.getLeftVisibleCells()),v(k.getCenterVisibleCells()),v(k.getRightVisibleCells()),e.length<=4&&(0,d.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},k.id)},D=e.length<=4,N=e.length+(D?1:0);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(dR,{tableBody:(0,d.jsx)(FE,{onKeyDown:f,ref:u,children:(()=>{var k,M;if(i.length===0)return(0,d.jsx)(dd,{children:(0,d.jsx)(Vx,{colSpan:N,className:"h-24 text-center",children:"No results."})});if(l){let S=c.getVirtualItems(),R=c.getTotalSize();return(0,d.jsxs)(d.Fragment,{children:[((k=S[0])==null?void 0:k.start)>0&&(0,d.jsx)("tr",{"data-virtual-spacer":"",style:{height:S[0].start},children:(0,d.jsx)("td",{colSpan:N})}),S.map(P=>j(i[P.index])),S.length>0&&(0,d.jsx)("tr",{"data-virtual-spacer":"",style:{height:R-(((M=S.at(-1))==null?void 0:M.end)??R)},children:(0,d.jsx)("td",{colSpan:N})})]})}return i.map(S=>j(S))})()}),contextMenuRef:w,tableRef:u,copyAllCells:y}),(0,d.jsx)(pR,{state:b.tooltipState,contentId:b.tooltipContentId,onClose:b.hideTooltip})]})};function vy(t){var l;let e=t.getIsPinned(),a=e==="left"&&t.getIsLastColumn("left"),n=e==="right"&&t.getIsFirstColumn("right"),r=(l=t.columnDef.meta)==null?void 0:l.width;return{className:V(e&&"bg-inherit","shadow-r z-10"),style:{boxShadow:a&&t.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":n?"4px 0 4px -4px var(--slate-8) inset":void 0,left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,opacity:1,position:e?"sticky":"relative",zIndex:e?1:0,width:t.getSize(),...r?{minWidth:r,maxWidth:r}:{}}}}function MR({table:t,column:e,thead:a}){if(!a)return;let n=Math.round(a.getBoundingClientRect().width);t.getState().columnSizing[e.id]!==n&&t.setColumnSizing(r=>({...r,[e.id]:n}))}function ER(t){let[e,a]=Wi(Object.fromEntries((t??[]).map(n=>[n,!1])),Uy);return{columnVisibility:e,setColumnVisibility:a}}function by(t){let e=t.getAllLeafColumns().filter(n=>n.getCanHide()),a=e.filter(n=>n.getIsVisible()).length;return{total:e.length,visible:a,hidden:e.length-a}}ec=function(t,e){let a=by(t);return{totalColumns:a.hidden>0?a.total:e,hiddenColumns:a.hidden}};const PR=({table:t,tableLoading:e,showPageSizeSelector:a})=>{let{locale:n}=ye(),r=Math.min(t.getState().pagination.pageIndex+1,t.getPageCount()),l=t.getPageCount(),i=t.getState().pagination.pageSize,o=u=>{e||u()},s=[...new Set([5,10,25,50,100,i])].toSorted((u,c)=>u-c);return(0,d.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,d.jsx)("div",{className:"order-2 lg:order-first",children:a&&(0,d.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,d.jsxs)(yi,{children:[(0,d.jsx)(hi,{asChild:!0,children:(0,d.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:[i," / page",(0,d.jsx)(gn,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,d.jsxs)(gi,{align:"center",sideOffset:6,children:[(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...s].map(u=>(0,d.jsx)(je,{className:V("text-xs cursor-pointer",u===i&&"font-semibold bg-accent"),onSelect:()=>t.setPageSize(u),onMouseDown:ht.preventFocus,children:u},u))]})]})})}),(0,d.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,d.jsx)(Pe,{content:"First page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>o(()=>t.setPageIndex(0)),onMouseDown:ht.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,d.jsx)(gd,{className:"h-4 w-4"})})}),(0,d.jsx)(Pe,{content:"Previous page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>o(()=>t.previousPage()),onMouseDown:ht.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,d.jsx)(Ku,{className:"h-4 w-4"})})}),(0,d.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,d.jsx)("span",{children:"Page"}),(0,d.jsx)(AR,{currentPage:r,totalPages:l,onPageChange:u=>o(()=>t.setPageIndex(u))}),(0,d.jsxs)("span",{className:"shrink-0",children:["of ",Ye(l,n)]})]}),(0,d.jsx)(Pe,{content:"Next page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>o(()=>t.nextPage()),onMouseDown:ht.preventFocus,disabled:!t.getCanNextPage(),children:(0,d.jsx)(xi,{className:"h-4 w-4"})})}),(0,d.jsx)(Pe,{content:"Last page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>o(()=>t.setPageIndex(t.getPageCount()-1)),onMouseDown:ht.preventFocus,disabled:!t.getCanNextPage(),children:(0,d.jsx)(jd,{className:"h-4 w-4"})})})]})]})};var Fu=32;function FR(t,e){let a=Number.parseInt(t,10);if(Number.isNaN(a)||a<=0||String(a)!==t)return[];let n=[],r=1;for(;a*r<=e;){let l=a*r,i=Math.min((a+1)*r-1,e);n.push([l,i]),r*=10}return n}function $R(t,e){if(t==="")return{count:e,pageAtIndex:r=>r+1,indexOfPage:r=>r-1};let a=FR(t,e),n=0;for(let[r,l]of a)n+=l-r+1;return{count:n,pageAtIndex:r=>{let l=0;for(let[i,o]of a){let s=o-i+1;if(r<l+s)return i+(r-l);l+=s}return-1},indexOfPage:r=>{let l=0;for(let[i,o]of a){if(r>=i&&r<=o)return l+(r-i);l+=o-i+1}return-1}}}const AR=({currentPage:t,totalPages:e,onPageChange:a})=>{let[n,r]=g.useState(!1),[l,i]=g.useState(""),o=g.useMemo(()=>$R(l,e),[l,e]),s=c=>{a(c-1),i(""),r(!1)},u=Math.min(o.count*Fu,240);return(0,d.jsxs)(Kt,{open:e>1?n:!1,onOpenChange:c=>{r(c),c||i("")},children:[(0,d.jsx)(Wt,{asChild:!0,disabled:e<=1,children:(0,d.jsxs)("button",{type:"button",className:V("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",e>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:e<=1,children:[t,(0,d.jsx)(gn,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,d.jsx)(Ut,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,d.jsxs)(Ti,{shouldFilter:!1,value:String(t),children:[(0,d.jsx)(_i,{placeholder:`Page (1\u2013${e})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,value:l,onValueChange:i,onKeyDown:c=>{!["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Enter","Escape"].includes(c.key)&&!/^\d$/.test(c.key)&&c.preventDefault()}}),(0,d.jsx)(Oi,{className:"max-h-60 overflow-hidden",children:o.count===0?(0,d.jsx)(Ii,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"}):(0,d.jsx)(_R,{mapping:o,currentPage:t,listHeight:u,onSelect:s})})]})})]})};var _R=({mapping:t,currentPage:e,listHeight:a,onSelect:n})=>{let r=g.useRef(null),l=t.indexOfPage(e),i=my({count:t.count,getScrollElement:()=>r.current,estimateSize:()=>Fu,overscan:10,initialOffset:l>0?Math.max(0,l*Fu-a/2):0}),o=g.useRef(t.count);return g.useEffect(()=>{t.count!==o.current&&(i.scrollToIndex(0),o.current=t.count)},[t.count,i]),(0,d.jsx)("div",{ref:r,style:{height:a,overflow:"auto"},children:(0,d.jsx)("div",{style:{height:i.getTotalSize(),width:"100%",position:"relative"},children:i.getVirtualItems().map(s=>{let u=t.pageAtIndex(s.index);return(0,d.jsx)(fa,{value:String(u),"data-testid":"page-option","aria-selected":u===e,className:V("text-xs cursor-pointer",u===e&&"font-semibold bg-accent"),style:{position:"absolute",top:0,left:0,width:"100%",height:s.size,transform:`translateY(${s.start}px)`},onSelect:()=>n(u),onMouseDown:ht.preventFocus,children:u},u)})})})};Qd=function(t,e){return`${Ye(t,e)} ${new qy("row").pluralize(t)}`},Ad=({numRows:t,totalColumns:e,hiddenColumns:a,locale:n})=>{let r=t==="too_many"?"Unknown":Qd(t,n),l=a??0,i=e-l;return{rowsAndColumns:[r,l>0?`${Ye(i,n)} visible`:`${Ye(e,n)} ${new qy("column").pluralize(e)}`].join(", "),hiddenSuffix:l>0?`(${Ye(l,n)} hidden)`:null}};var cr=q(),$u=3;const wy=t=>{let e=(0,cr.c)(21),{table:a,className:n}=t,{locale:r}=ye(),l=fn(Eu),i=Tk(l);if(i<2){let f;e[0]===n?f=e[1]:(f=V("text-xs text-muted-foreground/80 italic",n),e[0]=n,e[1]=f);let y;return e[2]===f?y=e[3]:(y=(0,d.jsx)(Pe,{content:"Select multiple cells to see stats",children:(0,d.jsx)("span",{className:f,children:"No selection"})}),e[2]=f,e[3]=y),y}let o;e[4]!==l||e[5]!==a?(o=Vk(a,l),e[4]=l,e[5]=a,e[6]=o):o=e[6];let s=o,u;e[7]===n?u=e[8]:(u=V("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",n),e[7]=n,e[8]=u);let c;e[9]!==i||e[10]!==r?(c=(0,d.jsx)(OR,{count:i,locale:r}),e[9]=i,e[10]=r,e[11]=c):c=e[11];let p,m;e[12]!==r||e[13]!==s?(p=(0,d.jsx)(TR,{numericValues:s,locale:r}),m=(0,d.jsx)(VR,{numericValues:s,locale:r}),e[12]=r,e[13]=s,e[14]=p,e[15]=m):(p=e[14],m=e[15]);let h;return e[16]!==u||e[17]!==c||e[18]!==p||e[19]!==m?(h=(0,d.jsxs)("div",{className:u,children:[c,p,m]}),e[16]=u,e[17]=c,e[18]=p,e[19]=m,e[20]=h):h=e[20],h};var IR=(t,e)=>t.toLocaleString(e,{maximumFractionDigits:$u}),Au=t=>{let e=(0,cr.c)(6),{name:a,value:n,locale:r}=t,l;e[0]!==r||e[1]!==n?(l=IR(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];let i;return e[3]!==a||e[4]!==l?(i=(0,d.jsxs)("span",{children:[a,": ",l]}),e[3]=a,e[4]=l,e[5]=i):i=e[5],i},OR=t=>{let e=(0,cr.c)(3),{count:a,locale:n}=t,r;return e[0]!==a||e[1]!==n?(r=(0,d.jsx)(Au,{name:"Count",value:a,locale:n}),e[0]=a,e[1]=n,e[2]=r):r=e[2],r},TR=t=>{let e=(0,cr.c)(6),{numericValues:a,locale:n}=t;if(a.length===0)return null;let r,l;if(e[0]!==a){let s=a.reduce(zR,0);r=Number,l=s.toFixed($u),e[0]=a,e[1]=r,e[2]=l}else r=e[1],l=e[2];let i=r(l),o;return e[3]!==n||e[4]!==i?(o=(0,d.jsx)(Au,{name:"Sum",value:i,locale:n}),e[3]=n,e[4]=i,e[5]=o):o=e[5],o},VR=t=>{let e=(0,cr.c)(5),{numericValues:a,locale:n}=t;if(a.length===0)return null;let r=a.reduce(BR,0)/a.length,l;e[0]===r?l=e[1]:(l=r.toFixed($u),e[0]=r,e[1]=l);let i=Number(l),o;return e[2]!==i||e[3]!==n?(o=(0,d.jsx)(Au,{name:"Average",value:i,locale:n}),e[2]=i,e[3]=n,e[4]=o):o=e[4],o};function zR(t,e){return t+e}function BR(t,e){return t+e}const LR=({pagination:t,totalColumns:e,selection:a,onRowSelectionChange:n,table:r,getRowIds:l,showPageSizeSelector:i,tableLoading:o,part:s,className:u})=>{let{locale:c}=ye(),p=m=>{if(!n)return;if(!m){n({});return}let h=()=>{let f=Array.from({length:r.getRowCount()},(y,w)=>[w,!0]);n(Object.fromEntries(f))};if(!l){h();return}l({}).then(f=>{if(f.error){wn({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?h():n(Object.fromEntries(f.row_ids.map(y=>[y,!0])))})};return(0,d.jsxs)("div",{part:s,className:V("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,d.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,d.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:m,cellSelection:h}=r.getState(),f=Object.keys(m).length,y=r.getIsAllPageRowsSelected(),w=r.getRowCount(),x=f===w,b=a==="single-cell"||a==="multi-cell";if(b&&(f=h.length,y=!1,x=!1),y&&!x)return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[Ye(f,c)," selected"]}),(0,d.jsxs)(pe,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:ht.preventFocus,onClick:()=>p(!0),children:["Select all ",Ye(w,c)]})]});if(f)return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[Ye(f,c)," selected"]}),(0,d.jsx)(pe,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:ht.preventFocus,onClick:()=>{b?r.resetCellSelection&&r.resetCellSelection():p(!1)},children:"Clear selection"})]});let{totalColumns:v,hiddenColumns:C}=ec(r,e),{rowsAndColumns:j,hiddenSuffix:D}=Ad({numRows:r.getRowCount(),totalColumns:v,hiddenColumns:C,locale:c});return(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{children:j}),D&&(0,d.jsx)("span",{className:"text-xs",children:D})]})})()}),(0,d.jsx)(wy,{table:r,className:"lg:hidden"})]}),(0,d.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:t&&(0,d.jsx)(PR,{table:r,tableLoading:o,showPageSizeSelector:i})}),(0,d.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,d.jsx)(wy,{table:r,className:"px-2"})})]})};var Fa=q();Qx=t=>{let e=(0,Fa.c)(2),{isExpanded:a}=t,n;return e[0]===a?n=e[1]:(n=(0,d.jsx)(cM,{isExpanded:a,className:"h-3 w-3"}),e[0]=a,e[1]=n),n},Jx=t=>{let e=(0,Fa.c)(6),{children:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("flex gap-1.5 items-center font-bold py-1.5 text-muted-foreground bg-(--slate-2) text-sm",n),e[0]=n,e[1]=l);let i;return e[2]!==a||e[3]!==r||e[4]!==l?(i=(0,d.jsx)("div",{className:l,style:r,children:a}),e[2]=a,e[3]=r,e[4]=l,e[5]=i):i=e[5],i},lv=t=>{let e=(0,Fa.c)(6),{content:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("text-sm text-muted-foreground py-1",n),e[0]=n,e[1]=l);let i;return e[2]!==a||e[3]!==r||e[4]!==l?(i=(0,d.jsx)("div",{className:l,style:r,children:a}),e[2]=a,e[3]=r,e[4]=l,e[5]=i):i=e[5],i},nv=t=>{let e=(0,Fa.c)(9),{error:a,style:n,className:r,showIcon:l}=t,i=l===void 0?!0:l,o;e[0]===r?o=e[1]:(o=V("text-sm bg-red-50 dark:bg-red-900 text-red-600 dark:text-red-50 flex items-center gap-2 p-2 h-8",r),e[0]=r,e[1]=o);let s;e[2]===i?s=e[3]:(s=i&&(0,d.jsx)(yn,{className:"h-4 w-4 mt-0.5"}),e[2]=i,e[3]=s);let u;return e[4]!==a.message||e[5]!==n||e[6]!==o||e[7]!==s?(u=(0,d.jsxs)("div",{className:o,style:n,children:[s,a.message]}),e[4]=a.message,e[5]=n,e[6]=o,e[7]=s,e[8]=u):u=e[8],u},Xx=t=>{let e=(0,Fa.c)(7),{message:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("text-sm bg-blue-50 dark:bg-(--accent) text-blue-500 dark:text-blue-50 flex items-center gap-2 p-2 h-8",n),e[0]=n,e[1]=l);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,d.jsx)(mx,{className:"h-4 w-4 animate-spin"}),e[2]=i):i=e[2];let o;return e[3]!==a||e[4]!==r||e[5]!==l?(o=(0,d.jsxs)("div",{className:l,style:r,children:[i,a]}),e[3]=a,e[4]=r,e[5]=l,e[6]=o):o=e[6],o},Zx=t=>{let e=(0,Fa.c)(5),{children:a,className:n}=t,r;e[0]===n?r=e[1]:(r=V("flex flex-col gap-2 relative",n),e[0]=n,e[1]=r);let l;return e[2]!==a||e[3]!==r?(l=(0,d.jsx)("div",{className:r,children:a}),e[2]=a,e[3]=r,e[4]=l):l=e[4],l},Yd=t=>{let e=(0,Fa.c)(6),{columnName:a,dataType:n}=t,r=Gy[n],l=`w-4 h-4 p-0.5 rounded-sm stroke-card-foreground ${Z6(n)}`,i;e[0]!==r||e[1]!==l?(i=(0,d.jsx)(r,{className:l}),e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;return e[3]!==a||e[4]!==i?(o=(0,d.jsxs)("div",{className:"flex flex-row items-center gap-1.5",children:[i,a]}),e[3]=a,e[4]=i,e[5]=o):o=e[5],o};function HR(t){return t.getAllLeafColumns().filter(e=>e.id!=="__select__"&&e.id!=="_marimo_row_id"&&!e.id.startsWith("__m_column__"))}let Sy;Sy=({table:t})=>{let e=HR(t),a=e.map(o=>{var s;return{value:o.id,label:o.id,disabled:!o.getCanHide(),data:{dataType:(s=o.columnDef.meta)==null?void 0:s.dataType}}}),n=e.filter(o=>!o.getIsVisible()).map(o=>o.id),r=o=>{let s=new Set(Array.isArray(o)?o:[]);t.setColumnVisibility(u=>({...u,...Object.fromEntries(e.map(c=>[c.id,!s.has(c.id)]))}))},l=Li({options:a,value:n,onChange:r,multiple:!0,filterFn:IE,pinSelected:!0}),i=l.bulkActions.filter(o=>o.kind==="select-matching"||o.kind==="deselect-matching");return(0,d.jsxs)(Kt,{open:l.open,onOpenChange:l.setOpen,children:[(0,d.jsx)(Wt,{asChild:!0,children:(0,d.jsxs)(pe,{variant:"text",size:"xs","data-testid":"column-visibility-trigger",onMouseDown:ht.preventFocus,className:V("print:hidden text-xs gap-1",l.open?"text-primary":"text-muted-foreground"),children:[(0,d.jsx)(Vc,{className:"w-3.5 h-3.5"}),"Columns"]})}),(0,d.jsx)(Ut,{className:"w-64 p-0",align:"end",children:(0,d.jsxs)(Ti,{shouldFilter:!1,children:[(0,d.jsx)(_i,{placeholder:"Search columns...",value:l.searchQuery,onValueChange:l.setSearchQuery}),(0,d.jsxs)(Oi,{children:[(0,d.jsx)(Ii,{children:"No results."}),l.searchQuery===""?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(fa,{value:"__show_all__",disabled:n.length===0,onSelect:()=>r([]),className:"cursor-pointer",children:[(0,d.jsx)(zu,{className:"w-3 h-3 mr-1.5"}),"Show all"]}),(0,d.jsx)(cd,{})]}):i.length>0&&(0,d.jsxs)(d.Fragment,{children:[i.map(o=>(0,d.jsxs)(fa,{value:`__bulk_${o.kind}`,onSelect:o.run,className:"cursor-pointer",children:[o.kind==="select-matching"?(0,d.jsx)(qu,{className:"w-3 h-3 mr-1.5"}):(0,d.jsx)(zu,{className:"w-3 h-3 mr-1.5"}),o.kind==="select-matching"?"Hide":"Show"," ",o.items.length," matching"]},o.kind)),(0,d.jsx)(cd,{})]}),l.visibleOptions.map((o,s)=>{let u=l.isChecked(o.value),{dataType:c}=o.data,p=s===l.pinnedCount&&l.pinnedCount>0&&l.pinnedCount<l.visibleOptions.length;return(0,d.jsxs)(g.Fragment,{children:[p&&(0,d.jsx)(cd,{}),(0,d.jsxs)(fa,{value:o.value,disabled:o.disabled,onSelect:()=>l.toggle(o.value),className:"flex items-center gap-1.5 cursor-pointer",children:[c===void 0?(0,d.jsx)("span",{children:o.label}):(0,d.jsx)(Yd,{columnName:o.label,dataType:c}),!o.disabled&&(0,d.jsx)("span",{className:V("ml-auto",u?"text-primary":"text-muted-foreground"),children:u?(0,d.jsx)(qu,{className:"w-3 h-3"}):(0,d.jsx)(zu,{className:"w-3 h-3"})})]})]},o.value)})]})]})})]})},Hd=tt(null);var WR=q();Od=t=>{let e=(0,WR.c)(13),{packages:a,showMaxPackages:n,className:r,onInstall:l}=t,{handleInstallPackages:i}=jE(),o=Jy();if(!a||a.length===0||!o)return null;let s;e[0]!==i||e[1]!==l||e[2]!==a?(s=()=>{i(a,l)},e[0]=i,e[1]=l,e[2]=a,e[3]=s):s=e[3];let u;e[4]===r?u=e[5]:(u=V("ml-2",r),e[4]=r,e[5]=u);let c;e[6]!==a||e[7]!==n?(c=n?a.slice(0,n).join(", "):a.join(", "),e[6]=a,e[7]=n,e[8]=c):c=e[8];let p;return e[9]!==s||e[10]!==u||e[11]!==c?(p=(0,d.jsxs)(pe,{variant:"outline",size:"xs",onClick:s,className:u,children:["Install"," ",c]}),e[9]=s,e[10]=u,e[11]=c,e[12]=p):p=e[12],p};var UR=q();const KR=t=>{let e=(0,UR.c)(16),{packages:a,featureName:n,description:r,onInstall:l,className:i}=t;if(!Jy()){let m;e[0]===i?m=e[1]:(m=V("text-xs",i),e[0]=i,e[1]=m);let h;return e[2]!==n||e[3]!==m?(h=(0,d.jsxs)("span",{className:m,children:[n," isn't available in this notebook"]}),e[2]=n,e[3]=m,e[4]=h):h=e[4],h}let o;e[5]===i?o=e[6]:(o=V("text-xs flex flex-col items-end gap-2",i),e[5]=i,e[6]=o);let s=r||`${n} requires ${a.join(", ")}`,u;e[7]===s?u=e[8]:(u=(0,d.jsx)("span",{className:"self-start",children:s}),e[7]=s,e[8]=u);let c;e[9]!==l||e[10]!==a?(c=(0,d.jsx)(Od,{packages:a,onInstall:l,className:"ml-0"}),e[9]=l,e[10]=a,e[11]=c):c=e[11];let p;return e[12]!==o||e[13]!==u||e[14]!==c?(p=(0,d.jsxs)("div",{className:o,children:[u,c]}),e[12]=o,e[13]=u,e[14]=c,e[15]=p):p=e[15],p};var GR=q(),da={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:ux},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:G6},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:Oc},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:ux},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:eN}},Cy=[da.CSV,da.TSV,da.JSON,da.PARQUET],Dy=[da.TSV,da.JSON,da.CSV,da.MARKDOWN],qR={csv:"csv",tsv:"tsv",json:"json",markdown:"json"},jy=t=>{var e;return((e=Cy.find(a=>a.format===t))==null?void 0:e.label)??t},ZR=t=>{var e;return((e=Dy.find(a=>a.format===t))==null?void 0:e.label)??t};const JR=t=>{let e=(0,GR.c)(55),[a,n]=g.useState(!1),r=fn(Hd),l=!!(r&&t.sizeBytes!=null&&t.sizeBytes>r.limitBytes),i=!!(r&&(t.sizeBytesIsLoading||l)),o=i?t.sizeBytesIsLoading?"Checking download size\u2026":r==null?void 0:r.unavailableMessage:"Export",s=a?"text-primary":"text-muted-foreground",u;e[0]===s?u=e[1]:(u=V("print:hidden text-xs gap-1",s),e[0]=s,e[1]=u);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=(0,d.jsx)(Dd,{className:"w-3.5 h-3.5"}),e[2]=c):c=e[2];let p;e[3]!==i||e[4]!==u?(p=(0,d.jsxs)(pe,{"data-testid":"export-button",size:"xs",variant:"text",disabled:i,className:u,children:[c,"Export"]}),e[3]=i,e[4]=u,e[5]=p):p=e[5];let m=p,h;e[6]===t?h=e[7]:(h=async(z,$)=>{let F;try{F=await t.downloadAs({format:z})}catch(_){let E=_;return wn({title:"Failed to download",description:typeof E=="object"&&E&&"message"in E?String(E.message):String(E)}),null}return F.missing_packages&&F.missing_packages.length>0?(wn({title:"Export failed",description:(0,d.jsx)(KR,{packages:F.missing_packages,featureName:`${jy(z)} export`,description:F.error,onInstall:$})}),null):{url:F.url,filename:F.filename}},e[6]=t,e[7]=h);let f=h,y,w,x,b,v,C,j,D,N,k,M,S,R;if(e[8]!==m||e[9]!==i||e[10]!==a||e[11]!==f||e[12]!==o){let z=async I=>{let L=jy(I);await rx(`Preparing ${L} export...`,async()=>{let Y=await f(I,()=>{z(I)});if(!Y)return!1;let W=(Y.filename??"").trim(),ae=`${qN.withoutExtension(W)||"download"}.${I}`,te=Y.url;if(!te.startsWith("data:")){let ce=te.includes("?")?"&":"?",B=new URLSearchParams({download:"1",filename:ae});te=`${te}${ce}${B.toString()}`}return ZN(te,ae),!0})&&wn({title:`${L} download started`})},$=async I=>{await rx(`Preparing ${ZR(I)} for clipboard...`,async()=>{let L=qR[I],Y=await f(L,()=>{$(I)});if(!Y)return;let W;e:switch(I){case"tsv":case"csv":W=await Ry(Y.url);break e;case"json":{let ae=await ky(Y.url);W=JSON.stringify(ae,null,2);break e}case"markdown":W=q6(await ky(Y.url));break e;default:Ia(I);return}await Sn(W),wn({title:"Copied to clipboard"})})};w=yi,v=!1,C=a,j=n;let F=a?!1:void 0,_=i?0:-1,E;e[26]!==m||e[27]!==_?(E=(0,d.jsx)("span",{tabIndex:_,className:"inline-flex",children:m}),e[26]=m,e[27]=_,e[28]=E):E=e[28];let O;e[29]!==i||e[30]!==E?(O=(0,d.jsx)(hi,{asChild:!0,disabled:i,children:E}),e[29]=i,e[30]=E,e[31]=O):O=e[31],e[32]!==F||e[33]!==O||e[34]!==o?(D=(0,d.jsx)(Pe,{content:o,open:F,children:O}),e[32]=F,e[33]=O,e[34]=o,e[35]=D):D=e[35],y=gi,N="bottom",k="print:hidden",e[36]===Symbol.for("react.memo_cache_sentinel")?(M=(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Download"}),e[36]=M):M=e[36],S=Cy.map(I=>(0,d.jsxs)(je,{onSelect:()=>{z(I.format)},children:[(0,d.jsx)(I.icon,{className:"mo-dropdown-icon"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{children:I.label}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:I.description})]})]},I.label)),e[37]===Symbol.for("react.memo_cache_sentinel")?(R=(0,d.jsx)(fi,{}),x=(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),e[37]=x,e[38]=R):(x=e[37],R=e[38]),b=Dy.map(I=>(0,d.jsxs)(je,{onSelect:async()=>{try{await $(I.format)}catch(L){wn({title:"Failed to copy to clipboard",description:dE(L),variant:"danger"})}},children:[(0,d.jsx)(I.icon,{className:"mo-dropdown-icon"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{children:I.label}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:I.description})]})]},I.label)),e[8]=m,e[9]=i,e[10]=a,e[11]=f,e[12]=o,e[13]=y,e[14]=w,e[15]=x,e[16]=b,e[17]=v,e[18]=C,e[19]=j,e[20]=D,e[21]=N,e[22]=k,e[23]=M,e[24]=S,e[25]=R}else y=e[13],w=e[14],x=e[15],b=e[16],v=e[17],C=e[18],j=e[19],D=e[20],N=e[21],k=e[22],M=e[23],S=e[24],R=e[25];let P;e[39]!==y||e[40]!==x||e[41]!==b||e[42]!==N||e[43]!==k||e[44]!==M||e[45]!==S||e[46]!==R?(P=(0,d.jsxs)(y,{side:N,className:k,children:[M,S,R,x,b]}),e[39]=y,e[40]=x,e[41]=b,e[42]=N,e[43]=k,e[44]=M,e[45]=S,e[46]=R,e[47]=P):P=e[47];let T;return e[48]!==w||e[49]!==v||e[50]!==C||e[51]!==j||e[52]!==D||e[53]!==P?(T=(0,d.jsxs)(w,{modal:v,open:C,onOpenChange:j,children:[D,P]}),e[48]=w,e[49]=v,e[50]=C,e[51]=j,e[52]=D,e[53]=P,e[54]=T):T=e[54],T};function ky(t){return Ry(t).then(gr)}function Ry(t){return fetch(t).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var YR=()=>{};let Ny;Ny=({table:t,enableSearch:e,searchQuery:a,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:i,toggleDisplayHeader:o,showTableExplorer:s,togglePanel:u,isAnyPanelOpen:c,downloadAs:p,sizeBytes:m,sizeBytesIsLoading:h})=>{let[f,y]=(0,g.useState)(a||""),w=z5(f,500),x=Je(n??YR),b=g.useRef(null);return(0,g.useEffect)(()=>{x(w)},[w,x]),(0,d.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&e&&(0,d.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,d.jsx)(xx,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,d.jsx)("input",{ref:b,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:f,onKeyDown:v=>{var C;v.key==="Escape"&&(y(""),(C=b.current)==null||C.blur())},onChange:v=>y(v.target.value),placeholder:"Search..."}),r&&(0,d.jsx)(px,{size:"small"}),f&&(0,d.jsx)(pe,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>y(""),children:(0,d.jsx)(yn,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,d.jsxs)("div",{className:"flex items-center shrink-0",children:[(0,d.jsx)(Sy,{table:t}),l&&(0,d.jsxs)(pe,{variant:"text",size:"xs",className:V("print:hidden text-xs gap-1",i?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,d.jsx)(Tc,{className:"w-3.5 h-3.5"}),"Visualize"]}),s&&u&&(0,d.jsxs)(pe,{variant:"text",size:"xs",className:V("print:hidden text-xs gap-1",c?"text-primary":"text-muted-foreground"),onClick:()=>u(Ui.ROW_VIEWER),children:[(0,d.jsx)(Lc,{className:"w-3.5 h-3.5"}),"Explore"]}),p&&(0,d.jsx)(JR,{downloadAs:p,sizeBytes:m,sizeBytesIsLoading:h})]})]})},Zd=(0,g.memo)(({wrapperClassName:t,className:e,maxHeight:a,columns:n,data:r,rawData:l,selection:i,totalColumns:o,totalRows:s,sizeBytes:u,sizeBytesIsLoading:c,manualSorting:p=!1,sorting:m,setSorting:h,rowSelection:f,cellSelection:y,cellStyling:w,hoverTemplate:x,cellHoverTexts:b,paginationState:v,setPaginationState:C,downloadAs:j,manualPagination:D=!1,pagination:N=!1,onRowSelectionChange:k,onCellSelectionChange:M,getRowIds:S,enableSearch:R=!1,searchQuery:P,onSearchQueryChange:T,showFilters:z=!1,filters:$,onFiltersChange:F,calculateTopKRows:_,reloading:E,freezeColumnsLeft:O,freezeColumnsRight:I,hiddenColumns:L,toggleDisplayHeader:Y,showChartBuilder:W,isChartBuilderOpen:ae,showPageSizeSelector:te,showTableExplorer:ce,togglePanel:B,isPanelOpen:J,isAnyPanelOpen:Se,viewedRowIdx:de,onViewedRowChange:Ce,renderTableExplorerPanel:Le})=>{let[Q,re]=g.useState(!1),{locale:Oe}=ye(),{columnPinning:ne,setColumnPinning:he}=Rk(O,I),{columnVisibility:Ie,setColumnVisibility:Ge}=ER(L);g.useEffect(()=>{let U;return E?U=setTimeout(()=>{re(!0)},300):re(!1),()=>{U&&clearTimeout(U)}},[E]);function H(U,ve){return v?ve+(D?v.pageIndex*v.pageSize:0):ve}let le=Vd({_features:[f1,lj,N5,Sj,Dj,wj,vj,jj,jk],data:r,columns:n,meta:{rawData:l},getCoreRowModel:Jd(),rowCount:s==="too_many"?void 0:s,...C?{onPaginationChange:C,getRowId:(U,ve)=>{let Aa=Il(U);if(Aa)return Aa;let _6=H(U,ve);return String(_6)}}:{},locale:Oe,manualPagination:D,getPaginationRowModel:D5(),...h?{onSortingChange:h}:{},manualSorting:p,enableMultiSort:!0,getSortedRowModel:qd(),manualFiltering:!0,enableColumnFilters:z,getFilteredRowModel:Ud(),onColumnFiltersChange:F,onRowSelectionChange:k,onCellSelectionChange:M,enableCellSelection:i==="single-cell"||i==="multi-cell",enableMultiCellSelection:i==="multi-cell",onColumnPinningChange:he,onColumnVisibilityChange:Ge,enableFocusRow:!0,onFocusRowChange:Ce,state:{...m?{sorting:m}:{},columnFilters:$,...v?{pagination:v}:N&&!v?{}:{pagination:{pageIndex:0,pageSize:r.length}},rowSelection:f??{},cellSelection:y??[],columnVisibility:Ie,cellStyling:w,columnPinning:ne,cellHoverTemplate:x,cellHoverTexts:b??{}}}),qe=(J==null?void 0:J(Ui.ROW_VIEWER))??!1,De=!N&&r.length>100,ot=Mk({maxHeight:a,virtualize:De}),[Ze,ie]=g.useState(null),me=g.useMemo(()=>({requestAddFilter:U=>{let ve=le.getColumn(U.columnId);ve&&ie(q1(ve,{operator:U.operator}))}}),[le]),ge=by(le),oe=ge.total>0&&ge.visible===0;return(0,d.jsx)(R4,{value:me,children:(0,d.jsxs)("div",{className:V(t,"flex flex-col space-y-1"),children:[(0,d.jsx)(Ck,{filters:$,table:le,calculateTopKRows:_,addFilterSnapshot:Ze,onAddFilterSnapshotChange:ie}),Le==null?void 0:Le(le),(0,d.jsx)(Gk,{children:(0,d.jsxs)("div",{part:"table-wrapper",className:V(e||"rounded-md border overflow-hidden"),children:[(0,d.jsx)(Ny,{table:le,enableSearch:R,searchQuery:P,onSearchQueryChange:T,reloading:E,showChartBuilder:W,isChartBuilderOpen:ae,toggleDisplayHeader:Y,showTableExplorer:ce,togglePanel:B,isAnyPanelOpen:Se,downloadAs:j,sizeBytes:u,sizeBytesIsLoading:c}),oe&&(0,d.jsxs)(Tx,{className:"mb-1 mx-2 rounded flex items-center justify-between",children:[(0,d.jsx)("span",{children:"All columns are hidden."}),(0,d.jsx)(pe,{variant:"link",size:"xs",onClick:()=>le.resetColumnVisibility(!0),children:"Unhide all"})]}),(0,d.jsxs)($E,{className:V("relative",n.length<=4?"w-auto":"w-full"),ref:ot,children:[Q&&(0,d.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),RR(le,De||!!a),(0,d.jsx)(NR,{table:le,columns:n,rowViewerPanelOpen:qe,getRowIndex:H,viewedRowIdx:de,virtualize:De})]}),(0,d.jsx)(LR,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:o,pagination:N,selection:i,onRowSelectionChange:k,table:le,getRowIds:S,showPageSizeSelector:te,tableLoading:E})]})})]})})});var dn=q(),QR=25;Kd=function(t){return t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1},Ji={"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 ii(t){return t.url==null?gM(t.base64,t.mime):t.url}let _u,My,Ey,Py,Fy,$y;_u=({contents:t})=>{let e=(0,g.useMemo)(()=>ud(t),[t]),[a,n]=(0,g.useState)({pageIndex:0,pageSize:QR}),r=(0,g.useMemo)(()=>yd(e),[e]),l=(0,g.useMemo)(()=>Pd({rowHeaders:tM.EMPTY,selection:null,fieldTypes:r}),[r]);return(0,d.jsx)(Zd,{data:e,totalRows:e.length,columns:l,totalColumns:l.length,manualPagination:!1,paginationState:a,setPaginationState:n,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex flex-col overflow-hidden",rowSelection:Lu.EMPTY})},My=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("img",{src:a,alt:"Preview"}),e[2]=a,e[3]=n),n},Ey=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("audio",{controls:!0,src:a}),e[2]=a,e[3]=n),n},Py=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("video",{controls:!0,src:a}),e[2]=a,e[3]=n),n},Fy=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("iframe",{src:a,title:"PDF Viewer",className:"w-full h-full"}),e[2]=a,e[3]=n),n},$y=t=>{let e=(0,dn.c)(11),a,n;if(e[0]===t?(a=e[1],n=e[2]):({mimeType:a,...n}=t,e[0]=t,e[1]=a,e[2]=n),a.startsWith("image/")){let r;return e[3]===n?r=e[4]:(r=(0,d.jsx)(My,{...n}),e[3]=n,e[4]=r),r}if(a.startsWith("audio/")){let r;return e[5]===n?r=e[6]:(r=(0,d.jsx)(Ey,{...n}),e[5]=n,e[6]=r),r}if(a.startsWith("video/")){let r;return e[7]===n?r=e[8]:(r=(0,d.jsx)(Py,{...n}),e[7]=n,e[8]=r),r}if(a.startsWith("application/pdf")){let r;return e[9]===n?r=e[10]:(r=(0,d.jsx)(Fy,{...n}),e[9]=n,e[10]=r),r}return null},ev=t=>{let e=(0,dn.c)(17),{mimeType:a,contents:n,mediaSource:r,readOnly:l,onChange:i,extensions:o}=t,s=l===void 0?!0:l,u;e[0]===o?u=e[1]:(u=o===void 0?[]:o,e[0]=o,e[1]=u);let c=u,{theme:p}=Ni();if(a==="text/csv"&&n!=null){let m;return e[2]===n?m=e[3]:(m=(0,d.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,d.jsx)(_u,{contents:n})}),e[2]=n,e[3]=m),m}if(Kd(a)&&r){let m;return e[4]!==r||e[5]!==a?(m=(0,d.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,d.jsx)($y,{...r,mimeType:a})}),e[4]=r,e[5]=a,e[6]=m):m=e[6],m}if(n!=null){let m=Ji[a]||Ji.default,h=p==="dark"?"dark":"light",f;e[7]===c?f=e[8]:(f=[ix.lineWrapping,...c],e[7]=c,e[8]=f);let y=s?!1:void 0,w=s?void 0:i,x;return e[9]!==n||e[10]!==m||e[11]!==s||e[12]!==h||e[13]!==f||e[14]!==y||e[15]!==w?(x=(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsx)(g.Suspense,{children:(0,d.jsx)(oM,{theme:h,language:m,className:"border-b",extensions:f,value:n,readOnly:s,editable:y,onChange:w})})}),e[9]=n,e[10]=m,e[11]=s,e[12]=h,e[13]=f,e[14]=y,e[15]=w,e[16]=x):x=e[16],x}return null};function XR(t,e){let{state:a}=t,n=a.doc;if(e<=0||e>n.lines)return Ht.warn(`Invalid line number: ${e}. Document has ${n.lines} lines.`),!1;let r=n.line(e);if(r.text.includes("breakpoint()"))return!0;let l=r.text.match(/^(\s*)/),i=`${l?l[1]:""}breakpoint()
49
+ color: hsl(${Math.max(0,Math.min(120-120*y,120))}deg 100% 31%);`,a==null?void 0:a.key)}return a!=null&&a.onChange&&!(l&&a.skipInitialOnChange)&&a.onChange(r),l=!1,r}return i.updateDeps=o=>{n=o},i}function iy(t,e){if(t===void 0)throw Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}var qk=(t,e)=>Math.abs(t-e)<1.01,Zk=(t,e,a)=>{let n;return function(...r){t.clearTimeout(n),n=t.setTimeout(()=>e.apply(this,r),a)}},oy=t=>{let{offsetWidth:e,offsetHeight:a}=t;return{width:e,height:a}},Jk=t=>t,Yk=t=>{let e=Math.max(t.startIndex-t.overscan,0),a=Math.min(t.endIndex+t.overscan,t.count-1),n=[];for(let r=e;r<=a;r++)n.push(r);return n},Qk=(t,e)=>{let a=t.scrollElement;if(!a)return;let n=t.targetWindow;if(!n)return;let r=i=>{let{width:o,height:s}=i;e({width:Math.round(o),height:Math.round(s)})};if(r(oy(a)),!n.ResizeObserver)return()=>{};let l=new n.ResizeObserver(i=>{let o=()=>{let s=i[0];if(s!=null&&s.borderBoxSize){let u=s.borderBoxSize[0];if(u){r({width:u.inlineSize,height:u.blockSize});return}}r(oy(a))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return l.observe(a,{box:"border-box"}),()=>{l.unobserve(a)}},sy={passive:!0},uy=typeof window>"u"?!0:"onscrollend"in window,Xk=(t,e)=>{let a=t.scrollElement;if(!a)return;let n=t.targetWindow;if(!n)return;let r=0,l=t.options.useScrollendEvent&&uy?()=>{}:Zk(n,()=>{e(r,!1)},t.options.isScrollingResetDelay),i=c=>()=>{let{horizontal:p,isRtl:m}=t.options;r=p?a.scrollLeft*(m&&-1||1):a.scrollTop,l(),e(r,c)},o=i(!0),s=i(!1);a.addEventListener("scroll",o,sy);let u=t.options.useScrollendEvent&&uy;return u&&a.addEventListener("scrollend",s,sy),()=>{a.removeEventListener("scroll",o),u&&a.removeEventListener("scrollend",s)}},eR=(t,e,a)=>{if(e!=null&&e.borderBoxSize){let n=e.borderBoxSize[0];if(n)return Math.round(n[a.options.horizontal?"inlineSize":"blockSize"])}return t[a.options.horizontal?"offsetWidth":"offsetHeight"]},tR=(t,{adjustments:e=0,behavior:a},n)=>{var o;var r,l;let i=t+e;(l=(o=r=n.scrollElement)==null?void 0:o.scrollTo)==null||l.call(r,{[n.options.horizontal?"left":"top"]:i,behavior:a})},aR=class{constructor(t){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 a,n,r;var e;return((r=(n=e=(a=this.targetWindow)==null?void 0:a.performance)==null?void 0:n.now)==null?void 0:r.call(e))??Date.now()},this.observer=(()=>{let e=null,a=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(n=>{n.forEach(r=>{let l=()=>{let i=r.target,o=this.indexFromElement(i);if(!i.isConnected){this.observer.unobserve(i);return}this.shouldMeasureDuringScroll(o)&&this.resizeItem(o,this.options.measureElement(i,r,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var n;(n=a())==null||n.disconnect(),e=null},observe:n=>{var r;return(r=a())==null?void 0:r.observe(n,{box:"border-box"})},unobserve:n=>{var r;return(r=a())==null?void 0:r.unobserve(n)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([a,n])=>{n===void 0&&delete e[a]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Jk,rangeExtractor:Yk,onChange:()=>{},measureElement:eR,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,...e}},this.notify=e=>{var a,n;(n=(a=this.options).onChange)==null||n.call(a,this,e)},this.maybeNotify=un(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{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(e=>e()),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 a;let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((a=this.scrollElement)==null?void 0:a.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,r)=>{this.scrollAdjustments=0,this.scrollDirection=r?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=r,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=(e,a)=>{let n=new Map,r=new Map;for(let l=a-1;l>=0;l--){let i=e[l];if(n.has(i.lane))continue;let o=r.get(i.lane);if(o==null||i.end>o.end?r.set(i.lane,i):i.end<o.end&&n.set(i.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((l,i)=>l.end===i.end?l.index-i.index:l.end-i.end)[0]:void 0},this.getMeasurementOptions=un(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,a,n,r,l,i)=>(this.prevLanes!==void 0&&this.prevLanes!==i&&(this.lanesChangedFlag=!0),this.prevLanes=i,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:a,scrollMargin:n,getItemKey:r,enabled:l,lanes:i}),{key:!1}),this.getMeasurements=un(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:a,scrollMargin:n,getItemKey:r,enabled:l,lanes:i},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let p of this.laneAssignments.keys())p>=e&&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 s=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,s),c=Array(i).fill(void 0);for(let p=0;p<s;p++){let m=u[p];m&&(c[m.lane]=p)}for(let p=s;p<e;p++){let m=r(p),h=this.laneAssignments.get(p),f,y;if(h!==void 0&&this.options.lanes>1){f=h;let v=c[f],C=v===void 0?void 0:u[v];y=C?C.end+this.options.gap:a+n}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);y=v?v.end+this.options.gap:a+n,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let w=o.get(m),x=typeof w=="number"?w:this.options.estimateSize(p),b=y+x;u[p]={index:p,start:y,size:x,end:b,key:m,lane:f},c[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=un(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,a,n,r)=>this.range=e.length>0&&a>0?nR({measurements:e,outerSize:a,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=un(()=>{let e=null,a=null,n=this.calculateRange();return n&&(e=n.startIndex,a=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,a]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,a]},(e,a,n,r,l)=>r===null||l===null?[]:e({startIndex:r,endIndex:l,overscan:a,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let a=this.options.indexAttribute,n=e.getAttribute(a);return n?parseInt(n,10):(console.warn(`Missing attribute name '${a}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let a=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(a!==void 0&&this.range){let r=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,a-r),i=Math.min(this.options.count-1,a+r);return e>=l&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((l,i)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(i))});return}let a=this.indexFromElement(e),n=this.options.getItemKey(a),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(a)&&this.resizeItem(a,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,a)=>{var l;let n=this.measurementsCache[e];if(!n)return;let r=a-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(((l=this.scrollState)==null?void 0:l.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,a)),this.notify(!1))},this.getVirtualItems=un(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,a)=>{let n=[];for(let r=0,l=e.length;r<l;r++){let i=a[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let a=this.getMeasurements();if(a.length!==0)return iy(a[dy(0,a.length-1,n=>iy(a[n]).start,e)])},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 e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,a,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),l=this.getScrollOffset();a==="auto"&&(a=e>=l+r?"end":"start"),a==="center"?e+=(n-r)/2:a==="end"&&(e-=r);let i=this.getMaxScrollOffset();return Math.max(Math.min(i,e),0)},this.getOffsetForIndex=(e,a="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),l=this.measurementsCache[e];if(!l)return;if(a==="auto")if(l.end>=r+n-this.options.scrollPaddingEnd)a="end";else if(l.start<=r+this.options.scrollPaddingStart)a="start";else return[r,a];if(a==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),a];let i=a==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(i,a,l.size),a]},this.scrollToOffset=(e,{align:a="start",behavior:n="auto"}={})=>{let r=this.getOffsetForAlignment(e,a);this.scrollState={index:null,align:a,behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:a="auto",behavior:n="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,a);if(!r)return;let[l,i]=r,o=this.now();this.scrollState={index:e,align:i,behavior:n,startedAt:o,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:a="auto"}={})=>{let n=this.getScrollOffset()+e;this.scrollState={index:null,align:"start",behavior:a,startedAt:this.now(),lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;let e=this.getMeasurements(),a;if(e.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=e[e.length-1])==null?void 0:n.end)??0;else{let r=Array(this.options.lanes).fill(null),l=e.length-1;for(;l>=0&&r.some(i=>i===null);){let i=e[l];r[i.lane]===null&&(r[i.lane]=i.end),l--}a=Math.max(...r.filter(i=>i!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:a,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:a},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}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 t=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),e=t?t[0]:this.scrollState.lastTargetOffset,a=e!==this.scrollState.lastTargetOffset;if(!a&&qk(e,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=e,this.scrollState.behavior="auto",this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},dy=(t,e,a,n)=>{for(;t<=e;){let r=(t+e)/2|0,l=a(r);if(l<n)t=r+1;else if(l>n)e=r-1;else return r}return t>0?t-1:0};function nR({measurements:t,outerSize:e,scrollOffset:a,lanes:n}){let r=t.length-1,l=s=>t[s].start;if(t.length<=n)return{startIndex:0,endIndex:r};let i=dy(0,r,l,a),o=i;if(n===1)for(;o<r&&t[o].end<a+e;)o++;else if(n>1){let s=Array(n).fill(0);for(;o<r&&s.some(c=>c<a+e);){let c=t[o];s[c.lane]=c.end,o++}let u=Array(n).fill(a+e);for(;i>=0&&u.some(c=>c>=a);){let c=t[i];u[c.lane]=c.start,i--}i=Math.max(0,i-i%n),o=Math.min(r,o+(n-1-o%n))}return{startIndex:i,endIndex:o}}var rR=Bu(),cy=typeof document<"u"?g.useLayoutEffect:g.useEffect;function lR({useFlushSync:t=!0,...e}){let a=g.useReducer(()=>({}),{})[1],n={...e,onChange:(l,i)=>{var o;t&&i?(0,rR.flushSync)(a):a(),(o=e.onChange)==null||o.call(e,l,i)}},[r]=g.useState(()=>new aR(n));return r.setOptions(n),cy(()=>r._didMount(),[]),cy(()=>r._willUpdate()),r}function my(t){return lR({observeElementRect:Qk,observeElementOffset:Xk,scrollToFn:tR,...t})}let Lt,Pu,py,fy,hy;Lt=q(),Id=Mv,Nd=Ev,Pu=dN(Pv),py=ex(Sc),fy=ex(Ec),hy=g.forwardRef((t,e)=>{let a=(0,Lt.c)(14),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:r,inset:l,children:n,...i}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]!==r||a[6]!==l?(o=fN({className:r,inset:l}),a[5]=r,a[6]=l,a[7]=o):o=a[7];let s;a[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,d.jsx)(vE,{className:"ml-auto h-4 w-4"}),a[8]=s):s=a[8];let u;return a[9]!==n||a[10]!==i||a[11]!==e||a[12]!==o?(u=(0,d.jsxs)(Mc,{ref:e,className:o,...i,children:[n,s]}),a[9]=n,a[10]=i,a[11]=e,a[12]=o,a[13]=u):u=a[13],u}),hy.displayName=Mc.displayName;var gy="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",iR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(9),n,r;a[0]===t?(n=a[1],r=a[2]):({className:n,...r}=t,a[0]=t,a[1]=n,a[2]=r);let l;a[3]===n?l=a[4]:(l=V(ax({subcontent:!0}),gy,n),a[3]=n,a[4]=l);let i;return a[5]!==r||a[6]!==e||a[7]!==l?(i=(0,d.jsx)(fy,{ref:e,className:l,...r}),a[5]=r,a[6]=e,a[7]=l,a[8]=i):i=a[8],i});iR.displayName=Ec.displayName,Zi=g.forwardRef((t,e)=>{let a=(0,Lt.c)(15),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:n,scrollable:l,...r}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i=l===void 0?!0:l,o;a[4]!==n||a[5]!==i?(o=V(ax(),gy,i&&"overflow-auto",n),a[4]=n,a[5]=i,a[6]=o):o=a[6];let s=i?`calc(var(--radix-context-menu-content-available-height) - ${cN}px)`:void 0,u;a[7]!==r.style||a[8]!==s?(u={...r.style,maxHeight:s},a[7]=r.style,a[8]=s,a[9]=u):u=a[9];let c;return a[10]!==r||a[11]!==e||a[12]!==o||a[13]!==u?(c=(0,d.jsx)(Pu,{children:(0,d.jsx)(uN,{children:(0,d.jsx)(py,{ref:e,className:o,style:u,...r})})}),a[10]=r,a[11]=e,a[12]=o,a[13]=u,a[14]=c):c=a[14],c}),Zi.displayName=Sc.displayName,Va=g.forwardRef((t,e)=>{let a=(0,Lt.c)(13),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:n,inset:r,variant:i,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]!==n||a[6]!==r||a[7]!==i?(o=hN({className:n,inset:r,variant:i}),a[5]=n,a[6]=r,a[7]=i,a[8]=o):o=a[8];let s;return a[9]!==l||a[10]!==e||a[11]!==o?(s=(0,d.jsx)(Dc,{ref:e,className:o,...l}),a[9]=l,a[10]=e,a[11]=o,a[12]=s):s=a[12],s}),Va.displayName=Dc.displayName,Xd=g.forwardRef((t,e)=>{let a=(0,Lt.c)(15),n,r,l,i;a[0]===t?(n=a[1],r=a[2],l=a[3],i=a[4]):({className:l,children:r,checked:n,...i}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l,a[4]=i);let o;a[5]===l?o=a[6]:(o=mN({className:l}),a[5]=l,a[6]=o);let s;a[7]===Symbol.for("react.memo_cache_sentinel")?(s=Wu(),a[7]=s):s=a[7];let u;a[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,d.jsx)("span",{className:s,children:(0,d.jsx)(Rc,{children:(0,d.jsx)(yE,{className:"h-4 w-4"})})}),a[8]=u):u=a[8];let c;return a[9]!==n||a[10]!==r||a[11]!==i||a[12]!==e||a[13]!==o?(c=(0,d.jsxs)(jc,{ref:e,className:o,checked:n,...i,children:[u,r]}),a[9]=n,a[10]=r,a[11]=i,a[12]=e,a[13]=o,a[14]=c):c=a[14],c}),Xd.displayName=jc.displayName;var oR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(13),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:r,children:n,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i;a[4]===r?i=a[5]:(i=Wu({className:r}),a[4]=r,a[5]=i);let o;a[6]===Symbol.for("react.memo_cache_sentinel")?(o=Wu(),a[6]=o):o=a[6];let s;a[7]===Symbol.for("react.memo_cache_sentinel")?(s=(0,d.jsx)("span",{className:o,children:(0,d.jsx)(Rc,{children:(0,d.jsx)(gE,{className:"h-4 w-4 fill-current"})})}),a[7]=s):s=a[7];let u;return a[8]!==n||a[9]!==l||a[10]!==e||a[11]!==i?(u=(0,d.jsxs)(kc,{ref:e,className:i,...l,children:[s,n]}),a[8]=n,a[9]=l,a[10]=e,a[11]=i,a[12]=u):u=a[12],u});oR.displayName=kc.displayName;var sR=g.forwardRef((t,e)=>{let a=(0,Lt.c)(11),n,r,l;a[0]===t?(n=a[1],r=a[2],l=a[3]):({className:n,inset:r,...l}=t,a[0]=t,a[1]=n,a[2]=r,a[3]=l);let i;a[4]!==n||a[5]!==r?(i=gN({className:n,inset:r}),a[4]=n,a[5]=r,a[6]=i):i=a[6];let o;return a[7]!==l||a[8]!==e||a[9]!==i?(o=(0,d.jsx)(Cc,{ref:e,className:i,...l}),a[7]=l,a[8]=e,a[9]=i,a[10]=o):o=a[10],o});sR.displayName=Cc.displayName,to=g.forwardRef((t,e)=>{let a=(0,Lt.c)(9),n,r;a[0]===t?(n=a[1],r=a[2]):({className:n,...r}=t,a[0]=t,a[1]=n,a[2]=r);let l;a[3]===n?l=a[4]:(l=V(pN({className:n})),a[3]=n,a[4]=l);let i;return a[5]!==r||a[6]!==e||a[7]!==l?(i=(0,d.jsx)(Nc,{ref:e,className:l,...r}),a[5]=r,a[6]=e,a[7]=l,a[8]=i):i=a[8],i}),to.displayName=Nc.displayName;var uR=q();const dR=t=>{let e=(0,uR.c)(12),{contextMenuRef:a,tableBody:n,tableRef:r,copyAllCells:l}=t,i;e[0]!==a||e[1]!==r?(i=p=>{var f;let m=a.current;if(!m)return;let h=(f=r.current)==null?void 0:f.querySelector(`[${U6}="${m.id}"]`);if(!h){Ht.error("Context menu cell not found in table");return}p?h.classList.add("bg-(--green-4)"):h.classList.remove("bg-(--green-4)")},e[0]=a,e[1]=r,e[2]=i):i=e[2];let o=Je(i),s;e[3]===n?s=e[4]:(s=(0,d.jsx)(Nd,{asChild:!0,children:n}),e[3]=n,e[4]=s);let u;e[5]!==a||e[6]!==l?(u=(0,d.jsx)(Pu,{children:(0,d.jsx)(cR,{cellRef:a,copySelectedCells:l})}),e[5]=a,e[6]=l,e[7]=u):u=e[7];let c;return e[8]!==o||e[9]!==s||e[10]!==u?(c=(0,d.jsxs)(Id,{onOpenChange:o,children:[s,u]}),e[8]=o,e[9]=s,e[10]=u,e[11]=c):c=e[11],c},cR=({cellRef:t,copySelectedCells:e})=>{var m;let a=fn(Eu).size>1,n=t.current;if(!n){Ht.error("No cell found in context menu");return}let r=n.getContext().table,l=n.getValue(),i=Js(r,n.row.index,n.column.id)??l,o=()=>{try{let{text:h,html:f}=n1(i,l);Sn(h,f)}catch(h){Ht.error("Failed to copy context menu cell",h)}},s=n.column,u=(m=s.columnDef.meta)==null?void 0:m.filterType,c=s.getCanFilter()&&u&&Ks(u)?u:void 0,p=(h,f)=>{let y=h==="number"?it.number({operator:f,values:[i]}):it.text({operator:f,values:[i]});s.setFilterValue(y)};return(0,d.jsxs)(Zi,{children:[(0,d.jsxs)(Va,{onClick:o,children:[(0,d.jsx)(bi,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),a&&(0,d.jsxs)(Va,{onClick:e,children:[(0,d.jsx)(Wc,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),c&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(to,{}),(0,d.jsxs)(Va,{onClick:()=>p(c,"in"),children:[(0,d.jsx)(jn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,d.jsxs)(Va,{onClick:()=>p(c,"not_in"),children:[(0,d.jsx)(jn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var mR=q();const pR=t=>{let e=(0,mR.c)(15),{state:a,contentId:n,onClose:r}=t,l=a!=null,i;e[0]===r?i=e[1]:(i=y=>{y||r()},e[0]=r,e[1]=i);let o=(a==null?void 0:a.rect.top)??0,s=(a==null?void 0:a.rect.left)??0,u=(a==null?void 0:a.rect.width)??0,c=(a==null?void 0:a.rect.height)??0,p;e[2]!==o||e[3]!==s||e[4]!==u||e[5]!==c?(p=(0,d.jsx)(XN,{asChild:!0,children:(0,d.jsx)("div",{"aria-hidden":!0,style:{position:"fixed",top:o,left:s,width:u,height:c,pointerEvents:"none"}})}),e[2]=o,e[3]=s,e[4]=u,e[5]=c,e[6]=p):p=e[6];let m=a==null?void 0:a.content,h;e[7]!==n||e[8]!==m?(h=(0,d.jsx)(eM,{children:(0,d.jsx)(QN,{id:n,children:m})}),e[7]=n,e[8]=m,e[9]=h):h=e[9];let f;return e[10]!==l||e[11]!==i||e[12]!==p||e[13]!==h?(f=(0,d.jsxs)(YN,{open:l,onOpenChange:i,delayDuration:0,disableHoverableContent:!0,children:[p,h]}),e[10]=l,e[11]=i,e[12]=p,e[13]=h,e[14]=f):f=e[14],f};function fR(t,e){let a=/{{(\w+)}}/g,n=new Map;for(let r of e){let l=Ma({value:r.getValue(),nullAsEmptyString:!0});n.set(r.column.id,l)}return t.replaceAll(a,(r,l)=>{let i=n.get(l);return i===void 0?`{{${l}}}`:i})}function yy(t,e){var n;let a=(n=t.getHoverTitle)==null?void 0:n.call(t);if(a!=null&&a!=="")return a;if(e)return fR(e,t.row.getVisibleCells())}var hR=q(),gR=400;function yR(t){let e=(0,hR.c)(33),{table:a}=t,n;e[0]===a?n=e[1]:(n=a.getState().cellHoverTemplate||null,e[0]=a,e[1]=n);let r=n,[l,i]=(0,g.useState)(null),o=(0,g.useRef)(null),s=(0,g.useId)(),u=(0,g.useRef)(null),c=(0,g.useRef)(!1),p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{o.current!=null&&(clearTimeout(o.current),o.current=null)},e[2]=p):p=e[2];let m=p,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{m(),i(null)},e[3]=h):h=e[3];let f=Je(h),y;e[4]===Symbol.for("react.memo_cache_sentinel")?(y=(E,O)=>{u.current=E;let I=E.getBoundingClientRect();i({rect:{top:I.top,left:I.left,width:I.width,height:I.height},content:O})},e[4]=y):y=e[4];let w=y,x,b;e[5]!==s||e[6]!==l?(x=()=>{if(!l)return;let E=u.current;return E==null||E.setAttribute("aria-describedby",s),()=>E==null?void 0:E.removeAttribute("aria-describedby")},b=[l,s],e[5]=s,e[6]=l,e[7]=x,e[8]=b):(x=e[7],b=e[8]),(0,g.useLayoutEffect)(x,b);let v,C;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{let E=()=>{c.current=!0},O=()=>{c.current=!1};return window.addEventListener("mousedown",E,{capture:!0}),window.addEventListener("mouseup",O,{capture:!0}),()=>{window.removeEventListener("mousedown",E,{capture:!0}),window.removeEventListener("mouseup",O,{capture:!0})}},C=[],e[9]=v,e[10]=C):(v=e[9],C=e[10]),(0,g.useEffect)(v,C);let j;e[11]!==f||e[12]!==r?(j=(E,O)=>{if(E.buttons!==0)return;let I=E.currentTarget,L=yy(O,r);if(L==null||L===""){f();return}m(),o.current=window.setTimeout(()=>w(I,L),gR)},e[11]=f,e[12]=r,e[13]=j):j=e[13];let D=Je(j),N;e[14]===f?N=e[15]:(N=()=>f(),e[14]=f,e[15]=N);let k=Je(N),M;e[16]===r?M=e[17]:(M=(E,O)=>{if(m(),c.current)return;let I=yy(O,r);I==null||I===""||w(E.currentTarget,I)},e[16]=r,e[17]=M);let S=Je(M),R;e[18]===f?R=e[19]:(R=()=>f(),e[18]=f,e[19]=R);let P=Je(R),T,z;e[20]===f?(T=e[21],z=e[22]):(T=()=>(window.addEventListener("scroll",f,{passive:!0,capture:!0}),window.addEventListener("resize",f),()=>{window.removeEventListener("scroll",f,{capture:!0}),window.removeEventListener("resize",f)}),z=[f],e[20]=f,e[21]=T,e[22]=z),(0,g.useEffect)(T,z);let $,F;e[23]===Symbol.for("react.memo_cache_sentinel")?($=()=>m,F=[],e[23]=$,e[24]=F):($=e[23],F=e[24]),(0,g.useEffect)($,F);let _;return e[25]!==P||e[26]!==S||e[27]!==k||e[28]!==D||e[29]!==f||e[30]!==s||e[31]!==l?(_={tooltipState:l,tooltipContentId:s,hideTooltip:f,handleCellMouseOver:D,handleCellMouseLeave:k,handleCellFocus:S,handleCellBlur:P},e[25]=P,e[26]=S,e[27]=k,e[28]=D,e[29]=f,e[30]=s,e[31]=l,e[32]=_):_=e[32],_}var xR=q();const xy=(0,g.memo)(t=>{let e=(0,xR.c)(9),{cellId:a,className:n}=t,r;e[0]===a?r=e[1]:(r=Wk(a),e[0]=a,e[1]=r);let{isSelected:l,isCopied:i}=fn(r);if(!l&&!i)return null;let o=l&&"bg-(--green-3)",s=i&&"bg-(--green-4) transition-colors duration-150",u;e[2]!==n||e[3]!==o||e[4]!==s?(u=V("absolute inset-0 pointer-events-none",o,s,n),e[2]=n,e[3]=o,e[4]=s,e[5]=u):u=e[5];let c;return e[6]!==a||e[7]!==u?(c=(0,d.jsx)("div",{"data-cell-id":a,className:u}),e[6]=a,e[7]=u,e[8]=c):c=e[8],c});xy.displayName="CellRangeSelectionIndicator";var vR=q();const bR=t=>{let e=(0,vR.c)(30),{table:a}=t,n=Lk(),r;e[0]!==n||e[1]!==a?(r=()=>{n.handleCopy({table:a,onCopyComplete:()=>{setTimeout(()=>{n.setCopiedCells(new Set)},500)}})},e[0]=n,e[1]=a,e[2]=r):r=e[2];let l=Je(r),i;e[3]!==n||e[4]!==a?(i=(v,C)=>{n.updateSelection({newCell:v,isShiftKey:C,table:a})},e[3]=n,e[4]=a,e[5]=i):i=e[5];let o=Je(i),s;e[6]!==n||e[7]!==a?(s=(v,C)=>{n.navigate({direction:C,isShiftKey:v.shiftKey,table:a})},e[6]=n,e[7]=a,e[8]=s):s=e[8];let u=Je(s),c;e[9]!==n||e[10]!==l||e[11]!==u||e[12]!==a?(c=v=>{e:switch(v.key){case"c":ht.isMetaOrCtrl(v)&&l();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(),n.toggleCurrentRowSelection(a);break e;case"Escape":n.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),n.selectAllCells(a))}},e[9]=n,e[10]=l,e[11]=u,e[12]=a,e[13]=c):c=e[13];let p=Je(c),m;e[14]!==n||e[15]!==a?(m=(v,C)=>{v.buttons!==2&&(CR(v)||n.handleCellMouseDown({cell:C,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:a}))},e[14]=n,e[15]=a,e[16]=m):m=e[16];let h=Je(m),f;e[17]===n?f=e[18]:(f=()=>{n.setIsSelecting(!1)},e[17]=n,e[18]=f);let y=Je(f),w;e[19]!==n||e[20]!==a?(w=(v,C)=>{v.buttons===1&&n.updateRangeSelection({cell:C,table:a})},e[19]=n,e[20]=a,e[21]=w):w=e[21];let x=Je(w),b;return e[22]!==n.clearSelection||e[23]!==h||e[24]!==x||e[25]!==y||e[26]!==p||e[27]!==l||e[28]!==o?(b={handleCellMouseDown:h,handleCellMouseUp:y,handleCellMouseOver:x,handleCopy:l,handleCellsKeyDown:p,updateSelection:o,clearSelection:n.clearSelection},e[22]=n.clearSelection,e[23]=h,e[24]=x,e[25]=y,e[26]=p,e[27]=l,e[28]=o,e[29]=b):b=e[29],b};var wR='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element',SR=new Set(["marimo-lazy","marimo-routes"]);function CR(t){var a;let e=typeof((a=t.nativeEvent)==null?void 0:a.composedPath)=="function"?t.nativeEvent.composedPath():[t.target];for(let n of e){if(n===t.currentTarget)break;if(!(!(n instanceof Element)||!n.matches(wR))){if(n.localName==="marimo-ui-element"){let r=n.firstElementChild;if(r&&SR.has(r.localName))continue}return!0}}return!1}var DR=q(),jR=tt(t=>t(Pa).focusedCell);function kR(t){let e=(0,DR.c)(2),a;e[0]===t?a=e[1]:(a=n=>{n!=null&&n.cellId&&setTimeout(()=>{var l;let r=(l=t.current)==null?void 0:l.querySelector(`[data-cell-id="${n.cellId}"]`);if(!r){Ht.warn("[ScrollIntoView] Could not find cell with ID:",n.cellId);return}r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},e[0]=t,e[1]=a),T6(jR,a)}function RR(t,e){var n;if(!((n=t.getRowModel().rows)!=null&&n.length))return null;let a=r=>r.map(l=>l.headers.map(i=>{let{className:o,style:s}=vy(i.column);return(0,d.jsx)(PE,{className:V("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",o),style:s,ref:u=>{MR({table:t,column:i.column,thead:u})},children:i.isPlaceholder?null:Vi(i.column.columnDef.header,i.getContext())},i.id)}));return(0,d.jsx)(EE,{className:V(e&&"sticky top-0 z-10"),children:(0,d.jsxs)(dd,{children:[a(t.getLeftHeaderGroups()),a(t.getCenterHeaderGroups()),a(t.getRightHeaderGroups()),t.getAllColumns().length<=4&&(0,d.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const NR=({table:t,columns:e,rowViewerPanelOpen:a,getRowIndex:n,viewedRowIdx:r,virtualize:l=!1})=>{let i=t.getRowModel().rows,[o,s]=(0,g.useState)(null),u=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{var k,M;s(((M=(k=u.current)==null?void 0:k.parentElement)==null?void 0:M.parentElement)??null)},[]);let c=my({count:l?i.length:0,getScrollElement:()=>o,estimateSize:()=>24,overscan:10});kR(u);let{handleCellMouseDown:p,handleCellMouseUp:m,handleCellMouseOver:h,handleCellsKeyDown:f,handleCopy:y}=bR({table:t}),w=(0,g.useRef)(null),x=Je(k=>{w.current=k}),b=yR({table:t}),v=k=>k.map(M=>{var z,$,F,_;let{className:S,style:R}=vy(M.column),P=(z=M.column.columnDef.meta)==null?void 0:z.width,T=Object.assign({},(($=M.getUserStyling)==null?void 0:$.call(M))||{},R);return(0,g.createElement)(Vx,{tabIndex:0,...K6(M.id),key:M.id,className:V("whitespace-pre truncate outline-hidden border-r border-r-border/75",!P&&"max-w-[300px]",M.column.getColumnWrapping&&((_=(F=M.column).getColumnWrapping)==null?void 0:_.call(F))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",S),style:T,onMouseDown:E=>{p(E,M),b.hideTooltip()},onMouseUp:m,onMouseOver:E=>{h(E,M),b.handleCellMouseOver(E,M)},onMouseLeave:b.handleCellMouseLeave,onFocus:E=>b.handleCellFocus(E,M),onBlur:b.handleCellBlur,onContextMenu:()=>x(M)},(0,d.jsx)(xy,{cellId:M.id}),(0,d.jsx)("div",{className:"relative",children:Vi(M.column.columnDef.cell,M.getContext())}))}),C=k=>{var M;if(a){let S=(n==null?void 0:n(k.original,k.index))??k.index;(M=k.focusRow)==null||M.call(k,S)}},j=k=>{let M=a?(n==null?void 0:n(k.original,k.index))??k.index:void 0,S=a&&r===M;return(0,d.jsxs)(dd,{"data-state":k.getIsSelected()&&"selected",className:V("border-t h-6",a&&"cursor-pointer",S&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>C(k),children:[v(k.getLeftVisibleCells()),v(k.getCenterVisibleCells()),v(k.getRightVisibleCells()),e.length<=4&&(0,d.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},k.id)},D=e.length<=4,N=e.length+(D?1:0);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(dR,{tableBody:(0,d.jsx)(FE,{onKeyDown:f,ref:u,children:(()=>{var k,M;if(i.length===0)return(0,d.jsx)(dd,{children:(0,d.jsx)(Vx,{colSpan:N,className:"h-24 text-center",children:"No results."})});if(l){let S=c.getVirtualItems(),R=c.getTotalSize();return(0,d.jsxs)(d.Fragment,{children:[((k=S[0])==null?void 0:k.start)>0&&(0,d.jsx)("tr",{"data-virtual-spacer":"",style:{height:S[0].start},children:(0,d.jsx)("td",{colSpan:N})}),S.map(P=>j(i[P.index])),S.length>0&&(0,d.jsx)("tr",{"data-virtual-spacer":"",style:{height:R-(((M=S.at(-1))==null?void 0:M.end)??R)},children:(0,d.jsx)("td",{colSpan:N})})]})}return i.map(S=>j(S))})()}),contextMenuRef:w,tableRef:u,copyAllCells:y}),(0,d.jsx)(pR,{state:b.tooltipState,contentId:b.tooltipContentId,onClose:b.hideTooltip})]})};function vy(t){var l;let e=t.getIsPinned(),a=e==="left"&&t.getIsLastColumn("left"),n=e==="right"&&t.getIsFirstColumn("right"),r=(l=t.columnDef.meta)==null?void 0:l.width;return{className:V(e&&"bg-inherit","shadow-r z-10"),style:{boxShadow:a&&t.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":n?"4px 0 4px -4px var(--slate-8) inset":void 0,left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,opacity:1,position:e?"sticky":"relative",zIndex:e?1:0,width:t.getSize(),...r?{minWidth:r,maxWidth:r}:{}}}}function MR({table:t,column:e,thead:a}){if(!a)return;let n=Math.round(a.getBoundingClientRect().width);t.getState().columnSizing[e.id]!==n&&t.setColumnSizing(r=>({...r,[e.id]:n}))}function ER(t){let[e,a]=Wi(Object.fromEntries((t??[]).map(n=>[n,!1])),Uy);return{columnVisibility:e,setColumnVisibility:a}}function by(t){let e=t.getAllLeafColumns().filter(n=>n.getCanHide()),a=e.filter(n=>n.getIsVisible()).length;return{total:e.length,visible:a,hidden:e.length-a}}ec=function(t,e){let a=by(t);return{totalColumns:a.hidden>0?a.total:e,hiddenColumns:a.hidden}};const PR=({table:t,tableLoading:e,showPageSizeSelector:a})=>{let{locale:n}=ye(),r=Math.min(t.getState().pagination.pageIndex+1,t.getPageCount()),l=t.getPageCount(),i=t.getState().pagination.pageSize,o=u=>{e||u()},s=[...new Set([5,10,25,50,100,i])].toSorted((u,c)=>u-c);return(0,d.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,d.jsx)("div",{className:"order-2 lg:order-first",children:a&&(0,d.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,d.jsxs)(yi,{children:[(0,d.jsx)(hi,{asChild:!0,children:(0,d.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:[i," / page",(0,d.jsx)(gn,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,d.jsxs)(gi,{align:"center",sideOffset:6,children:[(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...s].map(u=>(0,d.jsx)(je,{className:V("text-xs cursor-pointer",u===i&&"font-semibold bg-accent"),onSelect:()=>t.setPageSize(u),onMouseDown:ht.preventFocus,children:u},u))]})]})})}),(0,d.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,d.jsx)(Pe,{content:"First page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>o(()=>t.setPageIndex(0)),onMouseDown:ht.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,d.jsx)(gd,{className:"h-4 w-4"})})}),(0,d.jsx)(Pe,{content:"Previous page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>o(()=>t.previousPage()),onMouseDown:ht.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,d.jsx)(Ku,{className:"h-4 w-4"})})}),(0,d.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,d.jsx)("span",{children:"Page"}),(0,d.jsx)(AR,{currentPage:r,totalPages:l,onPageChange:u=>o(()=>t.setPageIndex(u))}),(0,d.jsxs)("span",{className:"shrink-0",children:["of ",Ye(l,n)]})]}),(0,d.jsx)(Pe,{content:"Next page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>o(()=>t.nextPage()),onMouseDown:ht.preventFocus,disabled:!t.getCanNextPage(),children:(0,d.jsx)(xi,{className:"h-4 w-4"})})}),(0,d.jsx)(Pe,{content:"Last page",children:(0,d.jsx)(pe,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>o(()=>t.setPageIndex(t.getPageCount()-1)),onMouseDown:ht.preventFocus,disabled:!t.getCanNextPage(),children:(0,d.jsx)(jd,{className:"h-4 w-4"})})})]})]})};var Fu=32;function FR(t,e){let a=Number.parseInt(t,10);if(Number.isNaN(a)||a<=0||String(a)!==t)return[];let n=[],r=1;for(;a*r<=e;){let l=a*r,i=Math.min((a+1)*r-1,e);n.push([l,i]),r*=10}return n}function $R(t,e){if(t==="")return{count:e,pageAtIndex:r=>r+1,indexOfPage:r=>r-1};let a=FR(t,e),n=0;for(let[r,l]of a)n+=l-r+1;return{count:n,pageAtIndex:r=>{let l=0;for(let[i,o]of a){let s=o-i+1;if(r<l+s)return i+(r-l);l+=s}return-1},indexOfPage:r=>{let l=0;for(let[i,o]of a){if(r>=i&&r<=o)return l+(r-i);l+=o-i+1}return-1}}}const AR=({currentPage:t,totalPages:e,onPageChange:a})=>{let[n,r]=g.useState(!1),[l,i]=g.useState(""),o=g.useMemo(()=>$R(l,e),[l,e]),s=c=>{a(c-1),i(""),r(!1)},u=Math.min(o.count*Fu,240);return(0,d.jsxs)(Kt,{open:e>1?n:!1,onOpenChange:c=>{r(c),c||i("")},children:[(0,d.jsx)(Wt,{asChild:!0,disabled:e<=1,children:(0,d.jsxs)("button",{type:"button",className:V("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",e>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:e<=1,children:[t,(0,d.jsx)(gn,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,d.jsx)(Ut,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,d.jsxs)(Ti,{shouldFilter:!1,value:String(t),children:[(0,d.jsx)(_i,{placeholder:`Page (1\u2013${e})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,value:l,onValueChange:i,onKeyDown:c=>{!["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Enter","Escape"].includes(c.key)&&!/^\d$/.test(c.key)&&c.preventDefault()}}),(0,d.jsx)(Oi,{className:"max-h-60 overflow-hidden",children:o.count===0?(0,d.jsx)(Ii,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"}):(0,d.jsx)(_R,{mapping:o,currentPage:t,listHeight:u,onSelect:s})})]})})]})};var _R=({mapping:t,currentPage:e,listHeight:a,onSelect:n})=>{let r=g.useRef(null),l=t.indexOfPage(e),i=my({count:t.count,getScrollElement:()=>r.current,estimateSize:()=>Fu,overscan:10,initialOffset:l>0?Math.max(0,l*Fu-a/2):0}),o=g.useRef(t.count);return g.useEffect(()=>{t.count!==o.current&&(i.scrollToIndex(0),o.current=t.count)},[t.count,i]),(0,d.jsx)("div",{ref:r,style:{height:a,overflow:"auto"},children:(0,d.jsx)("div",{style:{height:i.getTotalSize(),width:"100%",position:"relative"},children:i.getVirtualItems().map(s=>{let u=t.pageAtIndex(s.index);return(0,d.jsx)(fa,{value:String(u),"data-testid":"page-option","aria-selected":u===e,className:V("text-xs cursor-pointer",u===e&&"font-semibold bg-accent"),style:{position:"absolute",top:0,left:0,width:"100%",height:s.size,transform:`translateY(${s.start}px)`},onSelect:()=>n(u),onMouseDown:ht.preventFocus,children:u},u)})})})};Qd=function(t,e){return`${Ye(t,e)} ${new qy("row").pluralize(t)}`},Ad=({numRows:t,totalColumns:e,hiddenColumns:a,locale:n})=>{let r=t==="too_many"?"Unknown":Qd(t,n),l=a??0,i=e-l;return{rowsAndColumns:[r,l>0?`${Ye(i,n)} visible`:`${Ye(e,n)} ${new qy("column").pluralize(e)}`].join(", "),hiddenSuffix:l>0?`(${Ye(l,n)} hidden)`:null}};var cr=q(),$u=3;const wy=t=>{let e=(0,cr.c)(21),{table:a,className:n}=t,{locale:r}=ye(),l=fn(Eu),i=Tk(l);if(i<2){let f;e[0]===n?f=e[1]:(f=V("text-xs text-muted-foreground/80 italic",n),e[0]=n,e[1]=f);let y;return e[2]===f?y=e[3]:(y=(0,d.jsx)(Pe,{content:"Select multiple cells to see stats",children:(0,d.jsx)("span",{className:f,children:"No selection"})}),e[2]=f,e[3]=y),y}let o;e[4]!==l||e[5]!==a?(o=Vk(a,l),e[4]=l,e[5]=a,e[6]=o):o=e[6];let s=o,u;e[7]===n?u=e[8]:(u=V("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",n),e[7]=n,e[8]=u);let c;e[9]!==i||e[10]!==r?(c=(0,d.jsx)(OR,{count:i,locale:r}),e[9]=i,e[10]=r,e[11]=c):c=e[11];let p,m;e[12]!==r||e[13]!==s?(p=(0,d.jsx)(TR,{numericValues:s,locale:r}),m=(0,d.jsx)(VR,{numericValues:s,locale:r}),e[12]=r,e[13]=s,e[14]=p,e[15]=m):(p=e[14],m=e[15]);let h;return e[16]!==u||e[17]!==c||e[18]!==p||e[19]!==m?(h=(0,d.jsxs)("div",{className:u,children:[c,p,m]}),e[16]=u,e[17]=c,e[18]=p,e[19]=m,e[20]=h):h=e[20],h};var IR=(t,e)=>t.toLocaleString(e,{maximumFractionDigits:$u}),Au=t=>{let e=(0,cr.c)(6),{name:a,value:n,locale:r}=t,l;e[0]!==r||e[1]!==n?(l=IR(n,r),e[0]=r,e[1]=n,e[2]=l):l=e[2];let i;return e[3]!==a||e[4]!==l?(i=(0,d.jsxs)("span",{children:[a,": ",l]}),e[3]=a,e[4]=l,e[5]=i):i=e[5],i},OR=t=>{let e=(0,cr.c)(3),{count:a,locale:n}=t,r;return e[0]!==a||e[1]!==n?(r=(0,d.jsx)(Au,{name:"Count",value:a,locale:n}),e[0]=a,e[1]=n,e[2]=r):r=e[2],r},TR=t=>{let e=(0,cr.c)(6),{numericValues:a,locale:n}=t;if(a.length===0)return null;let r,l;if(e[0]!==a){let s=a.reduce(zR,0);r=Number,l=s.toFixed($u),e[0]=a,e[1]=r,e[2]=l}else r=e[1],l=e[2];let i=r(l),o;return e[3]!==n||e[4]!==i?(o=(0,d.jsx)(Au,{name:"Sum",value:i,locale:n}),e[3]=n,e[4]=i,e[5]=o):o=e[5],o},VR=t=>{let e=(0,cr.c)(5),{numericValues:a,locale:n}=t;if(a.length===0)return null;let r=a.reduce(BR,0)/a.length,l;e[0]===r?l=e[1]:(l=r.toFixed($u),e[0]=r,e[1]=l);let i=Number(l),o;return e[2]!==i||e[3]!==n?(o=(0,d.jsx)(Au,{name:"Average",value:i,locale:n}),e[2]=i,e[3]=n,e[4]=o):o=e[4],o};function zR(t,e){return t+e}function BR(t,e){return t+e}const LR=({pagination:t,totalColumns:e,selection:a,onRowSelectionChange:n,table:r,getRowIds:l,showPageSizeSelector:i,tableLoading:o,part:s,className:u})=>{let{locale:c}=ye(),p=m=>{if(!n)return;if(!m){n({});return}let h=()=>{let f=Array.from({length:r.getRowCount()},(y,w)=>[w,!0]);n(Object.fromEntries(f))};if(!l){h();return}l({}).then(f=>{if(f.error){wn({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?h():n(Object.fromEntries(f.row_ids.map(y=>[y,!0])))})};return(0,d.jsxs)("div",{part:s,className:V("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,d.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,d.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:m,cellSelection:h}=r.getState(),f=Object.keys(m).length,y=r.getIsAllPageRowsSelected(),w=r.getRowCount(),x=f===w,b=a==="single-cell"||a==="multi-cell";if(b&&(f=h.length,y=!1,x=!1),y&&!x)return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[Ye(f,c)," selected"]}),(0,d.jsxs)(pe,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:ht.preventFocus,onClick:()=>p(!0),children:["Select all ",Ye(w,c)]})]});if(f)return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{children:[Ye(f,c)," selected"]}),(0,d.jsx)(pe,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:ht.preventFocus,onClick:()=>{b?r.resetCellSelection&&r.resetCellSelection():p(!1)},children:"Clear selection"})]});let{totalColumns:v,hiddenColumns:C}=ec(r,e),{rowsAndColumns:j,hiddenSuffix:D}=Ad({numRows:r.getRowCount(),totalColumns:v,hiddenColumns:C,locale:c});return(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{children:j}),D&&(0,d.jsx)("span",{className:"text-xs",children:D})]})})()}),(0,d.jsx)(wy,{table:r,className:"lg:hidden"})]}),(0,d.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:t&&(0,d.jsx)(PR,{table:r,tableLoading:o,showPageSizeSelector:i})}),(0,d.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,d.jsx)(wy,{table:r,className:"px-2"})})]})};var Fa=q();Qx=t=>{let e=(0,Fa.c)(2),{isExpanded:a}=t,n;return e[0]===a?n=e[1]:(n=(0,d.jsx)(cM,{isExpanded:a,className:"h-3 w-3"}),e[0]=a,e[1]=n),n},Jx=t=>{let e=(0,Fa.c)(6),{children:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("flex gap-1.5 items-center font-bold py-1.5 text-muted-foreground bg-(--slate-2) text-sm",n),e[0]=n,e[1]=l);let i;return e[2]!==a||e[3]!==r||e[4]!==l?(i=(0,d.jsx)("div",{className:l,style:r,children:a}),e[2]=a,e[3]=r,e[4]=l,e[5]=i):i=e[5],i},lv=t=>{let e=(0,Fa.c)(6),{content:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("text-sm text-muted-foreground py-1",n),e[0]=n,e[1]=l);let i;return e[2]!==a||e[3]!==r||e[4]!==l?(i=(0,d.jsx)("div",{className:l,style:r,children:a}),e[2]=a,e[3]=r,e[4]=l,e[5]=i):i=e[5],i},nv=t=>{let e=(0,Fa.c)(9),{error:a,style:n,className:r,showIcon:l}=t,i=l===void 0?!0:l,o;e[0]===r?o=e[1]:(o=V("text-sm bg-red-50 dark:bg-red-900 text-red-600 dark:text-red-50 flex items-center gap-2 p-2 h-8",r),e[0]=r,e[1]=o);let s;e[2]===i?s=e[3]:(s=i&&(0,d.jsx)(yn,{className:"h-4 w-4 mt-0.5"}),e[2]=i,e[3]=s);let u;return e[4]!==a.message||e[5]!==n||e[6]!==o||e[7]!==s?(u=(0,d.jsxs)("div",{className:o,style:n,children:[s,a.message]}),e[4]=a.message,e[5]=n,e[6]=o,e[7]=s,e[8]=u):u=e[8],u},Xx=t=>{let e=(0,Fa.c)(7),{message:a,className:n,style:r}=t,l;e[0]===n?l=e[1]:(l=V("text-sm bg-blue-50 dark:bg-(--accent) text-blue-500 dark:text-blue-50 flex items-center gap-2 p-2 h-8",n),e[0]=n,e[1]=l);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,d.jsx)(mx,{className:"h-4 w-4 animate-spin"}),e[2]=i):i=e[2];let o;return e[3]!==a||e[4]!==r||e[5]!==l?(o=(0,d.jsxs)("div",{className:l,style:r,children:[i,a]}),e[3]=a,e[4]=r,e[5]=l,e[6]=o):o=e[6],o},Zx=t=>{let e=(0,Fa.c)(5),{children:a,className:n}=t,r;e[0]===n?r=e[1]:(r=V("flex flex-col gap-2 relative",n),e[0]=n,e[1]=r);let l;return e[2]!==a||e[3]!==r?(l=(0,d.jsx)("div",{className:r,children:a}),e[2]=a,e[3]=r,e[4]=l):l=e[4],l},Yd=t=>{let e=(0,Fa.c)(6),{columnName:a,dataType:n}=t,r=Gy[n],l=`w-4 h-4 p-0.5 rounded-sm stroke-card-foreground ${Z6(n)}`,i;e[0]!==r||e[1]!==l?(i=(0,d.jsx)(r,{className:l}),e[0]=r,e[1]=l,e[2]=i):i=e[2];let o;return e[3]!==a||e[4]!==i?(o=(0,d.jsxs)("div",{className:"flex flex-row items-center gap-1.5",children:[i,a]}),e[3]=a,e[4]=i,e[5]=o):o=e[5],o};function HR(t){return t.getAllLeafColumns().filter(e=>e.id!=="__select__"&&e.id!=="_marimo_row_id"&&!e.id.startsWith("__m_column__"))}let Sy;Sy=({table:t})=>{let e=HR(t),a=e.map(o=>{var s;return{value:o.id,label:o.id,disabled:!o.getCanHide(),data:{dataType:(s=o.columnDef.meta)==null?void 0:s.dataType}}}),n=e.filter(o=>!o.getIsVisible()).map(o=>o.id),r=o=>{let s=new Set(Array.isArray(o)?o:[]);t.setColumnVisibility(u=>({...u,...Object.fromEntries(e.map(c=>[c.id,!s.has(c.id)]))}))},l=Li({options:a,value:n,onChange:r,multiple:!0,filterFn:IE,pinSelected:!0}),i=l.bulkActions.filter(o=>o.kind==="select-matching"||o.kind==="deselect-matching");return(0,d.jsxs)(Kt,{open:l.open,onOpenChange:l.setOpen,children:[(0,d.jsx)(Wt,{asChild:!0,children:(0,d.jsxs)(pe,{variant:"text",size:"xs","data-testid":"column-visibility-trigger",onMouseDown:ht.preventFocus,className:V("print:hidden text-xs gap-1",l.open?"text-primary":"text-muted-foreground"),children:[(0,d.jsx)(Vc,{className:"w-3.5 h-3.5"}),"Columns"]})}),(0,d.jsx)(Ut,{className:"w-64 p-0",align:"end",children:(0,d.jsxs)(Ti,{shouldFilter:!1,children:[(0,d.jsx)(_i,{placeholder:"Search columns...",value:l.searchQuery,onValueChange:l.setSearchQuery}),(0,d.jsxs)(Oi,{children:[(0,d.jsx)(Ii,{children:"No results."}),l.searchQuery===""?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(fa,{value:"__show_all__",disabled:n.length===0,onSelect:()=>r([]),className:"cursor-pointer",children:[(0,d.jsx)(zu,{className:"w-3 h-3 mr-1.5"}),"Show all"]}),(0,d.jsx)(cd,{})]}):i.length>0&&(0,d.jsxs)(d.Fragment,{children:[i.map(o=>(0,d.jsxs)(fa,{value:`__bulk_${o.kind}`,onSelect:o.run,className:"cursor-pointer",children:[o.kind==="select-matching"?(0,d.jsx)(qu,{className:"w-3 h-3 mr-1.5"}):(0,d.jsx)(zu,{className:"w-3 h-3 mr-1.5"}),o.kind==="select-matching"?"Hide":"Show"," ",o.items.length," matching"]},o.kind)),(0,d.jsx)(cd,{})]}),l.visibleOptions.map((o,s)=>{let u=l.isChecked(o.value),{dataType:c}=o.data,p=s===l.pinnedCount&&l.pinnedCount>0&&l.pinnedCount<l.visibleOptions.length;return(0,d.jsxs)(g.Fragment,{children:[p&&(0,d.jsx)(cd,{}),(0,d.jsxs)(fa,{value:o.value,disabled:o.disabled,onSelect:()=>l.toggle(o.value),className:"flex items-center gap-1.5 cursor-pointer",children:[c===void 0?(0,d.jsx)("span",{children:o.label}):(0,d.jsx)(Yd,{columnName:o.label,dataType:c}),!o.disabled&&(0,d.jsx)("span",{className:V("ml-auto",u?"text-primary":"text-muted-foreground"),children:u?(0,d.jsx)(qu,{className:"w-3 h-3"}):(0,d.jsx)(zu,{className:"w-3 h-3"})})]})]},o.value)})]})]})})]})},Hd=tt(null);var WR=q();Od=t=>{let e=(0,WR.c)(13),{packages:a,showMaxPackages:n,className:r,onInstall:l}=t,{handleInstallPackages:i}=jE(),o=Jy();if(!a||a.length===0||!o)return null;let s;e[0]!==i||e[1]!==l||e[2]!==a?(s=()=>{i(a,l)},e[0]=i,e[1]=l,e[2]=a,e[3]=s):s=e[3];let u;e[4]===r?u=e[5]:(u=V("ml-2",r),e[4]=r,e[5]=u);let c;e[6]!==a||e[7]!==n?(c=n?a.slice(0,n).join(", "):a.join(", "),e[6]=a,e[7]=n,e[8]=c):c=e[8];let p;return e[9]!==s||e[10]!==u||e[11]!==c?(p=(0,d.jsxs)(pe,{variant:"outline",size:"xs",onClick:s,className:u,children:["Install"," ",c]}),e[9]=s,e[10]=u,e[11]=c,e[12]=p):p=e[12],p};var UR=q();const KR=t=>{let e=(0,UR.c)(16),{packages:a,featureName:n,description:r,onInstall:l,className:i}=t;if(!Jy()){let m;e[0]===i?m=e[1]:(m=V("text-xs",i),e[0]=i,e[1]=m);let h;return e[2]!==n||e[3]!==m?(h=(0,d.jsxs)("span",{className:m,children:[n," isn't available in this notebook"]}),e[2]=n,e[3]=m,e[4]=h):h=e[4],h}let o;e[5]===i?o=e[6]:(o=V("text-xs flex flex-col items-end gap-2",i),e[5]=i,e[6]=o);let s=r||`${n} requires ${a.join(", ")}`,u;e[7]===s?u=e[8]:(u=(0,d.jsx)("span",{className:"self-start",children:s}),e[7]=s,e[8]=u);let c;e[9]!==l||e[10]!==a?(c=(0,d.jsx)(Od,{packages:a,onInstall:l,className:"ml-0"}),e[9]=l,e[10]=a,e[11]=c):c=e[11];let p;return e[12]!==o||e[13]!==u||e[14]!==c?(p=(0,d.jsxs)("div",{className:o,children:[u,c]}),e[12]=o,e[13]=u,e[14]=c,e[15]=p):p=e[15],p};var GR=q(),da={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:ux},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:G6},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:Oc},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:ux},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:eN}},Cy=[da.CSV,da.TSV,da.JSON,da.PARQUET],Dy=[da.TSV,da.JSON,da.CSV,da.MARKDOWN],qR={csv:"csv",tsv:"tsv",json:"json",markdown:"json"},jy=t=>{var e;return((e=Cy.find(a=>a.format===t))==null?void 0:e.label)??t},ZR=t=>{var e;return((e=Dy.find(a=>a.format===t))==null?void 0:e.label)??t};const JR=t=>{let e=(0,GR.c)(55),[a,n]=g.useState(!1),r=fn(Hd),l=!!(r&&t.sizeBytes!=null&&t.sizeBytes>r.limitBytes),i=!!(r&&(t.sizeBytesIsLoading||l)),o=i?t.sizeBytesIsLoading?"Checking download size\u2026":r==null?void 0:r.unavailableMessage:"Export",s=a?"text-primary":"text-muted-foreground",u;e[0]===s?u=e[1]:(u=V("print:hidden text-xs gap-1",s),e[0]=s,e[1]=u);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=(0,d.jsx)(Dd,{className:"w-3.5 h-3.5"}),e[2]=c):c=e[2];let p;e[3]!==i||e[4]!==u?(p=(0,d.jsxs)(pe,{"data-testid":"export-button",size:"xs",variant:"text",disabled:i,className:u,children:[c,"Export"]}),e[3]=i,e[4]=u,e[5]=p):p=e[5];let m=p,h;e[6]===t?h=e[7]:(h=async(z,$)=>{let F;try{F=await t.downloadAs({format:z})}catch(_){let E=_;return wn({title:"Failed to download",description:typeof E=="object"&&E&&"message"in E?String(E.message):String(E)}),null}return F.missing_packages&&F.missing_packages.length>0?(wn({title:"Export failed",description:(0,d.jsx)(KR,{packages:F.missing_packages,featureName:`${jy(z)} export`,description:F.error,onInstall:$})}),null):{url:F.url,filename:F.filename}},e[6]=t,e[7]=h);let f=h,y,w,x,b,v,C,j,D,N,k,M,S,R;if(e[8]!==m||e[9]!==i||e[10]!==a||e[11]!==f||e[12]!==o){let z=async I=>{let L=jy(I);await rx(`Preparing ${L} export...`,async()=>{let Y=await f(I,()=>{z(I)});if(!Y)return!1;let W=(Y.filename??"").trim(),ae=`${qN.withoutExtension(W)||"download"}.${I}`,te=Y.url;if(!te.startsWith("data:")){let ce=te.includes("?")?"&":"?",B=new URLSearchParams({download:"1",filename:ae});te=`${te}${ce}${B.toString()}`}return ZN(te,ae),!0})&&wn({title:`${L} download started`})},$=async I=>{await rx(`Preparing ${ZR(I)} for clipboard...`,async()=>{let L=qR[I],Y=await f(L,()=>{$(I)});if(!Y)return;let W;e:switch(I){case"tsv":case"csv":W=await Ry(Y.url);break e;case"json":{let ae=await ky(Y.url);W=JSON.stringify(ae,null,2);break e}case"markdown":W=q6(await ky(Y.url));break e;default:Ia(I);return}await Sn(W),wn({title:"Copied to clipboard"})})};w=yi,v=!1,C=a,j=n;let F=a?!1:void 0,_=i?0:-1,E;e[26]!==m||e[27]!==_?(E=(0,d.jsx)("span",{tabIndex:_,className:"inline-flex",children:m}),e[26]=m,e[27]=_,e[28]=E):E=e[28];let O;e[29]!==i||e[30]!==E?(O=(0,d.jsx)(hi,{asChild:!0,disabled:i,children:E}),e[29]=i,e[30]=E,e[31]=O):O=e[31],e[32]!==F||e[33]!==O||e[34]!==o?(D=(0,d.jsx)(Pe,{content:o,open:F,children:O}),e[32]=F,e[33]=O,e[34]=o,e[35]=D):D=e[35],y=gi,N="bottom",k="print:hidden",e[36]===Symbol.for("react.memo_cache_sentinel")?(M=(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Download"}),e[36]=M):M=e[36],S=Cy.map(I=>(0,d.jsxs)(je,{onSelect:()=>{z(I.format)},children:[(0,d.jsx)(I.icon,{className:"mo-dropdown-icon"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{children:I.label}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:I.description})]})]},I.label)),e[37]===Symbol.for("react.memo_cache_sentinel")?(R=(0,d.jsx)(fi,{}),x=(0,d.jsx)(Uu,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),e[37]=x,e[38]=R):(x=e[37],R=e[38]),b=Dy.map(I=>(0,d.jsxs)(je,{onSelect:async()=>{try{await $(I.format)}catch(L){wn({title:"Failed to copy to clipboard",description:dE(L),variant:"danger"})}},children:[(0,d.jsx)(I.icon,{className:"mo-dropdown-icon"}),(0,d.jsxs)("div",{className:"flex flex-col",children:[(0,d.jsx)("span",{children:I.label}),(0,d.jsx)("span",{className:"text-xs text-muted-foreground",children:I.description})]})]},I.label)),e[8]=m,e[9]=i,e[10]=a,e[11]=f,e[12]=o,e[13]=y,e[14]=w,e[15]=x,e[16]=b,e[17]=v,e[18]=C,e[19]=j,e[20]=D,e[21]=N,e[22]=k,e[23]=M,e[24]=S,e[25]=R}else y=e[13],w=e[14],x=e[15],b=e[16],v=e[17],C=e[18],j=e[19],D=e[20],N=e[21],k=e[22],M=e[23],S=e[24],R=e[25];let P;e[39]!==y||e[40]!==x||e[41]!==b||e[42]!==N||e[43]!==k||e[44]!==M||e[45]!==S||e[46]!==R?(P=(0,d.jsxs)(y,{side:N,className:k,children:[M,S,R,x,b]}),e[39]=y,e[40]=x,e[41]=b,e[42]=N,e[43]=k,e[44]=M,e[45]=S,e[46]=R,e[47]=P):P=e[47];let T;return e[48]!==w||e[49]!==v||e[50]!==C||e[51]!==j||e[52]!==D||e[53]!==P?(T=(0,d.jsxs)(w,{modal:v,open:C,onOpenChange:j,children:[D,P]}),e[48]=w,e[49]=v,e[50]=C,e[51]=j,e[52]=D,e[53]=P,e[54]=T):T=e[54],T};function ky(t){return Ry(t).then(gr)}function Ry(t){return fetch(t).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var YR=()=>{};let Ny;Ny=({table:t,showSearch:e,searchQuery:a,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:i,toggleDisplayHeader:o,showTableExplorer:s,togglePanel:u,isAnyPanelOpen:c,downloadAs:p,sizeBytes:m,sizeBytesIsLoading:h})=>{let[f,y]=(0,g.useState)(a||""),w=z5(f,500),x=Je(n??YR),b=g.useRef(null);return(0,g.useEffect)(()=>{x(w)},[w,x]),(0,d.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&e&&(0,d.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,d.jsx)(xx,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,d.jsx)("input",{ref:b,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:f,onKeyDown:v=>{var C;v.key==="Escape"&&(y(""),(C=b.current)==null||C.blur())},onChange:v=>y(v.target.value),placeholder:"Search..."}),r&&(0,d.jsx)(px,{size:"small"}),f&&(0,d.jsx)(pe,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>y(""),children:(0,d.jsx)(yn,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,d.jsxs)("div",{className:"flex items-center shrink-0 ml-auto",children:[(0,d.jsx)(Sy,{table:t}),l&&(0,d.jsxs)(pe,{variant:"text",size:"xs",className:V("print:hidden text-xs gap-1",i?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,d.jsx)(Tc,{className:"w-3.5 h-3.5"}),"Visualize"]}),s&&u&&(0,d.jsxs)(pe,{variant:"text",size:"xs",className:V("print:hidden text-xs gap-1",c?"text-primary":"text-muted-foreground"),onClick:()=>u(Ui.ROW_VIEWER),children:[(0,d.jsx)(Lc,{className:"w-3.5 h-3.5"}),"Explore"]}),p&&(0,d.jsx)(JR,{downloadAs:p,sizeBytes:m,sizeBytesIsLoading:h})]})]})},Zd=(0,g.memo)(({wrapperClassName:t,className:e,maxHeight:a,columns:n,data:r,rawData:l,selection:i,totalColumns:o,totalRows:s,sizeBytes:u,sizeBytesIsLoading:c,manualSorting:p=!1,sorting:m,setSorting:h,rowSelection:f,cellSelection:y,cellStyling:w,hoverTemplate:x,cellHoverTexts:b,paginationState:v,setPaginationState:C,downloadAs:j,manualPagination:D=!1,pagination:N=!1,onRowSelectionChange:k,onCellSelectionChange:M,getRowIds:S,showSearch:R=!1,searchQuery:P,onSearchQueryChange:T,showFilters:z=!1,filters:$,onFiltersChange:F,calculateTopKRows:_,reloading:E,freezeColumnsLeft:O,freezeColumnsRight:I,hiddenColumns:L,toggleDisplayHeader:Y,showChartBuilder:W,isChartBuilderOpen:ae,showPageSizeSelector:te,showTableExplorer:ce,togglePanel:B,isPanelOpen:J,isAnyPanelOpen:Se,viewedRowIdx:de,onViewedRowChange:Ce,renderTableExplorerPanel:Le})=>{let[Q,re]=g.useState(!1),{locale:Oe}=ye(),{columnPinning:ne,setColumnPinning:he}=Rk(O,I),{columnVisibility:Ie,setColumnVisibility:Ge}=ER(L);g.useEffect(()=>{let U;return E?U=setTimeout(()=>{re(!0)},300):re(!1),()=>{U&&clearTimeout(U)}},[E]);function H(U,ve){return v?ve+(D?v.pageIndex*v.pageSize:0):ve}let le=Vd({_features:[f1,lj,N5,Sj,Dj,wj,vj,jj,jk],data:r,columns:n,meta:{rawData:l},getCoreRowModel:Jd(),rowCount:s==="too_many"?void 0:s,...C?{onPaginationChange:C,getRowId:(U,ve)=>{let Aa=Il(U);if(Aa)return Aa;let _6=H(U,ve);return String(_6)}}:{},locale:Oe,manualPagination:D,getPaginationRowModel:D5(),...h?{onSortingChange:h}:{},manualSorting:p,enableMultiSort:!0,getSortedRowModel:qd(),manualFiltering:!0,enableColumnFilters:z,getFilteredRowModel:Ud(),onColumnFiltersChange:F,onRowSelectionChange:k,onCellSelectionChange:M,enableCellSelection:i==="single-cell"||i==="multi-cell",enableMultiCellSelection:i==="multi-cell",onColumnPinningChange:he,onColumnVisibilityChange:Ge,enableFocusRow:!0,onFocusRowChange:Ce,state:{...m?{sorting:m}:{},columnFilters:$,...v?{pagination:v}:N&&!v?{}:{pagination:{pageIndex:0,pageSize:r.length}},rowSelection:f??{},cellSelection:y??[],columnVisibility:Ie,cellStyling:w,columnPinning:ne,cellHoverTemplate:x,cellHoverTexts:b??{}}}),qe=(J==null?void 0:J(Ui.ROW_VIEWER))??!1,De=!N&&r.length>100,ot=Mk({maxHeight:a,virtualize:De}),[Ze,ie]=g.useState(null),me=g.useMemo(()=>({requestAddFilter:U=>{let ve=le.getColumn(U.columnId);ve&&ie(q1(ve,{operator:U.operator}))}}),[le]),ge=by(le),oe=ge.total>0&&ge.visible===0;return(0,d.jsx)(R4,{value:me,children:(0,d.jsxs)("div",{className:V(t,"flex flex-col space-y-1"),children:[(0,d.jsx)(Ck,{filters:$,table:le,calculateTopKRows:_,addFilterSnapshot:Ze,onAddFilterSnapshotChange:ie}),Le==null?void 0:Le(le),(0,d.jsx)(Gk,{children:(0,d.jsxs)("div",{part:"table-wrapper",className:V(e||"rounded-md border overflow-hidden"),children:[(0,d.jsx)(Ny,{table:le,showSearch:R,searchQuery:P,onSearchQueryChange:T,reloading:E,showChartBuilder:W,isChartBuilderOpen:ae,toggleDisplayHeader:Y,showTableExplorer:ce,togglePanel:B,isAnyPanelOpen:Se,downloadAs:j,sizeBytes:u,sizeBytesIsLoading:c}),oe&&(0,d.jsxs)(Tx,{className:"mb-1 mx-2 rounded flex items-center justify-between",children:[(0,d.jsx)("span",{children:"All columns are hidden."}),(0,d.jsx)(pe,{variant:"link",size:"xs",onClick:()=>le.resetColumnVisibility(!0),children:"Unhide all"})]}),(0,d.jsxs)($E,{className:V("relative",n.length<=4?"w-auto":"w-full"),ref:ot,children:[Q&&(0,d.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),RR(le,De||!!a),(0,d.jsx)(NR,{table:le,columns:n,rowViewerPanelOpen:qe,getRowIndex:H,viewedRowIdx:de,virtualize:De})]}),(0,d.jsx)(LR,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:o,pagination:N,selection:i,onRowSelectionChange:k,table:le,getRowIds:S,showPageSizeSelector:te,tableLoading:E})]})})]})})});var dn=q(),QR=25;Kd=function(t){return t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1},Ji={"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 ii(t){return t.url==null?gM(t.base64,t.mime):t.url}let _u,My,Ey,Py,Fy,$y;_u=({contents:t})=>{let e=(0,g.useMemo)(()=>ud(t),[t]),[a,n]=(0,g.useState)({pageIndex:0,pageSize:QR}),r=(0,g.useMemo)(()=>yd(e),[e]),l=(0,g.useMemo)(()=>Pd({rowHeaders:tM.EMPTY,selection:null,fieldTypes:r}),[r]);return(0,d.jsx)(Zd,{data:e,totalRows:e.length,columns:l,totalColumns:l.length,manualPagination:!1,paginationState:a,setPaginationState:n,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex flex-col overflow-hidden",rowSelection:Lu.EMPTY})},My=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("img",{src:a,alt:"Preview"}),e[2]=a,e[3]=n),n},Ey=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("audio",{controls:!0,src:a}),e[2]=a,e[3]=n),n},Py=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("video",{controls:!0,src:a}),e[2]=a,e[3]=n),n},Fy=t=>{let e=(0,dn.c)(4),a;e[0]===t?a=e[1]:(a=ii(t),e[0]=t,e[1]=a);let n;return e[2]===a?n=e[3]:(n=(0,d.jsx)("iframe",{src:a,title:"PDF Viewer",className:"w-full h-full"}),e[2]=a,e[3]=n),n},$y=t=>{let e=(0,dn.c)(11),a,n;if(e[0]===t?(a=e[1],n=e[2]):({mimeType:a,...n}=t,e[0]=t,e[1]=a,e[2]=n),a.startsWith("image/")){let r;return e[3]===n?r=e[4]:(r=(0,d.jsx)(My,{...n}),e[3]=n,e[4]=r),r}if(a.startsWith("audio/")){let r;return e[5]===n?r=e[6]:(r=(0,d.jsx)(Ey,{...n}),e[5]=n,e[6]=r),r}if(a.startsWith("video/")){let r;return e[7]===n?r=e[8]:(r=(0,d.jsx)(Py,{...n}),e[7]=n,e[8]=r),r}if(a.startsWith("application/pdf")){let r;return e[9]===n?r=e[10]:(r=(0,d.jsx)(Fy,{...n}),e[9]=n,e[10]=r),r}return null},ev=t=>{let e=(0,dn.c)(17),{mimeType:a,contents:n,mediaSource:r,readOnly:l,onChange:i,extensions:o}=t,s=l===void 0?!0:l,u;e[0]===o?u=e[1]:(u=o===void 0?[]:o,e[0]=o,e[1]=u);let c=u,{theme:p}=Ni();if(a==="text/csv"&&n!=null){let m;return e[2]===n?m=e[3]:(m=(0,d.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,d.jsx)(_u,{contents:n})}),e[2]=n,e[3]=m),m}if(Kd(a)&&r){let m;return e[4]!==r||e[5]!==a?(m=(0,d.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,d.jsx)($y,{...r,mimeType:a})}),e[4]=r,e[5]=a,e[6]=m):m=e[6],m}if(n!=null){let m=Ji[a]||Ji.default,h=p==="dark"?"dark":"light",f;e[7]===c?f=e[8]:(f=[ix.lineWrapping,...c],e[7]=c,e[8]=f);let y=s?!1:void 0,w=s?void 0:i,x;return e[9]!==n||e[10]!==m||e[11]!==s||e[12]!==h||e[13]!==f||e[14]!==y||e[15]!==w?(x=(0,d.jsx)("div",{className:"flex-1 overflow-auto",children:(0,d.jsx)(g.Suspense,{children:(0,d.jsx)(oM,{theme:h,language:m,className:"border-b",extensions:f,value:n,readOnly:s,editable:y,onChange:w})})}),e[9]=n,e[10]=m,e[11]=s,e[12]=h,e[13]=f,e[14]=y,e[15]=w,e[16]=x):x=e[16],x}return null};function XR(t,e){let{state:a}=t,n=a.doc;if(e<=0||e>n.lines)return Ht.warn(`Invalid line number: ${e}. Document has ${n.lines} lines.`),!1;let r=n.line(e);if(r.text.includes("breakpoint()"))return!0;let l=r.text.match(/^(\s*)/),i=`${l?l[1]:""}breakpoint()
50
50
  `,o=r.from;return t.dispatch({changes:{from:o,to:o,insert:i},selection:{anchor:o+i.length-1,head:o+i.length-1},scrollIntoView:!0,effects:[ix.scrollIntoView(o,{y:"center"})]}),t.focus(),!0}var Ay=q();const e6=t=>{var F;let e=(0,Ay.c)(45),{onRefactorWithAI:a,traceback:n,cellId:r}=t,l;e[0]===n?l=e[1]:(l=od({html:n,additionalReplacements:[a6,r6,n6]}),e[0]=n,e[1]=l);let i=l,o;e[2]===n?o=e[3]:(o=t6(n),e[2]=n,e[3]=o);let s=o,u=fn(nN),c;e[4]===n?c=e[5]:(c=(F=tN(n))==null?void 0:F.at(0),e[4]=n,e[5]=c);let p=c,m;e[6]!==r||e[7]!==p?(m=p&&p.kind==="cell"&&!Xy()&&!Hu()&&r!=="__scratch__",e[6]=r,e[7]=p,e[8]=m):m=e[8];let h=m,f;e[9]!==u||e[10]!==a?(f=a&&u&&!Hu(),e[9]=u,e[10]=a,e[11]=f):f=e[11];let y=f,w=!Hu(),[x,b]=(0,g.useState)(!0),v;e[12]!==s||e[13]!==a?(v=_=>{a==null||a({prompt:`My code gives the following error:
51
51
 
52
52
  ${s}`,triggerImmediately:_})},e[12]=s,e[13]=a,e[14]=v):v=e[14];let C=v,j;e[15]===x?j=e[16]:(j=()=>b(!x),e[15]=x,e[16]=j);let D=x?"Collapse traceback":"Expand traceback",N;e[17]===x?N=e[18]:(N=x?(0,d.jsx)(gn,{className:"h-3 w-3"}):(0,d.jsx)(xi,{className:"h-3 w-3"}),e[17]=x,e[18]=N);let k;e[19]===Symbol.for("react.memo_cache_sentinel")?(k=(0,d.jsx)("span",{className:"text-[0.6875rem] uppercase tracking-wider",children:"Traceback"}),e[19]=k):k=e[19];let M;e[20]!==x||e[21]!==j||e[22]!==D||e[23]!==N?(M=(0,d.jsxs)("button",{type:"button",onClick:j,"aria-expanded":x,"aria-label":D,className:"self-start flex items-center gap-1 pt-2 text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[N,k]}),e[20]=x,e[21]=j,e[22]=D,e[23]=N,e[24]=M):M=e[24];let S;e[25]!==i||e[26]!==x?(S=x&&(0,d.jsx)("div",{className:"text-muted-foreground pr-4 text-xs overflow-auto",children:i}),e[25]=i,e[26]=x,e[27]=S):S=e[27];let R;e[28]!==C||e[29]!==y?(R=y&&(0,d.jsx)(AM,{tooltip:"Fix with AI",openPrompt:()=>C(!1),applyAutofix:()=>C(!0)}),e[28]=C,e[29]=y,e[30]=R):R=e[30];let P;e[31]!==h||e[32]!==p?(P=h&&(0,d.jsx)(Pe,{content:"Attach pdb to the exception point.",children:(0,d.jsxs)(pe,{size:"xs",variant:"outline",onClick:()=>{ox().sendPdb({cellId:p.cellId})},children:[(0,d.jsx)(no,{className:"h-3 w-3 mr-2"}),"Launch debugger"]})}),e[31]=h,e[32]=p,e[33]=P):P=e[33];let T;e[34]!==s||e[35]!==n?(T=w&&(0,d.jsxs)(yi,{children:[(0,d.jsx)(hi,{asChild:!0,children:(0,d.jsxs)(pe,{size:"xs",variant:"text",children:["Get help",(0,d.jsx)(gn,{className:"h-3 w-3 ml-1"})]})}),(0,d.jsxs)(gi,{align:"end",className:"w-56",children:[(0,d.jsx)(je,{asChild:!0,children:(0,d.jsxs)("a",{target:"_blank",href:`https://www.google.com/search?q=${encodeURIComponent(s)}`,rel:"noreferrer",children:[(0,d.jsx)(xx,{className:"h-4 w-4 mr-2"}),"Search on Google",(0,d.jsx)(cx,{className:"h-3 w-3 ml-auto"})]})}),(0,d.jsx)(je,{asChild:!0,children:(0,d.jsxs)("a",{target:"_blank",href:"https://marimo.io/discord?ref=notebook",rel:"noopener",children:[(0,d.jsx)(wM,{className:"h-4 w-4 mr-2"}),"Ask in Discord",(0,d.jsx)(cx,{className:"h-3 w-3 ml-auto"})]})}),(0,d.jsxs)(je,{onClick:()=>{let _=document.createElement("div");_.innerHTML=Yy(n),Sn(_.textContent||"")},children:[(0,d.jsx)(bi,{className:"h-4 w-4 mr-2"}),"Copy to clipboard"]})]})]}),e[34]=s,e[35]=n,e[36]=T):T=e[36];let z;e[37]!==R||e[38]!==P||e[39]!==T?(z=(0,d.jsxs)("div",{className:"flex gap-2",children:[R,P,T]}),e[37]=R,e[38]=P,e[39]=T,e[40]=z):z=e[40];let $;return e[41]!==M||e[42]!==S||e[43]!==z?($=(0,d.jsxs)("div",{className:"flex flex-col gap-2 min-w-full w-fit",children:[M,S,z]}),e[41]=M,e[42]=S,e[43]=z,e[44]=$):$=e[44],$};function t6(t){var a,n;let e=document.createElement("div");return e.innerHTML=Yy(t),((n=(a=e.textContent)==null?void 0:a.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 ne}from"./chunk-LvLJmgfZ.js";import{u as Ze}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{D as Je,Qn as y,jt as ce}from"./cells-B7nz4LNo.js";import{D as M,P as _,R as u,T as D,_ as ae,i as Ye,k as w,m as Xe}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as et}from"./useEventListener-BfYriKqt.js";import{c as tt}from"./utils-BGFUZat2.js";import{t as G}from"./cn-X2M2usMq.js";import{t as st}from"./jsx-runtime-PbYoItBR.js";import{a as rt,c as ie,o as le,s as ot}from"./popover-D1IutFqN.js";import{c as nt,i as ct,n as at,r as it,s as lt,t as dt}from"./select-sS-2VQvj.js";import{a as J,c as de,o as pt,p as ht,r as mt,t as ut}from"./dropdown-menu-BYGDVBcE.js";import{t as Y}from"./button-Db07tdz7.js";import{l as bt}from"./arrays-DWxvyYxP.js";import{r as U}from"./strings-B-yaq2o7.js";import{t as ft}from"./createLucideIcon-BTp1tQDO.js";import{t as gt}from"./circle-plus-BIy1BGHw.js";import{t as yt}from"./database-zap-DpKMaYZb.js";import{t as _t}from"./github-CqonmEC7.js";import{c,o as wt,t as St,u as xt}from"./form-BDERMNxH.js";import{n as kt}from"./DeferredRequestRegistry-EP9ZArpv.js";import{o as vt,r as $t}from"./input-BpT1_NFw.js";import{a as jt,c as Ct,d as At,g as Tt,l as Rt,o as Lt,p as Dt,s as It,u as Pt}from"./textarea-BWLmfOrN.js";import{r as qt}from"./useTheme-BcDiZbxe.js";import{a as Nt,c as Ft,l as Et,n as Bt,r as Ot,t as Mt}from"./dialog-CNmqslzW.js";import{n as Ut}from"./ImperativeModal-Da0ki2vE.js";import{t as V}from"./links-DK7te6sJ.js";import{t as Kt}from"./useIframeCapabilities-CJXRJK5V.js";import{r as Ht}from"./html-to-image-C4EfBRTz.js";import{o as Wt}from"./focus-BZmaIt_1.js";import{n as zt}from"./useAsyncData-CT1LpOBD.js";import{n as Gt,t as Vt}from"./azure-B42ls0Ui.js";import{t as Zt}from"./request-registry-unC7eRnq.js";import{n as Qt,t as Jt}from"./write-secret-modal-BEsGwBC8.js";var X=ft("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 Or(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 Yt=B(),N=ne(Qe(),1),n=ne(st(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:et.NOOP});const Xt=()=>(0,N.use)(he),es=t=>{let e=(0,Yt.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:r,isPending:d,error:i,refetch:a}=zt(ns,o),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 p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==i||e[6]!==d||e[7]!==a||e[8]!==l||e[9]!==p?(h={secretKeys:l,providerNames:p,loading:d,error:i,refreshSecrets:a},e[5]=i,e[6]=d,e[7]=a,e[8]=l,e[9]=p,e[10]=h):h=e[10];let f;return e[11]!==s||e[12]!==h?(f=(0,n.jsx)(he,{value:h,children:s}),e[11]=s,e[12]=h,e[13]=f):f=e[13],f},ts={isMatch:t=>{if(t instanceof ae||t instanceof Xe){let{optionRegex:e}=c.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:r,refreshSecrets:d}=Xt(),{openModal:i,closeModal:a}=Ut(),{label:l,description:p,optionRegex:h=""}=c.parse(t.description||""),[f,b]=bt(o,m=>new RegExp(h,"i").test(m));return(0,n.jsx)(Ct,{control:e.control,name:s,render:({field:m})=>(0,n.jsxs)(Rt,{children:[(0,n.jsx)(Pt,{children:l}),(0,n.jsx)(Lt,{children:p}),(0,n.jsx)(jt,{children:(0,n.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,n.jsx)($t,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,n.jsx)(vt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,n.jsxs)(ut,{children:[(0,n.jsx)(ht,{asChild:!0,children:(0,n.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,n.jsx)(kt,{className:"h-3 w-3"})})}),(0,n.jsxs)(mt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,n.jsxs)(J,{onSelect:()=>{i((0,n.jsx)(Jt,{providerNames:r,onSuccess:g=>{d(),m.onChange(te(g)),a()},onClose:a}))},children:[(0,n.jsx)(gt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(de,{}),(0,n.jsx)(pt,{children:"Recommended"})]}),f.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g)),b.length>0&&(0,n.jsx)(de,{}),b.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g))]})]})]})}),(0,n.jsx)(At,{})]})})}};function ss(t){return t.provider!=="env"}function rs(t){return t.name}function os(t){return t.keys}async function ns(){let t=await Zt.request({}),e=Qt(t.secrets).filter(ss).map(rs);return{secretKeys:t.secrets.flatMap(os).toSorted(),providerNames:e}}var H=B(),cs=[ts];const se=t=>{let e=(0,H.c)(2),{children:s}=t,o;return e[0]===s?o=e[1]:(o=(0,n.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=o),o},re=t=>{let e=(0,H.c)(9),{name:s,color:o,icon:r,onSelect:d}=t,i;e[0]===o?i=e[1]:(i={backgroundColor:o},e[0]=o,e[1]=i);let a;e[2]===s?a=e[3]:(a=(0,n.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==a?(l=(0,n.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,a]}),e[4]=r,e[5]=d,e[6]=i,e[7]=a,e[8]=l):l=e[8],l},as=t=>{let e=(0,H.c)(25),{onBack:s,isValid:o,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:a,libraryLabel:l}=t,p=l===void 0?"Preferred library":l,h;e[0]===s?h=e[1]:(h=(0,n.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let f=!o,b;e[2]===f?b=e[3]:(b=(0,n.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==h||e[5]!==b?(m=(0,n.jsxs)("div",{className:"flex gap-2",children:[h,b]}),e[4]=h,e[5]=b,e[6]=m):m=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)(lt,{children:(0,n.jsx)(nt,{placeholder:"Select a library"})}),e[7]=g):g=e[7];let S;e[8]===p?S=e[9]:(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[g,(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let $;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=R=>(0,n.jsx)(ct,{value:R,children:a[R]??R},R),e[13]=a,e[14]=j),$=r.map(j),e[10]=a,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,n.jsx)(at,{children:(0,n.jsx)(it,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==S||e[20]!==x?(v=(0,n.jsx)("div",{children:(0,n.jsxs)(dt,{value:d,onValueChange:i,children:[S,x]})}),e[17]=i,e[18]=d,e[19]=S,e[20]=x,e[21]=v):v=e[21];let C;return e[22]!==v||e[23]!==m?(C=(0,n.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=C):C=e[24],C};function is(){let t=(0,H.c)(4),{createNewCell:e}=Je(),s=Wt(),o=Ze(tt),r;return t[0]!==o||t[1]!==e||t[2]!==s?(r=d=>{/\bmo\./.test(d)&&Ht({autoInstantiate:o,createNewCell:e,fromCellId:s}),e({code:d,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:o,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:a,onSubmit:l,onBack:p}=t,h;e[0]===s?h=e[1]:(h=wt(s),e[0]=s,e[1]=h);let f=h,b;e[2]===s?b=e[3]:(b=Dt(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 g=Tt(m),[S,$]=N.useState(r),x=is(),v;e[7]!==a||e[8]!==x||e[9]!==l||e[10]!==S?(v=ze=>{x(a(ze,S)),l()},e[7]=a,e[8]=x,e[9]=l,e[10]=S,e[11]=v):v=e[11];let C=v,j;e[12]!==g||e[13]!==C?(j=g.handleSubmit(C),e[12]=g,e[13]=C,e[14]=j):j=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=(0,n.jsx)(It,{}),e[15]=R):R=e[15];let F;e[16]!==g||e[17]!==s?(F=(0,n.jsx)(es,{children:(0,n.jsx)(St,{schema:s,form:g,renderers:cs,children:R})}),e[16]=g,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==g.formState.isValid||e[21]!==o||e[22]!==i||e[23]!==p||e[24]!==S?(E=(0,n.jsx)(as,{onBack:p,isValid:g.formState.isValid,libraries:o,preferredLibrary:S,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=g.formState.isValid,e[21]=o,e[22]=i,e[23]=p,e[24]=S,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,n.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(c.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(c.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(c.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function oe(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(c.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(c.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function A(){return u().describe(c.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function ls(){return u().describe(c.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function T(){return u().nonempty().describe(c.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Ye().describe(c.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(c.of({label:"Read Only"}))}const be=_({type:w("postgres"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),fe=_({type:w("mysql"),host:L(),port:P(3306),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),ge=_({type:w("sqlite"),database:A().describe(c.of({label:"Database Path"}))}).describe(c.of({direction:"two-columns"})),ye=_({type:w("duckdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),_e=_({type:w("motherduck"),database:A().default("my_db").describe(c.of({label:"Database Name"})),token:Z()}).describe(c.of({direction:"two-columns"})),we=_({type:w("snowflake"),account:u().nonempty().describe(c.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(c.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:A(),schema:u().optional().describe(c.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(c.of({label:"Role"})),authType:M("type",[_({type:w("Password"),username:T(),password:I(),enable_mfa:D().default(!1).describe(c.of({label:"Enable MFA (Duo Push)"}))}),_({type:w("SSO (Browser)"),username:T()}),_({type:w("Key Pair"),username:T(),private_key_path:u().nonempty().describe(c.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(c.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),_({type:w("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(c.of({special:"tabs"}))}).describe(c.of({direction:"two-columns"})),Se=_({type:w("bigquery"),project:u().nonempty().describe(c.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(c.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(c.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(c.of({direction:"two-columns"})),xe=_({type:w("clickhouse_connect"),host:L(),port:P(8123).optional(),username:T(),password:I(),secure:D().default(!1).describe(c.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(c.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(c.of({direction:"two-columns"})),ke=_({type:w("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:T().default("default"),password:I().default("")}).describe(c.of({direction:"two-columns"})),ve=_({type:w("chdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),$e=_({type:w("trino"),host:L(),port:P(8080),database:A(),schema:ls().optional(),username:T(),password:I(),async_support:D().default(!1).describe(c.of({label:"Async Support"}))}).describe(c.of({direction:"two-columns"})),je=_({type:w("iceberg"),name:u().describe(c.of({label:"Catalog Name"})),catalog:M("type",[_({type:w("REST"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),_({type:w("SQL"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),_({type:w("Hive"),warehouse:Q(),uri:oe()}),_({type:w("Glue"),warehouse:Q(),uri:oe()}),_({type:w("DynamoDB"),"dynamodb.profile-name":u().optional().describe(c.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(c.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(c.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(c.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(c.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(c.of({special:"tabs"}))}),Ce=_({type:w("datafusion"),sessionContext:D().optional().describe(c.of({label:"Use Session Context"}))}),Ae=_({type:w("pyspark"),host:L().optional(),port:P().optional()}),Te=_({type:w("redshift"),host:L(),port:P(5439),connectionType:M("type",[_({type:w("IAM credentials"),region:u().describe(c.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(c.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(c.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(c.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),_({type:w("DB credentials"),user:T(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:A()}).describe(c.of({direction:"two-columns"})),Re=_({type:w("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:oe("HTTP Path",!0),catalog:u().optional().describe(c.of({label:"Catalog"})),schema:u().optional().describe(c.of({label:"Schema"}))}).describe(c.of({direction:"two-columns"})),Le=_({type:w("supabase"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),disable_client_pooling:D().default(!1).describe(c.of({label:"Disable Client-Side Pooling"}))}).describe(c.of({direction:"two-columns"})),ds=M("type",[be,fe,ge,ye,_e,we,Se,xe,ke,ve,$e,je,Ce,Ae,Te,Re,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}},ps=t=>`_${t}`,hs=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=ps(t),K(e)){let o=pe(e),r=s?`os.environ.get("${o}", "${s}")`:`os.environ.get("${o}")`;return this.secrets[t]=r,t}if(s!=null){let o=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=o,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 o=this.print(t,e,s);return o.startsWith('"')&&o.endsWith('"')?o.slice(1,-1):`{${o}}`}printPassword(t,e,s,o){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(o||"password",t):r(o||"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 ne}from"./chunk-LvLJmgfZ.js";import{u as Ze}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{D as Je,Qn as y,jt as ce}from"./cells-B7nz4LNo.js";import{D as M,P as _,R as u,T as D,_ as ae,i as Ye,k as w,m as Xe}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as et}from"./useEventListener-BfYriKqt.js";import{c as tt}from"./utils-BGFUZat2.js";import{t as G}from"./cn-X2M2usMq.js";import{t as st}from"./jsx-runtime-PbYoItBR.js";import{a as rt,c as ie,o as le,s as ot}from"./popover-D1IutFqN.js";import{c as nt,i as ct,n as at,r as it,s as lt,t as dt}from"./select-sS-2VQvj.js";import{a as J,c as de,o as pt,p as ht,r as mt,t as ut}from"./dropdown-menu-BYGDVBcE.js";import{t as Y}from"./button-Db07tdz7.js";import{l as bt}from"./arrays-DWxvyYxP.js";import{r as U}from"./strings-B-yaq2o7.js";import{t as ft}from"./createLucideIcon-BTp1tQDO.js";import{t as gt}from"./circle-plus-BIy1BGHw.js";import{t as yt}from"./database-zap-DpKMaYZb.js";import{t as _t}from"./github-CqonmEC7.js";import{c,o as wt,t as St,u as xt}from"./form-F1rvnx2z.js";import{n as kt}from"./DeferredRequestRegistry-EP9ZArpv.js";import{o as vt,r as $t}from"./input-BpT1_NFw.js";import{a as jt,c as Ct,d as At,g as Tt,l as Rt,o as Lt,p as Dt,s as It,u as Pt}from"./textarea-BWLmfOrN.js";import{r as qt}from"./useTheme-BcDiZbxe.js";import{a as Nt,c as Ft,l as Et,n as Bt,r as Ot,t as Mt}from"./dialog-CNmqslzW.js";import{n as Ut}from"./ImperativeModal-Da0ki2vE.js";import{t as V}from"./links-DK7te6sJ.js";import{t as Kt}from"./useIframeCapabilities-CJXRJK5V.js";import{r as Ht}from"./html-to-image-C4EfBRTz.js";import{o as Wt}from"./focus-BZmaIt_1.js";import{n as zt}from"./useAsyncData-CT1LpOBD.js";import{n as Gt,t as Vt}from"./azure-B42ls0Ui.js";import{t as Zt}from"./request-registry-unC7eRnq.js";import{n as Qt,t as Jt}from"./write-secret-modal-BEsGwBC8.js";var X=ft("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 Or(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 Yt=B(),N=ne(Qe(),1),n=ne(st(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:et.NOOP});const Xt=()=>(0,N.use)(he),es=t=>{let e=(0,Yt.c)(14),{children:s}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let{data:r,isPending:d,error:i,refetch:a}=zt(ns,o),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 p;e[3]===(r==null?void 0:r.providerNames)?p=e[4]:(p=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=p);let h;e[5]!==i||e[6]!==d||e[7]!==a||e[8]!==l||e[9]!==p?(h={secretKeys:l,providerNames:p,loading:d,error:i,refreshSecrets:a},e[5]=i,e[6]=d,e[7]=a,e[8]=l,e[9]=p,e[10]=h):h=e[10];let f;return e[11]!==s||e[12]!==h?(f=(0,n.jsx)(he,{value:h,children:s}),e[11]=s,e[12]=h,e[13]=f):f=e[13],f},ts={isMatch:t=>{if(t instanceof ae||t instanceof Xe){let{optionRegex:e}=c.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:o,providerNames:r,refreshSecrets:d}=Xt(),{openModal:i,closeModal:a}=Ut(),{label:l,description:p,optionRegex:h=""}=c.parse(t.description||""),[f,b]=bt(o,m=>new RegExp(h,"i").test(m));return(0,n.jsx)(Ct,{control:e.control,name:s,render:({field:m})=>(0,n.jsxs)(Rt,{children:[(0,n.jsx)(Pt,{children:l}),(0,n.jsx)(Lt,{children:p}),(0,n.jsx)(jt,{children:(0,n.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,n.jsx)($t,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,n.jsx)(vt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,n.jsxs)(ut,{children:[(0,n.jsx)(ht,{asChild:!0,children:(0,n.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,n.jsx)(kt,{className:"h-3 w-3"})})}),(0,n.jsxs)(mt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,n.jsxs)(J,{onSelect:()=>{i((0,n.jsx)(Jt,{providerNames:r,onSuccess:g=>{d(),m.onChange(te(g)),a()},onClose:a}))},children:[(0,n.jsx)(gt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(de,{}),(0,n.jsx)(pt,{children:"Recommended"})]}),f.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g)),b.length>0&&(0,n.jsx)(de,{}),b.map(g=>(0,n.jsx)(J,{onSelect:()=>m.onChange(te(g)),children:g},g))]})]})]})}),(0,n.jsx)(At,{})]})})}};function ss(t){return t.provider!=="env"}function rs(t){return t.name}function os(t){return t.keys}async function ns(){let t=await Zt.request({}),e=Qt(t.secrets).filter(ss).map(rs);return{secretKeys:t.secrets.flatMap(os).toSorted(),providerNames:e}}var H=B(),cs=[ts];const se=t=>{let e=(0,H.c)(2),{children:s}=t,o;return e[0]===s?o=e[1]:(o=(0,n.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=o),o},re=t=>{let e=(0,H.c)(9),{name:s,color:o,icon:r,onSelect:d}=t,i;e[0]===o?i=e[1]:(i={backgroundColor:o},e[0]=o,e[1]=i);let a;e[2]===s?a=e[3]:(a=(0,n.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=a);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==a?(l=(0,n.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,a]}),e[4]=r,e[5]=d,e[6]=i,e[7]=a,e[8]=l):l=e[8],l},as=t=>{let e=(0,H.c)(25),{onBack:s,isValid:o,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:a,libraryLabel:l}=t,p=l===void 0?"Preferred library":l,h;e[0]===s?h=e[1]:(h=(0,n.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=h);let f=!o,b;e[2]===f?b=e[3]:(b=(0,n.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==h||e[5]!==b?(m=(0,n.jsxs)("div",{className:"flex gap-2",children:[h,b]}),e[4]=h,e[5]=b,e[6]=m):m=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=(0,n.jsx)(lt,{children:(0,n.jsx)(nt,{placeholder:"Select a library"})}),e[7]=g):g=e[7];let S;e[8]===p?S=e[9]:(S=(0,n.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[g,(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:p})]}),e[8]=p,e[9]=S);let $;if(e[10]!==a||e[11]!==r){let j;e[13]===a?j=e[14]:(j=R=>(0,n.jsx)(ct,{value:R,children:a[R]??R},R),e[13]=a,e[14]=j),$=r.map(j),e[10]=a,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,n.jsx)(at,{children:(0,n.jsx)(it,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==S||e[20]!==x?(v=(0,n.jsx)("div",{children:(0,n.jsxs)(dt,{value:d,onValueChange:i,children:[S,x]})}),e[17]=i,e[18]=d,e[19]=S,e[20]=x,e[21]=v):v=e[21];let C;return e[22]!==v||e[23]!==m?(C=(0,n.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=C):C=e[24],C};function is(){let t=(0,H.c)(4),{createNewCell:e}=Je(),s=Wt(),o=Ze(tt),r;return t[0]!==o||t[1]!==e||t[2]!==s?(r=d=>{/\bmo\./.test(d)&&Ht({autoInstantiate:o,createNewCell:e,fromCellId:s}),e({code:d,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=e,t[2]=s,t[3]=r):r=t[3],r}const me=t=>{let e=(0,H.c)(30),{schema:s,libraries:o,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:a,onSubmit:l,onBack:p}=t,h;e[0]===s?h=e[1]:(h=wt(s),e[0]=s,e[1]=h);let f=h,b;e[2]===s?b=e[3]:(b=Dt(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 g=Tt(m),[S,$]=N.useState(r),x=is(),v;e[7]!==a||e[8]!==x||e[9]!==l||e[10]!==S?(v=ze=>{x(a(ze,S)),l()},e[7]=a,e[8]=x,e[9]=l,e[10]=S,e[11]=v):v=e[11];let C=v,j;e[12]!==g||e[13]!==C?(j=g.handleSubmit(C),e[12]=g,e[13]=C,e[14]=j):j=e[14];let R;e[15]===Symbol.for("react.memo_cache_sentinel")?(R=(0,n.jsx)(It,{}),e[15]=R):R=e[15];let F;e[16]!==g||e[17]!==s?(F=(0,n.jsx)(es,{children:(0,n.jsx)(St,{schema:s,form:g,renderers:cs,children:R})}),e[16]=g,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==g.formState.isValid||e[21]!==o||e[22]!==i||e[23]!==p||e[24]!==S?(E=(0,n.jsx)(as,{onBack:p,isValid:g.formState.isValid,libraries:o,preferredLibrary:S,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=g.formState.isValid,e[21]=o,e[22]=i,e[23]=p,e[24]=S,e[25]=E):E=e[25];let W;return e[26]!==j||e[27]!==F||e[28]!==E?(W=(0,n.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(c.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(c.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(c.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function oe(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(c.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(c.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function A(){return u().describe(c.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function ls(){return u().describe(c.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function T(){return u().nonempty().describe(c.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Ye().describe(c.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(c.of({label:"Read Only"}))}const be=_({type:w("postgres"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),fe=_({type:w("mysql"),host:L(),port:P(3306),database:A(),username:T(),password:I(),ssl:D().default(!1).describe(c.of({label:"Use SSL"}))}).describe(c.of({direction:"two-columns"})),ge=_({type:w("sqlite"),database:A().describe(c.of({label:"Database Path"}))}).describe(c.of({direction:"two-columns"})),ye=_({type:w("duckdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),_e=_({type:w("motherduck"),database:A().default("my_db").describe(c.of({label:"Database Name"})),token:Z()}).describe(c.of({direction:"two-columns"})),we=_({type:w("snowflake"),account:u().nonempty().describe(c.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(c.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:A(),schema:u().optional().describe(c.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(c.of({label:"Role"})),authType:M("type",[_({type:w("Password"),username:T(),password:I(),enable_mfa:D().default(!1).describe(c.of({label:"Enable MFA (Duo Push)"}))}),_({type:w("SSO (Browser)"),username:T()}),_({type:w("Key Pair"),username:T(),private_key_path:u().nonempty().describe(c.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(c.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),_({type:w("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(c.of({special:"tabs"}))}).describe(c.of({direction:"two-columns"})),Se=_({type:w("bigquery"),project:u().nonempty().describe(c.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(c.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(c.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(c.of({direction:"two-columns"})),xe=_({type:w("clickhouse_connect"),host:L(),port:P(8123).optional(),username:T(),password:I(),secure:D().default(!1).describe(c.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(c.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(c.of({direction:"two-columns"})),ke=_({type:w("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:T().default("default"),password:I().default("")}).describe(c.of({direction:"two-columns"})),ve=_({type:w("chdb"),database:A().describe(c.of({label:"Database Path"})),read_only:ue()}).describe(c.of({direction:"two-columns"})),$e=_({type:w("trino"),host:L(),port:P(8080),database:A(),schema:ls().optional(),username:T(),password:I(),async_support:D().default(!1).describe(c.of({label:"Async Support"}))}).describe(c.of({direction:"two-columns"})),je=_({type:w("iceberg"),name:u().describe(c.of({label:"Catalog Name"})),catalog:M("type",[_({type:w("REST"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),_({type:w("SQL"),warehouse:Q(),uri:u().optional().describe(c.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),_({type:w("Hive"),warehouse:Q(),uri:oe()}),_({type:w("Glue"),warehouse:Q(),uri:oe()}),_({type:w("DynamoDB"),"dynamodb.profile-name":u().optional().describe(c.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(c.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(c.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(c.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(c.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(c.of({special:"tabs"}))}),Ce=_({type:w("datafusion"),sessionContext:D().optional().describe(c.of({label:"Use Session Context"}))}),Ae=_({type:w("pyspark"),host:L().optional(),port:P().optional()}),Te=_({type:w("redshift"),host:L(),port:P(5439),connectionType:M("type",[_({type:w("IAM credentials"),region:u().describe(c.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(c.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(c.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(c.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),_({type:w("DB credentials"),user:T(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:A()}).describe(c.of({direction:"two-columns"})),Re=_({type:w("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:oe("HTTP Path",!0),catalog:u().optional().describe(c.of({label:"Catalog"})),schema:u().optional().describe(c.of({label:"Schema"}))}).describe(c.of({direction:"two-columns"})),Le=_({type:w("supabase"),host:L(),port:P(5432).optional(),database:A(),username:T(),password:I(),disable_client_pooling:D().default(!1).describe(c.of({label:"Disable Client-Side Pooling"}))}).describe(c.of({direction:"two-columns"})),ds=M("type",[be,fe,ge,ye,_e,we,Se,xe,ke,ve,$e,je,Ce,Ae,Te,Re,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}},ps=t=>`_${t}`,hs=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=ps(t),K(e)){let o=pe(e),r=s?`os.environ.get("${o}", "${s}")`:`os.environ.get("${o}")`;return this.secrets[t]=r,t}if(s!=null){let o=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=o,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 o=this.print(t,e,s);return o.startsWith('"')&&o.endsWith('"')?o.slice(1,-1):`{${o}}`}printPassword(t,e,s,o){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(o||"password",t):r(o||"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
  `)}},ms=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 y(`
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})