@marimo-team/frontend 0.24.1-dev121 → 0.24.1-dev124
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.
- package/dist/assets/{JsonOutput-Bgxc9G7d.js → JsonOutput-CzIGPEZQ.js} +1 -1
- package/dist/assets/{agent-panel-B03P2qSx.js → agent-panel-Cgt_K0tD.js} +1 -1
- package/dist/assets/{cell-editor-QmA8u1Ay.js → cell-editor-Dw09J9yD.js} +1 -1
- package/dist/assets/{column-preview-DHe0-7z4.js → column-preview-riSXbYe_.js} +1 -1
- package/dist/assets/{command-palette-D-kPO0tm.js → command-palette-CCVzJcyf.js} +1 -1
- package/dist/assets/{edit-page-CdCPUPqZ.js → edit-page-Vqd9NedM.js} +4 -4
- package/dist/assets/{file-explorer-panel-DMKcHVIX.js → file-explorer-panel-6HvNfCrJ.js} +1 -1
- package/dist/assets/home-page-BLd6rnbk.js +4 -0
- package/dist/assets/{index-ClZGC-u9.js → index-62Kfuyhr.js} +3 -3
- package/dist/assets/{layout-CC2AHMrW.js → layout-DWnrxIo2.js} +3 -3
- package/dist/assets/{panels-BsXw4GTa.js → panels-CWn0Yh1D.js} +1 -1
- package/dist/assets/{reveal-component-BuI7t0JO.js → reveal-component-nZIAapoD.js} +1 -1
- package/dist/assets/{run-page-DZNsqz9H.js → run-page-9pl8qhQR.js} +1 -1
- package/dist/assets/{scratchpad-panel-CARmXIqQ.js → scratchpad-panel-BleGt2KM.js} +1 -1
- package/dist/assets/{session-panel-CB5EvmZs.js → session-panel-DRGPlL5J.js} +1 -1
- package/dist/assets/{skeleton-idYPIMw_.js → skeleton-BKeh8hf3.js} +1 -1
- package/dist/assets/{useNotebookActions-Br4AVVRg.js → useNotebookActions-CQtbk9CB.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/src/components/data-table/renderers.tsx +2 -2
- package/src/components/home/components.tsx +1 -0
- package/src/plugins/impl/MatrixPlugin.tsx +1 -1
- package/dist/assets/home-page-Cir7n_EF.js +0 -4
|
@@ -46,5 +46,5 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
46
46
|
`),o;return r&&(o=`<table>${i.map(e=>`<tr>${e.map(e=>`<td>${e.html??Rj(e.text)}</td>`).join(``)}</tr>`).join(``)}</table>`),{text:a,html:o}}function Rj(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function zj(e){let t=0;for(let n of e)n.includes(`__select__`)||(t+=1);return t}function Bj(e,t){let n=[];for(let r of t){if(r.includes(`__select__`))continue;let{rowId:t,columnId:i}=Uj(r),a=e.getRow(t);if(!a)continue;let o=pE(e,a.index,i)??a.getValue(i),s;if(typeof o==`number`)s=o;else if(typeof o==`string`){if(o.trim()===``)continue;s=Number(o)}else continue;Number.isFinite(s)&&n.push(s)}return n}function Vj(e,t,n){let r=e.getRow(t.rowId),i=e.getRow(n.rowId);if(!r||!i)return[];let a=r.index,o=i.index,s=e.getColumn(t.columnId)?.getIndex(),c=e.getColumn(n.columnId)?.getIndex();if(s===void 0||c===void 0)return[];let l=Math.min(a,o),u=Math.max(a,o),d=Math.min(s,c),f=Math.max(s,c),p=[];p.length=(u-l+1)*(f-d+1);let m=0,h=e.getAllColumns().map(e=>e.id),g=e.getRowModel().rows;for(let e=l;e<=u;e++){let t=g[e].id;for(let e=d;e<=f;e++){let n=h[e];p[m++]=Hj(t,n)}}return p.length=m,p}function Hj(e,t){return`${e}_${t}`}function Uj(e){let t=e.indexOf(`_`);return{rowId:e.slice(0,t),columnId:e.slice(t+1)}}function Wj(){return{selectedCells:new Set,copiedCells:new Set,selectedStartCell:null,focusedCell:null,isSelecting:!1}}var{valueAtom:Gj,useActions:Kj,createActions:qj,reducer:Jj}=Kt(Wj,{setSelectedCells:(e,t)=>({...e,selectedCells:t}),setSelectedStartCell:(e,t)=>({...e,selectedStartCell:t}),setFocusedCell:(e,t)=>({...e,focusedCell:t}),setIsSelecting:(e,t)=>({...e,isSelecting:t}),setCopiedCells:(e,t)=>({...e,copiedCells:t}),clearSelection:e=>({...e,selectedCells:new Set,selectedStartCell:null,focusedCell:null}),selectAllCells:(e,t)=>{let n=t.getRowModel().rows.flatMap(e=>e.getAllCells().map(e=>e.id));return{...e,selectedCells:new Set(n)}},toggleCurrentRowSelection:(e,t)=>{let n=e.focusedCell;return n?.rowId&&t.getRow(n?.rowId)?.toggleSelected?.(),e},updateSelection:(e,{newCell:t,isShiftKey:n,table:r})=>{if(n&&e.selectedStartCell){let n=Vj(r,e.selectedStartCell,t);return{...e,selectedCells:new Set(n),focusedCell:t}}return{...e,selectedCells:new Set([t.cellId]),selectedStartCell:t,focusedCell:t}},updateRangeSelection:(e,{cell:t,table:n})=>{if(!e.selectedStartCell)return e;let r={rowId:t.row.id,columnId:t.column.id,cellId:t.id},i=Vj(n,e.selectedStartCell,r);return i.length>1&&Qj(),{...e,selectedCells:new Set(i)}},handleCopy:(e,{table:t,onCopyComplete:n})=>{let r=window.getSelection();if(r&&r.toString().length>0)return e;let{text:i,html:a}=Lj(t,e.selectedCells);return Vi(i,a),n(),{...e,copiedCells:e.selectedCells}},navigate:(e,{direction:t,isShiftKey:n,table:r})=>{let i=e.focusedCell??e.selectedStartCell;if(!i)return e;let a;if(t===`up`||t===`down`){let n=r.getRowModel().rows,o=n.findIndex(e=>e.id===i.rowId);if(o<0)return e;let s=t===`up`?n[o-1]:n[o+1];if(!s)return e;a=s.getAllCells().find(e=>e.column.id===i.columnId)}if(t===`left`||t===`right`){let n=r.getRow(i.rowId).getAllCells(),o=n.findIndex(e=>e.id===i.cellId);if(o<0)return e;a=t===`left`?n[o-1]:n[o+1]}if(!a)return e;let o={rowId:a.row.id,columnId:a.column.id,cellId:a.id};if(n&&e.selectedStartCell){let t=Vj(r,e.selectedStartCell,o);return{...e,selectedCells:new Set(t),focusedCell:o}}return{...e,selectedCells:new Set([o.cellId]),selectedStartCell:o,focusedCell:o}},handleCellMouseDown:(e,{cell:t,isShiftKey:n,isCtrlKey:r,table:i})=>{let a={rowId:t.row.id,columnId:t.column.id,cellId:t.id};if(n&&e.selectedStartCell){let t=Vj(i,e.selectedStartCell,a);return{...e,selectedCells:new Set(t),isSelecting:!0}}return r?e:e.selectedCells.size===1&&e.selectedCells.has(a.cellId)?{...e,selectedCells:new Set,selectedStartCell:null,focusedCell:null}:{...e,selectedCells:new Set([a.cellId]),selectedStartCell:a,focusedCell:a,isSelecting:!0}}}),Yj=i(e=>e(Gj).selectedCells),Xj=i(e=>e(Gj).copiedCells);i(e=>e(Gj).selectedStartCell),i(e=>e(Gj).focusedCell),i(e=>e(Gj).isSelecting);var Zj=e=>i(t=>{let n=t(Yj),r=t(Xj);return{isSelected:n.has(e),isCopied:r.has(e)}}),Qj=()=>{window.getSelection&&window.getSelection()?.empty()},$j=e=>{let t=(0,U.c)(3),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[Gj],t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,H.jsx)(Ij,{atoms:r,children:n}),t[1]=n,t[2]=i),i};function eM(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
|
|
47
47
|
font-size: .6rem;
|
|
48
48
|
font-weight: bold;
|
|
49
|
-
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function tM(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nM=(e,t)=>Math.abs(e-t)<1.01,rM=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iM=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},aM=e=>e,oM=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},sM=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(iM(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(iM(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},cM={passive:!0},lM=typeof window>`u`||`onscrollend`in window,uM=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&lM?()=>void 0:rM(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,cM);let l=e.options.useScrollendEvent&&lM;return l&&n.addEventListener(`scrollend`,c,cM),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},dM=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},fM=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},pM=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:aM,rangeExtractor:oM,onChange:()=>{},measureElement:dM,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 t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=eM(()=>(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=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,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,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=eM(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=eM(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);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(e=>{this.itemSizeCache.set(e.key,e.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 c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=eM(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?hM({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eM(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),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(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.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,t)),this.notify(!1))},this.getVirtualItems=eM(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return tM(t[mM(0,t.length-1,e=>tM(t[e]).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,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&nM(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},mM=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function hM({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=mM(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var gM=typeof document<`u`?V.useLayoutEffect:V.useEffect;function _M({useFlushSync:e=!0,...t}){let n=V.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,ho.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=V.useState(()=>new pM(r));return i.setOptions(r),gM(()=>i._didMount(),[]),gM(()=>i._willUpdate()),i}function vM(e){return _M({observeElementRect:sM,observeElementOffset:uM,scrollToFn:fM,...e})}var yM=no,bM=ro,xM=Ie(io),SM=Fe(ao),CM=Fe(mo),wM=V.forwardRef((e,t)=>{let n=(0,U.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==i||n[6]!==a?(s=We({className:i,inset:a}),n[5]=i,n[6]=a,n[7]=s):s=n[7];let c;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,H.jsx)($i,{className:`ml-auto h-4 w-4`}),n[8]=c):c=n[8];let l;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,H.jsxs)(po,{ref:t,className:s,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});wM.displayName=po.displayName;var TM=`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`,EM=V.forwardRef((e,t)=>{let n=(0,U.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=R(Ke({subcontent:!0}),TM,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,H.jsx)(CM,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});EM.displayName=mo.displayName;var DM=V.forwardRef((e,t)=>{let n=(0,U.c)(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,scrollable:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0||a,s;n[4]!==r||n[5]!==o?(s=R(Ke(),TM,o&&`overflow-auto`,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${ze}px)`:void 0,l;n[7]!==i.style||n[8]!==c?(l={...i.style,maxHeight:c},n[7]=i.style,n[8]=c,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==t||n[12]!==s||n[13]!==l?(u=(0,H.jsx)(xM,{children:(0,H.jsx)(Re,{children:(0,H.jsx)(SM,{ref:t,className:s,style:l,...i})})}),n[10]=i,n[11]=t,n[12]=s,n[13]=l,n[14]=u):u=n[14],u});DM.displayName=ao.displayName;var OM=V.forwardRef((e,t)=>{let n=(0,U.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,inset:i,variant:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==r||n[6]!==i||n[7]!==o?(s=Ge({className:r,inset:i,variant:o}),n[5]=r,n[6]=i,n[7]=o,n[8]=s):s=n[8];let c;return n[9]!==a||n[10]!==t||n[11]!==s?(c=(0,H.jsx)(so,{ref:t,className:s,...a}),n[9]=a,n[10]=t,n[11]=s,n[12]=c):c=n[12],c});OM.displayName=so.displayName;var kM=V.forwardRef((e,t)=>{let n=(0,U.c)(15),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=Ve({className:a}),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=Ue(),n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,H.jsx)(`span`,{className:c,children:(0,H.jsx)(uo,{children:(0,H.jsx)(Zi,{className:`h-4 w-4`})})}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==i||n[11]!==o||n[12]!==t||n[13]!==s?(u=(0,H.jsxs)(co,{ref:t,className:s,checked:r,...o,children:[l,i]}),n[9]=r,n[10]=i,n[11]=o,n[12]=t,n[13]=s,n[14]=u):u=n[14],u});kM.displayName=co.displayName;var AM=V.forwardRef((e,t)=>{let n=(0,U.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=Ue({className:i}),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=Ue(),n[6]=s):s=n[6];let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,H.jsx)(`span`,{className:s,children:(0,H.jsx)(uo,{children:(0,H.jsx)(Xi,{className:`h-4 w-4 fill-current`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==o?(l=(0,H.jsxs)(lo,{ref:t,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=t,n[11]=o,n[12]=l):l=n[12],l});AM.displayName=lo.displayName;var jM=V.forwardRef((e,t)=>{let n=(0,U.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==i?(o=qe({className:r,inset:i}),n[4]=r,n[5]=i,n[6]=o):o=n[6];let s;return n[7]!==a||n[8]!==t||n[9]!==o?(s=(0,H.jsx)(oo,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});jM.displayName=oo.displayName;var MM=V.forwardRef((e,t)=>{let n=(0,U.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=R(He({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,H.jsx)(fo,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});MM.displayName=fo.displayName;var NM=e=>{let t=(0,U.c)(12),{contextMenuRef:n,tableBody:r,tableRef:i,copyAllCells:a}=e,o;t[0]!==n||t[1]!==i?(o=e=>{let t=n.current;if(!t)return;let r=i.current?.querySelector(`[${k}="${t.id}"]`);if(!r){be.error(`Context menu cell not found in table`);return}e?r.classList.add(`bg-(--green-4)`):r.classList.remove(`bg-(--green-4)`)},t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=d(o),c;t[3]===r?c=t[4]:(c=(0,H.jsx)(bM,{asChild:!0,children:r}),t[3]=r,t[4]=c);let l;t[5]!==n||t[6]!==a?(l=(0,H.jsx)(xM,{children:(0,H.jsx)(PM,{cellRef:n,copySelectedCells:a})}),t[5]=n,t[6]=a,t[7]=l):l=t[7];let u;return t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,H.jsxs)(yM,{onOpenChange:s,children:[c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u},PM=({cellRef:e,copySelectedCells:t})=>{let n=s(Yj).size>1,r=e.current;if(!r){be.error(`No cell found in context menu`);return}let i=r.getContext().table,a=r.getValue(),o=pE(i,r.row.index,r.column.id)??a,c=()=>{try{let{text:e,html:t}=fE(o,a);Vi(e,t)}catch(e){be.error(`Failed to copy context menu cell`,e)}},l=r.column,u=l.columnDef.meta?.filterType,d=l.getCanFilter()&&u&&IT(u)?u:void 0,f=(e,t)=>{let n=e===`number`?mT.number({operator:t,values:[o]}):mT.text({operator:t,values:[o]});l.setFilterValue(n)};return(0,H.jsxs)(DM,{children:[(0,H.jsxs)(OM,{onClick:c,children:[(0,H.jsx)(bn,{className:`mo-dropdown-icon h-3 w-3`}),`Copy cell`]}),n&&(0,H.jsxs)(OM,{onClick:t,children:[(0,H.jsx)(Ro,{className:`mo-dropdown-icon h-3 w-3`}),`Copy selected cells`]}),d&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(MM,{}),(0,H.jsxs)(OM,{onClick:()=>f(d,`in`),children:[(0,H.jsx)(jo,{className:`mo-dropdown-icon h-3 w-3`}),`Filter by this value`]}),(0,H.jsxs)(OM,{onClick:()=>f(d,`not_in`),children:[(0,H.jsx)(jo,{className:`mo-dropdown-icon h-3 w-3`}),`Remove rows with this value`]})]})]})},FM=e=>{let t=(0,U.c)(15),{state:n,contentId:r,onClose:i}=e,a=n!=null,o;t[0]===i?o=t[1]:(o=e=>{e||i()},t[0]=i,t[1]=o);let s=n?.rect.top??0,c=n?.rect.left??0,l=n?.rect.width??0,u=n?.rect.height??0,d;t[2]!==s||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,H.jsx)(Lt,{asChild:!0,children:(0,H.jsx)(`div`,{"aria-hidden":!0,style:{position:`fixed`,top:s,left:c,width:l,height:u,pointerEvents:`none`}})}),t[2]=s,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f=n?.content,p;t[7]!==r||t[8]!==f?(p=(0,H.jsx)(Rt,{children:(0,H.jsx)(It,{id:r,children:f})}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;return t[10]!==a||t[11]!==o||t[12]!==d||t[13]!==p?(m=(0,H.jsxs)(Ft,{open:a,onOpenChange:o,delayDuration:0,disableHoverableContent:!0,children:[d,p]}),t[10]=a,t[11]=o,t[12]=d,t[13]=p,t[14]=m):m=t[14],m};function IM(e,t){let n=/{{(\w+)}}/g,r=new Map;for(let e of t){let t=lE({value:e.getValue(),nullAsEmptyString:!0});r.set(e.column.id,t)}return e.replaceAll(n,(e,t)=>{let n=r.get(t);return n===void 0?`{{${t}}}`:n})}function LM(e,t){let n=e.getHoverTitle?.();if(n!=null&&n!==``)return n;if(t)return IM(t,e.row.getVisibleCells())}var RM=400;function zM(e){let t=(0,U.c)(33),{table:n}=e,r;t[0]===n?r=t[1]:(r=n.getState().cellHoverTemplate||null,t[0]=n,t[1]=r);let i=r,[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useId)(),l=(0,V.useRef)(null),u=(0,V.useRef)(!1),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{s.current!=null&&(clearTimeout(s.current),s.current=null)},t[2]=f):f=t[2];let p=f,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(),o(null)},t[3]=m):m=t[3];let h=d(m),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{l.current=e;let n=e.getBoundingClientRect();o({rect:{top:n.top,left:n.left,width:n.width,height:n.height},content:t})},t[4]=g):g=t[4];let _=g,v,y;t[5]!==c||t[6]!==a?(v=()=>{if(!a)return;let e=l.current;return e?.setAttribute(`aria-describedby`,c),()=>e?.removeAttribute(`aria-describedby`)},y=[a,c],t[5]=c,t[6]=a,t[7]=v,t[8]=y):(v=t[7],y=t[8]),(0,V.useLayoutEffect)(v,y);let b,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{let e=()=>{u.current=!0},t=()=>{u.current=!1};return window.addEventListener(`mousedown`,e,{capture:!0}),window.addEventListener(`mouseup`,t,{capture:!0}),()=>{window.removeEventListener(`mousedown`,e,{capture:!0}),window.removeEventListener(`mouseup`,t,{capture:!0})}},x=[],t[9]=b,t[10]=x):(b=t[9],x=t[10]),(0,V.useEffect)(b,x);let S;t[11]!==h||t[12]!==i?(S=(e,t)=>{if(e.buttons!==0)return;let n=e.currentTarget,r=LM(t,i);if(r==null||r===``){h();return}p(),s.current=window.setTimeout(()=>_(n,r),RM)},t[11]=h,t[12]=i,t[13]=S):S=t[13];let C=d(S),w;t[14]===h?w=t[15]:(w=()=>h(),t[14]=h,t[15]=w);let T=d(w),E;t[16]===i?E=t[17]:(E=(e,t)=>{if(p(),u.current)return;let n=LM(t,i);n!=null&&n!==``&&_(e.currentTarget,n)},t[16]=i,t[17]=E);let D=d(E),O;t[18]===h?O=t[19]:(O=()=>h(),t[18]=h,t[19]=O);let k=d(O),A,j;t[20]===h?(A=t[21],j=t[22]):(A=()=>(window.addEventListener(`scroll`,h,{passive:!0,capture:!0}),window.addEventListener(`resize`,h),()=>{window.removeEventListener(`scroll`,h,{capture:!0}),window.removeEventListener(`resize`,h)}),j=[h],t[20]=h,t[21]=A,t[22]=j),(0,V.useEffect)(A,j);let M,N;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p,N=[],t[23]=M,t[24]=N):(M=t[23],N=t[24]),(0,V.useEffect)(M,N);let P;return t[25]!==k||t[26]!==D||t[27]!==T||t[28]!==C||t[29]!==h||t[30]!==c||t[31]!==a?(P={tooltipState:a,tooltipContentId:c,hideTooltip:h,handleCellMouseOver:C,handleCellMouseLeave:T,handleCellFocus:D,handleCellBlur:k},t[25]=k,t[26]=D,t[27]=T,t[28]=C,t[29]=h,t[30]=c,t[31]=a,t[32]=P):P=t[32],P}var BM=(0,V.memo)(e=>{let t=(0,U.c)(9),{cellId:n,className:r}=e,i;t[0]===n?i=t[1]:(i=Zj(n),t[0]=n,t[1]=i);let{isSelected:a,isCopied:o}=s(i);if(!a&&!o)return null;let c=a&&`bg-(--green-3)`,l=o&&`bg-(--green-4) transition-colors duration-150`,u;t[2]!==r||t[3]!==c||t[4]!==l?(u=R(`absolute inset-0 pointer-events-none`,c,l,r),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5];let d;return t[6]!==n||t[7]!==u?(d=(0,H.jsx)(`div`,{"data-cell-id":n,className:u}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d});BM.displayName=`CellRangeSelectionIndicator`;var VM=e=>{let t=(0,U.c)(30),{table:n}=e,r=Kj(),i;t[0]!==r||t[1]!==n?(i=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=d(i),o;t[3]!==r||t[4]!==n?(o=(e,t)=>{r.updateSelection({newCell:e,isShiftKey:t,table:n})},t[3]=r,t[4]=n,t[5]=o):o=t[5];let s=d(o),c;t[6]!==r||t[7]!==n?(c=(e,t)=>{r.navigate({direction:t,isShiftKey:e.shiftKey,table:n})},t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=d(c),u;t[9]!==r||t[10]!==a||t[11]!==l||t[12]!==n?(u=e=>{bb7:switch(e.key){case`c`:Vt.isMetaOrCtrl(e)&&a();break bb7;case`ArrowDown`:e.preventDefault(),l(e,`down`);break bb7;case`ArrowUp`:e.preventDefault(),l(e,`up`);break bb7;case`ArrowLeft`:e.preventDefault(),l(e,`left`);break bb7;case`ArrowRight`:e.preventDefault(),l(e,`right`);break bb7;case`Enter`:e.preventDefault(),r.toggleCurrentRowSelection(n);break bb7;case`Escape`:r.clearSelection();break bb7;case`a`:(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r.selectAllCells(n))}},t[9]=r,t[10]=a,t[11]=l,t[12]=n,t[13]=u):u=t[13];let f=d(u),p;t[14]!==r||t[15]!==n?(p=(e,t)=>{e.buttons!==2&&(WM(e)||r.handleCellMouseDown({cell:t,isShiftKey:e.shiftKey,isCtrlKey:e.ctrlKey,table:n}))},t[14]=r,t[15]=n,t[16]=p):p=t[16];let m=d(p),h;t[17]===r?h=t[18]:(h=()=>{r.setIsSelecting(!1)},t[17]=r,t[18]=h);let g=d(h),_;t[19]!==r||t[20]!==n?(_=(e,t)=>{e.buttons===1&&r.updateRangeSelection({cell:t,table:n})},t[19]=r,t[20]=n,t[21]=_):_=t[21];let v=d(_),y;return t[22]!==r.clearSelection||t[23]!==m||t[24]!==v||t[25]!==g||t[26]!==f||t[27]!==a||t[28]!==s?(y={handleCellMouseDown:m,handleCellMouseUp:g,handleCellMouseOver:v,handleCopy:a,handleCellsKeyDown:f,updateSelection:s,clearSelection:r.clearSelection},t[22]=r.clearSelection,t[23]=m,t[24]=v,t[25]=g,t[26]=f,t[27]=a,t[28]=s,t[29]=y):y=t[29],y},HM=`input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element`,UM=new Set([`marimo-lazy`,`marimo-routes`]);function WM(e){let t=typeof e.nativeEvent?.composedPath==`function`?e.nativeEvent.composedPath():[e.target];for(let n of t){if(n===e.currentTarget)break;if(!(!(n instanceof Element)||!n.matches(HM))){if(n.localName===`marimo-ui-element`){let e=n.firstElementChild;if(e&&UM.has(e.localName))continue}return!0}}return!1}var GM=i(e=>e(Gj).focusedCell);function KM(e){let t=(0,U.c)(2),n;t[0]===e?n=t[1]:(n=t=>{t?.cellId&&setTimeout(()=>{let n=e.current?.querySelector(`[data-cell-id="${t.cellId}"]`);if(!n){be.warn(`[ScrollIntoView] Could not find cell with ID:`,t.cellId);return}n.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},0)},t[0]=e,t[1]=n),o(GM,n)}function qM(e,t){if(!e.getRowModel().rows?.length)return null;let n=t=>t.map(t=>t.headers.map(t=>{let{className:n,style:r}=YM(t.column);return(0,H.jsx)(pa,{className:R(`h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75`,n),style:r,ref:n=>{XM({table:e,column:t.column,thead:n})},children:t.isPlaceholder?null:LD(t.column.columnDef.header,t.getContext())},t.id)}));return(0,H.jsx)(fa,{className:R(t&&`sticky top-0 z-10`),children:(0,H.jsxs)(ha,{children:[n(e.getLeftHeaderGroups()),n(e.getCenterHeaderGroups()),n(e.getRightHeaderGroups()),e.getAllColumns().length<=4&&(0,H.jsx)(`th`,{className:`w-full border-0`,"aria-hidden":`true`})]})})}var JM=({table:e,columns:t,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:i,virtualize:a=!1})=>{let o=e.getRowModel().rows,[s,c]=(0,V.useState)(null),l=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{c(l.current?.parentElement?.parentElement??null)},[]);let u=vM({count:a?o.length:0,getScrollElement:()=>s,estimateSize:()=>24,overscan:10});KM(l);let{handleCellMouseDown:f,handleCellMouseUp:p,handleCellMouseOver:h,handleCellsKeyDown:g,handleCopy:_}=VM({table:e}),v=(0,V.useRef)(null),y=d(e=>{v.current=e}),b=zM({table:e}),x=e=>e.map(e=>{let{className:t,style:n}=YM(e.column),r=e.column.columnDef.meta?.width,i=Object.assign({},e.getUserStyling?.()||{},n);return(0,V.createElement)(ga,{tabIndex:0,...m(e.id),key:e.id,className:R(`whitespace-pre truncate outline-hidden border-r border-r-border/75`,!r&&`max-w-[300px]`,e.column.getColumnWrapping&&e.column.getColumnWrapping?.()===`wrap`&&`whitespace-pre-wrap min-w-[200px]`,`px-1.5 py-[0.18rem]`,t),style:i,onMouseDown:t=>{f(t,e),b.hideTooltip()},onMouseUp:p,onMouseOver:t=>{h(t,e),b.handleCellMouseOver(t,e)},onMouseLeave:b.handleCellMouseLeave,onFocus:t=>b.handleCellFocus(t,e),onBlur:b.handleCellBlur,onContextMenu:()=>y(e)},(0,H.jsx)(BM,{cellId:e.id}),(0,H.jsx)(`div`,{className:`relative`,children:LD(e.column.columnDef.cell,e.getContext())}))}),S=e=>{if(n){let t=r?.(e.original,e.index)??e.index;e.focusRow?.(t)}},C=e=>{let a=n?r?.(e.original,e.index)??e.index:void 0,o=n&&i===a;return(0,H.jsxs)(ha,{"data-state":e.getIsSelected()&&`selected`,className:R(`border-t h-6`,n&&`cursor-pointer`,o&&`bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)`),onClick:()=>S(e),children:[x(e.getLeftVisibleCells()),x(e.getCenterVisibleCells()),x(e.getRightVisibleCells()),t.length<=4&&(0,H.jsx)(`td`,{className:`border-0`,"aria-hidden":`true`})]},e.id)},w=t.length<=4,T=t.length+ +!!w,E=(0,H.jsx)(ma,{onKeyDown:g,ref:l,children:(()=>{if(o.length===0)return(0,H.jsx)(ha,{children:(0,H.jsx)(ga,{colSpan:T,className:`h-24 text-center`,children:`No results.`})});if(a){let e=u.getVirtualItems(),t=u.getTotalSize();return(0,H.jsxs)(H.Fragment,{children:[e[0]?.start>0&&(0,H.jsx)(`tr`,{"data-virtual-spacer":``,style:{height:e[0].start},children:(0,H.jsx)(`td`,{colSpan:T})}),e.map(e=>C(o[e.index])),e.length>0&&(0,H.jsx)(`tr`,{"data-virtual-spacer":``,style:{height:t-(e.at(-1)?.end??t)},children:(0,H.jsx)(`td`,{colSpan:T})})]})}return o.map(e=>C(e))})()});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(NM,{tableBody:E,contextMenuRef:v,tableRef:l,copyAllCells:_}),(0,H.jsx)(FM,{state:b.tooltipState,contentId:b.tooltipContentId,onClose:b.hideTooltip})]})};function YM(e){let t=e.getIsPinned(),n=t===`left`&&e.getIsLastColumn(`left`),r=t===`right`&&e.getIsFirstColumn(`right`),i=e.columnDef.meta?.width;return{className:R(t&&`bg-inherit`,`shadow-r z-10`),style:{boxShadow:n&&e.id!==`__select__`?`-4px 0 4px -4px var(--slate-8) inset`:r?`4px 0 4px -4px var(--slate-8) inset`:void 0,left:t===`left`?`${e.getStart(`left`)}px`:void 0,right:t===`right`?`${e.getAfter(`right`)}px`:void 0,opacity:1,position:t?`sticky`:`relative`,zIndex:+!!t,width:e.getSize(),...i?{minWidth:i,maxWidth:i}:{}}}}function XM({table:e,column:t,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);e.getState().columnSizing[t.id]!==r&&e.setColumnSizing(e=>({...e,[t.id]:r}))}function ZM(e){let[t,n]=_j(Object.fromEntries((e??[]).map(e=>[e,!1])),l);return{columnVisibility:t,setColumnVisibility:n}}function QM(e){let t=e.getAllLeafColumns().filter(e=>e.getCanHide()),n=t.filter(e=>e.getIsVisible()).length;return{total:t.length,visible:n,hidden:t.length-n}}function $M(e,t){let n=QM(e);return{totalColumns:n.hidden>0?n.total:t,hiddenColumns:n.hidden}}function eN(e,t){let n=new Set(t),r={};for(let t of e.getAllLeafColumns())t.getCanHide()&&(r[t.id]=n.has(t.id));return r}function tN(e,t){e.setColumnVisibility(n=>({...n,...eN(e,t)}))}function nN(e){let t=[],n=[];for(let r of e.getAllLeafColumns())r.getCanHide()&&(t.push(r.id),r.getIsVisible()&&n.push(r.id));return{visibleHideableColumnIds:n,hideableColumnIdSet:new Set(t)}}function rN(e,t){let n=new Set(t.filter(t=>e.hideableColumnIdSet.has(t)));return e.visibleHideableColumnIds.length===n.size&&e.visibleHideableColumnIds.every(e=>n.has(e))}var iN=({table:e,tableLoading:t,showPageSizeSelector:n})=>{let{locale:r}=B(),i=Math.min(e.getState().pagination.pageIndex+1,e.getPageCount()),a=e.getPageCount(),o=e.getState().pagination.pageSize,s=e=>{t||e()},c=[...new Set([5,10,25,50,100,o])].toSorted((e,t)=>e-t);return(0,H.jsxs)(`div`,{className:`flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2`,children:[(0,H.jsx)(`div`,{className:`order-2 lg:order-first`,children:n&&(0,H.jsx)(`div`,{className:`flex items-center text-xs whitespace-nowrap mr-1 print:hidden`,children:(0,H.jsxs)(Ct,{children:[(0,H.jsx)(bt,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,className:`border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5`,children:[o,` / page`,(0,H.jsx)(an,{className:`h-3 w-3 opacity-50 mb-px`})]})}),(0,H.jsxs)(xt,{align:`center`,sideOffset:6,children:[(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Rows per page`}),[...c].map(t=>(0,H.jsx)(ut,{className:R(`text-xs cursor-pointer`,t===o&&`font-semibold bg-accent`),onSelect:()=>e.setPageSize(t),onMouseDown:Vt.preventFocus,children:t},t))]})]})})}),(0,H.jsxs)(`div`,{className:`order-1 lg:order-last flex items-center print:hidden`,children:[(0,H.jsx)(zt,{content:`First page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`first-page-button`,className:`hidden h-6 w-5 p-0 lg:flex`,onClick:()=>s(()=>e.setPageIndex(0)),onMouseDown:Vt.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,H.jsx)(wo,{className:`h-4 w-4`})})}),(0,H.jsx)(zt,{content:`Previous page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`previous-page-button`,className:`h-6 w-5 p-0`,onClick:()=>s(()=>e.previousPage()),onMouseDown:Vt.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,H.jsx)(Mt,{className:`h-4 w-4`})})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-center text-xs font-medium gap-1`,children:[(0,H.jsx)(`span`,{children:`Page`}),(0,H.jsx)(cN,{currentPage:i,totalPages:a,onPageChange:t=>s(()=>e.setPageIndex(t))}),(0,H.jsxs)(`span`,{className:`shrink-0`,children:[`of `,ki(a,r)]})]}),(0,H.jsx)(zt,{content:`Next page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`next-page-button`,className:`h-6 w-5 p-0`,onClick:()=>s(()=>e.nextPage()),onMouseDown:Vt.preventFocus,disabled:!e.getCanNextPage(),children:(0,H.jsx)(ln,{className:`h-4 w-4`})})}),(0,H.jsx)(zt,{content:`Last page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`last-page-button`,className:`hidden h-6 w-5 p-0 lg:flex`,onClick:()=>s(()=>e.setPageIndex(e.getPageCount()-1)),onMouseDown:Vt.preventFocus,disabled:!e.getCanNextPage(),children:(0,H.jsx)(To,{className:`h-4 w-4`})})})]})]})},aN=32;function oN(e,t){let n=Number.parseInt(e,10);if(Number.isNaN(n)||n<=0||String(n)!==e)return[];let r=[],i=1;for(;n*i<=t;){let e=n*i,a=Math.min((n+1)*i-1,t);r.push([e,a]),i*=10}return r}function sN(e,t){if(e===``)return{count:t,pageAtIndex:e=>e+1,indexOfPage:e=>e-1};let n=oN(e,t),r=0;for(let[e,t]of n)r+=t-e+1;return{count:r,pageAtIndex:e=>{let t=0;for(let[r,i]of n){let n=i-r+1;if(e<t+n)return r+(e-t);t+=n}return-1},indexOfPage:e=>{let t=0;for(let[r,i]of n){if(e>=r&&e<=i)return t+(e-r);t+=i-r+1}return-1}}}var cN=({currentPage:e,totalPages:t,onPageChange:n})=>{let[r,i]=V.useState(!1),[a,o]=V.useState(``),s=V.useMemo(()=>sN(a,t),[a,t]),c=e=>{n(e-1),o(``),i(!1)},l=Math.min(s.count*aN,240);return(0,H.jsxs)(I,{open:t>1&&r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,H.jsx)(P,{asChild:!0,disabled:t<=1,children:(0,H.jsxs)(`button`,{type:`button`,className:R(`border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5`,t>1?`hover:bg-accent cursor-pointer`:`opacity-50 cursor-default`),"data-testid":`page-select`,disabled:t<=1,children:[e,(0,H.jsx)(an,{className:`h-3 w-3 opacity-50 mb-px`})]})}),(0,H.jsx)(ae,{className:`w-36 p-0`,align:`center`,sideOffset:6,children:(0,H.jsxs)(pe,{shouldFilter:!1,value:String(e),children:[(0,H.jsx)(A,{placeholder:`Page (1–${t})`,rootClassName:`px-2 h-8`,className:`text-xs h-8`,autoFocus:!0,icon:null,value:a,onValueChange:o,onKeyDown:e=>{![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!/^\d$/.test(e.key)&&e.preventDefault()}}),(0,H.jsx)(me,{className:`max-h-60 overflow-hidden`,children:s.count===0?(0,H.jsx)(te,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No matching page`}):(0,H.jsx)(lN,{mapping:s,currentPage:e,listHeight:l,onSelect:c})})]})})]})},lN=({mapping:e,currentPage:t,listHeight:n,onSelect:r})=>{let i=V.useRef(null),a=e.indexOfPage(t),o=vM({count:e.count,getScrollElement:()=>i.current,estimateSize:()=>aN,overscan:10,initialOffset:a>0?Math.max(0,a*aN-n/2):0}),s=V.useRef(e.count);return V.useEffect(()=>{e.count!==s.current&&(o.scrollToIndex(0),s.current=e.count)},[e.count,o]),(0,H.jsx)(`div`,{ref:i,style:{height:n,overflow:`auto`},children:(0,H.jsx)(`div`,{style:{height:o.getTotalSize(),width:`100%`,position:`relative`},children:o.getVirtualItems().map(n=>{let i=e.pageAtIndex(n.index);return(0,H.jsx)(h,{value:String(i),"data-testid":`page-option`,"aria-selected":i===t,className:R(`text-xs cursor-pointer`,i===t&&`font-semibold bg-accent`),style:{position:`absolute`,top:0,left:0,width:`100%`,height:n.size,transform:`translateY(${n.start}px)`},onSelect:()=>r(i),onMouseDown:Vt.preventFocus,children:i},i)})})})};function uN(e,t){return`${ki(e,t)} ${new ce(`row`).pluralize(e)}`}var dN=({numRows:e,totalColumns:t,hiddenColumns:n,locale:r})=>{let i=e===`too_many`?`Unknown`:uN(e,r),a=n??0,o=t-a;return{rowsAndColumns:[i,a>0?`${ki(o,r)} visible`:`${ki(t,r)} ${new ce(`column`).pluralize(t)}`].join(`, `),hiddenSuffix:a>0?`(${ki(a,r)} hidden)`:null}},fN=3,pN=e=>{let t=(0,U.c)(21),{table:n,className:r}=e,{locale:i}=B(),a=s(Yj),o=zj(a);if(o<2){let e;t[0]===r?e=t[1]:(e=R(`text-xs text-muted-foreground/80 italic`,r),t[0]=r,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,H.jsx)(zt,{content:`Select multiple cells to see stats`,children:(0,H.jsx)(`span`,{className:e,children:`No selection`})}),t[2]=e,t[3]=n),n}let c;t[4]!==a||t[5]!==n?(c=Bj(n,a),t[4]=a,t[5]=n,t[6]=c):c=t[6];let l=c,u;t[7]===r?u=t[8]:(u=R(`flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0`,r),t[7]=r,t[8]=u);let d;t[9]!==o||t[10]!==i?(d=(0,H.jsx)(gN,{count:o,locale:i}),t[9]=o,t[10]=i,t[11]=d):d=t[11];let f,p;t[12]!==i||t[13]!==l?(f=(0,H.jsx)(_N,{numericValues:l,locale:i}),p=(0,H.jsx)(vN,{numericValues:l,locale:i}),t[12]=i,t[13]=l,t[14]=f,t[15]=p):(f=t[14],p=t[15]);let m;return t[16]!==u||t[17]!==d||t[18]!==f||t[19]!==p?(m=(0,H.jsxs)(`div`,{className:u,children:[d,f,p]}),t[16]=u,t[17]=d,t[18]=f,t[19]=p,t[20]=m):m=t[20],m},mN=(e,t)=>e.toLocaleString(t,{maximumFractionDigits:fN}),hN=e=>{let t=(0,U.c)(6),{name:n,value:r,locale:i}=e,a;t[0]!==i||t[1]!==r?(a=mN(r,i),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,H.jsxs)(`span`,{children:[n,`: `,a]}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o},gN=e=>{let t=(0,U.c)(3),{count:n,locale:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,H.jsx)(hN,{name:`Count`,value:n,locale:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},_N=e=>{let t=(0,U.c)(6),{numericValues:n,locale:r}=e;if(n.length===0)return null;let i,a;if(t[0]!==n){let e=n.reduce(yN,0);i=Number,a=e.toFixed(fN),t[0]=n,t[1]=i,t[2]=a}else i=t[1],a=t[2];let o=i(a),s;return t[3]!==r||t[4]!==o?(s=(0,H.jsx)(hN,{name:`Sum`,value:o,locale:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},vN=e=>{let t=(0,U.c)(5),{numericValues:n,locale:r}=e;if(n.length===0)return null;let i=n.reduce(bN,0)/n.length,a;t[0]===i?a=t[1]:(a=i.toFixed(fN),t[0]=i,t[1]=a);let o=Number(a),s;return t[2]!==o||t[3]!==r?(s=(0,H.jsx)(hN,{name:`Average`,value:o,locale:r}),t[2]=o,t[3]=r,t[4]=s):s=t[4],s};function yN(e,t){return e+t}function bN(e,t){return e+t}var xN=({pagination:e,totalColumns:t,selection:n,onRowSelectionChange:r,table:i,getRowIds:a,showPageSizeSelector:o,tableLoading:s,part:c,className:l})=>{let{locale:u}=B(),d=De(),f=e=>{if(!r)return;if(!e){r({});return}let t=()=>{let e=Array.from({length:i.getRowCount()},(e,t)=>[t,!0]);r(Object.fromEntries(e))};if(!a){t();return}a({}).then(e=>{if(e.error){ai({title:`Not available`,description:e.error,variant:`danger`});return}e.all_rows?t():r(Object.fromEntries(e.row_ids.map(e=>[e,!0])))})};return(0,H.jsxs)(`div`,{part:c,className:R(`flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0`,l),children:[(0,H.jsxs)(`div`,{className:`flex flex-col text-sm text-muted-foreground px-2 shrink-0`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-1`,children:(()=>{let{rowSelection:e,cellSelection:r}=i.getState(),a=Object.keys(e).length,o=i.getIsAllPageRowsSelected(),s=i.getRowCount(),c=a===s,l=n===`single-cell`||n===`multi-cell`;if(l&&(a=r.length,o=!1,c=!1),o&&!c)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[ki(a,u),` selected`]}),(0,H.jsxs)(z,{size:`xs`,"data-testid":`select-all-button`,variant:`link`,className:`h-4 print:hidden`,onMouseDown:Vt.preventFocus,onClick:()=>f(!0),children:[`Select all `,ki(s,u)]})]});if(a)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[ki(a,u),` selected`]}),(0,H.jsx)(z,{size:`xs`,"data-testid":`clear-selection-button`,variant:`link`,className:`h-4 print:hidden`,onMouseDown:Vt.preventFocus,onClick:()=>{l?i.resetCellSelection&&i.resetCellSelection():f(!1)},children:`Clear selection`})]});let{totalColumns:d,hiddenColumns:p}=$M(i,t),{rowsAndColumns:m,hiddenSuffix:h}=dN({numRows:i.getRowCount(),totalColumns:d,hiddenColumns:p,locale:u});return(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{children:m}),h&&(0,H.jsx)(`span`,{className:`text-xs`,children:h})]})})()}),(0,H.jsx)(pN,{table:i,className:`lg:hidden`})]}),(0,H.jsx)(`div`,{className:`ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0`,children:e&&!d&&(0,H.jsx)(iN,{table:i,tableLoading:s,showPageSizeSelector:o})}),(0,H.jsx)(`div`,{className:`hidden lg:flex justify-end`,children:(0,H.jsx)(pN,{table:i,className:`px-2`})})]})},SN=e=>{let t=(0,U.c)(2),{isExpanded:n}=e,r;return t[0]===n?r=t[1]:(r=(0,H.jsx)(un,{isExpanded:n,className:`h-3 w-3`}),t[0]=n,t[1]=r),r},CN=e=>{let t=(0,U.c)(6),{children:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`flex gap-1.5 items-center font-bold py-1.5 text-muted-foreground bg-(--slate-2) text-sm`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==i||t[4]!==a?(o=(0,H.jsx)(`div`,{className:a,style:i,children:n}),t[2]=n,t[3]=i,t[4]=a,t[5]=o):o=t[5],o},wN=e=>{let t=(0,U.c)(6),{content:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`text-sm text-muted-foreground py-1`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==i||t[4]!==a?(o=(0,H.jsx)(`div`,{className:a,style:i,children:n}),t[2]=n,t[3]=i,t[4]=a,t[5]=o):o=t[5],o},TN=e=>{let t=(0,U.c)(9),{error:n,style:r,className:i,showIcon:a}=e,o=a===void 0||a,s;t[0]===i?s=t[1]:(s=R(`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`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o&&(0,H.jsx)(sn,{className:`h-4 w-4 mt-0.5`}),t[2]=o,t[3]=c);let l;return t[4]!==n.message||t[5]!==r||t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:s,style:r,children:[c,n.message]}),t[4]=n.message,t[5]=r,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},EN=e=>{let t=(0,U.c)(7),{message:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`text-sm bg-blue-50 dark:bg-(--accent) text-blue-500 dark:text-blue-50 flex items-center gap-2 p-2 h-8`,r),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsx)(On,{className:`h-4 w-4 animate-spin`}),t[2]=o):o=t[2];let s;return t[3]!==n||t[4]!==i||t[5]!==a?(s=(0,H.jsxs)(`div`,{className:a,style:i,children:[o,n]}),t[3]=n,t[4]=i,t[5]=a,t[6]=s):s=t[6],s},DN=e=>{let t=(0,U.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=R(`flex flex-col gap-2 relative`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,H.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},ON=e=>{let t=(0,U.c)(9),{columnName:n,dataType:r}=e,i,a;if(t[0]!==r){let e=v(r);i=C[e],a=E(e),t[0]=r,t[1]=i,t[2]=a}else i=t[1],a=t[2];let o=`w-4 h-4 p-0.5 rounded-sm stroke-card-foreground ${a}`,s;t[3]!==i||t[4]!==o?(s=(0,H.jsx)(i,{className:o}),t[3]=i,t[4]=o,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==s?(c=(0,H.jsxs)(`div`,{className:`flex flex-row items-center gap-1.5`,children:[s,n]}),t[6]=n,t[7]=s,t[8]=c):c=t[8],c},kN=`Show only this column`;function AN({table:e,columnIds:t,disabled:n,className:r,iconClassName:i=`h-3 w-3`}){return(0,H.jsx)(zt,{content:kN,delayDuration:400,children:(0,H.jsx)(z,{type:`button`,variant:`text`,size:`icon`,"aria-label":kN,"aria-disabled":n,tabIndex:n?-1:0,className:R(`h-6 w-6 hover:bg-muted text-muted-foreground hover:text-primary`,n&&`opacity-50`,r),onPointerDown:e=>{e.stopPropagation()},onClick:r=>{r.preventDefault(),r.stopPropagation(),!n&&tN(e,t)},children:(0,H.jsx)(Io,{className:i,strokeWidth:2.5})})})}function jN(e){return e.getAllLeafColumns().filter(e=>e.id!==`__select__`&&e.id!==`_marimo_row_id`&&!e.id.startsWith(`__m_column__`))}var MN=({table:e})=>{let t=jN(e),n=t.map(e=>({value:e.id,label:e.id,disabled:!e.getCanHide(),data:{dataType:e.columnDef.meta?.dataType}})),r=t.filter(e=>!e.getIsVisible()).map(e=>e.id),i=t.filter(e=>e.getCanHide()).map(e=>e.id),a=i.filter(e=>!r.includes(e)).length,o=n=>{let r=new Set(Array.isArray(n)?n:[]);e.setColumnVisibility(e=>({...e,...Object.fromEntries(t.map(e=>[e.id,!r.has(e.id)]))}))},s=GA({options:n,value:r,onChange:o,multiple:!0,filterFn:T,pinSelected:!0}),c=s.bulkActions.filter(e=>e.kind===`select-matching`||e.kind===`deselect-matching`),l=s.searchQuery===``?[]:s.visibleOptions.filter(e=>!e.disabled).map(e=>e.value),u=(0,V.useMemo)(()=>({visibleHideableColumnIds:i.filter(e=>!r.includes(e)),hideableColumnIdSet:new Set(i)}),[i,r]),d=l.length>0||c.length>0;return(0,H.jsxs)(I,{open:s.open,onOpenChange:s.setOpen,children:[(0,H.jsx)(P,{asChild:!0,children:(0,H.jsxs)(z,{variant:`text`,size:`xs`,"data-testid":`column-visibility-trigger`,onMouseDown:Vt.preventFocus,className:R(`print:hidden text-xs gap-1`,s.open?`text-primary`:`text-muted-foreground`),children:[(0,H.jsx)(Eo,{className:`w-3.5 h-3.5`}),`Columns`]})}),(0,H.jsx)(ae,{className:`w-64 p-0`,align:`end`,children:(0,H.jsxs)(pe,{shouldFilter:!1,children:[(0,H.jsx)(A,{placeholder:`Search columns...`,value:s.searchQuery,onValueChange:s.setSearchQuery}),(0,H.jsxs)(me,{children:[(0,H.jsx)(te,{children:`No results.`}),s.searchQuery===``?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(h,{value:`__show_all__`,disabled:r.length===0,onSelect:()=>o([]),className:`cursor-pointer`,children:[(0,H.jsx)(p,{className:`w-3 h-3 mr-1.5`}),`Show all`]}),(0,H.jsxs)(h,{value:`__hide_all__`,disabled:a===0,onSelect:()=>o(i),className:`cursor-pointer`,children:[(0,H.jsx)(xn,{className:`w-3 h-3 mr-1.5`}),`Hide all`]}),(0,H.jsx)(j,{})]}):d&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(h,{value:`__show_only_matching__`,disabled:l.length===0||rN(u,l),onSelect:()=>{tN(e,l)},className:`cursor-pointer`,children:[(0,H.jsx)(Io,{className:`w-3 h-3 mr-1.5`}),`Show only `,l.length,` matching`]}),c.map(e=>(0,H.jsxs)(h,{value:`__bulk_${e.kind}`,onSelect:e.run,className:`cursor-pointer`,children:[e.kind===`select-matching`?(0,H.jsx)(xn,{className:`w-3 h-3 mr-1.5`}):(0,H.jsx)(p,{className:`w-3 h-3 mr-1.5`}),e.kind===`select-matching`?`Hide`:`Show`,` `,e.items.length,` matching`]},e.kind)),(0,H.jsx)(j,{})]}),s.visibleOptions.map((t,n)=>{let r=s.isChecked(t.value),{dataType:i}=t.data,a=n===s.pinnedCount&&s.pinnedCount>0&&s.pinnedCount<s.visibleOptions.length;return(0,H.jsxs)(V.Fragment,{children:[a&&(0,H.jsx)(j,{}),(0,H.jsxs)(h,{value:t.value,disabled:t.disabled,onSelect:()=>s.toggle(t.value),className:`flex items-center gap-1.5 cursor-pointer`,children:[i===void 0?(0,H.jsx)(`span`,{children:t.label}):(0,H.jsx)(ON,{columnName:t.label,dataType:i}),!t.disabled&&(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,H.jsx)(AN,{table:e,columnIds:[t.value],disabled:rN(u,[t.value]),iconClassName:`w-3 h-3`}),(0,H.jsx)(`span`,{className:R(r?`text-primary`:`text-muted-foreground`),children:r?(0,H.jsx)(xn,{className:`w-3 h-3`}):(0,H.jsx)(p,{className:`w-3 h-3`})})]})]})]},t.value)})]})]})})]})},NN=i(null),PN=e=>{let t=(0,U.c)(13),{packages:n,showMaxPackages:r,className:i,onInstall:a}=e,{handleInstallPackages:o}=aa(),s=Ee();if(!n||n.length===0||!s)return null;let c;t[0]!==o||t[1]!==a||t[2]!==n?(c=()=>{o(n,a)},t[0]=o,t[1]=a,t[2]=n,t[3]=c):c=t[3];let l;t[4]===i?l=t[5]:(l=R(`ml-2`,i),t[4]=i,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r?n.slice(0,r).join(`, `):n.join(`, `),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;return t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,H.jsxs)(z,{variant:`outline`,size:`xs`,onClick:c,className:l,children:[`Install`,` `,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d},FN=e=>{let t=(0,U.c)(20),{packages:n,featureName:r,description:i,onInstall:a,className:o}=e;if(!Ee()){let e;t[0]===o?e=t[1]:(e=R(`text-xs`,o),t[0]=o,t[1]=e);let n;return t[2]!==r||t[3]!==e?(n=(0,H.jsxs)(`span`,{className:e,children:[r,` isn't available in this notebook`]}),t[2]=r,t[3]=e,t[4]=n):n=t[4],n}let s;t[5]===o?s=t[6]:(s=R(`text-xs flex flex-col items-end gap-2`,o),t[5]=o,t[6]=s);let c;t[7]!==i||t[8]!==r||t[9]!==n?(c=i||`${r} requires ${n.join(`, `)}`,t[7]=i,t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,H.jsx)(`span`,{className:`self-start`,children:c}),t[11]=c,t[12]=l);let u;t[13]!==a||t[14]!==n?(u=(0,H.jsx)(PN,{packages:n,onInstall:a,className:`ml-0`}),t[13]=a,t[14]=n,t[15]=u):u=t[15];let d;return t[16]!==s||t[17]!==l||t[18]!==u?(d=(0,H.jsxs)(`div`,{className:s,children:[l,u]}),t[16]=s,t[17]=l,t[18]=u,t[19]=d):d=t[19],d},IN={CSV:{label:`CSV`,format:`csv`,description:`Comma-separated values`,icon:nn},JSON:{label:`JSON`,format:`json`,description:`Raw JSON data`,icon:ue},PARQUET:{label:`Parquet`,format:`parquet`,description:`Columnar binary format`,icon:xo},TSV:{label:`TSV`,format:`tsv`,description:`Best for Excel and Google Sheets`,icon:nn},MARKDOWN:{label:`Markdown`,format:`markdown`,description:`Preserves hyperlinks and formatting`,icon:D}},LN=[IN.CSV,IN.TSV,IN.JSON,IN.PARQUET],RN=[IN.TSV,IN.JSON,IN.CSV,IN.MARKDOWN],zN={csv:`csv`,tsv:`tsv`,json:`json`,markdown:`json`},BN=e=>LN.find(t=>t.format===e)?.label??e,VN=e=>RN.find(t=>t.format===e)?.label??e,HN=e=>{let t=(0,U.c)(55),[n,r]=V.useState(!1),i=s(NN),a=!!(i&&e.sizeBytes!=null&&e.sizeBytes>i.limitBytes),o=!!(i&&(e.sizeBytesIsLoading||a)),c=o?e.sizeBytesIsLoading?`Checking download size…`:i?.unavailableMessage:`Export`,l=n?`text-primary`:`text-muted-foreground`,u;t[0]===l?u=t[1]:(u=R(`print:hidden text-xs gap-1`,l),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,H.jsx)(Oo,{className:`w-3.5 h-3.5`}),t[2]=d):d=t[2];let f;t[3]!==o||t[4]!==u?(f=(0,H.jsxs)(z,{"data-testid":`export-button`,size:`xs`,variant:`text`,disabled:o,className:u,children:[d,`Export`]}),t[3]=o,t[4]=u,t[5]=f):f=t[5];let p=f,m;t[6]===e?m=t[7]:(m=async(t,n)=>{let r;try{r=await e.downloadAs({format:t})}catch(e){let t=e;return ai({title:`Failed to download`,description:typeof t==`object`&&t&&`message`in t?String(t.message):String(t)}),null}return r.missing_packages&&r.missing_packages.length>0?(ai({title:`Export failed`,description:(0,H.jsx)(FN,{packages:r.missing_packages,featureName:`${BN(t)} export`,description:r.error,onInstall:n})}),null):{url:r.url,filename:r.filename}},t[6]=e,t[7]=m);let h=m,g,_,v,b,x,S,C,w,T,E,D,O,k;if(t[8]!==p||t[9]!==o||t[10]!==n||t[11]!==h||t[12]!==c){let e=async t=>{let n=BN(t);await kt(`Preparing ${n} export...`,async()=>{let n=await h(t,()=>{e(t)});if(!n)return!1;let r=(n.filename??``).trim(),i=`${Nt.withoutExtension(r)||`download`}.${t}`,a=n.url;if(!a.startsWith(`data:`)){let e=a.includes(`?`)?`&`:`?`,t=new URLSearchParams({download:`1`,filename:i});a=`${a}${e}${t.toString()}`}return Pt(a,i),!0})&&ai({title:`${n} download started`})},i=async e=>{await kt(`Preparing ${VN(e)} for clipboard...`,async()=>{let t=zN[e],n=await h(t,()=>{i(e)});if(!n)return;let r;bb94:switch(e){case`tsv`:case`csv`:r=await WN(n.url);break bb94;case`json`:{let e=await UN(n.url);r=JSON.stringify(e,null,2);break bb94}case`markdown`:{let e=await UN(n.url);r=y(e);break bb94}default:Jt(e);return}await Vi(r),ai({title:`Copied to clipboard`})})};_=Ct,x=!1,S=n,C=r;let a=!n&&void 0,s=o?0:-1,l;t[26]!==p||t[27]!==s?(l=(0,H.jsx)(`span`,{tabIndex:s,className:`inline-flex`,children:p}),t[26]=p,t[27]=s,t[28]=l):l=t[28];let u;t[29]!==o||t[30]!==l?(u=(0,H.jsx)(bt,{asChild:!0,disabled:o,children:l}),t[29]=o,t[30]=l,t[31]=u):u=t[31],t[32]!==a||t[33]!==u||t[34]!==c?(w=(0,H.jsx)(zt,{content:c,open:a,children:u}),t[32]=a,t[33]=u,t[34]=c,t[35]=w):w=t[35],g=xt,T=`bottom`,E=`print:hidden`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Download`}),t[36]=D):D=t[36],O=LN.map(t=>(0,H.jsxs)(ut,{onSelect:()=>{e(t.format)},children:[(0,H.jsx)(t.icon,{className:`mo-dropdown-icon`}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{children:t.label}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.label)),t[37]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(ft,{}),v=(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Copy to clipboard`}),t[37]=v,t[38]=k):(v=t[37],k=t[38]),b=RN.map(e=>(0,H.jsxs)(ut,{onSelect:async()=>{try{await i(e.format)}catch(e){ai({title:`Failed to copy to clipboard`,description:Wi(e),variant:`danger`})}},children:[(0,H.jsx)(e.icon,{className:`mo-dropdown-icon`}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})]},e.label)),t[8]=p,t[9]=o,t[10]=n,t[11]=h,t[12]=c,t[13]=g,t[14]=_,t[15]=v,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=O,t[25]=k}else g=t[13],_=t[14],v=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25];let A;t[39]!==g||t[40]!==v||t[41]!==b||t[42]!==T||t[43]!==E||t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,H.jsxs)(g,{side:T,className:E,children:[D,O,k,v,b]}),t[39]=g,t[40]=v,t[41]=b,t[42]=T,t[43]=E,t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47];let j;return t[48]!==_||t[49]!==x||t[50]!==S||t[51]!==C||t[52]!==w||t[53]!==A?(j=(0,H.jsxs)(_,{modal:x,open:S,onOpenChange:C,children:[w,A]}),t[48]=_,t[49]=x,t[50]=S,t[51]=C,t[52]=w,t[53]=A,t[54]=j):j=t[54],j};function UN(e){return WN(e).then(N)}function WN(e){return fetch(e).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var GN=()=>{},KN=({table:e,showSearch:t,searchQuery:n,onSearchQueryChange:r,reloading:i,showChartBuilder:a,isChartBuilderOpen:o,toggleDisplayHeader:s,showTableExplorer:c,togglePanel:l,isAnyPanelOpen:u,downloadAs:f,sizeBytes:p,sizeBytesIsLoading:m})=>{let[h,g]=(0,V.useState)(n||``),_=sO(h,500),v=d(r??GN),y=V.useRef(null);return(0,V.useEffect)(()=>{v(_)},[_,v]),(0,H.jsxs)(`div`,{className:`flex items-center h-10 px-2 border-b gap-2`,children:[r&&t&&(0,H.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,H.jsx)(cr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`input`,{ref:y,type:`text`,className:`h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0`,value:h,onKeyDown:e=>{e.key===`Escape`&&(g(``),y.current?.blur())},onChange:e=>g(e.target.value),placeholder:`Search...`}),i&&(0,H.jsx)(kn,{size:`small`}),h&&(0,H.jsx)(z,{variant:`text`,size:`xs`,className:`h-5 w-5 p-0 shrink-0`,onClick:()=>g(``),children:(0,H.jsx)(sn,{className:`w-3 h-3 text-muted-foreground`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center shrink-0 ml-auto`,children:[(0,H.jsx)(MN,{table:e}),a&&(0,H.jsxs)(z,{variant:`text`,size:`xs`,className:R(`print:hidden text-xs gap-1`,o?`text-primary`:`text-muted-foreground`),onClick:s,children:[(0,H.jsx)(Co,{className:`w-3.5 h-3.5`}),`Visualize`]}),c&&l&&(0,H.jsxs)(z,{variant:`text`,size:`xs`,className:R(`print:hidden text-xs gap-1`,u?`text-primary`:`text-muted-foreground`),onClick:()=>l(kk.ROW_VIEWER),children:[(0,H.jsx)(No,{className:`w-3.5 h-3.5`}),`Explore`]}),f&&(0,H.jsx)(HN,{downloadAs:f,sizeBytes:p,sizeBytesIsLoading:m})]})]})},qN=(0,V.memo)(({wrapperClassName:e,className:t,maxHeight:n,columns:r,data:i,rawData:a,selection:o,totalColumns:s,totalRows:c,sizeBytes:l,sizeBytesIsLoading:u,manualSorting:d=!1,sorting:f,setSorting:p,rowSelection:m,cellSelection:h,cellStyling:g,hoverTemplate:_,cellHoverTexts:v,paginationState:y,setPaginationState:b,downloadAs:x,manualPagination:S=!1,pagination:C=!1,onRowSelectionChange:w,onCellSelectionChange:T,getRowIds:E,showSearch:D=!1,searchQuery:O,onSearchQueryChange:k,showFilters:A=!1,filters:j,onFiltersChange:M,calculateTopKRows:N,reloading:P,freezeColumnsLeft:F,freezeColumnsRight:ee,hiddenColumns:te,toggleDisplayHeader:ne,showChartBuilder:re,isChartBuilderOpen:ie,showPageSizeSelector:ae,showTableExplorer:oe,togglePanel:se,isPanelOpen:ce,isAnyPanelOpen:le,viewedRowIdx:I,onViewedRowChange:ue,renderTableExplorerPanel:de})=>{let L=De(),fe=!L,[pe,me]=V.useState(!1),{locale:he}=B(),{columnPinning:ge,setColumnPinning:_e}=vj(F,ee),{columnVisibility:ve,setColumnVisibility:ye}=ZM(te);V.useEffect(()=>{let e;return P?e=setTimeout(()=>{me(!0)},300):me(!1),()=>{e&&clearTimeout(e)}},[P]);function be(e,t){return y?t+(S?y.pageIndex*y.pageSize:0):t}let xe=VD({_features:[KE,qO,HD,Lk,zk,Fk,Nk,Bk,hj],data:i,columns:r,meta:{rawData:a},getCoreRowModel:kD(),rowCount:c===`too_many`?void 0:c,...b?{onPaginationChange:b,getRowId:(e,t)=>{let n=rE(e);if(n)return n;let r=be(e,t);return String(r)}}:{},locale:he,manualPagination:S,getPaginationRowModel:FD(),...p?{onSortingChange:p}:{},manualSorting:d,enableSorting:!L,enableMultiSort:!0,getSortedRowModel:ID(),manualFiltering:!0,enableColumnFilters:A&&!L,getFilteredRowModel:PD(),onColumnFiltersChange:M,onRowSelectionChange:w,onCellSelectionChange:T,enableCellSelection:o===`single-cell`||o===`multi-cell`,enableMultiCellSelection:o===`multi-cell`,onColumnPinningChange:_e,onColumnVisibilityChange:ye,enableFocusRow:!0,onFocusRowChange:ue,state:{...f?{sorting:f}:{},columnFilters:j,...y?{pagination:y}:C&&!y?{}:{pagination:{pageIndex:0,pageSize:i.length}},rowSelection:m??{},cellSelection:h??[],columnVisibility:ve,cellStyling:g,columnPinning:ge,cellHoverTemplate:_,cellHoverTexts:v??{}}}),Se=ce?.(kk.ROW_VIEWER)??!1,Ce=!C&&i.length>100,we=bj({maxHeight:n,virtualize:Ce}),[Te,Ee]=V.useState(null),Oe=V.useMemo(()=>({requestAddFilter:e=>{let t=xe.getColumn(e.columnId);t&&Ee(tj(t,{operator:e.operator}))}}),[xe]),ke=QM(xe),Ae=ke.total>0&&ke.visible===0;return(0,H.jsx)(fT,{value:Oe,children:(0,H.jsxs)(`div`,{className:R(e,`flex flex-col space-y-1`),children:[(0,H.jsx)(fj,{filters:j,table:xe,calculateTopKRows:N,addFilterSnapshot:Te,onAddFilterSnapshotChange:Ee}),de?.(xe),(0,H.jsx)($j,{children:(0,H.jsxs)(`div`,{part:`table-wrapper`,className:R(t||`rounded-md border overflow-hidden`),children:[fe&&(0,H.jsx)(KN,{table:xe,showSearch:D,searchQuery:O,onSearchQueryChange:k,reloading:P,showChartBuilder:re,isChartBuilderOpen:ie,toggleDisplayHeader:ne,showTableExplorer:oe,togglePanel:se,isAnyPanelOpen:le,downloadAs:x,sizeBytes:l,sizeBytesIsLoading:u}),Ae&&(0,H.jsxs)(la,{className:`mb-1 mx-2 rounded flex items-center justify-between`,children:[(0,H.jsx)(`span`,{children:`All columns are hidden.`}),(0,H.jsx)(z,{variant:`link`,size:`xs`,onClick:()=>xe.resetColumnVisibility(!0),children:`Unhide all`})]}),(0,H.jsxs)(_a,{className:R(`relative`,r.length<=4?`w-auto`:`w-full`),ref:we,children:[pe&&(0,H.jsx)(`thead`,{className:`absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide`}),qM(xe,Ce||!!n),(0,H.jsx)(JM,{table:xe,columns:r,rowViewerPanelOpen:Se,getRowIndex:be,viewedRowIdx:I,virtualize:Ce})]}),(0,H.jsx)(xN,{part:`table-footer`,className:`pt-1.5 pb-0.5 border-t border-border`,totalColumns:s,pagination:C,selection:o,onRowSelectionChange:w,table:xe,getRowIds:E,showPageSizeSelector:ae,tableLoading:P})]})})]})})}),JN=25;function YN(e){return e?e.startsWith(`image/`)||e.startsWith(`audio/`)||e.startsWith(`video/`)||e.startsWith(`application/pdf`):!1}var XN={"application/javascript":`javascript`,"text/markdown":`markdown`,"text/html":`html`,"text/css":`css`,"text/x-python":`python`,"application/json":`json`,"application/toml":`toml`,"application/x-toml":`toml`,"application/xml":`xml`,"text/x-toml":`toml`,"text/x-yaml":`yaml`,"text/csv":`markdown`,"text/plain":`markdown`,default:`markdown`},ZN={toml:`toml`},QN=new Set([`application/octet-stream`,`text/plain`]);function $N(e,t){let n=e.split(`;`,1)[0].trim().toLowerCase();if(QN.has(n)&&t){let e=oi.extension(t).toLowerCase(),n=Object.hasOwn(ZN,e)?ZN[e]:void 0;if(n)return n}return XN[n]||XN.default}function eP(e){return e.url==null?pn(e.base64,e.mime):e.url}function tP({contents:e,mimeType:t,isBase64:n}){return n?{base64:e,mime:t}:{url:`data:${t};charset=utf-8,${encodeURIComponent(e)}`}}var nP=e=>{let t=(0,U.c)(11),{contents:n}=e,r;t[0]===n?r=t[1]:(r=Ki(n),t[0]=n,t[1]=r);let i=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={pageIndex:0,pageSize:JN},t[2]=a):a=t[2];let[o,s]=(0,V.useState)(a),c;t[3]===i?c=t[4]:(c=dk(i),t[3]=i,t[4]=c);let l=c,u;t[5]===l?u=t[6]:(u=fk({rowHeaders:Ut.EMPTY,selection:null,fieldTypes:l}),t[5]=l,t[6]=u);let d=u,f;return t[7]!==d||t[8]!==i||t[9]!==o?(f=(0,H.jsx)(qN,{data:i,totalRows:i.length,columns:d,totalColumns:d.length,manualPagination:!1,paginationState:o,setPaginationState:s,wrapperClassName:`h-full justify-between pb-1 px-1`,pagination:!0,className:`rounded-none border-b flex flex-col overflow-hidden`,rowSelection:Se.EMPTY}),t[7]=d,t[8]=i,t[9]=o,t[10]=f):f=t[10],f},rP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`img`,{src:n,alt:`Preview`}),t[2]=n,t[3]=r),r},iP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`audio`,{controls:!0,src:n}),t[2]=n,t[3]=r),r},aP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`video`,{controls:!0,src:n}),t[2]=n,t[3]=r),r},oP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`iframe`,{src:n,title:`PDF Viewer`,className:`w-full h-full`}),t[2]=n,t[3]=r),r},sP=e=>{let t=(0,U.c)(11),n,r;if(t[0]===e?(n=t[1],r=t[2]):({mimeType:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n.startsWith(`image/`)){let e;return t[3]===r?e=t[4]:(e=(0,H.jsx)(rP,{...r}),t[3]=r,t[4]=e),e}if(n.startsWith(`audio/`)){let e;return t[5]===r?e=t[6]:(e=(0,H.jsx)(iP,{...r}),t[5]=r,t[6]=e),e}if(n.startsWith(`video/`)){let e;return t[7]===r?e=t[8]:(e=(0,H.jsx)(aP,{...r}),t[7]=r,t[8]=e),e}if(n.startsWith(`application/pdf`)){let e;return t[9]===r?e=t[10]:(e=(0,H.jsx)(oP,{...r}),t[9]=r,t[10]=e),e}return null},cP=[],lP=e=>{let t=(0,U.c)(18),{mimeType:n,filename:r,contents:i,mediaSource:a,readOnly:o,onChange:s,extensions:c}=e,l=o===void 0||o,u=c===void 0?cP:c,{theme:d}=ci();if(n===`text/csv`&&i!=null){let e;return t[0]===i?e=t[1]:(e=(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden flex flex-col`,children:(0,H.jsx)(nP,{contents:i})}),t[0]=i,t[1]=e),e}if(YN(n)&&a){let e;return t[2]!==a||t[3]!==n?(e=(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden flex flex-col`,children:(0,H.jsx)(sP,{...a,mimeType:n})}),t[2]=a,t[3]=n,t[4]=e):e=t[4],e}if(i!=null){let e;t[5]!==r||t[6]!==n?(e=$N(n,r),t[5]=r,t[6]=n,t[7]=e):e=t[7];let a=e,o=d===`dark`?`dark`:`light`,c;t[8]===u?c=t[9]:(c=[Ht.lineWrapping,...u],t[8]=u,t[9]=c);let f=!l&&void 0,p=l?void 0:s,m;return t[10]!==i||t[11]!==a||t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==f||t[16]!==p?(m=(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,H.jsx)(V.Suspense,{children:(0,H.jsx)(Qt,{theme:o,language:a,className:`border-b`,extensions:c,value:i,readOnly:l,editable:f,onChange:p})})}),t[10]=i,t[11]=a,t[12]=l,t[13]=o,t[14]=c,t[15]=f,t[16]=p,t[17]=m):m=t[17],m}return null};function uP(e,t){let{state:n}=e,r=n.doc;if(t<=0||t>r.lines)return be.warn(`Invalid line number: ${t}. Document has ${r.lines} lines.`),!1;let i=r.line(t);if(i.text.includes(`breakpoint()`))return!0;let a=i.text.match(/^(\s*)/),o=`${a?a[1]:``}breakpoint()\n`,s=i.from;return e.dispatch({changes:{from:s,to:s,insert:o},selection:{anchor:s+o.length-1,head:s+o.length-1},scrollIntoView:!0,effects:[Ht.scrollIntoView(s,{y:`center`})]}),e.focus(),!0}var dP=e=>{let t=(0,U.c)(51),{onRefactorWithAI:n,traceback:r,cellId:i}=e,a;t[0]===r?a=t[1]:(a=Ui({html:r,additionalReplacements:[pP,hP,mP]}),t[0]=r,t[1]=a);let o=a,c;t[2]===r?c=t[3]:(c=fP(r),t[2]=r,t[3]=c);let l=c,u=s(ve),d=Qr(),f;t[4]===r?f=t[5]:(f=de(r)?.at(0),t[4]=r,t[5]=f);let p=f,m;t[6]!==i||t[7]!==p?(m=p&&p.kind===`cell`&&!Te()&&!De()&&i!==`__scratch__`,t[6]=i,t[7]=p,t[8]=m):m=t[8];let h=m,g;t[9]!==u||t[10]!==n?(g=n&&u&&!De(),t[9]=u,t[10]=n,t[11]=g):g=t[11];let _=g,v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=De(),t[12]=v):v=t[12];let y=!v,[b,x]=(0,V.useState)(!0),S;t[13]!==l||t[14]!==n?(S=e=>{n?.({prompt:`My code gives the following error:\n\n${l}`,triggerImmediately:e})},t[13]=l,t[14]=n,t[15]=S):S=t[15];let C=S,w;t[16]!==i||t[17]!==l||t[18]!==d?(w=()=>{d({prompt:Jr(i,l)})},t[16]=i,t[17]=l,t[18]=d,t[19]=w):w=t[19];let T=w,E;t[20]===b?E=t[21]:(E=()=>x(!b),t[20]=b,t[21]=E);let D=b?`Collapse traceback`:`Expand traceback`,O;t[22]===b?O=t[23]:(O=b?(0,H.jsx)(an,{className:`h-3 w-3`}):(0,H.jsx)(ln,{className:`h-3 w-3`}),t[22]=b,t[23]=O);let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wider`,children:`Traceback`}),t[24]=k):k=t[24];let A;t[25]!==b||t[26]!==D||t[27]!==O||t[28]!==E?(A=(0,H.jsxs)(`button`,{type:`button`,onClick:E,"aria-expanded":b,"aria-label":D,className:`self-start flex items-center gap-1 pt-2 text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:[O,k]}),t[25]=b,t[26]=D,t[27]=O,t[28]=E,t[29]=A):A=t[29];let j;t[30]!==o||t[31]!==b?(j=b&&(0,H.jsx)(`div`,{className:`text-muted-foreground pr-4 text-xs overflow-auto`,children:o}),t[30]=o,t[31]=b,t[32]=j):j=t[32];let M;t[33]!==C||t[34]!==T||t[35]!==_?(M=_&&(0,H.jsx)(Xr,{tooltip:`Fix with AI`,openPrompt:()=>C(!1),applyAutofix:()=>C(!0),openChat:T}),t[33]=C,t[34]=T,t[35]=_,t[36]=M):M=t[36];let N;t[37]!==h||t[38]!==p?(N=h&&(0,H.jsx)(zt,{content:`Attach pdb to the exception point.`,children:(0,H.jsxs)(z,{size:`xs`,variant:`outline`,onClick:()=>{Xt().sendPdb({cellId:p.cellId})},children:[(0,H.jsx)(So,{className:`h-3 w-3 mr-2`}),`Launch debugger`]})}),t[37]=h,t[38]=p,t[39]=N):N=t[39];let P;t[40]!==l||t[41]!==r?(P=y&&(0,H.jsxs)(Ct,{children:[(0,H.jsx)(bt,{asChild:!0,children:(0,H.jsxs)(z,{size:`xs`,variant:`text`,children:[`Get help`,(0,H.jsx)(an,{className:`h-3 w-3 ml-1`})]})}),(0,H.jsxs)(xt,{align:`end`,className:`w-56`,children:[(0,H.jsx)(ut,{asChild:!0,children:(0,H.jsxs)(`a`,{target:`_blank`,href:`https://www.google.com/search?q=${encodeURIComponent(l)}`,rel:`noreferrer`,children:[(0,H.jsx)(cr,{className:`h-4 w-4 mr-2`}),`Search on Google`,(0,H.jsx)(Cn,{className:`h-3 w-3 ml-auto`})]})}),(0,H.jsx)(ut,{asChild:!0,children:(0,H.jsxs)(`a`,{target:`_blank`,href:`https://marimo.io/discord?ref=notebook`,rel:`noopener`,children:[(0,H.jsx)(An,{className:`h-4 w-4 mr-2`}),`Ask in Discord`,(0,H.jsx)(Cn,{className:`h-3 w-3 ml-auto`})]})}),(0,H.jsxs)(ut,{onClick:()=>{let e=document.createElement(`div`);e.innerHTML=oe(r);let t=e.textContent||``;Vi(t)},children:[(0,H.jsx)(bn,{className:`h-4 w-4 mr-2`}),`Copy to clipboard`]})]})]}),t[40]=l,t[41]=r,t[42]=P):P=t[42];let F;t[43]!==M||t[44]!==N||t[45]!==P?(F=(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[M,N,P]}),t[43]=M,t[44]=N,t[45]=P,t[46]=F):F=t[46];let ee;return t[47]!==A||t[48]!==j||t[49]!==F?(ee=(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-full w-fit`,children:[A,j,F]}),t[47]=A,t[48]=j,t[49]=F,t[50]=ee):ee=t[50],ee};function fP(e){let t=document.createElement(`div`);return t.innerHTML=oe(e),(t.textContent?.split(`
|
|
49
|
+
color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return o.updateDeps=e=>{r=e},o}function tM(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nM=(e,t)=>Math.abs(e-t)<1.01,rM=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iM=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},aM=e=>e,oM=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},sM=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(iM(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(iM(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},cM={passive:!0},lM=typeof window>`u`||`onscrollend`in window,uM=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=0,a=e.options.useScrollendEvent&&lM?()=>void 0:rM(r,()=>{t(i,!1)},e.options.isScrollingResetDelay),o=r=>()=>{let{horizontal:o,isRtl:s}=e.options;i=o?n.scrollLeft*(s&&-1||1):n.scrollTop,a(),t(i,r)},s=o(!0),c=o(!1);n.addEventListener(`scroll`,s,cM);let l=e.options.useScrollendEvent&&lM;return l&&n.addEventListener(`scrollend`,c,cM),()=>{n.removeEventListener(`scroll`,s),l&&n.removeEventListener(`scrollend`,c)}},dM=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},fM=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},pM=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:aM,rangeExtractor:oM,onChange:()=>{},measureElement:dM,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 t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=eM(()=>(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=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,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,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=eM(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,n,r,i,a)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a}),{key:!1}),this.getMeasurements=eM(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a},o)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);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(e=>{this.itemSizeCache.set(e.key,e.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 c=this.measurementsCache.slice(0,s),l=Array(a).fill(void 0);for(let e=0;e<s;e++){let t=c[e];t&&(l[t.lane]=e)}for(let i=s;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,u;if(a!==void 0&&this.options.lanes>1){s=a;let e=l[s],r=e===void 0?void 0:c[e];u=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?c[i-1]:this.getFurthestMeasurement(c,i);u=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(i,s)}let d=o.get(e),f=typeof d==`number`?d:this.options.estimateSize(i),p=u+f;c[i]={index:i,start:u,size:f,end:p,key:e,lane:s},l[s]=i}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=eM(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?hM({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eM(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),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(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.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,t)),this.notify(!1))},this.getVirtualItems=eM(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length!==0)return tM(t[mM(0,t.length-1,e=>tM(t[e]).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,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&nM(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=t,this.scrollState.behavior=`auto`,this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},mM=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function hM({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,a=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let o=mM(0,i,a,n),s=o;if(r===1)for(;s<i&&e[s].end<n+t;)s++;else if(r>1){let a=Array(r).fill(0);for(;s<i&&a.some(e=>e<n+t);){let t=e[s];a[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(i,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var gM=typeof document<`u`?V.useLayoutEffect:V.useEffect;function _M({useFlushSync:e=!0,...t}){let n=V.useReducer(()=>({}),{})[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,ho.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=V.useState(()=>new pM(r));return i.setOptions(r),gM(()=>i._didMount(),[]),gM(()=>i._willUpdate()),i}function vM(e){return _M({observeElementRect:sM,observeElementOffset:uM,scrollToFn:fM,...e})}var yM=no,bM=ro,xM=Ie(io),SM=Fe(ao),CM=Fe(mo),wM=V.forwardRef((e,t)=>{let n=(0,U.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:i,inset:a,children:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==i||n[6]!==a?(s=We({className:i,inset:a}),n[5]=i,n[6]=a,n[7]=s):s=n[7];let c;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,H.jsx)($i,{className:`ml-auto h-4 w-4`}),n[8]=c):c=n[8];let l;return n[9]!==r||n[10]!==o||n[11]!==t||n[12]!==s?(l=(0,H.jsxs)(po,{ref:t,className:s,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=t,n[12]=s,n[13]=l):l=n[13],l});wM.displayName=po.displayName;var TM=`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`,EM=V.forwardRef((e,t)=>{let n=(0,U.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=R(Ke({subcontent:!0}),TM,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,H.jsx)(CM,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});EM.displayName=mo.displayName;var DM=V.forwardRef((e,t)=>{let n=(0,U.c)(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,scrollable:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=a===void 0||a,s;n[4]!==r||n[5]!==o?(s=R(Ke(),TM,o&&`overflow-auto`,r),n[4]=r,n[5]=o,n[6]=s):s=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${ze}px)`:void 0,l;n[7]!==i.style||n[8]!==c?(l={...i.style,maxHeight:c},n[7]=i.style,n[8]=c,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==t||n[12]!==s||n[13]!==l?(u=(0,H.jsx)(xM,{children:(0,H.jsx)(Re,{children:(0,H.jsx)(SM,{ref:t,className:s,style:l,...i})})}),n[10]=i,n[11]=t,n[12]=s,n[13]=l,n[14]=u):u=n[14],u});DM.displayName=ao.displayName;var OM=V.forwardRef((e,t)=>{let n=(0,U.c)(13),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:r,inset:i,variant:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]!==r||n[6]!==i||n[7]!==o?(s=Ge({className:r,inset:i,variant:o}),n[5]=r,n[6]=i,n[7]=o,n[8]=s):s=n[8];let c;return n[9]!==a||n[10]!==t||n[11]!==s?(c=(0,H.jsx)(so,{ref:t,className:s,...a}),n[9]=a,n[10]=t,n[11]=s,n[12]=c):c=n[12],c});OM.displayName=so.displayName;var kM=V.forwardRef((e,t)=>{let n=(0,U.c)(15),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,children:i,checked:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s;n[5]===a?s=n[6]:(s=Ve({className:a}),n[5]=a,n[6]=s);let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=Ue(),n[7]=c):c=n[7];let l;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,H.jsx)(`span`,{className:c,children:(0,H.jsx)(uo,{children:(0,H.jsx)(Zi,{className:`h-4 w-4`})})}),n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==i||n[11]!==o||n[12]!==t||n[13]!==s?(u=(0,H.jsxs)(co,{ref:t,className:s,checked:r,...o,children:[l,i]}),n[9]=r,n[10]=i,n[11]=o,n[12]=t,n[13]=s,n[14]=u):u=n[14],u});kM.displayName=co.displayName;var AM=V.forwardRef((e,t)=>{let n=(0,U.c)(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:i,children:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]===i?o=n[5]:(o=Ue({className:i}),n[4]=i,n[5]=o);let s;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=Ue(),n[6]=s):s=n[6];let c;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,H.jsx)(`span`,{className:s,children:(0,H.jsx)(uo,{children:(0,H.jsx)(Xi,{className:`h-4 w-4 fill-current`})})}),n[7]=c):c=n[7];let l;return n[8]!==r||n[9]!==a||n[10]!==t||n[11]!==o?(l=(0,H.jsxs)(lo,{ref:t,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=t,n[11]=o,n[12]=l):l=n[12],l});AM.displayName=lo.displayName;var jM=V.forwardRef((e,t)=>{let n=(0,U.c)(11),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,inset:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==r||n[5]!==i?(o=qe({className:r,inset:i}),n[4]=r,n[5]=i,n[6]=o):o=n[6];let s;return n[7]!==a||n[8]!==t||n[9]!==o?(s=(0,H.jsx)(oo,{ref:t,className:o,...a}),n[7]=a,n[8]=t,n[9]=o,n[10]=s):s=n[10],s});jM.displayName=oo.displayName;var MM=V.forwardRef((e,t)=>{let n=(0,U.c)(9),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=R(He({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==t||n[7]!==a?(o=(0,H.jsx)(fo,{ref:t,className:a,...i}),n[5]=i,n[6]=t,n[7]=a,n[8]=o):o=n[8],o});MM.displayName=fo.displayName;var NM=e=>{let t=(0,U.c)(12),{contextMenuRef:n,tableBody:r,tableRef:i,copyAllCells:a}=e,o;t[0]!==n||t[1]!==i?(o=e=>{let t=n.current;if(!t)return;let r=i.current?.querySelector(`[${k}="${t.id}"]`);if(!r){be.error(`Context menu cell not found in table`);return}e?r.classList.add(`bg-(--green-4)`):r.classList.remove(`bg-(--green-4)`)},t[0]=n,t[1]=i,t[2]=o):o=t[2];let s=d(o),c;t[3]===r?c=t[4]:(c=(0,H.jsx)(bM,{asChild:!0,children:r}),t[3]=r,t[4]=c);let l;t[5]!==n||t[6]!==a?(l=(0,H.jsx)(xM,{children:(0,H.jsx)(PM,{cellRef:n,copySelectedCells:a})}),t[5]=n,t[6]=a,t[7]=l):l=t[7];let u;return t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,H.jsxs)(yM,{onOpenChange:s,children:[c,l]}),t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u},PM=({cellRef:e,copySelectedCells:t})=>{let n=s(Yj).size>1,r=e.current;if(!r){be.error(`No cell found in context menu`);return}let i=r.getContext().table,a=r.getValue(),o=pE(i,r.row.index,r.column.id)??a,c=()=>{try{let{text:e,html:t}=fE(o,a);Vi(e,t)}catch(e){be.error(`Failed to copy context menu cell`,e)}},l=r.column,u=l.columnDef.meta?.filterType,d=l.getCanFilter()&&u&&IT(u)?u:void 0,f=(e,t)=>{let n=e===`number`?mT.number({operator:t,values:[o]}):mT.text({operator:t,values:[o]});l.setFilterValue(n)};return(0,H.jsxs)(DM,{children:[(0,H.jsxs)(OM,{onClick:c,children:[(0,H.jsx)(bn,{className:`mo-dropdown-icon h-3 w-3`}),`Copy cell`]}),n&&(0,H.jsxs)(OM,{onClick:t,children:[(0,H.jsx)(Ro,{className:`mo-dropdown-icon h-3 w-3`}),`Copy selected cells`]}),d&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(MM,{}),(0,H.jsxs)(OM,{onClick:()=>f(d,`in`),children:[(0,H.jsx)(jo,{className:`mo-dropdown-icon h-3 w-3`}),`Filter by this value`]}),(0,H.jsxs)(OM,{onClick:()=>f(d,`not_in`),children:[(0,H.jsx)(jo,{className:`mo-dropdown-icon h-3 w-3`}),`Remove rows with this value`]})]})]})},FM=e=>{let t=(0,U.c)(15),{state:n,contentId:r,onClose:i}=e,a=n!=null,o;t[0]===i?o=t[1]:(o=e=>{e||i()},t[0]=i,t[1]=o);let s=n?.rect.top??0,c=n?.rect.left??0,l=n?.rect.width??0,u=n?.rect.height??0,d;t[2]!==s||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,H.jsx)(Lt,{asChild:!0,children:(0,H.jsx)(`div`,{"aria-hidden":!0,style:{position:`fixed`,top:s,left:c,width:l,height:u,pointerEvents:`none`}})}),t[2]=s,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6];let f=n?.content,p;t[7]!==r||t[8]!==f?(p=(0,H.jsx)(Rt,{children:(0,H.jsx)(It,{id:r,children:f})}),t[7]=r,t[8]=f,t[9]=p):p=t[9];let m;return t[10]!==a||t[11]!==o||t[12]!==d||t[13]!==p?(m=(0,H.jsxs)(Ft,{open:a,onOpenChange:o,delayDuration:0,disableHoverableContent:!0,children:[d,p]}),t[10]=a,t[11]=o,t[12]=d,t[13]=p,t[14]=m):m=t[14],m};function IM(e,t){let n=/{{(\w+)}}/g,r=new Map;for(let e of t){let t=lE({value:e.getValue(),nullAsEmptyString:!0});r.set(e.column.id,t)}return e.replaceAll(n,(e,t)=>{let n=r.get(t);return n===void 0?`{{${t}}}`:n})}function LM(e,t){let n=e.getHoverTitle?.();if(n!=null&&n!==``)return n;if(t)return IM(t,e.row.getVisibleCells())}var RM=400;function zM(e){let t=(0,U.c)(33),{table:n}=e,r;t[0]===n?r=t[1]:(r=n.getState().cellHoverTemplate||null,t[0]=n,t[1]=r);let i=r,[a,o]=(0,V.useState)(null),s=(0,V.useRef)(null),c=(0,V.useId)(),l=(0,V.useRef)(null),u=(0,V.useRef)(!1),f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{s.current!=null&&(clearTimeout(s.current),s.current=null)},t[2]=f):f=t[2];let p=f,m;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(),o(null)},t[3]=m):m=t[3];let h=d(m),g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{l.current=e;let n=e.getBoundingClientRect();o({rect:{top:n.top,left:n.left,width:n.width,height:n.height},content:t})},t[4]=g):g=t[4];let _=g,v,y;t[5]!==c||t[6]!==a?(v=()=>{if(!a)return;let e=l.current;return e?.setAttribute(`aria-describedby`,c),()=>e?.removeAttribute(`aria-describedby`)},y=[a,c],t[5]=c,t[6]=a,t[7]=v,t[8]=y):(v=t[7],y=t[8]),(0,V.useLayoutEffect)(v,y);let b,x;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{let e=()=>{u.current=!0},t=()=>{u.current=!1};return window.addEventListener(`mousedown`,e,{capture:!0}),window.addEventListener(`mouseup`,t,{capture:!0}),()=>{window.removeEventListener(`mousedown`,e,{capture:!0}),window.removeEventListener(`mouseup`,t,{capture:!0})}},x=[],t[9]=b,t[10]=x):(b=t[9],x=t[10]),(0,V.useEffect)(b,x);let S;t[11]!==h||t[12]!==i?(S=(e,t)=>{if(e.buttons!==0)return;let n=e.currentTarget,r=LM(t,i);if(r==null||r===``){h();return}p(),s.current=window.setTimeout(()=>_(n,r),RM)},t[11]=h,t[12]=i,t[13]=S):S=t[13];let C=d(S),w;t[14]===h?w=t[15]:(w=()=>h(),t[14]=h,t[15]=w);let T=d(w),E;t[16]===i?E=t[17]:(E=(e,t)=>{if(p(),u.current)return;let n=LM(t,i);n!=null&&n!==``&&_(e.currentTarget,n)},t[16]=i,t[17]=E);let D=d(E),O;t[18]===h?O=t[19]:(O=()=>h(),t[18]=h,t[19]=O);let k=d(O),A,j;t[20]===h?(A=t[21],j=t[22]):(A=()=>(window.addEventListener(`scroll`,h,{passive:!0,capture:!0}),window.addEventListener(`resize`,h),()=>{window.removeEventListener(`scroll`,h,{capture:!0}),window.removeEventListener(`resize`,h)}),j=[h],t[20]=h,t[21]=A,t[22]=j),(0,V.useEffect)(A,j);let M,N;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p,N=[],t[23]=M,t[24]=N):(M=t[23],N=t[24]),(0,V.useEffect)(M,N);let P;return t[25]!==k||t[26]!==D||t[27]!==T||t[28]!==C||t[29]!==h||t[30]!==c||t[31]!==a?(P={tooltipState:a,tooltipContentId:c,hideTooltip:h,handleCellMouseOver:C,handleCellMouseLeave:T,handleCellFocus:D,handleCellBlur:k},t[25]=k,t[26]=D,t[27]=T,t[28]=C,t[29]=h,t[30]=c,t[31]=a,t[32]=P):P=t[32],P}var BM=(0,V.memo)(e=>{let t=(0,U.c)(9),{cellId:n,className:r}=e,i;t[0]===n?i=t[1]:(i=Zj(n),t[0]=n,t[1]=i);let{isSelected:a,isCopied:o}=s(i);if(!a&&!o)return null;let c=a&&`bg-(--green-3)`,l=o&&`bg-(--green-4) transition-colors duration-150`,u;t[2]!==r||t[3]!==c||t[4]!==l?(u=R(`absolute inset-0 pointer-events-none`,c,l,r),t[2]=r,t[3]=c,t[4]=l,t[5]=u):u=t[5];let d;return t[6]!==n||t[7]!==u?(d=(0,H.jsx)(`div`,{"data-cell-id":n,className:u}),t[6]=n,t[7]=u,t[8]=d):d=t[8],d});BM.displayName=`CellRangeSelectionIndicator`;var VM=e=>{let t=(0,U.c)(30),{table:n}=e,r=Kj(),i;t[0]!==r||t[1]!==n?(i=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=d(i),o;t[3]!==r||t[4]!==n?(o=(e,t)=>{r.updateSelection({newCell:e,isShiftKey:t,table:n})},t[3]=r,t[4]=n,t[5]=o):o=t[5];let s=d(o),c;t[6]!==r||t[7]!==n?(c=(e,t)=>{r.navigate({direction:t,isShiftKey:e.shiftKey,table:n})},t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=d(c),u;t[9]!==r||t[10]!==a||t[11]!==l||t[12]!==n?(u=e=>{bb7:switch(e.key){case`c`:Vt.isMetaOrCtrl(e)&&a();break bb7;case`ArrowDown`:e.preventDefault(),l(e,`down`);break bb7;case`ArrowUp`:e.preventDefault(),l(e,`up`);break bb7;case`ArrowLeft`:e.preventDefault(),l(e,`left`);break bb7;case`ArrowRight`:e.preventDefault(),l(e,`right`);break bb7;case`Enter`:e.preventDefault(),r.toggleCurrentRowSelection(n);break bb7;case`Escape`:r.clearSelection();break bb7;case`a`:(e.metaKey||e.ctrlKey)&&(e.preventDefault(),r.selectAllCells(n))}},t[9]=r,t[10]=a,t[11]=l,t[12]=n,t[13]=u):u=t[13];let f=d(u),p;t[14]!==r||t[15]!==n?(p=(e,t)=>{e.buttons!==2&&(WM(e)||r.handleCellMouseDown({cell:t,isShiftKey:e.shiftKey,isCtrlKey:e.ctrlKey,table:n}))},t[14]=r,t[15]=n,t[16]=p):p=t[16];let m=d(p),h;t[17]===r?h=t[18]:(h=()=>{r.setIsSelecting(!1)},t[17]=r,t[18]=h);let g=d(h),_;t[19]!==r||t[20]!==n?(_=(e,t)=>{e.buttons===1&&r.updateRangeSelection({cell:t,table:n})},t[19]=r,t[20]=n,t[21]=_):_=t[21];let v=d(_),y;return t[22]!==r.clearSelection||t[23]!==m||t[24]!==v||t[25]!==g||t[26]!==f||t[27]!==a||t[28]!==s?(y={handleCellMouseDown:m,handleCellMouseUp:g,handleCellMouseOver:v,handleCopy:a,handleCellsKeyDown:f,updateSelection:s,clearSelection:r.clearSelection},t[22]=r.clearSelection,t[23]=m,t[24]=v,t[25]=g,t[26]=f,t[27]=a,t[28]=s,t[29]=y):y=t[29],y},HM=`input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element`,UM=new Set([`marimo-lazy`,`marimo-routes`]);function WM(e){let t=typeof e.nativeEvent?.composedPath==`function`?e.nativeEvent.composedPath():[e.target];for(let n of t){if(n===e.currentTarget)break;if(!(!(n instanceof Element)||!n.matches(HM))){if(n.localName===`marimo-ui-element`){let e=n.firstElementChild;if(e&&UM.has(e.localName))continue}return!0}}return!1}var GM=i(e=>e(Gj).focusedCell);function KM(e){let t=(0,U.c)(2),n;t[0]===e?n=t[1]:(n=t=>{t?.cellId&&setTimeout(()=>{let n=e.current?.querySelector(`[data-cell-id="${t.cellId}"]`);if(!n){be.warn(`[ScrollIntoView] Could not find cell with ID:`,t.cellId);return}n.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`})},0)},t[0]=e,t[1]=n),o(GM,n)}function qM(e,t){if(!e.getRowModel().rows?.length)return null;let n=t=>t.map(t=>t.headers.map(t=>{let{className:n,style:r}=YM(t.column);return(0,H.jsx)(pa,{className:R(`h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75`,n),style:r,ref:n=>{XM({table:e,column:t.column,thead:n})},children:t.isPlaceholder?null:LD(t.column.columnDef.header,t.getContext())},t.id)}));return(0,H.jsx)(fa,{className:R(t&&`sticky top-0 z-10`),children:(0,H.jsxs)(ha,{children:[n(e.getLeftHeaderGroups()),n(e.getCenterHeaderGroups()),n(e.getRightHeaderGroups()),e.getAllColumns().length<=4&&(0,H.jsx)(`th`,{className:`w-full border-0`,"aria-hidden":`true`})]})})}var JM=({table:e,columns:t,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:i,virtualize:a=!1})=>{let o=e.getRowModel().rows,[s,c]=(0,V.useState)(null),l=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{c(l.current?.parentElement?.parentElement??null)},[]);let u=vM({count:a?o.length:0,getScrollElement:()=>s,estimateSize:()=>24,overscan:10});KM(l);let{handleCellMouseDown:f,handleCellMouseUp:p,handleCellMouseOver:h,handleCellsKeyDown:g,handleCopy:_}=VM({table:e}),v=(0,V.useRef)(null),y=d(e=>{v.current=e}),b=zM({table:e}),x=e=>e.map(e=>{let{className:t,style:n}=YM(e.column),r=e.column.columnDef.meta?.width,i=Object.assign({},e.getUserStyling?.()||{},n);return(0,V.createElement)(ga,{tabIndex:0,...m(e.id),key:e.id,className:R(`whitespace-pre truncate outline-hidden border-r border-r-border/75`,!r&&`max-w-[300px]`,e.column.getColumnWrapping&&e.column.getColumnWrapping?.()===`wrap`&&`whitespace-pre-wrap min-w-[200px]`,`px-1.5 py-[0.18rem]`,t),style:i,onMouseDown:t=>{f(t,e),b.hideTooltip()},onMouseUp:p,onMouseOver:t=>{h(t,e),b.handleCellMouseOver(t,e)},onMouseLeave:b.handleCellMouseLeave,onFocus:t=>b.handleCellFocus(t,e),onBlur:b.handleCellBlur,onContextMenu:()=>y(e)},(0,H.jsx)(BM,{cellId:e.id}),(0,H.jsx)(`div`,{className:`relative`,children:LD(e.column.columnDef.cell,e.getContext())}))}),S=e=>{if(n){let t=r?.(e.original,e.index)??e.index;e.focusRow?.(t)}},C=e=>{let a=n?r?.(e.original,e.index)??e.index:void 0,o=n&&i===a;return(0,H.jsxs)(ha,{"data-state":e.getIsSelected()&&`selected`,className:R(`border-t h-6`,n&&`cursor-pointer`,o&&`bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)`),onClick:()=>S(e),children:[x(e.getLeftVisibleCells()),x(e.getCenterVisibleCells()),x(e.getRightVisibleCells()),t.length<=4&&(0,H.jsx)(`td`,{className:`border-0`,"aria-hidden":`true`})]},e.id)},w=t.length<=4,T=t.length+ +!!w,E=(0,H.jsx)(ma,{onKeyDown:g,ref:l,children:(()=>{if(o.length===0)return(0,H.jsx)(ha,{children:(0,H.jsx)(ga,{colSpan:T,className:`h-24 text-center`,children:`No results.`})});if(a){let e=u.getVirtualItems(),t=u.getTotalSize();return(0,H.jsxs)(H.Fragment,{children:[e[0]?.start>0&&(0,H.jsx)(`tr`,{"data-virtual-spacer":``,style:{height:e[0].start},children:(0,H.jsx)(`td`,{"aria-hidden":`true`,colSpan:T})}),e.map(e=>C(o[e.index])),e.length>0&&(0,H.jsx)(`tr`,{"data-virtual-spacer":``,style:{height:t-(e.at(-1)?.end??t)},children:(0,H.jsx)(`td`,{"aria-hidden":`true`,colSpan:T})})]})}return o.map(e=>C(e))})()});return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(NM,{tableBody:E,contextMenuRef:v,tableRef:l,copyAllCells:_}),(0,H.jsx)(FM,{state:b.tooltipState,contentId:b.tooltipContentId,onClose:b.hideTooltip})]})};function YM(e){let t=e.getIsPinned(),n=t===`left`&&e.getIsLastColumn(`left`),r=t===`right`&&e.getIsFirstColumn(`right`),i=e.columnDef.meta?.width;return{className:R(t&&`bg-inherit`,`shadow-r z-10`),style:{boxShadow:n&&e.id!==`__select__`?`-4px 0 4px -4px var(--slate-8) inset`:r?`4px 0 4px -4px var(--slate-8) inset`:void 0,left:t===`left`?`${e.getStart(`left`)}px`:void 0,right:t===`right`?`${e.getAfter(`right`)}px`:void 0,opacity:1,position:t?`sticky`:`relative`,zIndex:+!!t,width:e.getSize(),...i?{minWidth:i,maxWidth:i}:{}}}}function XM({table:e,column:t,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);e.getState().columnSizing[t.id]!==r&&e.setColumnSizing(e=>({...e,[t.id]:r}))}function ZM(e){let[t,n]=_j(Object.fromEntries((e??[]).map(e=>[e,!1])),l);return{columnVisibility:t,setColumnVisibility:n}}function QM(e){let t=e.getAllLeafColumns().filter(e=>e.getCanHide()),n=t.filter(e=>e.getIsVisible()).length;return{total:t.length,visible:n,hidden:t.length-n}}function $M(e,t){let n=QM(e);return{totalColumns:n.hidden>0?n.total:t,hiddenColumns:n.hidden}}function eN(e,t){let n=new Set(t),r={};for(let t of e.getAllLeafColumns())t.getCanHide()&&(r[t.id]=n.has(t.id));return r}function tN(e,t){e.setColumnVisibility(n=>({...n,...eN(e,t)}))}function nN(e){let t=[],n=[];for(let r of e.getAllLeafColumns())r.getCanHide()&&(t.push(r.id),r.getIsVisible()&&n.push(r.id));return{visibleHideableColumnIds:n,hideableColumnIdSet:new Set(t)}}function rN(e,t){let n=new Set(t.filter(t=>e.hideableColumnIdSet.has(t)));return e.visibleHideableColumnIds.length===n.size&&e.visibleHideableColumnIds.every(e=>n.has(e))}var iN=({table:e,tableLoading:t,showPageSizeSelector:n})=>{let{locale:r}=B(),i=Math.min(e.getState().pagination.pageIndex+1,e.getPageCount()),a=e.getPageCount(),o=e.getState().pagination.pageSize,s=e=>{t||e()},c=[...new Set([5,10,25,50,100,o])].toSorted((e,t)=>e-t);return(0,H.jsxs)(`div`,{className:`flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2`,children:[(0,H.jsx)(`div`,{className:`order-2 lg:order-first`,children:n&&(0,H.jsx)(`div`,{className:`flex items-center text-xs whitespace-nowrap mr-1 print:hidden`,children:(0,H.jsxs)(Ct,{children:[(0,H.jsx)(bt,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,className:`border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5`,children:[o,` / page`,(0,H.jsx)(an,{className:`h-3 w-3 opacity-50 mb-px`})]})}),(0,H.jsxs)(xt,{align:`center`,sideOffset:6,children:[(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Rows per page`}),[...c].map(t=>(0,H.jsx)(ut,{className:R(`text-xs cursor-pointer`,t===o&&`font-semibold bg-accent`),onSelect:()=>e.setPageSize(t),onMouseDown:Vt.preventFocus,children:t},t))]})]})})}),(0,H.jsxs)(`div`,{className:`order-1 lg:order-last flex items-center print:hidden`,children:[(0,H.jsx)(zt,{content:`First page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`first-page-button`,className:`hidden h-6 w-5 p-0 lg:flex`,onClick:()=>s(()=>e.setPageIndex(0)),onMouseDown:Vt.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,H.jsx)(wo,{className:`h-4 w-4`})})}),(0,H.jsx)(zt,{content:`Previous page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`previous-page-button`,className:`h-6 w-5 p-0`,onClick:()=>s(()=>e.previousPage()),onMouseDown:Vt.preventFocus,disabled:!e.getCanPreviousPage(),children:(0,H.jsx)(Mt,{className:`h-4 w-4`})})}),(0,H.jsxs)(`div`,{className:`flex items-center justify-center text-xs font-medium gap-1`,children:[(0,H.jsx)(`span`,{children:`Page`}),(0,H.jsx)(cN,{currentPage:i,totalPages:a,onPageChange:t=>s(()=>e.setPageIndex(t))}),(0,H.jsxs)(`span`,{className:`shrink-0`,children:[`of `,ki(a,r)]})]}),(0,H.jsx)(zt,{content:`Next page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`next-page-button`,className:`h-6 w-5 p-0`,onClick:()=>s(()=>e.nextPage()),onMouseDown:Vt.preventFocus,disabled:!e.getCanNextPage(),children:(0,H.jsx)(ln,{className:`h-4 w-4`})})}),(0,H.jsx)(zt,{content:`Last page`,children:(0,H.jsx)(z,{size:`xs`,variant:`text`,"data-testid":`last-page-button`,className:`hidden h-6 w-5 p-0 lg:flex`,onClick:()=>s(()=>e.setPageIndex(e.getPageCount()-1)),onMouseDown:Vt.preventFocus,disabled:!e.getCanNextPage(),children:(0,H.jsx)(To,{className:`h-4 w-4`})})})]})]})},aN=32;function oN(e,t){let n=Number.parseInt(e,10);if(Number.isNaN(n)||n<=0||String(n)!==e)return[];let r=[],i=1;for(;n*i<=t;){let e=n*i,a=Math.min((n+1)*i-1,t);r.push([e,a]),i*=10}return r}function sN(e,t){if(e===``)return{count:t,pageAtIndex:e=>e+1,indexOfPage:e=>e-1};let n=oN(e,t),r=0;for(let[e,t]of n)r+=t-e+1;return{count:r,pageAtIndex:e=>{let t=0;for(let[r,i]of n){let n=i-r+1;if(e<t+n)return r+(e-t);t+=n}return-1},indexOfPage:e=>{let t=0;for(let[r,i]of n){if(e>=r&&e<=i)return t+(e-r);t+=i-r+1}return-1}}}var cN=({currentPage:e,totalPages:t,onPageChange:n})=>{let[r,i]=V.useState(!1),[a,o]=V.useState(``),s=V.useMemo(()=>sN(a,t),[a,t]),c=e=>{n(e-1),o(``),i(!1)},l=Math.min(s.count*aN,240);return(0,H.jsxs)(I,{open:t>1&&r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,H.jsx)(P,{asChild:!0,disabled:t<=1,children:(0,H.jsxs)(`button`,{type:`button`,className:R(`border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5`,t>1?`hover:bg-accent cursor-pointer`:`opacity-50 cursor-default`),"data-testid":`page-select`,disabled:t<=1,children:[e,(0,H.jsx)(an,{className:`h-3 w-3 opacity-50 mb-px`})]})}),(0,H.jsx)(ae,{className:`w-36 p-0`,align:`center`,sideOffset:6,children:(0,H.jsxs)(pe,{shouldFilter:!1,value:String(e),children:[(0,H.jsx)(A,{placeholder:`Page (1–${t})`,rootClassName:`px-2 h-8`,className:`text-xs h-8`,autoFocus:!0,icon:null,value:a,onValueChange:o,onKeyDown:e=>{![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)&&!/^\d$/.test(e.key)&&e.preventDefault()}}),(0,H.jsx)(me,{className:`max-h-60 overflow-hidden`,children:s.count===0?(0,H.jsx)(te,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No matching page`}):(0,H.jsx)(lN,{mapping:s,currentPage:e,listHeight:l,onSelect:c})})]})})]})},lN=({mapping:e,currentPage:t,listHeight:n,onSelect:r})=>{let i=V.useRef(null),a=e.indexOfPage(t),o=vM({count:e.count,getScrollElement:()=>i.current,estimateSize:()=>aN,overscan:10,initialOffset:a>0?Math.max(0,a*aN-n/2):0}),s=V.useRef(e.count);return V.useEffect(()=>{e.count!==s.current&&(o.scrollToIndex(0),s.current=e.count)},[e.count,o]),(0,H.jsx)(`div`,{ref:i,style:{height:n,overflow:`auto`},children:(0,H.jsx)(`div`,{style:{height:o.getTotalSize(),width:`100%`,position:`relative`},children:o.getVirtualItems().map(n=>{let i=e.pageAtIndex(n.index);return(0,H.jsx)(h,{value:String(i),"data-testid":`page-option`,"aria-selected":i===t,className:R(`text-xs cursor-pointer`,i===t&&`font-semibold bg-accent`),style:{position:`absolute`,top:0,left:0,width:`100%`,height:n.size,transform:`translateY(${n.start}px)`},onSelect:()=>r(i),onMouseDown:Vt.preventFocus,children:i},i)})})})};function uN(e,t){return`${ki(e,t)} ${new ce(`row`).pluralize(e)}`}var dN=({numRows:e,totalColumns:t,hiddenColumns:n,locale:r})=>{let i=e===`too_many`?`Unknown`:uN(e,r),a=n??0,o=t-a;return{rowsAndColumns:[i,a>0?`${ki(o,r)} visible`:`${ki(t,r)} ${new ce(`column`).pluralize(t)}`].join(`, `),hiddenSuffix:a>0?`(${ki(a,r)} hidden)`:null}},fN=3,pN=e=>{let t=(0,U.c)(21),{table:n,className:r}=e,{locale:i}=B(),a=s(Yj),o=zj(a);if(o<2){let e;t[0]===r?e=t[1]:(e=R(`text-xs text-muted-foreground/80 italic`,r),t[0]=r,t[1]=e);let n;return t[2]===e?n=t[3]:(n=(0,H.jsx)(zt,{content:`Select multiple cells to see stats`,children:(0,H.jsx)(`span`,{className:e,children:`No selection`})}),t[2]=e,t[3]=n),n}let c;t[4]!==a||t[5]!==n?(c=Bj(n,a),t[4]=a,t[5]=n,t[6]=c):c=t[6];let l=c,u;t[7]===r?u=t[8]:(u=R(`flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0`,r),t[7]=r,t[8]=u);let d;t[9]!==o||t[10]!==i?(d=(0,H.jsx)(gN,{count:o,locale:i}),t[9]=o,t[10]=i,t[11]=d):d=t[11];let f,p;t[12]!==i||t[13]!==l?(f=(0,H.jsx)(_N,{numericValues:l,locale:i}),p=(0,H.jsx)(vN,{numericValues:l,locale:i}),t[12]=i,t[13]=l,t[14]=f,t[15]=p):(f=t[14],p=t[15]);let m;return t[16]!==u||t[17]!==d||t[18]!==f||t[19]!==p?(m=(0,H.jsxs)(`div`,{className:u,children:[d,f,p]}),t[16]=u,t[17]=d,t[18]=f,t[19]=p,t[20]=m):m=t[20],m},mN=(e,t)=>e.toLocaleString(t,{maximumFractionDigits:fN}),hN=e=>{let t=(0,U.c)(6),{name:n,value:r,locale:i}=e,a;t[0]!==i||t[1]!==r?(a=mN(r,i),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o;return t[3]!==n||t[4]!==a?(o=(0,H.jsxs)(`span`,{children:[n,`: `,a]}),t[3]=n,t[4]=a,t[5]=o):o=t[5],o},gN=e=>{let t=(0,U.c)(3),{count:n,locale:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,H.jsx)(hN,{name:`Count`,value:n,locale:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},_N=e=>{let t=(0,U.c)(6),{numericValues:n,locale:r}=e;if(n.length===0)return null;let i,a;if(t[0]!==n){let e=n.reduce(yN,0);i=Number,a=e.toFixed(fN),t[0]=n,t[1]=i,t[2]=a}else i=t[1],a=t[2];let o=i(a),s;return t[3]!==r||t[4]!==o?(s=(0,H.jsx)(hN,{name:`Sum`,value:o,locale:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},vN=e=>{let t=(0,U.c)(5),{numericValues:n,locale:r}=e;if(n.length===0)return null;let i=n.reduce(bN,0)/n.length,a;t[0]===i?a=t[1]:(a=i.toFixed(fN),t[0]=i,t[1]=a);let o=Number(a),s;return t[2]!==o||t[3]!==r?(s=(0,H.jsx)(hN,{name:`Average`,value:o,locale:r}),t[2]=o,t[3]=r,t[4]=s):s=t[4],s};function yN(e,t){return e+t}function bN(e,t){return e+t}var xN=({pagination:e,totalColumns:t,selection:n,onRowSelectionChange:r,table:i,getRowIds:a,showPageSizeSelector:o,tableLoading:s,part:c,className:l})=>{let{locale:u}=B(),d=De(),f=e=>{if(!r)return;if(!e){r({});return}let t=()=>{let e=Array.from({length:i.getRowCount()},(e,t)=>[t,!0]);r(Object.fromEntries(e))};if(!a){t();return}a({}).then(e=>{if(e.error){ai({title:`Not available`,description:e.error,variant:`danger`});return}e.all_rows?t():r(Object.fromEntries(e.row_ids.map(e=>[e,!0])))})};return(0,H.jsxs)(`div`,{part:c,className:R(`flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0`,l),children:[(0,H.jsxs)(`div`,{className:`flex flex-col text-sm text-muted-foreground px-2 shrink-0`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-1`,children:(()=>{let{rowSelection:e,cellSelection:r}=i.getState(),a=Object.keys(e).length,o=i.getIsAllPageRowsSelected(),s=i.getRowCount(),c=a===s,l=n===`single-cell`||n===`multi-cell`;if(l&&(a=r.length,o=!1,c=!1),o&&!c)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[ki(a,u),` selected`]}),(0,H.jsxs)(z,{size:`xs`,"data-testid":`select-all-button`,variant:`link`,className:`h-4 print:hidden`,onMouseDown:Vt.preventFocus,onClick:()=>f(!0),children:[`Select all `,ki(s,u)]})]});if(a)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[ki(a,u),` selected`]}),(0,H.jsx)(z,{size:`xs`,"data-testid":`clear-selection-button`,variant:`link`,className:`h-4 print:hidden`,onMouseDown:Vt.preventFocus,onClick:()=>{l?i.resetCellSelection&&i.resetCellSelection():f(!1)},children:`Clear selection`})]});let{totalColumns:d,hiddenColumns:p}=$M(i,t),{rowsAndColumns:m,hiddenSuffix:h}=dN({numRows:i.getRowCount(),totalColumns:d,hiddenColumns:p,locale:u});return(0,H.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{children:m}),h&&(0,H.jsx)(`span`,{className:`text-xs`,children:h})]})})()}),(0,H.jsx)(pN,{table:i,className:`lg:hidden`})]}),(0,H.jsx)(`div`,{className:`ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0`,children:e&&!d&&(0,H.jsx)(iN,{table:i,tableLoading:s,showPageSizeSelector:o})}),(0,H.jsx)(`div`,{className:`hidden lg:flex justify-end`,children:(0,H.jsx)(pN,{table:i,className:`px-2`})})]})},SN=e=>{let t=(0,U.c)(2),{isExpanded:n}=e,r;return t[0]===n?r=t[1]:(r=(0,H.jsx)(un,{isExpanded:n,className:`h-3 w-3`}),t[0]=n,t[1]=r),r},CN=e=>{let t=(0,U.c)(6),{children:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`flex gap-1.5 items-center font-bold py-1.5 text-muted-foreground bg-(--slate-2) text-sm`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==i||t[4]!==a?(o=(0,H.jsx)(`div`,{className:a,style:i,children:n}),t[2]=n,t[3]=i,t[4]=a,t[5]=o):o=t[5],o},wN=e=>{let t=(0,U.c)(6),{content:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`text-sm text-muted-foreground py-1`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==i||t[4]!==a?(o=(0,H.jsx)(`div`,{className:a,style:i,children:n}),t[2]=n,t[3]=i,t[4]=a,t[5]=o):o=t[5],o},TN=e=>{let t=(0,U.c)(9),{error:n,style:r,className:i,showIcon:a}=e,o=a===void 0||a,s;t[0]===i?s=t[1]:(s=R(`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`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o&&(0,H.jsx)(sn,{className:`h-4 w-4 mt-0.5`}),t[2]=o,t[3]=c);let l;return t[4]!==n.message||t[5]!==r||t[6]!==s||t[7]!==c?(l=(0,H.jsxs)(`div`,{className:s,style:r,children:[c,n.message]}),t[4]=n.message,t[5]=r,t[6]=s,t[7]=c,t[8]=l):l=t[8],l},EN=e=>{let t=(0,U.c)(7),{message:n,className:r,style:i}=e,a;t[0]===r?a=t[1]:(a=R(`text-sm bg-blue-50 dark:bg-(--accent) text-blue-500 dark:text-blue-50 flex items-center gap-2 p-2 h-8`,r),t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,H.jsx)(On,{className:`h-4 w-4 animate-spin`}),t[2]=o):o=t[2];let s;return t[3]!==n||t[4]!==i||t[5]!==a?(s=(0,H.jsxs)(`div`,{className:a,style:i,children:[o,n]}),t[3]=n,t[4]=i,t[5]=a,t[6]=s):s=t[6],s},DN=e=>{let t=(0,U.c)(5),{children:n,className:r}=e,i;t[0]===r?i=t[1]:(i=R(`flex flex-col gap-2 relative`,r),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,H.jsx)(`div`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},ON=e=>{let t=(0,U.c)(9),{columnName:n,dataType:r}=e,i,a;if(t[0]!==r){let e=v(r);i=C[e],a=E(e),t[0]=r,t[1]=i,t[2]=a}else i=t[1],a=t[2];let o=`w-4 h-4 p-0.5 rounded-sm stroke-card-foreground ${a}`,s;t[3]!==i||t[4]!==o?(s=(0,H.jsx)(i,{className:o}),t[3]=i,t[4]=o,t[5]=s):s=t[5];let c;return t[6]!==n||t[7]!==s?(c=(0,H.jsxs)(`div`,{className:`flex flex-row items-center gap-1.5`,children:[s,n]}),t[6]=n,t[7]=s,t[8]=c):c=t[8],c},kN=`Show only this column`;function AN({table:e,columnIds:t,disabled:n,className:r,iconClassName:i=`h-3 w-3`}){return(0,H.jsx)(zt,{content:kN,delayDuration:400,children:(0,H.jsx)(z,{type:`button`,variant:`text`,size:`icon`,"aria-label":kN,"aria-disabled":n,tabIndex:n?-1:0,className:R(`h-6 w-6 hover:bg-muted text-muted-foreground hover:text-primary`,n&&`opacity-50`,r),onPointerDown:e=>{e.stopPropagation()},onClick:r=>{r.preventDefault(),r.stopPropagation(),!n&&tN(e,t)},children:(0,H.jsx)(Io,{className:i,strokeWidth:2.5})})})}function jN(e){return e.getAllLeafColumns().filter(e=>e.id!==`__select__`&&e.id!==`_marimo_row_id`&&!e.id.startsWith(`__m_column__`))}var MN=({table:e})=>{let t=jN(e),n=t.map(e=>({value:e.id,label:e.id,disabled:!e.getCanHide(),data:{dataType:e.columnDef.meta?.dataType}})),r=t.filter(e=>!e.getIsVisible()).map(e=>e.id),i=t.filter(e=>e.getCanHide()).map(e=>e.id),a=i.filter(e=>!r.includes(e)).length,o=n=>{let r=new Set(Array.isArray(n)?n:[]);e.setColumnVisibility(e=>({...e,...Object.fromEntries(t.map(e=>[e.id,!r.has(e.id)]))}))},s=GA({options:n,value:r,onChange:o,multiple:!0,filterFn:T,pinSelected:!0}),c=s.bulkActions.filter(e=>e.kind===`select-matching`||e.kind===`deselect-matching`),l=s.searchQuery===``?[]:s.visibleOptions.filter(e=>!e.disabled).map(e=>e.value),u=(0,V.useMemo)(()=>({visibleHideableColumnIds:i.filter(e=>!r.includes(e)),hideableColumnIdSet:new Set(i)}),[i,r]),d=l.length>0||c.length>0;return(0,H.jsxs)(I,{open:s.open,onOpenChange:s.setOpen,children:[(0,H.jsx)(P,{asChild:!0,children:(0,H.jsxs)(z,{variant:`text`,size:`xs`,"data-testid":`column-visibility-trigger`,onMouseDown:Vt.preventFocus,className:R(`print:hidden text-xs gap-1`,s.open?`text-primary`:`text-muted-foreground`),children:[(0,H.jsx)(Eo,{className:`w-3.5 h-3.5`}),`Columns`]})}),(0,H.jsx)(ae,{className:`w-64 p-0`,align:`end`,children:(0,H.jsxs)(pe,{shouldFilter:!1,children:[(0,H.jsx)(A,{placeholder:`Search columns...`,value:s.searchQuery,onValueChange:s.setSearchQuery}),(0,H.jsxs)(me,{children:[(0,H.jsx)(te,{children:`No results.`}),s.searchQuery===``?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(h,{value:`__show_all__`,disabled:r.length===0,onSelect:()=>o([]),className:`cursor-pointer`,children:[(0,H.jsx)(p,{className:`w-3 h-3 mr-1.5`}),`Show all`]}),(0,H.jsxs)(h,{value:`__hide_all__`,disabled:a===0,onSelect:()=>o(i),className:`cursor-pointer`,children:[(0,H.jsx)(xn,{className:`w-3 h-3 mr-1.5`}),`Hide all`]}),(0,H.jsx)(j,{})]}):d&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(h,{value:`__show_only_matching__`,disabled:l.length===0||rN(u,l),onSelect:()=>{tN(e,l)},className:`cursor-pointer`,children:[(0,H.jsx)(Io,{className:`w-3 h-3 mr-1.5`}),`Show only `,l.length,` matching`]}),c.map(e=>(0,H.jsxs)(h,{value:`__bulk_${e.kind}`,onSelect:e.run,className:`cursor-pointer`,children:[e.kind===`select-matching`?(0,H.jsx)(xn,{className:`w-3 h-3 mr-1.5`}):(0,H.jsx)(p,{className:`w-3 h-3 mr-1.5`}),e.kind===`select-matching`?`Hide`:`Show`,` `,e.items.length,` matching`]},e.kind)),(0,H.jsx)(j,{})]}),s.visibleOptions.map((t,n)=>{let r=s.isChecked(t.value),{dataType:i}=t.data,a=n===s.pinnedCount&&s.pinnedCount>0&&s.pinnedCount<s.visibleOptions.length;return(0,H.jsxs)(V.Fragment,{children:[a&&(0,H.jsx)(j,{}),(0,H.jsxs)(h,{value:t.value,disabled:t.disabled,onSelect:()=>s.toggle(t.value),className:`flex items-center gap-1.5 cursor-pointer`,children:[i===void 0?(0,H.jsx)(`span`,{children:t.label}):(0,H.jsx)(ON,{columnName:t.label,dataType:i}),!t.disabled&&(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,H.jsx)(AN,{table:e,columnIds:[t.value],disabled:rN(u,[t.value]),iconClassName:`w-3 h-3`}),(0,H.jsx)(`span`,{className:R(r?`text-primary`:`text-muted-foreground`),children:r?(0,H.jsx)(xn,{className:`w-3 h-3`}):(0,H.jsx)(p,{className:`w-3 h-3`})})]})]})]},t.value)})]})]})})]})},NN=i(null),PN=e=>{let t=(0,U.c)(13),{packages:n,showMaxPackages:r,className:i,onInstall:a}=e,{handleInstallPackages:o}=aa(),s=Ee();if(!n||n.length===0||!s)return null;let c;t[0]!==o||t[1]!==a||t[2]!==n?(c=()=>{o(n,a)},t[0]=o,t[1]=a,t[2]=n,t[3]=c):c=t[3];let l;t[4]===i?l=t[5]:(l=R(`ml-2`,i),t[4]=i,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r?n.slice(0,r).join(`, `):n.join(`, `),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;return t[9]!==c||t[10]!==l||t[11]!==u?(d=(0,H.jsxs)(z,{variant:`outline`,size:`xs`,onClick:c,className:l,children:[`Install`,` `,u]}),t[9]=c,t[10]=l,t[11]=u,t[12]=d):d=t[12],d},FN=e=>{let t=(0,U.c)(20),{packages:n,featureName:r,description:i,onInstall:a,className:o}=e;if(!Ee()){let e;t[0]===o?e=t[1]:(e=R(`text-xs`,o),t[0]=o,t[1]=e);let n;return t[2]!==r||t[3]!==e?(n=(0,H.jsxs)(`span`,{className:e,children:[r,` isn't available in this notebook`]}),t[2]=r,t[3]=e,t[4]=n):n=t[4],n}let s;t[5]===o?s=t[6]:(s=R(`text-xs flex flex-col items-end gap-2`,o),t[5]=o,t[6]=s);let c;t[7]!==i||t[8]!==r||t[9]!==n?(c=i||`${r} requires ${n.join(`, `)}`,t[7]=i,t[8]=r,t[9]=n,t[10]=c):c=t[10];let l;t[11]===c?l=t[12]:(l=(0,H.jsx)(`span`,{className:`self-start`,children:c}),t[11]=c,t[12]=l);let u;t[13]!==a||t[14]!==n?(u=(0,H.jsx)(PN,{packages:n,onInstall:a,className:`ml-0`}),t[13]=a,t[14]=n,t[15]=u):u=t[15];let d;return t[16]!==s||t[17]!==l||t[18]!==u?(d=(0,H.jsxs)(`div`,{className:s,children:[l,u]}),t[16]=s,t[17]=l,t[18]=u,t[19]=d):d=t[19],d},IN={CSV:{label:`CSV`,format:`csv`,description:`Comma-separated values`,icon:nn},JSON:{label:`JSON`,format:`json`,description:`Raw JSON data`,icon:ue},PARQUET:{label:`Parquet`,format:`parquet`,description:`Columnar binary format`,icon:xo},TSV:{label:`TSV`,format:`tsv`,description:`Best for Excel and Google Sheets`,icon:nn},MARKDOWN:{label:`Markdown`,format:`markdown`,description:`Preserves hyperlinks and formatting`,icon:D}},LN=[IN.CSV,IN.TSV,IN.JSON,IN.PARQUET],RN=[IN.TSV,IN.JSON,IN.CSV,IN.MARKDOWN],zN={csv:`csv`,tsv:`tsv`,json:`json`,markdown:`json`},BN=e=>LN.find(t=>t.format===e)?.label??e,VN=e=>RN.find(t=>t.format===e)?.label??e,HN=e=>{let t=(0,U.c)(55),[n,r]=V.useState(!1),i=s(NN),a=!!(i&&e.sizeBytes!=null&&e.sizeBytes>i.limitBytes),o=!!(i&&(e.sizeBytesIsLoading||a)),c=o?e.sizeBytesIsLoading?`Checking download size…`:i?.unavailableMessage:`Export`,l=n?`text-primary`:`text-muted-foreground`,u;t[0]===l?u=t[1]:(u=R(`print:hidden text-xs gap-1`,l),t[0]=l,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,H.jsx)(Oo,{className:`w-3.5 h-3.5`}),t[2]=d):d=t[2];let f;t[3]!==o||t[4]!==u?(f=(0,H.jsxs)(z,{"data-testid":`export-button`,size:`xs`,variant:`text`,disabled:o,className:u,children:[d,`Export`]}),t[3]=o,t[4]=u,t[5]=f):f=t[5];let p=f,m;t[6]===e?m=t[7]:(m=async(t,n)=>{let r;try{r=await e.downloadAs({format:t})}catch(e){let t=e;return ai({title:`Failed to download`,description:typeof t==`object`&&t&&`message`in t?String(t.message):String(t)}),null}return r.missing_packages&&r.missing_packages.length>0?(ai({title:`Export failed`,description:(0,H.jsx)(FN,{packages:r.missing_packages,featureName:`${BN(t)} export`,description:r.error,onInstall:n})}),null):{url:r.url,filename:r.filename}},t[6]=e,t[7]=m);let h=m,g,_,v,b,x,S,C,w,T,E,D,O,k;if(t[8]!==p||t[9]!==o||t[10]!==n||t[11]!==h||t[12]!==c){let e=async t=>{let n=BN(t);await kt(`Preparing ${n} export...`,async()=>{let n=await h(t,()=>{e(t)});if(!n)return!1;let r=(n.filename??``).trim(),i=`${Nt.withoutExtension(r)||`download`}.${t}`,a=n.url;if(!a.startsWith(`data:`)){let e=a.includes(`?`)?`&`:`?`,t=new URLSearchParams({download:`1`,filename:i});a=`${a}${e}${t.toString()}`}return Pt(a,i),!0})&&ai({title:`${n} download started`})},i=async e=>{await kt(`Preparing ${VN(e)} for clipboard...`,async()=>{let t=zN[e],n=await h(t,()=>{i(e)});if(!n)return;let r;bb94:switch(e){case`tsv`:case`csv`:r=await WN(n.url);break bb94;case`json`:{let e=await UN(n.url);r=JSON.stringify(e,null,2);break bb94}case`markdown`:{let e=await UN(n.url);r=y(e);break bb94}default:Jt(e);return}await Vi(r),ai({title:`Copied to clipboard`})})};_=Ct,x=!1,S=n,C=r;let a=!n&&void 0,s=o?0:-1,l;t[26]!==p||t[27]!==s?(l=(0,H.jsx)(`span`,{tabIndex:s,className:`inline-flex`,children:p}),t[26]=p,t[27]=s,t[28]=l):l=t[28];let u;t[29]!==o||t[30]!==l?(u=(0,H.jsx)(bt,{asChild:!0,disabled:o,children:l}),t[29]=o,t[30]=l,t[31]=u):u=t[31],t[32]!==a||t[33]!==u||t[34]!==c?(w=(0,H.jsx)(zt,{content:c,open:a,children:u}),t[32]=a,t[33]=u,t[34]=c,t[35]=w):w=t[35],g=xt,T=`bottom`,E=`print:hidden`,t[36]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Download`}),t[36]=D):D=t[36],O=LN.map(t=>(0,H.jsxs)(ut,{onSelect:()=>{e(t.format)},children:[(0,H.jsx)(t.icon,{className:`mo-dropdown-icon`}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{children:t.label}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.label)),t[37]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(ft,{}),v=(0,H.jsx)(yt,{className:`text-xs text-muted-foreground`,children:`Copy to clipboard`}),t[37]=v,t[38]=k):(v=t[37],k=t[38]),b=RN.map(e=>(0,H.jsxs)(ut,{onSelect:async()=>{try{await i(e.format)}catch(e){ai({title:`Failed to copy to clipboard`,description:Wi(e),variant:`danger`})}},children:[(0,H.jsx)(e.icon,{className:`mo-dropdown-icon`}),(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{children:e.label}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.description})]})]},e.label)),t[8]=p,t[9]=o,t[10]=n,t[11]=h,t[12]=c,t[13]=g,t[14]=_,t[15]=v,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=E,t[23]=D,t[24]=O,t[25]=k}else g=t[13],_=t[14],v=t[15],b=t[16],x=t[17],S=t[18],C=t[19],w=t[20],T=t[21],E=t[22],D=t[23],O=t[24],k=t[25];let A;t[39]!==g||t[40]!==v||t[41]!==b||t[42]!==T||t[43]!==E||t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,H.jsxs)(g,{side:T,className:E,children:[D,O,k,v,b]}),t[39]=g,t[40]=v,t[41]=b,t[42]=T,t[43]=E,t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47];let j;return t[48]!==_||t[49]!==x||t[50]!==S||t[51]!==C||t[52]!==w||t[53]!==A?(j=(0,H.jsxs)(_,{modal:x,open:S,onOpenChange:C,children:[w,A]}),t[48]=_,t[49]=x,t[50]=S,t[51]=C,t[52]=w,t[53]=A,t[54]=j):j=t[54],j};function UN(e){return WN(e).then(N)}function WN(e){return fetch(e).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var GN=()=>{},KN=({table:e,showSearch:t,searchQuery:n,onSearchQueryChange:r,reloading:i,showChartBuilder:a,isChartBuilderOpen:o,toggleDisplayHeader:s,showTableExplorer:c,togglePanel:l,isAnyPanelOpen:u,downloadAs:f,sizeBytes:p,sizeBytesIsLoading:m})=>{let[h,g]=(0,V.useState)(n||``),_=sO(h,500),v=d(r??GN),y=V.useRef(null);return(0,V.useEffect)(()=>{v(_)},[_,v]),(0,H.jsxs)(`div`,{className:`flex items-center h-10 px-2 border-b gap-2`,children:[r&&t&&(0,H.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,H.jsx)(cr,{className:`w-4 h-4 text-muted-foreground shrink-0`}),(0,H.jsx)(`input`,{ref:y,type:`text`,className:`h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0`,value:h,onKeyDown:e=>{e.key===`Escape`&&(g(``),y.current?.blur())},onChange:e=>g(e.target.value),placeholder:`Search...`}),i&&(0,H.jsx)(kn,{size:`small`}),h&&(0,H.jsx)(z,{variant:`text`,size:`xs`,className:`h-5 w-5 p-0 shrink-0`,onClick:()=>g(``),children:(0,H.jsx)(sn,{className:`w-3 h-3 text-muted-foreground`})})]}),(0,H.jsxs)(`div`,{className:`flex items-center shrink-0 ml-auto`,children:[(0,H.jsx)(MN,{table:e}),a&&(0,H.jsxs)(z,{variant:`text`,size:`xs`,className:R(`print:hidden text-xs gap-1`,o?`text-primary`:`text-muted-foreground`),onClick:s,children:[(0,H.jsx)(Co,{className:`w-3.5 h-3.5`}),`Visualize`]}),c&&l&&(0,H.jsxs)(z,{variant:`text`,size:`xs`,className:R(`print:hidden text-xs gap-1`,u?`text-primary`:`text-muted-foreground`),onClick:()=>l(kk.ROW_VIEWER),children:[(0,H.jsx)(No,{className:`w-3.5 h-3.5`}),`Explore`]}),f&&(0,H.jsx)(HN,{downloadAs:f,sizeBytes:p,sizeBytesIsLoading:m})]})]})},qN=(0,V.memo)(({wrapperClassName:e,className:t,maxHeight:n,columns:r,data:i,rawData:a,selection:o,totalColumns:s,totalRows:c,sizeBytes:l,sizeBytesIsLoading:u,manualSorting:d=!1,sorting:f,setSorting:p,rowSelection:m,cellSelection:h,cellStyling:g,hoverTemplate:_,cellHoverTexts:v,paginationState:y,setPaginationState:b,downloadAs:x,manualPagination:S=!1,pagination:C=!1,onRowSelectionChange:w,onCellSelectionChange:T,getRowIds:E,showSearch:D=!1,searchQuery:O,onSearchQueryChange:k,showFilters:A=!1,filters:j,onFiltersChange:M,calculateTopKRows:N,reloading:P,freezeColumnsLeft:F,freezeColumnsRight:ee,hiddenColumns:te,toggleDisplayHeader:ne,showChartBuilder:re,isChartBuilderOpen:ie,showPageSizeSelector:ae,showTableExplorer:oe,togglePanel:se,isPanelOpen:ce,isAnyPanelOpen:le,viewedRowIdx:I,onViewedRowChange:ue,renderTableExplorerPanel:de})=>{let L=De(),fe=!L,[pe,me]=V.useState(!1),{locale:he}=B(),{columnPinning:ge,setColumnPinning:_e}=vj(F,ee),{columnVisibility:ve,setColumnVisibility:ye}=ZM(te);V.useEffect(()=>{let e;return P?e=setTimeout(()=>{me(!0)},300):me(!1),()=>{e&&clearTimeout(e)}},[P]);function be(e,t){return y?t+(S?y.pageIndex*y.pageSize:0):t}let xe=VD({_features:[KE,qO,HD,Lk,zk,Fk,Nk,Bk,hj],data:i,columns:r,meta:{rawData:a},getCoreRowModel:kD(),rowCount:c===`too_many`?void 0:c,...b?{onPaginationChange:b,getRowId:(e,t)=>{let n=rE(e);if(n)return n;let r=be(e,t);return String(r)}}:{},locale:he,manualPagination:S,getPaginationRowModel:FD(),...p?{onSortingChange:p}:{},manualSorting:d,enableSorting:!L,enableMultiSort:!0,getSortedRowModel:ID(),manualFiltering:!0,enableColumnFilters:A&&!L,getFilteredRowModel:PD(),onColumnFiltersChange:M,onRowSelectionChange:w,onCellSelectionChange:T,enableCellSelection:o===`single-cell`||o===`multi-cell`,enableMultiCellSelection:o===`multi-cell`,onColumnPinningChange:_e,onColumnVisibilityChange:ye,enableFocusRow:!0,onFocusRowChange:ue,state:{...f?{sorting:f}:{},columnFilters:j,...y?{pagination:y}:C&&!y?{}:{pagination:{pageIndex:0,pageSize:i.length}},rowSelection:m??{},cellSelection:h??[],columnVisibility:ve,cellStyling:g,columnPinning:ge,cellHoverTemplate:_,cellHoverTexts:v??{}}}),Se=ce?.(kk.ROW_VIEWER)??!1,Ce=!C&&i.length>100,we=bj({maxHeight:n,virtualize:Ce}),[Te,Ee]=V.useState(null),Oe=V.useMemo(()=>({requestAddFilter:e=>{let t=xe.getColumn(e.columnId);t&&Ee(tj(t,{operator:e.operator}))}}),[xe]),ke=QM(xe),Ae=ke.total>0&&ke.visible===0;return(0,H.jsx)(fT,{value:Oe,children:(0,H.jsxs)(`div`,{className:R(e,`flex flex-col space-y-1`),children:[(0,H.jsx)(fj,{filters:j,table:xe,calculateTopKRows:N,addFilterSnapshot:Te,onAddFilterSnapshotChange:Ee}),de?.(xe),(0,H.jsx)($j,{children:(0,H.jsxs)(`div`,{part:`table-wrapper`,className:R(t||`rounded-md border overflow-hidden`),children:[fe&&(0,H.jsx)(KN,{table:xe,showSearch:D,searchQuery:O,onSearchQueryChange:k,reloading:P,showChartBuilder:re,isChartBuilderOpen:ie,toggleDisplayHeader:ne,showTableExplorer:oe,togglePanel:se,isAnyPanelOpen:le,downloadAs:x,sizeBytes:l,sizeBytesIsLoading:u}),Ae&&(0,H.jsxs)(la,{className:`mb-1 mx-2 rounded flex items-center justify-between`,children:[(0,H.jsx)(`span`,{children:`All columns are hidden.`}),(0,H.jsx)(z,{variant:`link`,size:`xs`,onClick:()=>xe.resetColumnVisibility(!0),children:`Unhide all`})]}),(0,H.jsxs)(_a,{className:R(`relative`,r.length<=4?`w-auto`:`w-full`),ref:we,children:[pe&&(0,H.jsx)(`thead`,{className:`absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide`}),qM(xe,Ce||!!n),(0,H.jsx)(JM,{table:xe,columns:r,rowViewerPanelOpen:Se,getRowIndex:be,viewedRowIdx:I,virtualize:Ce})]}),(0,H.jsx)(xN,{part:`table-footer`,className:`pt-1.5 pb-0.5 border-t border-border`,totalColumns:s,pagination:C,selection:o,onRowSelectionChange:w,table:xe,getRowIds:E,showPageSizeSelector:ae,tableLoading:P})]})})]})})}),JN=25;function YN(e){return e?e.startsWith(`image/`)||e.startsWith(`audio/`)||e.startsWith(`video/`)||e.startsWith(`application/pdf`):!1}var XN={"application/javascript":`javascript`,"text/markdown":`markdown`,"text/html":`html`,"text/css":`css`,"text/x-python":`python`,"application/json":`json`,"application/toml":`toml`,"application/x-toml":`toml`,"application/xml":`xml`,"text/x-toml":`toml`,"text/x-yaml":`yaml`,"text/csv":`markdown`,"text/plain":`markdown`,default:`markdown`},ZN={toml:`toml`},QN=new Set([`application/octet-stream`,`text/plain`]);function $N(e,t){let n=e.split(`;`,1)[0].trim().toLowerCase();if(QN.has(n)&&t){let e=oi.extension(t).toLowerCase(),n=Object.hasOwn(ZN,e)?ZN[e]:void 0;if(n)return n}return XN[n]||XN.default}function eP(e){return e.url==null?pn(e.base64,e.mime):e.url}function tP({contents:e,mimeType:t,isBase64:n}){return n?{base64:e,mime:t}:{url:`data:${t};charset=utf-8,${encodeURIComponent(e)}`}}var nP=e=>{let t=(0,U.c)(11),{contents:n}=e,r;t[0]===n?r=t[1]:(r=Ki(n),t[0]=n,t[1]=r);let i=r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={pageIndex:0,pageSize:JN},t[2]=a):a=t[2];let[o,s]=(0,V.useState)(a),c;t[3]===i?c=t[4]:(c=dk(i),t[3]=i,t[4]=c);let l=c,u;t[5]===l?u=t[6]:(u=fk({rowHeaders:Ut.EMPTY,selection:null,fieldTypes:l}),t[5]=l,t[6]=u);let d=u,f;return t[7]!==d||t[8]!==i||t[9]!==o?(f=(0,H.jsx)(qN,{data:i,totalRows:i.length,columns:d,totalColumns:d.length,manualPagination:!1,paginationState:o,setPaginationState:s,wrapperClassName:`h-full justify-between pb-1 px-1`,pagination:!0,className:`rounded-none border-b flex flex-col overflow-hidden`,rowSelection:Se.EMPTY}),t[7]=d,t[8]=i,t[9]=o,t[10]=f):f=t[10],f},rP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`img`,{src:n,alt:`Preview`}),t[2]=n,t[3]=r),r},iP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`audio`,{controls:!0,src:n}),t[2]=n,t[3]=r),r},aP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`video`,{controls:!0,src:n}),t[2]=n,t[3]=r),r},oP=e=>{let t=(0,U.c)(4),n;t[0]===e?n=t[1]:(n=eP(e),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,H.jsx)(`iframe`,{src:n,title:`PDF Viewer`,className:`w-full h-full`}),t[2]=n,t[3]=r),r},sP=e=>{let t=(0,U.c)(11),n,r;if(t[0]===e?(n=t[1],r=t[2]):({mimeType:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n.startsWith(`image/`)){let e;return t[3]===r?e=t[4]:(e=(0,H.jsx)(rP,{...r}),t[3]=r,t[4]=e),e}if(n.startsWith(`audio/`)){let e;return t[5]===r?e=t[6]:(e=(0,H.jsx)(iP,{...r}),t[5]=r,t[6]=e),e}if(n.startsWith(`video/`)){let e;return t[7]===r?e=t[8]:(e=(0,H.jsx)(aP,{...r}),t[7]=r,t[8]=e),e}if(n.startsWith(`application/pdf`)){let e;return t[9]===r?e=t[10]:(e=(0,H.jsx)(oP,{...r}),t[9]=r,t[10]=e),e}return null},cP=[],lP=e=>{let t=(0,U.c)(18),{mimeType:n,filename:r,contents:i,mediaSource:a,readOnly:o,onChange:s,extensions:c}=e,l=o===void 0||o,u=c===void 0?cP:c,{theme:d}=ci();if(n===`text/csv`&&i!=null){let e;return t[0]===i?e=t[1]:(e=(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden flex flex-col`,children:(0,H.jsx)(nP,{contents:i})}),t[0]=i,t[1]=e),e}if(YN(n)&&a){let e;return t[2]!==a||t[3]!==n?(e=(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden flex flex-col`,children:(0,H.jsx)(sP,{...a,mimeType:n})}),t[2]=a,t[3]=n,t[4]=e):e=t[4],e}if(i!=null){let e;t[5]!==r||t[6]!==n?(e=$N(n,r),t[5]=r,t[6]=n,t[7]=e):e=t[7];let a=e,o=d===`dark`?`dark`:`light`,c;t[8]===u?c=t[9]:(c=[Ht.lineWrapping,...u],t[8]=u,t[9]=c);let f=!l&&void 0,p=l?void 0:s,m;return t[10]!==i||t[11]!==a||t[12]!==l||t[13]!==o||t[14]!==c||t[15]!==f||t[16]!==p?(m=(0,H.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,H.jsx)(V.Suspense,{children:(0,H.jsx)(Qt,{theme:o,language:a,className:`border-b`,extensions:c,value:i,readOnly:l,editable:f,onChange:p})})}),t[10]=i,t[11]=a,t[12]=l,t[13]=o,t[14]=c,t[15]=f,t[16]=p,t[17]=m):m=t[17],m}return null};function uP(e,t){let{state:n}=e,r=n.doc;if(t<=0||t>r.lines)return be.warn(`Invalid line number: ${t}. Document has ${r.lines} lines.`),!1;let i=r.line(t);if(i.text.includes(`breakpoint()`))return!0;let a=i.text.match(/^(\s*)/),o=`${a?a[1]:``}breakpoint()\n`,s=i.from;return e.dispatch({changes:{from:s,to:s,insert:o},selection:{anchor:s+o.length-1,head:s+o.length-1},scrollIntoView:!0,effects:[Ht.scrollIntoView(s,{y:`center`})]}),e.focus(),!0}var dP=e=>{let t=(0,U.c)(51),{onRefactorWithAI:n,traceback:r,cellId:i}=e,a;t[0]===r?a=t[1]:(a=Ui({html:r,additionalReplacements:[pP,hP,mP]}),t[0]=r,t[1]=a);let o=a,c;t[2]===r?c=t[3]:(c=fP(r),t[2]=r,t[3]=c);let l=c,u=s(ve),d=Qr(),f;t[4]===r?f=t[5]:(f=de(r)?.at(0),t[4]=r,t[5]=f);let p=f,m;t[6]!==i||t[7]!==p?(m=p&&p.kind===`cell`&&!Te()&&!De()&&i!==`__scratch__`,t[6]=i,t[7]=p,t[8]=m):m=t[8];let h=m,g;t[9]!==u||t[10]!==n?(g=n&&u&&!De(),t[9]=u,t[10]=n,t[11]=g):g=t[11];let _=g,v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=De(),t[12]=v):v=t[12];let y=!v,[b,x]=(0,V.useState)(!0),S;t[13]!==l||t[14]!==n?(S=e=>{n?.({prompt:`My code gives the following error:\n\n${l}`,triggerImmediately:e})},t[13]=l,t[14]=n,t[15]=S):S=t[15];let C=S,w;t[16]!==i||t[17]!==l||t[18]!==d?(w=()=>{d({prompt:Jr(i,l)})},t[16]=i,t[17]=l,t[18]=d,t[19]=w):w=t[19];let T=w,E;t[20]===b?E=t[21]:(E=()=>x(!b),t[20]=b,t[21]=E);let D=b?`Collapse traceback`:`Expand traceback`,O;t[22]===b?O=t[23]:(O=b?(0,H.jsx)(an,{className:`h-3 w-3`}):(0,H.jsx)(ln,{className:`h-3 w-3`}),t[22]=b,t[23]=O);let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(`span`,{className:`text-[0.6875rem] uppercase tracking-wider`,children:`Traceback`}),t[24]=k):k=t[24];let A;t[25]!==b||t[26]!==D||t[27]!==O||t[28]!==E?(A=(0,H.jsxs)(`button`,{type:`button`,onClick:E,"aria-expanded":b,"aria-label":D,className:`self-start flex items-center gap-1 pt-2 text-muted-foreground/70 hover:text-muted-foreground transition-colors`,children:[O,k]}),t[25]=b,t[26]=D,t[27]=O,t[28]=E,t[29]=A):A=t[29];let j;t[30]!==o||t[31]!==b?(j=b&&(0,H.jsx)(`div`,{className:`text-muted-foreground pr-4 text-xs overflow-auto`,children:o}),t[30]=o,t[31]=b,t[32]=j):j=t[32];let M;t[33]!==C||t[34]!==T||t[35]!==_?(M=_&&(0,H.jsx)(Xr,{tooltip:`Fix with AI`,openPrompt:()=>C(!1),applyAutofix:()=>C(!0),openChat:T}),t[33]=C,t[34]=T,t[35]=_,t[36]=M):M=t[36];let N;t[37]!==h||t[38]!==p?(N=h&&(0,H.jsx)(zt,{content:`Attach pdb to the exception point.`,children:(0,H.jsxs)(z,{size:`xs`,variant:`outline`,onClick:()=>{Xt().sendPdb({cellId:p.cellId})},children:[(0,H.jsx)(So,{className:`h-3 w-3 mr-2`}),`Launch debugger`]})}),t[37]=h,t[38]=p,t[39]=N):N=t[39];let P;t[40]!==l||t[41]!==r?(P=y&&(0,H.jsxs)(Ct,{children:[(0,H.jsx)(bt,{asChild:!0,children:(0,H.jsxs)(z,{size:`xs`,variant:`text`,children:[`Get help`,(0,H.jsx)(an,{className:`h-3 w-3 ml-1`})]})}),(0,H.jsxs)(xt,{align:`end`,className:`w-56`,children:[(0,H.jsx)(ut,{asChild:!0,children:(0,H.jsxs)(`a`,{target:`_blank`,href:`https://www.google.com/search?q=${encodeURIComponent(l)}`,rel:`noreferrer`,children:[(0,H.jsx)(cr,{className:`h-4 w-4 mr-2`}),`Search on Google`,(0,H.jsx)(Cn,{className:`h-3 w-3 ml-auto`})]})}),(0,H.jsx)(ut,{asChild:!0,children:(0,H.jsxs)(`a`,{target:`_blank`,href:`https://marimo.io/discord?ref=notebook`,rel:`noopener`,children:[(0,H.jsx)(An,{className:`h-4 w-4 mr-2`}),`Ask in Discord`,(0,H.jsx)(Cn,{className:`h-3 w-3 ml-auto`})]})}),(0,H.jsxs)(ut,{onClick:()=>{let e=document.createElement(`div`);e.innerHTML=oe(r);let t=e.textContent||``;Vi(t)},children:[(0,H.jsx)(bn,{className:`h-4 w-4 mr-2`}),`Copy to clipboard`]})]})]}),t[40]=l,t[41]=r,t[42]=P):P=t[42];let F;t[43]!==M||t[44]!==N||t[45]!==P?(F=(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[M,N,P]}),t[43]=M,t[44]=N,t[45]=P,t[46]=F):F=t[46];let ee;return t[47]!==A||t[48]!==j||t[49]!==F?(ee=(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 min-w-full w-fit`,children:[A,j,F]}),t[47]=A,t[48]=j,t[49]=F,t[50]=ee):ee=t[50],ee};function fP(e){let t=document.createElement(`div`);return t.innerHTML=oe(e),(t.textContent?.split(`
|
|
50
50
|
`).filter(Boolean))?.at(-1)||``}var pP=e=>{let t=fe(e);if(t?.kind===`cell`){let e=ne(`debugger`),n=e?(0,H.jsx)(_P,{}):(0,H.jsx)(gP,{});return(0,H.jsx)(`span`,{className:`nb`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,H.jsx)(oa,{cellId:t.cellId,lineNumber:t.lineNumber}),!Te()&&(0,H.jsx)(zt,{content:n,children:(0,H.jsx)(`button`,{type:`button`,className:`ml-1 p-1 rounded-sm hover:bg-muted transition-all inline`,children:(0,H.jsx)(So,{onClick:()=>{if(e&&!De()){he(t.cellId,t.lineNumber);return}let n=re(t.cellId);n&&uP(n,t.lineNumber)},className:`h-3 w-3`})})})]})})}if(t?.kind===`file`)return(0,H.jsx)(`div`,{className:`inline-block cursor-pointer text-destructive hover:underline`,onClick:e=>{Xt().openFile({path:t.filePath,lineNumber:t.lineNumber})},children:(0,H.jsxs)(`span`,{className:`nb`,children:[`"`,t.filePath,`"`]})})},mP=e=>{if(!(e instanceof le.Text)||!e.nodeValue||!Yr(e.nodeValue))return;let t=ti(e.nodeValue);return(0,H.jsx)($r,{segments:t})},hP=e=>{if(e instanceof le.Text&&e.nodeValue?.includes(`File`)&&e.next instanceof le.Element&&F(e.next))return(0,H.jsx)(H.Fragment,{children:e.nodeValue.replace(`File`,`Cell`)})},gP=()=>{let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsxs)(H.Fragment,{children:[`Insert a `,(0,H.jsx)(ia,{className:`inline`,children:`breakpoint()`}),` at this line`]}),e[0]=t):t=e[0],t},_P=()=>{let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,H.jsx)(H.Fragment,{children:`Toggle a breakpoint at this line`}),e[0]=t):t=e[0],t};function vP(e){switch(e){case`text/html`:return`🌐`;case`text/plain`:return`📄`;case`application/json`:return`📦`;case`image/png`:case`image/tiff`:case`image/avif`:case`image/bmp`:case`image/gif`:case`image/jpeg`:return`🖼️`;case`image/svg+xml`:return`🎨`;case`video/mp4`:case`video/mpeg`:return`🎥`;case`application/vnd.marimo+error`:return`🚨`;case`application/vnd.marimo+traceback`:return`🐍`;case`text/csv`:return`📊`;case`text/markdown`:return`📝`;case`application/vnd.vegalite.v5+json`:case`application/vnd.vega.v5+json`:case`application/vnd.vegalite.v6+json`:case`application/vnd.vega.v6+json`:return`📊`;case`application/vnd.marimo+mimebundle`:return`📦`;default:return`❓`}}var yP=`__metadata__`,bP=(0,V.memo)(e=>{let t=(0,U.c)(54),{message:n,onRefactorWithAI:r,cellId:i,wrapText:a,metadata:o,renderFallback:s}=e,{theme:c}=ci(),l;bb0:{let e=n.data;switch(n.mimetype){case`application/json`:case`application/vnd.marimo+mimebundle`:case`application/vnd.vegalite.v5+json`:case`application/vnd.vega.v5+json`:case`application/vnd.vegalite.v6+json`:case`application/vnd.vega.v6+json`:{let n;t[0]===e?n=t[1]:(n=typeof e==`string`?JSON.parse(e):e,t[0]=e,t[1]=n),l=n;break bb0}default:l=void 0}}let u=l,{channel:d,data:f,mimetype:p}=n;if(f==null)return null;switch(p){case`text/html`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[2]!==d||t[3]!==f?(e=(0,H.jsx)(Xw,{className:d,html:f,alwaysSanitizeHtml:!1}),t[2]=d,t[3]=f,t[4]=e):e=t[4],e}case`text/plain`:case`text/password`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[5]!==d||t[6]!==f||t[7]!==a?(e=(0,H.jsx)(Qw,{channel:d,text:f,wrapText:a}),t[5]=d,t[6]=f,t[7]=a,t[8]=e):e=t[8],e}case`application/json`:{let e;return t[9]!==d||t[10]!==u?(e=(0,H.jsx)(NP,{className:d,data:u,format:`auto`}),t[9]=d,t[10]=u,t[11]=e):e=t[11],e}case`image/png`:case`image/tiff`:case`image/avif`:case`image/bmp`:case`image/gif`:case`image/jpeg`:case`image/svg+xml`:{if(Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`),p===`image/svg+xml`&&!f.startsWith(`data:image/svg+xml;base64,`)){let e;return t[12]===f?e=t[13]:(e=Ui({html:f,alwaysSanitizeHtml:!0}),t[12]=f,t[13]=e),e}let e=o?.width,n=o?.height,r;return t[14]!==d||t[15]!==f||t[16]!==e||t[17]!==n?(r=(0,H.jsx)(Zw,{className:d,src:f,alt:``,width:e,height:n}),t[14]=d,t[15]=f,t[16]=e,t[17]=n,t[18]=r):r=t[18],r}case`video/mp4`:case`video/mpeg`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[19]!==d||t[20]!==f?(e=(0,H.jsx)($w,{className:d,src:f}),t[19]=d,t[20]=f,t[21]=e):e=t[21],e}case`application/vnd.marimo+error`:{Ce(Array.isArray(f),`Expected array data`);let e;return t[22]!==i||t[23]!==f?(e=(0,H.jsx)(ei,{cellId:i,errors:f}),t[22]=i,t[23]=f,t[24]=e):e=t[24],e}case`application/vnd.marimo+traceback`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[25]!==i||t[26]!==f||t[27]!==r?(e=(0,H.jsx)(dP,{onRefactorWithAI:r,traceback:f,cellId:i}),t[25]=i,t[26]=f,t[27]=r,t[28]=e):e=t[28],e}case`text/csv`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[29]===f?e=t[30]:(e=(0,H.jsx)(nP,{contents:f}),t[29]=f,t[30]=e),e}case`text/latex`:case`text/markdown`:{Ce(typeof f==`string`,`Expected string data for mime=${p}. Got ${typeof f}`);let e;return t[31]!==d||t[32]!==f?(e=(0,H.jsx)(Xw,{className:d,html:f,alwaysSanitizeHtml:!0}),t[31]=d,t[32]=f,t[33]=e):e=t[33],e}case`application/vnd.vegalite.v5+json`:case`application/vnd.vega.v5+json`:case`application/vnd.vegalite.v6+json`:case`application/vnd.vega.v6+json`:{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(sT,{}),t[34]=e):e=t[34];let n=u,r;t[35]===u?r=t[36]:(r=ua(u),t[35]=u,t[36]=r);let i=c===`dark`?`dark`:void 0,a;t[37]===i?a=t[38]:(a={theme:i,mode:`vega-lite`,tooltip:Ji.call,renderer:`canvas`},t[37]=i,t[38]=a);let o;return t[39]!==n||t[40]!==r||t[41]!==a?(o=(0,H.jsx)(V.Suspense,{fallback:e,children:(0,H.jsx)(oT,{spec:n,"data-container-width":r,options:a})}),t[39]=n,t[40]=r,t[41]=a,t[42]=o):o=t[42],o}case`application/vnd.marimo+mimebundle`:{let e=u,n;return t[43]!==d||t[44]!==e?(n=(0,H.jsx)(xP,{channel:d,data:e}),t[43]=d,t[44]=e,t[45]=n):n=t[45],n}case`application/vnd.jupyter.widget-view+json`:{let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,H.jsx)(`b`,{children:`Jupyter widgets are not supported in marimo.`}),t[46]=e):e=t[46];let n;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,H.jsx)(`br`,{}),t[47]=n):n=t[47];let r;return t[48]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,H.jsxs)(la,{kind:`warn`,children:[e,` `,n,`Please migrate this widget to`,` `,(0,H.jsx)(`a`,{href:`https://github.com/manzt/anywidget`,target:`_blank`,rel:`noopener noreferrer`,className:`underline hover:text-(--amber-12)`,children:`anywidget`}),`.`]}),t[48]=r):r=t[48],r}default:{if(Jt(p),s){let e;return t[49]!==p||t[50]!==s?(e=s(p),t[49]=p,t[50]=s,t[51]=e):e=t[51],e}let e;return t[52]===p?e=t[53]:(e=(0,H.jsxs)(`div`,{className:`text-destructive`,children:[`Unsupported mimetype: `,p]}),t[52]=p,t[53]=e),e}}});bP.displayName=`OutputRenderer`;var xP=(0,V.memo)(e=>{let t=(0,U.c)(31),{data:n,channel:r,cellId:i}=e,a=Array.isArray(n)?n[0]:n,{mode:o}=s(we),c=o===`present`||o===`read`,l=a[yP],u,d,f,p,m,h,g,_;if(t[0]!==c||t[1]!==i||t[2]!==r||t[3]!==l||t[4]!==a){_=Symbol.for(`react.early_return_sentinel`);bb0:{let{entries:e}=aT(Se.entries(a).filter(EP).map(DP)),n=e[0]?.[0];if(!n){_=null;break bb0}if(e.length===1){_=(0,H.jsx)(bP,{cellId:i,message:{channel:r,data:e[0][1],mimetype:n},metadata:l?.[n]});break bb0}u=Ze,h=n,g=`vertical`,p=`flex`;let o=c&&`mt-4`,s;t[13]===o?s=t[14]:(s=R(`self-start max-h-none flex flex-col gap-2 mr-3 shrink-0`,o),t[13]=o,t[14]=s),m=(0,H.jsx)(Xe,{className:s,children:e.map(OP)}),d=`flex-1 w-full`;let v;t[15]!==i||t[16]!==r||t[17]!==l?(v=e=>{let[t,n]=e;return(0,H.jsx)(Ye,{value:t,children:(0,H.jsx)(ke,{children:(0,H.jsx)(bP,{cellId:i,message:{channel:r,data:n,mimetype:t},metadata:l?.[t]})})},t)},t[15]=i,t[16]=r,t[17]=l,t[18]=v):v=t[18],f=e.map(v)}t[0]=c,t[1]=i,t[2]=r,t[3]=l,t[4]=a,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];if(_!==Symbol.for(`react.early_return_sentinel`))return _;let v;t[19]!==d||t[20]!==f?(v=(0,H.jsx)(`div`,{className:d,children:f}),t[19]=d,t[20]=f,t[21]=v):v=t[21];let y;t[22]!==p||t[23]!==m||t[24]!==v?(y=(0,H.jsxs)(`div`,{className:p,children:[m,v]}),t[22]=p,t[23]=m,t[24]=v,t[25]=y):y=t[25];let b;return t[26]!==u||t[27]!==h||t[28]!==g||t[29]!==y?(b=(0,H.jsx)(u,{defaultValue:h,orientation:g,children:y}),t[26]=u,t[27]=h,t[28]=g,t[29]=y,t[30]=b):b=t[30],b});xP.displayName=`MimeBundleOutputRenderer`;var SP=V.memo(e=>{let t=(0,U.c)(17),{output:n,cellId:r,stale:i,loading:a,allowExpand:o,forceExpand:s,className:c}=e;if(n==null||n.channel===`output`&&n.data===``)return null;let l=i?`This output is stale`:void 0,u=o?TP:CP,d;t[0]===r?d=t[1]:(d=w.create(r),t[0]=r,t[1]=d);let f=i&&`marimo-output-stale`,p=a&&`marimo-output-loading`,m;t[2]!==c||t[3]!==f||t[4]!==p?(m=R(f,p,c),t[2]=c,t[3]=f,t[4]=p,t[5]=m):m=t[5];let h;t[6]!==r||t[7]!==n?(h=(0,H.jsx)(bP,{cellId:r,message:n}),t[6]=r,t[7]=n,t[8]=h):h=t[8];let g;return t[9]!==u||t[10]!==r||t[11]!==s||t[12]!==d||t[13]!==m||t[14]!==h||t[15]!==l?(g=(0,H.jsx)(ke,{children:(0,H.jsx)(u,{title:l,cellId:r,forceExpand:s,id:d,className:m,children:h})}),t[9]=u,t[10]=r,t[11]=s,t[12]=d,t[13]=m,t[14]=h,t[15]=l,t[16]=g):g=t[16],g});SP.displayName=`OutputArea`;var CP=V.forwardRef((e,t)=>{let n=(0,U.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,H.jsx)(`div`,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});CP.displayName=`Div`;function wP(){document.exitFullscreen().catch(e=>{be.warn(`Failed to exit fullscreen`,e)})}var TP=V.memo(e=>{let t=(0,U.c)(34),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({cellId:n,children:r,forceExpand:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=(0,V.useRef)(null),[s,c]=hn(n),l=eT(o),{hasFullscreen:u}=sa(),d=Le(o);xe(d?document:null,`keydown`,kP);let f;t[5]===u?f=t[6]:(f=u&&(0,H.jsx)(zt,{content:`Fullscreen`,side:`left`,children:(0,H.jsx)(z,{"data-testid":`fullscreen-output-button`,className:`hover-action hover:bg-muted p-1 hover:border-border border border-transparent`,onClick:async()=>{await o.current?.requestFullscreen()},onMouseDown:Vt.preventFocus,size:`xs`,variant:`text`,children:(0,H.jsx)(ko,{className:`size-4 opacity-60 hover:opacity-80`,strokeWidth:1.25})})}),t[5]=u,t[6]=f);let p;t[7]!==i||t[8]!==s||t[9]!==l||t[10]!==c?(p=(l||s)&&!i&&(0,H.jsx)(z,{"data-testid":`expand-output-button`,className:R(`hover:border-border border border-transparent hover:bg-muted`,!s&&`hover-action`),onClick:()=>c(!s),size:`xs`,variant:`text`,children:s?(0,H.jsx)(zt,{content:`Collapse output`,side:`left`,children:(0,H.jsx)(fn,{className:`h-4 w-4`})}):(0,H.jsx)(zt,{content:`Expand output`,side:`left`,children:(0,H.jsx)(mn,{className:`h-4 w-4 opacity-60`})})}),t[7]=i,t[8]=s,t[9]=l,t[10]=c,t[11]=p):p=t[11];let m;t[12]!==f||t[13]!==p?(m=(0,H.jsx)(`div`,{className:`relative print:hidden`,children:(0,H.jsxs)(`div`,{className:`absolute -right-9 top-1 z-1 flex flex-col gap-1`,children:[f,p]})}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]===a.className?h=t[16]:(h=R(`relative fullscreen:bg-background fullscreen:flex fullscreen:items-center fullscreen:justify-center`,`fullscreen:items-center-safe`,a.className),t[15]=a.className,t[16]=h);let g;t[17]!==i||t[18]!==s?(g=s||i?{maxHeight:`none`}:void 0,t[17]=i,t[18]=s,t[19]=g):g=t[19];let _;t[20]===d?_=t[21]:(_=d&&(0,H.jsx)(zt,{content:`Exit fullscreen`,side:`left`,children:(0,H.jsx)(z,{"data-testid":`exit-fullscreen-output-button`,"aria-label":`Exit fullscreen`,className:`absolute right-2 top-2 z-2 p-1 bg-background/90 border border-border hover:bg-muted print:hidden`,onClick:wP,size:`xs`,variant:`text`,children:(0,H.jsx)(Lo,{className:`size-4 opacity-60 hover:opacity-80`,strokeWidth:1.25})})}),t[20]=d,t[21]=_);let v;t[22]!==r||t[23]!==a||t[24]!==h||t[25]!==g||t[26]!==_?(v=(0,H.jsxs)(`div`,{...a,"data-cell-role":`output`,className:h,ref:o,style:g,children:[_,r]}),t[22]=r,t[23]=a,t[24]=h,t[25]=g,t[26]=_,t[27]=v):v=t[27];let y;t[28]!==m||t[29]!==v?(y=(0,H.jsxs)(`div`,{children:[m,v]}),t[28]=m,t[29]=v,t[30]=y):y=t[30];let b;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,H.jsx)(`div`,{className:`increase-pointer-area-x contents print:hidden`}),t[31]=b):b=t[31];let x;return t[32]===y?x=t[33]:(x=(0,H.jsxs)(H.Fragment,{children:[y,b]}),t[32]=y,t[33]=x),x});TP.displayName=`ExpandableOutput`;function EP(e){let[t]=e;return t!==yP}function DP(e){let[t,n]=e;return[t,n]}function OP(e){let[t]=e;return(0,H.jsx)(Je,{value:t,className:`flex items-center space-x-2`,children:(0,H.jsx)(zt,{delayDuration:200,content:t,side:`right`,children:(0,H.jsx)(`span`,{children:vP(t)})})},t)}function kP(e){e.key!==`Escape`||!document.fullscreenElement||wP()}var AP=e=>{let t=(0,U.c)(8),{value:n}=e,r=typeof n==`string`&&(n.startsWith(`text/html:`)||n.startsWith(`image/`)||n.startsWith(`video/`)),[i,a]=(0,V.useState)(!1),o;t[0]===n?o=t[1]:(o=async e=>{e.stopPropagation(),await Vi(n),a(!0),setTimeout(()=>a(!1),1e3)},t[0]=n,t[1]=o);let s=o;if(r)return null;let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=R(`inline-flex ml-2 copy-button rounded w-6 h-3 justify-center items-center relative`),t[2]=c):c=t[2];let l;t[3]===i?l=t[4]:(l=i?(0,H.jsx)(rn,{className:`w-5 h-5 absolute -top-0.5 p-1 hover:bg-muted rounded`}):(0,H.jsx)(bn,{className:`w-5 h-5 absolute -top-0.5 p-1 hover:bg-muted rounded`}),t[3]=i,t[4]=l);let u;return t[5]!==s||t[6]!==l?(u=(0,H.jsx)(`button`,{onClick:s,className:c,"aria-label":`Copy to clipboard`,type:`button`,children:l}),t[5]=s,t[6]=l,t[7]=u):u=t[7],u},jP=e=>{let t=(0,U.c)(5),n;t[0]===e.value?n=t[1]:(n=JSON.stringify(e.value,null,2),t[0]=e.value,t[1]=n);let r;return t[2]!==e||t[3]!==n?(r=(0,H.jsx)(AP,{...e,value:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},MP=e=>{let t=(0,U.c)(5),n;t[0]===e.value?n=t[1]:(n=gF(e.value),t[0]=e.value,t[1]=n);let r;return t[2]!==e||t[3]!==n?(r=(0,H.jsx)(AP,{...e,value:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r},NP=(0,V.memo)(e=>{let t=(0,U.c)(24),{data:n,format:r,name:i,valueTypes:a,className:o}=e,s=r===void 0?`auto`:r,c=i!==void 0&&i,l=a===void 0?`python`:a,{theme:u}=ci();s===`auto`&&(s=PP(n));let d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d={python:XP,json:ZP},t[0]=d):d=t[0];let f=d;switch(s){case`tree`:{let e;t[1]===o?e=t[2]:(e=R(`marimo-json-output`,o),t[1]=o,t[2]=e);let r;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r={backgroundColor:`transparent`},t[3]=r):r=t[3];let i=f[l],a=l===`python`?lF:void 0,s;t[4]===n?s=t[5]:(s=_F(n),t[4]=n,t[5]=s);let d;return t[6]!==n||t[7]!==c||t[8]!==e||t[9]!==i||t[10]!==a||t[11]!==s||t[12]!==u?(d=(0,H.jsx)(Yw,{className:e,rootName:c,theme:u,displayDataTypes:!1,value:n,style:r,collapseStringsAfterLength:FP,valueTypes:i,keyRenderer:a,groupArraysAfterLength:2**53-1,enableClipboard:!1,maxDisplayLength:s}),t[6]=n,t[7]=c,t[8]=e,t[9]=i,t[10]=a,t[11]=s,t[12]=u,t[13]=d):d=t[13],d}case`raw`:{let e;t[14]===n?e=t[15]:(e=JSON.stringify(n,null,2),t[14]=n,t[15]=e);let r;return t[16]!==o||t[17]!==e?(r=(0,H.jsx)(`pre`,{className:o,children:e}),t[16]=o,t[17]=e,t[18]=r):r=t[18],r}default:{Jt(s);let e;t[19]===n?e=t[20]:(e=JSON.stringify(n,null,2),t[19]=n,t[20]=e);let r;return t[21]!==o||t[22]!==e?(r=(0,H.jsx)(`pre`,{className:o,children:e}),t[21]=o,t[22]=e,t[23]=r):r=t[23],r}}});NP.displayName=`JsonOutput`;function PP(e){return typeof e==`object`&&e?`tree`:`raw`}var FP=100,IP=e=>{let t=(0,U.c)(11),[n,r]=(0,V.useState)(!0);if(e.text.length<=FP){let n;return t[0]===e.text?n=t[1]:(n=(0,H.jsx)(`span`,{className:`break-all`,children:e.text}),t[0]=e.text,t[1]=n),n}if(n){let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=()=>r(!1),t[2]=n):n=t[2];let i;t[3]===e.text?i=t[4]:(i=e.text.slice(0,FP),t[3]=e.text,t[4]=i);let a=e.text.length>FP&&`...`,o;return t[5]!==i||t[6]!==a?(o=(0,H.jsxs)(`span`,{className:`cursor-pointer hover:opacity-90 break-all`,onClick:n,children:[i,a]}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}let i;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(!0),t[8]=i):i=t[8];let a;return t[9]===e.text?a=t[10]:(a=(0,H.jsx)(`span`,{className:`cursor-pointer hover:opacity-90 break-all`,onClick:i,children:e.text}),t[9]=e.text,t[10]=a),a},LP={"image/":e=>(0,H.jsx)(Zw,{src:e}),"video/":e=>(0,H.jsx)($w,{src:e}),"text/html:":e=>(0,H.jsx)(Xw,{html:e,inline:!0,alwaysSanitizeHtml:!1}),"text/markdown:":e=>(0,H.jsx)(Xw,{html:e,inline:!0,alwaysSanitizeHtml:!0}),"text/plain+float:":e=>(0,H.jsx)(`span`,{children:e}),"text/plain+bigint:":e=>(0,H.jsx)(`span`,{children:e}),"text/plain+set:":e=>(0,H.jsx)(`span`,{children:aF(e)}),"text/plain+frozenset:":e=>(0,H.jsx)(`span`,{children:iF(e)}),"text/plain+tuple:":e=>(0,H.jsx)(`span`,{children:e}),"text/plain:":e=>(0,H.jsx)(IP,{text:e}),"application/json:":e=>(0,H.jsx)(NP,{data:JSON.parse(e),format:`auto`}),"application/":(e,t)=>(0,H.jsx)(bP,{message:{channel:`output`,data:e,mimetype:t},renderFallback:()=>(0,H.jsxs)(`span`,{children:[t,`:`,e]})})},RP=Object.entries(LP).map(([e,t])=>({is:t=>typeof t==`string`&&t.startsWith(e),PostComponent:MP,Component:e=>eF(e.value,t)})),zP=PC({...KC,PostComponent:MP,Component:({value:e})=>(0,H.jsx)(`span`,{children:e?`True`:`False`})}),BP=PC({...ew,PostComponent:MP,Component:()=>(0,H.jsx)(`span`,{children:`None`})}),VP=PC({...KC,PostComponent:jP}),HP=PC({...ew,PostComponent:jP,Component:()=>(0,H.jsx)(`span`,{children:`null`})}),UP=PC({...Pw,is:e=>si(e),PostComponent:MP,Component:({value:e})=>(0,H.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-link hover:underline`,children:e})}),WP=PC({...iw,PostComponent:jP}),GP=PC({...rw,PostComponent:jP}),KP=PC({...Pw,PostComponent:MP}),qP=PC({...Nw,PreComponent:e=>(0,H.jsxs)(H.Fragment,{children:[Nw.PreComponent&&(0,H.jsx)(Nw.PreComponent,{...e}),(0,H.jsx)(MP,{...e})]})}),JP=PC({...Nw,PreComponent:e=>(0,H.jsxs)(H.Fragment,{children:[Nw.PreComponent&&(0,H.jsx)(Nw.PreComponent,{...e}),(0,H.jsx)(jP,{...e})]})}),YP=PC({...Pw,PostComponent:jP}),XP=[WP,zP,BP,...RP,UP,qP,KP].toReversed(),ZP=[WP,GP,VP,HP,JP,YP].toReversed();function QP(e){return $P(e)[0]}function $P(e){let t=e.indexOf(`:`);return t===-1?[e,void 0]:[e.slice(t+1),e.slice(0,t)]}function eF(e,t){let[n,r]=$P(e);return r?t(n,r):(0,H.jsx)(`span`,{children:e})}var tF=`text/plain+`;function nF(e){return e.map(e=>typeof e==`number`&&!Number.isFinite(e)?Number.isNaN(e)?`float('nan')`:e>0?`float('inf')`:`-float('inf')`:JSON.stringify(e)).join(`, `)}function rF(e){let t=N(e);if(!Array.isArray(t))return e;if(t.length===0)return`()`;let n=nF(t);return t.length===1?`(${n},)`:`(${n})`}function iF(e){let t=N(e);return Array.isArray(t)?t.length===0?`frozenset()`:`frozenset({${nF(t)}})`:e}function aF(e){let t=N(e);return Array.isArray(t)?t.length===0?`set()`:`{${nF(t)}}`:e}var oF={"text/plain+int:":e=>(0,H.jsx)(`span`,{children:e}),"text/plain+float:":e=>(0,H.jsx)(`span`,{children:e}),"text/plain+bool:":e=>(0,H.jsx)(`span`,{children:e===`True`?`True`:`False`}),"text/plain+none:":()=>(0,H.jsx)(`span`,{children:`None`}),"text/plain+tuple:":e=>(0,H.jsx)(`span`,{children:rF(e)}),"text/plain+frozenset:":e=>(0,H.jsx)(`span`,{children:iF(e)}),"text/plain+str:":e=>(0,H.jsxs)(`span`,{children:[`"`,e,`"`]})};function sF(e){return typeof e==`string`&&e.startsWith(tF)}var cF=/^-?\d+$/,lF=Object.assign(({path:e})=>{let t=e[e.length-1];if(typeof t!=`string`)return(0,H.jsx)(`span`,{children:String(t)});if(sF(t)){let[e,n]=$P(t),r=oF[`${n}:`];return r?r(e):(0,H.jsx)(`span`,{children:t})}return(0,H.jsxs)(`span`,{children:[`"`,t,`"`]})},{when:({path:e})=>{let t=e[e.length-1];return sF(t)||typeof t==`string`&&cF.test(t)}}),uF=Object.keys(LP),dF=`<marimo-replace>`,fF=`</marimo-replace>`;function pF(e,t){return t==null?`${dF}None${fF}`:typeof t==`object`?t:typeof t==`bigint`?`${dF}${t}${fF}`:Array.isArray(t)?t:typeof t==`string`?t.startsWith(`text/plain+float:`)?`${dF}${QP(t)}${fF}`:t.startsWith(`text/plain+bigint:`)?`${dF}${BigInt(QP(t))}${fF}`:t.startsWith(`text/plain+tuple:`)?`${dF}(${QP(t).slice(1,-1)})${fF}`:t.startsWith(`text/plain+set:`)?`${dF}${aF(QP(t))}${fF}`:t.startsWith(`text/plain+frozenset:`)?`${dF}${iF(QP(t))}${fF}`:uF.some(e=>t.startsWith(e))?QP(t):t:typeof t==`boolean`?`${dF}${t?`True`:`False`}${fF}`:t}function mF(e){let[t,n]=$P(e),r=e=>`${dF}${e}${fF}`;switch(`${n}:`){case`text/plain+int:`:return r(t);case`text/plain+float:`:return r(t===`nan`?`float('nan')`:t===`inf`?`float('inf')`:t===`-inf`?`-float('inf')`:t);case`text/plain+bool:`:return r(t===`True`?`True`:`False`);case`text/plain+none:`:return r(`None`);case`text/plain+tuple:`:return r(rF(t));case`text/plain+frozenset:`:return r(iF(t));case`text/plain+str:`:return t;default:return e}}function hF(e){if(Array.isArray(e))return e.map(hF);if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e)){let e=sF(n)?mF(n):n;t[e]=hF(r)}return t}return e}function gF(e){return JSON.stringify(hF(e),pF,2).replaceAll(`"${dF}`,``).replaceAll(`${fF}"`,``)}function _F(e){if(Array.isArray(e)){let t=e.slice(0,15),n=0;for(let e of t)if(Array.isArray(e)){let t=e.slice(0,5);for(let e of t)if(Array.isArray(e))return 5;n=Math.max(n,e.length)}return n<=20?void 0:n>=50?5:10}}export{lO as $,bM as A,Td as At,wk as B,yo as Bt,QM as C,ag as Ct,DM as D,Zh as Dt,kM as E,Bh as Et,dA as F,jo as Ft,sk as G,Ok as H,Ak as I,ko as It,bk as J,fk as K,jk as L,Oo as Lt,GA as M,Kc as Mt,AA as N,Bo as Nt,OM as O,$h as Ot,uA as P,Mo as Pt,cO as Q,kk as R,To as Rt,nN as S,Z_ as St,yM as T,rg as Tt,Ck as U,Tk as V,Sk as W,UO as X,WO as Y,dO as Z,EN as _,lT as _t,XN as a,PD as at,uN as b,eT as bt,qN as c,nE as ct,AN as d,GT as dt,uO as et,ON as f,qT as ft,TN as g,cT as gt,wN as h,NT as ht,lP as i,kD as it,_j as j,qc as jt,MM as k,Qh as kt,PN as l,tE as lt,CN as m,UT as mt,SP as n,LD as nt,tP as o,ID as ot,DN as p,WT as pt,dk as q,bP as r,VD as rt,YN as s,iE as st,NP as t,iO as tt,NN as u,KT as ut,SN as v,sT as vt,rN as w,ig as wt,$M as x,Xw as xt,dN as y,oT as yt,Ek as z,wo as zt};
|