@marimo-team/frontend 0.23.14-dev19 → 0.23.14-dev21
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/{CellStatus-B3d9WY2x.js → CellStatus-CSZHI8sz.js} +1 -1
- package/dist/assets/{JsonOutput-C3c9GGaV.js → JsonOutput-CYIo9GSP.js} +12 -12
- package/dist/assets/MarimoErrorOutput-BokuSnpU.js +11 -0
- package/dist/assets/{RenderHTML-v15QgtRg.js → RenderHTML-B9mw7TD1.js} +1 -1
- package/dist/assets/{RunButton-Bz4eaTJM.js → RunButton-CX_nNY62.js} +1 -1
- package/dist/assets/{add-cell-with-ai-wau9Yzcj.js → add-cell-with-ai-DwzlK27e.js} +47 -34
- package/dist/assets/{add-connection-dialog-_KCPEn7U.js → add-connection-dialog-fmiSisf0.js} +6 -6
- package/dist/assets/{agent-panel-Bn9AgwJH.js → agent-panel-BDO44WWH.js} +5 -5
- package/dist/assets/{ai-model-dropdown-BeZrAec-.js → ai-model-dropdown-BP8gjnOy.js} +3 -3
- package/dist/assets/{app-config-button-BG9ONWMU.js → app-config-button-CVpG64c2.js} +1 -1
- package/dist/assets/{cell-editor-24ykqaHj.js → cell-editor-Bbir67_U.js} +10 -10
- package/dist/assets/cell-link-CBRggkzf.js +1 -0
- package/dist/assets/{cells-DENsmH9t.js → cells-RJTD-euN.js} +44 -44
- package/dist/assets/{chat-display-CcL_dydg.js → chat-display-17k5Uy0b.js} +1 -1
- package/dist/assets/{chat-panel-CA-2-S1C.js → chat-panel-CGwZggen.js} +2 -2
- package/dist/assets/{chat-ui-DQeA0_b5.js → chat-ui-BrSyHh93.js} +1 -1
- package/dist/assets/{column-preview-BPgYXdDd.js → column-preview-dW7xtQ7S.js} +1 -1
- package/dist/assets/{command-palette-WlkKgdrI.js → command-palette-DtKhXIMn.js} +1 -1
- package/dist/assets/{common-DdBQICbD.js → common-DHzo8K8C.js} +1 -1
- package/dist/assets/components-ChBJEsmj.js +1 -0
- package/dist/assets/datasource-RP7m6Xrh.js +3 -0
- package/dist/assets/{dependency-graph-panel-nYHPHFU4.js → dependency-graph-panel-CjdEazj5.js} +4 -4
- package/dist/assets/{documentation-panel-Dw9tYBNf.js → documentation-panel-BcUF41gA.js} +1 -1
- package/dist/assets/{download-4NoBestd.js → download-CJ6tdZ-1.js} +4 -4
- package/dist/assets/{edit-page-CAfBRrHn.js → edit-page-lo6LC4Ie.js} +6 -6
- package/dist/assets/{error-panel-Ddr_mbqR.js → error-panel-D_1OmgVJ.js} +1 -1
- package/dist/assets/{file-explorer-panel-DhpN8_pR.js → file-explorer-panel-CG5na8ox.js} +3 -3
- package/dist/assets/{file-icons-BFLcd4J7.js → file-icons-CGJ6uWXm.js} +1 -1
- package/dist/assets/{file-name-input-x53prQQ6.js → file-name-input-DC8-M5r1.js} +1 -1
- package/dist/assets/{floating-outline--OlHG_yX.js → floating-outline-BOkj3eC_.js} +1 -1
- package/dist/assets/{focus-CZUEQpxX.js → focus-BViZMdHR.js} +1 -1
- package/dist/assets/{form-CJ3pB1ow.js → form-BbqpGicG.js} +2 -2
- package/dist/assets/{home-page-pH8-XovY.js → home-page-CU6li-ts.js} +2 -2
- package/dist/assets/{hooks-BqjZMbeu.js → hooks-CPpze3O4.js} +1 -1
- package/dist/assets/{html-to-image-B6eCuh-2.js → html-to-image-B8ja7wwq.js} +2 -2
- package/dist/assets/{index-CNmQbGXF.js → index-BcxGcwkJ.js} +6 -6
- package/dist/assets/kiosk-mode-BP35ALfP.js +1 -0
- package/dist/assets/{layout-DLJQyOOv.js → layout-BSHt96Sb.js} +5 -5
- package/dist/assets/{logs-panel-BBGNeMzu.js → logs-panel-CbZLi2XS.js} +1 -1
- package/dist/assets/{markdown-renderer-CcLl4-oB.js → markdown-renderer-jghC8PFL.js} +2 -2
- package/dist/assets/{name-cell-input-CNq9BTL7.js → name-cell-input-CN4MRZOm.js} +1 -1
- package/dist/assets/{outline-panel-CnGBTEs0.js → outline-panel-CvB3hUJ2.js} +1 -1
- package/dist/assets/{packages-panel-B17awHIF.js → packages-panel-BGgZLApn.js} +1 -1
- package/dist/assets/{panels-P8wFgP-8.js → panels-DCWntQim.js} +1 -1
- package/dist/assets/process-output-xDK6-i-G.js +1 -0
- package/dist/assets/{radio-group-B8OldelF.js → radio-group-DFkF8CeQ.js} +1 -1
- package/dist/assets/{readonly-code-display-bvftv2Nk.js → readonly-code-display-BHx0vyug.js} +1 -1
- package/dist/assets/{readonly-python-code-CoFR55Yt.js → readonly-python-code-Cla-uJpn.js} +1 -1
- package/dist/assets/{reveal-component-CfBFUsP0.js → reveal-component-Bvxyfpeh.js} +15 -15
- package/dist/assets/{run-page-CFoRuGGY.js → run-page-Cxc4jqCp.js} +1 -1
- package/dist/assets/scratchpad-panel-Bp4sg_00.js +1 -0
- package/dist/assets/{session-panel-D5OQ5JSm.js → session-panel-WkryRIGA.js} +1 -1
- package/dist/assets/{snippets-panel-DvfXacKM.js → snippets-panel-BcDwLUNv.js} +1 -1
- package/dist/assets/{state-CQn0dE8X.js → state-CXzKtmF5.js} +2 -2
- package/dist/assets/{state-LM4pQmYL.js → state-DHqaTLr2.js} +1 -1
- package/dist/assets/{textarea-Tswrj-fB.js → textarea-B5Bp08T3.js} +1 -1
- package/dist/assets/{tracing-BMvzhCBv.js → tracing-clJBeQm6.js} +1 -1
- package/dist/assets/{tracing-panel-DJF6cCQK.js → tracing-panel-7j9NY9lO.js} +2 -2
- package/dist/assets/{tree-actions-Bnmh7YGo.js → tree-actions-DLySKXUq.js} +1 -1
- package/dist/assets/useCellActionButton-CvQRbg1P.js +1 -0
- package/dist/assets/{useDeleteCell-DwNTIWuB.js → useDeleteCell-Sj06CzJn.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-BH_Eu2Kq.js → useDependencyPanelTab-BTgQmu1R.js} +1 -1
- package/dist/assets/{useNotebookActions-BmO8IOgN.js → useNotebookActions-9PPlpXk8.js} +1 -1
- package/dist/assets/useRunCells-D5aAUcAa.js +1 -0
- package/dist/assets/useSplitCell-CGE6jkuF.js +1 -0
- package/dist/index.html +22 -22
- package/package.json +2 -2
- package/src/components/editor/errors/__tests__/auto-fix.test.ts +11 -107
- package/src/components/editor/errors/auto-fix.tsx +11 -31
- package/src/components/editor/output/MarimoTracebackOutput.tsx +2 -2
- package/src/core/ai/context/__tests__/registry.test.ts +133 -3
- package/src/core/ai/context/providers/__tests__/datasource.test.ts +3 -1
- package/src/core/ai/context/providers/__tests__/error.test.ts +200 -15
- package/src/core/ai/context/providers/datasource.ts +27 -2
- package/src/core/ai/context/providers/error.ts +226 -36
- package/src/core/ai/context/registry.ts +77 -43
- package/src/core/codemirror/ai/resources.ts +15 -10
- package/src/core/errors/errors.ts +2 -1
- package/src/core/mime.ts +11 -4
- package/dist/assets/MarimoErrorOutput-D07aAGkQ.js +0 -12
- package/dist/assets/cell-link-exzcyUhT.js +0 -1
- package/dist/assets/components-DinLkTiR.js +0 -1
- package/dist/assets/datasource-BCOYpQ69.js +0 -3
- package/dist/assets/kiosk-mode-BBfHxqEx.js +0 -1
- package/dist/assets/process-output-BGcDSQBk.js +0 -1
- package/dist/assets/scratchpad-panel-DdKvJKy4.js +0 -1
- package/dist/assets/useCellActionButton-ibDHNca0.js +0 -1
- package/dist/assets/useRunCells-CTpvxsqp.js +0 -1
- package/dist/assets/useSplitCell-CFO4Cg5B.js +0 -1
- package/src/core/ai/context/providers/__tests__/__snapshots__/error.test.ts.snap +0 -3
|
@@ -9,11 +9,19 @@ import { MultiMap } from "@/utils/multi-map";
|
|
|
9
9
|
import type { TypedString } from "@/utils/typed";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Unique identifier for a context item in the format "type
|
|
12
|
+
* Unique identifier for a context item in the format "type://id"
|
|
13
13
|
* e.g., "variable://my_var", "data://users", "file://config.py"
|
|
14
14
|
*/
|
|
15
15
|
export type ContextLocatorId = TypedString<"ContextLocatorId">;
|
|
16
16
|
|
|
17
|
+
function parseContextType(uri: ContextLocatorId): string | undefined {
|
|
18
|
+
const separator = uri.indexOf("://");
|
|
19
|
+
if (separator === -1) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return uri.slice(0, separator);
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Base interface for context items that can be mentioned in AI prompts
|
|
19
27
|
*/
|
|
@@ -142,40 +150,80 @@ export class AIContextRegistry<T extends AIContextItem> {
|
|
|
142
150
|
);
|
|
143
151
|
}
|
|
144
152
|
|
|
153
|
+
private findProviderForUri(
|
|
154
|
+
uri: ContextLocatorId,
|
|
155
|
+
): AIContextProvider | undefined {
|
|
156
|
+
const type = parseContextType(uri);
|
|
157
|
+
if (!type) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
return [...this.providers].find(
|
|
161
|
+
(provider) =>
|
|
162
|
+
provider.contextType === type &&
|
|
163
|
+
provider.getItems().some((item) => item.uri === uri),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
145
167
|
/**
|
|
146
|
-
*
|
|
168
|
+
* Resolve only the requested context items, querying each matching provider
|
|
147
169
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
resolveItems(contextIds: ContextLocatorId[]): T[] {
|
|
171
|
+
if (contextIds.length === 0) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const idsByType = new MultiMap<string, ContextLocatorId>();
|
|
176
|
+
for (const contextId of contextIds) {
|
|
177
|
+
const type = parseContextType(contextId);
|
|
178
|
+
if (type) {
|
|
179
|
+
idsByType.add(type, contextId);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const itemsById = new Map<ContextLocatorId, T>();
|
|
184
|
+
for (const [type, ids] of idsByType.entries()) {
|
|
185
|
+
const providers = [...this.providers].filter(
|
|
186
|
+
(provider) => provider.contextType === type,
|
|
187
|
+
);
|
|
188
|
+
for (const provider of providers) {
|
|
189
|
+
const itemsByUri = new Map<ContextLocatorId, T>(
|
|
190
|
+
provider
|
|
191
|
+
.getItems()
|
|
192
|
+
.map((item) => [item.uri as ContextLocatorId, item as T]),
|
|
193
|
+
);
|
|
194
|
+
for (const id of ids) {
|
|
195
|
+
const item = itemsByUri.get(id);
|
|
196
|
+
if (item) {
|
|
197
|
+
itemsById.set(id, item);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
153
202
|
|
|
203
|
+
// Preserve the order in which the ids were requested, so formatted context
|
|
204
|
+
// matches the order the user mentioned them in the prompt.
|
|
205
|
+
const results: T[] = [];
|
|
154
206
|
for (const contextId of contextIds) {
|
|
155
|
-
const item =
|
|
207
|
+
const item = itemsById.get(contextId);
|
|
156
208
|
if (item) {
|
|
157
|
-
|
|
209
|
+
results.push(item);
|
|
158
210
|
}
|
|
159
211
|
}
|
|
212
|
+
return results;
|
|
213
|
+
}
|
|
160
214
|
|
|
161
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Get context information for mentioned items
|
|
217
|
+
*/
|
|
218
|
+
getContextInfo(contextIds: ContextLocatorId[]): T[] {
|
|
219
|
+
return this.resolveItems(contextIds);
|
|
162
220
|
}
|
|
163
221
|
|
|
164
222
|
/**
|
|
165
223
|
* Format context for AI prompt inclusion
|
|
166
224
|
*/
|
|
167
225
|
formatContextForAI(contextIds: ContextLocatorId[]): string {
|
|
168
|
-
const
|
|
169
|
-
this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const contextInfo: T[] = [];
|
|
173
|
-
for (const contextId of contextIds) {
|
|
174
|
-
const item = allItems.get(contextId);
|
|
175
|
-
if (item) {
|
|
176
|
-
contextInfo.push(item);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
226
|
+
const contextInfo = this.resolveItems(contextIds);
|
|
179
227
|
|
|
180
228
|
if (contextInfo.length === 0) {
|
|
181
229
|
return "";
|
|
@@ -183,7 +231,7 @@ export class AIContextRegistry<T extends AIContextItem> {
|
|
|
183
231
|
|
|
184
232
|
return contextInfo
|
|
185
233
|
.map((item) => {
|
|
186
|
-
const provider = this.
|
|
234
|
+
const provider = this.findProviderForUri(item.uri as ContextLocatorId);
|
|
187
235
|
return provider?.formatContext(item) || "";
|
|
188
236
|
})
|
|
189
237
|
.join("\n\n");
|
|
@@ -195,36 +243,22 @@ export class AIContextRegistry<T extends AIContextItem> {
|
|
|
195
243
|
async getAttachmentsForContext(
|
|
196
244
|
contextIds: ContextLocatorId[],
|
|
197
245
|
): Promise<FileUIPart[]> {
|
|
198
|
-
const
|
|
199
|
-
this.getAllItems().map((item) => [item.uri as ContextLocatorId, item]),
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
const contextInfo: T[] = [];
|
|
203
|
-
for (const contextId of contextIds) {
|
|
204
|
-
const item = allItems.get(contextId);
|
|
205
|
-
if (item) {
|
|
206
|
-
contextInfo.push(item);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
246
|
+
const contextInfo = this.resolveItems(contextIds);
|
|
209
247
|
|
|
210
248
|
if (contextInfo.length === 0) {
|
|
211
249
|
return [];
|
|
212
250
|
}
|
|
213
251
|
|
|
214
|
-
|
|
215
|
-
const itemsByProvider = new MultiMap<string, T>();
|
|
252
|
+
const itemsByProvider = new MultiMap<AIContextProvider, T>();
|
|
216
253
|
for (const item of contextInfo) {
|
|
217
|
-
const
|
|
218
|
-
|
|
254
|
+
const provider = this.findProviderForUri(item.uri as ContextLocatorId);
|
|
255
|
+
if (provider) {
|
|
256
|
+
itemsByProvider.add(provider, item);
|
|
257
|
+
}
|
|
219
258
|
}
|
|
220
259
|
|
|
221
|
-
// Collect attachments from all providers
|
|
222
260
|
const attachmentPromises = [...itemsByProvider.entries()].map(
|
|
223
|
-
async ([
|
|
224
|
-
const provider = this.getProvider(providerType);
|
|
225
|
-
if (!provider) {
|
|
226
|
-
return [];
|
|
227
|
-
}
|
|
261
|
+
async ([provider, items]) => {
|
|
228
262
|
try {
|
|
229
263
|
return await provider.getAttachments(items);
|
|
230
264
|
} catch (error) {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
resourceDecorations,
|
|
12
12
|
resourceInputFilter,
|
|
13
13
|
resourcesField,
|
|
14
|
+
resourceSync,
|
|
14
15
|
resourceTheme,
|
|
15
16
|
} from "@marimo-team/codemirror-mcp";
|
|
16
17
|
import {
|
|
@@ -38,25 +39,28 @@ const NONE_RESOURCE_FORMAT_COMPLETION = {
|
|
|
38
39
|
},
|
|
39
40
|
};
|
|
40
41
|
|
|
42
|
+
function getRegistryResources(store: JotaiStore): Resource[] {
|
|
43
|
+
const registry = getAIContextRegistry(store);
|
|
44
|
+
const resources = registry.getAllItems();
|
|
45
|
+
if (resources.length === 0) {
|
|
46
|
+
return NONE_RESOURCE;
|
|
47
|
+
}
|
|
48
|
+
return resources;
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
export function resourceExtension(opts: {
|
|
42
52
|
language: Language;
|
|
43
53
|
store: JotaiStore;
|
|
44
54
|
onAddFiles?: (files: File[]) => void;
|
|
45
55
|
}): Extension[] {
|
|
46
56
|
const { language, store, onAddFiles } = opts;
|
|
57
|
+
const getResources = () => getRegistryResources(store);
|
|
47
58
|
|
|
48
59
|
return [
|
|
49
60
|
language.data.of({
|
|
50
61
|
// Resource completion for static resources (variables, tables, etc.)
|
|
51
62
|
autocomplete: resourceCompletion(
|
|
52
|
-
async (): Promise<Resource[]> =>
|
|
53
|
-
const registry = getAIContextRegistry(store);
|
|
54
|
-
const resources = registry.getAllItems();
|
|
55
|
-
if (resources.length === 0) {
|
|
56
|
-
return NONE_RESOURCE;
|
|
57
|
-
}
|
|
58
|
-
return resources;
|
|
59
|
-
},
|
|
63
|
+
async (): Promise<Resource[]> => getResources(),
|
|
60
64
|
(resource) => {
|
|
61
65
|
if (resource.type === NONE_RESOURCE_TYPE) {
|
|
62
66
|
return NONE_RESOURCE_FORMAT_COMPLETION;
|
|
@@ -92,9 +96,10 @@ export function resourceExtension(opts: {
|
|
|
92
96
|
: []),
|
|
93
97
|
resourceDecorations,
|
|
94
98
|
resourceInputFilter,
|
|
99
|
+
// Resolve @-mention chips for programmatic prefills.
|
|
100
|
+
resourceSync(getResources, { logger: Logger }),
|
|
95
101
|
resourcesField.init(() => {
|
|
96
|
-
const
|
|
97
|
-
const resources = registry.getAllItems();
|
|
102
|
+
const resources = getRegistryResources(store);
|
|
98
103
|
return new Map(resources.map((resource) => [resource.uri, resource]));
|
|
99
104
|
}),
|
|
100
105
|
resourceTheme,
|
|
@@ -6,6 +6,7 @@ import type { AiCompletionCell } from "../ai/state";
|
|
|
6
6
|
import type { CellId } from "../cells/ids";
|
|
7
7
|
import type { MarimoError } from "../kernel/messages";
|
|
8
8
|
import { wrapInFunction } from "./utils";
|
|
9
|
+
import { store } from "../state/jotai";
|
|
9
10
|
|
|
10
11
|
interface AIFix {
|
|
11
12
|
setAiCompletionCell: (opts: AiCompletionCell) => void;
|
|
@@ -84,7 +85,7 @@ export function getAutoFixes(
|
|
|
84
85
|
description: "Fix the SQL statement",
|
|
85
86
|
fixType: "ai",
|
|
86
87
|
onFix: async (ctx) => {
|
|
87
|
-
const datasourceContext = getDatasourceContext(ctx.cellId);
|
|
88
|
+
const datasourceContext = getDatasourceContext(ctx.cellId, store);
|
|
88
89
|
let initialPrompt = `Fix the SQL statement: ${error.msg}.`;
|
|
89
90
|
if (datasourceContext) {
|
|
90
91
|
initialPrompt += `\nDatabase schema: ${datasourceContext}`;
|
package/src/core/mime.ts
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import type { OutputMessage } from "./kernel/messages";
|
|
3
3
|
|
|
4
|
+
export function isMarimoErrorsMime(
|
|
5
|
+
mime: OutputMessage["mimetype"] | undefined,
|
|
6
|
+
) {
|
|
7
|
+
return mime === "application/vnd.marimo+error";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isTracebackMime(mime: OutputMessage["mimetype"] | undefined) {
|
|
11
|
+
return mime === "application/vnd.marimo+traceback";
|
|
12
|
+
}
|
|
13
|
+
|
|
4
14
|
export function isErrorMime(mime: OutputMessage["mimetype"] | undefined) {
|
|
5
|
-
return (
|
|
6
|
-
mime === "application/vnd.marimo+error" ||
|
|
7
|
-
mime === "application/vnd.marimo+traceback"
|
|
8
|
-
);
|
|
15
|
+
return isMarimoErrorsMime(mime) || isTracebackMime(mime);
|
|
9
16
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{s as le}from"./chunk-LvLJmgfZ.js";import{d as ae,f as ie,l as oe,n as Re,p as Ve,u as ce}from"./useEvent-D91BmmQi.js";import{t as He}from"./react-Bj1aDYRI.js";import{Ci as de,D as Ge,Ii as Y,In as Z,Nn as me,On as pe,Si as Je,_r as Ke,b as Xe,it as Ye,pr as Ze}from"./cells-DENsmH9t.js";import{t as A}from"./compiler-runtime-B3qBwwSJ.js";import{_ as et,m as tt}from"./useEventListener-BakX-tnw.js";import{t as st}from"./invariant-C2E8KCbD.js";import{a as nt,i as rt,y as lt}from"./utils-Dev6I_Kv.js";import{t as ue}from"./cn-X2M2usMq.js";import{t as at}from"./jsx-runtime-PbYoItBR.js";import{a as it,i as ot,o as ct,r as dt,t as mt}from"./config-DMNo9K-z.js";import{a as pt,p as ut,r as xt,t as ht}from"./dropdown-menu-DfGLyCbP.js";import{t as Q}from"./tooltip-CgQpRVyN.js";import{r as xe,t as z}from"./button-BF7GSjhW.js";import{n as ft}from"./strings-DvZlHYnD.js";import{t as he}from"./createLucideIcon-BTp1tQDO.js";import{t as gt}from"./check-DQmqoJgr.js";import{r as fe}from"./x-9vLEgLY6.js";import{t as jt}from"./chevron-right-C7RH0Nc7.js";import{t as yt}from"./hat-glasses-DlK0E4SX.js";import{t as bt}from"./package-BTIV9-Dk.js";import{t as vt}from"./sparkles-COaEc8Qn.js";import{c as ge,n as je}from"./datasource-BCOYpQ69.js";import{a as Nt}from"./dist-BtrqKtvn.js";import{t as It}from"./uuid-ClFZlR7U.js";import{t as wt}from"./use-toast-kCNiuc-_.js";import{t as kt}from"./RenderHTML-v15QgtRg.js";import{t as ye}from"./kbd-UVzWBHfi.js";import{t as q}from"./links-CCkJpphF.js";import{r as $t,t as _t}from"./alert-1y_DnRWn.js";import{o as At,t as Tt}from"./useInstallPackage-C1Dd0aIZ.js";import{a as Ft,n as St}from"./state-LM4pQmYL.js";import{n as $}from"./cell-link-exzcyUhT.js";var D=he("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),be=he("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),ve=String.raw`_cell_([^\W_][\w-]*?)(_\w*)`,Ne=String.raw`(?<!_)${ve}`;`${ve}`;var Ct=new RegExp(Ne),ee=new RegExp(Ne,"g");function Ie(t){let e=[];ee.lastIndex=0;let n=0,r=ee.exec(t);for(;r!==null;)r.index>n&&e.push(t.slice(n,r.index)),e.push({cellId:r[1],name:r[2]}),n=r.index+r[0].length,r=ee.exec(t);return n<t.length&&e.push(t.slice(n)),e}function Mt(t){return Ct.test(t)}function zt(t){let e=null,n=t.cursor();do n.name==="ExpressionStatement"&&(e=n.node);while(n.next());return e}function Et(t){let e=t.split(`
|
|
2
|
-
`),n=" ",r=zt(Nt.parse(t));if(!r)return["def _():",...te(e,n),`${n}return`,"","","_()"].join(`
|
|
3
|
-
`);let l=t.slice(0,r.from).trim(),a=t.slice(r.from).trim(),o=l.split(`
|
|
4
|
-
`),i=a.split(`
|
|
5
|
-
`);return["def _():",...te(o,n),`${n}return ${i[0]}`,...te(i.slice(1),n),"","","_()"].join(`
|
|
6
|
-
`)}function te(t,e){if(t.length===1&&t[0]==="")return[];let n=[];for(let r of t)r===""?n.push(""):n.push(e+r);return n}function Pt(t,e){var n;if(t.type==="multiple-defs")return[{title:"Fix: Wrap in a function",description:"Make this cell's variables local by wrapping the cell in a function.",fixType:"manual",onFix:async r=>{st(r.editor,"Editor is null");let l=Et(r.editor.state.doc.toString());r.editor.dispatch({changes:{from:0,to:r.editor.state.doc.length,insert:l}})}}];if(t.type==="exception"&&t.exception_type==="NameError"){let r=(n=t.msg.match(/name '(.+)' is not defined/))==null?void 0:n[1];if(!r||!(r in we))return[];let l=qt(r);return[{title:`Fix: Add '${l}'`,description:"Add a new cell for the missing import",fixType:"manual",onFix:async a=>{a.addCodeBelow(l)}}]}return t.type==="sql-error"&&e.aiEnabled?[{title:"Fix with AI",description:"Fix the SQL statement",fixType:"ai",onFix:async r=>{var o;let l=je(r.cellId),a=`Fix the SQL statement: ${t.msg}.`;l&&(a+=`
|
|
7
|
-
Database schema: ${l}`),(o=r.aiFix)==null||o.setAiCompletionCell({cellId:r.cellId,initialPrompt:a,triggerImmediately:r.aiFix.triggerFix})}}]:[]}function qt(t){let e=we[t];return e===t?`import ${e}`:`import ${e} as ${t}`}var we={mo:"marimo",alt:"altair",bokeh:"bokeh",dask:"dask",np:"numpy",pd:"pandas",pl:"polars",plotly:"plotly",plt:"matplotlib.pyplot",px:"plotly.express",scipy:"scipy",sk:"sklearn",sns:"seaborn",stats:"scipy.stats",tf:"tensorflow",torch:"torch",xr:"xarray",dt:"datetime",json:"json",math:"math",os:"os",re:"re",sys:"sys"},ke=1;const R=Y("marimo:acp:sessions:v1",{sessions:[],activeTabId:null},Z),Dt=Ve(t=>{let e=t(R);return e.activeTabId&&e.sessions.find(n=>n.tabId===e.activeTabId)||null},(t,e,n)=>{e(R,r=>({...r,activeTabId:n}))});function Lt(){return`tab_${It()}`}function $e(t,e=20){return t.length<=e?t:`${t.slice(0,e-3)}...`}function Wt(t,e){let n=_e(e.agentId),r=Date.now(),l=e.firstMessage?$e(e.firstMessage.trim()):`New ${e.agentId} session`,a=Lt();if(n==="single"){let o=t.sessions.filter(c=>c.agentId===e.agentId),i=t.sessions.filter(c=>c.agentId!==e.agentId);if(o.length>0){let c=o[0],d={agentId:e.agentId,title:l,createdAt:r,lastUsedAt:r,tabId:c.tabId,externalAgentSessionId:null,selectedModel:e.model??c.selectedModel??null};return{...t,sessions:[...i.slice(0,ke-1),d],activeTabId:d.tabId}}}return{...t,sessions:[...t.sessions.slice(0,ke-1),{agentId:e.agentId,tabId:a,title:l,createdAt:r,lastUsedAt:r,externalAgentSessionId:null,selectedModel:e.model??null}],activeTabId:a}}function Ut(t,e){let n=t.sessions.filter(r=>r.tabId!==e);return{sessions:n,activeTabId:t.activeTabId===e?n.length>0?n[n.length-1].tabId:null:t.activeTabId}}function Ot(t,e){let n=t.activeTabId;return n?{...t,sessions:t.sessions.map(r=>r.tabId===n?{...r,title:$e(e)}:r)}:t}function Bt(t,e){return{...t,sessions:t.sessions.map(n=>n.tabId===e?{...n,lastUsedAt:Date.now()}:n)}}function Qt(t,e){let n=t.activeTabId;return n?{...t,sessions:t.sessions.map(r=>r.tabId===n?{...r,externalAgentSessionId:e,lastUsedAt:Date.now()}:r)}:t}function Rt(){return["claude","gemini","codex","opencode","cursor"]}function Vt(t){return ft(t)}function Ht(t){let e=V[t].port,n=window.location.hostname;return`${window.location.protocol==="https:"?"wss:":"ws:"}//${n}:${e}/message`}var V={claude:{port:3017,command:"npx @zed-industries/claude-code-acp",sessionSupport:"single"},gemini:{port:3019,command:"npx @google/gemini-cli --experimental-acp",sessionSupport:"single"},codex:{port:3021,command:"npx @zed-industries/codex-acp",sessionSupport:"single"},opencode:{port:3023,command:"npx opencode-ai acp",sessionSupport:"single"},cursor:{port:3025,command:"agent acp",sessionSupport:"single"}};function _e(t){return V[t].sessionSupport}function Gt(t){let e=V[t].port,n=V[t].command;return`npx stdio-to-ws "${tt()?`cmd /c ${n}`:n}" --port ${e}`}var Jt=A();const Ae=Y("marimo:chrome:ai-panel-tab","chat",Z);function Te(){let t=(0,Jt.c)(3),[e,n]=oe(Ae),r;return t[0]!==e||t[1]!==n?(r={aiPanelTab:e,setAiPanelTab:n},t[0]=e,t[1]=n,t[2]=r):r=t[2],r}var Kt=A(),Xt="code_mode";function Yt(t,e){return t||(me("external_agents")?e:"chat")}function Fe(){let t=(0,Kt.c)(6),{openApplication:e}=pe(),{setAiPanelTab:n}=Te(),{saveModeChange:r}=mt(),l=ae(Ft),a=ie(),o;return t[0]!==e||t[1]!==r||t[2]!==n||t[3]!==l||t[4]!==a?(o=async i=>{let c=Yt(i.panel,a.get(Ae)),d=a.get(nt),p=me("external_agents")&&a.get(R).sessions.length>0;if(!(c==="agents"?p:d)){wt({title:c==="agents"?"No agent session":"AI not configured",description:c==="agents"?"Start an agent session or switch to the chat panel.":"Configure an AI provider and chat model to fix with AI.",variant:"danger"});return}i.panel&&n(i.panel),c==="chat"&&await r(Xt).catch(Zt),l({prompt:i.prompt,submit:i.submit??!1}),e("ai")},t[0]=e,t[1]=r,t[2]=n,t[3]=l,t[4]=a,t[5]=o):o=t[5],Re(o)}function Zt(){return et.error("Failed to save mode change")}var es=A(),ts=Y("marimo:ai-autofix-mode","autofix",Z);function ss(){let t=(0,es.c)(3),[e,n]=oe(ts),r;return t[0]!==e||t[1]!==n?(r={fixMode:e,setFixMode:n},t[0]=e,t[1]=n,t[2]=r):r=t[2],r}var se=A(),s=le(at(),1);function Se(t,e,{includeDatasourceContext:n=!1}={}){let r=`${e==null?"My code gives the following error. Please fix it:":`My cell (id: ${e}) produced the following error. Please fix it:`}
|
|
8
|
-
|
|
9
|
-
${t}`;if(e!=null&&n){let l=je(e);l&&(r+=`
|
|
10
|
-
|
|
11
|
-
Database schema: ${l}`)}return r}function ns(t,e){return Se(t.map(n=>"msg"in n&&n.msg?n.msg:n.type).join(`
|
|
12
|
-
`),e,{includeDatasourceContext:t.some(n=>n.type==="sql-error")})}const w=t=>{let e=(0,se.c)(26),{errors:n,cellId:r,className:l}=t,a=ie(),{createNewCell:o}=Ge(),i=ce(rt),c;if(e[0]!==i||e[1]!==n){let v;e[3]===i?v=e[4]:(v=k=>Pt(k,{aiEnabled:i}),e[3]=i,e[4]=v),c=n.flatMap(v),e[0]=i,e[1]=n,e[2]=c}else c=e[2];let d=c,p=ae(St),u=Fe();if(d.length===0)return null;let m=d[0],x;e[5]!==r||e[6]!==o||e[7]!==m||e[8]!==p||e[9]!==a?(x=v=>{var S;let k=(S=a.get(Xe).cellHandles[r].current)==null?void 0:S.editorView;m.onFix({addCodeBelow:E=>{o({cellId:r,autoFocus:!1,before:!1,code:E})},editor:k,cellId:r,aiFix:{setAiCompletionCell:p,triggerFix:v}}),k==null||k.focus()},e[5]=r,e[6]=o,e[7]=m,e[8]=p,e[9]=a,e[10]=x):x=e[10];let g=x,h;e[11]!==r||e[12]!==n||e[13]!==u?(h=()=>{u({prompt:ns(n,r)})},e[11]=r,e[12]=n,e[13]=u,e[14]=h):h=e[14];let y=h,j;e[15]===l?j=e[16]:(j=ue("my-2",l),e[15]=l,e[16]=j);let b;e[17]!==m.description||e[18]!==m.fixType||e[19]!==m.title||e[20]!==g||e[21]!==y?(b=m.fixType==="ai"?(0,s.jsx)(Me,{tooltip:m.description,openPrompt:()=>g(!1),applyAutofix:()=>g(!0),openChat:y}):(0,s.jsx)(Q,{content:m.description,align:"start",children:(0,s.jsxs)(z,{size:"xs",variant:"outline",className:"font-normal",onClick:()=>g(!1),children:[(0,s.jsx)(ge,{className:"h-3 w-3 mr-2"}),m.title]})}),e[17]=m.description,e[18]=m.fixType,e[19]=m.title,e[20]=g,e[21]=y,e[22]=b):b=e[22];let N;return e[23]!==j||e[24]!==b?(N=(0,s.jsx)("div",{className:j,children:b}),e[23]=j,e[24]=b,e[25]=N):N=e[25],N};var Ce={autofix:{Icon:ge,title:"Inline AI Fix",description:"Apply AI fixes inline in the cell"},chat:{Icon:yt,title:"Fix with AI assistant",description:"Open the AI sidebar to fix"},prompt:{Icon:vt,title:"Suggest a prompt",description:"Edit the prompt before applying"}},rs=["autofix","prompt","chat"];const Me=t=>{let e=(0,se.c)(18),{tooltip:n,openPrompt:r,applyAutofix:l,openChat:a}=t,{fixMode:o,setFixMode:i}=ss(),c=r;o==="chat"?c=a:o==="autofix"&&(c=l);let{Icon:d,title:p}=Ce[o],u;e[0]===d?u=e[1]:(u=(0,s.jsx)(d,{className:"h-3 w-3 mr-2 mb-0.5"}),e[0]=d,e[1]=u);let m;e[2]!==c||e[3]!==u||e[4]!==p?(m=(0,s.jsxs)(z,{size:"xs",variant:"outline",className:"font-normal rounded-r-none border-r-0",onClick:c,children:[u,p]}),e[2]=c,e[3]=u,e[4]=p,e[5]=m):m=e[5];let x;e[6]!==m||e[7]!==n?(x=(0,s.jsx)(Q,{content:n,align:"start",children:m}),e[6]=m,e[7]=n,e[8]=x):x=e[8];let g;e[9]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(ut,{asChild:!0,children:(0,s.jsx)(z,{size:"xs",variant:"outline",className:"rounded-l-none px-2","aria-label":"Fix options",children:(0,s.jsx)(fe,{className:"h-3 w-3"})})}),e[9]=g):g=e[9];let h;e[10]!==o||e[11]!==i?(h=rs.map(b=>(0,s.jsx)(pt,{className:"flex items-center gap-2",onClick:()=>i(b),children:(0,s.jsx)(ls,{mode:b,selected:b===o})},b)),e[10]=o,e[11]=i,e[12]=h):h=e[12];let y;e[13]===h?y=e[14]:(y=(0,s.jsxs)(ht,{children:[g,(0,s.jsx)(xt,{align:"end",className:"w-56",children:h})]}),e[13]=h,e[14]=y);let j;return e[15]!==x||e[16]!==y?(j=(0,s.jsxs)("div",{className:"flex",children:[x,y]}),e[15]=x,e[16]=y,e[17]=j):j=e[17],j};var ls=t=>{let e=(0,se.c)(15),{mode:n,selected:r}=t,{Icon:l,title:a,description:o}=Ce[n],i;e[0]===l?i=e[1]:(i=(0,s.jsx)(l,{className:"h-4 w-4 shrink-0"}),e[0]=l,e[1]=i);let c;e[2]===a?c=e[3]:(c=(0,s.jsx)("span",{className:"font-medium",children:a}),e[2]=a,e[3]=c);let d;e[4]===o?d=e[5]:(d=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:o}),e[4]=o,e[5]=d);let p;e[6]!==c||e[7]!==d?(p=(0,s.jsxs)("div",{className:"flex flex-col",children:[c,d]}),e[6]=c,e[7]=d,e[8]=p):p=e[8];let u;e[9]===r?u=e[10]:(u=r&&(0,s.jsx)(gt,{className:"h-4 w-4 ml-auto shrink-0"}),e[9]=r,e[10]=u);let m;return e[11]!==i||e[12]!==p||e[13]!==u?(m=(0,s.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[i,p,u]}),e[11]=i,e[12]=p,e[13]=u,e[14]=m):m=e[14],m},ze=A();const as=t=>{let e=(0,ze.c)(12),{local:n}=t,r;e[0]===n.name?r=e[1]:(r=(0,s.jsx)("span",{className:"font-code",children:n.name}),e[0]=n.name,e[1]=r);let l;e[2]===n.cellId?l=e[3]:(l=(0,s.jsx)($,{cellId:n.cellId}),e[2]=n.cellId,e[3]=l);let a;e[4]!==r||e[5]!==l?(a=(0,s.jsxs)("div",{className:"max-w-xs",children:["Local variable ",r," in cell"," ",l,"."]}),e[4]=r,e[5]=l,e[6]=a):a=e[6];let o=a,i;e[7]===n.name?i=e[8]:(i=(0,s.jsx)("span",{className:"font-code cursor-help",children:n.name}),e[7]=n.name,e[8]=i);let c;return e[9]!==i||e[10]!==o?(c=(0,s.jsx)(Q,{content:o,children:i}),e[9]=i,e[10]=o,e[11]=c):c=e[11],c},Ee=t=>{let e=(0,ze.c)(4),{segments:n}=t,r;e[0]===n?r=e[1]:(r=n.map(is),e[0]=n,e[1]=r);let l;return e[2]===r?l=e[3]:(l=(0,s.jsx)(s.Fragment,{children:r}),e[2]=r,e[3]=l),l};function is(t,e){return typeof t=="string"?(0,s.jsx)("span",{children:t},e):(0,s.jsx)(as,{local:t},e)}var Pe=/(https?:\/\/\S+)/,os=/\.(png|jpe?g|gif|webp|svg|ico)(\?.*)?$/i,qe=/^data:image\//i,cs=["avatars.githubusercontent.com"];function De(t){return qe.test(t)?[{type:"image",url:t}]:t.split(Pe).filter(e=>e!=="").map(e=>Pe.test(e)?os.test(e)||qe.test(e)||cs.some(n=>e.includes(n))?{type:"image",url:e}:{type:"url",url:e}:{type:"text",value:e})}var Le=A(),L=le(He(),1),ds=new Ye;const ne=t=>{let e=RegExp("\x1B\\[[0-9;]*m","g");return t.replaceAll(e,"")};var We=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi;function ms(t){We.lastIndex=0;let e=We.exec(t);if(!e)return null;let n=e.index+e[0].length,r=t.slice(n).split(/\s+/),l="",a=0;for(let i of r){let c=i.trim();if(!c)continue;if(c.startsWith("-")){a+=c.length+1;continue}let d=c.match(/^[\w,.[\]-]+/);if(d){l=d[0];break}break}if(!l)return null;let o=n+a+l.length;return{package:l,endIndex:o}}function T(t,e=""){if(!t)return null;if(!/https?:\/\//.test(t))return t;let n=De(t);return n.length===1&&n[0].type==="text"?t:(0,s.jsx)(s.Fragment,{children:n.map((r,l)=>{let a=e?`${e}-${l}`:l;if(r.type==="url"){let o=ne(r.url);return(0,s.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:xe.stopPropagation(),className:"text-link hover:underline",children:o},a)}if(r.type==="image"){let o=ne(r.url);return(0,s.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:xe.stopPropagation(),className:"text-link hover:underline",children:o},a)}return(0,s.jsx)(L.Fragment,{children:r.value},a)})})}var ps=t=>{let e=(0,Le.c)(6),{packages:n,children:r}=t,{handleInstallPackages:l}=Tt(),a;e[0]!==l||e[1]!==n?(a=i=>{l(n),i.preventDefault()},e[0]=l,e[1]=n,e[2]=a):a=e[2];let o;return e[3]!==r||e[4]!==a?(o=(0,s.jsx)("button",{onClick:a,className:"text-link hover:underline",type:"button",children:r}),e[3]=r,e[4]=a,e[5]=o):o=e[5],o};const us=t=>{if(!(t instanceof de.Text))return;let e=ne(t.data);if(!/(pip\s+install|uv\s+add|uv\s+pip\s+install)/i.test(e))return;let n=[],r=/(pip\s+install|uv\s+add|uv\s+pip\s+install)\s+/gi,l;for(;(l=r.exec(e))!==null;){let i=l.index,c=ms(e.slice(i));c&&n.push({match:l,result:c})}if(n.length===0)return;let a=[],o=0;if(n.forEach((i,c)=>{let{match:d,result:p}=i,u=d.index,m=u+p.endIndex;if(o<u){let g=e.slice(o,u);a.push((0,s.jsx)(L.Fragment,{children:T(g,`before-${c}`)},`before-${c}`))}let x=e.slice(u,m);a.push((0,s.jsx)(ps,{packages:[p.package],children:x},`install-${c}`)),o=m}),o<e.length){let i=e.slice(o);a.push((0,s.jsx)(L.Fragment,{children:T(i,"after")},"after"))}return(0,s.jsx)(s.Fragment,{children:a})},xs=t=>{if(!(t instanceof de.Text))return;let e=t.data;if(!/https?:\/\//.test(e))return;let n=T(e);if(typeof n!="string")return(0,s.jsx)(s.Fragment,{children:n})},hs=(...t)=>e=>{for(let n of t){let r=n(e);if(r!==void 0)return r}},fs=(t,e)=>(0,s.jsx)("span",{children:Je(ds.ansi_to_html(t),{replace:n=>e(n)})}),gs=t=>{let e=(0,Le.c)(4),{text:n}=t,r;e[0]===n?r=e[1]:(r=fs(n,hs(us,xs)),e[0]=n,e[1]=r);let l=r,a;return e[2]===l?a=e[3]:(a=(0,s.jsx)(s.Fragment,{children:l}),e[2]=l,e[3]=a),a};var re=A(),Ue=t=>{let e=(0,re.c)(16),{traceback:n}=t,[r,l]=(0,L.useState)(!0),a;e[0]===r?a=e[1]:(a=()=>l(!r),e[0]=r,e[1]=a);let o=r?"Collapse traceback":"Expand traceback",i;e[2]===r?i=e[3]:(i=r?(0,s.jsx)(fe,{className:"h-3 w-3"}):(0,s.jsx)(jt,{className:"h-3 w-3"}),e[2]=r,e[3]=i);let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:"text-[0.6875rem] uppercase tracking-wider",children:"Traceback"}),e[4]=c):c=e[4];let d;e[5]!==r||e[6]!==a||e[7]!==o||e[8]!==i?(d=(0,s.jsxs)("button",{type:"button",onClick:a,"aria-expanded":r,"aria-label":o,className:"flex items-center gap-1 text-muted-foreground/70 hover:text-muted-foreground transition-colors",children:[i,c]}),e[5]=r,e[6]=a,e[7]=o,e[8]=i,e[9]=d):d=e[9];let p;e[10]!==r||e[11]!==n?(p=r&&(0,s.jsx)("div",{className:"font-code text-sm mt-1 p-3 bg-muted rounded border overflow-auto max-h-[50vh] cursor-text select-text",children:kt({html:n})}),e[10]=r,e[11]=n,e[12]=p):p=e[12];let u;return e[13]!==d||e[14]!==p?(u=(0,s.jsxs)("div",{className:"mt-2",children:[d,p]}),e[13]=d,e[14]=p,e[15]=u):u=e[15],u},F=t=>{let e=(0,re.c)(10),n=t.title??"Tip",r;e[0]===n?r=e[1]:(r=(0,s.jsx)(ct,{className:"pt-2 pb-0 font-normal",children:n}),e[0]=n,e[1]=r);let l;e[2]===t.children?l=e[3]:(l=(0,s.jsx)(ot,{className:"mr-24 text-[0.84375rem]",wrapperClassName:"pt-0 pb-2",children:t.children}),e[2]=t.children,e[3]=l);let a;e[4]!==r||e[5]!==l?(a=(0,s.jsxs)(it,{value:"item-1",className:"text-muted-foreground",children:[r,l]}),e[4]=r,e[5]=l,e[6]=a):a=e[6];let o;return e[7]!==t.className||e[8]!==a?(o=(0,s.jsx)(dt,{type:"single",collapsible:!0,className:t.className,children:a}),e[7]=t.className,e[8]=a,e[9]=o):o=e[9],o};const js=t=>{let e=(0,re.c)(38),{errors:n,cellId:r,className:l}=t,a=pe(),o=ce(lt).display.cell_output==="above",i="This cell wasn't run because it has errors",c="destructive",d="text-error",p=null;if(n.some(ys))i="Interrupted";else if(n.some(bs))i="An internal error occurred";else if(n.some(vs))i="Ancestor prevented from running",c="default",d="text-secondary-foreground";else if(n.some(Ns))i="Ancestor stopped",c="default",d="text-secondary-foreground";else if(n.some(Is))i="SQL error";else if(n.some(ws))i=null,p="Cell not run";else{let N;e[0]===n?N=e[1]:(N=n.find(ks),e[0]=n,e[1]=N);let v=N;v&&"exception_type"in v&&(i=v.exception_type)}let u,m,x,g,h,y;if(e[2]!==c||e[3]!==r||e[4]!==a||e[5]!==l||e[6]!==n||e[7]!==o||e[8]!==p||e[9]!==d||e[10]!==i){let N=n.filter($s),v=n.filter(_s),k=n.filter(As),S=n.filter(Ts),E=n.filter(Fs),W=n.filter(Ss),U=n.filter(Cs),H=n.filter(Ms),G=n.filter(zs),J=n.filter(Es),P=n.filter(Ps),K=n.filter(qs),X=n.filter(Ds),O;e[17]===a?O=e[18]:(O=()=>{a.openApplication("scratchpad")},e[17]=a,e[18]=O);let Oe=O,Be=()=>{let I=[];if(P.length>0||K.length>0){let f=P.some(Ls),_=!f&&P.some(Ws);I.push((0,s.jsxs)("div",{children:[P.map(Us),K.map(Os),f&&(0,s.jsxs)(z,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>At(a),children:[(0,s.jsx)(bt,{className:"h-3.5 w-3.5 mr-1.5 mb-0.5"}),(0,s.jsx)("span",{children:"Open package manager"})]}),_&&(0,s.jsxs)(z,{size:"xs",variant:"outline",className:"mt-2 font-normal",onClick:()=>a.openApplication("terminal"),children:[(0,s.jsx)(be,{className:"h-3.5 w-3.5 mr-1.5"}),(0,s.jsx)("span",{children:"Open terminal"})]}),r&&(0,s.jsx)(w,{errors:[...P,...K],cellId:r})]},"syntax-unknown"))}if(N.length>0&&I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"The setup cell cannot be run because it has references."}),(0,s.jsx)("ul",{className:"list-disc",children:N.flatMap(Bs)}),r&&(0,s.jsx)(w,{errors:N,cellId:r}),(0,s.jsxs)(F,{title:"Why can't the setup cell have references?",className:"mb-2",children:[(0,s.jsx)("p",{className:"pb-2",children:"The setup cell contains logic that must be run before any other cell runs, including top-level imports used by top-level functions. For this reason, it can't refer to other cells' variables."}),(0,s.jsx)("p",{className:"py-2",children:"Try simplifying the setup cell to only contain only necessary variables."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-setup",children:["Learn more at our docs"," ",(0,s.jsx)(D,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"setup-refs")),v.length>0&&I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell is in a cycle."}),(0,s.jsx)("ul",{className:"list-disc",children:v.flatMap(Qs)}),r&&(0,s.jsx)(w,{errors:v,cellId:r}),(0,s.jsxs)(F,{title:"What are cycles and how do I resolve them?",className:"mb-2",children:[(0,s.jsx)("p",{className:"pb-2",children:"An example of a cycle is if one cell declares a variable 'a' and reads 'b', and another cell declares 'b' and and reads 'a'. Cycles like this make it impossible for marimo to know how to run your cells, and generally suggest that your code has a bug."}),(0,s.jsx)("p",{className:"py-2",children:"Try merging these cells into a single cell to eliminate the cycle."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-cycles",children:["Learn more at our docs"," ",(0,s.jsx)(D,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"cycle")),k.length>0){let f=k[0].name;I.push((0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground font-medium",children:"This cell redefines variables from other cells."}),k.map(Vs),r&&(0,s.jsx)(w,{errors:k,cellId:r}),(0,s.jsxs)(F,{title:"Why can't I redefine variables?",children:[(0,s.jsx)("p",{className:"pb-2",children:"marimo requires that each variable is defined in just one cell. This constraint enables reactive and reproducible execution, arbitrary cell reordering, seamless UI elements, execution as a script, and more."}),(0,s.jsxs)("p",{className:"py-2",children:["Try merging this cell with the mentioned cells or wrapping it in a function. Alternatively, prefix variables with an underscore (e.g., ",(0,s.jsxs)(ye,{className:"inline",children:["_",f]}),"). to make them private to this cell."]}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-multiple-definitions",children:["Learn more at our docs"," ",(0,s.jsx)(D,{size:"0.75rem",className:"inline"})]}),"."]})]}),(0,s.jsx)(F,{title:"Need a scratchpad?",children:(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,s.jsxs)(z,{size:"xs",variant:"link",className:"my-2 font-normal mx-0 px-0",onClick:Oe,children:[(0,s.jsx)(Ze,{className:"h-3"}),(0,s.jsx)("span",{children:"Try the scratchpad"})]}),(0,s.jsx)("span",{children:"to experiment without restrictions on variable names."})]})})]},"multiple-defs"))}return S.length>0&&I.push((0,s.jsxs)("div",{children:[S.map(Hs),r&&(0,s.jsx)(w,{errors:S,cellId:r}),(0,s.jsxs)(F,{title:"Why can't I use `import *`?",children:[(0,s.jsx)("p",{className:"pb-2",children:"Star imports are incompatible with marimo's git-friendly file format and reproducible reactive execution."}),(0,s.jsx)("p",{className:"py-2",children:"marimo's Python file format stores code in functions, so notebooks can be imported as regular Python modules without executing all their code. But Python disallows `import *` everywhere except at the top-level of a module."}),(0,s.jsx)("p",{className:"py-2",children:"Star imports would also silently add names to globals, which would be incompatible with reactive execution."}),(0,s.jsxs)("p",{className:"py-2",children:[(0,s.jsxs)(q,{href:"https://links.marimo.app/errors-import-star",children:["Learn more at our docs"," ",(0,s.jsx)(D,{size:"0.75rem",className:"inline"})]}),"."]})]})]},"import-star")),E.length>0&&I.push((0,s.jsxs)("div",{children:[E.map(Gs),r&&(0,s.jsx)(w,{errors:E,cellId:r})]},"interruption")),W.length>0&&I.push((0,s.jsxs)("ul",{children:[W.map((f,_)=>f.exception_type==="NameError"&&f.msg.startsWith("name 'mo'")?(0,s.jsx)("li",{className:"my-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:"name 'mo' is not defined."}),(0,s.jsxs)("p",{className:"text-muted-foreground mt-2",children:["The marimo module (imported as"," ",(0,s.jsx)(ye,{className:"inline",children:"mo"}),") is required for Markdown, SQL, and UI elements."]})]})},`exception-${_}`):f.exception_type==="NameError"&&f.msg.startsWith("name '_")?(0,s.jsx)("li",{className:"my-2",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:(0,s.jsx)(Ee,{segments:Ie(f.msg)})}),(0,s.jsxs)("p",{className:"text-muted-foreground mt-2",children:["Variables prefixed with an underscore are local to a cell"," ","(",(0,s.jsxs)(q,{href:"https://links.marimo.app/local-variables",children:["docs"," ",(0,s.jsx)(D,{size:"0.75rem",className:"inline"})]}),")."]}),o&&(0,s.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]})},`exception-${_}`):(0,s.jsx)("li",{className:"my-2",children:f.raising_cell==null?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-muted-foreground",children:T(f.msg,`exception-${_}`)}),"traceback"in f&&f.traceback?(0,s.jsx)(Ue,{traceback:f.traceback}):o&&(0,s.jsx)("div",{className:"text-muted-foreground mt-2",children:"See the console area for a traceback."})]}):(0,s.jsxs)("div",{children:[T(f.msg,`exception-${_}`),(0,s.jsx)($,{cellId:f.raising_cell}),"traceback"in f&&f.traceback&&(0,s.jsx)(Ue,{traceback:f.traceback})]})},`exception-${_}`)),W.some(Js)&&(0,s.jsx)(F,{children:"Fix the error in the mentioned cells, or handle the exceptions with try/except blocks."}),r&&(0,s.jsx)(w,{errors:W,cellId:r})]},"exception")),U.length>0&&I.push((0,s.jsxs)("ul",{children:[U.map(Ks),r&&(0,s.jsx)(w,{errors:U,cellId:r}),(0,s.jsx)(F,{children:U.some(Xs)?"Ensure that the referenced cells define the required variables, or turn off strict execution.":"Something is wrong with your declarations. Fix any discrepancies, or turn off strict execution."})]},"strict-exception")),H.length>0&&I.push((0,s.jsxs)("div",{children:[H.map(Ys),r&&(0,s.jsx)(w,{errors:H,cellId:r})]},"internal")),G.length>0&&I.push((0,s.jsxs)("div",{children:[G.map(Zs),r&&(0,s.jsx)(w,{errors:G,cellId:r})]},"ancestor-prevented")),J.length>0&&I.push((0,s.jsxs)("div",{children:[J.map(en),r&&(0,s.jsx)(w,{errors:J,cellId:r})]},"ancestor-stopped")),X.length>0&&I.push((0,s.jsxs)("div",{children:[X.map(tn),r&&(0,s.jsx)(w,{errors:X,cellId:r,className:"mt-2.5"})]},"sql-errors")),I},C;e[19]===p?C=e[20]:(C=p&&(0,s.jsxs)("div",{className:"flex items-center gap-1 font-code text-[0.6875rem] uppercase tracking-wider text-muted-foreground/70",children:[p,(0,s.jsx)(Q,{content:"marimo didn't run this cell because it detected an error.",delayDuration:200,children:(0,s.jsx)(Ke,{className:"size-3 cursor-help"})})]}),e[19]=p,e[20]=C);let M;e[21]!==d||e[22]!==i?(M=i&&(0,s.jsx)($t,{className:`font-code font-medium ${d}`,children:i}),e[21]=d,e[22]=i,e[23]=M):M=e[23];let B;e[24]!==C||e[25]!==M?(B=(0,s.jsxs)("div",{className:"space-y-0.5",children:[C,M]}),e[24]=C,e[25]=M,e[26]=B):B=e[26];let Qe=B;u=_t,g=c,e[27]===l?h=e[28]:(h=ue("border-none font-code text-sm text-[0.84375rem] p-0 text-muted-foreground normal has-[svg]:pl-0 space-y-2",l),e[27]=l,e[28]=h),y=Qe,m="flex flex-col gap-4",x=Be(),e[2]=c,e[3]=r,e[4]=a,e[5]=l,e[6]=n,e[7]=o,e[8]=p,e[9]=d,e[10]=i,e[11]=u,e[12]=m,e[13]=x,e[14]=g,e[15]=h,e[16]=y}else u=e[11],m=e[12],x=e[13],g=e[14],h=e[15],y=e[16];let j;e[29]!==m||e[30]!==x?(j=(0,s.jsx)("div",{className:m,children:x}),e[29]=m,e[30]=x,e[31]=j):j=e[31];let b;return e[32]!==u||e[33]!==g||e[34]!==h||e[35]!==y||e[36]!==j?(b=(0,s.jsxs)(u,{variant:g,className:h,children:[y,j]}),e[32]=u,e[33]=g,e[34]=h,e[35]=y,e[36]=j,e[37]=b):b=e[37],b};function ys(t){return t.type==="interruption"}function bs(t){return t.type==="internal"}function vs(t){return t.type==="ancestor-prevented"}function Ns(t){return t.type==="ancestor-stopped"}function Is(t){return t.type==="sql-error"}function ws(t){return t.type==="multiple-defs"||t.type==="cycle"||t.type==="setup-refs"||t.type==="import-star"}function ks(t){return t.type==="exception"}function $s(t){return t.type==="setup-refs"}function _s(t){return t.type==="cycle"}function As(t){return t.type==="multiple-defs"}function Ts(t){return t.type==="import-star"}function Fs(t){return t.type==="interruption"}function Ss(t){return t.type==="exception"}function Cs(t){return t.type==="strict-exception"}function Ms(t){return t.type==="internal"}function zs(t){return t.type==="ancestor-prevented"}function Es(t){return t.type==="ancestor-stopped"}function Ps(t){return t.type==="syntax"}function qs(t){return t.type==="unknown"}function Ds(t){return t.type==="sql-error"}function Ls(t){return t.msg.includes("!pip")}function Ws(t){return t.msg.includes("use os.subprocess")}function Us(t,e){return(0,s.jsx)("pre",{children:T(t.msg,`syntax-${e}`)},`syntax-${e}`)}function Os(t,e){return(0,s.jsx)("pre",{children:T(t.msg,`unknown-${e}`)},`unknown-${e}`)}function Bs(t,e){return t.edges_with_vars.map((n,r)=>(0,s.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,s.jsx)($,{cellId:n[0]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[": "," ",n[1].length===1?n[1][0]:n[1].join(", ")]})]},`setup-refs-${e}-${r}`))}function Qs(t,e){return t.edges_with_vars.map((n,r)=>(0,s.jsxs)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:[(0,s.jsx)($,{cellId:n[0]}),(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" -> ",n[1].length===1?n[1][0]:n[1].join(", ")," -> "]}),(0,s.jsx)($,{cellId:n[2]})]},`cycle-${e}-${r}`))}function Rs(t,e){return(0,s.jsx)("li",{className:"my-0.5 ml-8 text-muted-foreground/40",children:(0,s.jsx)($,{cellId:t})},`cell-${e}`)}function Vs(t,e){return(0,s.jsxs)(L.Fragment,{children:[(0,s.jsx)("p",{className:"text-muted-foreground mt-2",children:`'${t.name}' was also defined by:`}),(0,s.jsx)("ul",{className:"list-disc",children:t.cells.map(Rs)})]},`multiple-defs-${e}`)}function Hs(t,e){return(0,s.jsx)("p",{className:"text-muted-foreground",children:t.msg},`import-star-${e}`)}function Gs(t,e){return(0,s.jsx)("p",{children:"This cell was interrupted and needs to be re-run."},`interruption-${e}`)}function Js(t){return t.raising_cell!=null}function Ks(t,e){return(0,s.jsx)("li",{className:"my-2",children:t.blamed_cell==null?(0,s.jsx)("p",{children:t.msg}):(0,s.jsxs)("div",{children:[t.msg,(0,s.jsx)($,{cellId:t.blamed_cell})]})},`strict-exception-${e}`)}function Xs(t){return t.blamed_cell!=null}function Ys(t,e){return(0,s.jsx)("p",{children:t.msg},`internal-${e}`)}function Zs(t,e){return(0,s.jsxs)("div",{children:[t.msg,t.blamed_cell==null?(0,s.jsxs)("span",{children:["(",(0,s.jsx)($,{cellId:t.raising_cell}),")"]}):(0,s.jsxs)("span",{children:["(",(0,s.jsx)($,{cellId:t.raising_cell}),"\xA0blames\xA0",(0,s.jsx)($,{cellId:t.blamed_cell}),")"]})]},`ancestor-prevented-${e}`)}function en(t,e){return(0,s.jsxs)("div",{children:[t.msg,(0,s.jsx)($,{cellId:t.raising_cell})]},`ancestor-stopped-${e}`)}function tn(t,e){return(0,s.jsx)("div",{className:"space-y-2 mt-2",children:(0,s.jsx)("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.msg})},`sql-error-${e}`)}export{be as C,Ie as S,Dt as _,Me as a,Ot as b,Te as c,Gt as d,Vt as f,Ut as g,Rt as h,Ee as i,Wt as l,Ht as m,gs as n,Se as o,_e as p,De as r,Fe as s,js as t,R as u,Qt as v,Mt as x,Bt as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as P}from"./chunk-LvLJmgfZ.js";import{d as L,l as j,n as w,u as O}from"./useEvent-D91BmmQi.js";import{D as y,It as A,M as D,Mi as _,P as E,Wi as M,hn as S}from"./cells-DENsmH9t.js";import{t as b}from"./compiler-runtime-B3qBwwSJ.js";import{_ as T}from"./useEventListener-BakX-tnw.js";import{p as $}from"./utils-Dev6I_Kv.js";import{r as I}from"./constants-B9JJ72XE.js";import{v as F,w as q}from"./config-3clPIEB9.js";import{t as B}from"./cn-X2M2usMq.js";import{t as G}from"./jsx-runtime-PbYoItBR.js";import{r as H}from"./requests-KshNNAOp.js";import{n as R}from"./paths-DhuNSnZ_.js";import{s as U}from"./session-CsT5Gg9j.js";import{n as V}from"./ImperativeModal-B62Q6S9l.js";var W=b();function N(){return O(_)}function z(){let r=(0,W.c)(5),[t]=j(F),e=L(_),{openAlert:s}=V(),{sendRename:o}=H(),a;return r[0]!==t.state||r[1]!==s||r[2]!==o||r[3]!==e?(a=async l=>{let n=$();return t.state===q.OPEN?(U(i=>{l===null?i.delete(I.filePath):i.set(I.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||R.basename(l)||"Untitled Notebook",l)).catch(i=>(s(i.message),null))):(s("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=s,r[2]=o,r[3]=e,r[4]=a):a=r[4],w(a)}var p=b(),v=P(G(),1);const h=r=>{let t=(0,p.c)(12),{className:e,cellId:s,variant:o,onClick:a,formatCellName:l,skipScroll:n}=r,i=E()[s]??"",C=D().inOrderIds.indexOf(s),{showCellIfHidden:d}=y(),g=l??Q,c;t[0]===e?c=t[1]:(c=B("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==s||t[3]!==a||t[4]!==d||t[5]!==n||t[6]!==o?(m=k=>{if(s==="__scratch__")return!1;d({cellId:s}),k.stopPropagation(),k.preventDefault(),requestAnimationFrame(()=>{x(s,o,n)&&(a==null||a())})},t[2]=s,t[3]=a,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(A(i,C)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},J=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(h,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},K=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:s}=r,o=N(),a;t[0]!==e||t[1]!==s?(a=()=>S(e,s),t[0]=e,t[1]=s,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==a||t[8]!==l?(n=(0,v.jsx)(h,{cellId:e,onClick:a,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=a,t[8]=l,t[9]=n):n=t[9],n};function x(r,t,e){let s=M.create(r),o=document.getElementById(s),a=o==null?void 0:o.classList.contains("has-error");return o===null?(T.error(`Cell ${s} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),(t==="destructive"||a&&t===void 0)&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),(t==="focus"||!a&&t===void 0)&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function Q(r){return r}export{N as a,x as i,J as n,z as o,K as r,h as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as x}from"./chunk-LvLJmgfZ.js";import{i as b}from"./useEvent-D91BmmQi.js";import{t as j}from"./react-Bj1aDYRI.js";import{f as w,vn as P,zn as C}from"./cells-DENsmH9t.js";import{t as N}from"./compiler-runtime-B3qBwwSJ.js";import{t as c}from"./cn-X2M2usMq.js";import{t as k}from"./jsx-runtime-PbYoItBR.js";import{a as A,i as R,o as B}from"./config-DMNo9K-z.js";import{t as I}from"./badge-6yGCqY1Z.js";var z=N(),m=x(k(),1);const S=o=>{let e=(0,z.c)(8),{variableName:a,className:r}=o,t;e[0]===a?t=e[1]:(t=i=>{i.stopPropagation();let d=T(a);if(!d)return;let u=w(d);u&&P(u,a)},e[0]=a,e[1]=t);let s=t,l;e[2]===r?l=e[3]:(l=c("text-link opacity-80 hover:opacity-100 hover:underline",r),e[2]=r,e[3]=l);let n;return e[4]!==s||e[5]!==l||e[6]!==a?(n=(0,m.jsx)("button",{type:"button",onClick:s,className:l,children:a}),e[4]=s,e[5]=l,e[6]=a,e[7]=n):n=e[7],n};function T(o){let e=b.get(C)[o];if(e)return e.declaredBy[0]}var p=N(),f=x(j(),1),v=f.forwardRef((o,e)=>{let a=(0,p.c)(11),r,t,s;a[0]===o?(r=a[1],t=a[2],s=a[3]):({className:r,lastItem:t,...s}=o,a[0]=o,a[1]=r,a[2]=t,a[3]=s);let l=t&&"border-b-0",n;a[4]!==r||a[5]!==l?(n=c(l,r),a[4]=r,a[5]=l,a[6]=n):n=a[6];let i;return a[7]!==s||a[8]!==e||a[9]!==n?(i=(0,m.jsx)(A,{ref:e,className:n,...s}),a[7]=s,a[8]=e,a[9]=n,a[10]=i):i=a[10],i});v.displayName="PanelAccordionItem";var y=f.forwardRef((o,e)=>{let a=(0,p.c)(13),r,t,s;a[0]===o?(r=a[1],t=a[2],s=a[3]):({className:t,children:r,...s}=o,a[0]=o,a[1]=r,a[2]=t,a[3]=s);let l;a[4]===t?l=a[5]:(l=c("px-3 py-2 text-xs font-semibold uppercase tracking-wide hover:no-underline",t),a[4]=t,a[5]=l);let n;a[6]===r?n=a[7]:(n=(0,m.jsx)("span",{className:"flex items-center gap-2",children:r}),a[6]=r,a[7]=n);let i;return a[8]!==s||a[9]!==e||a[10]!==l||a[11]!==n?(i=(0,m.jsx)(B,{ref:e,className:l,...s,children:n}),a[8]=s,a[9]=e,a[10]=l,a[11]=n,a[12]=i):i=a[12],i});y.displayName="PanelAccordionTrigger";var g=f.forwardRef((o,e)=>{let a=(0,p.c)(9),r,t;a[0]===o?(r=a[1],t=a[2]):({wrapperClassName:t,...r}=o,a[0]=o,a[1]=r,a[2]=t);let s;a[3]===t?s=a[4]:(s=c("p-0",t),a[3]=t,a[4]=s);let l;return a[5]!==r||a[6]!==e||a[7]!==s?(l=(0,m.jsx)(R,{ref:e,wrapperClassName:s,...r}),a[5]=r,a[6]=e,a[7]=s,a[8]=l):l=a[8],l});g.displayName="PanelAccordionContent";var h=o=>{let e=(0,p.c)(8),a,r;e[0]===o?(a=e[1],r=e[2]):({className:a,...r}=o,e[0]=o,e[1]=a,e[2]=r);let t;e[3]===a?t=e[4]:(t=c("py-0 px-1.5 text-[10px]",a),e[3]=a,e[4]=t);let s;return e[5]!==r||e[6]!==t?(s=(0,m.jsx)(I,{variant:"secondary",className:t,...r}),e[5]=r,e[6]=t,e[7]=s):s=e[7],s};h.displayName="PanelBadge";export{S as a,h as i,v as n,y as r,g as t};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var x=Object.defineProperty;var A=(r,e,n)=>e in r?x(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var l=(r,e,n)=>A(r,typeof e!="symbol"?e+"":e,n);import{i as m}from"./useEvent-D91BmmQi.js";import{Mr as I,Nr as E,Pi as T,Vt as C,Zr as p,ea as M,n as w,or as L,tr as O}from"./cells-DENsmH9t.js";import{_ as P}from"./useEventListener-BakX-tnw.js";import{n as $}from"./config-DMNo9K-z.js";import{t as R}from"./createLucideIcon-BTp1tQDO.js";var S=R("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),u,c;function U(r,e,n,a,i){var t={};return Object.keys(a).forEach(function(s){t[s]=a[s]}),t.enumerable=!!t.enumerable,t.configurable=!!t.configurable,("value"in t||t.initializer)&&(t.writable=!0),t=n.slice().reverse().reduce(function(s,o){return o(r,e,s)||s},t),i&&t.initializer!==void 0&&(t.value=t.initializer?t.initializer.call(i):void 0,t.initializer=void 0),t.initializer===void 0?(Object.defineProperty(r,e,t),null):t}var d=class{async getAttachments(r){return[]}asURI(r){return`${this.contextType}://${r}`}parseContextIds(r){let e=RegExp(`${this.mentionPrefix}([\\w-]+):\\/\\/([\\w./-]+)`,"g"),n=[...r.matchAll(e)],a=t=>t.slice(1),i=n.filter(([,t])=>t===this.contextType).map(([t])=>a(t));return[...new Set(i)]}createBasicCompletion(r,e){return{label:`${this.mentionPrefix}${r.uri.split("://")[1]}`,displayLabel:r.name,detail:(e==null?void 0:e.detail)||r.description,boost:(e==null?void 0:e.boost)||1,type:(e==null?void 0:e.type)||this.contextType,apply:`${this.mentionPrefix}${r.uri}`,section:(e==null?void 0:e.section)||this.title}}};let _=(u=T(),c=class{constructor(){l(this,"providers",new Set)}register(r){return this.providers.add(r),this}getProviders(){return this.providers}getProvider(r){return[...this.providers].find(e=>e.contextType===r)}getAllItems(){return[...this.providers].flatMap(r=>r.getItems())}parseAllContextIds(r){return[...this.providers].flatMap(e=>e.parseContextIds(r))}getContextInfo(r){let e=[],n=new Map(this.getAllItems().map(a=>[a.uri,a]));for(let a of r){let i=n.get(a);i&&e.push(i)}return e}formatContextForAI(r){let e=new Map(this.getAllItems().map(a=>[a.uri,a])),n=[];for(let a of r){let i=e.get(a);i&&n.push(i)}return n.length===0?"":n.map(a=>{var i;return((i=this.getProvider(a.type))==null?void 0:i.formatContext(a))||""}).join(`
|
|
2
|
-
|
|
3
|
-
`)}async getAttachmentsForContext(r){let e=new Map(this.getAllItems().map(t=>[t.uri,t])),n=[];for(let t of r){let s=e.get(t);s&&n.push(s)}if(n.length===0)return[];let a=new $;for(let t of n){let s=t.type;a.add(s,t)}let i=[...a.entries()].map(async([t,s])=>{let o=this.getProvider(t);if(!o)return[];try{return await o.getAttachments(s)}catch(v){return P.error("Error getting attachments from provider",v),[]}});return(await Promise.all(i)).flat()}},U(c.prototype,"getAllItems",[u],Object.getOwnPropertyDescriptor(c.prototype,"getAllItems"),c.prototype),c);function f(r){return r.replaceAll("<","<").replaceAll(">",">")}function h(r){let{type:e,data:n,details:a}=r,i=`<${e}`;for(let[t,s]of Object.entries(n))if(s!==void 0){let o=f(typeof s=="object"&&s?JSON.stringify(s):String(s));i+=` ${t}="${o}"`}return i+=">",a&&(i+=f(a)),i+=`</${e}>`,i}const g={LOCAL_TABLE:7,REMOTE_TABLE:5,HIGH:4,MEDIUM:3,CELL_OUTPUT:2,LOW:2},y={ERROR:{name:"Error",rank:1},TABLE:{name:"Table",rank:2},DATA_SOURCES:{name:"Data Sources",rank:3},VARIABLE:{name:"Variable",rank:4},CELL_OUTPUT:{name:"Cell Output",rank:5},FILE:{name:"File",rank:6}};var D=M(),b="datasource",k=class extends d{constructor(e,n){super();l(this,"title","Datasource");l(this,"mentionPrefix","@");l(this,"contextType",b);this.connectionsMap=e,this.dataframes=[...n.values()].filter(a=>E(a)==="dataframe")}getItems(){return[...this.connectionsMap.values()].map(e=>{var i;let n="Database schema.",a={connection:e};return p.has(e.name)&&(a.tables=this.dataframes,n="Database schema and the dataframes that can be queried"),e.databases.length===0&&(((i=a.tables)==null?void 0:i.length)??0)===0?null:{uri:this.asURI(e.name),name:e.name,description:n,type:this.contextType,data:a}}).filter(Boolean)}formatContext(e){let n=e.data,{name:a,display_name:i,source:t,...s}=n.connection,o=s;return p.has(a)||(o={...s,engine_name:a}),h({type:this.contextType,data:{connection:o,tables:n.tables}})}formatCompletion(e){let n=e.data,a=n.connection,i=n.tables,t=a.name;return p.has(a.name)&&(t="In-Memory"),{label:`@${t}`,displayLabel:t,detail:L(a.dialect),boost:g.MEDIUM,type:this.contextType,section:y.DATA_SOURCES,info:()=>{let s=document.createElement("div");return s.classList.add("mo-cm-tooltip","docs-documentation"),(0,D.createRoot)(s).render(O(a,i)),s}}}};function z(r){var s;let e=(s=m.get(w(r)))==null?void 0:s.code;if(!e||e.trim()==="")return null;let[n,a,i]=C.sql.transformIn(e),t=m.get(I).connectionsMap.get(i.engine);return t?`@${b}://${t.name}`:null}export{h as a,S as c,y as i,z as n,d as o,g as r,_ as s,k as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as n}from"./useEvent-D91BmmQi.js";import{ct as e}from"./cells-DENsmH9t.js";const l=r=>{let{children:t}=r;return n(e)?null:t},o=r=>{let{children:t}=r;return n(e)?t:null};export{o as n,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{nt as i,rt as m}from"./cells-DENsmH9t.js";import{t as a}from"./strings-DvZlHYnD.js";function r(t){return t.mimetype.startsWith("application/vnd.marimo")||t.mimetype==="text/html"?m(a.asString(t.data)):i(a.asString(t.data))}export{r as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as be,l as we,n as V,p as oe,u as Ne}from"./useEvent-D91BmmQi.js";import{t as ye}from"./react-Bj1aDYRI.js";import{D as ke,Gi as m,I as ze,Ii as Ce,In as Se,Wi as Ie,__tla as Oe}from"./cells-DENsmH9t.js";import"./react-dom-CSu739Rf.js";import{t as ie}from"./compiler-runtime-B3qBwwSJ.js";import{v as se}from"./useEventListener-BakX-tnw.js";import{x as Ae}from"./utils-Dev6I_Kv.js";import{t as Le}from"./constants-B9JJ72XE.js";import{t as le}from"./cn-X2M2usMq.js";import{t as Me}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-BXI8V5i6.js";import"./popover-DMNO6Poc.js";import{n as Pe,__tla as De}from"./JsonOutput-C3c9GGaV.js";import"./download-4NoBestd.js";import{t as z}from"./tooltip-CgQpRVyN.js";import{t as C}from"./button-BF7GSjhW.js";import"./dist-Dez1I5M9.js";import"./cjs-DXo9vDEJ.js";import"./main-DmhaVp6Y.js";import"./useNonce-0SWz6w4W.js";import{r as Ee}from"./requests-KshNNAOp.js";import{t as ne}from"./createLucideIcon-BTp1tQDO.js";import{f as Re,__tla as He}from"./layout-DLJQyOOv.js";import{n as Ve,t as qe,__tla as Ge}from"./LazyAnyLanguageCodeMirror-DpraoNlO.js";import{__tla as Te}from"./markdown-renderer-CcLl4-oB.js";import{u as Fe}from"./toDate-DCE7d2fN.js";import{t as Ue,__tla as We}from"./cell-editor-24ykqaHj.js";import{t as Be}from"./spinner-BbI9qk88.js";import{i as Je}from"./useDeleteCell-DwNTIWuB.js";import"./dist-DblYTes5.js";import"./dist-D-2yWcX9.js";import"./dist-CNKFZCiw.js";import"./dist-ZjSH4Z6x.js";import"./dist-BtrqKtvn.js";import"./session-CsT5Gg9j.js";import{r as Ke}from"./useTheme-D_ZbTTJw.js";import"./purify.es-DfJp_of2.js";import"./dates-D8uxHHPL.js";import"./utils-DPvpQ891.js";import"./vega-loader.browser-CZV6_g2i.js";import"./defaultLocale-OkOxlkkM.js";import"./defaultLocale-DK1MWd7f.js";import{__tla as Qe}from"./chunk-5FQGJX7Z-OScactr4.js";import"./html-to-image-B6eCuh-2.js";import{o as Xe}from"./focus-CZUEQpxX.js";import{n as Ye,r as Ze,t as me}from"./react-resizable-panels.browser.esm-Ce2ksurd.js";import{a as $e}from"./renderShortcut-LpVarhnQ.js";import"./esm-X3Tr2pur.js";import"./name-cell-input-CNq9BTL7.js";import{n as et,r as tt}from"./panel-context-DC1vAeB3.js";import{__tla as rt}from"./loro_wasm_bg-BFCm9sQd.js";import"./ws-DSN-Rmiu.js";import"./Inputs-SmI80aJQ.js";import"./dist-DU8gTNy9.js";import"./dist-DgBuTUso.js";import"./dist-RW5SS83Z.js";import"./dist-Ci66nyHs.js";import"./dist-DkYp4RmM.js";import"./dist-DlREAgj1.js";import"./dist-BbGE6FVk.js";import"./dist-qGjvyIZU.js";import"./dist-C6zQ57IZ.js";import"./esm-B_l4S2x_.js";import{t as at}from"./kiosk-mode-BBfHxqEx.js";let ce,ot=Promise.all([(()=>{try{return Oe}catch{}})(),(()=>{try{return De}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Ge}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return We}catch{}})(),(()=>{try{return Qe}catch{}})(),(()=>{try{return rt}catch{}})()]).then(async()=>{var de=ne("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),he=ne("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),pe=ie(),q=ae(ye(),1),ue=15;const G=Ce("marimo:scratchpadHistory:v1",[],Se),fe=oe(!1),xe=oe(null,(e,i,s)=>{if(s=s.trim(),!s)return;let n=e(G);i(G,[s,...n.filter(c=>c!==s)].slice(0,ue))});var t=ae(Me(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,pe.c)(60),i=ze(),[s]=Ae(),{theme:n}=Ke(),c=(0,q.useRef)(null),T=Xe(),{createNewCell:F,updateCellCode:d}=ke(),{sendRunScratchpad:h}=Ee(),S=et(),U=tt(),l=i.cellRuntime[m],W=l==null?void 0:l.output,I=l==null?void 0:l.status,B=l==null?void 0:l.consoleOutputs,r=((re=i.cellData.__scratch__)==null?void 0:re.code)??"",J=be(xe),[o,p]=we(fe),u=Ne(G),O;e[0]!==J||e[1]!==r||e[2]!==h?(O=()=>{h({code:r}),J(r)},e[0]=J,e[1]=r,e[2]=h,e[3]=O):O=e[3];let f=V(O),A;e[4]!==r||e[5]!==F||e[6]!==T?(A=()=>{r.trim()&&F({code:r,before:!1,cellId:T??"__end__"})},e[4]=r,e[5]=F,e[6]=T,e[7]=A):A=e[7];let K=V(A),L;e[8]!==h||e[9]!==d?(L=()=>{d({cellId:m,code:"",formattingChange:!1}),h({code:""});let a=c.current;a&&a.dispatch({changes:{from:0,to:a.state.doc.length,insert:""}})},e[8]=h,e[9]=d,e[10]=L):L=e[10];let Q=V(L),M;e[11]!==p||e[12]!==d?(M=a=>{p(!1),d({cellId:m,code:a,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:a}})},e[11]=p,e[12]=d,e[13]=M):M=e[13];let X=V(M),[Y,je]=(0,q.useState)(),P;e[14]!==X||e[15]!==u||e[16]!==o||e[17]!==n?(P=()=>o?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((a,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>X(a),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:n,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:a.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=X,e[15]=u,e[16]=o,e[17]=n,e[18]=P):P=e[18];let Z=P,D;e[19]!==Q||e[20]!==K||e[21]!==f||e[22]!==u.length||e[23]!==o||e[24]!==p||e[25]!==I?(D=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(z,{content:$e("cell.run"),children:(0,t.jsx)(C,{"data-testid":"scratchpad-run-button",onClick:f,disabled:o,variant:"text",size:"xs",children:(0,t.jsx)(Je,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(z,{content:"Clear code and outputs",children:(0,t.jsx)(C,{disabled:o,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(at,{children:(0,t.jsx)(z,{content:"Insert code",children:(0,t.jsx)(C,{disabled:o,size:"xs",variant:"text",onClick:K,children:(0,t.jsx)(Ve,{size:16})})})}),(I==="running"||I==="queued")&&(0,t.jsx)(Be,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(z,{content:"Toggle history",children:(0,t.jsx)(C,{size:"xs",variant:"text",className:le(o&&"bg-(--sky-3) rounded-none"),onClick:()=>p(!o),disabled:u.length===0,children:(0,t.jsx)(he,{size:16})})}),(0,t.jsx)(z,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(C,{size:"xs",variant:"text",children:(0,t.jsx)(Fe,{size:16})})})]}),e[19]=Q,e[20]=K,e[21]=f,e[22]=u.length,e[23]=o,e[24]=p,e[25]=I,e[26]=D):D=e[26];let $=D,ge=S==="vertical",E;e[27]===Symbol.for("react.memo_cache_sentinel")?(E=Ie.create(m),e[27]=E):E=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let R;e[30]===Symbol.for("react.memo_cache_sentinel")?(R=a=>{c.current=a},e[30]=R):R=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==Y||e[34]!==n||e[35]!==s?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:n,showPlaceholder:!1,id:m,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:s,editorViewRef:c,setEditorView:R,hidden:!1,showHiddenCode:se.NOOP,languageAdapter:Y,setLanguageAdapter:je})}),e[31]=r,e[32]=f,e[33]=Y,e[34]=n,e[35]=s,e[36]=_):_=e[36];let v;e[37]===Z?v=e[38]:(v=Z(),e[37]=Z,e[38]=v);let j;e[39]!==v||e[40]!==x||e[41]!==_?(j=(0,t.jsx)(me,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=j):j=e[42];let ee=ge?"h-1":"w-1",g;e[43]===ee?g=e[44]:(g=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=g);let b;e[45]===g?b=e[46]:(b=(0,t.jsx)(Ze,{className:g}),e[45]=g,e[46]=b);let w;e[47]===W?w=e[48]:(w=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Pe,{allowExpand:!1,output:W,className:Le.outputArea,cellId:m,stale:!1,loading:!1})}),e[47]=W,e[48]=w);let N;e[49]===B?N=e[50]:(N=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(Re,{consoleOutputs:B,className:"overflow-auto",stale:!1,interrupted:!1,cellName:"_",onSubmitDebugger:se.NOOP,cellId:m,debuggerActive:!1})}),e[49]=B,e[50]=N);let y;e[51]!==w||e[52]!==N?(y=(0,t.jsx)(me,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[w,N]})}),e[51]=w,e[52]=N,e[53]=y):y=e[53];let H;return e[54]!==S||e[55]!==U||e[56]!==j||e[57]!==b||e[58]!==y?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:E,children:(0,t.jsxs)(Ye,{direction:S,className:"h-full",children:[j,b,y]},U)}),e[54]=S,e[55]=U,e[56]=j,e[57]=b,e[58]=y,e[59]=H):H=e[59],H};let te;te=ie(),ce=()=>{let e=(0,te.c)(1),i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(ve,{}),e[0]=i):i=e[0],i}});export{ot as __tla,ce as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as ae}from"./chunk-LvLJmgfZ.js";import{d as ie,u as b}from"./useEvent-D91BmmQi.js";import{Cr as de,D as ne,Hn as se,Ki as re,Vn as ce,br as he,ct as me,er as pe,kt as F,v as ke,xr as fe,yr as ue}from"./cells-DENsmH9t.js";import{t as ye}from"./compiler-runtime-B3qBwwSJ.js";import{c as be,i as xe,s as je}from"./utils-Dev6I_Kv.js";import{t as ve}from"./jsx-runtime-PbYoItBR.js";import{t as Ce}from"./label-CFvCMYuj.js";import{a as we,h as ge}from"./download-4NoBestd.js";import{r as Ie}from"./requests-KshNNAOp.js";import{t as f}from"./createLucideIcon-BTp1tQDO.js";import{n as V,r as K}from"./x-9vLEgLY6.js";import{t as ze}from"./chevron-right-C7RH0Nc7.js";import{t as Q}from"./circle-plus-BIy1BGHw.js";import{t as We}from"./code-xml-tqeFGeKJ.js";import{t as Me}from"./eye-off-DI0EQXw0.js";import{t as _e}from"./image-BzUcK6ho.js";import{t as Se}from"./link-e5mRDDOC.js";import{i as Ae,t as De}from"./useDeleteCell-DwNTIWuB.js";import{t as Te}from"./sparkles-COaEc8Qn.js";import{t as He}from"./trash-2-CqTUwVuU.js";import{t as Ne}from"./use-toast-kCNiuc-_.js";import{n as Re}from"./copy-D8MtpXgN.js";import{i as Be}from"./useRunCells-CTpvxsqp.js";import{a as Ee,c as Le,n as qe}from"./dialog-DkJmIrsG.js";import{n as Oe}from"./ImperativeModal-B62Q6S9l.js";import{n as Pe}from"./state-LM4pQmYL.js";import{r as G}from"./html-to-image-B6eCuh-2.js";import{n as Ue,t as Fe}from"./icons-avFV3lBF.js";import{n as X}from"./name-cell-input-CNq9BTL7.js";import{t as $}from"./multi-icon-CTvmuLdL.js";import{t as Ve}from"./useSplitCell-CFO4Cg5B.js";var J=f("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Y=f("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Z=f("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),Ke=f("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),ee=f("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),le=f("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function Qe(a){let e=new URL(window.location.href);return e.hash=`scrollTo=${encodeURIComponent(a)}`,e.toString()}function Ge(a){var c;let e=(c=a.match(/scrollTo=([^&]+)/))==null?void 0:c[1];return e?decodeURIComponent(e.split("&")[0]):null}function te(a){return a==="_"?!1:!!(a&&a.trim().length>0)}var Xe=ye(),l=ae(ve(),1);function $e(a){let e=(0,Xe.c)(47),{cell:c,closePopover:u}=a,{createNewCell:m,updateCellConfig:s,updateCellName:x,moveCell:p,sendToTop:W,sendToBottom:M,addColumnBreakpoint:_,clearCellOutput:S,markUntouched:A}=ne(),D=Ve(),T=Be(c==null?void 0:c.cellId),H=!b(ke),N=De(),{openModal:j}=Oe(),R=ie(Pe),B=b(xe),v=b(be),oe=b(me),y=b(je),{saveCellConfig:r}=Ie();if(!c||oe){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0],t}let{cellId:o,config:i,getEditorView:n,name:h,hasOutput:C,hasConsoleOutput:E,status:L}=c,w;e[1]!==o||e[2]!==i.disabled||e[3]!==r||e[4]!==s?(w=async()=>{let t={disabled:!i.disabled};await r({configs:{[o]:t}}),s({cellId:o,config:t})},e[1]=o,e[2]=i.disabled,e[3]=r,e[4]=s,e[5]=w):w=e[5];let q=w,g;e[6]!==o||e[7]!==i.hide_code||e[8]!==n||e[9]!==r||e[10]!==s?(g=async()=>{let t={hide_code:!i.hide_code};await r({configs:{[o]:t}}),s({cellId:o,config:t});let U=n();U&&(t.hide_code?U.contentDOM.blur():U.focus())},e[6]=o,e[7]=i.hide_code,e[8]=n,e[9]=r,e[10]=s,e[11]=g):g=e[11];let O=g,d=o===re,I;e[12]===Symbol.for("react.memo_cache_sentinel")?(I=(0,l.jsx)(Ae,{size:13,strokeWidth:1.5}),e[12]=I):I=e[12];let P=L==="running"||L==="queued"||L==="disabled-transitively"||i.disabled,k;e[13]===T?k=e[14]:(k=()=>T(),e[13]=T,e[14]=k);let z;return e[15]!==_||e[16]!==B||e[17]!==y||e[18]!==v||e[19]!==H||e[20]!==o||e[21]!==S||e[22]!==u||e[23]!==i.disabled||e[24]!==i.hide_code||e[25]!==m||e[26]!==N||e[27]!==n||e[28]!==E||e[29]!==C||e[30]!==d||e[31]!==A||e[32]!==p||e[33]!==h||e[34]!==j||e[35]!==r||e[36]!==M||e[37]!==W||e[38]!==R||e[39]!==D||e[40]!==P||e[41]!==k||e[42]!==q||e[43]!==O||e[44]!==s||e[45]!==x?(z=[[{icon:I,label:"Run cell",hotkey:"cell.run",hidden:P,redundant:!0,handle:k},{icon:(0,l.jsx)(Te,{size:13,strokeWidth:1.5}),label:"Refactor with AI",hidden:!B,handle:()=>{R(t=>(t==null?void 0:t.cellId)===o?null:{cellId:o})},hotkey:"cell.aiCompletion"},{icon:(0,l.jsx)(Z,{size:13,strokeWidth:1.5}),label:"Split",hotkey:"cell.splitCell",handle:()=>D({cellId:o})},{icon:(0,l.jsx)(We,{size:13,strokeWidth:1.5}),label:"Format",hotkey:"cell.format",handle:()=>{let t=n();t&&pe({[o]:t})}},{icon:i.hide_code?(0,l.jsx)(ue,{size:13,strokeWidth:1.5}):(0,l.jsx)(Me,{size:13,strokeWidth:1.5}),label:i.hide_code?"Show code":"Hide code",handle:O,hotkey:"cell.hideCode"},{icon:i.disabled?(0,l.jsx)(ee,{size:13,strokeWidth:1.5}):(0,l.jsx)(le,{size:13,strokeWidth:1.5}),label:i.disabled?"Enable execution":"Disable execution",handle:q,hidden:d}],[{icon:(0,l.jsx)(Fe,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:async()=>{let t=n();t&&(G({autoInstantiate:v,createNewCell:m}),F(t,{language:"markdown",keepCodeAsIs:!1}),i.hide_code||(await r({configs:{[o]:{hide_code:!0}}}),s({cellId:o,config:{hide_code:!0}}),A({cellId:o})))},hidden:d},ce(n())==="sql"?{icon:(0,l.jsx)(Ue,{}),label:"View as Python",hotkey:"cell.viewAsSQL",handle:()=>{let t=n();t&&se(t,"python",{force:!0})},hidden:d}:{icon:(0,l.jsx)(he,{size:13,strokeWidth:1.5}),label:"Convert to SQL",hotkey:"cell.viewAsSQL",handle:()=>{let t=n();t&&(G({autoInstantiate:v,createNewCell:m}),F(t,{language:"sql",keepCodeAsIs:!1}))},hidden:d}],[{icon:(0,l.jsxs)($,{children:[(0,l.jsx)(Q,{size:13,strokeWidth:1.5}),(0,l.jsx)(V,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>m({cellId:o,before:!0}),hidden:d,redundant:!0},{icon:(0,l.jsxs)($,{children:[(0,l.jsx)(Q,{size:13,strokeWidth:1.5}),(0,l.jsx)(K,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>m({cellId:o,before:!1}),redundant:!0},{icon:(0,l.jsx)(V,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>p({cellId:o,before:!0}),hidden:d},{icon:(0,l.jsx)(K,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>p({cellId:o,before:!1}),hidden:d},{icon:(0,l.jsx)(ge,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>p({cellId:o,direction:"left"}),hidden:y!=="columns"||d},{icon:(0,l.jsx)(ze,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>p({cellId:o,direction:"right"}),hidden:y!=="columns"||d},{icon:(0,l.jsx)(Y,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>W({cellId:o,scroll:!1}),hidden:d},{icon:(0,l.jsx)(J,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>M({cellId:o,scroll:!1}),hidden:d},{icon:(0,l.jsx)(fe,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",handle:()=>_({cellId:o}),hidden:y!=="columns"||d}],[{icon:(0,l.jsx)(_e,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!C,handle:()=>we(o,"result")},{icon:(0,l.jsx)(de,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(C||E),handle:()=>{S({cellId:o})}}],[{icon:(0,l.jsx)(Ke,{size:13,strokeWidth:1.5}),label:"Name",disableClick:!0,handle:el,handleHeadless:()=>{j((0,l.jsxs)(qe,{children:[(0,l.jsx)(Ee,{children:(0,l.jsx)(Le,{children:"Rename cell"})}),(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(Ce,{htmlFor:"cell-name",children:"Cell name"}),(0,l.jsx)(X,{placeholder:"cell name",value:h,onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),j(null))},onChange:t=>x({cellId:o,name:t})})]})]}))},rightElement:(0,l.jsx)(X,{placeholder:"cell name",value:h,onChange:t=>x({cellId:o,name:t}),onEnterKey:()=>u==null?void 0:u()}),hidden:d},{icon:(0,l.jsx)(Se,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!te(h),tooltip:te(h)?void 0:"Only named cells can be linked to",handle:async()=>{await Re(Qe(h)),Ne({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!H,variant:"danger",icon:(0,l.jsx)(He,{size:13,strokeWidth:1.5}),handle:()=>{N({cellId:o})}}]].map(Ye).filter(Je),e[15]=_,e[16]=B,e[17]=y,e[18]=v,e[19]=H,e[20]=o,e[21]=S,e[22]=u,e[23]=i.disabled,e[24]=i.hide_code,e[25]=m,e[26]=N,e[27]=n,e[28]=E,e[29]=C,e[30]=d,e[31]=A,e[32]=p,e[33]=h,e[34]=j,e[35]=r,e[36]=M,e[37]=W,e[38]=R,e[39]=D,e[40]=P,e[41]=k,e[42]=q,e[43]=O,e[44]=s,e[45]=x,e[46]=z):z=e[46],z}function Je(a){return a.length>0}function Ye(a){return a.filter(Ze)}function Ze(a){return!a.hidden}function el(a){a==null||a.stopPropagation(),a==null||a.preventDefault()}export{Z as a,ee as i,Ge as n,Y as o,le as r,J as s,$e as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as k,n as i,p as v}from"./useEvent-D91BmmQi.js";import{D as w,St as y,Vn as F,ci as b,h as d,ri as D}from"./cells-DENsmH9t.js";import{t as V}from"./compiler-runtime-B3qBwwSJ.js";import{_}from"./useEventListener-BakX-tnw.js";import{o as x}from"./dist-B0WqBUnf.js";import{r as H}from"./requests-KshNNAOp.js";var u=V();const I=v(!1);function S(){let r=(0,u.c)(2),n=f(),t;return r[0]===n?t=r[1]:(t=()=>n(b(d())),r[0]=n,r[1]=t),i(t)}function j(r){let n=(0,u.c)(3),t=f(),o;return n[0]!==r||n[1]!==t?(o=()=>{r!==void 0&&t([r])},n[0]=r,n[1]=t,n[2]=o):o=n[2],i(o)}function q(){let r=(0,u.c)(2),n=f(),t;return r[0]===n?t=r[1]:(t=()=>n(D(d())),r[0]=n,r[1]=t),i(t)}function f(){let r=(0,u.c)(4),{prepareForRun:n}=w(),{sendRun:t}=H(),o=k(I),e;return r[0]!==n||r[1]!==t||r[2]!==o?(e=async s=>{if(s.length===0)return;let c=d();return o(!0),g({cellIds:s,sendRun:t,prepareForRun:n,notebook:c})},r[0]=n,r[1]=t,r[2]=o,r[3]=e):e=r[3],i(e)}async function g({cellIds:r,sendRun:n,prepareForRun:t,notebook:o}){var m,h,R;if(r.length===0)return;let{cellHandles:e,cellData:s}=o,c=[];for(let a of r){let l=(h=(m=e[a])==null?void 0:m.current)==null?void 0:h.editorView,p;l?(F(l)!=="markdown"&&x(l),p=y(l)):p=((R=s[a])==null?void 0:R.code)||"",c.push(p),t({cellId:a})}await n({cellIds:r,codes:c}).catch(a=>{_.error(a)})}export{f as a,j as i,g as n,S as o,q as r,I as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as m}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-D91BmmQi.js";import{D as d,St as f,f as u}from"./cells-DENsmH9t.js";import{t as c}from"./compiler-runtime-B3qBwwSJ.js";import{t as C}from"./jsx-runtime-PbYoItBR.js";import{r as h}from"./useDeleteCell-DwNTIWuB.js";import{t as v}from"./use-toast-kCNiuc-_.js";var x=c(),S=m(C(),1);function b(){let t=(0,x.c)(3),{splitCell:i,undoSplitCell:r}=d(),o;return t[0]!==i||t[1]!==r?(o=s=>{let l=u(s.cellId);if(!l)return;let a=f(l);i(s);let{dismiss:n}=v({title:"Cell split",action:(0,S.jsx)(h,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{r({...s,snapshot:a}),e()},children:"Undo"})}),e=n},t[0]=i,t[1]=r,t[2]=o):o=t[2],p(o)}export{b as t};
|