@marimo-team/frontend 0.23.10-dev16 → 0.23.10-dev17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{edit-page-C2zY3ykA.js → edit-page-i8CUVb2_.js} +2 -2
- package/dist/assets/file-explorer-panel-ndSjEMW1.js +26 -0
- package/dist/assets/{index-xTvcB4F3.js → index-BXAJ4fJT.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/storage/__tests__/storage-inspector.test.ts +55 -0
- package/src/components/storage/storage-inspector.tsx +55 -29
- package/dist/assets/file-explorer-panel-SnV3hzfA.js +0 -26
package/dist/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-BXAJ4fJT.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-DdZsAcJe.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import type { StorageEntry } from "@/core/storage/types";
|
|
4
|
+
import { exportedForTesting } from "../storage-inspector";
|
|
5
|
+
|
|
6
|
+
const { storageEntryKey } = exportedForTesting;
|
|
7
|
+
|
|
8
|
+
function makeEntry(
|
|
9
|
+
overrides: Partial<StorageEntry> & { path: string },
|
|
10
|
+
): StorageEntry {
|
|
11
|
+
return {
|
|
12
|
+
kind: overrides.kind ?? "file",
|
|
13
|
+
lastModified: overrides.lastModified ?? null,
|
|
14
|
+
metadata: overrides.metadata ?? {},
|
|
15
|
+
path: overrides.path,
|
|
16
|
+
size: overrides.size ?? 0,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("storageEntryKey", () => {
|
|
21
|
+
it("prefers the backend id when present (e.g. Google Drive)", () => {
|
|
22
|
+
const entry = makeEntry({
|
|
23
|
+
path: "Data Resume.pdf",
|
|
24
|
+
metadata: { id: "drive-file-id-123" },
|
|
25
|
+
});
|
|
26
|
+
// Two files can share a path on Drive; the id keeps keys unique.
|
|
27
|
+
expect(storageEntryKey(entry, 0)).toBe("drive-file-id-123");
|
|
28
|
+
expect(storageEntryKey(entry, 4)).toBe("drive-file-id-123");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("falls back to path + index when there is no id", () => {
|
|
32
|
+
const entry = makeEntry({ path: "Data Resume.pdf" });
|
|
33
|
+
expect(storageEntryKey(entry, 0)).toBe("Data Resume.pdf::0");
|
|
34
|
+
expect(storageEntryKey(entry, 4)).toBe("Data Resume.pdf::4");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("keeps duplicate-path entries unique via the index fallback", () => {
|
|
38
|
+
const entries = [
|
|
39
|
+
makeEntry({ path: "Data Resume.pdf" }),
|
|
40
|
+
makeEntry({ path: "Data Resume.pdf" }),
|
|
41
|
+
makeEntry({ path: "Data Resume.pdf" }),
|
|
42
|
+
];
|
|
43
|
+
const keys = entries.map((entry, index) => storageEntryKey(entry, index));
|
|
44
|
+
expect(new Set(keys).size).toBe(entries.length);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("ignores a non-string or empty id", () => {
|
|
48
|
+
expect(
|
|
49
|
+
storageEntryKey(makeEntry({ path: "a.pdf", metadata: { id: "" } }), 2),
|
|
50
|
+
).toBe("a.pdf::2");
|
|
51
|
+
expect(
|
|
52
|
+
storageEntryKey(makeEntry({ path: "a.pdf", metadata: { id: 5 } }), 2),
|
|
53
|
+
).toBe("a.pdf::2");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -94,6 +94,18 @@ function displayName(path: string): string {
|
|
|
94
94
|
return parts[parts.length - 1] || trimmed;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Stable, unique identity for an entry row. Prefer the
|
|
99
|
+
* backend's stable id when present and fall back to the list index
|
|
100
|
+
*/
|
|
101
|
+
function storageEntryKey(entry: StorageEntry, index: number): string {
|
|
102
|
+
const id = entry.metadata?.id;
|
|
103
|
+
if (typeof id === "string" && id.length > 0) {
|
|
104
|
+
return id;
|
|
105
|
+
}
|
|
106
|
+
return `${entry.path}::${index}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
/**
|
|
98
110
|
* Recursively check whether an entry (or any of its loaded descendants)
|
|
99
111
|
* matches the search query.
|
|
@@ -213,26 +225,31 @@ const StorageEntryChildren: React.FC<{
|
|
|
213
225
|
|
|
214
226
|
return (
|
|
215
227
|
<>
|
|
216
|
-
{filtered.map((child) =>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
{filtered.map((child) => {
|
|
229
|
+
const rowKey = storageEntryKey(child, children.indexOf(child));
|
|
230
|
+
return (
|
|
231
|
+
<StorageEntryRow
|
|
232
|
+
key={rowKey}
|
|
233
|
+
rowKey={rowKey}
|
|
234
|
+
entry={child}
|
|
235
|
+
namespace={namespace}
|
|
236
|
+
protocol={protocol}
|
|
237
|
+
rootPath={rootPath}
|
|
238
|
+
backendType={backendType}
|
|
239
|
+
depth={depth}
|
|
240
|
+
locale={locale}
|
|
241
|
+
searchValue={searchValue}
|
|
242
|
+
onOpenFile={onOpenFile}
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
})}
|
|
230
246
|
</>
|
|
231
247
|
);
|
|
232
248
|
};
|
|
233
249
|
|
|
234
250
|
const StorageEntryRow: React.FC<{
|
|
235
251
|
entry: StorageEntry;
|
|
252
|
+
rowKey: string;
|
|
236
253
|
namespace: string;
|
|
237
254
|
protocol: string;
|
|
238
255
|
rootPath: string;
|
|
@@ -243,6 +260,7 @@ const StorageEntryRow: React.FC<{
|
|
|
243
260
|
onOpenFile: (info: OpenFileInfo) => void;
|
|
244
261
|
}> = ({
|
|
245
262
|
entry,
|
|
263
|
+
rowKey,
|
|
246
264
|
namespace,
|
|
247
265
|
protocol,
|
|
248
266
|
rootPath,
|
|
@@ -312,7 +330,7 @@ const StorageEntryRow: React.FC<{
|
|
|
312
330
|
isDir && "font-medium",
|
|
313
331
|
)}
|
|
314
332
|
style={indentStyle(depth)}
|
|
315
|
-
value={`${namespace}:${
|
|
333
|
+
value={`${namespace}:${rowKey}`}
|
|
316
334
|
onSelect={() => {
|
|
317
335
|
if (isDir) {
|
|
318
336
|
setIsExpanded(!effectiveExpanded);
|
|
@@ -525,20 +543,24 @@ const StorageNamespaceSection: React.FC<{
|
|
|
525
543
|
No matches
|
|
526
544
|
</div>
|
|
527
545
|
)}
|
|
528
|
-
{filtered.map((entry) =>
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
546
|
+
{filtered.map((entry) => {
|
|
547
|
+
const rowKey = storageEntryKey(entry, entries.indexOf(entry));
|
|
548
|
+
return (
|
|
549
|
+
<StorageEntryRow
|
|
550
|
+
key={rowKey}
|
|
551
|
+
rowKey={rowKey}
|
|
552
|
+
entry={entry}
|
|
553
|
+
namespace={namespaceName}
|
|
554
|
+
protocol={namespace.protocol}
|
|
555
|
+
rootPath={namespace.rootPath}
|
|
556
|
+
backendType={namespace.backendType}
|
|
557
|
+
depth={1}
|
|
558
|
+
locale={locale}
|
|
559
|
+
searchValue={searchValue}
|
|
560
|
+
onOpenFile={onOpenFile}
|
|
561
|
+
/>
|
|
562
|
+
);
|
|
563
|
+
})}
|
|
542
564
|
</>
|
|
543
565
|
)}
|
|
544
566
|
</>
|
|
@@ -652,3 +674,7 @@ export const StorageInspector: React.FC = () => {
|
|
|
652
674
|
</div>
|
|
653
675
|
);
|
|
654
676
|
};
|
|
677
|
+
|
|
678
|
+
export const exportedForTesting = {
|
|
679
|
+
storageEntryKey,
|
|
680
|
+
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import{s as qe}from"./chunk-LvLJmgfZ.js";import{i as It,l as ke,n as ee,p as Ue,u as ye}from"./useEvent-D91BmmQi.js";import{t as Rt}from"./react-Bj1aDYRI.js";import{D as Et,Fn as We,Oi as Ge,wi as At,wr as Ht}from"./cells-FW8WlzJY.js";import"./react-dom-CSu739Rf.js";import{t as fe}from"./compiler-runtime-B3qBwwSJ.js";import{_ as De}from"./useEventListener-DvoEXWke.js";import{t as Vt}from"./invariant-BUdrueMv.js";import{f as Je,h as Lt}from"./utils-CvI-39U6.js";import{T as _e}from"./config-DH1Le_e1.js";import{t as ie}from"./cn-DCUzRj2J.js";import{t as Bt}from"./jsx-runtime-BqBOg78p.js";import"./fullscreen-eipL3i3Y.js";import{n as qt}from"./multi-map-CUuNtzHt.js";import{o as Ut}from"./alert-dialog-BqFLkbUc.js";import"./popover-Bz_0Vkyf.js";import{a as E,c as ue,p as Wt,r as Gt,t as Jt}from"./dropdown-menu-CR7cnzLX.js";import{a as Kt,i as Ke,o as Fe,wt as Me}from"./JsonOutput-Df7Vt26h.js";import{c as Yt,i as ze,r as Ce}from"./download-4dvb0Tm7.js";import{r as Ye}from"./radio-group-BMlG1iLU.js";import{t as A}from"./tooltip-DTV9tlSr.js";import{n as Xt,t as I}from"./button-BbCh-29a.js";import{St as Zt}from"./dist-BrR4M-k3.js";import"./cjs-BRGiG41H.js";import"./main-B0OX4z33.js";import"./useNonce-DfoVjkkH.js";import{n as Qt,r as Pe}from"./requests-DIwGYs0l.js";import{t as re}from"./createLucideIcon-D5guW7EU.js";import{a as Xe,c as Ze,i as Qe,n as Se,o as Te,r as ea,t as ta}from"./state-CcAGAozT.js";import{n as aa}from"./LazyAnyLanguageCodeMirror-kGFT2d8V.js";import{t as na}from"./x-C-6liIBr.js";import{n as Oe}from"./markdown-renderer-B2dVZ8Vp.js";import{u as ra}from"./toDate-B5A0DFEz.js";import{t as et}from"./copy-BwrPA9zQ.js";import{t as $e}from"./external-link-BTNxSavU.js";import{a as sa,i as tt,n as at,r as la,t as oa}from"./file-icons-QWprdVWf.js";import{t as nt}from"./file-HTLbeC2b.js";import{i as rt,r as ia,t as st}from"./add-connection-dialog-DV3vbtpl.js";import{n as Ie,t as ca}from"./spinner-UuZAUjoP.js";import{a as da,c as ma,d as pa,f as ha,i as xa,l as fa,n as ua,r as ya,t as ja,u as ga}from"./file-name-input-4pvJeVQK.js";import{t as lt}from"./plus-CxkHs8QM.js";import{t as ot}from"./refresh-cw-a_9k9BK7.js";import{t as ba}from"./save-DZ5aail6.js";import{t as va}from"./triangle-alert-CJ0ZIqcz.js";import{n as wa,t as Na}from"./es-au8YY-8E.js";import"./dist-DCqxOggh.js";import"./dist-BZr6MMV-.js";import"./dist-BU26XwgJ.js";import"./dist-COs9gIu5.js";import"./dist-DkA__6UI.js";import{t as te}from"./use-toast-9t59MOqR.js";import{t as ka}from"./paths-SFhaqGlE.js";import"./session-DGdfs0bJ.js";import"./purify.es-DvRMX74T.js";import"./dates-DS_7IZoI.js";import{n as je}from"./copy-Ch48HVPK.js";import{t as _a}from"./copy-icon-z0dzhmL4.js";import{t as it}from"./context-C1Tm_47t.js";import{n as ct}from"./ImperativeModal-BeQmePpG.js";import{t as dt}from"./blob-3_FN0u9S.js";import"./utils-DQRuLEof.js";import"./vega-loader.browser-xq8miGHn.js";import"./defaultLocale-DPBdGRrH.js";import"./defaultLocale-Lfi0pexn.js";import{n as Fa,t as Ca}from"./alert-DrHguQlr.js";import{n as mt}from"./error-banner-CLO6LFll.js";import"./chunk-5FQGJX7Z-WmZDj8ty.js";import"./html-to-image-C5f8yFhw.js";import{o as Sa}from"./focus-9N2kMkkO.js";import{n as Re}from"./useAsyncData-Dg8E_bPh.js";import"./react-resizable-panels.browser.esm-BdtIs0E-.js";import{a as Da,d as Ma,o as pt,t as za}from"./command-DUeag2QH.js";import{a as Pa}from"./renderShortcut-BTgMpqTK.js";import{t as Ta}from"./bundle.esm-BXIlAZ6T.js";import{a as Oa,i as Ee,n as $a,r as ht,t as ge}from"./tree-actions-B5athjIm.js";import{a as Ia}from"./components-CtK6Njp_.js";import{n as Ra}from"./pathUtils-vgBYIo5B.js";import{n as Ea}from"./semaphore-X3ApuO41.js";import{t as Aa}from"./empty-state-CcobJSnG.js";import{t as Ae}from"./formatting-BGBHA0kw.js";import{a as Ha,i as Va,n as xt,r as ft,t as ut}from"./components-BqAv4KRy.js";import{n as yt,t as La}from"./marimo-icons-BmEL8W-Z.js";import{t as Ba}from"./links-C-_seirg.js";var qa=re("book-plus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]),Ua=re("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),jt=re("file-plus-corner",[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]]),Wa=re("file-symlink",[["path",{d:"M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7",key:"huwfnr"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m10 18 3-3-3-3",key:"18f6ys"}]]),gt=re("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),bt=re("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]),Ga=re("square-play",[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}]]),vt=re("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),T=qe(Rt(),1),Ja=fe(),a=qe(Bt(),1);const wt=t=>{let e=(0,Ja.c)(17),{filename:n,filenameIcon:i,onBack:o,onRefresh:r,onDownload:d,actions:c}=t,x;e[0]===o?x=e[1]:(x=o&&(0,a.jsx)(A,{content:"Back to file list",children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:o,children:(0,a.jsx)(Ze,{className:"h-4 w-4"})})}),e[0]=o,e[1]=x);let s;e[2]!==n||e[3]!==i?(s=n?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate",children:[i,n]}):(0,a.jsx)("span",{className:"flex-1"}),e[2]=n,e[3]=i,e[4]=s):s=e[4];let y;e[5]===r?y=e[6]:(y=r&&(0,a.jsx)(A,{content:"Refresh",children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:r,children:(0,a.jsx)(ot,{className:"h-3.5 w-3.5"})})}),e[5]=r,e[6]=y);let m;e[7]===d?m=e[8]:(m=d&&(0,a.jsx)(A,{content:"Download",children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:d,children:(0,a.jsx)(Me,{className:"h-3.5 w-3.5"})})}),e[7]=d,e[8]=m);let f;e[9]!==c||e[10]!==y||e[11]!==m?(f=(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[y,c,m]}),e[9]=c,e[10]=y,e[11]=m,e[12]=f):f=e[12];let u;return e[13]!==x||e[14]!==s||e[15]!==f?(u=(0,a.jsxs)("div",{className:"flex items-center shrink-0 border-b px-1 gap-1",children:[x,s,f]}),e[13]=x,e[14]=s,e[15]=f,e[16]=u):u=e[16],u};var Ka=new Set(["http","file","in-memory"]);function He(t){return JSON.stringify(t).slice(1,-1)}const Nt=[{id:"read-file",label:"Insert read snippet",icon:qa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=He(t.entry.path);return t.backendType==="obstore"?`_data = ${t.variableName}.get("${e}").bytes()
|
|
2
|
-
_data`:`_data = ${t.variableName}.cat_file("${e}")
|
|
3
|
-
_data`}},{id:"download-file",label:"Insert download snippet",icon:Wa,getCode:t=>{if(t.entry.kind==="directory")return null;let e=He(t.entry.path);if(t.backendType==="obstore")return Ka.has(t.protocol)?null:`from datetime import timedelta
|
|
4
|
-
from obstore import sign
|
|
5
|
-
|
|
6
|
-
signed_url = sign(
|
|
7
|
-
${t.variableName}, "GET", "${e}",
|
|
8
|
-
expires_in=timedelta(hours=1),
|
|
9
|
-
)
|
|
10
|
-
signed_url`;let n=He(t.entry.path.split("/").pop()||"download");return`${t.variableName}.get("${e}", "${n}")`}}];var Ya=100*1024*1024;function Xa(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}const Za=({entry:t,namespace:e,protocol:n,backendType:i,onBack:o})=>{let{locale:r}=it(),d=Ye(),c=Xa(t.path),x=t.mimeType||"text/plain",s=Fe(x),y=s&&t.size>Ya&&t.size>0,{data:m,isPending:f,error:u,refetch:g}=Re(async()=>{if(y)return null;let p=await Te.request({namespace:e,path:t.path,preview:!s});if(p.error)throw Error(p.error);if(!p.url)throw Error("No URL returned");if(s)return{type:"media",url:p.url};let b=await fetch(p.url);if(!b.ok)throw Error(`Failed to fetch preview: ${b.statusText}`);return{type:"text",content:await b.text()}},[e,t.path,s,y]),w=(0,T.useCallback)(async()=>{try{let p=await Te.request({namespace:e,path:t.path});if(p.error){te({title:"Download failed",description:p.error,variant:"danger"});return}p.url&&ze(p.url,p.filename??c)}catch(p){De.error("Failed to download storage entry",p),te({title:"Download failed",description:String(p),variant:"danger"})}},[e,t.path,c]),v=Nt.map(p=>{let b=p.getCode({variableName:e,protocol:n,entry:t,backendType:i});if(b===null)return null;let h=p.icon;return(0,a.jsx)(A,{content:p.label,children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:()=>d(b),"aria-label":p.label,children:(0,a.jsx)(h,{className:"h-3.5 w-3.5"})})},p.id)}),l=(0,a.jsx)(wt,{filename:c,filenameIcon:tt(c),onBack:o,onDownload:w,actions:v}),j=({includeMime:p=!1})=>(0,a.jsxs)("div",{className:"grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs",children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Path"}),(0,a.jsxs)("div",{className:"truncate flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"font-mono text-[11px]",children:t.path}),(0,a.jsx)(_a,{value:t.path,className:"h-3 w-3"})]}),p&&(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Type"}),p&&(0,a.jsx)("span",{children:x}),t.size>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Size"}),(0,a.jsx)("span",{children:Ae(t.size,r)})]}),t.lastModified!=null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground font-medium",children:"Modified"}),(0,a.jsx)("span",{children:new Date(t.lastModified*1e3).toLocaleString()})]})]});return y?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-muted-foreground italic",children:["File is too large to preview (",Ae(t.size,r),")."]})]}):f?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({}),(0,a.jsxs)("div",{className:"flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24",children:[(0,a.jsx)(Ie,{className:"h-4 w-4 animate-spin"}),"Loading preview..."]})]}):u?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({includeMime:!0}),(0,a.jsxs)("div",{className:"px-4 pb-4 text-xs text-destructive",children:["Failed to load preview: ",u.message]}),(0,a.jsx)("div",{className:"px-4 pb-4",children:(0,a.jsxs)(I,{variant:"secondary",size:"xs",onClick:g,children:[(0,a.jsx)(ot,{className:"h-3 w-3 mr-1"}),"Retry"]})})]}):m?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({}),(0,a.jsx)(Ke,{mimeType:x,contents:m.type==="text"?m.content:void 0,mediaSource:m.type==="media"?{url:m.url}:void 0})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[l,j({includeMime:!0}),(0,a.jsxs)("div",{className:"p-4 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(nt,{className:"h-4 w-4"}),"Preview not available for this file type."]})]})};var Ve=fe(),Qa=16;function se(t){return{paddingLeft:t*Qa}}function en(t,e){return new Date(t*1e3).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function kt(t){let e=t.endsWith("/")?t.slice(0,-1):t,n=e.split("/");return n[n.length-1]||e}function Le(t,e,n,i){let o=n.toLowerCase();if(kt(t.path).toLowerCase().includes(o))return!0;if(t.kind==="directory"){let r=i.get(Xe(e,t.path));if(r)return r.some(d=>Le(d,e,n,i))}return!1}function _t(t,e,n,i){return n.trim()?t.filter(o=>Le(o,e,n,i)):t}var tn=t=>{let e=(0,Ve.c)(36),{namespace:n,protocol:i,rootPath:o,backendType:r,prefix:d,depth:c,locale:x,searchValue:s,onOpenFile:y}=t,{entriesByPath:m}=Se(),{entries:f,isPending:u,error:g}=Qe(n,d);if(u){let l;e[0]===c?l=e[1]:(l=se(c),e[0]=c,e[1]=l);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)(Ie,{className:"h-3 w-3 animate-spin"}),e[2]=j):j=e[2];let p;return e[3]===l?p=e[4]:(p=(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:l,children:[j,"Loading..."]}),e[3]=l,e[4]=p),p}if(g){let l;e[5]===c?l=e[6]:(l=se(c),e[5]=c,e[6]=l);let j;return e[7]!==g.message||e[8]!==l?(j=(0,a.jsxs)("div",{className:"py-1 text-xs text-destructive",style:l,children:["Failed to load: ",g.message]}),e[7]=g.message,e[8]=l,e[9]=j):j=e[9],j}if(f.length===0){let l;e[10]===c?l=e[11]:(l=se(c),e[10]=c,e[11]=l);let j;return e[12]===l?j=e[13]:(j=(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:l,children:"Empty"}),e[12]=l,e[13]=j),j}let w;if(e[14]!==r||e[15]!==f||e[16]!==c||e[17]!==m||e[18]!==x||e[19]!==n||e[20]!==y||e[21]!==i||e[22]!==o||e[23]!==s){let l=_t(f,n,s,m),j;e[25]!==r||e[26]!==c||e[27]!==x||e[28]!==n||e[29]!==y||e[30]!==i||e[31]!==o||e[32]!==s?(j=p=>(0,a.jsx)(Ft,{entry:p,namespace:n,protocol:i,rootPath:o,backendType:r,depth:c,locale:x,searchValue:s,onOpenFile:y},p.path),e[25]=r,e[26]=c,e[27]=x,e[28]=n,e[29]=y,e[30]=i,e[31]=o,e[32]=s,e[33]=j):j=e[33],w=l.map(j),e[14]=r,e[15]=f,e[16]=c,e[17]=m,e[18]=x,e[19]=n,e[20]=y,e[21]=i,e[22]=o,e[23]=s,e[24]=w}else w=e[24];let v;return e[34]===w?v=e[35]:(v=(0,a.jsx)(a.Fragment,{children:w}),e[34]=w,e[35]=v),v},Ft=({entry:t,namespace:e,protocol:n,rootPath:i,backendType:o,depth:r,locale:d,searchValue:c,onOpenFile:x})=>{var b;let[s,y]=(0,T.useState)(!1),{entriesByPath:m}=Se(),f=Ye(),u=t.kind==="directory",g=kt(t.path),w=!!c.trim(),v=u&&w&&g.toLowerCase().includes(c.trim().toLowerCase()),l=u&&w&&!!((b=m.get(Xe(e,t.path)))!=null&&b.some(h=>Le(h,e,c,m))),j=s||l,p=(0,T.useCallback)(async()=>{try{let h=await Te.request({namespace:e,path:t.path});if(h.error){te({title:"Download failed",description:h.error,variant:"danger"});return}h.url&&ze(h.url,h.filename??"download")}catch(h){De.error("Failed to download storage entry",h),te({title:"Download failed",description:String(h),variant:"danger"})}},[e,t.path]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(pt,{className:ie("text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5",u&&"font-medium"),style:se(r),value:`${e}:${t.path}`,onSelect:()=>{u?y(!j):x({entry:t,namespace:e,protocol:n,backendType:o})},children:[u?(0,a.jsx)(Ee,{isExpanded:j,className:"h-3 w-3"}):(0,a.jsx)("span",{className:"w-3 shrink-0"}),u?(0,a.jsx)(sa,{className:ie("h-3.5 w-3.5 shrink-0",at.directory)}):tt(g),(0,a.jsx)("span",{className:"truncate flex-1 text-left",children:g}),(0,a.jsxs)("div",{className:"flex items-center",children:[t.size>0&&(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums",children:Ae(t.size,d)}),t.lastModified!=null&&(0,a.jsx)(A,{content:`Last modified: ${new Date(t.lastModified*1e3).toLocaleString()}`,children:(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:en(t.lastModified,d)})}),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Wt,{asChild:!0,children:(0,a.jsx)($a,{iconClassName:"h-3 w-3",onClick:h=>h.stopPropagation()})}),(0,a.jsxs)(Gt,{align:"end",onClick:h=>h.stopPropagation(),onCloseAutoFocus:h=>h.preventDefault(),children:[!u&&(0,a.jsxs)(E,{onSelect:()=>x({entry:t,namespace:e,protocol:n,backendType:o}),children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"View"]}),(0,a.jsxs)(E,{onSelect:async()=>{await je(t.path),te({title:"Copied to clipboard"})},children:[(0,a.jsx)(et,{className:ge}),"Copy path"]}),!u&&(0,a.jsxs)(E,{onSelect:()=>p(),children:[(0,a.jsx)(Me,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{}),Nt.map(h=>{let k=h.getCode({variableName:e,protocol:n,entry:t,backendType:o});if(k===null)return null;let _=h.icon;return(0,a.jsxs)(E,{onSelect:()=>f(k),children:[(0,a.jsx)(_,{className:ge}),h.label]},h.id)})]})]})]})]}),u&&j&&(0,a.jsx)(tn,{namespace:e,protocol:n,rootPath:i,backendType:o,prefix:t.path,depth:r+1,locale:d,searchValue:v?"":c,onOpenFile:x})]})},an=t=>{let e=(0,Ve.c)(43),{namespace:n,locale:i,searchValue:o,onOpenFile:r}=t,[d,c]=(0,T.useState)(!0),{entriesByPath:x}=Se(),{clearNamespaceCache:s}=ea(),y=n.name??n.displayName,{entries:m,isPending:f,error:u,refetch:g}=Qe(y),w;e[0]!==s||e[1]!==y||e[2]!==g?(w=p=>{p.stopPropagation(),s(y),g()},e[0]=s,e[1]=y,e[2]=g,e[3]=w):w=e[3];let v=w,l=f?n.storageEntries:m,j;if(e[4]!==l||e[5]!==x||e[6]!==u||e[7]!==v||e[8]!==d||e[9]!==f||e[10]!==i||e[11]!==n.backendType||e[12]!==n.displayName||e[13]!==n.name||e[14]!==n.protocol||e[15]!==n.rootPath||e[16]!==y||e[17]!==r||e[18]!==o){let p=_t(l,y,o,x),b;e[20]===d?b=e[21]:(b=()=>c(!d),e[20]=d,e[21]=b);let h;e[22]===d?h=e[23]:(h=(0,a.jsx)(Ee,{isExpanded:d,className:"h-3 w-3"}),e[22]=d,e[23]=h);let k;e[24]===n.protocol?k=e[25]:(k=(0,a.jsx)(ia,{protocol:n.protocol}),e[24]=n.protocol,e[25]=k);let _;e[26]===n.displayName?_=e[27]:(_=(0,a.jsx)("span",{children:n.displayName}),e[26]=n.displayName,e[27]=_);let F;e[28]===n.name?F=e[29]:(F=n.name&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-normal",children:["(",(0,a.jsx)(Ha,{variableName:n.name}),")"]}),e[28]=n.name,e[29]=F);let C;e[30]===v?C=e[31]:(C=(0,a.jsx)(ht,{onClick:v,tooltip:"Refresh storage connection",className:"p-0",iconClassName:"h-3 w-3"}),e[30]=v,e[31]=C);let z=n.rootPath||"(root)",S;e[32]===z?S=e[33]:(S=(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground font-normal tabular-nums ml-auto",children:z}),e[32]=z,e[33]=S);let D;e[34]!==n.name||e[35]!==S||e[36]!==b||e[37]!==h||e[38]!==k||e[39]!==_||e[40]!==F||e[41]!==C?(D=(0,a.jsxs)(pt,{value:n.name,onSelect:b,className:"flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none",children:[h,k,_,F,C,S]}),e[34]=n.name,e[35]=S,e[36]=b,e[37]=h,e[38]=k,e[39]=_,e[40]=F,e[41]=C,e[42]=D):D=e[42],j=(0,a.jsxs)(a.Fragment,{children:[D,d&&(0,a.jsxs)(a.Fragment,{children:[f&&l.length===0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 py-1 text-xs text-muted-foreground",style:se(1),children:[(0,a.jsx)(Ie,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),u&&l.length===0&&(0,a.jsx)(Ia,{error:u,style:se(1),className:"py-1 text-xs h-auto overflow-auto max-h-32 items-start",showIcon:!1}),!f&&l.length===0&&!u&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No entries"}),o&&p.length===0&&l.length>0&&(0,a.jsx)("div",{className:"py-1 text-xs text-muted-foreground italic",style:se(1),children:"No matches"}),p.map(R=>(0,a.jsx)(Ft,{entry:R,namespace:y,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:i,searchValue:o,onOpenFile:r},R.path))]})]}),e[4]=l,e[5]=x,e[6]=u,e[7]=v,e[8]=d,e[9]=f,e[10]=i,e[11]=n.backendType,e[12]=n.displayName,e[13]=n.name,e[14]=n.protocol,e[15]=n.rootPath,e[16]=y,e[17]=r,e[18]=o,e[19]=j}else j=e[19];return j};const nn=()=>{let t=(0,Ve.c)(31),{namespaces:e}=Se(),{locale:n}=it(),[i,o]=(0,T.useState)(""),[r,d]=(0,T.useState)(null),c=!!i.trim();if(e.length===0){let b;t[0]===Symbol.for("react.memo_cache_sentinel")?(b=(0,a.jsxs)("span",{children:["Create an obstore or fsspec connection in your notebook. See the"," ",(0,a.jsx)("a",{className:"text-link",href:"https://docs.marimo.io/guides/working_with_data/remote_storage/#quick-start",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]}),t[0]=b):b=t[0];let h;return t[1]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsx)(Aa,{title:"No storage connected",description:b,action:(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsxs)(I,{variant:"outline",size:"sm",children:["Add remote storage",(0,a.jsx)(lt,{className:"h-4 w-4 ml-2"})]})}),icon:(0,a.jsx)(rt,{className:"h-8 w-8"})}),t[1]=h):h=t[1],h}let x;t[2]===r?x=t[3]:(x=r&&(0,a.jsx)(Za,{entry:r.entry,namespace:r.namespace,protocol:r.protocol,backendType:r.backendType,onBack:()=>d(null)}),t[2]=r,t[3]=x);let s=r&&"hidden",y;t[4]===s?y=t[5]:(y=ie("border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin",s),t[4]=s,t[5]=y);let m;t[6]===i?m=t[7]:(m=(0,a.jsx)(Da,{placeholder:"Search entries...",className:"h-6 m-1",value:i,onValueChange:o,rootClassName:"flex-1 border-b-0"}),t[6]=i,t[7]=m);let f;t[8]===c?f=t[9]:(f=c&&(0,a.jsx)(I,{variant:"text",size:"xs",className:"float-right border-none px-2 m-0 h-full",onClick:()=>o(""),children:(0,a.jsx)(na,{className:"h-4 w-4"})}),t[8]=c,t[9]=f);let u;t[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)(A,{content:"Filters loaded entries only. Expand directories to include their contents in the search.",delayDuration:200,children:(0,a.jsx)(ra,{className:"h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2"})}),t[10]=u):u=t[10];let g;t[11]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(st,{defaultTab:"storage",children:(0,a.jsx)(I,{variant:"ghost",size:"sm",className:"px-2 border-0 border-l border-muted-background rounded-none focus-visible:ring-0 focus-visible:ring-offset-0",children:(0,a.jsx)(lt,{className:"h-4 w-4"})})}),t[11]=g):g=t[11];let w;t[12]!==m||t[13]!==f?(w=(0,a.jsxs)("div",{className:"flex items-center w-full border-b",children:[m,f,u,g]}),t[12]=m,t[13]=f,t[14]=w):w=t[14];let v;if(t[15]!==n||t[16]!==e||t[17]!==i){let b;t[19]!==n||t[20]!==i?(b=h=>(0,a.jsx)(an,{namespace:h,locale:n,searchValue:i,onOpenFile:d},h.name??h.displayName),t[19]=n,t[20]=i,t[21]=b):b=t[21],v=e.map(b),t[15]=n,t[16]=e,t[17]=i,t[18]=v}else v=t[18];let l;t[22]===v?l=t[23]:(l=(0,a.jsx)(Ma,{className:"flex flex-col",children:v}),t[22]=v,t[23]=l);let j;t[24]!==y||t[25]!==w||t[26]!==l?(j=(0,a.jsxs)(za,{className:y,shouldFilter:!1,children:[w,l]}),t[24]=y,t[25]=w,t[26]=l,t[27]=j):j=t[27];let p;return t[28]!==x||t[29]!==j?(p=(0,a.jsxs)("div",{className:"h-full flex flex-col",children:[x,j]}),t[28]=x,t[29]=j,t[30]=p):p=t[30],p};var Ct=fe(),St=(0,T.createContext)(null);function rn(){return(0,T.useContext)(St)??void 0}var sn=t=>{let e=(0,Ct.c)(3),{children:n}=t,i=pa(),o;return e[0]!==n||e[1]!==i?(o=(0,a.jsx)(St.Provider,{value:i,children:n}),e[0]=n,e[1]=i,e[2]=o):o=e[2],o};const ln=t=>{let e=(0,Ct.c)(5),{children:n}=t,[i,o]=(0,T.useState)(null),r;e[0]!==n||e[1]!==i?(r=i&&(0,a.jsx)(ha,{backend:ga,options:{rootElement:i},children:(0,a.jsx)(sn,{children:n})}),e[0]=n,e[1]=i,e[2]=r):r=e[2];let d;return e[3]===r?d=e[4]:(d=(0,a.jsx)("div",{ref:o,className:"contents",children:r}),e[3]=r,e[4]=d),d};var Be=new Map;const on=({file:t,onOpenNotebook:e})=>{let{sendFileDetails:n,sendUpdateFile:i}=Pe(),o=ye(Lt),r=ye(Je),d=ye(At),[c,x]=(0,T.useState)(""),{data:s,isPending:y,error:m,setData:f,refetch:u}=Re(async()=>{let k=await n({path:t.path}),_=k.contents||"";return x(Be.get(t.path)||_),k},[t.path]),g=async()=>{c!==(s==null?void 0:s.contents)&&await i({path:t.path,contents:c}).then(k=>{k.success&&(f(_=>({..._,contents:c})),x(c))})},w=(0,T.useRef)(c);if(w.current=c,(0,T.useEffect)(()=>()=>{if(!(s!=null&&s.contents))return;let k=w.current;k===s.contents?Be.delete(t.path):Be.set(t.path,k)},[t.path,s==null?void 0:s.contents]),m)return(0,a.jsx)(mt,{error:m});if(y||!s)return null;let v=s.mimeType||"text/plain",l=v in Kt,j=d&&s.file.isMarimoFile&&(t.path===d||t.path.endsWith(`/${d}`));if(!s.contents&&!l)return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-6",children:[(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Name"}),(0,a.jsx)("div",{children:s.file.name}),(0,a.jsx)("div",{className:"font-bold text-muted-foreground",children:"Type"}),(0,a.jsx)("div",{children:v})]});let p=(0,a.jsx)(wt,{filename:s.file.name,onRefresh:u,onDownload:r?void 0:()=>{if(s.isBase64&&s.contents){Fe(v)?ze(Oe(s.contents,v),s.file.name):Ce(dt(Oe(s.contents,s.mimeType||"application/octet-stream")),s.file.name);return}Ce(new Blob([s.contents||c],{type:v}),s.file.name)},actions:(0,a.jsxs)(a.Fragment,{children:[t.isMarimoFile&&!_e()&&(0,a.jsx)(A,{content:"Open notebook",children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:k=>e(k),children:(0,a.jsx)($e,{className:"h-3.5 w-3.5"})})}),!Fe(v)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(A,{content:"Copy contents to clipboard",children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:async()=>{await je(c)},children:(0,a.jsx)(et,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(A,{content:Pa("global.save"),children:(0,a.jsx)(I,{variant:"text",size:"xs",onClick:g,disabled:c===s.contents,children:(0,a.jsx)(ba,{className:"h-3.5 w-3.5"})})})]})]})}),b=Fe(v),h=!b&&v!=="text/csv";return(0,a.jsxs)(a.Fragment,{children:[p,h&&j&&(0,a.jsxs)(Ca,{variant:"warning",className:"rounded-none",children:[(0,a.jsx)(va,{className:"h-4 w-4"}),(0,a.jsx)(Fa,{children:"Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution."})]}),(0,a.jsx)(Ke,{mimeType:v,contents:b?void 0:h?c:s.contents??void 0,mediaSource:b?{base64:s.contents,mime:v}:void 0,readOnly:!h,onChange:x,extensions:[Zt.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>c===s.contents?!1:(g(),!0)}])]})]})},Dt=Ue(t=>{let e=t(Qt);return Vt(e,"no requestClientAtom set"),new ma({listFiles:e.sendListFiles,createFileOrFolder:e.sendCreateFileOrFolder,deleteFileOrFolder:e.sendDeleteFileOrFolder,copyFileOrFolder:e.sendCopyFileOrFolder,renameFileOrFolder:e.sendRenameFileOrFolder})}),cn=Ue({});async function dn(){await It.get(Dt).refreshAll([])}var le=" ";const Mt={directory:t=>`os.listdir("${t}")`,python:t=>`with open("${t}", "r") as _f:
|
|
11
|
-
${le}...
|
|
12
|
-
`,json:t=>`with open("${t}", "r") as _f:
|
|
13
|
-
${le}_data = json.load(_f)
|
|
14
|
-
`,code:t=>`with open("${t}", "r") as _f:
|
|
15
|
-
${le}...
|
|
16
|
-
`,text:t=>`with open("${t}", "r") as _f:
|
|
17
|
-
${le}...
|
|
18
|
-
`,image:t=>`mo.image("${t}")`,audio:t=>`mo.audio("${t}")`,video:t=>`mo.video("${t}")`,pdf:t=>`with open("${t}", "rb") as _f:
|
|
19
|
-
${le}...
|
|
20
|
-
`,zip:t=>`with open("${t}", "rb") as _f:
|
|
21
|
-
${le}...
|
|
22
|
-
`,data:t=>`with open("${t}", "r") as _f:
|
|
23
|
-
${le}...
|
|
24
|
-
`,unknown:t=>`with open("${t}", "r") as _f:
|
|
25
|
-
${le}...
|
|
26
|
-
`};var mn=fe(),pn=1024*1024*100,hn=5;function zt(t){let e=(0,mn.c)(7),n;e[0]===t?n=e[1]:(n=t===void 0?{}:t,e[0]=t,e[1]=n);let i=n,{sendCreateFileOrFolder:o}=Pe(),r;e[2]===o?r=e[3]:(r=async c=>{if(c.length===0)return;let x=c.length===1;await Yt(x?"Uploading file...":"Uploading files...",async s=>{s.addTotal(c.length),await Ea(c,hn,async y=>{let m=gn(jn(y)),f="";m&&(f=ka.guessDeliminator(m).dirname(m)),await o({path:f,type:"file",name:y.name,file:y}),s.increment(1)}),await dn()},{title:x?"File uploaded":`${c.length} files uploaded`})},e[2]=o,e[3]=r);let d;return e[4]!==i||e[5]!==r?(d={multiple:!0,maxSize:pn,onError:yn,onDropRejected:xn,onDrop:r,...i},e[4]=i,e[5]=r,e[6]=d):d=e[6],Na(d)}function xn(t){te({title:"File upload failed",description:(0,a.jsx)("div",{className:"flex flex-col gap-1",children:t.map(fn)}),variant:"danger"})}function fn(t){return(0,a.jsxs)("div",{children:[t.file.name," (",t.errors.map(un).join(", "),")"]},t.file.name)}function un(t){return t.message}function yn(t){De.error(t),te({title:"File upload failed",description:t.message,variant:"danger"})}function jn(t){if(t.webkitRelativePath)return t.webkitRelativePath;if("path"in t&&typeof t.path=="string")return t.path;if("relativePath"in t&&typeof t.relativePath=="string")return t.relativePath}function gn(t){if(t)return t.replace(/^\/+/,"")}var be=fe(),bn=Ge("marimo:showHiddenFiles",!0,We,{getOnInit:!0}),Pt=T.createContext(null);const vn=t=>{let e=(0,be.c)(73),{height:n}=t,i=(0,T.useRef)(null),o=rn(),[r]=ke(Dt),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0];let[c,x]=(0,T.useState)(d),[s,y]=(0,T.useState)(null),[m,f]=ke(bn),{openPrompt:u}=ct(),[g,w]=ke(cn),v;e[1]===r?v=e[2]:(v=()=>r.initialize(x),e[1]=r,e[2]=v);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[3]=l):l=e[3];let{isPending:j,error:p}=Re(v,l),b;e[4]!==g||e[5]!==r?(b=()=>r.refreshAll(Object.keys(g).filter(N=>g[N])),e[4]=g,e[5]=r,e[6]=b):b=e[6];let h=ee(b),k;e[7]!==f||e[8]!==m?(k=()=>{f(!m)},e[7]=f,e[8]=m,e[9]=k):k=e[9];let _=ee(k),F;e[10]!==u||e[11]!==r?(F=async()=>{u({title:"Folder name",onConfirm:async N=>{r.createFolder(N,null)}})},e[10]=u,e[11]=r,e[12]=F):F=e[12];let C=ee(F),z;e[13]!==u||e[14]!==r?(z=async()=>{u({title:"File name",onConfirm:async N=>{r.createFile({name:N,parentId:null})}})},e[13]=u,e[14]=r,e[15]=z):z=e[15];let S=ee(z),D;e[16]!==u||e[17]!==r?(D=async()=>{u({title:"Notebook name",onConfirm:async N=>{r.createFile({name:N,parentId:null,type:"notebook"})}})},e[16]=u,e[17]=r,e[18]=D):D=e[18];let R=ee(D),$;e[19]===w?$=e[20]:($=()=>{var N;(N=i.current)==null||N.closeAll(),w({})},e[19]=w,e[20]=$);let Z=ee($),J;e[21]!==c||e[22]!==m?(J=Ot(c,m),e[21]=c,e[22]=m,e[23]=J):J=e[23];let oe=J;if(j){let N;return e[24]===Symbol.for("react.memo_cache_sentinel")?(N=(0,a.jsx)(ca,{size:"medium",centered:!0}),e[24]=N):N=e[24],N}if(p){let N;return e[25]===p?N=e[26]:(N=(0,a.jsx)(mt,{error:p}),e[25]=p,e[26]=N),N}if(s){let N;e[27]===Symbol.for("react.memo_cache_sentinel")?(N=()=>y(null),e[27]=N):N=e[27];let P;e[28]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)(I,{onClick:N,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:(0,a.jsx)(Ze,{size:16})}),e[28]=P):P=e[28];let O;e[29]===s.name?O=e[30]:(O=(0,a.jsxs)("div",{className:"flex items-center pl-1 pr-3 shrink-0 border-b justify-between",children:[P,(0,a.jsx)("span",{className:"font-bold",children:s.name})]}),e[29]=s.name,e[30]=O);let G;e[31]!==s.path||e[32]!==r?(G=ne=>Tt(ne,r.relativeFromRoot(s.path)),e[31]=s.path,e[32]=r,e[33]=G):G=e[33];let Y;e[34]!==s||e[35]!==G?(Y=(0,a.jsx)(T.Suspense,{children:(0,a.jsx)(on,{onOpenNotebook:G,file:s})}),e[34]=s,e[35]=G,e[36]=Y):Y=e[36];let X;return e[37]!==O||e[38]!==Y?(X=(0,a.jsxs)(a.Fragment,{children:[O,Y]}),e[37]=O,e[38]=Y,e[39]=X):X=e[39],X}let H;e[40]!==Z||e[41]!==S||e[42]!==C||e[43]!==R||e[44]!==_||e[45]!==h||e[46]!==m||e[47]!==r?(H=(0,a.jsx)(Nn,{onRefresh:h,onHidden:_,showHiddenFiles:m,onCreateFile:S,onCreateNotebook:R,onCreateFolder:C,onCollapseAll:Z,tree:r}),e[40]=Z,e[41]=S,e[42]=C,e[43]=R,e[44]=_,e[45]=h,e[46]=m,e[47]=r,e[48]=H):H=e[48];let Q=n-33,V,L,B;e[49]===r?(V=e[50],L=e[51],B=e[52]):(V=async N=>{let{ids:P}=N;for(let O of P)await r.delete(O)},L=async N=>{let{id:P,name:O}=N;await r.rename(P,O)},B=async N=>{let{dragIds:P,parentId:O}=N;await r.move(P,O)},e[49]=r,e[50]=V,e[51]=L,e[52]=B);let K;e[53]===Symbol.for("react.memo_cache_sentinel")?(K=N=>{let P=N[0];P&&(P.data.isDirectory||y(P.data))},e[53]=K):K=e[53];let q;e[54]!==g||e[55]!==w||e[56]!==r?(q=async N=>{if(await r.expand(N)){let P=g[N]??!1;w({...g,[N]:!P})}},e[54]=g,e[55]=w,e[56]=r,e[57]=q):q=e[57];let U;e[58]!==o||e[59]!==g||e[60]!==Q||e[61]!==V||e[62]!==L||e[63]!==B||e[64]!==q||e[65]!==oe?(U=(0,a.jsx)(fa,{width:"100%",ref:i,height:Q,className:"h-full",data:oe,initialOpenState:g,openByDefault:!1,dndManager:o,renderCursor:Sn,disableDrop:Dn,onDelete:V,onRename:L,onMove:B,onSelect:K,onToggle:q,padding:15,rowHeight:30,indent:wn,overscanCount:1e3,disableMultiSelection:!0,children:_n}),e[58]=o,e[59]=g,e[60]=Q,e[61]=V,e[62]=L,e[63]=B,e[64]=q,e[65]=oe,e[66]=U):U=e[66];let W;e[67]!==U||e[68]!==r?(W=(0,a.jsx)(Pt,{value:r,children:U}),e[67]=U,e[68]=r,e[69]=W):W=e[69];let ae;return e[70]!==H||e[71]!==W?(ae=(0,a.jsxs)(a.Fragment,{children:[H,W]}),e[70]=H,e[71]=W,e[72]=ae):ae=e[72],ae};var wn=15,Nn=t=>{let e=(0,be.c)(37),{onRefresh:n,onHidden:i,showHiddenFiles:o,onCreateFile:r,onCreateNotebook:d,onCreateFolder:c,onCollapseAll:x}=t,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={noDrag:!0,noDragEventsBubbling:!0},e[0]=s):s=e[0];let{getRootProps:y,getInputProps:m}=zt(s),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)(yt,{size:16}),e[1]=f):f=e[1];let u;e[2]===d?u=e[3]:(u=(0,a.jsx)(A,{content:"Add notebook",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-notebook-button",onClick:d,variant:"text",size:"xs",children:f})}),e[2]=d,e[3]=u);let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)(jt,{size:16}),e[4]=g):g=e[4];let w;e[5]===r?w=e[6]:(w=(0,a.jsx)(A,{content:"Add file",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-file-button",onClick:r,variant:"text",size:"xs",children:g})}),e[5]=r,e[6]=w);let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)(gt,{size:16}),e[7]=v):v=e[7];let l;e[8]===c?l=e[9]:(l=(0,a.jsx)(A,{content:"Add folder",children:(0,a.jsx)(I,{"data-testid":"file-explorer-add-folder-button",onClick:c,variant:"text",size:"xs",children:v})}),e[8]=c,e[9]=l);let j;e[10]===y?j=e[11]:(j=y({}),e[10]=y,e[11]=j);let p,b;e[12]===Symbol.for("react.memo_cache_sentinel")?(b=Xt({variant:"text",size:"xs"}),p=(0,a.jsx)(wa,{size:16}),e[12]=p,e[13]=b):(p=e[12],b=e[13]);let h;e[14]===j?h=e[15]:(h=(0,a.jsx)(A,{content:"Upload file",children:(0,a.jsx)("button",{"data-testid":"file-explorer-upload-button",...j,className:b,children:p})}),e[14]=j,e[15]=h);let k;e[16]===m?k=e[17]:(k=m({}),e[16]=m,e[17]=k);let _;e[18]===k?_=e[19]:(_=(0,a.jsx)("input",{...k,type:"file"}),e[18]=k,e[19]=_);let F;e[20]===n?F=e[21]:(F=(0,a.jsx)(ht,{"data-testid":"file-explorer-refresh-button",onClick:n}),e[20]=n,e[21]=F);let C;e[22]!==i||e[23]!==o?(C=(0,a.jsx)(Oa,{"data-testid":"file-explorer-hidden-files-button",isVisible:o,onToggle:i,showTooltip:"Show hidden files",hideTooltip:"Hide hidden files"}),e[22]=i,e[23]=o,e[24]=C):C=e[24];let z;e[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(Ua,{size:16}),e[25]=z):z=e[25];let S;e[26]===x?S=e[27]:(S=(0,a.jsx)(A,{content:"Collapse all folders",children:(0,a.jsx)(I,{"data-testid":"file-explorer-collapse-button",onClick:x,variant:"text",size:"xs",children:z})}),e[26]=x,e[27]=S);let D;return e[28]!==h||e[29]!==_||e[30]!==F||e[31]!==C||e[32]!==S||e[33]!==u||e[34]!==w||e[35]!==l?(D=(0,a.jsxs)("div",{className:"flex items-center justify-end px-2 shrink-0 border-b",children:[u,w,l,h,_,F,C,S]}),e[28]=h,e[29]=_,e[30]=F,e[31]=C,e[32]=S,e[33]=u,e[34]=w,e[35]=l,e[36]=D):D=e[36],D},kn=t=>{let e=(0,be.c)(9),{node:n,onOpenMarimoFile:i}=t,o;e[0]===n?o=e[1]:(o=c=>{n.data.isDirectory||(c.stopPropagation(),n.select())},e[0]=n,e[1]=o);let r;e[2]!==n.data.isMarimoFile||e[3]!==i?(r=n.data.isMarimoFile&&!_e()&&(0,a.jsxs)("span",{"data-testid":"file-explorer-open-marimo-button",className:"shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:i,children:["open ",(0,a.jsx)($e,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=i,e[4]=r):r=e[4];let d;return e[5]!==n.data.name||e[6]!==o||e[7]!==r?(d=(0,a.jsxs)("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:o,children:[n.data.name,r]}),e[5]=n.data.name,e[6]=o,e[7]=r,e[8]=d):d=e[8],d},_n=t=>{let e=(0,be.c)(116),{node:n,style:i,dragHandle:o}=t,{openFile:r,sendFileDetails:d}=Pe(),c=ye(Je),x;e[0]!==n.data.isDirectory||e[1]!==n.data.name?(x=n.data.isDirectory?"directory":la(n.data.name),e[0]=n.data.isDirectory,e[1]=n.data.name,e[2]=x):x=e[2];let s=x,y=oa[s],{openConfirm:m,openPrompt:f}=ct(),{createNewCell:u}=Et(),g=Sa(),w;e[3]!==u||e[4]!==g?(w=M=>{u({code:M,before:!1,cellId:g??"__end__"})},e[3]=u,e[4]=g,e[5]=w):w=e[5];let v=w,l=(0,T.use)(Pt),j;e[6]!==n.data.path||e[7]!==l?(j=async M=>{Tt(M,l?l.relativeFromRoot(n.data.path):n.data.path)},e[6]=n.data.path,e[7]=l,e[8]=j):j=e[8];let p=j,b;e[9]!==n.data.name||e[10]!==n.id||e[11]!==n.tree||e[12]!==m?(b=async M=>{M.stopPropagation(),M.preventDefault(),m({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:(0,a.jsx)(Ut,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},e[9]=n.data.name,e[10]=n.id,e[11]=n.tree,e[12]=m,e[13]=b):b=e[13];let h=b,k;e[14]!==n||e[15]!==f||e[16]!==l?(k=async()=>{n.open(),f({title:"Folder name",onConfirm:async M=>{l==null||l.createFolder(M,n.id)}})},e[14]=n,e[15]=f,e[16]=l,e[17]=k):k=e[17];let _=ee(k),F;e[18]!==n||e[19]!==f||e[20]!==l?(F=async()=>{n.open(),f({title:"File name",onConfirm:async M=>{l==null||l.createFile({name:M,parentId:n.id})}})},e[18]=n,e[19]=f,e[20]=l,e[21]=F):F=e[21];let C=ee(F),z;e[22]!==n||e[23]!==f||e[24]!==l?(z=async()=>{n.open(),f({title:"Notebook name",onConfirm:async M=>{l==null||l.createFile({name:M,parentId:n.id,type:"notebook"})}})},e[22]=n,e[23]=f,e[24]=l,e[25]=z):z=e[25];let S=ee(z),D;e[26]!==n.data.name||e[27]!==n.id||e[28]!==l?(D=async()=>{l&&await l.copy(n.id,Ra(n.data.name))},e[26]=n.data.name,e[27]=n.id,e[28]=l,e[29]=D):D=e[29];let R=ee(D),$;e[30]===Symbol.for("react.memo_cache_sentinel")?($=ie("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),e[30]=$):$=e[30];let Z,J;e[31]===n?(Z=e[32],J=e[33]):(Z=M=>{M.stopPropagation(),n.data.isDirectory&&n.toggle()},J=(0,a.jsx)(Fn,{node:n}),e[31]=n,e[32]=Z,e[33]=J);let oe=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground",H;e[34]===oe?H=e[35]:(H=ie("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",oe),e[34]=oe,e[35]=H);let Q;e[36]!==y||e[37]!==s||e[38]!==n.data.isMarimoFile?(Q=n.data.isMarimoFile?(0,a.jsx)(La,{className:"w-5 h-5 shrink-0 mr-2",strokeWidth:1.5}):(0,a.jsx)(y,{className:ie("w-5 h-5 shrink-0 mr-2",at[s]),strokeWidth:1.5}),e[36]=y,e[37]=s,e[38]=n.data.isMarimoFile,e[39]=Q):Q=e[39];let V;e[40]!==p||e[41]!==n?(V=n.isEditing?(0,a.jsx)(ja,{node:n}):(0,a.jsx)(kn,{node:n,onOpenMarimoFile:p}),e[40]=p,e[41]=n,e[42]=V):V=e[42];let L;e[43]===n?L=e[44]:(L=!n.data.isDirectory&&(0,a.jsxs)(E,{onSelect:()=>n.select(),"data-testid":"file-explorer-open-file-menu-item",children:[(0,a.jsx)(vt,{className:"h-3.5 w-3.5 mr-2"}),"Open file"]}),e[43]=n,e[44]=L);let B;e[45]!==n.data.isDirectory||e[46]!==n.data.path||e[47]!==r?(B=!n.data.isDirectory&&!_e()&&(0,a.jsxs)(E,{onSelect:()=>{r({path:n.data.path})},"data-testid":"file-explorer-open-external-menu-item",children:[(0,a.jsx)($e,{className:"h-3.5 w-3.5 mr-2"}),"Open file in external editor"]}),e[45]=n.data.isDirectory,e[46]=n.data.path,e[47]=r,e[48]=B):B=e[48];let K;e[49]!==C||e[50]!==_||e[51]!==S||e[52]!==n.data.isDirectory?(K=n.data.isDirectory&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:()=>S(),"data-testid":"file-explorer-create-notebook-menu-item",children:[(0,a.jsx)(yt,{className:"h-3.5 w-3.5 mr-2"}),"Create notebook"]}),(0,a.jsxs)(E,{onSelect:()=>C(),"data-testid":"file-explorer-create-file-menu-item",children:[(0,a.jsx)(jt,{className:"h-3.5 w-3.5 mr-2"}),"Create file"]}),(0,a.jsxs)(E,{onSelect:()=>_(),"data-testid":"file-explorer-create-folder-menu-item",children:[(0,a.jsx)(gt,{className:"h-3.5 w-3.5 mr-2"}),"Create folder"]}),(0,a.jsx)(ue,{})]}),e[49]=C,e[50]=_,e[51]=S,e[52]=n.data.isDirectory,e[53]=K):K=e[53];let q;e[54]===n?q=e[55]:(q=(0,a.jsx)(da,{onSelect:()=>n.edit(),testId:"file-explorer-rename-menu-item"}),e[54]=n,e[55]=q);let U;e[56]===R?U=e[57]:(U=(0,a.jsx)(ya,{onSelect:R,testId:"file-explorer-duplicate-menu-item"}),e[56]=R,e[57]=U);let W;e[58]===n.data.path?W=e[59]:(W=async()=>{await je(n.data.path),te({title:"Copied to clipboard"})},e[58]=n.data.path,e[59]=W);let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=(0,a.jsx)(bt,{className:ge}),e[60]=ae):ae=e[60];let N;e[61]===W?N=e[62]:(N=(0,a.jsxs)(E,{onSelect:W,"data-testid":"file-explorer-copy-path-menu-item",children:[ae,"Copy path"]}),e[61]=W,e[62]=N);let P;e[63]!==n.data.path||e[64]!==l?(P=l&&(0,a.jsxs)(E,{onSelect:async()=>{await je(l.relativeFromRoot(n.data.path)),te({title:"Copied to clipboard"})},"data-testid":"file-explorer-copy-relative-path-menu-item",children:[(0,a.jsx)(bt,{className:"h-3.5 w-3.5 mr-2"}),"Copy relative path"]}),e[63]=n.data.path,e[64]=l,e[65]=P):P=e[65];let O;e[66]===Symbol.for("react.memo_cache_sentinel")?(O=(0,a.jsx)(ue,{}),e[66]=O):O=e[66];let G;e[67]!==s||e[68]!==v||e[69]!==n.data?(G=()=>{let{path:M}=n.data;v(Mt[s](M))},e[67]=s,e[68]=v,e[69]=n.data,e[70]=G):G=e[70];let Y;e[71]===Symbol.for("react.memo_cache_sentinel")?(Y=(0,a.jsx)(aa,{className:ge}),e[71]=Y):Y=e[71];let X;e[72]===G?X=e[73]:(X=(0,a.jsxs)(E,{onSelect:G,"data-testid":"file-explorer-insert-snippet-menu-item",children:[Y,"Insert snippet for reading file"]}),e[72]=G,e[73]=X);let ne;e[74]!==s||e[75]!==n.data?(ne=async()=>{te({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});let{path:M}=n.data;await je(Mt[s](M))},e[74]=s,e[75]=n.data,e[76]=ne):ne=e[76];let ve;e[77]===Symbol.for("react.memo_cache_sentinel")?(ve=(0,a.jsx)(Ht,{className:ge}),e[77]=ve):ve=e[77];let ce;e[78]===ne?ce=e[79]:(ce=(0,a.jsxs)(E,{onSelect:ne,"data-testid":"file-explorer-copy-snippet-menu-item",children:[ve,"Copy snippet for reading file"]}),e[78]=ne,e[79]=ce);let de;e[80]!==p||e[81]!==n.data.isMarimoFile?(de=n.data.isMarimoFile&&!_e()&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ue,{}),(0,a.jsxs)(E,{onSelect:p,"data-testid":"file-explorer-open-notebook-menu-item",children:[(0,a.jsx)(Ga,{className:"h-3.5 w-3.5 mr-2"}),"Open notebook"]})]}),e[80]=p,e[81]=n.data.isMarimoFile,e[82]=de):de=e[82];let we;e[83]===Symbol.for("react.memo_cache_sentinel")?(we=(0,a.jsx)(ue,{}),e[83]=we):we=e[83];let me;e[84]!==c||e[85]!==n.data.isDirectory||e[86]!==n.data.name||e[87]!==n.data.path||e[88]!==d?(me=!n.data.isDirectory&&!c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(E,{onSelect:async()=>{let M=await d({path:n.data.path});M.isBase64&&M.contents?Ce(dt(Oe(M.contents,M.mimeType||"application/octet-stream")),n.data.name):Ce(new Blob([M.contents||""]),n.data.name)},"data-testid":"file-explorer-download-menu-item",children:[(0,a.jsx)(Me,{className:"h-3.5 w-3.5 mr-2"}),"Download"]}),(0,a.jsx)(ue,{})]}),e[84]=c,e[85]=n.data.isDirectory,e[86]=n.data.name,e[87]=n.data.path,e[88]=d,e[89]=me):me=e[89];let pe;e[90]===h?pe=e[91]:(pe=(0,a.jsx)(ua,{onSelect:h,testId:"file-explorer-delete-menu-item"}),e[90]=h,e[91]=pe);let he;e[92]!==L||e[93]!==B||e[94]!==K||e[95]!==q||e[96]!==U||e[97]!==N||e[98]!==P||e[99]!==X||e[100]!==ce||e[101]!==de||e[102]!==me||e[103]!==pe?(he=(0,a.jsxs)(xa,{testId:"file-explorer-more-button",iconClassName:"w-5 h-5",children:[L,B,K,q,U,N,P,O,X,ce,de,we,me,pe]}),e[92]=L,e[93]=B,e[94]=K,e[95]=q,e[96]=U,e[97]=N,e[98]=P,e[99]=X,e[100]=ce,e[101]=de,e[102]=me,e[103]=pe,e[104]=he):he=e[104];let xe;e[105]!==H||e[106]!==Q||e[107]!==V||e[108]!==he?(xe=(0,a.jsxs)("span",{className:H,children:[Q,V,he]}),e[105]=H,e[106]=Q,e[107]=V,e[108]=he,e[109]=xe):xe=e[109];let Ne;return e[110]!==o||e[111]!==i||e[112]!==Z||e[113]!==J||e[114]!==xe?(Ne=(0,a.jsxs)("div",{style:i,ref:o,className:$,draggable:!0,onClick:Z,children:[J,xe]}),e[110]=o,e[111]=i,e[112]=Z,e[113]=J,e[114]=xe,e[115]=Ne):Ne=e[115],Ne},Fn=t=>{let e=(0,be.c)(3),{node:n}=t;if(!n.data.isDirectory){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{className:"w-4 h-4 shrink-0"}),e[0]=o):o=e[0],o}let i;return e[1]===n.isOpen?i=e[2]:(i=(0,a.jsx)(Ee,{isExpanded:n.isOpen,className:"w-4 h-4"}),e[1]=n.isOpen,e[2]=i),i};function Tt(t,e){t.stopPropagation(),t.preventDefault(),Ba(e)}function Ot(t,e){if(e)return t;let n=[];for(let i of t){if(Cn(i.name))continue;let o=i;if(i.children){let r=Ot(i.children,e);r!==i.children&&(o={...i,children:r})}n.push(o)}return n}function Cn(t){return!!t.startsWith(".")}function Sn(){return null}function Dn(t){let{parentNode:e}=t;return!e.data.isDirectory}var $t=fe(),Mn=Ge("marimo:file-explorer-panel:state",{openSections:["files"],hasUserInteracted:!1},We),zn=t=>{let e=(0,$t.c)(20),{height:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={noClick:!0,noKeyboard:!0},e[0]=i):i=e[0];let{getRootProps:o,getInputProps:r,isDragActive:d}=zt(i),c;e[1]===o?c=e[2]:(c=o(),e[1]=o,e[2]=c);let x;e[3]===Symbol.for("react.memo_cache_sentinel")?(x=ie("flex flex-col overflow-hidden relative"),e[3]=x):x=e[3];let s;e[4]===n?s=e[5]:(s={height:n},e[4]=n,e[5]=s);let y;e[6]===r?y=e[7]:(y=r(),e[6]=r,e[7]=y);let m;e[8]===y?m=e[9]:(m=(0,a.jsx)("input",{...y}),e[8]=y,e[9]=m);let f;e[10]===d?f=e[11]:(f=d&&(0,a.jsx)("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[10]=d,e[11]=f);let u;e[12]===n?u=e[13]:(u=(0,a.jsx)(vn,{height:n}),e[12]=n,e[13]=u);let g;return e[14]!==c||e[15]!==s||e[16]!==m||e[17]!==f||e[18]!==u?(g=(0,a.jsx)(ln,{children:(0,a.jsxs)("div",{...c,className:x,style:s,children:[m,f,u]})}),e[14]=c,e[15]=s,e[16]=m,e[17]=f,e[18]=u,e[19]=g):g=e[19],g},Pn=33,Tn=()=>{let t=(0,$t.c)(36),{ref:e,height:n}=Ta(),i=n===void 0?500:n,[o,r]=ke(Mn),d=ye(ta).length,c;e:{if(!o.hasUserInteracted&&d>0){if(o.openSections.includes("remote-storage")){c=o.openSections;break e}let $;t[0]===o.openSections?$=t[1]:($=[...o.openSections,"remote-storage"],t[0]=o.openSections,t[1]=$),c=$;break e}c=o.openSections}let x=c,s;t[2]===r?s=t[3]:(s=$=>{r({openSections:$,hasUserInteracted:!0})},t[2]=r,t[3]=s);let y=s,m=i-Pn*2,f;t[4]===x?f=t[5]:(f=x.includes("remote-storage"),t[4]=x,t[5]=f);let u=f,g;t[6]!==x||t[7]!==u?(g=u&&x.includes("files"),t[6]=x,t[7]=u,t[8]=g):g=t[8];let w=g,v;t[9]!==m||t[10]!==w?(v=w?Math.round(m*.4):m,t[9]=m,t[10]=w,t[11]=v):v=t[11];let l=v,j=Math.max(200,w?m-l:m),p;t[12]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)(rt,{className:"w-4 h-4"}),t[12]=p):p=t[12];let b;t[13]===d?b=t[14]:(b=d>0&&(0,a.jsx)(Va,{children:d}),t[13]=d,t[14]=b);let h;t[15]===b?h=t[16]:(h=(0,a.jsxs)(ft,{children:[p," Remote storage",b]}),t[15]=b,t[16]=h);let k;t[17]===l?k=t[18]:(k={maxHeight:l},t[17]=l,t[18]=k);let _;t[19]===Symbol.for("react.memo_cache_sentinel")?(_=(0,a.jsx)(nn,{}),t[19]=_):_=t[19];let F;t[20]===k?F=t[21]:(F=(0,a.jsx)(ut,{className:"overflow-auto",style:k,children:_}),t[20]=k,t[21]=F);let C;t[22]!==F||t[23]!==h?(C=(0,a.jsxs)(xt,{value:"remote-storage",children:[h,F]}),t[22]=F,t[23]=h,t[24]=C):C=t[24];let z;t[25]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsxs)(ft,{children:[(0,a.jsx)(nt,{className:"w-4 h-4"}),"Files"]}),t[25]=z):z=t[25];let S;t[26]===j?S=t[27]:(S=(0,a.jsxs)(xt,{value:"files",children:[z,(0,a.jsx)(ut,{children:(0,a.jsx)(zn,{height:j})})]}),t[26]=j,t[27]=S);let D;t[28]!==y||t[29]!==x||t[30]!==C||t[31]!==S?(D=(0,a.jsxs)(qt,{type:"multiple",value:x,onValueChange:y,children:[C,S]}),t[28]=y,t[29]=x,t[30]=C,t[31]=S,t[32]=D):D=t[32];let R;return t[33]!==e||t[34]!==D?(R=(0,a.jsx)("div",{ref:e,className:"h-full overflow-auto",children:D}),t[33]=e,t[34]=D,t[35]=R):R=t[35],R};export{Tn as default};
|