@marimo-team/frontend 0.24.1-dev50 → 0.24.1-dev52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonOutput-BI2qFHVr.js → JsonOutput--lW6GQQ9.js} +10 -10
- package/dist/assets/{agent-panel-PB0I1dIC.js → agent-panel-i6F-fC5e.js} +1 -1
- package/dist/assets/{cell-editor-5wcJHF0s.js → cell-editor-X3xHqmCs.js} +1 -1
- package/dist/assets/{column-preview-D6cIOnWQ.js → column-preview-DKbMmEB5.js} +1 -1
- package/dist/assets/{command-palette-DkGgAhyM.js → command-palette-L1LZCmet.js} +1 -1
- package/dist/assets/{edit-page-Bpqbjwkb.js → edit-page-DOpi9pL6.js} +4 -4
- package/dist/assets/file-explorer-panel-z-rke195.js +1 -0
- package/dist/assets/{index-CRLe8Sox.js → index-CNnOirLv.js} +2 -2
- package/dist/assets/{layout-Ddsz1eHh.js → layout-DmbNDyY3.js} +3 -3
- package/dist/assets/{panels-D53vWR00.js → panels-BMikLSqU.js} +1 -1
- package/dist/assets/{reveal-component-C0L5MU2W.js → reveal-component-6t8SeOsr.js} +1 -1
- package/dist/assets/{run-page-DXZapRtY.js → run-page-BIyr61hZ.js} +1 -1
- package/dist/assets/{scratchpad-panel-ja6doGoa.js → scratchpad-panel-B2KUccqM.js} +1 -1
- package/dist/assets/{session-panel-ftyqfsYy.js → session-panel-1RH7Zh0c.js} +1 -1
- package/dist/assets/{skeleton-CxFczTPo.js → skeleton-DZV2_Wnl.js} +1 -1
- package/dist/assets/{useNotebookActions-DpphIKt5.js → useNotebookActions-BcAzvJBD.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +4 -2
- package/src/components/editor/file-tree/__tests__/file-render-mode.test.ts +3 -0
- package/src/components/editor/file-tree/__tests__/file-viewer.test.tsx +21 -0
- package/src/components/editor/file-tree/__tests__/renderers.test.tsx +129 -0
- package/src/components/editor/file-tree/file-viewer.tsx +1 -0
- package/src/components/editor/file-tree/renderers.tsx +27 -1
- package/src/components/storage/__tests__/storage-file-viewer.test.tsx +84 -0
- package/src/components/storage/storage-file-viewer.tsx +1 -0
- package/src/plugins/__tests__/plugin-schema.test.ts +343 -0
- package/src/plugins/__tests__/plugin-schema.ts +398 -0
- package/src/plugins/plugins.ts +1 -1
- package/dist/assets/file-explorer-panel-DaDDgJV2.js +0 -1
- package/src/components/editor/file-tree/__tests__/renderers.test.ts +0 -31
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { z, type ZodType } from "zod";
|
|
4
|
+
import type { PluginFunctions } from "../core/rpc";
|
|
5
|
+
import type { IPlugin } from "../types";
|
|
6
|
+
|
|
7
|
+
export type PluginContract = Pick<
|
|
8
|
+
IPlugin<unknown, unknown, PluginFunctions>,
|
|
9
|
+
"tagName" | "validator" | "functions"
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
export interface PluginOpenAPIDocument {
|
|
13
|
+
openapi: "3.1.0";
|
|
14
|
+
info: {
|
|
15
|
+
title: string;
|
|
16
|
+
version: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
tags: Array<{ name: string; description: string }>;
|
|
20
|
+
paths: Record<string, Record<string, unknown>>;
|
|
21
|
+
components: {
|
|
22
|
+
schemas: Record<string, Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UnrepresentableSchemaContext {
|
|
27
|
+
componentName: string;
|
|
28
|
+
path: PropertyKey[];
|
|
29
|
+
type: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface BuildPluginSpecOptions {
|
|
33
|
+
unrepresentableSchemaOverride?: (
|
|
34
|
+
context: UnrepresentableSchemaContext,
|
|
35
|
+
) => Record<string, unknown> | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const IDENTIFIER = /^[A-Za-z0-9._-]+$/;
|
|
39
|
+
const UNREPRESENTABLE_ZOD_TYPES = new Set([
|
|
40
|
+
"bigint",
|
|
41
|
+
"custom",
|
|
42
|
+
"date",
|
|
43
|
+
"function",
|
|
44
|
+
"map",
|
|
45
|
+
"nan",
|
|
46
|
+
"set",
|
|
47
|
+
"symbol",
|
|
48
|
+
"transform",
|
|
49
|
+
"undefined",
|
|
50
|
+
"void",
|
|
51
|
+
]);
|
|
52
|
+
const JSON_SCHEMA_SHAPE_KEYS = [
|
|
53
|
+
"$ref",
|
|
54
|
+
"allOf",
|
|
55
|
+
"anyOf",
|
|
56
|
+
"const",
|
|
57
|
+
"enum",
|
|
58
|
+
"not",
|
|
59
|
+
"oneOf",
|
|
60
|
+
"type",
|
|
61
|
+
] as const;
|
|
62
|
+
|
|
63
|
+
function assertIdentifier(value: string, kind: string): void {
|
|
64
|
+
if (!IDENTIFIER.test(value)) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`${kind} ${JSON.stringify(value)} must match ${IDENTIFIER.source}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function hasJSONSchemaShape(metadata: Record<string, unknown>): boolean {
|
|
72
|
+
return JSON_SCHEMA_SHAPE_KEYS.some((key) => key in metadata);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getZodSchemaType(schema: unknown): string {
|
|
76
|
+
const definitions = schema as unknown as {
|
|
77
|
+
def?: { type?: unknown };
|
|
78
|
+
_zod?: { def?: { type?: unknown } };
|
|
79
|
+
};
|
|
80
|
+
const type = definitions.def?.type ?? definitions._zod?.def?.type;
|
|
81
|
+
if (typeof type !== "string") {
|
|
82
|
+
throw new Error("Unable to determine the Zod schema type");
|
|
83
|
+
}
|
|
84
|
+
return type;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function rewriteSharedReference(
|
|
88
|
+
reference: string,
|
|
89
|
+
componentName: string,
|
|
90
|
+
): string {
|
|
91
|
+
const prefix = "#/components/schemas/__shared#/$defs/";
|
|
92
|
+
return reference.startsWith(prefix)
|
|
93
|
+
? `#/components/schemas/${componentName}.def.${reference.slice(prefix.length)}`
|
|
94
|
+
: reference;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function rewriteSharedReferences(
|
|
98
|
+
value: unknown,
|
|
99
|
+
componentName: string,
|
|
100
|
+
): unknown {
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
return value.map((item) => rewriteSharedReferences(item, componentName));
|
|
103
|
+
}
|
|
104
|
+
if (value === null || typeof value !== "object") {
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
return Object.fromEntries(
|
|
108
|
+
Object.entries(value).map(([key, item]) => [
|
|
109
|
+
key,
|
|
110
|
+
key === "$ref" && typeof item === "string"
|
|
111
|
+
? rewriteSharedReference(item, componentName)
|
|
112
|
+
: rewriteSharedReferences(item, componentName),
|
|
113
|
+
]),
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function withoutDocumentMetadata(
|
|
118
|
+
schema: Record<string, unknown>,
|
|
119
|
+
): Record<string, unknown> {
|
|
120
|
+
const { $id: _id, $schema: _schema, ...component } = schema;
|
|
121
|
+
return component;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function toComponentSchemas(
|
|
125
|
+
componentName: string,
|
|
126
|
+
schema: ZodType,
|
|
127
|
+
options: BuildPluginSpecOptions,
|
|
128
|
+
): Record<string, Record<string, unknown>> {
|
|
129
|
+
const registry = z.registry<{ id: string }>();
|
|
130
|
+
registry.add(schema, { id: componentName });
|
|
131
|
+
const unrepresentablePaths = new Set<string>();
|
|
132
|
+
// Zod may visit the same emitted path more than once, such as for both an
|
|
133
|
+
// underlying custom schema and its metadata-bearing clone. The path is valid
|
|
134
|
+
// when any visit provides an explicit JSON Schema representation.
|
|
135
|
+
const representedPaths = new Set<string>();
|
|
136
|
+
|
|
137
|
+
const result = z.toJSONSchema(registry, {
|
|
138
|
+
io: "input",
|
|
139
|
+
unrepresentable: "any",
|
|
140
|
+
uri: (id) => `#/components/schemas/${id}`,
|
|
141
|
+
override: ({ jsonSchema, path, zodSchema }) => {
|
|
142
|
+
const type = getZodSchemaType(zodSchema);
|
|
143
|
+
if (!UNREPRESENTABLE_ZOD_TYPES.has(type)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const pathKey = JSON.stringify(path);
|
|
148
|
+
const metadata = z.globalRegistry.get(zodSchema) ?? {};
|
|
149
|
+
if (hasJSONSchemaShape(metadata)) {
|
|
150
|
+
representedPaths.add(pathKey);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const override = options.unrepresentableSchemaOverride?.({
|
|
155
|
+
componentName,
|
|
156
|
+
path,
|
|
157
|
+
type,
|
|
158
|
+
});
|
|
159
|
+
if (override && hasJSONSchemaShape(override)) {
|
|
160
|
+
Object.assign(jsonSchema, override);
|
|
161
|
+
representedPaths.add(pathKey);
|
|
162
|
+
} else {
|
|
163
|
+
unrepresentablePaths.add(pathKey);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
for (const path of unrepresentablePaths) {
|
|
168
|
+
if (!representedPaths.has(path)) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
`Zod schema at ${path} in ${componentName} is not representable in JSON Schema; add explicit JSON Schema metadata with .meta(...) or a narrowly scoped test-only override`,
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const generated = result.schemas[componentName];
|
|
175
|
+
if (!generated) {
|
|
176
|
+
throw new Error(`Zod did not generate component ${componentName}`);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const components: Record<string, Record<string, unknown>> = {
|
|
180
|
+
[componentName]: withoutDocumentMetadata(
|
|
181
|
+
rewriteSharedReferences(generated, componentName) as Record<
|
|
182
|
+
string,
|
|
183
|
+
unknown
|
|
184
|
+
>,
|
|
185
|
+
),
|
|
186
|
+
};
|
|
187
|
+
const shared = result.schemas.__shared as
|
|
188
|
+
| { $defs?: Record<string, Record<string, unknown>> }
|
|
189
|
+
| undefined;
|
|
190
|
+
for (const [definitionName, definition] of Object.entries(
|
|
191
|
+
shared?.$defs ?? {},
|
|
192
|
+
)) {
|
|
193
|
+
const name = `${componentName}.def.${definitionName}`;
|
|
194
|
+
assertIdentifier(name, "Generated definition name");
|
|
195
|
+
components[name] = withoutDocumentMetadata(
|
|
196
|
+
rewriteSharedReferences(definition, componentName) as Record<
|
|
197
|
+
string,
|
|
198
|
+
unknown
|
|
199
|
+
>,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
return components;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function operationSuffix(componentName: string): string {
|
|
206
|
+
return componentName.replaceAll(/[^A-Za-z0-9]+/g, "_");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function addBidirectionalContract({
|
|
210
|
+
paths,
|
|
211
|
+
operationIds,
|
|
212
|
+
path,
|
|
213
|
+
componentName,
|
|
214
|
+
summary,
|
|
215
|
+
tag,
|
|
216
|
+
}: {
|
|
217
|
+
paths: Record<string, Record<string, unknown>>;
|
|
218
|
+
operationIds: Set<string>;
|
|
219
|
+
path: string;
|
|
220
|
+
componentName: string;
|
|
221
|
+
summary: string;
|
|
222
|
+
tag: string;
|
|
223
|
+
}): void {
|
|
224
|
+
if (paths[path]) {
|
|
225
|
+
throw new Error(`Duplicate OpenAPI path ${path}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const suffix = operationSuffix(componentName);
|
|
229
|
+
const readOperationId = `read_${suffix}`;
|
|
230
|
+
const writeOperationId = `write_${suffix}`;
|
|
231
|
+
for (const operationId of [readOperationId, writeOperationId]) {
|
|
232
|
+
if (operationIds.has(operationId)) {
|
|
233
|
+
throw new Error(`Duplicate OpenAPI operationId ${operationId}`);
|
|
234
|
+
}
|
|
235
|
+
operationIds.add(operationId);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const ref = { $ref: `#/components/schemas/${componentName}` };
|
|
239
|
+
paths[path] = {
|
|
240
|
+
summary,
|
|
241
|
+
get: {
|
|
242
|
+
operationId: readOperationId,
|
|
243
|
+
summary: `Read ${summary}`,
|
|
244
|
+
tags: [tag],
|
|
245
|
+
responses: {
|
|
246
|
+
"200": {
|
|
247
|
+
description: `${summary} accepted by a plugin consumer.`,
|
|
248
|
+
content: { "application/json": { schema: ref } },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
put: {
|
|
253
|
+
operationId: writeOperationId,
|
|
254
|
+
summary: `Write ${summary}`,
|
|
255
|
+
tags: [tag],
|
|
256
|
+
requestBody: {
|
|
257
|
+
required: true,
|
|
258
|
+
content: { "application/json": { schema: ref } },
|
|
259
|
+
},
|
|
260
|
+
responses: { "204": { description: "Accepted." } },
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function assertLocalReferencesResolve(document: PluginOpenAPIDocument): void {
|
|
266
|
+
const visit = (value: unknown): void => {
|
|
267
|
+
if (Array.isArray(value)) {
|
|
268
|
+
value.forEach(visit);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (value === null || typeof value !== "object") {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const record = value as Record<string, unknown>;
|
|
276
|
+
const ref = record.$ref;
|
|
277
|
+
if (typeof ref === "string") {
|
|
278
|
+
if (ref.startsWith("#/$defs")) {
|
|
279
|
+
throw new Error(`Dangling document-root Zod reference ${ref}`);
|
|
280
|
+
}
|
|
281
|
+
const prefix = "#/components/schemas/";
|
|
282
|
+
if (
|
|
283
|
+
ref.startsWith(prefix) &&
|
|
284
|
+
!document.components.schemas[ref.slice(prefix.length)]
|
|
285
|
+
) {
|
|
286
|
+
throw new Error(`Unresolved OpenAPI component reference ${ref}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
Object.values(record).forEach(visit);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
visit(document);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Build a synthetic OpenAPI document for the Zod-backed plugin contracts.
|
|
297
|
+
*
|
|
298
|
+
* Each schema is exposed as both a response and request so compatibility
|
|
299
|
+
* checks catch narrowing/removals as well as newly required fields. The paths
|
|
300
|
+
* describe internal frontend/kernel contracts; they are not HTTP endpoints.
|
|
301
|
+
*/
|
|
302
|
+
export function buildPluginSpec(
|
|
303
|
+
plugins: readonly PluginContract[],
|
|
304
|
+
options: BuildPluginSpecOptions = {},
|
|
305
|
+
): PluginOpenAPIDocument {
|
|
306
|
+
const paths: Record<string, Record<string, unknown>> = {};
|
|
307
|
+
const schemas: Record<string, Record<string, unknown>> = {};
|
|
308
|
+
const operationIds = new Set<string>();
|
|
309
|
+
const tagNames = new Set<string>();
|
|
310
|
+
|
|
311
|
+
const addComponent = (name: string, schema: ZodType): void => {
|
|
312
|
+
assertIdentifier(name, "Component name");
|
|
313
|
+
const generated = toComponentSchemas(name, schema, options);
|
|
314
|
+
for (const [generatedName, generatedSchema] of Object.entries(generated)) {
|
|
315
|
+
if (schemas[generatedName]) {
|
|
316
|
+
throw new Error(`Duplicate OpenAPI component ${generatedName}`);
|
|
317
|
+
}
|
|
318
|
+
schemas[generatedName] = generatedSchema;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
for (const plugin of [...plugins].toSorted((a, b) =>
|
|
323
|
+
a.tagName.localeCompare(b.tagName),
|
|
324
|
+
)) {
|
|
325
|
+
assertIdentifier(plugin.tagName, "Plugin tag name");
|
|
326
|
+
if (tagNames.has(plugin.tagName)) {
|
|
327
|
+
throw new Error(`Duplicate plugin tag name ${plugin.tagName}`);
|
|
328
|
+
}
|
|
329
|
+
tagNames.add(plugin.tagName);
|
|
330
|
+
|
|
331
|
+
const dataComponent = `${plugin.tagName}.data`;
|
|
332
|
+
addComponent(dataComponent, plugin.validator);
|
|
333
|
+
addBidirectionalContract({
|
|
334
|
+
paths,
|
|
335
|
+
operationIds,
|
|
336
|
+
path: `/plugins/${plugin.tagName}/data`,
|
|
337
|
+
componentName: dataComponent,
|
|
338
|
+
summary: `${plugin.tagName} data`,
|
|
339
|
+
tag: "plugin-data",
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const functions = Object.entries(plugin.functions ?? {}).toSorted(
|
|
343
|
+
([a], [b]) => a.localeCompare(b),
|
|
344
|
+
);
|
|
345
|
+
for (const [functionName, contract] of functions) {
|
|
346
|
+
assertIdentifier(functionName, "Plugin function name");
|
|
347
|
+
for (const [direction, schema] of [
|
|
348
|
+
["input", contract.input],
|
|
349
|
+
["output", contract.output],
|
|
350
|
+
] as const) {
|
|
351
|
+
const componentName = `${plugin.tagName}.${functionName}.${direction}`;
|
|
352
|
+
addComponent(componentName, schema);
|
|
353
|
+
addBidirectionalContract({
|
|
354
|
+
paths,
|
|
355
|
+
operationIds,
|
|
356
|
+
path: `/plugins/${plugin.tagName}/functions/${functionName}/${direction}`,
|
|
357
|
+
componentName,
|
|
358
|
+
summary: `${plugin.tagName} ${functionName} ${direction}`,
|
|
359
|
+
tag: `rpc-${direction}`,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const document: PluginOpenAPIDocument = {
|
|
366
|
+
openapi: "3.1.0",
|
|
367
|
+
info: {
|
|
368
|
+
title: "marimo plugin contracts",
|
|
369
|
+
version: "1.0.0",
|
|
370
|
+
description: [
|
|
371
|
+
"Machine-checkable description of every registered frontend plugin's",
|
|
372
|
+
"Zod-backed data and RPC contracts. This is not an HTTP API: each",
|
|
373
|
+
"synthetic GET models what consumers must accept and each PUT models",
|
|
374
|
+
"what producers may write, allowing OpenAPI diff tooling to enforce",
|
|
375
|
+
"backward compatibility in both directions.",
|
|
376
|
+
"Regenerate with: pnpm --filter @marimo-team/frontend plugins:generate-schema",
|
|
377
|
+
].join("\n"),
|
|
378
|
+
},
|
|
379
|
+
tags: [
|
|
380
|
+
{
|
|
381
|
+
name: "plugin-data",
|
|
382
|
+
description: "Data supplied when rendering a plugin.",
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "rpc-input",
|
|
386
|
+
description: "Arguments supplied to a plugin RPC function.",
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: "rpc-output",
|
|
390
|
+
description: "Values returned by a plugin RPC function.",
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
paths,
|
|
394
|
+
components: { schemas },
|
|
395
|
+
};
|
|
396
|
+
assertLocalReferencesResolve(document);
|
|
397
|
+
return document;
|
|
398
|
+
}
|
package/src/plugins/plugins.ts
CHANGED
|
@@ -97,7 +97,7 @@ export const UI_PLUGINS: IPlugin<any, unknown>[] = [
|
|
|
97
97
|
];
|
|
98
98
|
|
|
99
99
|
// List of output / layout plugins
|
|
100
|
-
const LAYOUT_PLUGINS: IStatelessPlugin<unknown>[] = [
|
|
100
|
+
export const LAYOUT_PLUGINS: IStatelessPlugin<unknown>[] = [
|
|
101
101
|
new AccordionPlugin(),
|
|
102
102
|
new CalloutPlugin(),
|
|
103
103
|
new CarouselPlugin(),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{c as t,f as n,l as r,t as i}from"./useEvent-xfs0Sn4r.js";import{t as a}from"./react-CBDbhulC.js";import{At as o,Ct as s,Dn as c,Dt as l,E as u,Et as d,Ht as f,Ot as p,Tt as m,bn as h,bo as g,gn as _,go as v,ia as y,kt as b,ni as x,wt as S,xn as C}from"./cells-B1S_6FG3.js";import{t as w}from"./compiler-runtime-CYIjoINj.js";import{g as T}from"./useEventListener-D27Dii_l.js";import{t as E}from"./invariant-Ci2dTZ72.js";import{g as D,p as O}from"./utils-R_pHe-RB.js";import{N as k,r as A}from"./config-CUBl5qBg.js";import{t as j}from"./cn-ldLVeaqm.js";import{t as M}from"./jsx-runtime-B74pBk57.js";import{r as N}from"./config-DcB2swfZ.js";import{o as P}from"./alert-dialog-DBoy-FMx.js";import{a as F,c as I,p as L,r as R,t as z}from"./dropdown-menu-CqNabM1f.js";import{Pt as B,a as V,h as H,i as U,o as W,s as G}from"./JsonOutput-BI2qFHVr.js";import{c as K,n as ee,r as te}from"./download-CIdXYNHv.js";import{t as q}from"./tooltip-D7dq6bnc.js";import{t as J}from"./button-BMBznEru.js";import{Tt as ne}from"./dist-PIe1xcZo.js";import{n as Y,r as re,t as ie}from"./requests-C6_IaFh7.js";import{t as X}from"./createLucideIcon-B7HeEoG2.js";import{t as ae}from"./arrow-left-DrqK6gPp.js";import{n as oe}from"./LazyAnyLanguageCodeMirror-YVX2AZaI.js";import{r as se}from"./useNumberFormatter-DHJ9s6Vk.js";import{a as ce,i as le,n as ue,r as de,t as fe}from"./tree-actions-CrWpuExP.js";import{a as pe}from"./markdown-renderer-DIXiKP4m.js";import{u as me}from"./toDate-hGYJX0Ha.js";import{t as he}from"./copy-BMXKNElG.js";import{t as ge}from"./external-link-Bp3BxyRA.js";import{a as _e,i as ve,n as ye,r as be,t as xe}from"./file-icons-Bo1Ewf1W.js";import{t as Se}from"./file-DF8n85RA.js";import{n as Ce,t as we}from"./components-DwH_Yb1N.js";import{b as Te}from"./write-secret-modal-BG_B6y1P.js";import{n as Ee,t as De}from"./spinner-Ck-Hgfvj.js";import{a as Oe,c as ke,d as Ae,f as je,i as Me,l as Ne,n as Pe,r as Fe,t as Ie,u as Le}from"./file-name-input-BeYyD2dj.js";import{t as Re}from"./refresh-cw-Bf-rx_aV.js";import{t as ze}from"./save-BybsbOKz.js";import{t as Be}from"./triangle-alert-MihykDYG.js";import{n as Ve,t as He}from"./es-BuMFDpR4.js";import{t as Ue}from"./use-toast-DpWHUGuF.js";import{n as We,t as Ge}from"./paths-zcL04qUW.js";import{t as Ke}from"./context-Do8M9TDF.js";import{n as qe}from"./useAsyncData-Buhk-UgR.js";import{n as Je}from"./copy-Cg05mM3C.js";import{t as Ye}from"./copy-icon-LPQzn7_f.js";import{t as Xe}from"./blob-BBiZd3vX.js";import{a as Ze}from"./errors-DzO-nXy-.js";import{n as Qe,t as $e}from"./alert-dmKwNsrp.js";import{n as et}from"./error-banner-B3KYUlCX.js";import{a as tt}from"./renderShortcut-D9XYVNe3.js";import{t as nt}from"./bundle.esm-DzY74mzC.js";import{t as rt}from"./useAddCell-DIdbaU70.js";import{n as it}from"./pathUtils-Cryrlpma.js";import{n as at}from"./semaphore-BjoL5P0h.js";import{t as ot}from"./empty-state-kWyb5dCS.js";import{t as st}from"./formatting-BJlT1s_3.js";import{a as ct,i as lt,n as ut,o as dt,r as ft,s as pt,t as mt}from"./components-BAvTsivu.js";import{n as ht,t as gt}from"./marimo-icons-C3KxMV9A.js";import{t as _t}from"./links-DPh7yoP-.js";import{n as vt}from"./panel-accordion-state-DmV3OgfX.js";var yt=X(`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`}]]),bt=X(`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`}]]),xt=X(`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`}]]),St=X(`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`}]]),Ct=X(`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`}]]),wt=X(`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`}]]),Tt=X(`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`}]]),Et=X(`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`}]]),Z=e(a(),1),Q=w(),$=M(),Dt=e=>{let t=(0,Q.c)(17),{filename:n,filenameIcon:r,onBack:i,onRefresh:a,onDownload:o,actions:s}=e,c;t[0]===i?c=t[1]:(c=i&&(0,$.jsx)(q,{content:`Back to file list`,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:i,children:(0,$.jsx)(ae,{className:`h-4 w-4`})})}),t[0]=i,t[1]=c);let l;t[2]!==n||t[3]!==r?(l=n?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 flex-1 min-w-0 text-xs font-semibold truncate`,children:[r,n]}):(0,$.jsx)(`span`,{className:`flex-1`}),t[2]=n,t[3]=r,t[4]=l):l=t[4];let u;t[5]===a?u=t[6]:(u=a&&(0,$.jsx)(q,{content:`Refresh`,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:a,children:(0,$.jsx)(Re,{className:`h-3.5 w-3.5`})})}),t[5]=a,t[6]=u);let d;t[7]===o?d=t[8]:(d=o&&(0,$.jsx)(q,{content:`Download`,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:o,children:(0,$.jsx)(B,{className:`h-3.5 w-3.5`})})}),t[7]=o,t[8]=d);let f;t[9]!==s||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[u,s,d]}),t[9]=s,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==c||t[14]!==l||t[15]!==f?(p=(0,$.jsxs)(`div`,{className:`flex items-center shrink-0 border-b px-1 gap-1`,children:[c,l,f]}),t[13]=c,t[14]=l,t[15]=f,t[16]=p):p=t[16],p},Ot=new Set([`http`,`file`,`in-memory`]);function kt(e){return JSON.stringify(e).slice(1,-1)}var At=new Set([`datasets`,`spaces`,`buckets`]);function jt(e){let t=e.split(`/`).filter(Boolean);return t[0]===`datasets`&&t.length>=4?{repoType:`dataset`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t[0]===`spaces`&&t.length>=4?{repoType:`space`,repoId:`${t[1]}/${t[2]}`,filename:t.slice(3).join(`/`)}:t.length>=3&&!At.has(t[0])?{repoType:`model`,repoId:`${t[0]}/${t[1]}`,filename:t.slice(2).join(`/`)}:null}function Mt(e){return`from huggingface_hub import hf_hub_download\n\nlocal_path = hf_hub_download(\n repo_id="${kt(e.repoId)}",\n filename="${kt(e.filename)}",\n repo_type="${kt(e.repoType)}",\n)`}var Nt=[{id:`read-file`,label:`Insert read snippet`,icon:yt,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=kt(e.entry.path);if(e.backendType===`huggingface`){let t=jt(e.entry.path);return t?`${Mt(t)}\n\nwith open(local_path, "rb") as f:\n _data = f.read()\n_data`:null}return e.backendType===`obstore`?`_data = ${e.variableName}.get("${t}").bytes()\n_data`:`_data = ${e.variableName}.cat_file("${t}")\n_data`}},{id:`download-file`,label:`Insert download snippet`,icon:St,getCode:e=>{if(e.entry.kind===`directory`)return null;let t=kt(e.entry.path);if(e.backendType===`huggingface`){let t=jt(e.entry.path);return t?`${Mt(t)}\nlocal_path`:null}if(e.backendType===`obstore`)return Ot.has(e.protocol)?null:`from datetime import timedelta\nfrom obstore import sign\n\nsigned_url = sign(\n ${e.variableName}, "GET", "${t}",\n expires_in=timedelta(hours=1),\n)\nsigned_url`;let n=kt(e.entry.path.split(`/`).pop()||`download`);return`${e.variableName}.get("${t}", "${n}")`}}],Pt=104857600;function Ft(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}var It=e=>{let t=(0,Q.c)(82),{entry:n,namespace:r,protocol:i,backendType:a,onBack:s}=e,{locale:c}=Ke(),l=rt(),u;t[0]===n.path?u=t[1]:(u=Ft(n.path),t[0]=n.path,t[1]=u);let d=u,f=n.mimeType||`text/plain`,p;t[2]===f?p=t[3]:(p=G(f),t[2]=f,t[3]=p);let m=p,h=m&&n.size>Pt&&n.size>0,g,_;t[4]!==n.path||t[5]!==m||t[6]!==r||t[7]!==h?(g=async()=>{if(h)return null;let e=await o.request({namespace:r,path:n.path,preview:!m});if(e.error)throw Error(e.error);if(!e.url)throw Error(`No URL returned`);if(m)return{type:`media`,url:e.url};let t=await fetch(e.url);if(!t.ok)throw Error(`Failed to fetch preview: ${t.statusText}`);return{type:`text`,content:await t.text()}},_=[r,n.path,m,h],t[4]=n.path,t[5]=m,t[6]=r,t[7]=h,t[8]=g,t[9]=_):(g=t[8],_=t[9]);let{data:v,isPending:y,error:b,refetch:x}=qe(g,_),S;t[10]!==n.path||t[11]!==d||t[12]!==r?(S=async()=>{try{let e=await o.request({namespace:r,path:n.path});if(e.error){Ue({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&te(e.url,e.filename??d)}catch(e){let t=e;T.error(`Failed to download storage entry`,t),Ue({title:`Download failed`,description:String(t),variant:`danger`})}},t[10]=n.path,t[11]=d,t[12]=r,t[13]=S):S=t[13];let C=S,w;t[14]!==l||t[15]!==a||t[16]!==n||t[17]!==r||t[18]!==i?(w=Nt.map(e=>{let t=e.getCode({variableName:r,protocol:i,entry:n,backendType:a});if(t===null)return null;let o=e.icon;return(0,$.jsx)(q,{content:e.label,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:()=>l(t),"aria-label":e.label,children:(0,$.jsx)(o,{className:`h-3.5 w-3.5`})})},e.id)}),t[14]=l,t[15]=a,t[16]=n,t[17]=r,t[18]=i,t[19]=w):w=t[19];let E=w,D;t[20]===d?D=t[21]:(D=ve(d),t[20]=d,t[21]=D);let O;t[22]!==C||t[23]!==d||t[24]!==s||t[25]!==E||t[26]!==D?(O=(0,$.jsx)(Dt,{filename:d,filenameIcon:D,onBack:s,onDownload:C,actions:E}),t[22]=C,t[23]=d,t[24]=s,t[25]=E,t[26]=D,t[27]=O):O=t[27];let k=O,A;t[28]!==n.lastModified||t[29]!==n.path||t[30]!==n.size||t[31]!==c||t[32]!==f?(A=e=>{let{includeMime:t}=e,r=t!==void 0&&t;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 p-4 text-xs`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),(0,$.jsxs)(`div`,{className:`truncate flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[11px]`,children:n.path}),(0,$.jsx)(Ye,{value:n.path,className:`h-3 w-3`})]}),r&&(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),r&&(0,$.jsx)(`span`,{children:f}),n.size>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:st(n.size,c)})]}),n.lastModified!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Modified`}),(0,$.jsx)(`span`,{children:new Date(n.lastModified*1e3).toLocaleString()})]})]})},t[28]=n.lastModified,t[29]=n.path,t[30]=n.size,t[31]=c,t[32]=f,t[33]=A):A=t[33];let j=A;if(h){let e;t[34]===j?e=t[35]:(e=j({includeMime:!0}),t[34]=j,t[35]=e);let r;t[36]!==n.size||t[37]!==c?(r=st(n.size,c),t[36]=n.size,t[37]=c,t[38]=r):r=t[38];let i;t[39]===r?i=t[40]:(i=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-muted-foreground italic`,children:[`File is too large to preview (`,r,`).`]}),t[39]=r,t[40]=i);let a;return t[41]!==k||t[42]!==e||t[43]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[41]=k,t[42]=e,t[43]=i,t[44]=a):a=t[44],a}if(y){let e;t[45]===j?e=t[46]:(e=j({}),t[45]=j,t[46]=e);let n;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-2 text-xs text-muted-foreground min-h-24`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4 animate-spin`}),`Loading preview...`]}),t[47]=n):n=t[47];let r;return t[48]!==k||t[49]!==e?(r=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n]}),t[48]=k,t[49]=e,t[50]=r):r=t[50],r}if(b){let e;t[51]===j?e=t[52]:(e=j({includeMime:!0}),t[51]=j,t[52]=e);let n;t[53]===b.message?n=t[54]:(n=(0,$.jsxs)(`div`,{className:`px-4 pb-4 text-xs text-destructive`,children:[`Failed to load preview: `,b.message]}),t[53]=b.message,t[54]=n);let r;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Re,{className:`h-3 w-3 mr-1`}),t[55]=r):r=t[55];let i;t[56]===x?i=t[57]:(i=(0,$.jsx)(`div`,{className:`px-4 pb-4`,children:(0,$.jsxs)(J,{variant:`secondary`,size:`xs`,onClick:x,children:[r,`Retry`]})}),t[56]=x,t[57]=i);let a;return t[58]!==k||t[59]!==e||t[60]!==n||t[61]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,n,i]}),t[58]=k,t[59]=e,t[60]=n,t[61]=i,t[62]=a):a=t[62],a}if(v){let e;t[63]===j?e=t[64]:(e=j({}),t[63]=j,t[64]=e);let n=v.type===`text`?v.content:void 0,r;t[65]!==v.type||t[66]!==v.url?(r=v.type===`media`?{url:v.url}:void 0,t[65]=v.type,t[66]=v.url,t[67]=r):r=t[67];let i;t[68]!==f||t[69]!==n||t[70]!==r?(i=(0,$.jsx)(U,{mimeType:f,contents:n,mediaSource:r}),t[68]=f,t[69]=n,t[70]=r,t[71]=i):i=t[71];let a;return t[72]!==k||t[73]!==e||t[74]!==i?(a=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,e,i]}),t[72]=k,t[73]=e,t[74]=i,t[75]=a):a=t[75],a}let M;t[76]===j?M=t[77]:(M=j({includeMime:!0}),t[76]=j,t[77]=M);let N;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsxs)(`div`,{className:`p-4 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(Se,{className:`h-4 w-4`}),`Preview not available for this file type.`]}),t[78]=N):N=t[78];let P;return t[79]!==k||t[80]!==M?(P=(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[k,M,N]}),t[79]=k,t[80]=M,t[81]=P):P=t[81],P},Lt=16;function Rt(e){return{paddingLeft:e*Lt}}function zt(e,t){return new Date(e*1e3).toLocaleDateString(t,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Bt(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.split(`/`);return n[n.length-1]||t}function Vt(e){return e.endsWith(`/`)?e:`${e}/`}function Ht(e,t){let n=e.metadata?.id;return typeof n==`string`&&n.length>0?n:`${e.path}::${t}`}function Ut(e,{namespace:t,searchValue:n,entriesByPath:r}){let i=n.trim().toLowerCase(),a=e.path.toLowerCase();if(Bt(e.path).toLowerCase().includes(i)||a.includes(i))return!0;if(e.kind===`directory`){let i=r.get(b(t,Vt(e.path)));if(i)return i.some(e=>Ut(e,{namespace:t,searchValue:n,entriesByPath:r}))}return!1}function Wt(e,t){return t.searchValue.trim()?e.filter(e=>Ut(e,t)):e}var Gt=5;function Kt(e){return{query:e,status:`idle`}}function qt(e){return e.status===`idle`||e.status===`error`||e.status===`capped`}function Jt(e,t,n){return t.get(e)===void 0||n.get(e)?.nextPageToken!=null}function Yt({hasSearch:e,hasLoadedMatches:t,isPending:n,remoteSearch:r,searchKey:i,entriesByPath:a,pageMetadataByPath:o}){return!e||t||n||!qt(r)?!1:Jt(i,a,o)}function Xt(e){let t=e.trim(),n=t.lastIndexOf(`/`);return n===-1?``:t.slice(0,n+1)}function Zt(e,t){let n=t.trim().toLowerCase();return!n||e.path.toLowerCase().includes(n)||Bt(e.path).toLowerCase().includes(n)}var Qt=e=>{let t=(0,Q.c)(15),{depth:n,isLoading:r,error:i,onLoadMore:a}=e,o;t[0]===n?o=t[1]:(o=Rt(n),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=r&&(0,$.jsx)(Ee,{className:`h-3 w-3 mr-1 animate-spin`}),t[2]=r,t[3]=s);let c=r?`Loading...`:`Load more`,l;t[4]!==r||t[5]!==a||t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(J,{variant:`text`,size:`xs`,className:`h-6 px-0 hover:text-blue-600`,disabled:r,onClick:a,children:[s,c]}),t[4]=r,t[5]=a,t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===i?u=t[10]:(u=i&&(0,$.jsxs)(`span`,{className:`ml-2 text-destructive`,children:[`Failed to load: `,i.message]}),t[9]=i,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`div`,{className:`py-px text-xs`,style:o,children:[l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d},$t=e=>{let t=(0,Q.c)(44),{namespace:n,protocol:r,rootPath:i,backendType:a,prefix:o,depth:s,locale:c,searchValue:u,onOpenFile:d}=e,{entriesByPath:f}=m(),{entries:p,isPending:h,error:g,hasMore:_,loadMore:v,isLoadingMore:y,loadMoreError:b}=l(n,o);if(h){let e;t[0]===s?e=t[1]:(e=Rt(s),t[0]=s,t[1]=e);let n;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(Ee,{className:`h-3 w-3 animate-spin`}),t[2]=n):n=t[2];let r;return t[3]===e?r=t[4]:(r=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1 text-xs text-muted-foreground`,style:e,children:[n,`Loading...`]}),t[3]=e,t[4]=r),r}if(g){let e;t[5]===s?e=t[6]:(e=Rt(s),t[5]=s,t[6]=e);let n;return t[7]!==g.message||t[8]!==e?(n=(0,$.jsxs)(`div`,{className:`py-1 text-xs text-destructive`,style:e,children:[`Failed to load: `,g.message]}),t[7]=g.message,t[8]=e,t[9]=n):n=t[9],n}if(p.length===0){let e;t[10]===s?e=t[11]:(e=Rt(s),t[10]=s,t[11]=e);let n;return t[12]===e?n=t[13]:(n=(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:e,children:`Empty`}),t[12]=e,t[13]=n),n}let x;if(t[14]!==a||t[15]!==p||t[16]!==s||t[17]!==f||t[18]!==c||t[19]!==n||t[20]!==d||t[21]!==r||t[22]!==i||t[23]!==u){let e=Wt(p,{namespace:n,searchValue:u,entriesByPath:f}),o;t[25]!==a||t[26]!==p||t[27]!==s||t[28]!==c||t[29]!==n||t[30]!==d||t[31]!==r||t[32]!==i||t[33]!==u?(o=e=>{let t=Ht(e,p.indexOf(e));return(0,$.jsx)(en,{rowKey:t,entry:e,namespace:n,protocol:r,rootPath:i,backendType:a,depth:s,locale:c,searchValue:u,onOpenFile:d},t)},t[25]=a,t[26]=p,t[27]=s,t[28]=c,t[29]=n,t[30]=d,t[31]=r,t[32]=i,t[33]=u,t[34]=o):o=t[34],x=e.map(o),t[14]=a,t[15]=p,t[16]=s,t[17]=f,t[18]=c,t[19]=n,t[20]=d,t[21]=r,t[22]=i,t[23]=u,t[24]=x}else x=t[24];let S;t[35]!==s||t[36]!==_||t[37]!==y||t[38]!==v||t[39]!==b?(S=_&&(0,$.jsx)(Qt,{depth:s,isLoading:y,error:b,onLoadMore:v}),t[35]=s,t[36]=_,t[37]=y,t[38]=v,t[39]=b,t[40]=S):S=t[40];let C;return t[41]!==x||t[42]!==S?(C=(0,$.jsxs)($.Fragment,{children:[x,S]}),t[41]=x,t[42]=S,t[43]=C):C=t[43],C},en=e=>{let t=(0,Q.c)(115),{entry:n,rowKey:r,namespace:i,protocol:a,rootPath:s,backendType:c,depth:l,locale:u,searchValue:d,onOpenFile:f}=e,[p,h]=(0,Z.useState)(!1),{entriesByPath:g}=m(),_=rt(),v=n.kind===`directory`,y,x,S,w,E,D,O,k,A,M,N;if(t[0]!==c||t[1]!==l||t[2]!==g||t[3]!==n||t[4]!==v||t[5]!==p||t[6]!==i||t[7]!==f||t[8]!==a||t[9]!==r||t[10]!==d){w=Bt(n.path);let e;t[22]===d?e=t[23]:(e=d.trim(),t[22]=d,t[23]=e);let s=!!e;E=v&&s&&w.toLowerCase().includes(d.trim().toLowerCase());let u;t[24]!==g||t[25]!==n.path||t[26]!==s||t[27]!==v||t[28]!==i||t[29]!==d?(u=v&&s&&!!g.get(b(i,Vt(n.path)))?.some(e=>Ut(e,{namespace:i,searchValue:d,entriesByPath:g})),t[24]=g,t[25]=n.path,t[26]=s,t[27]=v,t[28]=i,t[29]=d,t[30]=u):u=t[30],x=p||u;let m;t[31]!==n.path||t[32]!==i?(m=async()=>{try{let e=await o.request({namespace:i,path:n.path});if(e.error){Ue({title:`Download failed`,description:e.error,variant:`danger`});return}e.url&&te(e.url,e.filename??`download`)}catch(e){let t=e;T.error(`Failed to download storage entry`,t),Ue({title:`Download failed`,description:String(t),variant:`danger`})}},t[31]=n.path,t[32]=i,t[33]=m):m=t[33],S=m,y=C;let _=v&&`font-medium`;t[34]===_?D=t[35]:(D=j(`text-xs flex items-center gap-1.5 cursor-pointer rounded-none group h-6.5`,_),t[34]=_,t[35]=D),t[36]===l?O=t[37]:(O=Rt(l),t[36]=l,t[37]=O),k=`${i}:${r}`,t[38]!==c||t[39]!==x||t[40]!==n||t[41]!==v||t[42]!==i||t[43]!==f||t[44]!==a?(A=()=>{v?h(!x):f({entry:n,namespace:i,protocol:a,backendType:c})},t[38]=c,t[39]=x,t[40]=n,t[41]=v,t[42]=i,t[43]=f,t[44]=a,t[45]=A):A=t[45],t[46]!==x||t[47]!==v?(M=v?(0,$.jsx)(le,{isExpanded:x,className:`h-3 w-3`}):(0,$.jsx)(`span`,{className:`w-3 shrink-0`}),t[46]=x,t[47]=v,t[48]=M):M=t[48],N=v?(0,$.jsx)(_e,{className:j(`h-3.5 w-3.5 shrink-0`,ye.directory)}):ve(w),t[0]=c,t[1]=l,t[2]=g,t[3]=n,t[4]=v,t[5]=p,t[6]=i,t[7]=f,t[8]=a,t[9]=r,t[10]=d,t[11]=y,t[12]=x,t[13]=S,t[14]=w,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=M,t[21]=N}else y=t[11],x=t[12],S=t[13],w=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],M=t[20],N=t[21];let P;t[49]===w?P=t[50]:(P=(0,$.jsx)(`span`,{className:`truncate flex-1 text-left`,children:w}),t[49]=w,t[50]=P);let V;t[51]!==n.size||t[52]!==u?(V=n.size>0&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-2 opacity-0 group-hover:opacity-100 transition-opacity tabular-nums`,children:st(n.size,u)}),t[51]=n.size,t[52]=u,t[53]=V):V=t[53];let H;t[54]!==n.lastModified||t[55]!==u?(H=n.lastModified!=null&&(0,$.jsx)(q,{content:`Last modified: ${new Date(n.lastModified*1e3).toLocaleString()}`,children:(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground pr-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap`,children:zt(n.lastModified,u)})}),t[54]=n.lastModified,t[55]=u,t[56]=H):H=t[56];let U;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(L,{asChild:!0,children:(0,$.jsx)(ue,{iconClassName:`h-3 w-3`,onClick:rn})}),t[57]=U):U=t[57];let W;t[58]!==c||t[59]!==n||t[60]!==v||t[61]!==i||t[62]!==f||t[63]!==a?(W=!v&&(0,$.jsxs)(F,{onSelect:()=>f({entry:n,namespace:i,protocol:a,backendType:c}),children:[(0,$.jsx)(Et,{className:`h-3.5 w-3.5 mr-2`}),`View`]}),t[58]=c,t[59]=n,t[60]=v,t[61]=i,t[62]=f,t[63]=a,t[64]=W):W=t[64];let G;t[65]===n.path?G=t[66]:(G=async()=>{await Je(n.path),Ue({title:`Copied to clipboard`})},t[65]=n.path,t[66]=G);let K;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(he,{className:fe}),t[67]=K):K=t[67];let ee;t[68]===G?ee=t[69]:(ee=(0,$.jsxs)(F,{onSelect:G,children:[K,`Copy path`]}),t[68]=G,t[69]=ee);let J;t[70]!==S||t[71]!==v?(J=!v&&(0,$.jsxs)(F,{onSelect:()=>S(),children:[(0,$.jsx)(B,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[70]=S,t[71]=v,t[72]=J):J=t[72];let ne;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(I,{}),t[73]=ne):ne=t[73];let Y;t[74]!==_||t[75]!==c||t[76]!==n||t[77]!==i||t[78]!==a?(Y=Nt.map(e=>{let t=e.getCode({variableName:i,protocol:a,entry:n,backendType:c});if(t===null)return null;let r=e.icon;return(0,$.jsxs)(F,{onSelect:()=>_(t),children:[(0,$.jsx)(r,{className:fe}),e.label]},e.id)}),t[74]=_,t[75]=c,t[76]=n,t[77]=i,t[78]=a,t[79]=Y):Y=t[79];let re;t[80]!==W||t[81]!==ee||t[82]!==J||t[83]!==Y?(re=(0,$.jsxs)(z,{children:[U,(0,$.jsxs)(R,{align:`end`,onClick:an,onCloseAutoFocus:on,children:[W,ee,J,ne,Y]})]}),t[80]=W,t[81]=ee,t[82]=J,t[83]=Y,t[84]=re):re=t[84];let ie;t[85]!==re||t[86]!==V||t[87]!==H?(ie=(0,$.jsxs)(`div`,{className:`flex items-center`,children:[V,H,re]}),t[85]=re,t[86]=V,t[87]=H,t[88]=ie):ie=t[88];let X;t[89]!==y||t[90]!==D||t[91]!==ie||t[92]!==O||t[93]!==k||t[94]!==A||t[95]!==M||t[96]!==N||t[97]!==P?(X=(0,$.jsxs)(y,{className:D,style:O,value:k,onSelect:A,children:[M,N,P,ie]}),t[89]=y,t[90]=D,t[91]=ie,t[92]=O,t[93]=k,t[94]=A,t[95]=M,t[96]=N,t[97]=P,t[98]=X):X=t[98];let ae;t[99]!==c||t[100]!==l||t[101]!==x||t[102]!==n.path||t[103]!==v||t[104]!==u||t[105]!==i||t[106]!==f||t[107]!==a||t[108]!==s||t[109]!==d||t[110]!==E?(ae=v&&x&&(0,$.jsx)($t,{namespace:i,protocol:a,rootPath:s,backendType:c,prefix:Vt(n.path),depth:l+1,locale:u,searchValue:E?``:d,onOpenFile:f}),t[99]=c,t[100]=l,t[101]=x,t[102]=n.path,t[103]=v,t[104]=u,t[105]=i,t[106]=f,t[107]=a,t[108]=s,t[109]=d,t[110]=E,t[111]=ae):ae=t[111];let oe;return t[112]!==X||t[113]!==ae?(oe=(0,$.jsxs)($.Fragment,{children:[X,ae]}),t[112]=X,t[113]=ae,t[114]=oe):oe=t[114],oe},tn=e=>{let t=(0,Q.c)(66),{namespace:n,locale:r,searchValue:i,remoteSearch:a,onContinueRemoteSearch:o,onOpenFile:s}=e,[c,u]=(0,Z.useState)(!0),{entriesByPath:f,pageMetadataByPath:p}=m(),{clearNamespaceCache:h}=d(),g=n.name??n.displayName,{entries:_,isPending:v,error:y,hasMore:x,loadMore:S,isLoadingMore:w,loadMoreError:T,refetch:E}=l(g),D;t[0]!==h||t[1]!==g||t[2]!==E?(D=e=>{e.stopPropagation(),h(g),E()},t[0]=h,t[1]=g,t[2]=E,t[3]=D):D=t[3];let O=D,k=v?n.storageEntries:_,A;if(t[4]!==k||t[5]!==f||t[6]!==y||t[7]!==O||t[8]!==x||t[9]!==c||t[10]!==w||t[11]!==v||t[12]!==S||t[13]!==T||t[14]!==r||t[15]!==n.backendType||t[16]!==n.displayName||t[17]!==n.name||t[18]!==n.protocol||t[19]!==n.rootPath||t[20]!==g||t[21]!==o||t[22]!==s||t[23]!==p||t[24]!==a||t[25]!==i){let e=Wt(k,{namespace:g,searchValue:i,entriesByPath:f}),l=Xt(i),d=b(g,l),m=l===``?[]:f.get(d)??[],h=Wt(m,{namespace:g,searchValue:i,entriesByPath:f}),_;t[27]===i?_=t[28]:(_=i.trim(),t[27]=i,t[28]=_);let E=!!_,D=e.length>0||h.length>0,j=l!==``&&Yt({hasSearch:E,hasLoadedMatches:D,isPending:v,remoteSearch:a,searchKey:d,entriesByPath:f,pageMetadataByPath:p}),M=E&&e.length===0,N;bb0:{if(v&&k.length===0){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ee,{className:`h-3 w-3 animate-spin`}),`Loading...`]}),t[29]=e):e=t[29],N=e;break bb0}if(a.status===`searching`){let e;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ee,{className:`h-3 w-3 animate-spin`}),`Searching more entries...`]}),t[30]=e):e=t[30],N=e;break bb0}if(a.status===`error`){let e;t[31]===a.error.message?e=t[32]:(e=(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`Search failed: `,a.error.message]}),t[31]=a.error.message,t[32]=e),N=e;break bb0}if(a.status===`capped`){let e;t[33]===o?e=t[34]:(e=(0,$.jsx)(J,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Continue searching`}),t[33]=o,t[34]=e);let n;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[35]=n):n=t[35];let r;t[36]===e?r=t[37]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`Searched more entries.`,e,n]}),t[36]=e,t[37]=r),N=r;break bb0}if(a.status===`exhausted`&&!D){N=`No matches`;break bb0}if(!E&&!v&&k.length===0){N=`No entries`;break bb0}if(j){let e;t[38]===o?e=t[39]:(e=(0,$.jsx)(J,{variant:`text`,size:`xs`,className:`h-5 px-0 text-xs hover:text-blue-600`,onClick:o,children:`Search more entries`}),t[38]=o,t[39]=e);let n;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`span`,{className:`text-[10px]`,children:`(or press Enter)`}),t[40]=n):n=t[40];let r;t[41]===e?r=t[42]:(r=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[`No loaded matches.`,e,n]}),t[41]=e,t[42]=r),N=r;break bb0}if(E&&!D&&k.length>0){N=`No matches`;break bb0}N=null}let P=N,F;t[43]===c?F=t[44]:(F=()=>u(!c),t[43]=c,t[44]=F);let I;t[45]===c?I=t[46]:(I=(0,$.jsx)(le,{isExpanded:c,className:`h-3 w-3`}),t[45]=c,t[46]=I);let L;t[47]===n.protocol?L=t[48]:(L=(0,$.jsx)(we,{protocol:n.protocol}),t[47]=n.protocol,t[48]=L);let R;t[49]===n.displayName?R=t[50]:(R=(0,$.jsx)(`span`,{children:n.displayName}),t[49]=n.displayName,t[50]=R);let z;t[51]===n.name?z=t[52]:(z=n.name&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground font-normal`,children:[`(`,(0,$.jsx)(pt,{variableName:n.name}),`)`]}),t[51]=n.name,t[52]=z);let B;t[53]===O?B=t[54]:(B=(0,$.jsx)(de,{onClick:O,tooltip:`Refresh storage connection`,className:`p-0`,iconClassName:`h-3 w-3`}),t[53]=O,t[54]=B);let V=n.rootPath||`(root)`,U;t[55]===V?U=t[56]:(U=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-normal tabular-nums ml-auto`,children:V}),t[55]=V,t[56]=U);let W;t[57]!==n.name||t[58]!==B||t[59]!==U||t[60]!==F||t[61]!==I||t[62]!==L||t[63]!==R||t[64]!==z?(W=(0,$.jsxs)(C,{value:n.name,onSelect:F,className:`flex flex-row font-semibold h-7 text-xs gap-1.5 bg-(--slate-2) text-muted-foreground rounded-none`,children:[I,L,R,z,B,U]}),t[57]=n.name,t[58]=B,t[59]=U,t[60]=F,t[61]=I,t[62]=L,t[63]=R,t[64]=z,t[65]=W):W=t[65],A=(0,$.jsxs)($.Fragment,{children:[W,c&&(0,$.jsxs)($.Fragment,{children:[y&&k.length===0&&(0,$.jsx)(H,{error:y,style:Rt(1),className:`py-1 text-xs h-auto overflow-auto max-h-32 items-start`,showIcon:!1}),!y&&P&&(0,$.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground italic`,style:Rt(1),children:P}),e.map(e=>{let t=Ht(e,k.indexOf(e));return(0,$.jsx)(en,{rowKey:t,entry:e,namespace:g,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:s},t)}),M&&h.map(e=>{let t=Ht(e,m.indexOf(e));return(0,$.jsx)(en,{rowKey:`remote-search:${t}`,entry:e,namespace:g,protocol:n.protocol,rootPath:n.rootPath,backendType:n.backendType,depth:1,locale:r,searchValue:i,onOpenFile:s},`remote-search:${t}`)}),x&&!j&&(0,$.jsx)(Qt,{depth:1,isLoading:w,error:T,onLoadMore:S})]})]}),t[4]=k,t[5]=f,t[6]=y,t[7]=O,t[8]=x,t[9]=c,t[10]=w,t[11]=v,t[12]=S,t[13]=T,t[14]=r,t[15]=n.backendType,t[16]=n.displayName,t[17]=n.name,t[18]=n.protocol,t[19]=n.rootPath,t[20]=g,t[21]=o,t[22]=s,t[23]=p,t[24]=a,t[25]=i,t[26]=A}else A=t[26];return A},nn=()=>{let e=(0,Q.c)(63),{namespaces:t,entriesByPath:n,pageMetadataByPath:r}=m(),{locale:i}=Ke(),[a,o]=(0,Z.useState)(``),s;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},e[0]=s):s=e[0];let[l,u]=(0,Z.useState)(s),[d,f]=(0,Z.useState)(null),g=p(),v;e[1]===a?v=e[2]:(v=a.trim(),e[1]=a,e[2]=v);let y=!!v,x;e[3]===a?x=e[4]:(x=a.trim(),e[3]=a,e[4]=x);let S=x,C;e[5]!==S||e[6]!==l?(C=e=>{let t=l[e];return t?.query===S?t:Kt(S)},e[5]=S,e[6]=l,e[7]=C):C=e[7];let w=C,T;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(e,t)=>{u(n=>({...n,[e]:t}))},e[8]=T):T=e[8];let E=T,D;e[9]!==S||e[10]!==n||e[11]!==r||e[12]!==w?(D=e=>{if(!S)return!1;let t=e.name??e.displayName,i=Xt(S);if(i===``||!qt(w(t))||Wt(n.get(b(t,``))??e.storageEntries,{namespace:t,searchValue:S,entriesByPath:n}).length>0)return!1;let a=b(t,i);return Wt(n.get(a)??[],{namespace:t,searchValue:S,entriesByPath:n}).length>0?!1:Jt(a,n,r)},e[9]=S,e[10]=n,e[11]=r,e[12]=w,e[13]=D):D=e[13];let O=D,k;e[14]!==O||e[15]!==S||e[16]!==n||e[17]!==g||e[18]!==r?(k=async e=>{if(!O(e))return;let t=S,i=e.name??e.displayName,a=Xt(t),o=b(i,a),s=n.get(o),c=r.get(o)?.nextPageToken??null,l=s!==void 0;E(i,{query:t,status:`searching`});try{for(let e=0;e<Gt;e++){let e=!l||c!==null,n=[];if(e){let e=await g({namespace:i,prefix:a,pageToken:c,append:l});n=e.entries,c=e.next_page_token??null,l=!0}if((e?n:s??[]).some(e=>Zt(e,t))){E(i,{query:t,status:`found`});return}if(c===null){E(i,{query:t,status:`exhausted`});return}}E(i,{query:t,status:`capped`})}catch(e){let n=e;E(i,{query:t,status:`error`,error:n instanceof Error?n:Error(String(n))})}},e[14]=O,e[15]=S,e[16]=n,e[17]=g,e[18]=r,e[19]=k):k=e[19];let A=k,M;e[20]!==O||e[21]!==A||e[22]!==t?(M=()=>{let e=t.filter(O);for(let t of e)A(t)},e[20]=O,e[21]=A,e[22]=t,e[23]=M):M=e[23];let N=M;if(t.length===0){let t;return e[24]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(ot,{title:`No storage connected`,description:(0,$.jsxs)(`span`,{children:[`Create an obstore or fsspec connection in your notebook. See the`,` `,(0,$.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`}),`.`]}),action:(0,$.jsx)(dt,{group:`storage`,label:`Add remote storage`,variant:`outline`,size:`sm`}),icon:(0,$.jsx)(Ce,{className:`h-8 w-8`})}),e[24]=t):t=e[24],t}let P;e[25]===d?P=e[26]:(P=d&&(0,$.jsx)(It,{entry:d.entry,namespace:d.namespace,protocol:d.protocol,backendType:d.backendType,onBack:()=>f(null)}),e[25]=d,e[26]=P);let F=d&&`hidden`,I;e[27]===F?I=e[28]:(I=j(`border-b bg-background rounded-none h-full pb-10 overflow-auto outline-hidden scrollbar-thin`,F),e[27]=F,e[28]=I);let L;e[29]!==O||e[30]!==N||e[31]!==t?(L=e=>{e.key===`Enter`&&t.some(O)&&(e.preventDefault(),N())},e[29]=O,e[30]=N,e[31]=t,e[32]=L):L=e[32];let R;e[33]!==a||e[34]!==L?(R=(0,$.jsx)(h,{placeholder:`Search entries...`,className:`h-6 m-1`,value:a,onValueChange:o,onKeyDown:L,rootClassName:`flex-1 border-b-0`}),e[33]=a,e[34]=L,e[35]=R):R=e[35];let z;e[36]===y?z=e[37]:(z=y&&(0,$.jsx)(J,{variant:`text`,size:`xs`,className:`float-right border-none px-2 m-0 h-full`,onClick:()=>o(``),children:(0,$.jsx)(se,{className:`h-4 w-4`})}),e[36]=y,e[37]=z);let B,V;e[38]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(q,{content:`Search by file name within loaded entries, or by prefix (e.g. 'folder/x') for backend search. Press Enter to fetch more results.`,delayDuration:200,children:(0,$.jsx)(me,{className:`h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2`})}),V=(0,$.jsx)(dt,{group:`storage`,label:`Add remote storage`,compact:!0,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`}),e[38]=B,e[39]=V):(B=e[38],V=e[39]);let H;e[40]!==R||e[41]!==z?(H=(0,$.jsxs)(`div`,{className:`flex items-center w-full border-b`,children:[R,z,B,V]}),e[40]=R,e[41]=z,e[42]=H):H=e[42];let U;if(e[43]!==A||e[44]!==i||e[45]!==t||e[46]!==w||e[47]!==a){let n;e[49]!==A||e[50]!==i||e[51]!==w||e[52]!==a?(n=e=>{let t=e.name??e.displayName;return(0,$.jsx)(tn,{namespace:e,locale:i,searchValue:a,remoteSearch:w(t),onContinueRemoteSearch:()=>void A(e),onOpenFile:f},t)},e[49]=A,e[50]=i,e[51]=w,e[52]=a,e[53]=n):n=e[53],U=t.map(n),e[43]=A,e[44]=i,e[45]=t,e[46]=w,e[47]=a,e[48]=U}else U=e[48];let W;e[54]===U?W=e[55]:(W=(0,$.jsx)(c,{className:`flex flex-col`,children:U}),e[54]=U,e[55]=W);let G;e[56]!==I||e[57]!==H||e[58]!==W?(G=(0,$.jsxs)(_,{className:I,shouldFilter:!1,children:[H,W]}),e[56]=I,e[57]=H,e[58]=W,e[59]=G):G=e[59];let K;return e[60]!==G||e[61]!==P?(K=(0,$.jsxs)(`div`,{className:`h-full flex flex-col`,children:[P,G]}),e[60]=G,e[61]=P,e[62]=K):K=e[62],K};function rn(e){return e.stopPropagation()}function an(e){return e.stopPropagation()}function on(e){return e.preventDefault()}var sn=(0,Z.createContext)(null);function cn(){return(0,Z.useContext)(sn)??void 0}var ln=e=>{let t=(0,Q.c)(3),{children:n}=e,r=Ae(),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(sn.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},un=e=>{let t=(0,Q.c)(5),{children:n}=e,[r,i]=(0,Z.useState)(null),a;t[0]!==n||t[1]!==r?(a=r&&(0,$.jsx)(je,{backend:Le,options:{rootElement:r},children:(0,$.jsx)(ln,{children:n})}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;return t[3]===a?o=t[4]:(o=(0,$.jsx)(`div`,{ref:i,className:`contents`,children:a}),t[3]=a,t[4]=o),o};async function dn(e,t){if(!k()){let n=A().formatNavigableHttpURL(`api/files/download`,new URLSearchParams({path:e}));te(n.toString(),t);return}let n=await ie().sendFileDetails({path:e});if(n.isBase64&&n.contents){let e=Xe(pe(n.contents,n.mimeType||`application/octet-stream`));ee(e,t)}else ee(new Blob([n.contents||``],{type:n.mimeType||`application/octet-stream`}),t)}var fn=e=>{let t=(0,Q.c)(21),{file:n,mimeType:r,message:i,onDownload:a}=e,{locale:o}=Ke(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Path`}),t[0]=s):s=t[0];let c;t[1]===n.path?c=t[2]:(c=(0,$.jsx)(`span`,{className:`font-mono text-xs break-all`,children:n.path}),t[1]=n.path,t[2]=c);let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Type`}),t[3]=l):l=t[3];let u;t[4]===r?u=t[5]:(u=(0,$.jsx)(`span`,{children:r}),t[4]=r,t[5]=u);let d;t[6]!==n.size||t[7]!==o?(d=n.size!=null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Size`}),(0,$.jsx)(`span`,{children:st(n.size,o)})]}),t[6]=n.size,t[7]=o,t[8]=d):d=t[8];let f;t[9]!==c||t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-2`,children:[s,c,l,u,d]}),t[9]=c,t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]===i?p=t[14]:(p=(0,$.jsx)(`div`,{className:`mt-4 text-muted-foreground italic`,children:i}),t[13]=i,t[14]=p);let m;t[15]===a?m=t[16]:(m=a&&(0,$.jsxs)(J,{variant:`outline`,size:`sm`,className:`mt-4`,onClick:a,children:[(0,$.jsx)(B,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),t[15]=a,t[16]=m);let h;return t[17]!==f||t[18]!==p||t[19]!==m?(h=(0,$.jsxs)(`div`,{className:`p-4 text-sm`,children:[f,p,m]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h):h=t[20],h};function pn(e,t){let n=e||`text/plain`;return G(n)?`media`:t?`unsupported`:n===`text/csv`?`csv`:n.startsWith(`text/`)||n!=="default"&&n in V||e==null?`text`:`unsupported`}var mn=10485760,hn=new Map,gn=({file:e,onOpenNotebook:t})=>{let{sendFileDetails:n,sendUpdateFile:i}=re(),a=r(D),o=r(O),s=r(v),[c,l]=(0,Z.useState)(``),{data:u,isPending:d,error:f,setData:p,refetch:m}=qe(async()=>{let t=await n({path:e.path,maxBytes:mn}),r=pn(t.mimeType,t.isBase64);if(!t.isTooLarge&&r===`text`){let n=t.contents||``;l(hn.get(e.path)??n)}return t},[e.path]),h=async()=>{c!==u?.contents&&await i({path:e.path,contents:c}).then(e=>{e.success&&(p(e=>({...e,contents:c})),l(c))})},g=(0,Z.useRef)(c);if(g.current=c,(0,Z.useEffect)(()=>()=>{if(u?.contents==null||u.isTooLarge||pn(u.mimeType,u.isBase64)!==`text`)return;let t=g.current;t===u.contents?hn.delete(e.path):hn.set(e.path,t)},[e.path,u?.contents,u?.isTooLarge,u?.mimeType,u?.isBase64]),f)return(0,$.jsx)(et,{error:f});if(d||!u)return null;let _=u.mimeType||`text/plain`,y=pn(u.mimeType,u.isBase64),b=y===`text`,x=y===`csv`,S=y===`media`,C=s&&u.file.isMarimoFile&&(e.path===s||e.path.endsWith(`/${s}`)),w=async()=>{await dn(e.path,u.file.name)},T=ne.of([{key:a.getHotkey(`global.save`).key,stopPropagation:!0,run:()=>c!==u.contents&&(h(),!0)}]),E=(0,$.jsx)(Dt,{filename:u.file.name,onRefresh:m,onDownload:o?void 0:w,actions:(0,$.jsxs)($.Fragment,{children:[e.isMarimoFile&&!k()&&(0,$.jsx)(q,{content:`Open notebook`,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:e=>t(e),children:(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})})}),b&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{content:`Copy contents to clipboard`,children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:async()=>{await Je(c)},children:(0,$.jsx)(he,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(q,{content:tt(`global.save`),children:(0,$.jsx)(J,{variant:`text`,size:`xs`,onClick:h,disabled:c===u.contents,children:(0,$.jsx)(ze,{className:`h-3.5 w-3.5`})})})]})]})});if(u.isTooLarge||y===`unsupported`)return(0,$.jsxs)($.Fragment,{children:[E,(0,$.jsx)(fn,{file:u.file,mimeType:_,message:u.isTooLarge?`File is too large to preview.`:`This file type cannot be previewed.`,onDownload:o?void 0:w})]});let A=b&&C&&(0,$.jsxs)($e,{variant:`warning`,className:`rounded-none`,children:[(0,$.jsx)(Be,{className:`h-4 w-4`}),(0,$.jsx)(Qe,{children:`Editing the notebook file directly while running in marimo's editor may cause unintended changes. Please use with caution.`})]}),j=S&&u.contents?W({contents:u.contents,mimeType:_,isBase64:u.isBase64??!1}):void 0;return(0,$.jsxs)($.Fragment,{children:[E,A,(0,$.jsx)(U,{mimeType:_,contents:b?c:x?u.contents??void 0:void 0,mediaSource:j,readOnly:!b,onChange:b?l:void 0,extensions:b?[T]:[]})]})},_n=n(e=>{let t=e(Y);return E(t,`no requestClientAtom set`),new ke({listFiles:t.sendListFiles,createFileOrFolder:t.sendCreateFileOrFolder,deleteFileOrFolder:t.sendDeleteFileOrFolder,copyFileOrFolder:t.sendCopyFileOrFolder,renameFileOrFolder:t.sendRenameFileOrFolder})}),vn=n({}),yn=` `,bn={directory:e=>`os.listdir("${e}")`,python:e=>`with open("${e}", "r") as _f:\n${yn}...\n`,json:e=>`with open("${e}", "r") as _f:\n${yn}_data = json.load(_f)\n`,code:e=>`with open("${e}", "r") as _f:\n${yn}...\n`,text:e=>`with open("${e}", "r") as _f:\n${yn}...\n`,image:e=>`mo.image("${e}")`,audio:e=>`mo.audio("${e}")`,video:e=>`mo.video("${e}")`,pdf:e=>`with open("${e}", "rb") as _f:\n${yn}...\n`,zip:e=>`with open("${e}", "rb") as _f:\n${yn}...\n`,data:e=>`with open("${e}", "r") as _f:\n${yn}...\n`,unknown:e=>`with open("${e}", "r") as _f:\n${yn}...\n`},xn=104857600,Sn=5,Cn=`data-file-explorer-directory-path`;function wn(e){let{destinationPath:t,getDestinationLabel:n=e=>e,onUploadStart:r,refreshDestination:i,...a}=e,{sendCreateFileOrFolder:o}=re();return He({multiple:!0,maxSize:xn,...a,onError:e=>{T.error(e),Ue({title:`File upload failed`,description:e.message,variant:`danger`})},onDropRejected:e=>{Ue({title:`File upload failed`,description:(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,$.jsxs)(`div`,{children:[e.file.name,` (`,e.errors.map(e=>e.message).join(`, `),`)`]},e.file.name))}),variant:`danger`})},onDrop:async(e,a,s)=>{if(e.length===0)return;let c=typeof t==`function`?t(s):t,l=n(c),u=e.length===1?`Uploading file to ${l}...`:`Uploading files to ${l}...`;r?.(c,e);let d;try{d=await K(u,async t=>(t.addTotal(e.length),Tn({files:e,destinationPath:c,createFile:o,onFileProcessed:()=>t.increment(1)})))}catch{await i(c);return}await i(c),On(d,l)}})}async function Tn({files:e,destinationPath:t,createFile:n,onFileProcessed:r}){let i=await at(e,Sn,async e=>{try{return{file:e,response:await n({path:En({destinationPath:t,filePath:An(kn(e))}),type:`file`,name:e.name,file:e})}}catch(t){return{file:e,response:{success:!1,message:Ze(t)}}}finally{r?.()}});return{successful:i.filter(({response:e})=>e.success),failed:i.filter(({response:e})=>!e.success)}}function En({destinationPath:e,filePath:t}){if(!t)return e;if(We.isAbsolute(t))throw Error(`Upload path must be relative: ${t}`);let n=t.split(/[\\/]+/).slice(0,-1).filter(Boolean);if(n.includes(`..`))throw Error(`Upload path cannot contain parent traversal: ${t}`);let r=n.filter(e=>e!==`.`);if(r.length===0)return e;let i=Ge.guessDeliminator(e),a=r.join(i.deliminator);return i.join(e,a)}function Dn(e,t){return e instanceof Element&&e.closest(`[${Cn}]`)?.getAttribute(Cn)||t}function On(e,t){let n=e.successful.length+e.failed.length;if(e.failed.length>0){let r;r=e.successful.length===0?n===1?`File upload failed`:`Files failed to upload`:`${e.successful.length} of ${n} files uploaded`,Ue({title:r,description:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Destination: `,t,`.`]}),e.failed.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,`:`,` `,t.message||`The server rejected the upload.`]},`${e.name}-${n}`))]}),variant:`danger`});return}let r=e.successful.filter(({file:e,response:t})=>t.info?.name&&t.info.name!==e.name);Ue({title:n===1?`File uploaded`:`${n} files uploaded`,description:r.length===0?`Uploaded to ${t}.`:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{children:[`Uploaded to `,t,`.`]}),r.map(({file:e,response:t},n)=>(0,$.jsxs)(`div`,{children:[e.name,` was saved as `,t.info?.name,`.`]},`${e.name}-${n}`))]})})}function kn(e){if(e.webkitRelativePath)return e.webkitRelativePath;if(`path`in e&&typeof e.path==`string`)return e.path;if(`relativePath`in e&&typeof e.relativePath==`string`)return e.relativePath}function An(e){if(e)return e.replace(/^\/+/,``)}var jn=g(`marimo:showHiddenFiles`,!0,x,{getOnInit:!0}),Mn=Z.createContext(null),Nn=e=>{let n=(0,Q.c)(107),{height:r,externalDropDestinationPath:a}=e,o=a===void 0?null:a,s=(0,Z.useRef)(null),c=cn(),[l]=t(_n),u;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],n[0]=u):u=n[0];let[d,f]=(0,Z.useState)(u),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(null),[_,v]=t(jn),[y,b]=t(vn),x;n[1]===l?x=n[2]:(x=e=>l.refreshPath(e),n[1]=l,n[2]=x);let S=i(x),C=(0,Z.useRef)(``),w;n[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>C.current,n[3]=w):w=n[3];let T;n[4]===l?T=n[5]:(T=e=>Bn(l,e),n[4]=l,n[5]=T);let E;n[6]!==S||n[7]!==T?(E={noClick:!0,noDrag:!0,noKeyboard:!0,destinationPath:w,getDestinationLabel:T,refreshDestination:S},n[6]=S,n[7]=T,n[8]=E):E=n[8];let{getInputProps:D,open:O}=wn(E),k;n[9]===O?k=n[10]:(k=e=>{C.current=e,O()},n[9]=O,n[10]=k);let A=i(k),{openPrompt:j}=Te(),M;n[11]===l?M=n[12]:(M=()=>l.initialize(f),n[11]=l,n[12]=M);let N;n[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=[],n[13]=N):N=n[13];let{isPending:P,error:F}=qe(M,N),I;n[14]!==y||n[15]!==l?(I=()=>l.refreshAll(Object.keys(y).filter(e=>y[e])),n[14]=y,n[15]=l,n[16]=I):I=n[16];let L=i(I),R;n[17]!==v||n[18]!==_?(R=()=>{v(!_)},n[17]=v,n[18]=_,n[19]=R):R=n[19];let z=i(R),B;n[20]!==j||n[21]!==l?(B=async()=>{j({title:`Folder name`,onConfirm:async e=>{l.createFolder(e,null)}})},n[20]=j,n[21]=l,n[22]=B):B=n[22];let V=i(B),H;n[23]!==j||n[24]!==l?(H=async()=>{j({title:`File name`,onConfirm:async e=>{l.createFile({name:e,parentId:null})}})},n[23]=j,n[24]=l,n[25]=H):H=n[25];let U=i(H),W;n[26]!==j||n[27]!==l?(W=async()=>{j({title:`Notebook name`,onConfirm:async e=>{l.createFile({name:e,parentId:null,type:`notebook`})}})},n[26]=j,n[27]=l,n[28]=W):W=n[28];let G=i(W),K;n[29]===b?K=n[30]:(K=()=>{s.current?.closeAll(),b({})},n[29]=b,n[30]=K);let ee=i(K),te;n[31]!==d||n[32]!==_?(te=Vn(d,_),n[31]=d,n[32]=_,n[33]=te):te=n[33];let q=te,ne,Y;n[34]!==h||n[35]!==q?(ne=()=>{h&&!Un(q,h)&&g(null)},Y=[h,q],n[34]=h,n[35]=q,n[36]=ne,n[37]=Y):(ne=n[36],Y=n[37]),Z.useEffect(ne,Y);let re;n[38]!==o||n[39]!==A||n[40]!==l?(re={tree:l,uploadFiles:A,externalDropDestinationPath:o},n[38]=o,n[39]=A,n[40]=l,n[41]=re):re=n[41];let ie=re;if(P){let e;return n[42]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(De,{size:`medium`,centered:!0}),n[42]=e):e=n[42],e}if(F){let e;return n[43]===F?e=n[44]:(e=(0,$.jsx)(et,{error:F}),n[43]=F,n[44]=e),e}if(p){let e;n[45]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>m(null),n[45]=e):e=n[45];let t;n[46]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(J,{onClick:e,"data-testid":`file-explorer-back-button`,variant:`text`,size:`xs`,className:`mb-0`,children:(0,$.jsx)(ae,{size:16})}),n[46]=t):t=n[46];let r;n[47]===p.name?r=n[48]:(r=(0,$.jsxs)(`div`,{className:`flex items-center pl-1 pr-3 shrink-0 border-b justify-between`,children:[t,(0,$.jsx)(`span`,{className:`font-bold`,children:p.name})]}),n[47]=p.name,n[48]=r);let i;n[49]!==p.path||n[50]!==l?(i=e=>zn(e,l.relativeFromRoot(p.path)),n[49]=p.path,n[50]=l,n[51]=i):i=n[51];let a;n[52]!==p||n[53]!==i?(a=(0,$.jsx)(Z.Suspense,{children:(0,$.jsx)(gn,{onOpenNotebook:i,file:p})}),n[52]=p,n[53]=i,n[54]=a):a=n[54];let o;return n[55]!==r||n[56]!==a?(o=(0,$.jsxs)($.Fragment,{children:[r,a]}),n[55]=r,n[56]=a,n[57]=o):o=n[57],o}let X;n[58]===D?X=n[59]:(X=D(),n[58]=D,n[59]=X);let oe;n[60]===X?oe=n[61]:(oe=(0,$.jsx)(`input`,{"data-testid":`file-explorer-upload-input`,...X}),n[60]=X,n[61]=oe);let se;n[62]!==h||n[63]!==l?(se=h??l.getRootPath(),n[62]=h,n[63]=l,n[64]=se):se=n[64];let ce;n[65]!==h||n[66]!==l?(ce=h??l.getRootPath(),n[65]=h,n[66]=l,n[67]=ce):ce=n[67];let le;n[68]!==ce||n[69]!==l?(le=Bn(l,ce),n[68]=ce,n[69]=l,n[70]=le):le=n[70];let ue;n[71]!==ee||n[72]!==U||n[73]!==V||n[74]!==G||n[75]!==z||n[76]!==L||n[77]!==A||n[78]!==_||n[79]!==se||n[80]!==le?(ue=(0,$.jsx)(Fn,{onRefresh:L,onHidden:z,showHiddenFiles:_,onCreateFile:U,onCreateNotebook:G,onCreateFolder:V,onCollapseAll:ee,uploadDestinationPath:se,uploadDestinationLabel:le,onUpload:A}),n[71]=ee,n[72]=U,n[73]=V,n[74]=G,n[75]=z,n[76]=L,n[77]=A,n[78]=_,n[79]=se,n[80]=le,n[81]=ue):ue=n[81];let de=r-33,fe,pe,me;n[82]===l?(fe=n[83],pe=n[84],me=n[85]):(fe=async e=>{let{ids:t}=e;for(let e of t)await l.delete(e)},pe=async e=>{let{id:t,name:n}=e;await l.rename(t,n)},me=async e=>{let{dragIds:t,parentId:n}=e;await l.move(t,n)},n[82]=l,n[83]=fe,n[84]=pe,n[85]=me);let he;n[86]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>{let t=e[0];if(!t){g(null);return}if(t.data.isDirectory){g(t.data.path);return}g(null),m(t.data)},n[86]=he):he=n[86];let ge;n[87]!==y||n[88]!==b||n[89]!==l?(ge=async e=>{if(await l.expand(e)){let t=y[e]??!1;b({...y,[e]:!t})}},n[87]=y,n[88]=b,n[89]=l,n[90]=ge):ge=n[90];let _e;n[91]!==c||n[92]!==y||n[93]!==de||n[94]!==fe||n[95]!==pe||n[96]!==me||n[97]!==ge||n[98]!==q?(_e=(0,$.jsx)(Ne,{width:`100%`,ref:s,height:de,className:`h-full`,data:q,initialOpenState:y,openByDefault:!1,dndManager:c,renderCursor:Wn,disableDrop:Gn,onDelete:fe,onRename:pe,onMove:me,onSelect:he,onToggle:ge,padding:15,rowHeight:30,indent:Pn,overscanCount:1e3,disableMultiSelection:!0,children:Ln}),n[91]=c,n[92]=y,n[93]=de,n[94]=fe,n[95]=pe,n[96]=me,n[97]=ge,n[98]=q,n[99]=_e):_e=n[99];let ve;n[100]!==ie||n[101]!==_e?(ve=(0,$.jsx)(Mn,{value:ie,children:_e}),n[100]=ie,n[101]=_e,n[102]=ve):ve=n[102];let ye;return n[103]!==oe||n[104]!==ue||n[105]!==ve?(ye=(0,$.jsxs)($.Fragment,{children:[oe,ue,ve]}),n[103]=oe,n[104]=ue,n[105]=ve,n[106]=ye):ye=n[106],ye},Pn=15,Fn=e=>{let t=(0,Q.c)(35),{onRefresh:n,onHidden:r,showHiddenFiles:i,onCreateFile:a,onCreateNotebook:o,onCreateFolder:s,onCollapseAll:c,uploadDestinationPath:l,uploadDestinationLabel:u,onUpload:d}=e,f=`Upload files to ${u}`,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(ht,{size:16}),t[0]=p):p=t[0];let m;t[1]===o?m=t[2]:(m=(0,$.jsx)(q,{content:`Add notebook`,children:(0,$.jsx)(J,{"data-testid":`file-explorer-add-notebook-button`,onClick:o,variant:`text`,size:`xs`,children:p})}),t[1]=o,t[2]=m);let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(xt,{size:16}),t[3]=h):h=t[3];let g;t[4]===a?g=t[5]:(g=(0,$.jsx)(q,{content:`Add file`,children:(0,$.jsx)(J,{"data-testid":`file-explorer-add-file-button`,onClick:a,variant:`text`,size:`xs`,children:h})}),t[4]=a,t[5]=g);let _;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(Ct,{size:16}),t[6]=_):_=t[6];let v;t[7]===s?v=t[8]:(v=(0,$.jsx)(q,{content:`Add folder`,children:(0,$.jsx)(J,{"data-testid":`file-explorer-add-folder-button`,onClick:s,variant:`text`,size:`xs`,children:_})}),t[7]=s,t[8]=v);let y;t[9]!==d||t[10]!==l?(y=()=>d(l),t[9]=d,t[10]=l,t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Ve,{size:16}),t[12]=b):b=t[12];let x;t[13]!==y||t[14]!==f?(x=(0,$.jsx)(J,{"data-testid":`file-explorer-upload-button`,"aria-label":f,onClick:y,variant:`text`,size:`xs`,children:b}),t[13]=y,t[14]=f,t[15]=x):x=t[15];let S;t[16]!==x||t[17]!==f?(S=(0,$.jsx)(q,{content:f,children:x}),t[16]=x,t[17]=f,t[18]=S):S=t[18];let C;t[19]===n?C=t[20]:(C=(0,$.jsx)(de,{"data-testid":`file-explorer-refresh-button`,onClick:n}),t[19]=n,t[20]=C);let w;t[21]!==r||t[22]!==i?(w=(0,$.jsx)(ce,{"data-testid":`file-explorer-hidden-files-button`,isVisible:i,onToggle:r,showTooltip:`Show hidden files`,hideTooltip:`Hide hidden files`}),t[21]=r,t[22]=i,t[23]=w):w=t[23];let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(bt,{size:16}),t[24]=T):T=t[24];let E;t[25]===c?E=t[26]:(E=(0,$.jsx)(q,{content:`Collapse all folders`,children:(0,$.jsx)(J,{"data-testid":`file-explorer-collapse-button`,onClick:c,variant:`text`,size:`xs`,children:T})}),t[25]=c,t[26]=E);let D;return t[27]!==S||t[28]!==C||t[29]!==w||t[30]!==E||t[31]!==m||t[32]!==g||t[33]!==v?(D=(0,$.jsxs)(`div`,{className:`flex items-center justify-end px-2 shrink-0 border-b`,children:[m,g,v,S,C,w,E]}),t[27]=S,t[28]=C,t[29]=w,t[30]=E,t[31]=m,t[32]=g,t[33]=v,t[34]=D):D=t[34],D},In=e=>{let t=(0,Q.c)(9),{node:n,onOpenMarimoFile:r}=e,i;t[0]===n?i=t[1]:(i=e=>{n.data.isDirectory||(e.stopPropagation(),n.select())},t[0]=n,t[1]=i);let a;t[2]!==n.data.isMarimoFile||t[3]!==r?(a=n.data.isMarimoFile&&!k()&&(0,$.jsxs)(`span`,{"data-testid":`file-explorer-open-marimo-button`,className:`shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline`,onClick:r,children:[`open `,(0,$.jsx)(ge,{className:`inline ml-1`,size:12})]}),t[2]=n.data.isMarimoFile,t[3]=r,t[4]=a):a=t[4];let o;return t[5]!==n.data.name||t[6]!==i||t[7]!==a?(o=(0,$.jsxs)(`span`,{className:`flex-1 overflow-hidden text-ellipsis`,onClick:i,children:[n.data.name,a]}),t[5]=n.data.name,t[6]=i,t[7]=a,t[8]=o):o=t[8],o},Ln=e=>{let t=(0,Q.c)(123),{node:n,style:a,dragHandle:o}=e,{openFile:s}=re(),c=r(O),l;t[0]!==n.data.isDirectory||t[1]!==n.data.name?(l=n.data.isDirectory?`directory`:be(n.data.name),t[0]=n.data.isDirectory,t[1]=n.data.name,t[2]=l):l=t[2];let d=l,p=xe[d],{openConfirm:m,openPrompt:h}=Te(),{createNewCell:g}=u(),_=f(),v;t[3]!==g||t[4]!==_?(v=e=>{g({code:e,before:!1,cellId:_??`__end__`})},t[3]=g,t[4]=_,t[5]=v):v=t[5];let b=v,x=(0,Z.use)(Mn),S=x?.tree,C=n.data.isDirectory&&x?.externalDropDestinationPath===n.data.path,w;t[6]!==n.data.path||t[7]!==S?(w=async e=>{zn(e,S?S.relativeFromRoot(n.data.path):n.data.path)},t[6]=n.data.path,t[7]=S,t[8]=w):w=t[8];let T=w,E;t[9]!==n.data.name||t[10]!==n.id||t[11]!==n.tree||t[12]!==m?(E=async e=>{e.stopPropagation(),e.preventDefault(),m({title:`Delete file`,description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:(0,$.jsx)(P,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":`Confirm`,children:`Delete`})})},t[9]=n.data.name,t[10]=n.id,t[11]=n.tree,t[12]=m,t[13]=E):E=t[13];let D=E,A;t[14]!==n||t[15]!==h||t[16]!==S?(A=async()=>{n.open(),h({title:`Folder name`,onConfirm:async e=>{S?.createFolder(e,n.id)}})},t[14]=n,t[15]=h,t[16]=S,t[17]=A):A=t[17];let M=i(A),N;t[18]!==n||t[19]!==h||t[20]!==S?(N=async()=>{n.open(),h({title:`File name`,onConfirm:async e=>{S?.createFile({name:e,parentId:n.id})}})},t[18]=n,t[19]=h,t[20]=S,t[21]=N):N=t[21];let L=i(N),R;t[22]!==n||t[23]!==h||t[24]!==S?(R=async()=>{n.open(),h({title:`Notebook name`,onConfirm:async e=>{S?.createFile({name:e,parentId:n.id,type:`notebook`})}})},t[22]=n,t[23]=h,t[24]=S,t[25]=R):R=t[25];let z=i(R),V;t[26]!==n.data.name||t[27]!==n.id||t[28]!==S?(V=async()=>{S&&await S.copy(n.id,it(n.data.name))},t[26]=n.data.name,t[27]=n.id,t[28]=S,t[29]=V):V=t[29];let H=i(V),U;t[30]!==n.data.isDirectory||t[31]!==n.data.path?(U=n.data.isDirectory?{[Cn]:n.data.path}:{},t[30]=n.data.isDirectory,t[31]=n.data.path,t[32]=U):U=t[32];let W;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(W=j(`flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group`),t[33]=W):W=t[33];let G,K;t[34]===n?(G=t[35],K=t[36]):(G=e=>{e.stopPropagation(),n.data.isDirectory&&(n.select(),n.toggle())},K=(0,$.jsx)(Rn,{node:n}),t[34]=n,t[35]=G,t[36]=K);let ee=n.willReceiveDrop&&n.data.isDirectory&&`bg-accent/80 hover:bg-accent/80 text-accent-foreground`,te=n.isSelected&&`bg-accent/60 hover:bg-accent/60 text-accent-foreground`,q=C&&`bg-primary/15 hover:bg-primary/15 text-accent-foreground ring-1 ring-inset ring-primary`,J;t[37]!==ee||t[38]!==te||t[39]!==q?(J=j(`flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group`,ee,te,q),t[37]=ee,t[38]=te,t[39]=q,t[40]=J):J=t[40];let ne;t[41]!==p||t[42]!==d||t[43]!==n.data.isMarimoFile?(ne=n.data.isMarimoFile?(0,$.jsx)(gt,{className:`w-5 h-5 shrink-0 mr-2`,strokeWidth:1.5}):(0,$.jsx)(p,{className:j(`w-5 h-5 shrink-0 mr-2`,ye[d]),strokeWidth:1.5}),t[41]=p,t[42]=d,t[43]=n.data.isMarimoFile,t[44]=ne):ne=t[44];let Y;t[45]!==T||t[46]!==n?(Y=n.isEditing?(0,$.jsx)(Ie,{node:n}):(0,$.jsx)(In,{node:n,onOpenMarimoFile:T}),t[45]=T,t[46]=n,t[47]=Y):Y=t[47];let ie;t[48]===n?ie=t[49]:(ie=!n.data.isDirectory&&(0,$.jsxs)(F,{onSelect:()=>n.select(),"data-testid":`file-explorer-open-file-menu-item`,children:[(0,$.jsx)(Et,{className:`h-3.5 w-3.5 mr-2`}),`Open file`]}),t[48]=n,t[49]=ie);let X;t[50]!==n.data.isDirectory||t[51]!==n.data.path||t[52]!==s?(X=!n.data.isDirectory&&!k()&&(0,$.jsxs)(F,{onSelect:()=>{s({path:n.data.path})},"data-testid":`file-explorer-open-external-menu-item`,children:[(0,$.jsx)(ge,{className:`h-3.5 w-3.5 mr-2`}),`Open file in external editor`]}),t[50]=n.data.isDirectory,t[51]=n.data.path,t[52]=s,t[53]=X):X=t[53];let ae;t[54]!==x||t[55]!==L||t[56]!==M||t[57]!==z||t[58]!==n.data.isDirectory||t[59]!==n.data.path?(ae=n.data.isDirectory&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(F,{onSelect:()=>z(),"data-testid":`file-explorer-create-notebook-menu-item`,children:[(0,$.jsx)(ht,{className:`h-3.5 w-3.5 mr-2`}),`Create notebook`]}),(0,$.jsxs)(F,{onSelect:()=>L(),"data-testid":`file-explorer-create-file-menu-item`,children:[(0,$.jsx)(xt,{className:`h-3.5 w-3.5 mr-2`}),`Create file`]}),(0,$.jsxs)(F,{onSelect:()=>M(),"data-testid":`file-explorer-create-folder-menu-item`,children:[(0,$.jsx)(Ct,{className:`h-3.5 w-3.5 mr-2`}),`Create folder`]}),(0,$.jsxs)(F,{onSelect:()=>x?.uploadFiles(n.data.path),"data-testid":`file-explorer-upload-files-menu-item`,children:[(0,$.jsx)(Ve,{className:`h-3.5 w-3.5 mr-2`}),`Upload files here`]}),(0,$.jsx)(I,{})]}),t[54]=x,t[55]=L,t[56]=M,t[57]=z,t[58]=n.data.isDirectory,t[59]=n.data.path,t[60]=ae):ae=t[60];let se;t[61]===n?se=t[62]:(se=(0,$.jsx)(Oe,{onSelect:()=>n.edit(),testId:`file-explorer-rename-menu-item`}),t[61]=n,t[62]=se);let ce;t[63]===H?ce=t[64]:(ce=(0,$.jsx)(Fe,{onSelect:H,testId:`file-explorer-duplicate-menu-item`}),t[63]=H,t[64]=ce);let le;t[65]===n.data.path?le=t[66]:(le=async()=>{await Je(n.data.path),Ue({title:`Copied to clipboard`})},t[65]=n.data.path,t[66]=le);let ue;t[67]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(wt,{className:fe}),t[67]=ue):ue=t[67];let de;t[68]===le?de=t[69]:(de=(0,$.jsxs)(F,{onSelect:le,"data-testid":`file-explorer-copy-path-menu-item`,children:[ue,`Copy path`]}),t[68]=le,t[69]=de);let pe;t[70]!==n.data.path||t[71]!==S?(pe=S&&(0,$.jsxs)(F,{onSelect:async()=>{await Je(S.relativeFromRoot(n.data.path)),Ue({title:`Copied to clipboard`})},"data-testid":`file-explorer-copy-relative-path-menu-item`,children:[(0,$.jsx)(wt,{className:`h-3.5 w-3.5 mr-2`}),`Copy relative path`]}),t[70]=n.data.path,t[71]=S,t[72]=pe):pe=t[72];let me;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(I,{}),t[73]=me):me=t[73];let he;t[74]!==d||t[75]!==b||t[76]!==n.data?(he=()=>{let{path:e}=n.data,t=bn[d](e);b(t)},t[74]=d,t[75]=b,t[76]=n.data,t[77]=he):he=t[77];let _e;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(oe,{className:fe}),t[78]=_e):_e=t[78];let ve;t[79]===he?ve=t[80]:(ve=(0,$.jsxs)(F,{onSelect:he,"data-testid":`file-explorer-insert-snippet-menu-item`,children:[_e,`Insert snippet for reading file`]}),t[79]=he,t[80]=ve);let Se;t[81]!==d||t[82]!==n.data?(Se=async()=>{Ue({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:e}=n.data,t=bn[d](e);await Je(t)},t[81]=d,t[82]=n.data,t[83]=Se):Se=t[83];let Ce;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(y,{className:fe}),t[84]=Ce):Ce=t[84];let we;t[85]===Se?we=t[86]:(we=(0,$.jsxs)(F,{onSelect:Se,"data-testid":`file-explorer-copy-snippet-menu-item`,children:[Ce,`Copy snippet for reading file`]}),t[85]=Se,t[86]=we);let Ee;t[87]!==T||t[88]!==n.data.isMarimoFile?(Ee=n.data.isMarimoFile&&!k()&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{}),(0,$.jsxs)(F,{onSelect:T,"data-testid":`file-explorer-open-notebook-menu-item`,children:[(0,$.jsx)(Tt,{className:`h-3.5 w-3.5 mr-2`}),`Open notebook`]})]}),t[87]=T,t[88]=n.data.isMarimoFile,t[89]=Ee):Ee=t[89];let De;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,$.jsx)(I,{}),t[90]=De):De=t[90];let ke;t[91]!==c||t[92]!==n.data.isDirectory||t[93]!==n.data.name||t[94]!==n.data.path?(ke=!n.data.isDirectory&&!c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(F,{onSelect:async()=>{await dn(n.data.path,n.data.name)},"data-testid":`file-explorer-download-menu-item`,children:[(0,$.jsx)(B,{className:`h-3.5 w-3.5 mr-2`}),`Download`]}),(0,$.jsx)(I,{})]}),t[91]=c,t[92]=n.data.isDirectory,t[93]=n.data.name,t[94]=n.data.path,t[95]=ke):ke=t[95];let Ae;t[96]===D?Ae=t[97]:(Ae=(0,$.jsx)(Pe,{onSelect:D,testId:`file-explorer-delete-menu-item`}),t[96]=D,t[97]=Ae);let je;t[98]!==ie||t[99]!==X||t[100]!==ae||t[101]!==se||t[102]!==ce||t[103]!==de||t[104]!==pe||t[105]!==ve||t[106]!==we||t[107]!==Ee||t[108]!==ke||t[109]!==Ae?(je=(0,$.jsxs)(Me,{testId:`file-explorer-more-button`,iconClassName:`w-5 h-5`,children:[ie,X,ae,se,ce,de,pe,me,ve,we,Ee,De,ke,Ae]}),t[98]=ie,t[99]=X,t[100]=ae,t[101]=se,t[102]=ce,t[103]=de,t[104]=pe,t[105]=ve,t[106]=we,t[107]=Ee,t[108]=ke,t[109]=Ae,t[110]=je):je=t[110];let Ne;t[111]!==J||t[112]!==ne||t[113]!==Y||t[114]!==je?(Ne=(0,$.jsxs)(`span`,{className:J,children:[ne,Y,je]}),t[111]=J,t[112]=ne,t[113]=Y,t[114]=je,t[115]=Ne):Ne=t[115];let Le;return t[116]!==o||t[117]!==a||t[118]!==G||t[119]!==K||t[120]!==Ne||t[121]!==U?(Le=(0,$.jsxs)(`div`,{style:a,ref:o,...U,className:W,draggable:!0,onClick:G,children:[K,Ne]}),t[116]=o,t[117]=a,t[118]=G,t[119]=K,t[120]=Ne,t[121]=U,t[122]=Le):Le=t[122],Le},Rn=e=>{let t=(0,Q.c)(3),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`w-4 h-4 shrink-0`}),t[0]=e):e=t[0],e}let r;return t[1]===n.isOpen?r=t[2]:(r=(0,$.jsx)(le,{isExpanded:n.isOpen,className:`w-4 h-4`}),t[1]=n.isOpen,t[2]=r),r};function zn(e,t){e.stopPropagation(),e.preventDefault(),_t(t)}function Bn(e,t){return t===e.getRootPath()?`workspace root`:e.relativeFromRoot(t)}function Vn(e,t){if(t)return e;let n=[];for(let r of e){if(Hn(r.name))continue;let e=r;if(r.children){let n=Vn(r.children,t);n!==r.children&&(e={...r,children:n})}n.push(e)}return n}function Hn(e){return!!e.startsWith(`.`)}function Un(e,t){return e.some(e=>e.path===t||(e.children?Un(e.children,t):!1))}function Wn(){return null}function Gn(e){let{parentNode:t}=e;return!t.data.isDirectory}var Kn=e=>{let t=(0,Q.c)(44),{height:n}=e,i=r(_n),[a,o]=(0,Z.useState)(null),s;t[0]===i?s=t[1]:(s=e=>qn(e,i.getRootPath()),t[0]=i,t[1]=s);let c=s,l;t[2]===i?l=t[3]:(l=e=>i.refreshPath(e),t[2]=i,t[3]=l);let u=l,d;t[4]===i?d=t[5]:(d=e=>Bn(i,e),t[4]=i,t[5]=d);let f,p;t[6]===c?(f=t[7],p=t[8]):(f=e=>o(c(e)),p=e=>o(c(e)),t[6]=c,t[7]=f,t[8]=p);let m,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>o(null),h=()=>o(null),t[9]=m,t[10]=h):(m=t[9],h=t[10]);let g;t[11]!==c||t[12]!==u||t[13]!==d||t[14]!==f||t[15]!==p?(g={noClick:!0,noKeyboard:!0,destinationPath:c,getDestinationLabel:d,refreshDestination:u,onDragEnter:f,onDragOver:p,onDragLeave:m,onUploadStart:h},t[11]=c,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=g):g=t[16];let{getRootProps:_,getInputProps:v,isDragActive:y}=wn(g),b;t[17]!==a||t[18]!==i?(b=a??i.getRootPath(),t[17]=a,t[18]=i,t[19]=b):b=t[19];let x=b,S;t[20]!==x||t[21]!==i?(S=Bn(i,x),t[20]=x,t[21]=i,t[22]=S):S=t[22];let C=S,w;t[23]===_?w=t[24]:(w=_(),t[23]=_,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=j(`flex flex-col overflow-hidden relative`),t[25]=T):T=t[25];let E;t[26]===n?E=t[27]:(E={height:n},t[26]=n,t[27]=E);let D;t[28]===v?D=t[29]:(D=v(),t[28]=v,t[29]=D);let O;t[30]===D?O=t[31]:(O=(0,$.jsx)(`input`,{...D}),t[30]=D,t[31]=O);let k;t[32]!==C||t[33]!==y?(k=y&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-start justify-center pt-3 bg-accent/20 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none`,children:(0,$.jsxs)(`span`,{className:`px-3 py-1.5 rounded-md bg-background/95 border shadow-sm text-sm font-semibold text-primary`,children:[`Drop files into `,C]})}),t[32]=C,t[33]=y,t[34]=k):k=t[34];let A=y?x:null,M;t[35]!==n||t[36]!==A?(M=(0,$.jsx)(Nn,{height:n,externalDropDestinationPath:A}),t[35]=n,t[36]=A,t[37]=M):M=t[37];let N;return t[38]!==w||t[39]!==E||t[40]!==O||t[41]!==k||t[42]!==M?(N=(0,$.jsx)(un,{children:(0,$.jsxs)(`div`,{...w,className:T,style:E,children:[O,k,M]})}),t[38]=w,t[39]=E,t[40]=O,t[41]=k,t[42]=M,t[43]=N):N=t[43],N};function qn(e,t){return Array.isArray(e)?t:Dn(e.target,t)}var Jn=()=>{let e=(0,Q.c)(40),{ref:n,height:i}=nt(),a=i===void 0?500:i,[o,c]=t(vt),l=r(S).length,u=s(`storage`),d;bb0:{if(!o.hasUserInteracted&&l>0){if(o.openSections.includes(`remote-storage`)){d=o.openSections;break bb0}let t;e[0]===o.openSections?t=e[1]:(t=[...o.openSections,`remote-storage`],e[0]=o.openSections,e[1]=t),d=t;break bb0}d=o.openSections}let f=d,p;e[2]===c?p=e[3]:(p=e=>{c({openSections:e,hasUserInteracted:!0})},e[2]=c,e[3]=p);let m=p,h=a-66,g;e[4]===f?g=e[5]:(g=f.includes(`remote-storage`),e[4]=f,e[5]=g);let _=g,v=u.length>0,y;e[6]!==f||e[7]!==_?(y=_&&f.includes(`files`),e[6]=f,e[7]=_,e[8]=y):y=e[8];let b=y,x;e[9]!==h||e[10]!==b?(x=b?Math.round(h*.4):h,e[9]=h,e[10]=b,e[11]=x):x=e[11];let C=x,w=Math.max(200,b?h-C:h),T;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Ce,{className:`w-4 h-4`}),e[12]=T):T=e[12];let E;e[13]===l?E=e[14]:(E=l>0&&(0,$.jsx)(ct,{children:l}),e[13]=l,e[14]=E);let D;e[15]!==u.length||e[16]!==v?(D=v&&(0,$.jsx)(mt,{count:u.length,type:`storage`}),e[15]=u.length,e[16]=v,e[17]=D):D=e[17];let O;e[18]!==E||e[19]!==D?(O=(0,$.jsxs)(lt,{children:[T,` Remote storage`,E,D]}),e[18]=E,e[19]=D,e[20]=O):O=e[20];let k;e[21]===C?k=e[22]:(k={maxHeight:C},e[21]=C,e[22]=k);let A;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(nn,{}),e[23]=A):A=e[23];let j;e[24]===k?j=e[25]:(j=(0,$.jsx)(ut,{className:`overflow-auto`,style:k,children:A}),e[24]=k,e[25]=j);let M;e[26]!==j||e[27]!==O?(M=(0,$.jsxs)(ft,{value:`remote-storage`,children:[O,j]}),e[26]=j,e[27]=O,e[28]=M):M=e[28];let P;e[29]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsxs)(lt,{children:[(0,$.jsx)(Se,{className:`w-4 h-4`}),`Files`]}),e[29]=P):P=e[29];let F;e[30]===w?F=e[31]:(F=(0,$.jsxs)(ft,{value:`files`,children:[P,(0,$.jsx)(ut,{children:(0,$.jsx)(Kn,{height:w})})]}),e[30]=w,e[31]=F);let I;e[32]!==m||e[33]!==f||e[34]!==M||e[35]!==F?(I=(0,$.jsxs)(N,{type:`multiple`,value:f,onValueChange:m,children:[M,F]}),e[32]=m,e[33]=f,e[34]=M,e[35]=F,e[36]=I):I=e[36];let L;return e[37]!==n||e[38]!==I?(L=(0,$.jsx)(`div`,{ref:n,className:`h-full overflow-auto`,children:I}),e[37]=n,e[38]=I,e[39]=L):L=e[39],L};export{Jn as default,qn as getUploadDestinationForEvent};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { buildMediaSource } from "../renderers";
|
|
4
|
-
|
|
5
|
-
describe("buildMediaSource", () => {
|
|
6
|
-
it("returns base64 source for binary media", () => {
|
|
7
|
-
expect(
|
|
8
|
-
buildMediaSource({
|
|
9
|
-
contents: "aGVsbG8=",
|
|
10
|
-
mimeType: "image/png",
|
|
11
|
-
isBase64: true,
|
|
12
|
-
}),
|
|
13
|
-
).toEqual({
|
|
14
|
-
base64: "aGVsbG8=",
|
|
15
|
-
mime: "image/png",
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns UTF-8 data URL for text-based media", () => {
|
|
20
|
-
const svg = '<svg xmlns="http://www.w3.org/2000/svg"></svg>';
|
|
21
|
-
expect(
|
|
22
|
-
buildMediaSource({
|
|
23
|
-
contents: svg,
|
|
24
|
-
mimeType: "image/svg+xml",
|
|
25
|
-
isBase64: false,
|
|
26
|
-
}),
|
|
27
|
-
).toEqual({
|
|
28
|
-
url: `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`,
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|