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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/assets/{JsonOutput-9XtRRx5l.js → JsonOutput-D_ORGqdz.js} +1 -1
  2. package/dist/assets/{add-connection-dialog-ux7eCDRM.js → add-connection-dialog-DGgtN73u.js} +1 -1
  3. package/dist/assets/{agent-panel-CdOqi3vb.js → agent-panel-D7gqlew5.js} +1 -1
  4. package/dist/assets/{cell-editor-CuHdpTsy.js → cell-editor-B2IIBFCB.js} +1 -1
  5. package/dist/assets/{column-preview-DrU255Z3.js → column-preview-DQBtRWJG.js} +1 -1
  6. package/dist/assets/{command-palette-DaEVrXkC.js → command-palette-BCrWwbIt.js} +1 -1
  7. package/dist/assets/{edit-page-DOK2VJe6.js → edit-page-fl9KJOcI.js} +3 -3
  8. package/dist/assets/{file-explorer-panel-CzYUz358.js → file-explorer-panel-bcSqGkbZ.js} +1 -1
  9. package/dist/assets/{form-BiDLPu7R.js → form-30oC5z9y.js} +1 -1
  10. package/dist/assets/{hooks-BgwM3Mb2.js → hooks-DLUrd-jH.js} +1 -1
  11. package/dist/assets/{index-DXwhLiKr.js → index-DTBKKey_.js} +11 -11
  12. package/dist/assets/{index-Dbq6ugUC.css → index-qO0a4zuT.css} +1 -1
  13. package/dist/assets/{layout-CF-7BNtf.js → layout-cq-nxDfO.js} +1 -1
  14. package/dist/assets/{panels-7-kbDRzv.js → panels-B5BFPT3k.js} +1 -1
  15. package/dist/assets/{run-page-9OQqe8IY.js → run-page-CI2eOA-G.js} +1 -1
  16. package/dist/assets/{scratchpad-panel-C8dGg-F9.js → scratchpad-panel-Dwp8-2S1.js} +1 -1
  17. package/dist/assets/{session-panel-BuzMiMf3.js → session-panel-ryqVmqVd.js} +1 -1
  18. package/dist/assets/{state-6D_2UAw3.js → state-CMxx6hcP.js} +1 -1
  19. package/dist/assets/{useNotebookActions-aodoqUGd.js → useNotebookActions-D8Dm93y8.js} +1 -1
  20. package/dist/index.html +6 -6
  21. package/package.json +1 -1
  22. package/src/components/data-table/TableTopBar.tsx +1 -1
  23. package/src/components/data-table/table-explorer-panel/table-explorer-panel.tsx +1 -1
  24. package/src/css/table.css +4 -0
  25. package/src/plugins/impl/common/labeled.tsx +5 -3
  26. package/src/plugins/impl/plotly/PlotlyPlugin.tsx +4 -2
  27. package/src/plugins/impl/plotly/__tests__/PlotlyPlugin.test.tsx +50 -0
  28. package/src/plugins/impl/plotly/__tests__/selection.test.ts +73 -0
  29. package/src/plugins/impl/plotly/selection.ts +35 -3
@@ -1,3 +1,3 @@
1
- var Ht=Object.defineProperty;var De=f=>{throw TypeError(f)};var Ot=(f,h,y)=>h in f?Ht(f,h,{enumerable:!0,configurable:!0,writable:!0,value:y}):f[h]=y;var n=(f,h,y)=>Ot(f,typeof h!="symbol"?h+"":h,y),ue=(f,h,y)=>h.has(f)||De("Cannot "+y);var o=(f,h,y)=>(ue(f,h,"read from private field"),y?y.call(f):h.get(f)),_=(f,h,y)=>h.has(f)?De("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(f):h.set(f,y),C=(f,h,y,z)=>(ue(f,h,"write to private field"),z?z.call(f,y):h.set(f,y),y),A=(f,h,y)=>(ue(f,h,"access private method"),y);import{i as Q,p as de,u as $t}from"./useEvent-D91BmmQi.js";import{An as zt,Si as Y,b as Vt,ci as Qt,di as Yt,gi as Gt,it as He,pi as Jt,x as Kt,xi as Xt,__tla as Zt}from"./cells-EJo3u4za.js";import{t as er}from"./get-D7jeR2wg.js";import{t as tr}from"./debounce-BbSyBDA8.js";import{t as rr}from"./_baseSet-49dbm-yb.js";import{_ as p,y as g}from"./useEventListener-DGjKht0c.js";import{t as sr}from"./invariant-CkiqGLcK.js";import{S as nr}from"./utils-8btzWeZg.js";import{S as ar,n as ir}from"./config-DoZCLcOb.js";import{n as or}from"./switch-C6xjg01T.js";import{n as Oe}from"./globals-DQM2RvzM.js";import{at as ce,ot as $e,__tla as lr}from"./JsonOutput-9XtRRx5l.js";import{t as ur}from"./createReducer-CYlwteGD.js";import{r as dr}from"./strings-pfr2N700.js";import{t as pe}from"./requests-9-v2bhoi.js";import{a as ze,l as cr,r as Ve,__tla as pr}from"./markdown-renderer-B9RsGqHb.js";import{t as fr}from"./DeferredRequestRegistry-BLWK1eKa.js";import{t as hr}from"./preload-helper-D2MJg03u.js";import{t as Qe}from"./Deferred-DxQeE5uh.js";import{t as Ye}from"./uuid-DXdzqzcr.js";import{t as mr}from"./use-toast-BDYuj3zG.js";import{n as gr,r as yr,t as wr}from"./share-0LPgOyiW.js";import{t as br}from"./blob-CTort_or.js";import{i as Ge,r as vr,t as _r}from"./events-Qeh-bHlj.js";let G,fe,he,Je,Ke,Xe,Ze,et,J,tt,me,rt,st,nt,ge,at,ne,it,ot,ye,lt,ut,Cr=Promise.all([(()=>{try{return Zt}catch{}})(),(()=>{try{return lr}catch{}})(),(()=>{try{return pr}catch{}})()]).then(async()=>{var U,ee,ct,Ie,M,T,E,Le,F,Ne,P,V,D,ae,Ae,Ue,te,I,L,H,R,j,N,pt,ft,ht,re;function f(t,e,r){return t==null?t:rr(t,e,r)}G=f,ut=de(null);var{valueAtom:h,useActions:y}=ur(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:Ye()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(r=>r.id!==e)}),clearBanners:t=>({...t,banners:[]})});Je=()=>$t(h),lt=function(){return y()};let z,be,ve;z=class{constructor(){n(this,"subscriptions",new Map)}addSubscription(t,e){var r;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(r=this.subscriptions.get(t))==null||r.add(e)}removeSubscription(t,e){var r;(r=this.subscriptions.get(t))==null||r.delete(e)}notify(t,e){for(let r of this.subscriptions.get(t)??[])r(e)}},ye=class we{constructor(e){n(this,"subscriptions",new z);this.producer=e}static withProducerCallback(e){return new we(e)}static empty(){return new we}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,r){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,r){this.subscriptions.addSubscription(e,r),e==="open"&&r(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,r){this.subscriptions.removeSubscription(e,r)}},be=1e10,ve=1e3;function K(t,e){let r=t.map(s=>`"${s}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${r}`)}function gt(t={}){let e={};function r(l){e=l}let s={};function a(l){var c;s.unregisterHandler&&s.unregisterHandler(),s=l,(c=s.registerHandler)==null||c.call(s,Dt)}let i;function u(l){if(typeof l=="function"){i=l;return}i=(c,w)=>{let m=l[c];if(m)return m(w);let b=l._;if(!b)throw Error(`The requested method has no handler: ${c}`);return b(c,w)}}let{maxRequestTime:d=ve}=t;t.transport&&a(t.transport),t.requestHandler&&u(t.requestHandler),t._debugHooks&&r(t._debugHooks);let v=0;function q(){return v<=be?++v:v=0}let x=new Map,S=new Map;function O(l,...c){let w=c[0];return new Promise((m,b)=>{var $;if(!s.send)throw K(["send"],"make requests");let k=q(),W={type:"request",id:k,method:l,params:w};x.set(k,{resolve:m,reject:b}),d!==1/0&&S.set(k,setTimeout(()=>{S.delete(k),b(Error("RPC request timed out."))},d)),($=e.onSend)==null||$.call(e,W),s.send(W)})}let se=new Proxy(O,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>O(c,m)}),Te=se;function je(l,...c){var b;let w=c[0];if(!s.send)throw K(["send"],"send messages");let m={type:"message",id:l,payload:w};(b=e.onSend)==null||b.call(e,m),s.send(m)}let Be=new Proxy(je,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>je(c,m)}),We=Be,B=new Map,le=new Set;function Bt(l,c){var w;if(!s.registerHandler)throw K(["registerHandler"],"register message listeners");if(l==="*"){le.add(c);return}B.has(l)||B.set(l,new Set),(w=B.get(l))==null||w.add(c)}function Wt(l,c){var w,m;if(l==="*"){le.delete(c);return}(w=B.get(l))==null||w.delete(c),((m=B.get(l))==null?void 0:m.size)===0&&B.delete(l)}async function Dt(l){var c,w;if((c=e.onReceive)==null||c.call(e,l),!("type"in l))throw Error("Message does not contain a type.");if(l.type==="request"){if(!s.send||!i)throw K(["send","requestHandler"],"handle requests");let{id:m,method:b,params:k}=l,W;try{W={type:"response",id:m,success:!0,payload:await i(b,k)}}catch($){if(!($ instanceof Error))throw $;W={type:"response",id:m,success:!1,error:$.message}}(w=e.onSend)==null||w.call(e,W),s.send(W);return}if(l.type==="response"){let m=S.get(l.id);m!=null&&clearTimeout(m);let{resolve:b,reject:k}=x.get(l.id)??{};l.success?b==null||b(l.payload):k==null||k(Error(l.error));return}if(l.type==="message"){for(let b of le)b(l.id,l.payload);let m=B.get(l.id);if(!m)return;for(let b of m)b(l.payload);return}throw Error(`Unexpected RPC message type: ${l.type}`)}return{setTransport:a,setRequestHandler:u,request:se,requestProxy:Te,send:Be,sendProxy:We,addMessageListener:Bt,removeMessageListener:Wt,proxy:{send:We,request:Te},_setDebugHooks:r}}function yt(t){return gt(t)}var _e="[transport-id]";function wt(t,e){let{transportId:r}=e;return r==null?t:{[_e]:r,data:t}}function bt(t,e){let{transportId:r,filter:s}=e,a=s==null?void 0:s();if(r!=null&&a!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(r){if(t[_e]!==r)return[!0];i=t.data}return a===!1?[!0]:[!1,i]}function vt(t,e={}){let{transportId:r,filter:s,remotePort:a}=e,i=t,u=a??t,d;return{send(v){u.postMessage(wt(v,{transportId:r}))},registerHandler(v){d=q=>{let x=q.data,[S,O]=bt(x,{transportId:r,filter:()=>s==null?void 0:s(q)});S||v(O)},i.addEventListener("message",d)},unregisterHandler(){d&&i.removeEventListener("message",d)}}}function _t(t,e){return vt(t,e)}function Ce(t){return yt({transport:_t(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{p.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{p.debug("[rpc] Worker -> Parent",e)}}})}fe=de("Initializing..."),et=de(t=>{let e=t(Vt),r=Object.values(e.cellRuntime);return r.some(s=>!cr(s.output))?!0:r.every(s=>s.status==="idle")});var Re=gr(),qe="marimo:file",xe=new Qt(null);const Ct={saveFile(t){xe.set(qe,t)},readFile(){return xe.get(qe)}};var Rt={saveFile(t){Y.setCodeForHash((0,Re.compressToEncodedURIComponent)(t))},readFile(){let t=Y.getCodeFromHash()||Y.getCodeFromSearchParam();return t?(0,Re.decompressFromEncodedURIComponent)(t):null}};const qt={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var xt={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}};const St={saveFile(t){},readFile(){return Q.get(Yt)??null}};var Et={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
1
+ var Ht=Object.defineProperty;var De=f=>{throw TypeError(f)};var Ot=(f,h,y)=>h in f?Ht(f,h,{enumerable:!0,configurable:!0,writable:!0,value:y}):f[h]=y;var n=(f,h,y)=>Ot(f,typeof h!="symbol"?h+"":h,y),ue=(f,h,y)=>h.has(f)||De("Cannot "+y);var o=(f,h,y)=>(ue(f,h,"read from private field"),y?y.call(f):h.get(f)),_=(f,h,y)=>h.has(f)?De("Cannot add the same private member more than once"):h instanceof WeakSet?h.add(f):h.set(f,y),C=(f,h,y,z)=>(ue(f,h,"write to private field"),z?z.call(f,y):h.set(f,y),y),A=(f,h,y)=>(ue(f,h,"access private method"),y);import{i as Q,p as de,u as $t}from"./useEvent-D91BmmQi.js";import{An as zt,Si as Y,b as Vt,ci as Qt,di as Yt,gi as Gt,it as He,pi as Jt,x as Kt,xi as Xt,__tla as Zt}from"./cells-EJo3u4za.js";import{t as er}from"./get-D7jeR2wg.js";import{t as tr}from"./debounce-BbSyBDA8.js";import{t as rr}from"./_baseSet-49dbm-yb.js";import{_ as p,y as g}from"./useEventListener-DGjKht0c.js";import{t as sr}from"./invariant-CkiqGLcK.js";import{S as nr}from"./utils-8btzWeZg.js";import{S as ar,n as ir}from"./config-DoZCLcOb.js";import{n as or}from"./switch-C6xjg01T.js";import{n as Oe}from"./globals-DQM2RvzM.js";import{at as ce,ot as $e,__tla as lr}from"./JsonOutput-D_ORGqdz.js";import{t as ur}from"./createReducer-CYlwteGD.js";import{r as dr}from"./strings-pfr2N700.js";import{t as pe}from"./requests-9-v2bhoi.js";import{a as ze,l as cr,r as Ve,__tla as pr}from"./markdown-renderer-B9RsGqHb.js";import{t as fr}from"./DeferredRequestRegistry-BLWK1eKa.js";import{t as hr}from"./preload-helper-D2MJg03u.js";import{t as Qe}from"./Deferred-DxQeE5uh.js";import{t as Ye}from"./uuid-DXdzqzcr.js";import{t as mr}from"./use-toast-BDYuj3zG.js";import{n as gr,r as yr,t as wr}from"./share-0LPgOyiW.js";import{t as br}from"./blob-CTort_or.js";import{i as Ge,r as vr,t as _r}from"./events-Qeh-bHlj.js";let G,fe,he,Je,Ke,Xe,Ze,et,J,tt,me,rt,st,nt,ge,at,ne,it,ot,ye,lt,ut,Cr=Promise.all([(()=>{try{return Zt}catch{}})(),(()=>{try{return lr}catch{}})(),(()=>{try{return pr}catch{}})()]).then(async()=>{var U,ee,ct,Ie,M,T,E,Le,F,Ne,P,V,D,ae,Ae,Ue,te,I,L,H,R,j,N,pt,ft,ht,re;function f(t,e,r){return t==null?t:rr(t,e,r)}G=f,ut=de(null);var{valueAtom:h,useActions:y}=ur(()=>({banners:[]}),{addBanner:(t,e)=>({...t,banners:[...t.banners,{...e,id:Ye()}]}),removeBanner:(t,e)=>({...t,banners:t.banners.filter(r=>r.id!==e)}),clearBanners:t=>({...t,banners:[]})});Je=()=>$t(h),lt=function(){return y()};let z,be,ve;z=class{constructor(){n(this,"subscriptions",new Map)}addSubscription(t,e){var r;this.subscriptions.has(t)||this.subscriptions.set(t,new Set),(r=this.subscriptions.get(t))==null||r.add(e)}removeSubscription(t,e){var r;(r=this.subscriptions.get(t))==null||r.delete(e)}notify(t,e){for(let r of this.subscriptions.get(t)??[])r(e)}},ye=class we{constructor(e){n(this,"subscriptions",new z);this.producer=e}static withProducerCallback(e){return new we(e)}static empty(){return new we}startProducer(){this.producer&&this.producer(e=>{this.subscriptions.notify("message",e)})}connect(){return new Promise(e=>setTimeout(e,0)).then(()=>{this.subscriptions.notify("open",new Event("open"))})}get readyState(){return WebSocket.OPEN}reconnect(e,r){this.close(),this.connect()}close(){this.subscriptions.notify("close",new Event("close"))}send(e){return this.subscriptions.notify("message",new MessageEvent("message",{data:e})),Promise.resolve()}addEventListener(e,r){this.subscriptions.addSubscription(e,r),e==="open"&&r(new Event("open")),e==="message"&&this.startProducer()}removeEventListener(e,r){this.subscriptions.removeSubscription(e,r)}},be=1e10,ve=1e3;function K(t,e){let r=t.map(s=>`"${s}"`).join(", ");return Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${r}`)}function gt(t={}){let e={};function r(l){e=l}let s={};function a(l){var c;s.unregisterHandler&&s.unregisterHandler(),s=l,(c=s.registerHandler)==null||c.call(s,Dt)}let i;function u(l){if(typeof l=="function"){i=l;return}i=(c,w)=>{let m=l[c];if(m)return m(w);let b=l._;if(!b)throw Error(`The requested method has no handler: ${c}`);return b(c,w)}}let{maxRequestTime:d=ve}=t;t.transport&&a(t.transport),t.requestHandler&&u(t.requestHandler),t._debugHooks&&r(t._debugHooks);let v=0;function q(){return v<=be?++v:v=0}let x=new Map,S=new Map;function O(l,...c){let w=c[0];return new Promise((m,b)=>{var $;if(!s.send)throw K(["send"],"make requests");let k=q(),W={type:"request",id:k,method:l,params:w};x.set(k,{resolve:m,reject:b}),d!==1/0&&S.set(k,setTimeout(()=>{S.delete(k),b(Error("RPC request timed out."))},d)),($=e.onSend)==null||$.call(e,W),s.send(W)})}let se=new Proxy(O,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>O(c,m)}),Te=se;function je(l,...c){var b;let w=c[0];if(!s.send)throw K(["send"],"send messages");let m={type:"message",id:l,payload:w};(b=e.onSend)==null||b.call(e,m),s.send(m)}let Be=new Proxy(je,{get:(l,c,w)=>c in l?Reflect.get(l,c,w):m=>je(c,m)}),We=Be,B=new Map,le=new Set;function Bt(l,c){var w;if(!s.registerHandler)throw K(["registerHandler"],"register message listeners");if(l==="*"){le.add(c);return}B.has(l)||B.set(l,new Set),(w=B.get(l))==null||w.add(c)}function Wt(l,c){var w,m;if(l==="*"){le.delete(c);return}(w=B.get(l))==null||w.delete(c),((m=B.get(l))==null?void 0:m.size)===0&&B.delete(l)}async function Dt(l){var c,w;if((c=e.onReceive)==null||c.call(e,l),!("type"in l))throw Error("Message does not contain a type.");if(l.type==="request"){if(!s.send||!i)throw K(["send","requestHandler"],"handle requests");let{id:m,method:b,params:k}=l,W;try{W={type:"response",id:m,success:!0,payload:await i(b,k)}}catch($){if(!($ instanceof Error))throw $;W={type:"response",id:m,success:!1,error:$.message}}(w=e.onSend)==null||w.call(e,W),s.send(W);return}if(l.type==="response"){let m=S.get(l.id);m!=null&&clearTimeout(m);let{resolve:b,reject:k}=x.get(l.id)??{};l.success?b==null||b(l.payload):k==null||k(Error(l.error));return}if(l.type==="message"){for(let b of le)b(l.id,l.payload);let m=B.get(l.id);if(!m)return;for(let b of m)b(l.payload);return}throw Error(`Unexpected RPC message type: ${l.type}`)}return{setTransport:a,setRequestHandler:u,request:se,requestProxy:Te,send:Be,sendProxy:We,addMessageListener:Bt,removeMessageListener:Wt,proxy:{send:We,request:Te},_setDebugHooks:r}}function yt(t){return gt(t)}var _e="[transport-id]";function wt(t,e){let{transportId:r}=e;return r==null?t:{[_e]:r,data:t}}function bt(t,e){let{transportId:r,filter:s}=e,a=s==null?void 0:s();if(r!=null&&a!=null)throw Error("Cannot use both `transportId` and `filter` at the same time");let i=t;if(r){if(t[_e]!==r)return[!0];i=t.data}return a===!1?[!0]:[!1,i]}function vt(t,e={}){let{transportId:r,filter:s,remotePort:a}=e,i=t,u=a??t,d;return{send(v){u.postMessage(wt(v,{transportId:r}))},registerHandler(v){d=q=>{let x=q.data,[S,O]=bt(x,{transportId:r,filter:()=>s==null?void 0:s(q)});S||v(O)},i.addEventListener("message",d)},unregisterHandler(){d&&i.removeEventListener("message",d)}}}function _t(t,e){return vt(t,e)}function Ce(t){return yt({transport:_t(t,{transportId:"marimo-transport"}),maxRequestTime:2e4,_debugHooks:{onSend:e=>{p.debug("[rpc] Parent -> Worker",e)},onReceive:e=>{p.debug("[rpc] Worker -> Parent",e)}}})}fe=de("Initializing..."),et=de(t=>{let e=t(Vt),r=Object.values(e.cellRuntime);return r.some(s=>!cr(s.output))?!0:r.every(s=>s.status==="idle")});var Re=gr(),qe="marimo:file",xe=new Qt(null);const Ct={saveFile(t){xe.set(qe,t)},readFile(){return xe.get(qe)}};var Rt={saveFile(t){Y.setCodeForHash((0,Re.compressToEncodedURIComponent)(t))},readFile(){let t=Y.getCodeFromHash()||Y.getCodeFromSearchParam();return t?(0,Re.decompressFromEncodedURIComponent)(t):null}};const qt={saveFile(t){},readFile(){let t=document.querySelector("marimo-code");return t?decodeURIComponent(t.textContent||"").trim():null}};var xt={saveFile(t){},readFile(){if(window.location.hostname!=="marimo.app")return null;let t=new URL("files/wasm-intro.py",document.baseURI);return fetch(t.toString()).then(e=>e.ok?e.text():null).catch(()=>null)}};const St={saveFile(t){},readFile(){return Q.get(Yt)??null}};var Et={saveFile(t){},readFile(){return["import marimo","app = marimo.App()","","@app.cell","def __():"," return","",'if __name__ == "__main__":'," app.run()"].join(`
2
2
  `)}},Se=class{constructor(t){this.stores=t}insert(t,e){this.stores.splice(t,0,e)}saveFile(t){this.stores.forEach(e=>e.saveFile(t))}readFile(){for(let t of this.stores){let e=t.readFile();if(e)return e}return null}};let X;J=new Se([St,qt,Rt]),X=new Se([Ct,xt,Et]),ge=class dt{constructor(){n(this,"initialized",new Qe);n(this,"sendRename",async({filename:e})=>(e===null||(Y.setFilename(e),await this.rpc.proxy.request.bridge({functionName:"rename_file",payload:e})),null));n(this,"sendSave",async e=>{if(!this.saveRpc)return p.warn("Save RPC not initialized"),null;await this.saveRpc.saveNotebook(e);let r=await this.readCode();return r.contents&&(J.saveFile(r.contents),X.saveFile(r.contents)),this.rpc.proxy.request.saveNotebook(e).catch(s=>{p.error(s)}),null});n(this,"sendCopy",async()=>{g()});n(this,"sendStdin",async e=>(await this.rpc.proxy.request.bridge({functionName:"put_input",payload:e.text}),null));n(this,"sendPdb",async()=>{g()});n(this,"sendRun",async e=>(await this.rpc.proxy.request.loadPackages(e.codes.join(`
3
3
  `)),await this.putControlRequest({type:"execute-cells",...e}),null));n(this,"sendRunScratchpad",async e=>(await this.rpc.proxy.request.loadPackages(e.code),await this.putControlRequest({type:"execute-scratchpad",...e}),null));n(this,"sendInterrupt",async()=>(this.interruptBuffer!==void 0&&(this.interruptBuffer[0]=2),null));n(this,"sendShutdown",async()=>(window.close(),null));n(this,"sendFormat",async e=>await this.rpc.proxy.request.bridge({functionName:"format",payload:e}));n(this,"sendDeleteCell",async e=>(await this.putControlRequest({type:"delete-cell",...e}),null));n(this,"sendInstallMissingPackages",async e=>(this.putControlRequest({type:"install-packages",...e}),null));n(this,"sendCodeCompletionRequest",async e=>(Q.get(Kt)||await this.rpc.proxy.request.bridge({functionName:"code_complete",payload:e}),null));n(this,"saveUserConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_user_config",payload:e}),or.post("/kernel/save_user_config",e,{baseUrl:"/"}).catch(r=>(p.error(r),null))));n(this,"saveAppConfig",async e=>(await this.rpc.proxy.request.bridge({functionName:"save_app_config",payload:e}),null));n(this,"saveCellConfig",async e=>(await this.putControlRequest({type:"update-cell-config",...e}),null));n(this,"sendRestart",async()=>{let e=await this.readCode();return e.contents&&(J.saveFile(e.contents),X.saveFile(e.contents)),yr(),null});n(this,"readCode",async()=>this.saveRpc?{contents:await this.saveRpc.readNotebook()}:(p.warn("Save RPC not initialized"),{contents:""}));n(this,"readSnippets",async()=>await this.rpc.proxy.request.bridge({functionName:"read_snippets",payload:void 0}));n(this,"openFile",async({path:e})=>{let r=wr({code:null,baseUrl:window.location.origin});return window.open(r,"_blank"),null});n(this,"sendListFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"list_files",payload:e}));n(this,"sendSearchFiles",async e=>await this.rpc.proxy.request.bridge({functionName:"search_files",payload:e}));n(this,"sendComponentValues",async e=>(await this.putControlRequest({type:"update-ui-element",...e,token:Ye()}),null));n(this,"sendInstantiate",async e=>null);n(this,"sendFunctionRequest",async e=>(await this.putControlRequest({type:"invoke-function",...e}),null));n(this,"sendCreateFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"create_file_or_directory",payload:e}));n(this,"sendDeleteFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"delete_file_or_directory",payload:e}));n(this,"sendRenameFileOrFolder",async e=>await this.rpc.proxy.request.bridge({functionName:"move_file_or_directory",payload:e}));n(this,"sendUpdateFile",async e=>await this.rpc.proxy.request.bridge({functionName:"update_file",payload:e}));n(this,"sendFileDetails",async e=>await this.rpc.proxy.request.bridge({functionName:"file_details",payload:e}));n(this,"exportAsHTML",async e=>await this.rpc.proxy.request.bridge({functionName:"export_html",payload:e}));n(this,"exportAsMarkdown",async e=>await this.rpc.proxy.request.bridge({functionName:"export_markdown",payload:e}));n(this,"previewDatasetColumn",async e=>(await this.putControlRequest({type:"preview-dataset-column",...e}),null));n(this,"previewSQLTable",async e=>(await this.putControlRequest({type:"preview-sql-table",...e}),null));n(this,"previewSQLTableList",async e=>(await this.putControlRequest({type:"list-sql-tables",...e}),null));n(this,"previewSQLSchemaList",async e=>(await this.putControlRequest({type:"list-sql-schemas",...e}),null));n(this,"previewDataSourceConnection",async e=>(await this.putControlRequest({type:"list-data-source-connection",...e}),null));n(this,"validateSQL",async e=>(await this.putControlRequest({type:"validate-sql",...e}),null));n(this,"sendModelValue",async e=>(await this.putControlRequest({type:"model",...e}),null));n(this,"sendDocumentTransaction",()=>Promise.resolve(null));n(this,"addPackage",async e=>this.rpc.proxy.request.addPackage(e));n(this,"removePackage",async e=>this.rpc.proxy.request.removePackage(e));n(this,"getPackageList",async()=>await this.rpc.proxy.request.listPackages());n(this,"getDependencyTree",async()=>({tree:{dependencies:[],name:"",tags:[],version:null}}));n(this,"listSecretKeys",async e=>(await this.putControlRequest({type:"list-secret-keys",...e}),null));n(this,"getUsageStats",g);n(this,"openTutorial",g);n(this,"getRecentFiles",g);n(this,"getWorkspaceFiles",g);n(this,"getRunningNotebooks",g);n(this,"shutdownSession",g);n(this,"exportAsIPYNB",g);n(this,"exportAsPDF",g);n(this,"autoExportAsHTML",g);n(this,"autoExportAsMarkdown",g);n(this,"autoExportAsIPYNB",g);n(this,"updateCellOutputs",g);n(this,"writeSecret",g);n(this,"invokeAiTool",g);n(this,"clearCache",g);n(this,"getCacheInfo",g);n(this,"listStorageEntries",g);n(this,"downloadStorage",g);ar()&&(this.rpc=Ce(new Worker(new URL(""+new URL("worker-BPV9SmHz.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})),this.rpc.addMessageListener("ready",()=>{this.startSession()}),this.rpc.addMessageListener("initialized",()=>{this.saveRpc=this.getSaveWorker(),this.setInterruptBuffer(),this.initialized.resolve()}),this.rpc.addMessageListener("initializingMessage",({message:e})=>{Q.set(fe,e)}),this.rpc.addMessageListener("initializedError",({error:e})=>{this.initialized.status==="resolved"&&(p.error(e),mr({title:"Error initializing",description:e,variant:"danger"})),this.initialized.reject(Error(e))}),this.rpc.addMessageListener("kernelMessage",({message:e})=>{var r;(r=this.messageConsumer)==null||r.call(this,new MessageEvent("message",{data:e}))}))}static get INSTANCE(){let e="_marimo_private_PyodideBridge";return window[e]||(window[e]=new dt),window[e]}getSaveWorker(){return He()==="read"?(p.debug("Skipping SaveWorker in read-mode"),{readFile:g,readNotebook:g,saveNotebook:g}):Ce(new Worker(new URL(""+new URL("save-worker-CtJsIYIM.js",import.meta.url).href,""+import.meta.url),{type:"module",name:Oe()})).proxy.request}async startSession(){let e=await J.readFile(),r=await X.readFile(),s=Q.get(Jt)??Y.getFilename(),a=Q.get(nr),i={},u=new URLSearchParams(window.location.search);for(let d of u.keys()){let v=u.getAll(d);i[d]=v.length===1?v[0]:v}await this.rpc.proxy.request.startSession({queryParameters:i,code:e||r||"",filename:s,userConfig:{...a,runtime:{...a.runtime,auto_instantiate:He()==="read"?!0:a.runtime.auto_instantiate}}})}setInterruptBuffer(){crossOriginIsolated?(this.interruptBuffer=new Uint8Array(new SharedArrayBuffer(1)),this.rpc.proxy.request.setInterruptBuffer(this.interruptBuffer)):p.warn("Not running in a secure context; interrupts are not available.")}attachMessageConsumer(e){this.messageConsumer=e,this.rpc.proxy.send.consumerReady({})}async putControlRequest(e){await this.rpc.proxy.request.bridge({functionName:"put_control_request",payload:e})}},rt=function(){return ye.withProducerCallback(t=>{ge.INSTANCE.attachMessageConsumer(t)})},Xe=function(t=ce()){let e=window.fetch;return window.fetch=async(r,s)=>{let a=r instanceof Request?r.url:r.toString();if(a.startsWith("data:"))return e(r,s);try{let i=Z(a,t);if(i){let u=await(await e(i)).arrayBuffer();return new Response(u,{headers:{"Content-Type":kt(a)}})}return e(r,s)}catch(i){return p.error("Error parsing URL",i),e(r,s)}},()=>{window.fetch=e}};function kt(t){return t.endsWith(".csv")?"text/csv":t.endsWith(".json")?"application/json":t.endsWith(".txt")?"text/plain":"application/octet-stream"}Ze=function(t,e=ce()){let r=t.http.bind(t),s=t.load.bind(t);return t.http=async a=>{let i=Z(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await r(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},t.load=async a=>{let i=Z(a,e);if(i)return await window.fetch(i).then(u=>u.text());try{return await s(a)}catch(u){if(a.startsWith("data:"))return await window.fetch(a).then(d=>d.text());throw u}},()=>{t.http=r,t.load=s}};function Ee(t){return t.startsWith(".")?t.slice(1):t}function Mt(t,e=ce()){let r=Z(t,e);if(!r)return t;let s=br(r);return URL.createObjectURL(s)}function Z(t,e){let r=document.baseURI;r.startsWith("blob:")&&(r=r.replace("blob:",""));let s=new URL(t,r).pathname,a=ke(t),i=ke(s);return e[t]||e[Ee(t)]||e[s]||e[Ee(s)]||a&&e[a]||i&&e[i]}function ke(t){let e=t.indexOf("/@file/");return e===-1?null:t.slice(e)}function ie(t,e=[]){let r=[];if(t instanceof DataView)r.push(e);else if(Array.isArray(t))for(let[s,a]of t.entries())r.push(...ie(a,[...e,s]));else if(typeof t=="object"&&t)for(let[s,a]of Object.entries(t))r.push(...ie(a,[...e,s]));return r}function Pt(t){let e=ie(t);if(e.length===0)return{state:t,buffers:[],bufferPaths:[]};let r=structuredClone(t),s=[],a=[];for(let i of e){let u=er(t,i);if(u instanceof DataView){let d=ze(u);s.push(d),a.push(i),G(r,i,d)}}return{state:r,buffers:s,bufferPaths:a}}function Me(t){let{state:e,bufferPaths:r,buffers:s}=t;if(!r||r.length===0)return e;s&&sr(s.length===r.length,"Buffers and buffer paths not the same length");let a=e;for(let[i,u]of r.entries()){let d=s==null?void 0:s[i];if(d==null){p.warn("[anywidget] Could not find buffer at path",u);continue}typeof d=="string"?G(a,u,Ve(d)):G(a,u,d)}return a}const Pe={invoke:async()=>{let t="anywidget.invoke not supported in marimo. Please file an issue at https://github.com/marimo-team/marimo/issues";throw p.warn(t),Error(t)}};function Ft(t){if(typeof AbortSignal.any=="function")return AbortSignal.any(t);let e=new AbortController;for(let r of t){if(r.aborted)return e.abort(r.reason),e.signal;r.addEventListener("abort",()=>e.abort(r.reason),{once:!0})}return e.signal}var It=(Ie=class{constructor(){_(this,ee);_(this,U,new Map)}getModule(t,e){let r=o(this,U).get(e);if(r)return r;let s=A(this,ee,ct).call(this,t).catch(a=>{throw o(this,U).delete(e),a});return o(this,U).set(e,s),s}invalidate(t){p.debug(`[WidgetDefRegistry] Invalidating module cache for hash=${t}`),o(this,U).delete(t)}},U=new WeakMap,ee=new WeakSet,ct=async function(t){let e=ir(t).toString();return $e()&&(e=Mt(e)),hr(()=>import(e).then(async r=>(await r.__tla,r)),[],import.meta.url)},Ie),Lt=(Le=class{constructor(){_(this,M);_(this,T);_(this,E)}async bind(t,e){var i,u;if(o(this,E)&&o(this,T)===t)return o(this,E);o(this,E)&&o(this,T)!==t&&(p.debug("[WidgetBinding] Hot-reload detected, aborting previous binding"),(i=o(this,M))==null||i.abort(),C(this,M,void 0),C(this,E,void 0)),C(this,T,t),C(this,M,new AbortController);let r=o(this,M).signal,s=typeof t=="function"?await t():t,a=await((u=s.initialize)==null?void 0:u.call(s,{model:e,experimental:Pe}));return a&&r.addEventListener("abort",a),C(this,E,async(d,v)=>{var x;let q=await((x=s.render)==null?void 0:x.call(s,{model:e,el:d,experimental:Pe}));q&&Ft([v,r]).addEventListener("abort",()=>{let S=v.aborted?"view unmount":"binding destroyed";p.debug(`[WidgetBinding] Render cleanup triggered (reason: ${S})`),q()})}),o(this,E)}destroy(){var t;p.debug("[WidgetBinding] Destroying binding, aborting initialize lifecycle"),(t=o(this,M))==null||t.abort(),C(this,M,void 0),C(this,T,void 0),C(this,E,void 0)}},M=new WeakMap,T=new WeakMap,E=new WeakMap,Le),Nt=(Ne=class{constructor(){_(this,F,new Map)}getOrCreate(t){let e=o(this,F).get(t);return e||(e=new Lt,o(this,F).set(t,e)),e}destroy(t){let e=o(this,F).get(t);e&&(p.debug(`[BindingManager] Destroying binding for model=${t}`),e.destroy(),o(this,F).delete(t))}has(t){return o(this,F).has(t)}},F=new WeakMap,Ne);ot=new It,me=new Nt;var At=(Ae=class{constructor(t=1e4){_(this,D);_(this,P,new Map);_(this,V);C(this,V,t)}get(t){let e=A(this,D,ae).call(this,t);return e.deferred.status==="pending"&&setTimeout(()=>{e.deferred.status==="pending"&&(e.deferred.reject(Error(`Model not found for key: ${t}`)),o(this,P).delete(t))},o(this,V)),e.deferred.promise}create(t,e){let r=A(this,D,ae).call(this,t);r.deferred.resolve(e(r.controller.signal))}set(t,e){A(this,D,ae).call(this,t).deferred.resolve(e)}getSync(t){let e=o(this,P).get(t);if(e&&e.deferred.status==="resolved")return e.deferred.value}delete(t){var e;p.debug(`[ModelManager] Deleting model=${t}, aborting lifecycle signal`),(e=o(this,P).get(t))==null||e.controller.abort(),o(this,P).delete(t)}},P=new WeakMap,V=new WeakMap,D=new WeakSet,ae=function(t){let e=o(this,P).get(t);return e||(e={deferred:new Qe,controller:new AbortController},o(this,P).set(t,e)),e},Ae),Fe=Symbol("marimo");function oe(t){return t[Fe]}ne=new At;var Ut=(Ue=Fe,j=class{constructor(e,r,s){_(this,N);_(this,te,"change");_(this,I);_(this,L);_(this,H);_(this,R,{});n(this,Ue,{updateAndEmitDiffs:e=>A(this,N,ft).call(this,e),emitCustomMessage:(e,r)=>A(this,N,ht).call(this,e,r)});n(this,"widget_manager",{async get_model(e){let r=await j._modelManager.get(e);if(!r)throw Error(`Model not found with id: ${e}. This is likely because the model was not registered.`);return r}});_(this,re,tr(()=>{let e=o(this,R)[o(this,te)];if(e)for(let r of e)try{r()}catch(s){p.error("Error emitting event",s)}},0));C(this,L,e),C(this,H,r),C(this,I,new Map),s&&s.addEventListener("abort",()=>{p.debug("[Model] Signal aborted, clearing all listeners"),C(this,R,{})})}off(e,r){var s;if(!e){C(this,R,{});return}if(!r){o(this,R)[e]=new Set;return}(s=o(this,R)[e])==null||s.delete(r)}send(e,r,s){let a=(s??[]).map(i=>i instanceof ArrayBuffer?new DataView(i):new DataView(i.buffer,i.byteOffset,i.byteLength));return o(this,H).sendCustomMessage(e,a).then(()=>r==null?void 0:r())}get(e){return o(this,L)[e]}set(e,r){C(this,L,{...o(this,L),[e]:r}),o(this,I).set(e,r),A(this,N,pt).call(this,`change:${e}`,r),o(this,re).call(this)}save_changes(){if(o(this,I).size===0)return;let e=Object.fromEntries(o(this,I).entries());o(this,I).clear(),o(this,H).sendUpdate(e)}on(e,r){o(this,R)[e]||(o(this,R)[e]=new Set),o(this,R)[e].add(r)}},te=new WeakMap,I=new WeakMap,L=new WeakMap,H=new WeakMap,R=new WeakMap,N=new WeakSet,pt=function(e,r){if(!o(this,R)[e])return;let s=o(this,R)[e];for(let a of s)try{a(r)}catch(i){p.error("Error emitting event",i)}},ft=function(e){e!=null&&Object.keys(e).forEach(r=>{let s=r;o(this,L)[s]!==e[s]&&this.set(s,e[s])})},ht=function(e,r=[]){let s=o(this,R)["msg:custom"];if(s)for(let a of s)try{a(e.content,r)}catch(i){p.error("Error emitting event",i)}},re=new WeakMap,n(j,"_modelManager",ne),j);Ke=async function(t,e){let r=e.model_id,s=e.message,a=("buffers"in s?s.buffers:[]).map(Ve);switch(s.method){case"open":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a}),v=t.getSync(r);if(v){oe(v).updateAndEmitDiffs(d);return}t.create(r,q=>new Ut(d,$e()?{sendUpdate:async()=>{},sendCustomMessage:async()=>{}}:{async sendUpdate(x){if(q.aborted){p.debug(`[Model] sendUpdate suppressed for model=${r} (signal aborted)`);return}let{state:S,buffers:O,bufferPaths:se}=Pt(x);await pe().sendModelValue({modelId:r,message:{method:"update",state:S,bufferPaths:se},buffers:O})},async sendCustomMessage(x,S){if(q.aborted){p.debug(`[Model] sendCustomMessage suppressed for model=${r} (signal aborted)`);return}await pe().sendModelValue({modelId:r,message:{method:"custom",content:x},buffers:S.map(ze)})}},q));return}case"custom":oe(await t.get(r)).emitCustomMessage({method:"custom",content:s.content},a);return;case"close":me.destroy(r),t.delete(r);return;case"update":{let{state:i,buffer_paths:u=[]}=s,d=Me({state:i,bufferPaths:u,buffers:a});oe(await t.get(r)).updateAndEmitDiffs(d);return}default:dr(s)}},zt(ne,"MODEL_MANAGER");function Tt(t){return typeof t!="object"||!t?!1:"type"in t&&t.type==="marimo-ui-value-update"}he=class mt{static get INSTANCE(){let e="_marimo_private_UIElementRegistry";return window[e]||(window[e]=new mt),window[e]}constructor(){this.entries=new Map}has(e){return this.entries.has(e)}set(e,r){this.entries.has(e)&&p.debug("UIElementRegistry overwriting entry for objectId.",e),this.entries.set(e,{objectId:e,value:r,elements:new Set})}registerInstance(e,r){let s=this.entries.get(e);s===void 0?this.entries.set(e,{objectId:e,value:Xt(r,this),elements:new Set([r])}):s.elements.add(r)}removeInstance(e,r){let s=this.entries.get(e);s!=null&&s.elements.has(r)&&s.elements.delete(r)}removeElementsByCell(e){[...this.entries.keys()].filter(r=>r.startsWith(`${e}-`)).forEach(r=>{this.entries.delete(r)})}lookupValue(e){let r=this.entries.get(e);return r===void 0?void 0:r.value}broadcastMessage(e,r,s){let a=this.entries.get(e);if(a===void 0){p.warn("UIElementRegistry missing entry",e);return}if(Tt(r)){a.value=r.value,a.elements.forEach(i=>{i.dispatchEvent(Ge.create({bubbles:!1,composed:!0,detail:{value:r.value,element:i}}))});return}a.elements.forEach(i=>{i.dispatchEvent(_r.create({bubbles:!1,composed:!0,detail:{objectId:e,message:r,buffers:s}}))})}broadcastValueUpdate(e,r,s){let a=this.entries.get(r);a===void 0?p.warn("UIElementRegistry missing entry",r):(a.value=s,a.elements.forEach(i=>{i!==e&&i.dispatchEvent(Ge.create({bubbles:!1,composed:!0,detail:{value:s,element:i}}))}),document.dispatchEvent(vr.create({bubbles:!0,composed:!0,detail:{objectId:r}})))}},nt=he.INSTANCE,tt=new fr("function-call-result",async(t,e)=>{await pe().sendFunctionRequest({functionCallId:t,...e})}),it="68px";var jt="288px";st=t=>t?/^\d+$/.test(t)?`${t}px`:t:jt,at=Gt({isOpen:!0},(t,e)=>{if(!e)return t;switch(e.type){case"toggle":return{...t,isOpen:e.isOpen??t.isOpen};case"setWidth":return{...t,width:e.width};default:return t}})});export{G as S,fe as _,Cr as __tla,he as a,Je as b,Ke as c,Xe as d,Ze as f,et as g,J as h,tt as i,me as l,rt as m,st as n,nt as o,ge as p,at as r,ne as s,it as t,ot as u,ye as v,lt as x,ut as y};
@@ -1 +1 @@
1
- import{s as ze}from"./chunk-LvLJmgfZ.js";import{d as $,l as ct,p as ht,u as me}from"./useEvent-D91BmmQi.js";import{t as mt}from"./react-Bj1aDYRI.js";import{E as Me,En as pt,Jt as ut,Rr as ft,Ti as pe,Tn as xt,_ as yt,cr as kt,ct as We,h as _e,kn as bt,ot as wt,pr as jt,st as gt,t as vt,ur as Ct,vr as zt,wn as Mt}from"./cells-EJo3u4za.js";import{t as N}from"./compiler-runtime-B3qBwwSJ.js";import{n as Wt,x as _t}from"./ai-model-dropdown-DWOGmhDj.js";import{_ as H,d as Ne}from"./useEventListener-DGjKht0c.js";import{y as Nt}from"./utils-8btzWeZg.js";import{n as L,t as Se}from"./constants-tOPFFcLZ.js";import{S as ue,h as St,n as Dt,o as Pt,x as At}from"./config-DoZCLcOb.js";import{n as It}from"./switch-C6xjg01T.js";import{t as Et}from"./jsx-runtime-Blw4afVn.js";import{o as Lt}from"./alert-dialog-CXspBRlP.js";import{a as Tt,c as fe,o as xe,s as Rt}from"./popover-AtoFZ7i4.js";import{a as $t,c as Ht,i as qt,n as Bt,r as Ot,s as Ut,t as Vt}from"./select--zcABebs.js";import{gt as Ft}from"./JsonOutput-9XtRRx5l.js";import{c as De,d as ye,n as Yt,o as Kt,r as ke,t as Gt}from"./download-TSo32ofd.js";import{m as Jt}from"./form-BiDLPu7R.js";import{t as Pe}from"./tooltip-DmqhBBs6.js";import{r as Ae,t as q}from"./button-BKVLeSTX.js";import{i as Zt,r as Qt,t as Ie}from"./strings-pfr2N700.js";import{r as B}from"./requests-9-v2bhoi.js";import{t as b}from"./createLucideIcon-w-Qo9n0R.js";import{a as Ee,f as Xt,i as Le,m as ea,p as Te,u as Re}from"./layout-CF-7BNtf.js";import{t as be}from"./check-B-sKate2.js";import{n as ta}from"./maps-B4xARV9R.js";import{r as aa}from"./useCellActionButton-DftkIqUl.js";import{t as $e}from"./copy-DFMsQ6MJ.js";import{t as oa}from"./eye-off-DgRJ-xBZ.js";import{t as ae}from"./file-l37OnSN4.js";import{t as na}from"./github-C3N4cuN4.js";import{n as sa,r as la,t as ia}from"./youtube-D6LtMx2w.js";import{i as ra,n as He}from"./add-connection-dialog-ux7eCDRM.js";import{n as da,t as ca}from"./square-COtNnHUC.js";import{t as ha}from"./image-BgkzrnsX.js";import{t as ma}from"./link-dU_vDDSR.js";import{r as pa}from"./input-Bg12i6qY.js";import{t as ua}from"./settings-C1bg8A2T.js";import{t as fa}from"./sparkles-B79Qf6ma.js";import{y as xa}from"./textarea-Cfp3upzK.js";import{t as S}from"./use-toast-BDYuj3zG.js";import{n as qe,t as ya}from"./paths-BzSgteR-.js";import{o as ka}from"./session-DdnWW30b.js";import{n as O}from"./copy-Bizk-4hH.js";import{r as ba}from"./useRunCells-d2edY6Tu.js";import{a as Be,c as Oe,i as Ue,n as Ve,r as Fe}from"./dialog-BYjetQgE.js";import{n as we}from"./ImperativeModal-DoGv2BXV.js";import{r as wa,t as ja}from"./share-0LPgOyiW.js";import{a as ga}from"./cell-link-CcAqXeeg.js";import{a as va}from"./renderShortcut-DrDh2657.js";import{t as Ca}from"./icons-DlzgV4KY.js";import{n as za}from"./marimo-icons-Dp8wmdDL.js";import{t as Ma}from"./links-C19POYUQ.js";import{r as Wa,t as Ye}from"./hooks-BgwM3Mb2.js";import{t as Ke}from"./types-DOdUT9LT.js";var _a=b("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Na=b("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ge=b("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"}]]),Je=b("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"}]]),Ze=b("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"}]]),Sa=b("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"}]]),Da=b("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"}]]),Pa=b("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Qe=b("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Aa=b("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"}]]),Ia=b("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"}]]),Ea=b("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Xe=b("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"}]]),La=b("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"}]]),Ta=b("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"}]]),et=b("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"}]]),je=N(),D=ze(mt(),1),a=ze(Et(),1);function Ra(){return"uvx marimo@latest"}function $a(t,e,n){let o=n?" --with-token":"",s=`${Ra()} pair prompt --url '${e}'${o}`;switch(t){case"claude":return`claude "$(${s} --claude)"`;case"codex":return`codex "$(${s} --codex)"`;case"opencode":return`opencode "$(${s} --opencode)"`;default:Qt(t)}}function Ha(t){return t.length<=4?"****":`${"*".repeat(Math.min(t.length-4,8))}${t.slice(-4)}`}var qa="npx skills add marimo-team/marimo-pair";function Ba(){let t=(0,je.c)(2),[e,n]=(0,D.useState)(null),o,s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{fetch(Dt("/auth/token").href,{headers:It.headers()}).then(Oa).then(r=>n((r==null?void 0:r.token)??null)).catch(()=>n(null))},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,D.useEffect)(o,s),e}function Oa(t){return t.ok?t.json():null}const Ua=t=>{let e=(0,je.c)(32),{onClose:n}=t,[o,s]=(0,D.useState)("claude"),r=Pt(),i=Ba(),l=!!i,d;e[0]!==o||e[1]!==l||e[2]!==r.httpURL?(d=$a(o,r.httpURL.toString(),l),e[0]=o,e[1]=l,e[2]=r.httpURL,e[3]=d):d=e[3];let c=d,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(Oe,{children:"Pair with an agent"}),e[4]=m):m=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)(Be,{children:[m,(0,a.jsxs)(Fe,{children:["Use an AI coding agent to pair-program on this notebook."," ",(0,a.jsx)("a",{href:"https://links.marimo.app/marimo-pair",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Learn more"}),"."]})]}),e[5]=p):p=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"1. Install the skill"}),(0,a.jsx)(U,{command:qa})]}),e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)("span",{className:"text-sm font-medium",children:"2. Run in your terminal"}),e[7]=u):u=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=_=>s(_),e[8]=x):x=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Rt,{className:"w-full",children:[(0,a.jsx)(fe,{value:"claude",className:"flex-1",children:"Claude"}),(0,a.jsx)(fe,{value:"codex",className:"flex-1",children:"Codex"}),(0,a.jsx)(fe,{value:"opencode",className:"flex-1",children:"OpenCode"})]}),e[9]=w):w=e[9];let y;e[10]===c?y=e[11]:(y=(0,a.jsx)(xe,{value:"claude",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[10]=c,e[11]=y);let k;e[12]===c?k=e[13]:(k=(0,a.jsx)(xe,{value:"codex",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[12]=c,e[13]=k);let j;e[14]===c?j=e[15]:(j=(0,a.jsx)(xe,{value:"opencode",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[14]=c,e[15]=j);let g;e[16]!==o||e[17]!==j||e[18]!==y||e[19]!==k?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[u,(0,a.jsxs)(Tt,{value:o,onValueChange:x,children:[w,y,k,j]})]}),e[16]=o,e[17]=j,e[18]=y,e[19]=k,e[20]=g):g=e[20];let z;e[21]!==i||e[22]!==l?(z=l&&i&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"3. Paste when prompted for token"}),(0,a.jsx)(U,{command:i,display:Ha(i)})]}),e[21]=i,e[22]=l,e[23]=z):z=e[23];let v;e[24]!==g||e[25]!==z?(v=(0,a.jsxs)("div",{className:"flex flex-col gap-4 py-2",children:[h,g,z]}),e[24]=g,e[25]=z,e[26]=v):v=e[26];let M;e[27]===n?M=e[28]:(M=(0,a.jsx)(Ue,{children:(0,a.jsx)(q,{variant:"secondary",onClick:n,children:"Close"})}),e[27]=n,e[28]=M);let W;return e[29]!==v||e[30]!==M?(W=(0,a.jsxs)(Ve,{className:"sm:max-w-lg",children:[p,v,M]}),e[29]=v,e[30]=M,e[31]=W):W=e[31],W};var U=t=>{let e=(0,je.c)(15),{command:n,display:o}=t,[s,r]=(0,D.useState)(!1),i;e[0]===n?i=e[1]:(i=Ae.stopPropagation(async x=>{x.preventDefault(),await O(n),r(!0),setTimeout(()=>r(!1),2e3)}),e[0]=n,e[1]=i);let l=i,d=o??n,c;e[2]===d?c=e[3]:(c=(0,a.jsx)("code",{className:"flex-1 select-all break-words",children:d}),e[2]=d,e[3]=c);let m;e[4]===s?m=e[5]:(m=s?(0,a.jsx)(be,{size:14,strokeWidth:1.5}):(0,a.jsx)($e,{size:14,strokeWidth:1.5}),e[4]=s,e[5]=m);let p;e[6]!==l||e[7]!==m?(p=(0,a.jsx)(q,{onClick:l,size:"xs",variant:"ghost",children:m}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let h;e[9]!==s||e[10]!==p?(h=(0,a.jsx)(Pe,{content:"Copied!",open:s,children:p}),e[9]=s,e[10]=p,e[11]=h):h=e[11];let u;return e[12]!==c||e[13]!==h?(u=(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-xs",children:[c,h]}),e[12]=c,e[13]=h,e[14]=u):u=e[14],u},tt=N(),oe="https://static.marimo.app";const Va=t=>{let e=(0,tt.c)(25),{onClose:n}=t,[o,s]=(0,D.useState)(""),{exportAsHTML:r}=B(),i=`${o}-${Math.random().toString(36).slice(2,6)}`,l=`${oe}/static/${i}`,d;e[0]!==r||e[1]!==n||e[2]!==i?(d=async g=>{g.preventDefault(),n();let z=await r({download:!1,includeCode:!0,files:Xt.INSTANCE.filenames()}),v=S({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${oe}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:z,path:i})}).catch(()=>{v.dismiss(),S({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:L.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),v.dismiss(),S({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."]})})},e[0]=r,e[1]=n,e[2]=i,e[3]=d):d=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Oe,{children:"Share static notebook"}),e[4]=c):c=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsxs)(Be,{children:[c,(0,a.jsxs)(Fe,{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}),"."]})]}),e[5]=m):m=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=g=>{s(g.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},e[6]=p):p=e[6];let h;e[7]===o?h=e[8]:(h=(0,a.jsx)(pa,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:p,required:!0,autoComplete:"off"}),e[7]=o,e[8]=h);let u;e[9]===l?u=e[10]:(u=(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)(Fa,{text:l}),(0,a.jsx)("span",{className:"text-primary",children:l})]})]}),e[9]=l,e[10]=u);let x;e[11]!==h||e[12]!==u?(x=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[h,u]}),e[11]=h,e[12]=u,e[13]=x):x=e[13];let w;e[14]===n?w=e[15]:(w=(0,a.jsx)(q,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=w);let y;e[16]===l?y=e[17]:(y=(0,a.jsx)(q,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await O(l)},children:"Create"}),e[16]=l,e[17]=y);let k;e[18]!==w||e[19]!==y?(k=(0,a.jsxs)(Ue,{children:[w,y]}),e[18]=w,e[19]=y,e[20]=k):k=e[20];let j;return e[21]!==d||e[22]!==k||e[23]!==x?(j=(0,a.jsx)(Ve,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[m,x,k]})}),e[21]=d,e[22]=k,e[23]=x,e[24]=j):j=e[24],j};var Fa=t=>{let e=(0,tt.c)(8),[n,o]=D.useState(!1),s;e[0]===t.text?s=e[1]:(s=Ae.stopPropagation(async c=>{c.preventDefault(),await O(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=s);let r=s,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)($e,{size:14,strokeWidth:1.5}),e[2]=i):i=e[2];let l;e[3]===r?l=e[4]:(l=(0,a.jsx)(q,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:i}),e[3]=r,e[4]=l);let d;return e[5]!==n||e[6]!==l?(d=(0,a.jsx)(Pe,{content:"Copied!",open:n,children:l}),e[5]=n,e[6]=l,e[7]=d):d=e[7],d},Ya=N();function Ka(){let t=document.getElementsByClassName(Se.outputArea);for(let e of t){let n=e.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=pe.findElement(e);if(!o){H.warn("Could not find HTMLCellId for visible output area",e);continue}return{cellId:pe.parse(o.id)}}}return H.warn("No visible output area found for scroll anchor"),null}function Ga(t){if(!t){H.warn("No scroll anchor provided to restore scroll position");return}let e=document.getElementById(pe.create(t.cellId));if(!e){H.warn("Could not find cell element to restore scroll position",t.cellId);return}if(!e.querySelector(`.${Se.outputArea}`)){H.warn("Could not find output area to restore scroll position",t.cellId);return}e.scrollIntoView({block:"start",behavior:"auto"})}function at(){let t=(0,Ya.c)(2),e=$(We),n;return t[0]===e?n=t[1]:(n=()=>{let o=Ka();e(s=>({mode:gt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ga(o)})})},t[0]=e,t[1]=n),n}const ot=ht(!1);var Ja=N();const Za=()=>{let t=(0,Ja.c)(7),{selectedLayout:e}=Ee(),{setLayoutView:n}=Le();if(ue()&&!bt("wasm_layouts"))return null;let o;t[0]===n?o=t[1]:(o=l=>n(l),t[0]=n,t[1]=o);let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Ut,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),t[2]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Bt,{children:(0,a.jsxs)(Ot,{children:[(0,a.jsx)($t,{children:"View as"}),Ke.map(Xa)]})}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==o?(i=(0,a.jsxs)(Vt,{"data-testid":"layout-select",value:e,onValueChange:o,children:[s,r]}),t[4]=e,t[5]=o,t[6]=i):i=t[6],i};function Qa(t){return(0,a.jsx)(nt(t),{className:"h-4 w-4"})}function nt(t){switch(t){case"vertical":return Aa;case"grid":return la;case"slides":return Xe;default:return Zt(t),ca}}function st(t){return Ie.startCase(t)}function Xa(t){return(0,a.jsx)(qt,{value:t,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Qa(t),(0,a.jsx)("span",{children:st(t)})]})},t)}async function eo(t){let{filename:e,preset:n,downloadPDF:o}=t;await o({filename:e,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var to=N();function ao(t){let e=(0,to.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:s}=B(),r;return e[0]!==o||e[1]!==n||e[2]!==s||e[3]!==t?(r=()=>{if(!t)return null;let i=ya.guessDeliminator(t);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(t)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:l=>{let d=i.join(qe.dirname(t),l);s({source:t,destination:d}).then(()=>{o(),S({title:"Notebook copied",description:"A copy of the notebook has been created."}),Ma(d)})}})},e[0]=o,e[1]=n,e[2]=s,e[3]=t,e[4]=r):r=e[4],r}const oo=()=>{let{updateCellConfig:t}=Me(),{saveCellConfig:e}=B();return(0,D.useCallback)(async()=>{let n=new ut,o=_e(),s=o.cellIds.inOrderIds,r={};for(let l of s){if(o.cellData[l]===void 0)continue;let{code:d,config:c}=o.cellData[l];c.hide_code||n.isSupported(d)&&(r[l]={hide_code:!0})}let i=Ne.entries(r);if(i.length!==0){await e({configs:r});for(let[l,d]of i)t({cellId:l,config:d})}},[t])};var no=N();function lt(){let t=(0,no.c)(4),{openConfirm:e}=we(),n=$(St),{sendRestart:o}=B(),s;return t[0]!==e||t[1]!==o||t[2]!==n?(s=()=>{e({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)(Lt,{onClick:async()=>{n({state:At.CLOSING}),await o(),wa()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=o,t[2]=n,t[3]=s):s=t[3],s}var so=N(),T=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};function lo(){var ve,Ce;let t=(0,so.c)(51),e=ga(),{openModal:n,closeModal:o}=we(),{toggleApplication:s}=Mt(),{selectedPanel:r}=xt(),[i]=ct(We),l=me(wt),d=oo(),[c]=Nt(),{updateCellConfig:m,undoDeleteCell:p,clearAllCellOutputs:h,addSetupCellIfDoesntExist:u,collapseAllCells:x,expandAllCells:w}=Me(),y=lt(),k=ba(),j=ao(e),g=$(ot),z=$(Wt),v=$(_t),{exportAsIPYNB:M,exportAsMarkdown:W,readCode:_,saveCellConfig:se,updateCellOutputs:P}=B(),A=Wa(),le=me(yt),ie=me(vt),{selectedLayout:V}=Ee(),{setLayoutView:re}=Le(),F=at(),Y=((ve=c.sharing)==null?void 0:ve.html)??!0,K=((Ce=c.sharing)==null?void 0:Ce.wasm)??!0,ge=!ue(),de=V==="slides",it=zo,rt=Co,G;t[0]!==e||t[1]!==A||t[2]!==P?(G=async f=>{let{preset:C,title:R}=f;if(!e){ne();return}await De(R,async he=>{await Ye({takeScreenshots:()=>A({progress:he}),updateCellOutputs:P}),await eo({filename:e,preset:C,downloadPDF:Yt})})},t[0]=e,t[1]=A,t[2]=P,t[3]=G):G=t[3];let I=G,J;t[4]===I?J=t[5]:(J=async()=>{if(ge){await I({preset:"document",title:"Downloading Document PDF..."});return}let f=new Event("export-beforeprint"),C=new Event("export-afterprint");window.dispatchEvent(f),setTimeout(vo,0),setTimeout(()=>window.dispatchEvent(C),0)},t[4]=I,t[5]=J);let Z=J,Q;t[6]!==M||t[7]!==e||t[8]!==A||t[9]!==P?(Q=async()=>{if(!e){ne();return}await De("Downloading IPYNB...",async f=>{await Ye({takeScreenshots:()=>A({progress:f}),updateCellOutputs:P});let C=await M({download:!1});ke(new Blob([C],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},t[6]=M,t[7]=e,t[8]=A,t[9]=P,t[10]=Q):Q=t[10];let ce=Q,X;t[11]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),t[11]=X):X=t[11];let ee;t[12]===Symbol.for("react.memo_cache_sentinel")?(ee=(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),t[12]=ee):ee=t[12];let E;t[13]===e?E=t[14]:(E=async()=>{if(!e){ne();return}await Re({filename:e,includeCode:!0})},t[13]=e,t[14]=E);let te;return t[15]!==u||t[16]!==ie||t[17]!==h||t[18]!==o||t[19]!==x||t[20]!==j||t[21]!==I||t[22]!==w||t[23]!==W||t[24]!==e||t[25]!==Z||t[26]!==ce||t[27]!==le||t[28]!==d||t[29]!==de||t[30]!==l||t[31]!==n||t[32]!==_||t[33]!==y||t[34]!==k||t[35]!==se||t[36]!==V||t[37]!==r||t[38]!==g||t[39]!==v||t[40]!==re||t[41]!==z||t[42]!==Y||t[43]!==K||t[44]!==E||t[45]!==s||t[46]!==F||t[47]!==p||t[48]!==m||t[49]!==i.mode?(te=[{icon:X,label:"Download",handle:T,dropdown:[{icon:ee,label:"Download as HTML",handle:E},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!e){ne();return}await Re({filename:e,includeCode:!1})}},{icon:(0,a.jsx)(Ca,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let f=await W({download:!1});ke(new Blob([f],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ce},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let f=await _();ke(new Blob([f.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:i.mode!=="present",tooltip:i.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",va("global.hideCode",!1)]}),handle:go},de?{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:T,dropdown:[{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Z},{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:rt(!0),hidden:!ge,handle:async()=>{await I({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Z}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",handle:async()=>{n((0,a.jsx)(Ua,{onClose:o}))}},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Share",handle:T,hidden:!Y&&!K,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!Y,handle:async()=>{n((0,a.jsx)(Va,{onClose:o}))}},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!K,handle:async()=>{await O(ja({code:(await _()).contents})),S({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ea,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:T,dropdown:pt.flatMap(f=>{let{type:C,Icon:R,hidden:he,additionalKeywords:dt}=f;return he?[]:{label:Ie.startCase(C),rightElement:it(r===C),icon:(0,a.jsx)(R,{size:14,strokeWidth:1.5}),handle:()=>s(C),additionalKeywords:dt}})},{icon:(0,a.jsx)(Xe,{size:14,strokeWidth:1.5}),label:"Present as",handle:T,dropdown:[{icon:i.mode==="present"?(0,a.jsx)(xa,{size:14,strokeWidth:1.5}):(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{F()}},...Ke.map((f,C)=>{let R=nt(f);return{divider:C===0,label:st(f),icon:(0,a.jsx)(R,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:V===f&&(0,a.jsx)(be,{size:14})}),handle:()=>{re(f),i.mode==="edit"&&F()}}})]},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!e||ue(),handle:j},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{await O((await _()).contents),S({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!le||l,handle:async()=>{let f=ft(_e());await se({configs:Ne.fromEntries(f.map(jo))});for(let C of f)m({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ze,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(He,{onClose:o}))}},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(He,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(et,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ie||l,handle:()=>{p()}},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:y,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{h()}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:x,redundant:!0},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:w,redundant:!0},{divider:!0,icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>g(wo)},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>v(bo)},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>z(ko),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Resources",handle:T,dropdown:[{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:yo},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"GitHub",handle:xo},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:fo},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"YouTube",handle:uo},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:po}]},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:mo},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:ho}].filter(co).map(io),t[15]=u,t[16]=ie,t[17]=h,t[18]=o,t[19]=x,t[20]=j,t[21]=I,t[22]=w,t[23]=W,t[24]=e,t[25]=Z,t[26]=ce,t[27]=le,t[28]=d,t[29]=de,t[30]=l,t[31]=n,t[32]=_,t[33]=y,t[34]=k,t[35]=se,t[36]=V,t[37]=r,t[38]=g,t[39]=v,t[40]=re,t[41]=z,t[42]=Y,t[43]=K,t[44]=E,t[45]=s,t[46]=F,t[47]=p,t[48]=m,t[49]=i.mode,t[50]=te):te=t[50],te}function io(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(ro)}:t}function ro(t){return!t.hidden}function co(t){return!t.hidden}function ho(){let t=ka();window.open(t,"_blank")}function mo(){let t=document.baseURI.split("?")[0];window.open(t,"_self")}function po(){window.open(L.releasesPage,"_blank")}function uo(){window.open(L.youtube,"_blank")}function fo(){window.open(L.discordLink,"_blank")}function xo(){window.open(L.githubPage,"_blank")}function yo(){window.open(L.docsPage,"_blank")}function ko(t){return!t}function bo(t){return!t}function wo(t){return!t}function jo(t){return[t,{disabled:!1}]}async function go(){let t=document.getElementById("App");t&&await Kt({element:t,filename:document.title,prepare:Gt})}function vo(){return window.print()}function Co(t){return t?(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 zo(t){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:t&&(0,a.jsx)(be,{size:14})})}function ne(){S({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{at as a,Ze as c,ot as i,Je as l,lt as n,et as o,Za as r,Qe as s,lo as t,Ge as u};
1
+ import{s as ze}from"./chunk-LvLJmgfZ.js";import{d as $,l as ct,p as ht,u as me}from"./useEvent-D91BmmQi.js";import{t as mt}from"./react-Bj1aDYRI.js";import{E as Me,En as pt,Jt as ut,Rr as ft,Ti as pe,Tn as xt,_ as yt,cr as kt,ct as We,h as _e,kn as bt,ot as wt,pr as jt,st as gt,t as vt,ur as Ct,vr as zt,wn as Mt}from"./cells-EJo3u4za.js";import{t as N}from"./compiler-runtime-B3qBwwSJ.js";import{n as Wt,x as _t}from"./ai-model-dropdown-DWOGmhDj.js";import{_ as H,d as Ne}from"./useEventListener-DGjKht0c.js";import{y as Nt}from"./utils-8btzWeZg.js";import{n as L,t as Se}from"./constants-tOPFFcLZ.js";import{S as ue,h as St,n as Dt,o as Pt,x as At}from"./config-DoZCLcOb.js";import{n as It}from"./switch-C6xjg01T.js";import{t as Et}from"./jsx-runtime-Blw4afVn.js";import{o as Lt}from"./alert-dialog-CXspBRlP.js";import{a as Tt,c as fe,o as xe,s as Rt}from"./popover-AtoFZ7i4.js";import{a as $t,c as Ht,i as qt,n as Bt,r as Ot,s as Ut,t as Vt}from"./select--zcABebs.js";import{gt as Ft}from"./JsonOutput-D_ORGqdz.js";import{c as De,d as ye,n as Yt,o as Kt,r as ke,t as Gt}from"./download-TSo32ofd.js";import{m as Jt}from"./form-30oC5z9y.js";import{t as Pe}from"./tooltip-DmqhBBs6.js";import{r as Ae,t as q}from"./button-BKVLeSTX.js";import{i as Zt,r as Qt,t as Ie}from"./strings-pfr2N700.js";import{r as B}from"./requests-9-v2bhoi.js";import{t as b}from"./createLucideIcon-w-Qo9n0R.js";import{a as Ee,f as Xt,i as Le,m as ea,p as Te,u as Re}from"./layout-cq-nxDfO.js";import{t as be}from"./check-B-sKate2.js";import{n as ta}from"./maps-B4xARV9R.js";import{r as aa}from"./useCellActionButton-DftkIqUl.js";import{t as $e}from"./copy-DFMsQ6MJ.js";import{t as oa}from"./eye-off-DgRJ-xBZ.js";import{t as ae}from"./file-l37OnSN4.js";import{t as na}from"./github-C3N4cuN4.js";import{n as sa,r as la,t as ia}from"./youtube-D6LtMx2w.js";import{i as ra,n as He}from"./add-connection-dialog-DGgtN73u.js";import{n as da,t as ca}from"./square-COtNnHUC.js";import{t as ha}from"./image-BgkzrnsX.js";import{t as ma}from"./link-dU_vDDSR.js";import{r as pa}from"./input-Bg12i6qY.js";import{t as ua}from"./settings-C1bg8A2T.js";import{t as fa}from"./sparkles-B79Qf6ma.js";import{y as xa}from"./textarea-Cfp3upzK.js";import{t as S}from"./use-toast-BDYuj3zG.js";import{n as qe,t as ya}from"./paths-BzSgteR-.js";import{o as ka}from"./session-DdnWW30b.js";import{n as O}from"./copy-Bizk-4hH.js";import{r as ba}from"./useRunCells-d2edY6Tu.js";import{a as Be,c as Oe,i as Ue,n as Ve,r as Fe}from"./dialog-BYjetQgE.js";import{n as we}from"./ImperativeModal-DoGv2BXV.js";import{r as wa,t as ja}from"./share-0LPgOyiW.js";import{a as ga}from"./cell-link-CcAqXeeg.js";import{a as va}from"./renderShortcut-DrDh2657.js";import{t as Ca}from"./icons-DlzgV4KY.js";import{n as za}from"./marimo-icons-Dp8wmdDL.js";import{t as Ma}from"./links-C19POYUQ.js";import{r as Wa,t as Ye}from"./hooks-DLUrd-jH.js";import{t as Ke}from"./types-DOdUT9LT.js";var _a=b("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Na=b("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),Ge=b("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"}]]),Je=b("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"}]]),Ze=b("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"}]]),Sa=b("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"}]]),Da=b("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"}]]),Pa=b("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Qe=b("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Aa=b("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"}]]),Ia=b("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"}]]),Ea=b("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Xe=b("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"}]]),La=b("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"}]]),Ta=b("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"}]]),et=b("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"}]]),je=N(),D=ze(mt(),1),a=ze(Et(),1);function Ra(){return"uvx marimo@latest"}function $a(t,e,n){let o=n?" --with-token":"",s=`${Ra()} pair prompt --url '${e}'${o}`;switch(t){case"claude":return`claude "$(${s} --claude)"`;case"codex":return`codex "$(${s} --codex)"`;case"opencode":return`opencode "$(${s} --opencode)"`;default:Qt(t)}}function Ha(t){return t.length<=4?"****":`${"*".repeat(Math.min(t.length-4,8))}${t.slice(-4)}`}var qa="npx skills add marimo-team/marimo-pair";function Ba(){let t=(0,je.c)(2),[e,n]=(0,D.useState)(null),o,s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{fetch(Dt("/auth/token").href,{headers:It.headers()}).then(Oa).then(r=>n((r==null?void 0:r.token)??null)).catch(()=>n(null))},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,D.useEffect)(o,s),e}function Oa(t){return t.ok?t.json():null}const Ua=t=>{let e=(0,je.c)(32),{onClose:n}=t,[o,s]=(0,D.useState)("claude"),r=Pt(),i=Ba(),l=!!i,d;e[0]!==o||e[1]!==l||e[2]!==r.httpURL?(d=$a(o,r.httpURL.toString(),l),e[0]=o,e[1]=l,e[2]=r.httpURL,e[3]=d):d=e[3];let c=d,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(Oe,{children:"Pair with an agent"}),e[4]=m):m=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)(Be,{children:[m,(0,a.jsxs)(Fe,{children:["Use an AI coding agent to pair-program on this notebook."," ",(0,a.jsx)("a",{href:"https://links.marimo.app/marimo-pair",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"Learn more"}),"."]})]}),e[5]=p):p=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"1. Install the skill"}),(0,a.jsx)(U,{command:qa})]}),e[6]=h):h=e[6];let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)("span",{className:"text-sm font-medium",children:"2. Run in your terminal"}),e[7]=u):u=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=_=>s(_),e[8]=x):x=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=(0,a.jsxs)(Rt,{className:"w-full",children:[(0,a.jsx)(fe,{value:"claude",className:"flex-1",children:"Claude"}),(0,a.jsx)(fe,{value:"codex",className:"flex-1",children:"Codex"}),(0,a.jsx)(fe,{value:"opencode",className:"flex-1",children:"OpenCode"})]}),e[9]=w):w=e[9];let y;e[10]===c?y=e[11]:(y=(0,a.jsx)(xe,{value:"claude",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[10]=c,e[11]=y);let k;e[12]===c?k=e[13]:(k=(0,a.jsx)(xe,{value:"codex",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[12]=c,e[13]=k);let j;e[14]===c?j=e[15]:(j=(0,a.jsx)(xe,{value:"opencode",className:"mt-3",children:(0,a.jsx)(U,{command:c})}),e[14]=c,e[15]=j);let g;e[16]!==o||e[17]!==j||e[18]!==y||e[19]!==k?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[u,(0,a.jsxs)(Tt,{value:o,onValueChange:x,children:[w,y,k,j]})]}),e[16]=o,e[17]=j,e[18]=y,e[19]=k,e[20]=g):g=e[20];let z;e[21]!==i||e[22]!==l?(z=l&&i&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"3. Paste when prompted for token"}),(0,a.jsx)(U,{command:i,display:Ha(i)})]}),e[21]=i,e[22]=l,e[23]=z):z=e[23];let v;e[24]!==g||e[25]!==z?(v=(0,a.jsxs)("div",{className:"flex flex-col gap-4 py-2",children:[h,g,z]}),e[24]=g,e[25]=z,e[26]=v):v=e[26];let M;e[27]===n?M=e[28]:(M=(0,a.jsx)(Ue,{children:(0,a.jsx)(q,{variant:"secondary",onClick:n,children:"Close"})}),e[27]=n,e[28]=M);let W;return e[29]!==v||e[30]!==M?(W=(0,a.jsxs)(Ve,{className:"sm:max-w-lg",children:[p,v,M]}),e[29]=v,e[30]=M,e[31]=W):W=e[31],W};var U=t=>{let e=(0,je.c)(15),{command:n,display:o}=t,[s,r]=(0,D.useState)(!1),i;e[0]===n?i=e[1]:(i=Ae.stopPropagation(async x=>{x.preventDefault(),await O(n),r(!0),setTimeout(()=>r(!1),2e3)}),e[0]=n,e[1]=i);let l=i,d=o??n,c;e[2]===d?c=e[3]:(c=(0,a.jsx)("code",{className:"flex-1 select-all break-words",children:d}),e[2]=d,e[3]=c);let m;e[4]===s?m=e[5]:(m=s?(0,a.jsx)(be,{size:14,strokeWidth:1.5}):(0,a.jsx)($e,{size:14,strokeWidth:1.5}),e[4]=s,e[5]=m);let p;e[6]!==l||e[7]!==m?(p=(0,a.jsx)(q,{onClick:l,size:"xs",variant:"ghost",children:m}),e[6]=l,e[7]=m,e[8]=p):p=e[8];let h;e[9]!==s||e[10]!==p?(h=(0,a.jsx)(Pe,{content:"Copied!",open:s,children:p}),e[9]=s,e[10]=p,e[11]=h):h=e[11];let u;return e[12]!==c||e[13]!==h?(u=(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted px-3 py-2 font-mono text-xs",children:[c,h]}),e[12]=c,e[13]=h,e[14]=u):u=e[14],u},tt=N(),oe="https://static.marimo.app";const Va=t=>{let e=(0,tt.c)(25),{onClose:n}=t,[o,s]=(0,D.useState)(""),{exportAsHTML:r}=B(),i=`${o}-${Math.random().toString(36).slice(2,6)}`,l=`${oe}/static/${i}`,d;e[0]!==r||e[1]!==n||e[2]!==i?(d=async g=>{g.preventDefault(),n();let z=await r({download:!1,includeCode:!0,files:Xt.INSTANCE.filenames()}),v=S({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${oe}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:z,path:i})}).catch(()=>{v.dismiss(),S({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:L.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),v.dismiss(),S({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."]})})},e[0]=r,e[1]=n,e[2]=i,e[3]=d):d=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Oe,{children:"Share static notebook"}),e[4]=c):c=e[4];let m;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsxs)(Be,{children:[c,(0,a.jsxs)(Fe,{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}),"."]})]}),e[5]=m):m=e[5];let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=g=>{s(g.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},e[6]=p):p=e[6];let h;e[7]===o?h=e[8]:(h=(0,a.jsx)(pa,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:p,required:!0,autoComplete:"off"}),e[7]=o,e[8]=h);let u;e[9]===l?u=e[10]:(u=(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)(Fa,{text:l}),(0,a.jsx)("span",{className:"text-primary",children:l})]})]}),e[9]=l,e[10]=u);let x;e[11]!==h||e[12]!==u?(x=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[h,u]}),e[11]=h,e[12]=u,e[13]=x):x=e[13];let w;e[14]===n?w=e[15]:(w=(0,a.jsx)(q,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=w);let y;e[16]===l?y=e[17]:(y=(0,a.jsx)(q,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await O(l)},children:"Create"}),e[16]=l,e[17]=y);let k;e[18]!==w||e[19]!==y?(k=(0,a.jsxs)(Ue,{children:[w,y]}),e[18]=w,e[19]=y,e[20]=k):k=e[20];let j;return e[21]!==d||e[22]!==k||e[23]!==x?(j=(0,a.jsx)(Ve,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[m,x,k]})}),e[21]=d,e[22]=k,e[23]=x,e[24]=j):j=e[24],j};var Fa=t=>{let e=(0,tt.c)(8),[n,o]=D.useState(!1),s;e[0]===t.text?s=e[1]:(s=Ae.stopPropagation(async c=>{c.preventDefault(),await O(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=s);let r=s,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)($e,{size:14,strokeWidth:1.5}),e[2]=i):i=e[2];let l;e[3]===r?l=e[4]:(l=(0,a.jsx)(q,{"data-testid":"copy-static-notebook-url-button",onClick:r,size:"xs",variant:"secondary",children:i}),e[3]=r,e[4]=l);let d;return e[5]!==n||e[6]!==l?(d=(0,a.jsx)(Pe,{content:"Copied!",open:n,children:l}),e[5]=n,e[6]=l,e[7]=d):d=e[7],d},Ya=N();function Ka(){let t=document.getElementsByClassName(Se.outputArea);for(let e of t){let n=e.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=pe.findElement(e);if(!o){H.warn("Could not find HTMLCellId for visible output area",e);continue}return{cellId:pe.parse(o.id)}}}return H.warn("No visible output area found for scroll anchor"),null}function Ga(t){if(!t){H.warn("No scroll anchor provided to restore scroll position");return}let e=document.getElementById(pe.create(t.cellId));if(!e){H.warn("Could not find cell element to restore scroll position",t.cellId);return}if(!e.querySelector(`.${Se.outputArea}`)){H.warn("Could not find output area to restore scroll position",t.cellId);return}e.scrollIntoView({block:"start",behavior:"auto"})}function at(){let t=(0,Ya.c)(2),e=$(We),n;return t[0]===e?n=t[1]:(n=()=>{let o=Ka();e(s=>({mode:gt(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{Ga(o)})})},t[0]=e,t[1]=n),n}const ot=ht(!1);var Ja=N();const Za=()=>{let t=(0,Ja.c)(7),{selectedLayout:e}=Ee(),{setLayoutView:n}=Le();if(ue()&&!bt("wasm_layouts"))return null;let o;t[0]===n?o=t[1]:(o=l=>n(l),t[0]=n,t[1]=o);let s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(Ut,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(Ht,{placeholder:"Select a view"})}),t[2]=s):s=t[2];let r;t[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Bt,{children:(0,a.jsxs)(Ot,{children:[(0,a.jsx)($t,{children:"View as"}),Ke.map(Xa)]})}),t[3]=r):r=t[3];let i;return t[4]!==e||t[5]!==o?(i=(0,a.jsxs)(Vt,{"data-testid":"layout-select",value:e,onValueChange:o,children:[s,r]}),t[4]=e,t[5]=o,t[6]=i):i=t[6],i};function Qa(t){return(0,a.jsx)(nt(t),{className:"h-4 w-4"})}function nt(t){switch(t){case"vertical":return Aa;case"grid":return la;case"slides":return Xe;default:return Zt(t),ca}}function st(t){return Ie.startCase(t)}function Xa(t){return(0,a.jsx)(qt,{value:t,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Qa(t),(0,a.jsx)("span",{children:st(t)})]})},t)}async function eo(t){let{filename:e,preset:n,downloadPDF:o}=t;await o({filename:e,webpdf:!1,preset:n,includeInputs:!0,rasterServer:"static"})}var to=N();function ao(t){let e=(0,to.c)(5),{openPrompt:n,closeModal:o}=we(),{sendCopy:s}=B(),r;return e[0]!==o||e[1]!==n||e[2]!==s||e[3]!==t?(r=()=>{if(!t)return null;let i=ya.guessDeliminator(t);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${qe.basename(t)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:l=>{let d=i.join(qe.dirname(t),l);s({source:t,destination:d}).then(()=>{o(),S({title:"Notebook copied",description:"A copy of the notebook has been created."}),Ma(d)})}})},e[0]=o,e[1]=n,e[2]=s,e[3]=t,e[4]=r):r=e[4],r}const oo=()=>{let{updateCellConfig:t}=Me(),{saveCellConfig:e}=B();return(0,D.useCallback)(async()=>{let n=new ut,o=_e(),s=o.cellIds.inOrderIds,r={};for(let l of s){if(o.cellData[l]===void 0)continue;let{code:d,config:c}=o.cellData[l];c.hide_code||n.isSupported(d)&&(r[l]={hide_code:!0})}let i=Ne.entries(r);if(i.length!==0){await e({configs:r});for(let[l,d]of i)t({cellId:l,config:d})}},[t])};var no=N();function lt(){let t=(0,no.c)(4),{openConfirm:e}=we(),n=$(St),{sendRestart:o}=B(),s;return t[0]!==e||t[1]!==o||t[2]!==n?(s=()=>{e({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)(Lt,{onClick:async()=>{n({state:At.CLOSING}),await o(),wa()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=o,t[2]=n,t[3]=s):s=t[3],s}var so=N(),T=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};function lo(){var ve,Ce;let t=(0,so.c)(51),e=ga(),{openModal:n,closeModal:o}=we(),{toggleApplication:s}=Mt(),{selectedPanel:r}=xt(),[i]=ct(We),l=me(wt),d=oo(),[c]=Nt(),{updateCellConfig:m,undoDeleteCell:p,clearAllCellOutputs:h,addSetupCellIfDoesntExist:u,collapseAllCells:x,expandAllCells:w}=Me(),y=lt(),k=ba(),j=ao(e),g=$(ot),z=$(Wt),v=$(_t),{exportAsIPYNB:M,exportAsMarkdown:W,readCode:_,saveCellConfig:se,updateCellOutputs:P}=B(),A=Wa(),le=me(yt),ie=me(vt),{selectedLayout:V}=Ee(),{setLayoutView:re}=Le(),F=at(),Y=((ve=c.sharing)==null?void 0:ve.html)??!0,K=((Ce=c.sharing)==null?void 0:Ce.wasm)??!0,ge=!ue(),de=V==="slides",it=zo,rt=Co,G;t[0]!==e||t[1]!==A||t[2]!==P?(G=async f=>{let{preset:C,title:R}=f;if(!e){ne();return}await De(R,async he=>{await Ye({takeScreenshots:()=>A({progress:he}),updateCellOutputs:P}),await eo({filename:e,preset:C,downloadPDF:Yt})})},t[0]=e,t[1]=A,t[2]=P,t[3]=G):G=t[3];let I=G,J;t[4]===I?J=t[5]:(J=async()=>{if(ge){await I({preset:"document",title:"Downloading Document PDF..."});return}let f=new Event("export-beforeprint"),C=new Event("export-afterprint");window.dispatchEvent(f),setTimeout(vo,0),setTimeout(()=>window.dispatchEvent(C),0)},t[4]=I,t[5]=J);let Z=J,Q;t[6]!==M||t[7]!==e||t[8]!==A||t[9]!==P?(Q=async()=>{if(!e){ne();return}await De("Downloading IPYNB...",async f=>{await Ye({takeScreenshots:()=>A({progress:f}),updateCellOutputs:P});let C=await M({download:!1});ke(new Blob([C],{type:"application/x-ipynb+json"}),ye.toIPYNB(document.title))})},t[6]=M,t[7]=e,t[8]=A,t[9]=P,t[10]=Q):Q=t[10];let ce=Q,X;t[11]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(Ft,{size:14,strokeWidth:1.5}),t[11]=X):X=t[11];let ee;t[12]===Symbol.for("react.memo_cache_sentinel")?(ee=(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),t[12]=ee):ee=t[12];let E;t[13]===e?E=t[14]:(E=async()=>{if(!e){ne();return}await Re({filename:e,includeCode:!0})},t[13]=e,t[14]=E);let te;return t[15]!==u||t[16]!==ie||t[17]!==h||t[18]!==o||t[19]!==x||t[20]!==j||t[21]!==I||t[22]!==w||t[23]!==W||t[24]!==e||t[25]!==Z||t[26]!==ce||t[27]!==le||t[28]!==d||t[29]!==de||t[30]!==l||t[31]!==n||t[32]!==_||t[33]!==y||t[34]!==k||t[35]!==se||t[36]!==V||t[37]!==r||t[38]!==g||t[39]!==v||t[40]!==re||t[41]!==z||t[42]!==Y||t[43]!==K||t[44]!==E||t[45]!==s||t[46]!==F||t[47]!==p||t[48]!==m||t[49]!==i.mode?(te=[{icon:X,label:"Download",handle:T,dropdown:[{icon:ee,label:"Download as HTML",handle:E},{icon:(0,a.jsx)(Te,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!e){ne();return}await Re({filename:e,includeCode:!1})}},{icon:(0,a.jsx)(Ca,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let f=await W({download:!1});ke(new Blob([f],{type:"text/plain"}),ye.toMarkdown(document.title))}},{icon:(0,a.jsx)(Ia,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:ce},{icon:(0,a.jsx)(ea,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let f=await _();ke(new Blob([f.contents],{type:"text/plain"}),ye.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(ha,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:i.mode!=="present",tooltip:i.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",va("global.hideCode",!1)]}),handle:go},de?{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:T,dropdown:[{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:Z},{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:rt(!0),hidden:!ge,handle:async()=>{await I({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:Z}]},{icon:(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),label:"Pair with an agent",handle:async()=>{n((0,a.jsx)(Ua,{onClose:o}))}},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Share",handle:T,hidden:!Y&&!K,dropdown:[{icon:(0,a.jsx)(Jt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!Y,handle:async()=>{n((0,a.jsx)(Va,{onClose:o}))}},{icon:(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!K,handle:async()=>{await O(ja({code:(await _()).contents})),S({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:(0,a.jsx)(Ea,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:T,dropdown:pt.flatMap(f=>{let{type:C,Icon:R,hidden:he,additionalKeywords:dt}=f;return he?[]:{label:Ie.startCase(C),rightElement:it(r===C),icon:(0,a.jsx)(R,{size:14,strokeWidth:1.5}),handle:()=>s(C),additionalKeywords:dt}})},{icon:(0,a.jsx)(Xe,{size:14,strokeWidth:1.5}),label:"Present as",handle:T,dropdown:[{icon:i.mode==="present"?(0,a.jsx)(xa,{size:14,strokeWidth:1.5}):(0,a.jsx)(Qe,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{F()}},...Ke.map((f,C)=>{let R=nt(f);return{divider:C===0,label:st(f),icon:(0,a.jsx)(R,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:V===f&&(0,a.jsx)(be,{size:14})}),handle:()=>{re(f),i.mode==="edit"&&F()}}})]},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!e||ue(),handle:j},{icon:(0,a.jsx)(Ge,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{await O((await _()).contents),S({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(aa,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!le||l,handle:async()=>{let f=ft(_e());await se({configs:Ne.fromEntries(f.map(jo))});for(let C of f)m({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(Ze,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{u({})}},{icon:(0,a.jsx)(Ct,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(He,{onClose:o}))}},{icon:(0,a.jsx)(ra,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(He,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(et,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!ie||l,handle:()=>{p()}},{icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:y,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{k()}},{icon:(0,a.jsx)(jt,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{h()}},{icon:(0,a.jsx)(oa,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:d,redundant:!0},{icon:(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:x,redundant:!0},{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:w,redundant:!0},{divider:!0,icon:(0,a.jsx)(Je,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>g(wo)},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>v(bo)},{icon:(0,a.jsx)(ua,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>z(ko),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ta,{size:14,strokeWidth:1.5}),label:"Resources",handle:T,dropdown:[{icon:(0,a.jsx)(zt,{size:14,strokeWidth:1.5}),label:"Documentation",handle:yo},{icon:(0,a.jsx)(na,{size:14,strokeWidth:1.5}),label:"GitHub",handle:xo},{icon:(0,a.jsx)(sa,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:fo},{icon:(0,a.jsx)(ia,{size:14,strokeWidth:1.5}),label:"YouTube",handle:uo},{icon:(0,a.jsx)(kt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:po}]},{divider:!0,icon:(0,a.jsx)(da,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:mo},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:ho}].filter(co).map(io),t[15]=u,t[16]=ie,t[17]=h,t[18]=o,t[19]=x,t[20]=j,t[21]=I,t[22]=w,t[23]=W,t[24]=e,t[25]=Z,t[26]=ce,t[27]=le,t[28]=d,t[29]=de,t[30]=l,t[31]=n,t[32]=_,t[33]=y,t[34]=k,t[35]=se,t[36]=V,t[37]=r,t[38]=g,t[39]=v,t[40]=re,t[41]=z,t[42]=Y,t[43]=K,t[44]=E,t[45]=s,t[46]=F,t[47]=p,t[48]=m,t[49]=i.mode,t[50]=te):te=t[50],te}function io(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(ro)}:t}function ro(t){return!t.hidden}function co(t){return!t.hidden}function ho(){let t=ka();window.open(t,"_blank")}function mo(){let t=document.baseURI.split("?")[0];window.open(t,"_self")}function po(){window.open(L.releasesPage,"_blank")}function uo(){window.open(L.youtube,"_blank")}function fo(){window.open(L.discordLink,"_blank")}function xo(){window.open(L.githubPage,"_blank")}function yo(){window.open(L.docsPage,"_blank")}function ko(t){return!t}function bo(t){return!t}function wo(t){return!t}function jo(t){return[t,{disabled:!1}]}async function go(){let t=document.getElementById("App");t&&await Kt({element:t,filename:document.title,prepare:Gt})}function vo(){return window.print()}function Co(t){return t?(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 zo(t){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:t&&(0,a.jsx)(be,{size:14})})}function ne(){S({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{at as a,Ze as c,ot as i,Je as l,lt as n,et as o,Za as r,Qe as s,lo as t,Ge 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-DXwhLiKr.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-DTBKKey_.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-D2MJg03u.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
@@ -193,14 +193,14 @@
193
193
  <link rel="modulepreload" crossorigin href="./assets/ellipsis-DidENKDy.js">
194
194
  <link rel="modulepreload" crossorigin href="./assets/message-circle-DiHwtSG8.js">
195
195
  <link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-BUNcfKXO.js">
196
- <link rel="modulepreload" crossorigin href="./assets/JsonOutput-9XtRRx5l.js">
196
+ <link rel="modulepreload" crossorigin href="./assets/JsonOutput-D_ORGqdz.js">
197
197
  <link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-CsXoiEZx.js">
198
198
  <link rel="modulepreload" crossorigin href="./assets/square-function-BecUoMho.js">
199
199
  <link rel="modulepreload" crossorigin href="./assets/spec-DqqZbNbU.js">
200
200
  <link rel="modulepreload" crossorigin href="./assets/ellipsis-vertical-DEH0lwkn.js">
201
201
  <link rel="modulepreload" crossorigin href="./assets/refresh-cw-CiOe0azG.js">
202
202
  <link rel="modulepreload" crossorigin href="./assets/components-B8TZ_vT_.js">
203
- <link rel="modulepreload" crossorigin href="./assets/column-preview-DrU255Z3.js">
203
+ <link rel="modulepreload" crossorigin href="./assets/column-preview-DQBtRWJG.js">
204
204
  <link rel="modulepreload" crossorigin href="./assets/icons-DlzgV4KY.js">
205
205
  <link rel="modulepreload" crossorigin href="./assets/floating-outline-BTmyhMGv.js">
206
206
  <link rel="modulepreload" crossorigin href="./assets/useAddCell-BaTlDxTu.js">
@@ -221,12 +221,12 @@
221
221
  <link rel="modulepreload" crossorigin href="./assets/memoize-BwAF2XN5.js">
222
222
  <link rel="modulepreload" crossorigin href="./assets/get-D7jeR2wg.js">
223
223
  <link rel="modulepreload" crossorigin href="./assets/_baseSet-49dbm-yb.js">
224
- <link rel="modulepreload" crossorigin href="./assets/state-6D_2UAw3.js">
224
+ <link rel="modulepreload" crossorigin href="./assets/state-CMxx6hcP.js">
225
225
  <link rel="modulepreload" crossorigin href="./assets/label-C89F4v17.js">
226
226
  <link rel="modulepreload" crossorigin href="./assets/textarea-Cfp3upzK.js">
227
227
  <link rel="modulepreload" crossorigin href="./assets/refresh-ccw-CfYqAbmq.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/trash-2-DunI72kV.js">
229
- <link rel="modulepreload" crossorigin href="./assets/form-BiDLPu7R.js">
229
+ <link rel="modulepreload" crossorigin href="./assets/form-30oC5z9y.js">
230
230
  <link rel="modulepreload" crossorigin href="./assets/renderShortcut-DrDh2657.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/field-DTzXkFLZ.js">
232
232
  <link rel="modulepreload" crossorigin href="./assets/RSPContexts-LWFBF00h.js">
@@ -246,7 +246,7 @@
246
246
  <link rel="stylesheet" crossorigin href="./assets/cells-jmgGt1lS.css">
247
247
  <link rel="stylesheet" crossorigin href="./assets/markdown-renderer-DdDKmWlR.css">
248
248
  <link rel="stylesheet" crossorigin href="./assets/JsonOutput-B7vuddcd.css">
249
- <link rel="stylesheet" crossorigin href="./assets/index-Dbq6ugUC.css">
249
+ <link rel="stylesheet" crossorigin href="./assets/index-qO0a4zuT.css">
250
250
  </head>
251
251
  <body>
252
252
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.22.6-dev9",
3
+ "version": "0.23.1-dev1",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -127,7 +127,7 @@ export const TableTopBar: React.FC<TableTopBarProps> = ({
127
127
  onClick={() => togglePanel(PANEL_TYPES.ROW_VIEWER)}
128
128
  >
129
129
  <PanelRightIcon className="w-3.5 h-3.5" />
130
- Explorer
130
+ Explore
131
131
  </Button>
132
132
  )}
133
133
  {downloadAs && <ExportMenu downloadAs={downloadAs} />}
@@ -139,7 +139,7 @@ export const TableExplorerPanel: React.FC<TableExplorerPanelProps> = ({
139
139
  : inactiveClassName,
140
140
  )}
141
141
  >
142
- Explorer
142
+ Columns
143
143
  </Button>
144
144
  </div>
145
145
  </Fill>
package/src/css/table.css CHANGED
@@ -17,6 +17,10 @@
17
17
  padding-right: var(--marimo-table-edge-padding, 0.375rem);
18
18
  }
19
19
 
20
+ [part="label"] {
21
+ padding-left: var(--marimo-table-edge-padding, 0);
22
+ }
23
+
20
24
  .markdown table,
21
25
  table.dataframe {
22
26
  display: block;
@@ -44,9 +44,11 @@ export const Labeled: React.FC<PropsWithChildren<Props>> = ({
44
44
  }
45
45
 
46
46
  const labelElement = (
47
- <Label htmlFor={id} className={cn("font-prose", labelClassName)}>
48
- {renderHTML({ html: label })}
49
- </Label>
47
+ <div part="label" className="m-0 p-0">
48
+ <Label htmlFor={id} className={cn("font-prose", labelClassName)}>
49
+ {renderHTML({ html: label })}
50
+ </Label>
51
+ </div>
50
52
  );
51
53
 
52
54
  return (
@@ -19,6 +19,7 @@ import {
19
19
  extractPoints,
20
20
  extractSunburstPoints,
21
21
  extractTreemapPoints,
22
+ hasAreaTrace,
22
23
  hasPureLineTrace,
23
24
  lineSelectionButtons,
24
25
  type ModeBarButton,
@@ -113,7 +114,8 @@ export const PlotlyComponent = memo(
113
114
 
114
115
  const configMemo = useDeepCompareMemoize(config);
115
116
  const plotlyConfig = useMemo((): Partial<Plotly.Config> => {
116
- const hasPureLine = hasPureLineTrace(figure.data);
117
+ const hasLineOrAreaTrace =
118
+ hasPureLineTrace(figure.data) || hasAreaTrace(figure.data);
117
119
  const defaultButtons: ModeBarButton[] = [
118
120
  // Custom button to reset the state
119
121
  {
@@ -130,7 +132,7 @@ export const PlotlyComponent = memo(
130
132
  click: handleResetWithClear,
131
133
  },
132
134
  ];
133
- if (hasPureLine) {
135
+ if (hasLineOrAreaTrace) {
134
136
  defaultButtons.push(...lineSelectionButtons(handleSetDragmode));
135
137
  }
136
138
 
@@ -111,4 +111,54 @@ describe("PlotlyPlugin", () => {
111
111
  range: undefined,
112
112
  });
113
113
  });
114
+
115
+ it("clicking a violin element triggers onClick", async () => {
116
+ const setValue = vi.fn<Setter<unknown>>();
117
+
118
+ render(
119
+ <Suspense fallback={null}>
120
+ <PlotlyComponent
121
+ figure={{
122
+ data: [{ type: "violin" }],
123
+ layout: {},
124
+ frames: null,
125
+ }}
126
+ value={undefined}
127
+ setValue={setValue}
128
+ host={document.createElement("div")}
129
+ config={{}}
130
+ />
131
+ </Suspense>,
132
+ );
133
+
134
+ await waitFor(() => {
135
+ expect(capturedPlotProps).not.toBeNull();
136
+ });
137
+
138
+ act(() => {
139
+ capturedPlotProps?.onClick?.({
140
+ points: [
141
+ {
142
+ data: { type: "violin" },
143
+ x: "Group A",
144
+ y: 3,
145
+ pointIndex: 0,
146
+ pointNumber: 0,
147
+ curveNumber: 0,
148
+ },
149
+ ],
150
+ });
151
+ });
152
+
153
+ expect(setValue).toHaveBeenCalledTimes(1);
154
+ const updater = setValue.mock.calls[0][0] as (value: unknown) => unknown;
155
+ expect(updater({})).toEqual({
156
+ selections: [],
157
+ points: [
158
+ { x: "Group A", y: 3, curveNumber: 0, pointNumber: 0, pointIndex: 0 },
159
+ ],
160
+ indices: [0],
161
+ range: undefined,
162
+ });
163
+ });
114
164
  });
@@ -5,6 +5,7 @@ import { describe, expect, it, vi } from "vitest";
5
5
  import {
6
6
  extractIndices,
7
7
  extractPoints,
8
+ hasAreaTrace,
8
9
  hasPureLineTrace,
9
10
  lineSelectionButtons,
10
11
  type ModeBarButton,
@@ -101,6 +102,14 @@ describe("shouldHandleClickSelection", () => {
101
102
  expect(shouldHandleClickSelection([heatmapPoint])).toBe(true);
102
103
  });
103
104
 
105
+ it("accepts violin clicks", () => {
106
+ const violinPoint = createPlotDatum({
107
+ data: { type: "violin" },
108
+ });
109
+
110
+ expect(shouldHandleClickSelection([violinPoint])).toBe(true);
111
+ });
112
+
104
113
  it("accepts histogram clicks", () => {
105
114
  const histogramPoint = createPlotDatum({
106
115
  data: { type: "histogram" },
@@ -219,3 +228,67 @@ describe("extractPoints", () => {
219
228
  ]);
220
229
  });
221
230
  });
231
+
232
+ describe("hasAreaTrace", () => {
233
+ it("detects scatter trace with tozeroy fill", () => {
234
+ expect(
235
+ hasAreaTrace([createTrace({ type: "scatter", fill: "tozeroy" })]),
236
+ ).toBe(true);
237
+ });
238
+
239
+ it("detects scatter trace with tonexty fill", () => {
240
+ expect(
241
+ hasAreaTrace([createTrace({ type: "scatter", fill: "tonexty" })]),
242
+ ).toBe(true);
243
+ });
244
+
245
+ it("detects scatter trace with stackgroup (px.area pattern)", () => {
246
+ expect(
247
+ hasAreaTrace([
248
+ createTrace({ type: "scatter", mode: "lines", stackgroup: "one" }),
249
+ ]),
250
+ ).toBe(true);
251
+ });
252
+
253
+ it("detects area traces with mode=none (fill-only, no visible line)", () => {
254
+ expect(
255
+ hasAreaTrace([
256
+ createTrace({ type: "scatter", fill: "tozeroy", mode: "none" }),
257
+ ]),
258
+ ).toBe(true);
259
+ });
260
+
261
+ it("ignores scatter traces with no fill and no stackgroup", () => {
262
+ expect(
263
+ hasAreaTrace([
264
+ createTrace({ type: "scatter", mode: "lines" }),
265
+ createTrace({ type: "scatter", mode: "markers" }),
266
+ ]),
267
+ ).toBe(false);
268
+ });
269
+
270
+ it("ignores scatter traces with fill=none", () => {
271
+ expect(hasAreaTrace([createTrace({ type: "scatter", fill: "none" })])).toBe(
272
+ false,
273
+ );
274
+ });
275
+
276
+ it("ignores scatter traces with fill=empty string", () => {
277
+ expect(
278
+ hasAreaTrace([createTrace({ type: "scatter", fill: "" as "none" })]),
279
+ ).toBe(false);
280
+ });
281
+
282
+ it("ignores non-scatter traces", () => {
283
+ expect(
284
+ hasAreaTrace([
285
+ createTrace({ type: "bar" }),
286
+ createTrace({ type: "heatmap" }),
287
+ ]),
288
+ ).toBe(false);
289
+ });
290
+
291
+ it("returns false for undefined data", () => {
292
+ expect(hasAreaTrace(undefined)).toBe(false);
293
+ });
294
+ });
@@ -141,13 +141,44 @@ export function hasPureLineTrace(
141
141
  }
142
142
 
143
143
  return data.some((trace) => {
144
- const traceType = (trace as { type?: unknown }).type;
144
+ const t = trace as Record<string, unknown>;
145
145
  const isScatterLike =
146
- traceType === undefined || LINE_CLICK_TRACE_TYPES.has(String(traceType));
146
+ t.type === undefined || LINE_CLICK_TRACE_TYPES.has(String(t.type));
147
147
  if (!isScatterLike) {
148
148
  return false;
149
149
  }
150
- return isPureLineMode((trace as { mode?: unknown }).mode);
150
+ return isPureLineMode(t.mode);
151
+ });
152
+ }
153
+
154
+ /**
155
+ * Return true when any scatter/scattergl trace has a non-empty fill or a
156
+ * stackgroup, i.e. it is an area chart.
157
+ *
158
+ * Area traces built with `mode="none"` have no visible line or markers, so
159
+ * `hasPureLineTrace` returns false for them even though they need select/lasso
160
+ * buttons just as much as `mode="lines"` area charts. This function covers
161
+ * that gap and is OR-ed with `hasPureLineTrace` in the config builder.
162
+ */
163
+ export function hasAreaTrace(
164
+ data: readonly Plotly.Data[] | undefined,
165
+ ): boolean {
166
+ if (!data) {
167
+ return false;
168
+ }
169
+
170
+ return data.some((trace) => {
171
+ const t = trace as Record<string, unknown>;
172
+ // Only scatter/scattergl can be area traces.
173
+ if (t.type !== undefined && !LINE_CLICK_TRACE_TYPES.has(String(t.type))) {
174
+ return false;
175
+ }
176
+ // A trace is an area trace when fill is a non-empty string other than
177
+ // "none", OR it belongs to a stackgroup (px.area always sets stackgroup).
178
+ return (
179
+ (typeof t.fill === "string" && t.fill !== "" && t.fill !== "none") ||
180
+ t.stackgroup != null
181
+ );
151
182
  });
152
183
  }
153
184
 
@@ -228,6 +259,7 @@ export function shouldHandleClickSelection(
228
259
  type === "heatmap" ||
229
260
  type === "histogram" ||
230
261
  type === "waterfall" ||
262
+ type === "violin" ||
231
263
  isLinePoint(point)
232
264
  );
233
265
  });