@marimo-team/frontend 0.23.16-dev42 → 0.23.16-dev43
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-CyzvjIjx.js → JsonOutput-C08yZPMz.js} +1 -1
- package/dist/assets/{add-connection-dialog-C97ylgk0.js → add-connection-dialog-ChQis5IF.js} +1 -1
- package/dist/assets/{agent-panel-Dxo9WUKV.js → agent-panel-Bh4wHqF0.js} +1 -1
- package/dist/assets/{cell-editor-BKrHbyX_.js → cell-editor-_0p7q-Z_.js} +1 -1
- package/dist/assets/{column-preview-Cb8R9kfl.js → column-preview-UAW6odg3.js} +1 -1
- package/dist/assets/{command-palette-B1S9PjZi.js → command-palette-YAVCtQ6D.js} +1 -1
- package/dist/assets/{dependency-graph-panel-DY5lvPDx.js → dependency-graph-panel-BmvJHSNy.js} +1 -1
- package/dist/assets/{download-DpS57jyt.js → download-BIGA4WFm.js} +3 -3
- package/dist/assets/{edit-page-DA765yQV.js → edit-page-ejL0j3OD.js} +4 -4
- package/dist/assets/{file-explorer-panel-BKUo-MDh.js → file-explorer-panel-BxfypeX1.js} +1 -1
- package/dist/assets/{form-nHzLTU1m.js → form-D8N71OB1.js} +1 -1
- package/dist/assets/{index-C7_REKh1.js → index-BLnlUAQy.js} +2 -2
- package/dist/assets/{layout-B29hqiiK.js → layout-B8cCh91r.js} +3 -3
- package/dist/assets/{panels-Bb4fIHgH.js → panels-DG_QWeJn.js} +1 -1
- package/dist/assets/{reveal-component-5jf0W625.js → reveal-component-c5jsRi2_.js} +1 -1
- package/dist/assets/{run-page-BMKx9ld_.js → run-page-BUPqI6K7.js} +1 -1
- package/dist/assets/{scratchpad-panel-C8z8vzBX.js → scratchpad-panel-BR7YpUiV.js} +1 -1
- package/dist/assets/{session-panel-BVVk-02h.js → session-panel-DW3mL5Qf.js} +1 -1
- package/dist/assets/{skeleton-Bubr9pIj.js → skeleton-CeWH7IQO.js} +1 -1
- package/dist/assets/{useCellActionButton-DypR3yDt.js → useCellActionButton-D-uro4Di.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-CwdwKf7A.js → useDependencyPanelTab-BGGAtEWD.js} +1 -1
- package/dist/assets/useNotebookActions-Cm5GAHUD.js +12 -0
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/src/components/editor/actions/__tests__/pdf-export.test.ts +32 -9
- package/src/components/editor/actions/pdf-export.ts +11 -11
- package/src/components/editor/actions/useNotebookActions.tsx +11 -5
- package/src/core/export/__tests__/hooks.test.ts +2 -4
- package/src/core/export/hooks.ts +4 -3
- package/src/utils/__tests__/download.test.tsx +20 -3
- package/src/utils/download.ts +3 -9
- package/dist/assets/useNotebookActions-jWIcmpv0.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as J}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{$r as Ye,Bn as Ze,Br as Ne,Ct as ea,E as aa,Gr as oe,Hn as ta,Hr as sa,Ir as la,Kr as we,Lt as na,N as ra,Qr as Se,Rt as oa,Tr as ce,Ur as ca,Vr as _e,Wi as Ce,Xr as ma,Yr as ia,Zr as da,d as ha,dr as ua,fn as xa,fr as pa,i as fa,j as ba,jt as ga,mr as ja,ni as Ie,qr as me,ti as ya,wr as va,xr as Na,zn as ke,zr as ie,zt as wa}from"./cells-DzyDERZy.js";import"./react-dom-CSu739Rf.js";import{t as Te}from"./compiler-runtime-B3qBwwSJ.js";import{c as Sa}from"./utils-BWBBpCkT.js";import{t as _a}from"./ErrorBoundary-DzTD8LVq.js";import{t as Q}from"./cn-DYvqRARy.js";import{t as Ca}from"./jsx-runtime-Blw4afVn.js";import"./fullscreen-CTDqNQr6.js";import{r as Ia}from"./config-BJVx3eBW.js";import"./popover-Bcz1Zikb.js";import{$ as de,et as Pe,f as Fe,g as $e,h as he,it as ka,m as ue,nt as Ta,p as le,rt as Pa,tt as Fa,u as $a}from"./JsonOutput-CyzvjIjx.js";import"./download-DpS57jyt.js";import{r as Re}from"./radio-group-DfioQthW.js";import{t as xe}from"./tooltip-4bZlU7jl.js";import{r as Ra,t as ne}from"./button-DDGiD1NW.js";import"./dist-12S8I4CH.js";import{l as Y}from"./arrays-DbOq36rN.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{i as Va}from"./strings--BknHX9C.js";import{r as Da}from"./requests-9-v2bhoi.js";import{t as qa}from"./createLucideIcon-w-Qo9n0R.js";import{t as Ba}from"./x-C-Eq0ag8.js";import{a as La,r as Ma}from"./tree-actions-Dx9CDaxV.js";import"./markdown-renderer-sEayY9-m.js";import{t as Ve}from"./add-connection-dialog-C97ylgk0.js";import{t as De}from"./plus-AgXtozBz.js";import{a as Ea}from"./input-JxFwu-3G.js";import{n as Oa,o as za}from"./column-preview-Cb8R9kfl.js";import{t as Aa}from"./workflow-e-XGaKyY.js";import"./dist-DcwTQG1A.js";import"./dist-DnjsPBRJ.js";import"./dist-BJZAIIze.js";import"./dist-aRc_dRed.js";import"./dist-CPjTeT8p.js";import"./session-BmukRjSi.js";import"./purify.es-CWmnYhGI.js";import"./dates-C2LWzsCZ.js";import{t as Ua}from"./copy-icon-neDQUo4Q.js";import{t as Ga}from"./context-BFPaAUK_.js";import"./tooltip-B7U4xkIN.js";import"./vega-loader.browser-Dun7Qe4B.js";import"./defaultLocale-DOVIEEPN.js";import"./defaultLocale-BUCH2FMc.js";import{t as qe}from"./cell-link-w5IbCQV4.js";import"./chunk-5FQGJX7Z-Cp0LZT-a.js";import{r as Ha}from"./html-to-image-JaxFFZcr.js";import{o as Ka}from"./focus-CNKbm-Xz.js";import{n as pe}from"./useAsyncData-Bg5iAViP.js";import{a as Wa,i as Xa,n as Ja,o as Be,r as Qa,t as Ya}from"./table-CH2plyy9.js";import"./react-resizable-panels.browser.esm-Z-MD3n3J.js";import{a as Za,f as et,o as re,t as at}from"./command-Dqxie4gq.js";import{n as tt}from"./icons-CIPE8AIY.js";import{t as st}from"./useDeepCompareMemoize-CSMoa-ga.js";import{t as lt}from"./empty-state-CqJvEFRk.js";import{n as nt,t as rt}from"./common-CJ3baa6D.js";import{a as ot,i as ct,n as Le,r as Me,t as Ee}from"./components-DpUIWGaj.js";var mt=qa("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),U=Te(),F=ge(Qe(),1),s=ge(Ca(),1),fe=1;function Oe(a){return 1.75+a*fe}function it(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var A={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function E(a){return{paddingLeft:`${a}rem`}}var dt=ve(a=>{let e=a(_e),t=a(ta),l=a(fa);return Y(e,n=>{if(!n.variable_name)return-1;let i=Object.values(t).find(d=>d.name===n.variable_name);if(!i)return 0;let c=l.inOrderIds.indexOf(i.declaredBy[0]);return c===-1?0:c})});const ht=Ce("marimo:datasources:hideEmpty",!1,ke,{getOnInit:!0});function Ae(a){let e=!1,t=[];for(let l of a){if(!me(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],i=Ae(n);if(l.tables.length===0&&i.length===0){e=!0;continue}if(i===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:i})}return e?t:a}function ut(a){let e=!1,t=[];for(let l of a){if(we(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ae(l.schemas);if(n.length===0){e=!0;continue}if(n===l.schemas){t.push(l);continue}e=!0,t.push({...l,schemas:n})}return e?t:a}const Ue=ve(a=>{let e=new Map(a(la));for(let t of Ie){let l=e.get(t);l&&(l.databases.length===0&&e.delete(t),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(t))}return Y([...e.values()],t=>Ie.has(t.name)?1:0)}),xt=()=>{let a=(0,U.c)(40),[e,t]=F.useState(""),[l,n]=ye(ht),i=je(Ne),c=J(dt),d=J(Ue),r;e:{if(!l){r=d;break e}let f,v;a[0]===d?(f=a[1],v=a[2]):(f=!1,v=d.map(C=>{let k=ut(C.databases);return k===C.databases?C:(f=!0,{...C,databases:k})}),a[0]=d,a[1]=f,a[2]=v),r=f?v:d}let x=r;if(c.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(lt,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,s.jsx)(Ve,{children:(0,s.jsxs)(ne,{variant:"outline",size:"sm",children:["Add database or catalog",(0,s.jsx)(De,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ce,{})}),a[3]=f):f=a[3],f}let h=!!e.trim(),m;a[4]===i?m=a[5]:(m=f=>{i(f.length>0),t(f)},a[4]=i,a[5]=m);let o;a[6]!==e||a[7]!==m?(o=(0,s.jsx)(Za,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,a[8]=o):o=a[8];let p;a[9]===h?p=a[10]:(p=h&&(0,s.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:(0,s.jsx)(Ba,{className:"h-4 w-4"})}),a[9]=h,a[10]=p);let S=!l,b;a[11]!==l||a[12]!==n?(b=()=>n(!l),a[11]=l,a[12]=n,a[13]=b):b=a[13];let N;a[14]!==S||a[15]!==b?(N=(0,s.jsx)(La,{"data-testid":"datasources-hide-empty-button",isVisible:S,onToggle:b,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=S,a[15]=b,a[16]=N):N=a[16];let y;a[17]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ve,{children:(0,s.jsx)(ne,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,s.jsx)(De,{className:"h-4 w-4"})})}),a[17]=y):y=a[17];let j;a[18]!==o||a[19]!==p||a[20]!==N?(j=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[o,p,N,y]}),a[18]=o,a[19]=p,a[20]=N,a[21]=j):j=a[21];let g;if(a[22]!==x||a[23]!==e){let f;a[25]===e?f=a[26]:(f=v=>(0,s.jsx)(pt,{connection:v,hasChildren:v.databases.length>0,children:v.databases.map(C=>(0,s.jsx)(ft,{connection:v,database:C,searchValue:e},C.name))},v.name),a[25]=e,a[26]=f),g=x.map(f),a[22]=x,a[23]=e,a[24]=g}else g=a[24];let w;a[27]!==x.length||a[28]!==c.length?(w=x.length>0&&c.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:E(A.engine),children:[(0,s.jsx)(tt,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[27]=x.length,a[28]=c.length,a[29]=w):w=a[29];let u;a[30]!==e||a[31]!==c?(u=c.length>0&&(0,s.jsx)(be,{tables:c,searchValue:e}),a[30]=e,a[31]=c,a[32]=u):u=a[32];let _;a[33]!==w||a[34]!==u||a[35]!==g?(_=(0,s.jsxs)(et,{className:"flex flex-col",children:[g,w,u]}),a[33]=w,a[34]=u,a[35]=g,a[36]=_):_=a[36];let I;return a[37]!==_||a[38]!==j?(I=(0,s.jsxs)(at,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[j,_]}),a[37]=_,a[38]=j,a[39]=I):I=a[39],I};var pt=a=>{let e=(0,U.c)(26),{connection:t,children:l,hasChildren:n}=a,i=t.name===ya,c=i?"In-Memory":t.name,{previewDataSourceConnection:d}=Da(),r;e[0]!==t.name||e[1]!==d?(r=async()=>{await d({engine:t.name})},e[0]=t.name,e[1]=d,e[2]=r):r=e[2];let x=r,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=E(A.engine),e[3]=h):h=e[3];let m;e[4]===t.dialect?m=e[5]:(m=(0,s.jsx)(ea,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=m);let o;e[6]===t.dialect?o=e[7]:(o=ua(t.dialect),e[6]=t.dialect,e[7]=o);let p;e[8]===o?p=e[9]:(p=(0,s.jsx)("span",{className:"text-xs",children:o}),e[8]=o,e[9]=p);let S=c,b;e[10]===S?b=e[11]:(b=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(ot,{variableName:S}),")"]}),e[10]=S,e[11]=b);let N;e[12]!==x||e[13]!==i?(N=!i&&(0,s.jsx)(Ma,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=i,e[14]=N):N=e[14];let y;e[15]!==m||e[16]!==p||e[17]!==b||e[18]!==N?(y=(0,s.jsxs)(Fe,{className:"pr-2",style:h,children:[m,p,b,N]}),e[15]=m,e[16]=p,e[17]=b,e[18]=N,e[19]=y):y=e[19];let j;e[20]!==l||e[21]!==n?(j=n?l:(0,s.jsx)(le,{content:"No databases available",style:E(A.engineEmpty)}),e[20]=l,e[21]=n,e[22]=j):j=e[22];let g;return e[23]!==j||e[24]!==y?(g=(0,s.jsxs)(s.Fragment,{children:[y,j]}),e[23]=j,e[24]=y,e[25]=g):g=e[25],g},Ge=F.createContext(null);function He(){let a=F.useContext(Ge);if(a==null)throw Error("useDataSourceTree must be used within a DataSourceTreeContext.Provider");return a}function Ke(a,{schema:e,schemaPath:t}){return{engine:a.engineName,database:a.databaseName,schema:e,schemaPath:t,defaultSchema:a.defaultSchema,defaultDatabase:a.defaultDatabase,dialect:a.dialect}}var ft=a=>{let e=(0,U.c)(21),{connection:t,database:l,searchValue:n}=a,i;e[0]!==t.default_database||e[1]!==t.default_schema||e[2]!==t.dialect||e[3]!==t.name||e[4]!==l.name||e[5]!==n?(i={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,searchValue:n},e[0]=t.default_database,e[1]=t.default_schema,e[2]=t.dialect,e[3]=t.name,e[4]=l.name,e[5]=n,e[6]=i):i=e[6];let c=i,d=t.name,r=l.schemas,x;e[7]===l?x=e[8]:(x=we(l),e[7]=l,e[8]=x);let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[9]=h):h=e[9];let m;e[10]!==l.schemas||e[11]!==x?(m=(0,s.jsx)(We,{schemas:r,schemasResolved:x,schemaPath:h,depth:0}),e[10]=l.schemas,e[11]=x,e[12]=m):m=e[12];let o;e[13]!==m||e[14]!==c?(o=(0,s.jsx)(Ge.Provider,{value:c,children:m}),e[13]=m,e[14]=c,e[15]=o):o=e[15];let p;return e[16]!==t.name||e[17]!==l||e[18]!==n||e[19]!==o?(p=(0,s.jsx)(bt,{engineName:d,database:l,searchValue:n,children:o}),e[16]=t.name,e[17]=l,e[18]=n,e[19]=o,e[20]=p):p=e[20],p},bt=a=>{let e=(0,U.c)(29),{searchValue:t,engineName:l,database:n,children:i}=a,c;e[0]!==n||e[1]!==t?(c=da(n,t),e[0]=n,e[1]=t,e[2]=c):c=e[2];let d=c,[r,x]=F.useState(d),[h,m]=F.useState(!1),[o,p]=F.useState(t),[S,b]=F.useState(d);(o!==t||S!==d)&&(p(t),b(d),x(d));let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=E(A.database),e[3]=N):N=e[3];let y;e[4]!==r||e[5]!==h?(y=()=>{x(!r),m(!h)},e[4]=r,e[5]=h,e[6]=y):y=e[6];let j=`${l}:${n.name}`,g;e[7]===r?g=e[8]:(g=(0,s.jsx)($e,{isExpanded:r}),e[7]=r,e[8]=g);let w=h&&r?"text-foreground":"text-muted-foreground",u;e[9]===w?u=e[10]:(u=Q("h-4 w-4",w),e[9]=w,e[10]=u);let _;e[11]===u?_=e[12]:(_=(0,s.jsx)(ce,{className:u}),e[11]=u,e[12]=_);let I=h&&r&&"font-semibold",f;e[13]===I?f=e[14]:(f=Q(I),e[13]=I,e[14]=f);let v;e[15]===n.name?v=e[16]:(v=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[15]=n.name,e[16]=v);let C;e[17]!==f||e[18]!==v?(C=(0,s.jsx)("span",{className:f,children:v}),e[17]=f,e[18]=v,e[19]=C):C=e[19];let k;e[20]!==C||e[21]!==y||e[22]!==j||e[23]!==g||e[24]!==_?(k=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:N,onSelect:y,value:j,children:[g,_,C]}),e[20]=C,e[21]=y,e[22]=j,e[23]=g,e[24]=_,e[25]=k):k=e[25];let T=r&&i,P;return e[26]!==k||e[27]!==T?(P=(0,s.jsxs)(s.Fragment,{children:[k,T]}),e[26]=k,e[27]=T,e[28]=P):P=e[28],P},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:i,databaseName:c,searchValue:d}=n,{addSchemaList:r}=ie(),x=st(a.schemaPath),[h,m]=F.useState(!1),{isPending:o,error:p}=pe(async()=>{if(!t&&i){m(!0);try{r({schemas:(await na.request({engine:i,database:c,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:i,database:c,schemaPath:x}})}finally{m(!1)}}},[t,i,c,x]),S=E(Oe(l));return o||h?(0,s.jsx)(he,{message:"Loading schemas...",style:S}):p?(0,s.jsx)(ue,{error:p,style:S}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:S}):(0,s.jsx)(s.Fragment,{children:e.map(b=>ia(b.name)?(0,s.jsx)(be,{tables:b.tables,tablesResolved:me(b),searchValue:d,sqlTableContext:Ke(n,{schema:b.name,schemaPath:x})},b.name):(0,s.jsx)(gt,{schema:b,schemaPath:[...x,b.name],depth:l},b.name))})},gt=a=>{let e=(0,U.c)(39),{schema:t,schemaPath:l,depth:n}=a,i=He(),{databaseName:c,searchValue:d}=i,r;e[0]!==t||e[1]!==d?(r=ma(t,d),e[0]=t,e[1]=d,e[2]=r):r=e[2];let x=r,[h,m]=F.useState(x),[o,p]=F.useState(!1),[S,b]=F.useState(d),[N,y]=F.useState(x),j=`${c}:${l.join(".")}`,g;e[3]===t.child_schemas?g=e[4]:(g=t.child_schemas??[],e[3]=t.child_schemas,e[4]=g);let w=g;(S!==d||N!==x)&&(b(d),y(x),m(x));let u;e[5]===n?u=e[6]:(u=E(Oe(n)),e[5]=n,e[6]=u);let _;e[7]!==h||e[8]!==o?(_=()=>{m(!h),p(!o)},e[7]=h,e[8]=o,e[9]=_):_=e[9];let I;e[10]===h?I=e[11]:(I=(0,s.jsx)($e,{isExpanded:h}),e[10]=h,e[11]=I);let f=o&&h&&"text-foreground",v;e[12]===f?v=e[13]:(v=Q("h-4 w-4 text-muted-foreground",f),e[12]=f,e[13]=v);let C;e[14]===v?C=e[15]:(C=(0,s.jsx)(Na,{className:v}),e[14]=v,e[15]=C);let k=o&&h&&"font-semibold",T;e[16]===k?T=e[17]:(T=Q(k),e[16]=k,e[17]=T);let P;e[18]!==t.name||e[19]!==T?(P=(0,s.jsx)("span",{className:T,children:t.name}),e[18]=t.name,e[19]=T,e[20]=P):P=e[20];let R;e[21]!==P||e[22]!==u||e[23]!==_||e[24]!==I||e[25]!==C||e[26]!==j?(R=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:u,onSelect:_,value:j,children:[I,C,P]}),e[21]=P,e[22]=u,e[23]=_,e[24]=I,e[25]=C,e[26]=j,e[27]=R):R=e[27];let V;e[28]!==w||e[29]!==n||e[30]!==h||e[31]!==t||e[32]!==l||e[33]!==d||e[34]!==i?(V=h&&(0,s.jsxs)(s.Fragment,{children:[(w.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:w,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:me(t),searchValue:d,tableIndentRem:it(n),columnIndentRem:ze(n),sqlTableContext:Ke(i,{schema:t.name,schemaPath:l})})]}),e[28]=w,e[29]=n,e[30]=h,e[31]=t,e[32]=l,e[33]=d,e[34]=i,e[35]=V):V=e[35];let $;return e[36]!==R||e[37]!==V?($=(0,s.jsxs)(s.Fragment,{children:[R,V]}),e[36]=R,e[37]=V,e[38]=$):$=e[38],$},be=a=>{let e=(0,U.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:i,tableIndentRem:c,columnIndentRem:d}=a,r=i===void 0?!0:i,{addTableList:x}=ie(),[h,m]=F.useState(!1),o;e[0]!==x||e[1]!==l||e[2]!==r?(o=async()=>{if(!r&&l){m(!0);let{engine:u,database:_,schema:I,schemaPath:f}=l,v=await wa.request({engine:u,database:_,schema:I,schemaPath:f??[]});if(!(v!=null&&v.tables))throw m(!1),Error("No tables available");x({tables:v.tables,sqlTableContext:l}),m(!1)}},e[0]=x,e[1]=l,e[2]=r,e[3]=o):o=e[3];let p;e[4]!==l||e[5]!==r?(p=[r,l],e[4]=l,e[5]=r,e[6]=p):p=e[6];let{isPending:S,error:b}=pe(o,p),N=c??A.tableLoading,y;e[7]===N?y=e[8]:(y=E(N),e[7]=N,e[8]=y);let j=y;if(S||h){let u;return e[9]===j?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:j}),e[9]=j,e[10]=u),u}if(b){let u;return e[11]!==b||e[12]!==j?(u=(0,s.jsx)(ue,{error:b,style:j}),e[11]=b,e[12]=j,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===j?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:j}),e[14]=j,e[15]=u),u}let g;if(e[16]!==d||e[17]!==n||e[18]!==l||e[19]!==c||e[20]!==t){let u;e[22]===n?u=e[23]:(u=f=>n?f.name.toLowerCase().includes(n.toLowerCase()):!0,e[22]=n,e[23]=u);let _=t.filter(u),I;e[24]!==d||e[25]!==n||e[26]!==l||e[27]!==c?(I=f=>(0,s.jsx)(jt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:c,columnIndentRem:d},f.name),e[24]=d,e[25]=n,e[26]=l,e[27]=c,e[28]=I):I=e[28],g=_.map(I),e[16]=d,e[17]=n,e[18]=l,e[19]=c,e[20]=t,e[21]=g}else g=e[21];let w;return e[29]===g?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:g}),e[29]=g,e[30]=w),w},jt=a=>{let e=(0,U.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:i,columnIndentRem:c}=a,{addTable:d}=ie(),[r,x]=F.useState(!1),h=t.columns.length>0,m;e[0]!==d||e[1]!==r||e[2]!==l||e[3]!==t.name||e[4]!==h?(m=async()=>{if(r&&!h&&l){let{engine:L,database:ae,schema:te,schemaPath:Je}=l,se=await oa.request({engine:L,database:ae,schema:te,tableName:t.name,schemaPath:Je??[]});if(!(se!=null&&se.table))throw Error("No table details available");d({table:se.table,sqlTableContext:l})}},e[0]=d,e[1]=r,e[2]=l,e[3]=t.name,e[4]=h,e[5]=m):m=e[5];let o;e[6]!==r||e[7]!==h?(o=[r,h],e[6]=r,e[7]=h,e[8]=o):o=e[8];let{isFetching:p,isPending:S,error:b}=pe(m,o),N=J(Sa),y=Ka(),{createNewCell:j}=aa(),g=Re(),w;e[9]!==g||e[10]!==N||e[11]!==j||e[12]!==y||e[13]!==l||e[14]!==t?(w=()=>{Ha({autoInstantiate:N,createNewCell:j,fromCellId:y}),g((()=>{if(t.source_type==="catalog"){let L=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${L}")`}if(l)return Se({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return Se({table:t,columnName:"*",sqlTableContext:l});default:return Va(t.source_type),""}})())},e[9]=g,e[10]=N,e[11]=j,e[12]=y,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,_;e[16]!==t.num_columns||e[17]!==t.num_rows?(_=()=>{let L=[];return t.num_rows!=null&&L.push(`${t.num_rows} rows`),t.num_columns!=null&&L.push(`${t.num_columns} columns`),L.length===0?null:(0,s.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:L.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=_):_=e[18];let I=_,f;e[19]!==c||e[20]!==b||e[21]!==p||e[22]!==S||e[23]!==l||e[24]!==t?(f=()=>{let L=E(c??A.tableLoading);if(S||p)return(0,s.jsx)(he,{message:"Loading columns...",style:L});if(b)return(0,s.jsx)(ue,{error:b,style:L});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:L}):ae.map(te=>(0,s.jsx)(yt,{table:t,column:te,sqlTableContext:l,columnIndentRem:c},te.name))},e[19]=c,e[20]=b,e[21]=p,e[22]=S,e[23]=l,e[24]=t,e[25]=f):f=e[25];let v=f,C;e[26]!==r||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(C=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?ja:va,{className:"h-3 w-3",strokeWidth:r||n?2.5:void 0})},e[26]=r,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=C):C=e[30];let k=C,T;e[31]!==l||e[32]!==t.name?(T=Ye(l,t.name),e[31]=l,e[32]=t.name,e[33]=T):T=e[33];let P=T,R=i??(l?A.tableSchemaless:0),V=(r||n)&&"font-semibold",$;e[34]===V?$=e[35]:($=Q("rounded-none group h-8 cursor-pointer",V),e[34]=V,e[35]=$);let D;e[36]===R?D=e[37]:(D=E(R),e[36]=R,e[37]=D);let q;e[38]===r?q=e[39]:(q=()=>x(!r),e[38]=r,e[39]=q);let M;e[40]===k?M=e[41]:(M=k(),e[40]=k,e[41]=M);let O;e[42]===t.name?O=e[43]:(O=(0,s.jsx)("span",{className:"text-sm",children:t.name}),e[42]=t.name,e[43]=O);let z;e[44]!==M||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[M,O]}),e[44]=M,e[45]=O,e[46]=z):z=e[46];let B;e[47]===I?B=e[48]:(B=I(),e[47]=I,e[48]=B);let H;e[49]===u?H=e[50]:(H=Ra.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(za,{className:"h-3 w-3"}),e[51]=Z):Z=e[51];let K;e[52]===H?K=e[53]:(K=(0,s.jsx)(xe,{content:"Add table to notebook",delayDuration:400,children:(0,s.jsx)(ne,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:H,children:Z})}),e[52]=H,e[53]=K);let W;e[54]!==r||e[55]!==D||e[56]!==q||e[57]!==z||e[58]!==B||e[59]!==K||e[60]!==$||e[61]!==P?(W=(0,s.jsxs)(re,{className:$,style:D,value:P,"aria-selected":r,forceMount:!0,onSelect:q,children:[z,B,K]}),e[54]=r,e[55]=D,e[56]=q,e[57]=z,e[58]=B,e[59]=K,e[60]=$,e[61]=P,e[62]=W):W=e[62];let X;e[63]!==r||e[64]!==v?(X=r&&v(),e[63]=r,e[64]=v,e[65]=X):X=e[65];let ee;return e[66]!==W||e[67]!==X?(ee=(0,s.jsxs)(s.Fragment,{children:[W,X]}),e[66]=W,e[67]=X,e[68]=ee):ee=e[68],ee},yt=a=>{var O,z;let e=(0,U.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:i}=a,[c,d]=F.useState(!1),r=J(Ne),x=je(sa);r&&c&&d(!1),x(c?B=>new Set([...B,`${t.name}:${l.name}`]):B=>(B.delete(`${t.name}:${l.name}`),new Set(B)));let h=Re(),{columnsPreviews:m}=ca(),o;e[0]!==l.name||e[1]!==t.primary_keys?(o=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=o):o=e[2];let p=o,S;e[3]!==l.name||e[4]!==t.indexes?(S=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=S):S=e[5];let b=S,N;e[6]===h?N=e[7]:(N=B=>{h(B)},e[6]=h,e[7]=N);let y=N,j=vt,g=c?"font-semibold":"",w;e[8]!==l.name||e[9]!==g?(w=(0,s.jsx)("span",{className:g,children:l.name}),e[8]=l.name,e[9]=g,e[10]=w):w=e[10];let u=w,_=`${t.name}.${l.name}`,I=`${t.name}.${l.name}`,f;e[11]===c?f=e[12]:(f=()=>d(!c),e[11]=c,e[12]=f);let v;e[13]!==i||e[14]!==n?(v=i??(n?ze(0):A.columnLocal),e[13]=i,e[14]=n,e[15]=v):v=e[15];let C;e[16]===v?C=e[17]:(C=E(v),e[16]=v,e[17]=C);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)($a,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let T;e[21]===p?T=e[22]:(T=p&&j({tooltipContent:"Primary key",content:"PK"}),e[21]=p,e[22]=T);let P;e[23]===b?P=e[24]:(P=b&&j({tooltipContent:"Indexed",content:"IDX"}),e[23]=b,e[24]=P);let R;e[25]!==C||e[26]!==k||e[27]!==T||e[28]!==P?(R=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:C,children:[k,T,P]}),e[25]=C,e[26]=k,e[27]=T,e[28]=P,e[29]=R):R=e[29];let V;e[30]===l.name?V=e[31]:(V=(0,s.jsx)(xe,{content:"Copy column name",delayDuration:400,children:(0,s.jsx)(ne,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,s.jsx)(Ua,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=V);let $;e[32]===l.external_type?$=e[33]:($=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=$);let D;e[34]!==R||e[35]!==V||e[36]!==$||e[37]!==_||e[38]!==I||e[39]!==f?(D=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:I,onSelect:f,children:[R,V,$]},_),e[34]=R,e[35]=V,e[36]=$,e[37]=_,e[38]=I,e[39]=f,e[40]=D):D=e[40];let q;e[41]!==l||e[42]!==m||e[43]!==y||e[44]!==c||e[45]!==n||e[46]!==t?(q=c&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:E(A.columnPreview),children:(0,s.jsx)(_a,{children:(0,s.jsx)(Oa,{table:t,column:l,onAddColumnChart:y,preview:m.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=m,e[43]=y,e[44]=c,e[45]=n,e[46]=t,e[47]=q):q=e[47];let M;return e[48]!==D||e[49]!==q?(M=(0,s.jsxs)(s.Fragment,{children:[D,q]}),e[48]=D,e[49]=q,e[50]=M):M=e[50],M};function vt(a){let{tooltipContent:e,content:t}=a;return(0,s.jsx)(xe,{content:e,delayDuration:100,children:(0,s.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:t})})}function Ds(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},Nt=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsx)(rt,{name:e,declaredBy:t})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Type"}),(0,s.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsxs)("div",{className:"max-w-[150px]",children:[(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:t??"",children:t})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Declared By"}),(0,s.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,t,l]=a(),n=i=>{let c=ha(i);c&&xa(c,l)};return(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,s.jsx)("span",{title:"Declared by",children:(0,s.jsx)(mt,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(qe,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>n(e[0])}):(0,s.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((i,c)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(qe,{variant:"focus",cellId:i,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(i)},i),c<e.length-1&&", "]},i))})]}),(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,s.jsx)("span",{title:"Used by",children:(0,s.jsx)(Aa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(nt,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function wt({variables:a,sort:e,cellIdToIndex:t}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=Y(a,n=>n.name);break;case G.type:l=Y(a,n=>n.dataType);break;case G.defs:l=Y(a,n=>t.get(n.declaredBy[0]));break}return e.desc?l.toReversed():l}const Xe=(0,F.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=F.useState([]),[i,c]=F.useState(""),d=ra(),{locale:r}=Ga(),x=(0,F.useMemo)(()=>{let m=o=>{let p=d[o];return ga(p)?`cell-${e.indexOf(o)}`:p??`cell-${e.indexOf(o)}`};return Object.values(t).map(o=>({...o,declaredByNames:o.declaredBy.map(m),usedByNames:o.usedBy.map(m)}))},[t,d,e]),h=Fa({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((o,p)=>m.set(o,p)),wt({variables:x,sort:l[0],cellIdToIndex:m})},[x,l,e]),columns:Nt,getCoreRowModel:Ta(),onGlobalFilterChange:c,getFilteredRowModel:Pa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:r,onSortingChange:n,getSortedRowModel:ka(),state:{sorting:l,globalFilter:i}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ea,{className:"w-full",placeholder:"Search",value:i,onChange:m=>c(m.target.value)}),(0,s.jsxs)(Ya,{className:Q("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Wa,{children:(0,s.jsx)(Be,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map(m=>(0,s.jsx)(Xa,{className:"sticky top-0 bg-background border-b",children:Pe(m.column.columnDef.header,m.getContext())},m.id))})}),(0,s.jsx)(Ja,{children:h.getRowModel().rows.map(m=>(0,s.jsx)(Be,{className:"hover:bg-accent",children:m.getVisibleCells().map(o=>(0,s.jsx)(Qa,{className:"border-b",children:Pe(o.column.columnDef.cell,o.getContext())},o.id))},m.id))})]})]})});Xe.displayName="VariableTable";var St=Te(),_t=Ce("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},ke),Ct=()=>{let a=(0,St.c)(24),e=Ze(),t=ba(),l=J(_e),n=J(Ue),[i,c]=ye(_t),d=l.length+n.length,r;a[0]!==d||a[1]!==i.hasUserInteracted||a[2]!==i.openSections?(r=!i.hasUserInteracted&&d>0?[...new Set([...i.openSections,"datasources"])]:i.openSections,a[0]=d,a[1]=i.hasUserInteracted,a[2]=i.openSections,a[3]=r):r=a[3];let x=r,h;a[4]===c?h=a[5]:(h=u=>{c({openSections:u,hasUserInteracted:!0})},a[4]=c,a[5]=h);let m=h,o=!x.includes("datasources")&&d>0,p;a[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ce,{className:"w-4 h-4"}),a[6]=p):p=a[6];let S;a[7]!==d||a[8]!==o?(S=o&&(0,s.jsx)(ct,{children:d}),a[7]=d,a[8]=o,a[9]=S):S=a[9];let b;a[10]===S?b=a[11]:(b=(0,s.jsxs)(Me,{children:[p,"Data sources",S]}),a[10]=S,a[11]=b);let N;a[12]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(Ee,{children:(0,s.jsx)(xt,{})}),a[12]=N):N=a[12];let y;a[13]===b?y=a[14]:(y=(0,s.jsxs)(Le,{value:"datasources",children:[b,N]}),a[13]=b,a[14]=y);let j;a[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsxs)(Me,{children:[(0,s.jsx)(pa,{className:"w-4 h-4"}),"Variables"]}),a[15]=j):j=a[15];let g;a[16]!==t||a[17]!==e?(g=(0,s.jsxs)(Le,{value:"variables",lastItem:!0,children:[j,(0,s.jsx)(Ee,{children:Object.keys(e).length===0?(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,s.jsx)(Xe,{cellIds:t.inOrderIds,variables:e})})]}),a[16]=t,a[17]=e,a[18]=g):g=a[18];let w;return a[19]!==m||a[20]!==x||a[21]!==y||a[22]!==g?(w=(0,s.jsxs)(Ia,{type:"multiple",value:x,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[y,g]}),a[19]=m,a[20]=x,a[21]=y,a[22]=g,a[23]=w):w=a[23],w};export{Ct as default};
|
|
1
|
+
import{s as ge}from"./chunk-LvLJmgfZ.js";import{d as je,l as ye,p as ve,u as J}from"./useEvent-D91BmmQi.js";import{t as Qe}from"./react-Bj1aDYRI.js";import{$r as Ye,Bn as Ze,Br as Ne,Ct as ea,E as aa,Gr as oe,Hn as ta,Hr as sa,Ir as la,Kr as we,Lt as na,N as ra,Qr as Se,Rt as oa,Tr as ce,Ur as ca,Vr as _e,Wi as Ce,Xr as ma,Yr as ia,Zr as da,d as ha,dr as ua,fn as xa,fr as pa,i as fa,j as ba,jt as ga,mr as ja,ni as Ie,qr as me,ti as ya,wr as va,xr as Na,zn as ke,zr as ie,zt as wa}from"./cells-DzyDERZy.js";import"./react-dom-CSu739Rf.js";import{t as Te}from"./compiler-runtime-B3qBwwSJ.js";import{c as Sa}from"./utils-BWBBpCkT.js";import{t as _a}from"./ErrorBoundary-DzTD8LVq.js";import{t as Q}from"./cn-DYvqRARy.js";import{t as Ca}from"./jsx-runtime-Blw4afVn.js";import"./fullscreen-CTDqNQr6.js";import{r as Ia}from"./config-BJVx3eBW.js";import"./popover-Bcz1Zikb.js";import{$ as de,et as Pe,f as Fe,g as $e,h as he,it as ka,m as ue,nt as Ta,p as le,rt as Pa,tt as Fa,u as $a}from"./JsonOutput-C08yZPMz.js";import"./download-BIGA4WFm.js";import{r as Re}from"./radio-group-DfioQthW.js";import{t as xe}from"./tooltip-4bZlU7jl.js";import{r as Ra,t as ne}from"./button-DDGiD1NW.js";import"./dist-12S8I4CH.js";import{l as Y}from"./arrays-DbOq36rN.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{i as Va}from"./strings--BknHX9C.js";import{r as Da}from"./requests-9-v2bhoi.js";import{t as qa}from"./createLucideIcon-w-Qo9n0R.js";import{t as Ba}from"./x-C-Eq0ag8.js";import{a as La,r as Ma}from"./tree-actions-Dx9CDaxV.js";import"./markdown-renderer-sEayY9-m.js";import{t as Ve}from"./add-connection-dialog-ChQis5IF.js";import{t as De}from"./plus-AgXtozBz.js";import{a as Ea}from"./input-JxFwu-3G.js";import{n as Oa,o as za}from"./column-preview-UAW6odg3.js";import{t as Aa}from"./workflow-e-XGaKyY.js";import"./dist-DcwTQG1A.js";import"./dist-DnjsPBRJ.js";import"./dist-BJZAIIze.js";import"./dist-aRc_dRed.js";import"./dist-CPjTeT8p.js";import"./session-BmukRjSi.js";import"./purify.es-CWmnYhGI.js";import"./dates-C2LWzsCZ.js";import{t as Ua}from"./copy-icon-neDQUo4Q.js";import{t as Ga}from"./context-BFPaAUK_.js";import"./tooltip-B7U4xkIN.js";import"./vega-loader.browser-Dun7Qe4B.js";import"./defaultLocale-DOVIEEPN.js";import"./defaultLocale-BUCH2FMc.js";import{t as qe}from"./cell-link-w5IbCQV4.js";import"./chunk-5FQGJX7Z-Cp0LZT-a.js";import{r as Ha}from"./html-to-image-JaxFFZcr.js";import{o as Ka}from"./focus-CNKbm-Xz.js";import{n as pe}from"./useAsyncData-Bg5iAViP.js";import{a as Wa,i as Xa,n as Ja,o as Be,r as Qa,t as Ya}from"./table-CH2plyy9.js";import"./react-resizable-panels.browser.esm-Z-MD3n3J.js";import{a as Za,f as et,o as re,t as at}from"./command-Dqxie4gq.js";import{n as tt}from"./icons-CIPE8AIY.js";import{t as st}from"./useDeepCompareMemoize-CSMoa-ga.js";import{t as lt}from"./empty-state-CqJvEFRk.js";import{n as nt,t as rt}from"./common-CJ3baa6D.js";import{a as ot,i as ct,n as Le,r as Me,t as Ee}from"./components-DpUIWGaj.js";var mt=qa("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),U=Te(),F=ge(Qe(),1),s=ge(Ca(),1),fe=1;function Oe(a){return 1.75+a*fe}function it(a){return 3+a*fe}function ze(a){return 3.25+a*fe}var A={engineEmpty:.75,engine:.75,database:1,tableLoading:2.75,tableSchemaless:2,columnLocal:1.25,columnPreview:2.5};function E(a){return{paddingLeft:`${a}rem`}}var dt=ve(a=>{let e=a(_e),t=a(ta),l=a(fa);return Y(e,n=>{if(!n.variable_name)return-1;let i=Object.values(t).find(d=>d.name===n.variable_name);if(!i)return 0;let c=l.inOrderIds.indexOf(i.declaredBy[0]);return c===-1?0:c})});const ht=Ce("marimo:datasources:hideEmpty",!1,ke,{getOnInit:!0});function Ae(a){let e=!1,t=[];for(let l of a){if(!me(l)||!oe(l)){t.push(l);continue}let n=l.child_schemas??[],i=Ae(n);if(l.tables.length===0&&i.length===0){e=!0;continue}if(i===n){t.push(l);continue}e=!0,t.push({...l,child_schemas:i})}return e?t:a}function ut(a){let e=!1,t=[];for(let l of a){if(we(l)&&l.schemas.length===0){e=!0;continue}if(l.schemas.length===0){t.push(l);continue}let n=Ae(l.schemas);if(n.length===0){e=!0;continue}if(n===l.schemas){t.push(l);continue}e=!0,t.push({...l,schemas:n})}return e?t:a}const Ue=ve(a=>{let e=new Map(a(la));for(let t of Ie){let l=e.get(t);l&&(l.databases.length===0&&e.delete(t),l.databases.length===1&&l.databases[0].name==="memory"&&l.databases[0].schemas.length===0&&e.delete(t))}return Y([...e.values()],t=>Ie.has(t.name)?1:0)}),xt=()=>{let a=(0,U.c)(40),[e,t]=F.useState(""),[l,n]=ye(ht),i=je(Ne),c=J(dt),d=J(Ue),r;e:{if(!l){r=d;break e}let f,v;a[0]===d?(f=a[1],v=a[2]):(f=!1,v=d.map(C=>{let k=ut(C.databases);return k===C.databases?C:(f=!0,{...C,databases:k})}),a[0]=d,a[1]=f,a[2]=v),r=f?v:d}let x=r;if(c.length===0&&x.length===0){let f;return a[3]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsx)(lt,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:(0,s.jsx)(Ve,{children:(0,s.jsxs)(ne,{variant:"outline",size:"sm",children:["Add database or catalog",(0,s.jsx)(De,{className:"h-4 w-4 ml-2"})]})}),icon:(0,s.jsx)(ce,{})}),a[3]=f):f=a[3],f}let h=!!e.trim(),m;a[4]===i?m=a[5]:(m=f=>{i(f.length>0),t(f)},a[4]=i,a[5]=m);let o;a[6]!==e||a[7]!==m?(o=(0,s.jsx)(Za,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:m,rootClassName:"flex-1 border-r border-b-0"}),a[6]=e,a[7]=m,a[8]=o):o=a[8];let p;a[9]===h?p=a[10]:(p=h&&(0,s.jsx)("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>t(""),children:(0,s.jsx)(Ba,{className:"h-4 w-4"})}),a[9]=h,a[10]=p);let S=!l,b;a[11]!==l||a[12]!==n?(b=()=>n(!l),a[11]=l,a[12]=n,a[13]=b):b=a[13];let N;a[14]!==S||a[15]!==b?(N=(0,s.jsx)(La,{"data-testid":"datasources-hide-empty-button",isVisible:S,onToggle:b,showTooltip:"Show empty schemas and databases",hideTooltip:"Hide empty schemas and databases",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden"}),a[14]=S,a[15]=b,a[16]=N):N=a[16];let y;a[17]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Ve,{children:(0,s.jsx)(ne,{variant:"ghost",size:"sm",className:"px-2 rounded-none focus-visible:outline-hidden",children:(0,s.jsx)(De,{className:"h-4 w-4"})})}),a[17]=y):y=a[17];let j;a[18]!==o||a[19]!==p||a[20]!==N?(j=(0,s.jsxs)("div",{className:"flex items-center w-full border-b",children:[o,p,N,y]}),a[18]=o,a[19]=p,a[20]=N,a[21]=j):j=a[21];let g;if(a[22]!==x||a[23]!==e){let f;a[25]===e?f=a[26]:(f=v=>(0,s.jsx)(pt,{connection:v,hasChildren:v.databases.length>0,children:v.databases.map(C=>(0,s.jsx)(ft,{connection:v,database:C,searchValue:e},C.name))},v.name),a[25]=e,a[26]=f),g=x.map(f),a[22]=x,a[23]=e,a[24]=g}else g=a[24];let w;a[27]!==x.length||a[28]!==c.length?(w=x.length>0&&c.length>0&&(0,s.jsxs)(Fe,{className:"pr-2",style:E(A.engine),children:[(0,s.jsx)(tt,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-xs",children:"Python"})]}),a[27]=x.length,a[28]=c.length,a[29]=w):w=a[29];let u;a[30]!==e||a[31]!==c?(u=c.length>0&&(0,s.jsx)(be,{tables:c,searchValue:e}),a[30]=e,a[31]=c,a[32]=u):u=a[32];let _;a[33]!==w||a[34]!==u||a[35]!==g?(_=(0,s.jsxs)(et,{className:"flex flex-col",children:[g,w,u]}),a[33]=w,a[34]=u,a[35]=g,a[36]=_):_=a[36];let I;return a[37]!==_||a[38]!==j?(I=(0,s.jsxs)(at,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden",shouldFilter:!1,children:[j,_]}),a[37]=_,a[38]=j,a[39]=I):I=a[39],I};var pt=a=>{let e=(0,U.c)(26),{connection:t,children:l,hasChildren:n}=a,i=t.name===ya,c=i?"In-Memory":t.name,{previewDataSourceConnection:d}=Da(),r;e[0]!==t.name||e[1]!==d?(r=async()=>{await d({engine:t.name})},e[0]=t.name,e[1]=d,e[2]=r):r=e[2];let x=r,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h=E(A.engine),e[3]=h):h=e[3];let m;e[4]===t.dialect?m=e[5]:(m=(0,s.jsx)(ea,{className:"h-4 w-4 text-muted-foreground",name:t.dialect}),e[4]=t.dialect,e[5]=m);let o;e[6]===t.dialect?o=e[7]:(o=ua(t.dialect),e[6]=t.dialect,e[7]=o);let p;e[8]===o?p=e[9]:(p=(0,s.jsx)("span",{className:"text-xs",children:o}),e[8]=o,e[9]=p);let S=c,b;e[10]===S?b=e[11]:(b=(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(0,s.jsx)(ot,{variableName:S}),")"]}),e[10]=S,e[11]=b);let N;e[12]!==x||e[13]!==i?(N=!i&&(0,s.jsx)(Ma,{onClick:x,tooltip:"Refresh connection",className:"ml-auto h-4 p-0",iconClassName:"h-3.5 w-3.5"}),e[12]=x,e[13]=i,e[14]=N):N=e[14];let y;e[15]!==m||e[16]!==p||e[17]!==b||e[18]!==N?(y=(0,s.jsxs)(Fe,{className:"pr-2",style:h,children:[m,p,b,N]}),e[15]=m,e[16]=p,e[17]=b,e[18]=N,e[19]=y):y=e[19];let j;e[20]!==l||e[21]!==n?(j=n?l:(0,s.jsx)(le,{content:"No databases available",style:E(A.engineEmpty)}),e[20]=l,e[21]=n,e[22]=j):j=e[22];let g;return e[23]!==j||e[24]!==y?(g=(0,s.jsxs)(s.Fragment,{children:[y,j]}),e[23]=j,e[24]=y,e[25]=g):g=e[25],g},Ge=F.createContext(null);function He(){let a=F.useContext(Ge);if(a==null)throw Error("useDataSourceTree must be used within a DataSourceTreeContext.Provider");return a}function Ke(a,{schema:e,schemaPath:t}){return{engine:a.engineName,database:a.databaseName,schema:e,schemaPath:t,defaultSchema:a.defaultSchema,defaultDatabase:a.defaultDatabase,dialect:a.dialect}}var ft=a=>{let e=(0,U.c)(21),{connection:t,database:l,searchValue:n}=a,i;e[0]!==t.default_database||e[1]!==t.default_schema||e[2]!==t.dialect||e[3]!==t.name||e[4]!==l.name||e[5]!==n?(i={engineName:t.name,databaseName:l.name,dialect:t.dialect,defaultSchema:t.default_schema,defaultDatabase:t.default_database,searchValue:n},e[0]=t.default_database,e[1]=t.default_schema,e[2]=t.dialect,e[3]=t.name,e[4]=l.name,e[5]=n,e[6]=i):i=e[6];let c=i,d=t.name,r=l.schemas,x;e[7]===l?x=e[8]:(x=we(l),e[7]=l,e[8]=x);let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=[],e[9]=h):h=e[9];let m;e[10]!==l.schemas||e[11]!==x?(m=(0,s.jsx)(We,{schemas:r,schemasResolved:x,schemaPath:h,depth:0}),e[10]=l.schemas,e[11]=x,e[12]=m):m=e[12];let o;e[13]!==m||e[14]!==c?(o=(0,s.jsx)(Ge.Provider,{value:c,children:m}),e[13]=m,e[14]=c,e[15]=o):o=e[15];let p;return e[16]!==t.name||e[17]!==l||e[18]!==n||e[19]!==o?(p=(0,s.jsx)(bt,{engineName:d,database:l,searchValue:n,children:o}),e[16]=t.name,e[17]=l,e[18]=n,e[19]=o,e[20]=p):p=e[20],p},bt=a=>{let e=(0,U.c)(29),{searchValue:t,engineName:l,database:n,children:i}=a,c;e[0]!==n||e[1]!==t?(c=da(n,t),e[0]=n,e[1]=t,e[2]=c):c=e[2];let d=c,[r,x]=F.useState(d),[h,m]=F.useState(!1),[o,p]=F.useState(t),[S,b]=F.useState(d);(o!==t||S!==d)&&(p(t),b(d),x(d));let N;e[3]===Symbol.for("react.memo_cache_sentinel")?(N=E(A.database),e[3]=N):N=e[3];let y;e[4]!==r||e[5]!==h?(y=()=>{x(!r),m(!h)},e[4]=r,e[5]=h,e[6]=y):y=e[6];let j=`${l}:${n.name}`,g;e[7]===r?g=e[8]:(g=(0,s.jsx)($e,{isExpanded:r}),e[7]=r,e[8]=g);let w=h&&r?"text-foreground":"text-muted-foreground",u;e[9]===w?u=e[10]:(u=Q("h-4 w-4",w),e[9]=w,e[10]=u);let _;e[11]===u?_=e[12]:(_=(0,s.jsx)(ce,{className:u}),e[11]=u,e[12]=_);let I=h&&r&&"font-semibold",f;e[13]===I?f=e[14]:(f=Q(I),e[13]=I,e[14]=f);let v;e[15]===n.name?v=e[16]:(v=n.name===""?(0,s.jsx)("i",{children:"Not connected"}):n.name,e[15]=n.name,e[16]=v);let C;e[17]!==f||e[18]!==v?(C=(0,s.jsx)("span",{className:f,children:v}),e[17]=f,e[18]=v,e[19]=C):C=e[19];let k;e[20]!==C||e[21]!==y||e[22]!==j||e[23]!==g||e[24]!==_?(k=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:N,onSelect:y,value:j,children:[g,_,C]}),e[20]=C,e[21]=y,e[22]=j,e[23]=g,e[24]=_,e[25]=k):k=e[25];let T=r&&i,P;return e[26]!==k||e[27]!==T?(P=(0,s.jsxs)(s.Fragment,{children:[k,T]}),e[26]=k,e[27]=T,e[28]=P):P=e[28],P},We=a=>{let{schemas:e,schemasResolved:t,depth:l}=a,n=He(),{engineName:i,databaseName:c,searchValue:d}=n,{addSchemaList:r}=ie(),x=st(a.schemaPath),[h,m]=F.useState(!1),{isPending:o,error:p}=pe(async()=>{if(!t&&i){m(!0);try{r({schemas:(await na.request({engine:i,database:c,schemaPath:x})).schemas??[],sqlSchemaContext:{engine:i,database:c,schemaPath:x}})}finally{m(!1)}}},[t,i,c,x]),S=E(Oe(l));return o||h?(0,s.jsx)(he,{message:"Loading schemas...",style:S}):p?(0,s.jsx)(ue,{error:p,style:S}):e.length===0?(0,s.jsx)(le,{content:"No schemas available",style:S}):(0,s.jsx)(s.Fragment,{children:e.map(b=>ia(b.name)?(0,s.jsx)(be,{tables:b.tables,tablesResolved:me(b),searchValue:d,sqlTableContext:Ke(n,{schema:b.name,schemaPath:x})},b.name):(0,s.jsx)(gt,{schema:b,schemaPath:[...x,b.name],depth:l},b.name))})},gt=a=>{let e=(0,U.c)(39),{schema:t,schemaPath:l,depth:n}=a,i=He(),{databaseName:c,searchValue:d}=i,r;e[0]!==t||e[1]!==d?(r=ma(t,d),e[0]=t,e[1]=d,e[2]=r):r=e[2];let x=r,[h,m]=F.useState(x),[o,p]=F.useState(!1),[S,b]=F.useState(d),[N,y]=F.useState(x),j=`${c}:${l.join(".")}`,g;e[3]===t.child_schemas?g=e[4]:(g=t.child_schemas??[],e[3]=t.child_schemas,e[4]=g);let w=g;(S!==d||N!==x)&&(b(d),y(x),m(x));let u;e[5]===n?u=e[6]:(u=E(Oe(n)),e[5]=n,e[6]=u);let _;e[7]!==h||e[8]!==o?(_=()=>{m(!h),p(!o)},e[7]=h,e[8]=o,e[9]=_):_=e[9];let I;e[10]===h?I=e[11]:(I=(0,s.jsx)($e,{isExpanded:h}),e[10]=h,e[11]=I);let f=o&&h&&"text-foreground",v;e[12]===f?v=e[13]:(v=Q("h-4 w-4 text-muted-foreground",f),e[12]=f,e[13]=v);let C;e[14]===v?C=e[15]:(C=(0,s.jsx)(Na,{className:v}),e[14]=v,e[15]=C);let k=o&&h&&"font-semibold",T;e[16]===k?T=e[17]:(T=Q(k),e[16]=k,e[17]=T);let P;e[18]!==t.name||e[19]!==T?(P=(0,s.jsx)("span",{className:T,children:t.name}),e[18]=t.name,e[19]=T,e[20]=P):P=e[20];let R;e[21]!==P||e[22]!==u||e[23]!==_||e[24]!==I||e[25]!==C||e[26]!==j?(R=(0,s.jsxs)(re,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",style:u,onSelect:_,value:j,children:[I,C,P]}),e[21]=P,e[22]=u,e[23]=_,e[24]=I,e[25]=C,e[26]=j,e[27]=R):R=e[27];let V;e[28]!==w||e[29]!==n||e[30]!==h||e[31]!==t||e[32]!==l||e[33]!==d||e[34]!==i?(V=h&&(0,s.jsxs)(s.Fragment,{children:[(w.length>0||!oe(t))&&(0,s.jsx)(We,{schemas:w,schemasResolved:oe(t),schemaPath:l,depth:n+1}),(0,s.jsx)(be,{tables:t.tables,tablesResolved:me(t),searchValue:d,tableIndentRem:it(n),columnIndentRem:ze(n),sqlTableContext:Ke(i,{schema:t.name,schemaPath:l})})]}),e[28]=w,e[29]=n,e[30]=h,e[31]=t,e[32]=l,e[33]=d,e[34]=i,e[35]=V):V=e[35];let $;return e[36]!==R||e[37]!==V?($=(0,s.jsxs)(s.Fragment,{children:[R,V]}),e[36]=R,e[37]=V,e[38]=$):$=e[38],$},be=a=>{let e=(0,U.c)(31),{tables:t,sqlTableContext:l,searchValue:n,tablesResolved:i,tableIndentRem:c,columnIndentRem:d}=a,r=i===void 0?!0:i,{addTableList:x}=ie(),[h,m]=F.useState(!1),o;e[0]!==x||e[1]!==l||e[2]!==r?(o=async()=>{if(!r&&l){m(!0);let{engine:u,database:_,schema:I,schemaPath:f}=l,v=await wa.request({engine:u,database:_,schema:I,schemaPath:f??[]});if(!(v!=null&&v.tables))throw m(!1),Error("No tables available");x({tables:v.tables,sqlTableContext:l}),m(!1)}},e[0]=x,e[1]=l,e[2]=r,e[3]=o):o=e[3];let p;e[4]!==l||e[5]!==r?(p=[r,l],e[4]=l,e[5]=r,e[6]=p):p=e[6];let{isPending:S,error:b}=pe(o,p),N=c??A.tableLoading,y;e[7]===N?y=e[8]:(y=E(N),e[7]=N,e[8]=y);let j=y;if(S||h){let u;return e[9]===j?u=e[10]:(u=(0,s.jsx)(he,{message:"Loading tables...",style:j}),e[9]=j,e[10]=u),u}if(b){let u;return e[11]!==b||e[12]!==j?(u=(0,s.jsx)(ue,{error:b,style:j}),e[11]=b,e[12]=j,e[13]=u):u=e[13],u}if(t.length===0){let u;return e[14]===j?u=e[15]:(u=(0,s.jsx)(le,{content:"No tables found",style:j}),e[14]=j,e[15]=u),u}let g;if(e[16]!==d||e[17]!==n||e[18]!==l||e[19]!==c||e[20]!==t){let u;e[22]===n?u=e[23]:(u=f=>n?f.name.toLowerCase().includes(n.toLowerCase()):!0,e[22]=n,e[23]=u);let _=t.filter(u),I;e[24]!==d||e[25]!==n||e[26]!==l||e[27]!==c?(I=f=>(0,s.jsx)(jt,{table:f,sqlTableContext:l,isSearching:!!n,tableIndentRem:c,columnIndentRem:d},f.name),e[24]=d,e[25]=n,e[26]=l,e[27]=c,e[28]=I):I=e[28],g=_.map(I),e[16]=d,e[17]=n,e[18]=l,e[19]=c,e[20]=t,e[21]=g}else g=e[21];let w;return e[29]===g?w=e[30]:(w=(0,s.jsx)(s.Fragment,{children:g}),e[29]=g,e[30]=w),w},jt=a=>{let e=(0,U.c)(69),{table:t,sqlTableContext:l,isSearching:n,tableIndentRem:i,columnIndentRem:c}=a,{addTable:d}=ie(),[r,x]=F.useState(!1),h=t.columns.length>0,m;e[0]!==d||e[1]!==r||e[2]!==l||e[3]!==t.name||e[4]!==h?(m=async()=>{if(r&&!h&&l){let{engine:L,database:ae,schema:te,schemaPath:Je}=l,se=await oa.request({engine:L,database:ae,schema:te,tableName:t.name,schemaPath:Je??[]});if(!(se!=null&&se.table))throw Error("No table details available");d({table:se.table,sqlTableContext:l})}},e[0]=d,e[1]=r,e[2]=l,e[3]=t.name,e[4]=h,e[5]=m):m=e[5];let o;e[6]!==r||e[7]!==h?(o=[r,h],e[6]=r,e[7]=h,e[8]=o):o=e[8];let{isFetching:p,isPending:S,error:b}=pe(m,o),N=J(Sa),y=Ka(),{createNewCell:j}=aa(),g=Re(),w;e[9]!==g||e[10]!==N||e[11]!==j||e[12]!==y||e[13]!==l||e[14]!==t?(w=()=>{Ha({autoInstantiate:N,createNewCell:j,fromCellId:y}),g((()=>{if(t.source_type==="catalog"){let L=l!=null&&l.database?[l.database,...l.schemaPath??[],t.name].join("."):t.name;return`${t.engine}.load_table("${L}")`}if(l)return Se({table:t,columnName:"*",sqlTableContext:l});switch(t.source_type){case"local":return`mo.ui.table(${t.name})`;case"duckdb":case"connection":return Se({table:t,columnName:"*",sqlTableContext:l});default:return Va(t.source_type),""}})())},e[9]=g,e[10]=N,e[11]=j,e[12]=y,e[13]=l,e[14]=t,e[15]=w):w=e[15];let u=w,_;e[16]!==t.num_columns||e[17]!==t.num_rows?(_=()=>{let L=[];return t.num_rows!=null&&L.push(`${t.num_rows} rows`),t.num_columns!=null&&L.push(`${t.num_columns} columns`),L.length===0?null:(0,s.jsx)("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:L.join(", ")})})},e[16]=t.num_columns,e[17]=t.num_rows,e[18]=_):_=e[18];let I=_,f;e[19]!==c||e[20]!==b||e[21]!==p||e[22]!==S||e[23]!==l||e[24]!==t?(f=()=>{let L=E(c??A.tableLoading);if(S||p)return(0,s.jsx)(he,{message:"Loading columns...",style:L});if(b)return(0,s.jsx)(ue,{error:b,style:L});let ae=t.columns;return ae.length===0?(0,s.jsx)(le,{content:"No columns found",style:L}):ae.map(te=>(0,s.jsx)(yt,{table:t,column:te,sqlTableContext:l,columnIndentRem:c},te.name))},e[19]=c,e[20]=b,e[21]=p,e[22]=S,e[23]=l,e[24]=t,e[25]=f):f=e[25];let v=f,C;e[26]!==r||e[27]!==n||e[28]!==t.source_type||e[29]!==t.type?(C=()=>{if(t.source_type!=="local")return(0,s.jsx)(t.type==="table"?ja:va,{className:"h-3 w-3",strokeWidth:r||n?2.5:void 0})},e[26]=r,e[27]=n,e[28]=t.source_type,e[29]=t.type,e[30]=C):C=e[30];let k=C,T;e[31]!==l||e[32]!==t.name?(T=Ye(l,t.name),e[31]=l,e[32]=t.name,e[33]=T):T=e[33];let P=T,R=i??(l?A.tableSchemaless:0),V=(r||n)&&"font-semibold",$;e[34]===V?$=e[35]:($=Q("rounded-none group h-8 cursor-pointer",V),e[34]=V,e[35]=$);let D;e[36]===R?D=e[37]:(D=E(R),e[36]=R,e[37]=D);let q;e[38]===r?q=e[39]:(q=()=>x(!r),e[38]=r,e[39]=q);let M;e[40]===k?M=e[41]:(M=k(),e[40]=k,e[41]=M);let O;e[42]===t.name?O=e[43]:(O=(0,s.jsx)("span",{className:"text-sm",children:t.name}),e[42]=t.name,e[43]=O);let z;e[44]!==M||e[45]!==O?(z=(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-1 pl-1",children:[M,O]}),e[44]=M,e[45]=O,e[46]=z):z=e[46];let B;e[47]===I?B=e[48]:(B=I(),e[47]=I,e[48]=B);let H;e[49]===u?H=e[50]:(H=Ra.stopPropagation(()=>u()),e[49]=u,e[50]=H);let Z;e[51]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,s.jsx)(za,{className:"h-3 w-3"}),e[51]=Z):Z=e[51];let K;e[52]===H?K=e[53]:(K=(0,s.jsx)(xe,{content:"Add table to notebook",delayDuration:400,children:(0,s.jsx)(ne,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:H,children:Z})}),e[52]=H,e[53]=K);let W;e[54]!==r||e[55]!==D||e[56]!==q||e[57]!==z||e[58]!==B||e[59]!==K||e[60]!==$||e[61]!==P?(W=(0,s.jsxs)(re,{className:$,style:D,value:P,"aria-selected":r,forceMount:!0,onSelect:q,children:[z,B,K]}),e[54]=r,e[55]=D,e[56]=q,e[57]=z,e[58]=B,e[59]=K,e[60]=$,e[61]=P,e[62]=W):W=e[62];let X;e[63]!==r||e[64]!==v?(X=r&&v(),e[63]=r,e[64]=v,e[65]=X):X=e[65];let ee;return e[66]!==W||e[67]!==X?(ee=(0,s.jsxs)(s.Fragment,{children:[W,X]}),e[66]=W,e[67]=X,e[68]=ee):ee=e[68],ee},yt=a=>{var O,z;let e=(0,U.c)(51),{table:t,column:l,sqlTableContext:n,columnIndentRem:i}=a,[c,d]=F.useState(!1),r=J(Ne),x=je(sa);r&&c&&d(!1),x(c?B=>new Set([...B,`${t.name}:${l.name}`]):B=>(B.delete(`${t.name}:${l.name}`),new Set(B)));let h=Re(),{columnsPreviews:m}=ca(),o;e[0]!==l.name||e[1]!==t.primary_keys?(o=((O=t.primary_keys)==null?void 0:O.includes(l.name))||!1,e[0]=l.name,e[1]=t.primary_keys,e[2]=o):o=e[2];let p=o,S;e[3]!==l.name||e[4]!==t.indexes?(S=((z=t.indexes)==null?void 0:z.includes(l.name))||!1,e[3]=l.name,e[4]=t.indexes,e[5]=S):S=e[5];let b=S,N;e[6]===h?N=e[7]:(N=B=>{h(B)},e[6]=h,e[7]=N);let y=N,j=vt,g=c?"font-semibold":"",w;e[8]!==l.name||e[9]!==g?(w=(0,s.jsx)("span",{className:g,children:l.name}),e[8]=l.name,e[9]=g,e[10]=w):w=e[10];let u=w,_=`${t.name}.${l.name}`,I=`${t.name}.${l.name}`,f;e[11]===c?f=e[12]:(f=()=>d(!c),e[11]=c,e[12]=f);let v;e[13]!==i||e[14]!==n?(v=i??(n?ze(0):A.columnLocal),e[13]=i,e[14]=n,e[15]=v):v=e[15];let C;e[16]===v?C=e[17]:(C=E(v),e[16]=v,e[17]=C);let k;e[18]!==l.type||e[19]!==u?(k=(0,s.jsx)($a,{columnName:u,dataType:l.type}),e[18]=l.type,e[19]=u,e[20]=k):k=e[20];let T;e[21]===p?T=e[22]:(T=p&&j({tooltipContent:"Primary key",content:"PK"}),e[21]=p,e[22]=T);let P;e[23]===b?P=e[24]:(P=b&&j({tooltipContent:"Indexed",content:"IDX"}),e[23]=b,e[24]=P);let R;e[25]!==C||e[26]!==k||e[27]!==T||e[28]!==P?(R=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center flex-1",style:C,children:[k,T,P]}),e[25]=C,e[26]=k,e[27]=T,e[28]=P,e[29]=R):R=e[29];let V;e[30]===l.name?V=e[31]:(V=(0,s.jsx)(xe,{content:"Copy column name",delayDuration:400,children:(0,s.jsx)(ne,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,s.jsx)(Ua,{tooltip:!1,value:l.name,className:"h-3 w-3"})})}),e[30]=l.name,e[31]=V);let $;e[32]===l.external_type?$=e[33]:($=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:l.external_type}),e[32]=l.external_type,e[33]=$);let D;e[34]!==R||e[35]!==V||e[36]!==$||e[37]!==_||e[38]!==I||e[39]!==f?(D=(0,s.jsxs)(re,{className:"rounded-none py-1 group cursor-pointer",value:I,onSelect:f,children:[R,V,$]},_),e[34]=R,e[35]=V,e[36]=$,e[37]=_,e[38]=I,e[39]=f,e[40]=D):D=e[40];let q;e[41]!==l||e[42]!==m||e[43]!==y||e[44]!==c||e[45]!==n||e[46]!==t?(q=c&&(0,s.jsx)("div",{className:"pr-2 py-2 bg-(--slate-1) shadow-inner border-b",style:E(A.columnPreview),children:(0,s.jsx)(_a,{children:(0,s.jsx)(Oa,{table:t,column:l,onAddColumnChart:y,preview:m.get(n?`${n.database}.${n.schema}.${t.name}:${l.name}`:`${t.name}:${l.name}`),sqlTableContext:n})})}),e[41]=l,e[42]=m,e[43]=y,e[44]=c,e[45]=n,e[46]=t,e[47]=q):q=e[47];let M;return e[48]!==D||e[49]!==q?(M=(0,s.jsxs)(s.Fragment,{children:[D,q]}),e[48]=D,e[49]=q,e[50]=M):M=e[50],M};function vt(a){let{tooltipContent:e,content:t}=a;return(0,s.jsx)(xe,{content:e,delayDuration:100,children:(0,s.jsx)("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:t})})}function Ds(a){return a}var G={name:"name",type:"type-value",defs:"defs-refs"},Nt=[{id:G.name,accessorFn:a=>[a.name,a.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:"Name",column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsx)(rt,{name:e,declaredBy:t})}},{id:G.type,accessorFn:a=>[a.dataType,a.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Type"}),(0,s.jsx)("span",{children:"Value"})]}),column:a}),cell:({getValue:a})=>{let[e,t]=a();return(0,s.jsxs)("div",{className:"max-w-[150px]",children:[(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),(0,s.jsx)("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:t??"",children:t})]})}},{id:G.defs,accessorFn:a=>[a.declaredBy,a.usedBy,a.name,a.declaredByNames,a.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:a})=>(0,s.jsx)(de,{header:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("span",{children:"Declared By"}),(0,s.jsx)("span",{children:"Used By"})]}),column:a}),cell:({getValue:a})=>{let[e,t,l]=a(),n=i=>{let c=ha(i);c&&xa(c,l)};return(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-1",children:[(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[(0,s.jsx)("span",{title:"Declared by",children:(0,s.jsx)(mt,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?(0,s.jsx)(qe,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>n(e[0])}):(0,s.jsx)("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((i,c)=>(0,s.jsxs)("span",{className:"flex",children:[(0,s.jsx)(qe,{variant:"focus",cellId:i,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>n(i)},i),c<e.length-1&&", "]},i))})]}),(0,s.jsxs)("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[(0,s.jsx)("span",{title:"Used by",children:(0,s.jsx)(Aa,{className:"w-3.5 h-3.5 text-muted-foreground"})}),(0,s.jsx)(nt,{maxCount:3,cellIds:t,skipScroll:!0,onClick:n})]})]})}}];function wt({variables:a,sort:e,cellIdToIndex:t}){e||(e={id:G.defs,desc:!1});let l=[];switch(e.id){case G.name:l=Y(a,n=>n.name);break;case G.type:l=Y(a,n=>n.dataType);break;case G.defs:l=Y(a,n=>t.get(n.declaredBy[0]));break}return e.desc?l.toReversed():l}const Xe=(0,F.memo)(({className:a,cellIds:e,variables:t})=>{let[l,n]=F.useState([]),[i,c]=F.useState(""),d=ra(),{locale:r}=Ga(),x=(0,F.useMemo)(()=>{let m=o=>{let p=d[o];return ga(p)?`cell-${e.indexOf(o)}`:p??`cell-${e.indexOf(o)}`};return Object.values(t).map(o=>({...o,declaredByNames:o.declaredBy.map(m),usedByNames:o.usedBy.map(m)}))},[t,d,e]),h=Fa({data:(0,F.useMemo)(()=>{let m=new Map;return e.forEach((o,p)=>m.set(o,p)),wt({variables:x,sort:l[0],cellIdToIndex:m})},[x,l,e]),columns:Nt,getCoreRowModel:Ta(),onGlobalFilterChange:c,getFilteredRowModel:Pa(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter(m){return m.columnDef.enableGlobalFilter??!0},globalFilterFn:"auto",manualSorting:!0,locale:r,onSortingChange:n,getSortedRowModel:ka(),state:{sorting:l,globalFilter:i}});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Ea,{className:"w-full",placeholder:"Search",value:i,onChange:m=>c(m.target.value)}),(0,s.jsxs)(Ya,{className:Q("w-full text-sm flex-1 border-separate border-spacing-0",a),children:[(0,s.jsx)(Wa,{children:(0,s.jsx)(Be,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map(m=>(0,s.jsx)(Xa,{className:"sticky top-0 bg-background border-b",children:Pe(m.column.columnDef.header,m.getContext())},m.id))})}),(0,s.jsx)(Ja,{children:h.getRowModel().rows.map(m=>(0,s.jsx)(Be,{className:"hover:bg-accent",children:m.getVisibleCells().map(o=>(0,s.jsx)(Qa,{className:"border-b",children:Pe(o.column.columnDef.cell,o.getContext())},o.id))},m.id))})]})]})});Xe.displayName="VariableTable";var St=Te(),_t=Ce("marimo:session-panel:state",{openSections:["variables"],hasUserInteracted:!1},ke),Ct=()=>{let a=(0,St.c)(24),e=Ze(),t=ba(),l=J(_e),n=J(Ue),[i,c]=ye(_t),d=l.length+n.length,r;a[0]!==d||a[1]!==i.hasUserInteracted||a[2]!==i.openSections?(r=!i.hasUserInteracted&&d>0?[...new Set([...i.openSections,"datasources"])]:i.openSections,a[0]=d,a[1]=i.hasUserInteracted,a[2]=i.openSections,a[3]=r):r=a[3];let x=r,h;a[4]===c?h=a[5]:(h=u=>{c({openSections:u,hasUserInteracted:!0})},a[4]=c,a[5]=h);let m=h,o=!x.includes("datasources")&&d>0,p;a[6]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ce,{className:"w-4 h-4"}),a[6]=p):p=a[6];let S;a[7]!==d||a[8]!==o?(S=o&&(0,s.jsx)(ct,{children:d}),a[7]=d,a[8]=o,a[9]=S):S=a[9];let b;a[10]===S?b=a[11]:(b=(0,s.jsxs)(Me,{children:[p,"Data sources",S]}),a[10]=S,a[11]=b);let N;a[12]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(Ee,{children:(0,s.jsx)(xt,{})}),a[12]=N):N=a[12];let y;a[13]===b?y=a[14]:(y=(0,s.jsxs)(Le,{value:"datasources",children:[b,N]}),a[13]=b,a[14]=y);let j;a[15]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsxs)(Me,{children:[(0,s.jsx)(pa,{className:"w-4 h-4"}),"Variables"]}),a[15]=j):j=a[15];let g;a[16]!==t||a[17]!==e?(g=(0,s.jsxs)(Le,{value:"variables",lastItem:!0,children:[j,(0,s.jsx)(Ee,{children:Object.keys(e).length===0?(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground",children:"No variables defined"}):(0,s.jsx)(Xe,{cellIds:t.inOrderIds,variables:e})})]}),a[16]=t,a[17]=e,a[18]=g):g=a[18];let w;return a[19]!==m||a[20]!==x||a[21]!==y||a[22]!==g?(w=(0,s.jsxs)(Ia,{type:"multiple",value:x,onValueChange:m,className:"flex flex-col h-full overflow-auto",children:[y,g]}),a[19]=m,a[20]=x,a[21]=y,a[22]=g,a[23]=w):w=a[23],w};export{Ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var A=Object.defineProperty;var N=(t,e,
|
|
1
|
+
var A=Object.defineProperty;var N=(t,e,r)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var b=(t,e,r)=>N(t,typeof e!="symbol"?e+"":e,r);import{s as T}from"./chunk-LvLJmgfZ.js";import{u as I}from"./useEvent-D91BmmQi.js";import{a as V}from"./cells-DzyDERZy.js";import{t as M}from"./compiler-runtime-B3qBwwSJ.js";import{g as k}from"./useEventListener-C0195JsF.js";import{t as E}from"./objects-BlG0ZrO0.js";import{o as _}from"./utils-BWBBpCkT.js";import{T as P,v as z}from"./config-B-Q7J_6d.js";import{t as D}from"./cn-DYvqRARy.js";import{t as $}from"./jsx-runtime-Blw4afVn.js";import{c as B,d as H}from"./download-BIGA4WFm.js";import{r as L}from"./requests-9-v2bhoi.js";import{F as R}from"./layout-B8cCh91r.js";import{t as Y}from"./Deferred-D2igisxY.js";import{t as q}from"./use-toast-BwJoaaDM.js";import{t as x}from"./useInterval-CWBTUy5W.js";var G=class{constructor(){b(this,"capturedInputs",new Map);b(this,"inFlight",new Map)}cancelEntry(t){t.controller.abort(),t.deferred.status==="pending"&&t.deferred.resolve(void 0)}needsCapture(t,e){if(this.capturedInputs.get(t)===e)return!1;let r=this.inFlight.get(t);return!(r&&r.inputValue===e)}waitForInFlight(t,e){let r=this.inFlight.get(t);return r&&r.inputValue===e?r.deferred.promise:null}startCapture(t,e){let r=this.inFlight.get(t);r&&this.cancelEntry(r);let a=new AbortController,i=new Y,s={controller:a,inputValue:e,deferred:i};return this.inFlight.set(t,s),{signal:a.signal,markCaptured:p=>{this.inFlight.get(t)===s&&(i.resolve(p),this.capturedInputs.set(t,e),this.inFlight.delete(t))},markFailed:()=>{this.inFlight.get(t)===s&&(i.resolve(void 0),this.inFlight.delete(t))}}}prune(t){for(let e of this.capturedInputs.keys())t.has(e)||this.capturedInputs.delete(e);for(let[e,r]of this.inFlight)t.has(e)||(this.cancelEntry(r),this.inFlight.delete(e))}get isCapturing(){return this.inFlight.size>0}abort(){for(let t of this.inFlight.values())this.cancelEntry(t);this.inFlight.clear()}reset(){this.abort(),this.capturedInputs.clear()}},J=M(),S=5e3;function K(){let t=(0,J.c)(14),e=I(_),{state:r}=I(z),a=e.auto_download.includes("markdown"),i=e.auto_download.includes("html"),s=e.auto_download.includes("ipynb"),p=r===P.OPEN,m=!a||!p,d=!i||!p,c=!s||!p,{autoExportAsHTML:l,autoExportAsIPYNB:o,autoExportAsMarkdown:n,updateCellOutputs:u}=L(),h=O(),f;t[0]===n?f=t[1]:(f=async()=>{await n({download:!1})},t[0]=n,t[1]=f);let g;t[2]===m?g=t[3]:(g={delayMs:S,whenVisible:!0,disabled:m},t[2]=m,t[3]=g),x(f,g);let w;t[4]===l?w=t[5]:(w=async()=>{await l({download:!1,includeCode:!0,files:R.INSTANCE.filenames()})},t[4]=l,t[5]=w);let v;t[6]===d?v=t[7]:(v={delayMs:S,whenVisible:!0,disabled:d},t[6]=d,t[7]=v),x(w,v);let F;t[8]!==o||t[9]!==h||t[10]!==u?(F=async()=>{await j({takeScreenshots:()=>h({progress:H.indeterminate()}),updateCellOutputs:u}),await o({download:!1})},t[8]=o,t[9]=h,t[10]=u,t[11]=F):F=t[11];let y;t[12]===c?y=t[13]:(y={delayMs:S,whenVisible:!0,disabled:c,skipIfRunning:!0},t[12]=c,t[13]=y),x(F,y)}var Q=new Set(["text/html","application/vnd.vegalite.v5+json","application/vnd.vega.v5+json","application/vnd.vegalite.v6+json","application/vnd.vega.v6+json"]);const C=new G;function O(){let t=I(V);return async e=>{var d,c;let{progress:r}=e,a=new Set(E.keys(t));C.prune(a);let i=[],s=[];for(let[l,o]of E.entries(t)){let n=(d=o.output)==null?void 0:d.data;if((c=o.output)!=null&&c.mimetype&&Q.has(o.output.mimetype)&&n)if(C.needsCapture(l,n))i.push([l,n]);else{let u=C.waitForInFlight(l,n);u&&s.push({cellId:l,promise:u})}}if(i.length===0&&s.length===0)return{};i.length>0&&r.addTotal(i.length);let p={};for(let[l,o]of i){let n=C.startCapture(l,o);try{let u=await B(l);if(n.signal.aborted)continue;if(!u){k.error(`Failed to capture screenshot for cell ${l}`),n.markFailed();continue}let h=["image/png",u];p[l]=h,n.markCaptured(h)}catch(u){k.error(`Error screenshotting cell ${l}:`,u),n.markFailed()}finally{r.increment(1)}}let m=await Promise.allSettled(s.map(({promise:l})=>l));for(let[l,{cellId:o}]of s.entries()){let n=m[l];n.status==="fulfilled"&&n.value&&(p[o]=n.value)}return p}}async function j(t){let{takeScreenshots:e,updateCellOutputs:r}=t;try{let a=await e();E.size(a)>0&&await r({cellIdsToOutput:a})}catch(a){k.error("Error updating cell outputs with screenshots:",a),q({title:"Failed to capture cell outputs",description:"Some outputs may be missing from the export. Continuing.",variant:"danger"})}}var U=M(),W=T($(),1),X=t=>{let e=(0,U.c)(8),r,a;e[0]===t?(r=e[1],a=e[2]):({className:r,...a}=t,e[0]=t,e[1]=r,e[2]=a);let i;e[3]===r?i=e[4]:(i=D("animate-pulse rounded-md bg-muted",r),e[3]=r,e[4]=i);let s;return e[5]!==a||e[6]!==i?(s=(0,W.jsx)("div",{className:i,...a}),e[5]=a,e[6]=i,e[7]=s):s=e[7],s};export{O as i,j as n,K as r,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as ie,u as b}from"./useEvent-D91BmmQi.js";import{E as de,Er as ne,Gn as se,Or as re,St as F,Tr as ce,Wn as he,_ as me,ar as pe,ea as ke,wr as fe}from"./cells-DzyDERZy.js";import{t as ue}from"./compiler-runtime-B3qBwwSJ.js";import{c as ye,i as be,s as xe}from"./utils-BWBBpCkT.js";import{O as je}from"./config-B-Q7J_6d.js";import{t as ve}from"./jsx-runtime-Blw4afVn.js";import{t as we}from"./label-CqjrpwRC.js";import{a as Ce,g as ge}from"./download-
|
|
1
|
+
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as ie,u as b}from"./useEvent-D91BmmQi.js";import{E as de,Er as ne,Gn as se,Or as re,St as F,Tr as ce,Wn as he,_ as me,ar as pe,ea as ke,wr as fe}from"./cells-DzyDERZy.js";import{t as ue}from"./compiler-runtime-B3qBwwSJ.js";import{c as ye,i as be,s as xe}from"./utils-BWBBpCkT.js";import{O as je}from"./config-B-Q7J_6d.js";import{t as ve}from"./jsx-runtime-Blw4afVn.js";import{t as we}from"./label-CqjrpwRC.js";import{a as Ce,g as ge}from"./download-BIGA4WFm.js";import{r as Ie}from"./requests-9-v2bhoi.js";import{t as f}from"./createLucideIcon-w-Qo9n0R.js";import{n as G,r as K}from"./x-C-Eq0ag8.js";import{t as ze}from"./chevron-right-BS_NcSch.js";import{t as Q}from"./circle-plus-BluydVNx.js";import{t as We}from"./code-xml-aSiY8T7C.js";import{t as Me}from"./eye-off-BOZA7gbn.js";import{t as _e}from"./image-5XI2VU-q.js";import{t as Se}from"./link-CHdiBDr5.js";import{i as Ae,t as Te}from"./useDeleteCell-vMXAr3rY.js";import{t as Ee}from"./sparkles-DUCpRFlS.js";import{t as Oe}from"./trash-2-72W0TZ3L.js";import{t as De}from"./use-toast-BwJoaaDM.js";import{n as Ne}from"./copy-Bxb1_Gtw.js";import{i as Re}from"./useRunCells-C2dvU2jA.js";import{a as Be,c as He,n as Le}from"./dialog-BCVepWLJ.js";import{n as qe}from"./ImperativeModal-fY-ZfT0b.js";import{n as Pe}from"./state-DxQhUsG9.js";import{r as V}from"./html-to-image-JaxFFZcr.js";import{n as Ue,t as Fe}from"./icons-CIPE8AIY.js";import{n as $}from"./name-cell-input-B-aj1KH3.js";import{t as J}from"./multi-icon-nrKPWjDU.js";import{t as Ge}from"./useSplitCell-C1tubdNi.js";var X=f("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Y=f("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Z=f("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),Ke=f("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),ee=f("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),le=f("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Qe(a){let e=new URL(window.location.href);return e.hash=`scrollTo=${encodeURIComponent(a)}`,e.toString()}function Ve(a){var c;let e=(c=a.match(/scrollTo=([^&]+)/))==null?void 0:c[1];return e?decodeURIComponent(e.split("&")[0]):null}function oe(a){return a==="_"?!1:!!(a&&a.trim().length>0)}var $e=ue(),l=ae(ve(),1);function Je(a){let e=(0,$e.c)(47),{cell:c,closePopover:u}=a,{createNewCell:m,updateCellConfig:s,updateCellName:x,moveCell:p,sendToTop:W,sendToBottom:M,addColumnBreakpoint:_,clearCellOutput:S,markUntouched:A}=de(),T=Ge(),E=Re(c==null?void 0:c.cellId),O=!b(me),D=Te(),{openModal:j}=qe(),N=ie(Pe),R=b(be),v=b(ye),te=b(je),y=b(xe),{saveCellConfig:r}=Ie();if(!c||te){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0],o}let{cellId:t,config:i,getEditorView:n,name:h,hasOutput:w,hasConsoleOutput:B,status:H}=c,C;e[1]!==t||e[2]!==i.disabled||e[3]!==r||e[4]!==s?(C=async()=>{let o={disabled:!i.disabled};await r({configs:{[t]:o}}),s({cellId:t,config:o})},e[1]=t,e[2]=i.disabled,e[3]=r,e[4]=s,e[5]=C):C=e[5];let L=C,g;e[6]!==t||e[7]!==i.hide_code||e[8]!==n||e[9]!==r||e[10]!==s?(g=async()=>{let o={hide_code:!i.hide_code};await r({configs:{[t]:o}}),s({cellId:t,config:o});let U=n();U&&(o.hide_code?U.contentDOM.blur():U.focus())},e[6]=t,e[7]=i.hide_code,e[8]=n,e[9]=r,e[10]=s,e[11]=g):g=e[11];let q=g,d=t===ke,I;e[12]===Symbol.for("react.memo_cache_sentinel")?(I=(0,l.jsx)(Ae,{size:13,strokeWidth:1.5}),e[12]=I):I=e[12];let P=H==="running"||H==="queued"||H==="disabled-transitively"||i.disabled,k;e[13]===E?k=e[14]:(k=()=>E(),e[13]=E,e[14]=k);let z;return e[15]!==_||e[16]!==R||e[17]!==y||e[18]!==v||e[19]!==O||e[20]!==t||e[21]!==S||e[22]!==u||e[23]!==i.disabled||e[24]!==i.hide_code||e[25]!==m||e[26]!==D||e[27]!==n||e[28]!==B||e[29]!==w||e[30]!==d||e[31]!==A||e[32]!==p||e[33]!==h||e[34]!==j||e[35]!==r||e[36]!==M||e[37]!==W||e[38]!==N||e[39]!==T||e[40]!==P||e[41]!==k||e[42]!==L||e[43]!==q||e[44]!==s||e[45]!==x?(z=[[{icon:I,label:"Run cell",hotkey:"cell.run",hidden:P,redundant:!0,handle:k},{icon:(0,l.jsx)(Ee,{size:13,strokeWidth:1.5}),label:"Refactor with AI",hidden:!R,handle:()=>{N(o=>(o==null?void 0:o.cellId)===t?null:{cellId:t})},hotkey:"cell.aiCompletion"},{icon:(0,l.jsx)(Z,{size:13,strokeWidth:1.5}),label:"Split",hotkey:"cell.splitCell",handle:()=>T({cellId:t})},{icon:(0,l.jsx)(We,{size:13,strokeWidth:1.5}),label:"Format",hotkey:"cell.format",handle:()=>{let o=n();o&&pe({[t]:o})}},{icon:i.hide_code?(0,l.jsx)(fe,{size:13,strokeWidth:1.5}):(0,l.jsx)(Me,{size:13,strokeWidth:1.5}),label:i.hide_code?"Show code":"Hide code",handle:q,hotkey:"cell.hideCode"},{icon:i.disabled?(0,l.jsx)(ee,{size:13,strokeWidth:1.5}):(0,l.jsx)(le,{size:13,strokeWidth:1.5}),label:i.disabled?"Enable execution":"Disable execution",handle:L,hidden:d}],[{icon:(0,l.jsx)(Fe,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:async()=>{let o=n();o&&(V({autoInstantiate:v,createNewCell:m}),F(o,{language:"markdown",keepCodeAsIs:!1}),i.hide_code||(await r({configs:{[t]:{hide_code:!0}}}),s({cellId:t,config:{hide_code:!0}}),A({cellId:t})))},hidden:d},he(n())==="sql"?{icon:(0,l.jsx)(Ue,{}),label:"View as Python",hotkey:"cell.viewAsSQL",handle:()=>{let o=n();o&&se(o,"python",{force:!0})},hidden:d}:{icon:(0,l.jsx)(ce,{size:13,strokeWidth:1.5}),label:"Convert to SQL",hotkey:"cell.viewAsSQL",handle:()=>{let o=n();o&&(V({autoInstantiate:v,createNewCell:m}),F(o,{language:"sql",keepCodeAsIs:!1}))},hidden:d}],[{icon:(0,l.jsxs)(J,{children:[(0,l.jsx)(Q,{size:13,strokeWidth:1.5}),(0,l.jsx)(G,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>m({cellId:t,before:!0}),hidden:d,redundant:!0},{icon:(0,l.jsxs)(J,{children:[(0,l.jsx)(Q,{size:13,strokeWidth:1.5}),(0,l.jsx)(K,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>m({cellId:t,before:!1}),redundant:!0},{icon:(0,l.jsx)(G,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>p({cellId:t,before:!0}),hidden:d},{icon:(0,l.jsx)(K,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>p({cellId:t,before:!1}),hidden:d},{icon:(0,l.jsx)(ge,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>p({cellId:t,direction:"left"}),hidden:y!=="columns"||d},{icon:(0,l.jsx)(ze,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>p({cellId:t,direction:"right"}),hidden:y!=="columns"||d},{icon:(0,l.jsx)(Y,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>W({cellId:t,scroll:!1}),hidden:d},{icon:(0,l.jsx)(X,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>M({cellId:t,scroll:!1}),hidden:d},{icon:(0,l.jsx)(ne,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",handle:()=>_({cellId:t}),hidden:y!=="columns"||d}],[{icon:(0,l.jsx)(_e,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!w,handle:()=>Ce(t,"result")},{icon:(0,l.jsx)(re,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(w||B),handle:()=>{S({cellId:t})}}],[{icon:(0,l.jsx)(Ke,{size:13,strokeWidth:1.5}),label:"Name",disableClick:!0,handle:el,handleHeadless:()=>{j((0,l.jsxs)(Le,{children:[(0,l.jsx)(Be,{children:(0,l.jsx)(He,{children:"Rename cell"})}),(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(we,{htmlFor:"cell-name",children:"Cell name"}),(0,l.jsx)($,{placeholder:"cell name",value:h,onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),o.stopPropagation(),j(null))},onChange:o=>x({cellId:t,name:o})})]})]}))},rightElement:(0,l.jsx)($,{placeholder:"cell name",value:h,onChange:o=>x({cellId:t,name:o}),onEnterKey:()=>u==null?void 0:u()}),hidden:d},{icon:(0,l.jsx)(Se,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!oe(h),tooltip:oe(h)?void 0:"Only named cells can be linked to",handle:async()=>{await Ne(Qe(h)),De({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!O,variant:"danger",icon:(0,l.jsx)(Oe,{size:13,strokeWidth:1.5}),handle:()=>{D({cellId:t})}}]].map(Ye).filter(Xe),e[15]=_,e[16]=R,e[17]=y,e[18]=v,e[19]=O,e[20]=t,e[21]=S,e[22]=u,e[23]=i.disabled,e[24]=i.hide_code,e[25]=m,e[26]=D,e[27]=n,e[28]=B,e[29]=w,e[30]=d,e[31]=A,e[32]=p,e[33]=h,e[34]=j,e[35]=r,e[36]=M,e[37]=W,e[38]=N,e[39]=T,e[40]=P,e[41]=k,e[42]=L,e[43]=q,e[44]=s,e[45]=x,e[46]=z):z=e[46],z}function Xe(a){return a.length>0}function Ye(a){return a.filter(Ze)}function Ze(a){return!a.hidden}function el(a){a==null||a.stopPropagation(),a==null||a.preventDefault()}export{Z as a,ee as i,Ve as n,Y as o,le as r,X as s,Je as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as V}from"./chunk-LvLJmgfZ.js";import{d as X,l as Y,n as q,p as Z,u as $}from"./useEvent-D91BmmQi.js";import{t as ee}from"./react-Bj1aDYRI.js";import{Dt as te,K as re}from"./cells-DzyDERZy.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{t as le}from"./cn-DYvqRARy.js";import{t as ne}from"./jsx-runtime-Blw4afVn.js";import{d as se}from"./alert-dialog-Bb8Lz8ko.js";import{i as B,r as ae,t as G}from"./popover-Bcz1Zikb.js";import{a as oe,n as ie,o as ce,t as me}from"./tooltip-4bZlU7jl.js";import{t as de}from"./useCellActionButton-
|
|
1
|
+
import{s as V}from"./chunk-LvLJmgfZ.js";import{d as X,l as Y,n as q,p as Z,u as $}from"./useEvent-D91BmmQi.js";import{t as ee}from"./react-Bj1aDYRI.js";import{Dt as te,K as re}from"./cells-DzyDERZy.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{t as le}from"./cn-DYvqRARy.js";import{t as ne}from"./jsx-runtime-Blw4afVn.js";import{d as se}from"./alert-dialog-Bb8Lz8ko.js";import{i as B,r as ae,t as G}from"./popover-Bcz1Zikb.js";import{a as oe,n as ie,o as ce,t as me}from"./tooltip-4bZlU7jl.js";import{t as de}from"./useCellActionButton-D-uro4Di.js";import{n as he}from"./focus-CNKbm-Xz.js";import{a as fe,c as pe,f as ue,i as xe,o as je,r as be,t as ve}from"./command-Dqxie4gq.js";import{a as ye,i as Ne}from"./renderShortcut-Bl8_FVn8.js";var J=z(),h=V(ee(),1),t=V(ne(),1);const L=h.memo(h.forwardRef((r,n)=>{let e=(0,J.c)(39),{children:s,showTooltip:c,...m}=r,f=c===void 0?!0:c,[d,k]=(0,h.useState)(!1),N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=()=>k(!1),e[0]=N):N=e[0];let W=N,I=(0,h.useRef)(null),M=de({cell:m,closePopover:W}).map(we).filter(_e),T=se(),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{re(()=>{I.current&&I.current.scrollIntoView({behavior:"auto",block:"nearest"})})},e[1]=g):g=e[1];let P=q(g),w;e[2]===P?w=e[3]:(w=a=>{k(o=>{let l=typeof a=="function"?a(o):a;return l&&P(),l})},e[2]=P,e[3]=w);let i=q(w),_;e[4]===i?_=e[5]:(_=()=>({toggle:()=>i(Ce)}),e[4]=i,e[5]=_),(0,h.useImperativeHandle)(n,_);let A=ae,E=ve,H=te(m.cellId),p;e[6]===H?p=e[7]:(p=(0,t.jsx)(fe,{placeholder:"Search actions...",className:"h-6 m-1",...H}),e[6]=H,e[7]=p);let O=ue,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(be,{children:"No results"}),e[8]=u):u=e[8];let R=M.map((a,o)=>(0,t.jsxs)(h.Fragment,{children:[(0,t.jsx)(xe,{children:a.map(l=>{let K=(0,t.jsxs)("div",{className:"flex items-center flex-1",children:[l.icon&&(0,t.jsx)("div",{className:"mr-2 w-5 text-muted-foreground",children:l.icon}),(0,t.jsx)("div",{className:"flex-1",children:l.label}),(0,t.jsxs)("div",{className:"shrink-0 text-sm",children:[l.hotkey&&Ne(l.hotkey),l.rightElement]})]});return l.tooltip&&(K=(0,t.jsx)(me,{content:l.tooltip,delayDuration:100,children:K})),(0,t.jsx)(je,{className:le(l.disabled&&"opacity-50!"),onSelect:()=>{l.disableClick||l.disabled||(l.handle(),k(!1))},variant:l.variant,children:K},l.label)})},o),o<M.length-1&&(0,t.jsx)(pe,{})]},o)),x;e[9]!==O||e[10]!==u||e[11]!==R?(x=(0,t.jsxs)(O,{children:[u,R]}),e[9]=O,e[10]=u,e[11]=R,e[12]=x):x=e[12];let j;e[13]!==E||e[14]!==x||e[15]!==p?(j=(0,t.jsxs)(E,{children:[p,x]}),e[13]=E,e[14]=x,e[15]=p,e[16]=j):j=e[16];let C;e[17]!==A||e[18]!==T||e[19]!==j?(C=(0,t.jsx)(A,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...T,children:j}),e[17]=A,e[18]=T,e[19]=j,e[20]=C):C=e[20];let b=C;if(!f){let a;e[21]===s?a=e[22]:(a=(0,t.jsx)(B,{asChild:!0,children:s}),e[21]=s,e[22]=a);let o;return e[23]!==b||e[24]!==i||e[25]!==d||e[26]!==a?(o=(0,t.jsxs)(G,{open:d,onOpenChange:i,children:[a,b]}),e[23]=b,e[24]=i,e[25]=d,e[26]=a,e[27]=o):o=e[27],o}let S;e[28]===Symbol.for("react.memo_cache_sentinel")?(S=(0,t.jsx)(ie,{tabIndex:-1,children:ye("cell.cellActions")}),e[28]=S):S=e[28];let F=!d&&S,v;e[29]===s?v=e[30]:(v=(0,t.jsx)(ce,{ref:I,children:(0,t.jsx)(B,{className:"flex",children:s})}),e[29]=s,e[30]=v);let y;e[31]!==F||e[32]!==v?(y=(0,t.jsxs)(oe,{delayDuration:200,disableHoverableContent:!0,children:[F,v]}),e[31]=F,e[32]=v,e[33]=y):y=e[33];let D;return e[34]!==b||e[35]!==i||e[36]!==d||e[37]!==y?(D=(0,t.jsxs)(G,{open:d,onOpenChange:i,children:[y,b]}),e[34]=b,e[35]=i,e[36]=d,e[37]=y,e[38]=D):D=e[38],D})),Q=h.memo(r=>{let n=(0,J.c)(5),{children:e,cellId:s}=r,c;n[0]===s?c=n[1]:(c=he(s),n[0]=s,n[1]=c);let m=$(c);if(!m)return null;let f;return n[2]!==e||n[3]!==m?(f=(0,t.jsx)(L,{showTooltip:!1,...m,children:e}),n[2]=e,n[3]=m,n[4]=f):f=n[4],f});Q.displayName="ConnectionCellActionsDropdown";function ge(r){return!r.redundant}function we(r){return r.filter(ge)}function _e(r){return r.length>0}function Ce(r){return!r}var Se=z();const U=Z("minimap");function De(){let r=(0,Se.c)(3),[n,e]=Y(U),s;return r[0]!==n||r[1]!==e?(s={dependencyPanelTab:n,setDependencyPanelTab:e},r[0]=n,r[1]=e,r[2]=s):s=r[2],s}function ke(){return X(U)}export{Q as i,ke as n,L as r,De as t};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{s as Se}from"./chunk-LvLJmgfZ.js";import{d as R,i as Wt,l as St,p as At,u as N}from"./useEvent-D91BmmQi.js";import{t as _t}from"./react-Bj1aDYRI.js";import{An as Dt,Bi as Et,Cr as It,E as Ae,Fi as Pt,Fn as Ot,Kn as Tt,Ln as Lt,Nn as Ht,Nr as Rt,Nt as _e,Or as Ft,Pn as $t,Qi as ke,T as qt,Tr as Bt,g as Ut,m as De,qt as Yt,si as Kt,t as Vt,wr as Ee,y as Gt}from"./cells-DzyDERZy.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as Jt,r as Qt,x as Xt}from"./ai-model-dropdown-Bvqy98cI.js";import{g as F,n as Zt}from"./useEventListener-C0195JsF.js";import{t as Ie}from"./objects-BlG0ZrO0.js";import{C as ea,r as ta}from"./utils-BWBBpCkT.js";import{n as v,t as Pe}from"./constants-CDyU_g2F.js";import{M as ee,O as aa,T as Oe,j as Te,k as na,v as Le}from"./config-B-Q7J_6d.js";import{c as oa}from"./readonly-python-code-DHxOnQGj.js";import{t as sa}from"./cn-DYvqRARy.js";import{t as ra}from"./jsx-runtime-Blw4afVn.js";import{o as ia}from"./alert-dialog-Bb8Lz8ko.js";import{a as la,c as da,i as ca,n as ha,r as ma,s as ua,t as pa}from"./select-BP75_5jJ.js";import{Ft as fa}from"./JsonOutput-C08yZPMz.js";import{f as xa,l as He,n as ba,o as Re,r as ya,s as ka,t as wa}from"./download-BIGA4WFm.js";import{t as ga}from"./tooltip-4bZlU7jl.js";import{r as ja,t as P}from"./button-DDGiD1NW.js";import{i as va,t as we}from"./strings--BknHX9C.js";import{r as O}from"./requests-9-v2bhoi.js";import{t as k}from"./createLucideIcon-w-Qo9n0R.js";import{F as Ca,I as Na,L as za,R as Fe,a as $e,d as Ma,i as qe,u as Be}from"./layout-B8cCh91r.js";import{t as Ue}from"./check-rzLRd0j9.js";import{r as Wa}from"./useCellActionButton-D-uro4Di.js";import{t as Sa}from"./code-B2aKtXoe.js";import{t as Aa}from"./copy-3iHFdt22.js";import{t as Ye}from"./eye-off-BOZA7gbn.js";import{t as Ke}from"./external-link-BOlXZUla.js";import{t as te}from"./file-CJH9JNGH.js";import{u as _a}from"./form-D8N71OB1.js";import{n as Da,r as Ea,t as Ia}from"./youtube-OwaksuQt.js";import{i as Pa,n as Ve}from"./add-connection-dialog-ChQis5IF.js";import{t as Oa}from"./house-DS0r7dNZ.js";import{t as Ta}from"./image-5XI2VU-q.js";import{t as La}from"./link-CHdiBDr5.js";import{r as Ha}from"./input-JxFwu-3G.js";import{t as Ra}from"./settings-D_PiwXwo.js";import{t as Fa}from"./sparkles-DUCpRFlS.js";import{y as $a}from"./textarea-Bmzmbbpo.js";import{t as qa}from"./square-DFICx2Qv.js";import{t as Ge}from"./triangle-alert-BL4YVsPy.js";import{t as W}from"./use-toast-BwJoaaDM.js";import{n as Je,t as Ba}from"./paths-BKO-pHK6.js";import{o as Ua}from"./session-BmukRjSi.js";import{n as ae}from"./copy-Bxb1_Gtw.js";import{t as Qe}from"./copy-icon-neDQUo4Q.js";import{r as Ya}from"./useRunCells-C2dvU2jA.js";import{a as Xe,c as Ze,i as Ka,n as et,r as tt}from"./dialog-BCVepWLJ.js";import{n as ne}from"./ImperativeModal-fY-ZfT0b.js";import{r as Va,t as at}from"./share-852X_cqy.js";import{a as Ga}from"./cell-link-w5IbCQV4.js";import{n as nt}from"./useAsyncData-Bg5iAViP.js";import{a as Ja}from"./renderShortcut-Bl8_FVn8.js";import{t as Qa}from"./icons-CIPE8AIY.js";import{i as Xa,n as ot}from"./error-entries-CTYMwfsh.js";import{t as Za}from"./pair-with-agent-modal-BCRSACei.js";import{t as en}from"./github-_JH-0hIO.js";import{n as st}from"./marimo-icons-C_nFooxr.js";import{t as tn}from"./links-CZr5bjvo.js";import{i as an,n as rt,t as ge}from"./skeleton-CeWH7IQO.js";import{t as it}from"./types-Da7lA5YC.js";var nn=k("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),on=k("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),lt=k("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),dt=k("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),ct=k("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),sn=k("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),rn=k("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),ln=k("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ht=k("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),dn=k("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),cn=k("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),mt=k("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),hn=k("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),mn=k("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),ut=k("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),un=z(),T=Se(_t(),1);function je(e,t){let n=(0,un.c)(11),o;n[0]===t?o=n[1]:(o=new Pt(t),n[0]=t,n[1]=o);let s=o,i;n[2]!==e||n[3]!==s?(i=()=>s.get(e),n[2]=e,n[3]=s,n[4]=i):i=n[4];let[r,d]=(0,T.useState)(i),l;n[5]!==e||n[6]!==s?(l=x=>{d(x),s.set(e,x)},n[5]=e,n[6]=s,n[7]=l):l=n[7];let c=l,h;return n[8]!==c||n[9]!==r?(h=[r,c],n[8]=c,n[9]=r,n[10]=h):h=n[10],h}function pn(e,t){return{...e,Binaries:{...e.Binaries,Browser:t}}}function fn(e,t,n,o){return{marimo:e,Locale:n||void 0,Binaries:{Browser:t},"Environment Collection Error":o}}function ve(e,t){let n=Math.max(2,...Array.from(t.matchAll(/`+/g),s=>s[0].length)),o="`".repeat(n+1);return`${o}${e}
|
|
2
|
+
${t}
|
|
3
|
+
${o}`}function xn(e,t){let n=e.includes("?")?"&":"?",o=[],s=e,i=0;for(let[r,d]of Object.entries(t)){if(d.length===0)continue;let l=`${r}=${encodeURIComponent(d)}`,c=`${s}${i===0?n:"&"}${l}`;if(c.length>6e3){o.push(r);continue}s=c,i+=1}return{url:s,omitted:o}}function Ce(e,t){return["<details>",`<summary>${we.htmlEscape(e)??""}</summary>`,"",t,"","</details>"].join(`
|
|
4
|
+
`)}function bn(e){return Ce("Environment",ve("json",JSON.stringify(e,null,2)))}function pt(e){return Ce("Errors",ve("text",e.map(ot).join(`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`)))}function yn(e){return Ce("Code",ve("python",e))}var ft=z(),a=Se(ra(),1),kn=Zt,xt=e=>{let t=(0,ft.c)(16),{content:n}=e,[o,s]=(0,T.useState)(!1),i=!o&&"max-h-24 overflow-hidden",r;t[0]===i?r=t[1]:(r=sa("text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap",i),t[0]=i,t[1]=r);let d;t[2]!==n||t[3]!==r?(d=(0,a.jsx)("pre",{className:r,children:n}),t[2]=n,t[3]=r,t[4]=d):d=t[4];let l;t[5]===o?l=t[6]:(l=!o&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 rounded-b bg-gradient-to-b from-transparent to-muted"}),t[5]=o,t[6]=l);let c;t[7]!==d||t[8]!==l?(c=(0,a.jsxs)("div",{className:"relative",children:[d,l]}),t[7]=d,t[8]=l,t[9]=c):c=t[9];let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>s(gn),t[10]=h):h=t[10];let x=o?"Show less":"Show more",m;t[11]===x?m=t[12]:(m=(0,a.jsx)(P,{type:"button",variant:"link",size:"xs",className:"self-start",onClick:h,children:x}),t[11]=x,t[12]=m);let b;return t[13]!==c||t[14]!==m?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[c,m]}),t[13]=c,t[14]=m,t[15]=b):b=t[15],b};const wn=e=>{let t=(0,ft.c)(6),{children:n}=e,{openModal:o,closeModal:s}=ne(),i;t[0]!==s||t[1]!==o?(i=()=>o((0,a.jsx)(bt,{onClose:s})),t[0]=s,t[1]=o,t[2]=i):i=t[2];let r;return t[3]!==n||t[4]!==i?(r=(0,a.jsx)(kn,{onClick:i,children:n}),t[3]=n,t[4]=i,t[5]=r):r=t[5],r},bt=()=>{let{getEnvironmentInfo:e,readCode:t}=O(),n=nt(async()=>e(),[e]),o=N(Gt),s=(0,T.useMemo)(()=>Xa(Wt),[o]),i=Ma(o.cellIds.inOrderIds.map(u=>o.cellData[u])),r=N(Et),d=N(Le),l=r!==null&&i&&d.state===Oe.OPEN,c=l?void 0:r===null?"Save the notebook first.":i?"Connect the notebook to include its source.":"Notebook source is hidden in this view.",[h,x]=je("marimo:issue-report:include-errors",!1),[m,b]=je("marimo:issue-report:include-code",!1),f=n.data?pn(n.data,navigator.userAgent):n.status==="error"?fn(oa(),navigator.userAgent,navigator.language,"Server environment information unavailable"):void 0,y=nt(async()=>{if(!m||!l)return;let{contents:u}=await t();return u},[m,l,t]),{url:w,omitted:g}=(0,T.useMemo)(()=>{if(!f)return{url:v.bugReportUrl,omitted:[]};let u={env:bn(f)};return h&&s.length>0&&(u["bug-description"]=pt(s)),m&&y.data&&(u["reproduction-code"]=yn(y.data)),xn(v.bugReportUrl,u)},[f,s,h,m,y.data]),j=g.map(u=>u==="bug-description"?"errors":u==="reproduction-code"?"code":u).join(", ");return(0,a.jsxs)(et,{className:"w-[540px] max-w-[90vw]",children:[(0,a.jsxs)(Xe,{children:[(0,a.jsx)(Ze,{children:"Report an issue"}),(0,a.jsx)(tt,{children:"Open a GitHub bug report prefilled with your environment, and optionally your current errors and notebook code. Nothing is uploaded automatically; review the details before posting."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 max-h-[60vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(P,{type:"button",variant:"default",size:"xs",asChild:!0,className:"self-start",children:(0,a.jsxs)("a",{href:w,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(Ke,{className:"w-4 h-4 mr-2"}),"Open GitHub issue"]})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(_e,{id:"issue-include-errors",checked:h,disabled:s.length===0,onCheckedChange:u=>x(u===!0),"aria-label":"Include errors"}),(0,a.jsx)("label",{htmlFor:"issue-include-errors",children:"Include errors"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(_e,{id:"issue-include-code",checked:m,disabled:!l,onCheckedChange:u=>b(u===!0),"aria-label":"Include notebook code"}),(0,a.jsx)("label",{htmlFor:"issue-include-code",children:"Include notebook code"})]}),c&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-6",children:c}),m&&y.status==="error"&&(0,a.jsx)("span",{className:"text-xs text-(--red-11) ml-6",children:"Notebook source could not be loaded."})]})]}),j?(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs text-(--yellow-11)",children:[(0,a.jsx)(Ge,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),(0,a.jsxs)("span",{children:["Too large to prefill and left out of the link: ",j,". Paste them into the issue manually."]})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your environment is always included."})]}),n.status==="pending"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading environment details\u2026"}),(0,a.jsx)(ge,{className:"h-4 w-full"}),(0,a.jsx)(ge,{className:"h-4 w-3/4"}),(0,a.jsx)(ge,{className:"h-4 w-1/2"})]}),n.status==="error"&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(Ge,{className:"w-4 h-4 text-(--yellow-11) shrink-0"}),(0,a.jsx)("span",{children:"Server environment information unavailable"}),(0,a.jsx)(P,{type:"button",variant:"link",size:"xs",onClick:()=>n.refetch(),children:"Retry"})]}),f&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Environment details"}),(0,a.jsx)(Qe,{className:"w-3.5 h-3.5",value:JSON.stringify(f,null,2),ariaLabel:"Copy environment JSON",toastTitle:"Environment details copied"})]}),(0,a.jsx)(xt,{content:JSON.stringify(f,null,2)})]}),f&&s.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Errors"}),(0,a.jsx)(Qe,{className:"w-3.5 h-3.5",value:pt(s),ariaLabel:"Copy errors",toastTitle:"Errors copied"})]}),(0,a.jsx)(xt,{content:s.map(ot).join(`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
`)})]}),f&&s.length===0&&(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"No errors detected."}),(0,a.jsx)("div",{className:"border-t pt-3",children:(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Other feedback? Take our"," ",(0,a.jsx)("a",{href:v.feedbackForm,target:"_blank",rel:"noreferrer",className:"underline",children:"two-minute survey"})," ","or chat with us on"," ",(0,a.jsx)("a",{href:v.discordLink,target:"_blank",rel:"noreferrer",className:"underline",children:"Discord"}),"."]})})]})]})};function gn(e){return!e}var yt=z(),oe="https://static.marimo.app";const jn=e=>{let t=(0,yt.c)(25),{onClose:n}=e,[o,s]=(0,T.useState)(""),{exportAsHTML:i}=O(),r=`${o}-${Math.random().toString(36).slice(2,6)}`,d=`${oe}/static/${r}`,l;t[0]!==i||t[1]!==n||t[2]!==r?(l=async u=>{u.preventDefault(),n();let{contents:H}=await i({download:!1,includeCode:!0,files:Ca.INSTANCE.filenames()}),S=W({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${oe}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:H,path:r})}).catch(()=>{S.dismiss(),W({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:v.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),S.dismiss(),W({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=i,t[1]=n,t[2]=r,t[3]=l):l=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Ze,{children:"Share static notebook"}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)(Xe,{children:[c,(0,a.jsxs)(tt,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:oe,target:"_blank",children:oe}),"."]})]}),t[5]=h):h=t[5];let x;t[6]===Symbol.for("react.memo_cache_sentinel")?(x=u=>{s(u.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=x):x=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:x,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let b;t[9]===d?b=t[10]:(b=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(vn,{text:d}),(0,a.jsx)("span",{className:"text-primary",children:d})]})]}),t[9]=d,t[10]=b);let f;t[11]!==m||t[12]!==b?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,b]}),t[11]=m,t[12]=b,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(P,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let w;t[16]===d?w=t[17]:(w=(0,a.jsx)(P,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ae(d)},children:"Create"}),t[16]=d,t[17]=w);let g;t[18]!==y||t[19]!==w?(g=(0,a.jsxs)(Ka,{children:[y,w]}),t[18]=y,t[19]=w,t[20]=g):g=t[20];let j;return t[21]!==l||t[22]!==g||t[23]!==f?(j=(0,a.jsx)(et,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:l,children:[h,f,g]})}),t[21]=l,t[22]=g,t[23]=f,t[24]=j):j=t[24],j};var vn=e=>{let t=(0,yt.c)(8),[n,o]=T.useState(!1),s;t[0]===e.text?s=t[1]:(s=ja.stopPropagation(async c=>{c.preventDefault(),await ae(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let i=s,r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),t[2]=r):r=t[2];let d;t[3]===i?d=t[4]:(d=(0,a.jsx)(P,{"data-testid":"copy-static-notebook-url-button",onClick:i,size:"xs",variant:"secondary",children:r}),t[3]=i,t[4]=d);let l;return t[5]!==n||t[6]!==d?(l=(0,a.jsx)(ga,{content:"Copied!",open:n,children:d}),t[5]=n,t[6]=d,t[7]=l):l=t[7],l},Cn=z();function Nn(){let e=document.getElementsByClassName(Pe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ke.findElement(t);if(!o){F.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ke.parse(o.id)}}}return F.warn("No visible output area found for scroll anchor"),null}function zn(e){if(!e){F.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ke.create(e.cellId));if(!t){F.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Pe.outputArea}`)){F.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function kt(){let e=(0,Cn.c)(2),t=R(Te),n;return e[0]===t?n=e[1]:(n=()=>{let o=Nn();t(s=>({mode:na(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{zn(o)})})},e[0]=t,e[1]=n),n}const wt=At(!1);var Mn=z();const Wn=()=>{let e=(0,Mn.c)(7),{selectedLayout:t}=$e(),{setLayoutView:n}=qe();if(ee()&&!Tt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=d=>n(d),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ua,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(da,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(ha,{children:(0,a.jsxs)(ma,{children:[(0,a.jsx)(la,{children:"View as"}),it.map(An)]})}),e[3]=i):i=e[3];let r;return e[4]!==t||e[5]!==o?(r=(0,a.jsxs)(pa,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,i]}),e[4]=t,e[5]=o,e[6]=r):r=e[6],r};function Sn(e){return(0,a.jsx)(gt(e),{className:"h-4 w-4"})}function gt(e){switch(e){case"vertical":return ln;case"grid":return Ea;case"slides":return mt;default:return va(e),qa}}function jt(e){return we.startCase(e)}function An(e){return(0,a.jsx)(ca,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Sn(e),(0,a.jsx)("span",{children:jt(e)})]})},e)}async function _n(e){let{exportOptions:t,captureOutputs:n,downloadPDF:o}=e;t.includeOutputs&&await n(),await o(t)}var Dn=z();function En(e){let t=(0,Dn.c)(5),{openPrompt:n,closeModal:o}=ne(),{sendCopy:s}=O(),i;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(i=()=>{if(!e)return null;let r=Ba.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Je.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:d=>{let l=r.join(Je.dirname(e),d);s({source:e,destination:l}).then(()=>{o(),W({title:"Notebook copied",description:"A copy of the notebook has been created."}),tn(l)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=i):i=t[4],i}var In=z();function vt(){let e=(0,In.c)(4),{openConfirm:t}=ne(),n=R(Le),{sendRestart:o}=O(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(ia,{onClick:async()=>{n({state:Oe.CLOSING}),await o(),Va()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Pn=z(),On=new Yt,Tn=e=>On.isSupported(e)?"markdown":"code";const Ct=()=>{let e=(0,Pn.c)(3),{updateCellConfig:t}=Ae(),{saveCellConfig:n}=O(),o;return e[0]!==n||e[1]!==t?(o=async(s,i)=>{let r=De(),d={};for(let c of r.cellIds.inOrderIds){let h=r.cellData[c];h===void 0||h.config.hide_code===s||Tn(h.code)===i&&(d[c]={hide_code:s})}let l=Ie.entries(d);if(l.length!==0){await n({configs:d});for(let[c,h]of l)t({cellId:c,config:h})}},e[0]=n,e[1]=t,e[2]=o):o=e[2],o};var Ln=z(),L=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Hn(){var ze,Me,We;let e=(0,Ln.c)(56),t=Ga(),{openModal:n,closeModal:o}=ne(),{toggleApplication:s}=Ht(),{selectedPanel:i}=$t(),[r]=St(Te),d=N(aa),l=Ct(),[c]=ea(),h=N(Dt),x=N(ta),{updateCellConfig:m,undoDeleteCell:b,clearAllCellOutputs:f,addSetupCellIfDoesntExist:y,collapseAllCells:w,expandAllCells:g}=Ae(),j=vt(),u=Ya(),H=En(t),S=R(wt),re=R(Jt),{handleClick:ie}=Qt(),le=R(Xt),{exportAsIPYNB:de,exportAsMarkdown:ce,readCode:A,saveCellConfig:he,updateCellOutputs:_}=O(),D=an(),me=N(Ut),ue=N(Vt),pe=N(qt),{selectedLayout:$}=$e(),{setLayoutView:fe}=qe(),q=kt(),B=((ze=c.sharing)==null?void 0:ze.html)??!0,U=((Me=c.sharing)==null?void 0:Me.wasm)??!0,Y=((We=c.sharing)==null?void 0:We.molab)??!0,Ne=!ee(),xe=$==="slides",Nt=no,zt=ao,K;e[0]!==t||e[1]!==D||e[2]!==_?(K=async p=>{let{preset:C,title:M}=p;if(!t){se();return}await He(M,async ye=>{await _n({exportOptions:{webpdf:!1,preset:C,includeInputs:!0,includeOutputs:!0},captureOutputs:()=>rt({takeScreenshots:()=>D({progress:ye}),updateCellOutputs:_}),downloadPDF:ba})})},e[0]=t,e[1]=D,e[2]=_,e[3]=K):K=e[3];let E=K,V;e[4]===E?V=e[5]:(V=async()=>{if(Ne){await E({preset:"document",title:"Downloading Document PDF..."});return}let p=new Event("export-beforeprint"),C=new Event("export-afterprint");window.dispatchEvent(p),setTimeout(to,0),setTimeout(()=>window.dispatchEvent(C),0)},e[4]=E,e[5]=V);let G=V,J;e[6]!==de||e[7]!==t||e[8]!==D||e[9]!==_?(J=async()=>{if(!t){se();return}await He("Downloading IPYNB...",async p=>{await rt({takeScreenshots:()=>D({progress:p}),updateCellOutputs:_}),Re(await de({download:!1}))})},e[6]=de,e[7]=t,e[8]=D,e[9]=_,e[10]=J):J=e[10];let be=J,Q;e[11]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),e[11]=Q):Q=e[11];let X;e[12]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),e[12]=X):X=e[12];let I;e[13]===t?I=e[14]:(I=async()=>{if(!t){se();return}await Be({includeCode:!0})},e[13]=t,e[14]=I);let Z;return e[15]!==y||e[16]!==x||e[17]!==ue||e[18]!==h||e[19]!==f||e[20]!==o||e[21]!==w||e[22]!==H||e[23]!==E||e[24]!==g||e[25]!==ce||e[26]!==t||e[27]!==G||e[28]!==be||e[29]!==me||e[30]!==xe||e[31]!==d||e[32]!==n||e[33]!==ie||e[34]!==A||e[35]!==j||e[36]!==u||e[37]!==he||e[38]!==$||e[39]!==i||e[40]!==l||e[41]!==S||e[42]!==le||e[43]!==fe||e[44]!==re||e[45]!==B||e[46]!==Y||e[47]!==U||e[48]!==I||e[49]!==s||e[50]!==q||e[51]!==b||e[52]!==pe||e[53]!==m||e[54]!==r.mode?(Z=[{icon:Q,label:"Download",handle:L,dropdown:[{icon:X,label:"Download as HTML",handle:I},{icon:(0,a.jsx)(Fe,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){se();return}await Be({includeCode:!1})}},{icon:(0,a.jsx)(Qa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{Re(await ce({download:!1}))}},{icon:(0,a.jsx)(dn,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:be},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let p=await A();ya(new Blob([p.contents],{type:"text/plain"}),xa.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:r.mode!=="present",tooltip:r.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Ja("global.hideCode",!1)]}),handle:eo},xe?{divider:!0,icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:L,dropdown:[{icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:G},{icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:zt(!0),hidden:!Ne,handle:async()=>{await E({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:G}]},{icon:(0,a.jsx)(Fa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:ee(),handle:async()=>{n((0,a.jsx)(Za,{onClose:o}))}},{icon:(0,a.jsx)(hn,{size:14,strokeWidth:1.5}),label:"Share",handle:L,hidden:!B&&!U&&!Y,dropdown:[{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!B,handle:async()=>{n((0,a.jsx)(jn,{onClose:o}))}},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!U,handle:async()=>{await ae(at({code:(await A()).contents})),W({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!Y,handle:async()=>{let p=at({code:(await A()).contents,baseUrl:`${v.molab}/new`});window.open(p,"_blank")}}]},{icon:(0,a.jsx)(cn,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:L,dropdown:Ot.flatMap(p=>{let C=p.type==="ai"&&!x;if(Lt({panel:p,capabilities:h,aiEnabled:x})&&!C)return[];let{type:M,Icon:ye,additionalKeywords:Mt}=p;return{label:we.startCase(M),rightElement:Nt(i===M),icon:(0,a.jsx)(ye,{size:14,strokeWidth:1.5}),handle:()=>{if(C){ie("ai","ai-features");return}s(M)},additionalKeywords:Mt}})},{icon:(0,a.jsx)(mt,{size:14,strokeWidth:1.5}),label:"Present as",handle:L,dropdown:[{icon:r.mode==="present"?(0,a.jsx)($a,{size:14,strokeWidth:1.5}):(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...it.map((p,C)=>{let M=gt(p);return{divider:C===0,label:jt(p),icon:(0,a.jsx)(M,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:$===p&&(0,a.jsx)(Ue,{size:14})}),handle:()=>{fe(p),r.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(rn,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ee(),handle:H},{icon:(0,a.jsx)(lt,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ae((await A()).contents),W({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!me||d,handle:async()=>{let p=Kt(De());await he({configs:Ie.fromEntries(p.map(Zn))});for(let C of p)m({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Ve,{onClose:o}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Ve,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:pe,hidden:!ue||d,handle:()=>{b()}},{icon:(0,a.jsx)(mn,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:j,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(sn,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{u()}},{icon:(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{f()}},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Show all code",hotkey:"global.showAllCode",handle:()=>l(!1,"code"),redundant:!0},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Hide all code",hotkey:"global.hideAllCode",handle:()=>l(!0,"code"),redundant:!0},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Show all markdown code",hotkey:"global.showAllMarkdownCode",handle:()=>l(!1,"markdown"),redundant:!0},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",hotkey:"global.hideAllMarkdownCode",handle:()=>l(!0,"markdown"),redundant:!0},{icon:(0,a.jsx)(on,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:w,redundant:!0},{icon:(0,a.jsx)(nn,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:g,redundant:!0},{divider:!0,icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>S(Xn)},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>le(Qn)},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>re(Jn),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Report an issue",additionalKeywords:["feedback","bug","issue","report","diagnostics"],handle:()=>n((0,a.jsx)(bt,{onClose:o}))},{icon:(0,a.jsx)(Ke,{size:14,strokeWidth:1.5}),label:"Resources",handle:L,dropdown:[{icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Gn},{icon:(0,a.jsx)(en,{className:"h-3.5 w-3.5"}),label:"GitHub",handle:Vn},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Kn},{icon:(0,a.jsx)(Ia,{className:"h-3.5 w-3.5"}),label:"YouTube",handle:Yn},{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Un}]},{divider:!0,icon:(0,a.jsx)(Oa,{size:14,strokeWidth:1.5}),label:"Open home",hidden:!location.search.includes("file"),handle:Bn},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:qn}].filter($n).map(Rn),e[15]=y,e[16]=x,e[17]=ue,e[18]=h,e[19]=f,e[20]=o,e[21]=w,e[22]=H,e[23]=E,e[24]=g,e[25]=ce,e[26]=t,e[27]=G,e[28]=be,e[29]=me,e[30]=xe,e[31]=d,e[32]=n,e[33]=ie,e[34]=A,e[35]=j,e[36]=u,e[37]=he,e[38]=$,e[39]=i,e[40]=l,e[41]=S,e[42]=le,e[43]=fe,e[44]=re,e[45]=B,e[46]=Y,e[47]=U,e[48]=I,e[49]=s,e[50]=q,e[51]=b,e[52]=pe,e[53]=m,e[54]=r.mode,e[55]=Z):Z=e[55],Z}function Rn(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Fn)}:e}function Fn(e){return!e.hidden}function $n(e){return!e.hidden}function qn(){let e=Ua();window.open(e,"_blank")}function Bn(){let e=document.baseURI.split("?")[0];window.open(e,"_blank","noopener")}function Un(){window.open(v.releasesPage,"_blank")}function Yn(){window.open(v.youtube,"_blank")}function Kn(){window.open(v.discordLink,"_blank")}function Vn(){window.open(v.githubPage,"_blank")}function Gn(){window.open(v.docsPage,"_blank")}function Jn(e){return!e}function Qn(e){return!e}function Xn(e){return!e}function Zn(e){return[e,{disabled:!1}]}async function eo(){let e=document.getElementById("App");e&&await ka({element:e,filename:document.title,prepare:wa})}function to(){return window.print()}function ao(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function no(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ue,{size:14})})}function se(){W({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{wt as a,je as c,ct as d,dt as f,Wn as i,ut as l,Ct as n,kt as o,lt as p,vt as r,wn as s,Hn as t,ht as u};
|
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-BLnlUAQy.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-TXkS1QI3.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/objects-BlG0ZrO0.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
<link rel="modulepreload" crossorigin href="./assets/field-BsxD35VE.js">
|
|
181
181
|
<link rel="modulepreload" crossorigin href="./assets/popover-Bcz1Zikb.js">
|
|
182
182
|
<link rel="modulepreload" crossorigin href="./assets/errors-PgHhDa-M.js">
|
|
183
|
-
<link rel="modulepreload" crossorigin href="./assets/download-
|
|
183
|
+
<link rel="modulepreload" crossorigin href="./assets/download-BIGA4WFm.js">
|
|
184
184
|
<link rel="modulepreload" crossorigin href="./assets/table-CH2plyy9.js">
|
|
185
185
|
<link rel="modulepreload" crossorigin href="./assets/useIframeCapabilities-j6fR_dBA.js">
|
|
186
186
|
<link rel="modulepreload" crossorigin href="./assets/error-banner-BSxEOIn2.js">
|
|
@@ -201,11 +201,11 @@
|
|
|
201
201
|
<link rel="modulepreload" crossorigin href="./assets/plus-AgXtozBz.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-72W0TZ3L.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-Z-MD3n3J.js">
|
|
204
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
204
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-C08yZPMz.js">
|
|
205
205
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-iDRxid4h.js">
|
|
206
206
|
<link rel="modulepreload" crossorigin href="./assets/square-function-DNNRTPQJ.js">
|
|
207
207
|
<link rel="modulepreload" crossorigin href="./assets/spec-C7opZZRp.js">
|
|
208
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
208
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-UAW6odg3.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/icons-CIPE8AIY.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/radio-group-DfioQthW.js">
|
|
211
211
|
<link rel="modulepreload" crossorigin href="./assets/floating-outline-LitP0wCD.js">
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/label-CqjrpwRC.js">
|
|
228
228
|
<link rel="modulepreload" crossorigin href="./assets/textarea-Bmzmbbpo.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-sLaKP2vj.js">
|
|
230
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
230
|
+
<link rel="modulepreload" crossorigin href="./assets/form-D8N71OB1.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-Bl8_FVn8.js">
|
|
232
232
|
<link rel="modulepreload" crossorigin href="./assets/useBoolean-CFj86iac.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-CSMoa-ga.js">
|
package/package.json
CHANGED
|
@@ -4,35 +4,58 @@ import { describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import { runServerSidePDFDownload } from "../pdf-export";
|
|
5
5
|
|
|
6
6
|
describe("runServerSidePDFDownload", () => {
|
|
7
|
-
it("
|
|
8
|
-
const
|
|
7
|
+
it("captures current outputs before downloading the PDF", async () => {
|
|
8
|
+
const calls: string[] = [];
|
|
9
|
+
const captureOutputs = vi.fn(async () => {
|
|
10
|
+
calls.push("capture:start");
|
|
11
|
+
await Promise.resolve();
|
|
12
|
+
calls.push("capture:end");
|
|
13
|
+
});
|
|
14
|
+
const downloadPDF = vi.fn(async () => {
|
|
15
|
+
calls.push("download");
|
|
16
|
+
});
|
|
9
17
|
|
|
10
18
|
await runServerSidePDFDownload({
|
|
11
|
-
|
|
19
|
+
exportOptions: {
|
|
20
|
+
webpdf: false,
|
|
21
|
+
preset: "document",
|
|
22
|
+
includeInputs: true,
|
|
23
|
+
includeOutputs: true,
|
|
24
|
+
},
|
|
25
|
+
captureOutputs,
|
|
12
26
|
downloadPDF,
|
|
13
27
|
});
|
|
14
28
|
|
|
29
|
+
expect(calls).toEqual(["capture:start", "capture:end", "download"]);
|
|
15
30
|
expect(downloadPDF).toHaveBeenCalledWith({
|
|
16
31
|
webpdf: false,
|
|
17
32
|
preset: "document",
|
|
18
33
|
includeInputs: true,
|
|
19
|
-
|
|
34
|
+
includeOutputs: true,
|
|
20
35
|
});
|
|
21
36
|
});
|
|
22
37
|
|
|
23
|
-
it("
|
|
38
|
+
it("skips browser capture when outputs are excluded", async () => {
|
|
39
|
+
const captureOutputs = vi.fn().mockResolvedValue(undefined);
|
|
24
40
|
const downloadPDF = vi.fn().mockResolvedValue(undefined);
|
|
25
41
|
|
|
26
42
|
await runServerSidePDFDownload({
|
|
27
|
-
|
|
43
|
+
exportOptions: {
|
|
44
|
+
webpdf: true,
|
|
45
|
+
preset: "slides",
|
|
46
|
+
includeInputs: false,
|
|
47
|
+
includeOutputs: false,
|
|
48
|
+
},
|
|
49
|
+
captureOutputs,
|
|
28
50
|
downloadPDF,
|
|
29
51
|
});
|
|
30
52
|
|
|
53
|
+
expect(captureOutputs).not.toHaveBeenCalled();
|
|
31
54
|
expect(downloadPDF).toHaveBeenCalledWith({
|
|
32
|
-
webpdf:
|
|
55
|
+
webpdf: true,
|
|
33
56
|
preset: "slides",
|
|
34
|
-
includeInputs:
|
|
35
|
-
|
|
57
|
+
includeInputs: false,
|
|
58
|
+
includeOutputs: false,
|
|
36
59
|
});
|
|
37
60
|
});
|
|
38
61
|
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
type Preset = "document" | "slides";
|
|
4
|
-
|
|
4
|
+
interface PDFExportOptions {
|
|
5
5
|
webpdf: boolean;
|
|
6
6
|
preset: Preset;
|
|
7
7
|
includeInputs: boolean;
|
|
8
|
-
|
|
9
|
-
}
|
|
8
|
+
includeOutputs: boolean;
|
|
9
|
+
}
|
|
10
|
+
type DownloadPDF = (opts: PDFExportOptions) => Promise<void>;
|
|
10
11
|
|
|
11
12
|
export async function runServerSidePDFDownload(opts: {
|
|
12
|
-
|
|
13
|
+
exportOptions: PDFExportOptions;
|
|
14
|
+
captureOutputs: () => Promise<void>;
|
|
13
15
|
downloadPDF: DownloadPDF;
|
|
14
16
|
}): Promise<void> {
|
|
15
|
-
const {
|
|
17
|
+
const { exportOptions, captureOutputs, downloadPDF } = opts;
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rasterServer: "static",
|
|
22
|
-
});
|
|
19
|
+
if (exportOptions.includeOutputs) {
|
|
20
|
+
await captureOutputs();
|
|
21
|
+
}
|
|
22
|
+
await downloadPDF(exportOptions);
|
|
23
23
|
}
|
|
@@ -193,12 +193,18 @@ export function useNotebookActions() {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
const runDownload = async (progress: ProgressState) => {
|
|
196
|
-
await updateCellOutputsWithScreenshots({
|
|
197
|
-
takeScreenshots: () => takeScreenshots({ progress }),
|
|
198
|
-
updateCellOutputs,
|
|
199
|
-
});
|
|
200
196
|
await runServerSidePDFDownload({
|
|
201
|
-
|
|
197
|
+
exportOptions: {
|
|
198
|
+
webpdf: false,
|
|
199
|
+
preset,
|
|
200
|
+
includeInputs: true,
|
|
201
|
+
includeOutputs: true,
|
|
202
|
+
},
|
|
203
|
+
captureOutputs: () =>
|
|
204
|
+
updateCellOutputsWithScreenshots({
|
|
205
|
+
takeScreenshots: () => takeScreenshots({ progress }),
|
|
206
|
+
updateCellOutputs,
|
|
207
|
+
}),
|
|
202
208
|
downloadPDF: downloadAsPDF,
|
|
203
209
|
});
|
|
204
210
|
};
|
|
@@ -648,8 +648,7 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
648
648
|
);
|
|
649
649
|
expect(toast).toHaveBeenCalledWith({
|
|
650
650
|
title: "Failed to capture cell outputs",
|
|
651
|
-
description:
|
|
652
|
-
"Some outputs may not appear in the PDF. Continuing with export.",
|
|
651
|
+
description: "Some outputs may be missing from the export. Continuing.",
|
|
653
652
|
variant: "danger",
|
|
654
653
|
});
|
|
655
654
|
});
|
|
@@ -679,8 +678,7 @@ describe("updateCellOutputsWithScreenshots", () => {
|
|
|
679
678
|
);
|
|
680
679
|
expect(toast).toHaveBeenCalledWith({
|
|
681
680
|
title: "Failed to capture cell outputs",
|
|
682
|
-
description:
|
|
683
|
-
"Some outputs may not appear in the PDF. Continuing with export.",
|
|
681
|
+
description: "Some outputs may be missing from the export. Continuing.",
|
|
684
682
|
variant: "danger",
|
|
685
683
|
});
|
|
686
684
|
});
|
package/src/core/export/hooks.ts
CHANGED
|
@@ -112,7 +112,9 @@ interface UseEnrichCellOutputsOptions {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
115
|
+
* Capture browser-rendered cell outputs for current-session exports.
|
|
116
|
+
*
|
|
117
|
+
* The caller uploads these PNG representations before requesting an export.
|
|
116
118
|
* @returns A map of cell IDs to their screenshots data.
|
|
117
119
|
*/
|
|
118
120
|
export function useEnrichCellOutputs(): (
|
|
@@ -221,8 +223,7 @@ export async function updateCellOutputsWithScreenshots(opts: {
|
|
|
221
223
|
Logger.error("Error updating cell outputs with screenshots:", error);
|
|
222
224
|
toast({
|
|
223
225
|
title: "Failed to capture cell outputs",
|
|
224
|
-
description:
|
|
225
|
-
"Some outputs may not appear in the PDF. Continuing with export.",
|
|
226
|
+
description: "Some outputs may be missing from the export. Continuing.",
|
|
226
227
|
variant: "danger",
|
|
227
228
|
});
|
|
228
229
|
}
|