@marimo-team/frontend 0.23.15-dev72 → 0.23.15-dev75

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.
@@ -6,9 +6,11 @@ import type { CellErrorEntry } from "@/core/errors/error-entries";
6
6
  import type { EnvironmentInfo } from "@/core/network/types";
7
7
  import {
8
8
  buildBugReportUrl,
9
- buildIssueDetails,
10
9
  createPartialEnvironment,
11
10
  enrichEnvironment,
11
+ formatCodeSection,
12
+ formatEnvironmentSection,
13
+ formatErrorsSection,
12
14
  markdownCodeFence,
13
15
  MAX_PREFILL_URL_LENGTH,
14
16
  } from "../issue-details";
@@ -86,20 +88,16 @@ describe("markdownCodeFence", () => {
86
88
  });
87
89
  });
88
90
 
89
- describe("buildIssueDetails", () => {
90
- it("includes the environment and omits notebook source unless provided", () => {
91
- const markdown = buildIssueDetails({
92
- environment,
93
- errors: [],
94
- notebook: undefined,
95
- });
91
+ describe("formatEnvironmentSection", () => {
92
+ it("wraps the environment JSON in a collapsible section", () => {
93
+ const markdown = formatEnvironmentSection(environment);
96
94
  expect(markdown).toContain("<summary>Environment</summary>");
97
95
  expect(markdown).toContain('"marimo": "1.2.3"');
98
- expect(markdown).not.toContain("Notebook source");
99
- expect(markdown).not.toContain("Current errors");
100
96
  });
97
+ });
101
98
 
102
- it("includes current errors as plain text without notebook source", () => {
99
+ describe("formatErrorsSection", () => {
100
+ it("wraps errors in a collapsible section without cell source", () => {
103
101
  const errors: CellErrorEntry[] = [
104
102
  {
105
103
  cellId: cellId("cell-1"),
@@ -110,38 +108,19 @@ describe("buildIssueDetails", () => {
110
108
  '<span class="gr">ValueError</span>: <span class="n">bad value</span>',
111
109
  },
112
110
  ];
113
- const markdown = buildIssueDetails({ environment, errors });
114
- expect(markdown).toContain("<summary>Current errors</summary>");
111
+ const markdown = formatErrorsSection(errors);
112
+ expect(markdown).toContain("<summary>Errors</summary>");
113
+ expect(markdown).toContain("```text\n");
115
114
  expect(markdown).toContain("ValueError: bad value");
116
115
  expect(markdown).not.toContain("password");
117
116
  });
117
+ });
118
118
 
119
- it("includes notebook source under its basename when provided", () => {
120
- const markdown = buildIssueDetails({
121
- environment,
122
- errors: [],
123
- notebook: {
124
- filename: "/project/example.py",
125
- contents: "x = 1",
126
- },
127
- });
128
- expect(markdown).toContain(
129
- "<summary>Notebook source: example.py</summary>",
130
- );
131
- expect(markdown).toContain("x = 1");
132
- });
133
-
134
- it("escapes the summary label as text", () => {
135
- const markdown = buildIssueDetails({
136
- environment,
137
- errors: [],
138
- notebook: {
139
- filename: "/project/<script>.py",
140
- contents: "x = 1",
141
- },
142
- });
143
- expect(markdown).toContain("&lt;script&gt;.py");
144
- expect(markdown).not.toContain("<script>.py");
119
+ describe("formatCodeSection", () => {
120
+ it("wraps the code in a collapsible python section", () => {
121
+ const markdown = formatCodeSection("import marimo");
122
+ expect(markdown).toContain("<summary>Code</summary>");
123
+ expect(markdown).toContain("```python\nimport marimo");
145
124
  });
146
125
  });
147
126
 
@@ -149,25 +128,48 @@ describe("buildBugReportUrl", () => {
149
128
  const baseUrl =
150
129
  "https://github.com/marimo-team/marimo/issues/new?template=bug_report.yaml";
151
130
 
152
- it("prefills the env field with the encoded issue details", () => {
153
- const url = buildBugReportUrl(baseUrl, "hello world");
154
- expect(url).toBe(`${baseUrl}&env=hello%20world`);
131
+ it("prefills each field keyed by its template id", () => {
132
+ const { url, omitted } = buildBugReportUrl(baseUrl, {
133
+ env: "hello world",
134
+ "bug-description": "boom",
135
+ });
136
+ expect(url).toBe(`${baseUrl}&env=hello%20world&bug-description=boom`);
137
+ expect(omitted).toEqual([]);
155
138
  });
156
139
 
157
- it("appends env with a query separator when the base URL has none", () => {
158
- const url = buildBugReportUrl("https://example.com/new", "x");
140
+ it("appends fields with a query separator when the base URL has none", () => {
141
+ const { url } = buildBugReportUrl("https://example.com/new", { env: "x" });
159
142
  expect(url).toBe("https://example.com/new?env=x");
160
143
  });
161
144
 
145
+ it("skips empty fields", () => {
146
+ const { url } = buildBugReportUrl(baseUrl, {
147
+ env: "x",
148
+ "bug-description": "",
149
+ });
150
+ expect(url).toBe(`${baseUrl}&env=x`);
151
+ expect(url).not.toContain("bug-description");
152
+ });
153
+
154
+ it("returns the base URL when no fields have content", () => {
155
+ const { url } = buildBugReportUrl(baseUrl, { env: "" });
156
+ expect(url).toBe(baseUrl);
157
+ });
158
+
162
159
  it("encodes markdown so it survives as a single query param", () => {
163
- const details = buildIssueDetails({ environment, errors: [] });
164
- const url = buildBugReportUrl(baseUrl, details);
160
+ const details = formatEnvironmentSection(environment);
161
+ const { url } = buildBugReportUrl(baseUrl, { env: details });
165
162
  expect(url).toContain("&env=");
166
163
  expect(new URL(url).searchParams.get("env")).toBe(details);
167
164
  });
168
165
 
169
- it("falls back to the plain base URL when the prefill exceeds the cap", () => {
166
+ it("keeps earlier fields and omits only the oversized later one", () => {
170
167
  const huge = "x".repeat(MAX_PREFILL_URL_LENGTH);
171
- expect(buildBugReportUrl(baseUrl, huge)).toBe(baseUrl);
168
+ const { url, omitted } = buildBugReportUrl(baseUrl, {
169
+ env: "small",
170
+ "reproduction-code": huge,
171
+ });
172
+ expect(url).toBe(`${baseUrl}&env=small`);
173
+ expect(omitted).toEqual(["reproduction-code"]);
172
174
  });
173
175
  });
@@ -5,7 +5,6 @@ import {
5
5
  formatCellError,
6
6
  } from "@/core/errors/error-entries";
7
7
  import type { EnvironmentInfo } from "@/core/network/types";
8
- import { Paths } from "@/utils/paths";
9
8
  import { Strings } from "@/utils/strings";
10
9
 
11
10
  /**
@@ -23,12 +22,6 @@ export interface NotebookSource {
23
22
  contents: string;
24
23
  }
25
24
 
26
- export interface IssueDetailsInput {
27
- environment: EnvironmentDiagnostics;
28
- errors: CellErrorEntry[];
29
- notebook?: NotebookSource;
30
- }
31
-
32
25
  /**
33
26
  * Replace the server-detected browser with the active browser's user agent.
34
27
  *
@@ -82,17 +75,35 @@ export function markdownCodeFence(language: string, contents: string): string {
82
75
  export const MAX_PREFILL_URL_LENGTH = 6000;
83
76
 
84
77
  /**
85
- * Build a bug-report URL with `issueDetails` prefilled into the form's `env`
86
- * field. Falls back to `baseUrl` unchanged when the prefilled URL would exceed
87
- * `MAX_PREFILL_URL_LENGTH`.
78
+ * Build a bug-report URL with `fields` prefilled into the issue form, keyed by
79
+ * each field's template `id`. Fields are added greedily in order; any that
80
+ * would push the URL past `MAX_PREFILL_URL_LENGTH` are skipped and returned in
81
+ * `omitted`, so an oversized later field never discards the ones before it.
88
82
  */
89
83
  export function buildBugReportUrl(
90
84
  baseUrl: string,
91
- issueDetails: string,
92
- ): string {
85
+ fields: Record<string, string>,
86
+ ): { url: string; omitted: string[] } {
93
87
  const separator = baseUrl.includes("?") ? "&" : "?";
94
- const prefilled = `${baseUrl}${separator}env=${encodeURIComponent(issueDetails)}`;
95
- return prefilled.length > MAX_PREFILL_URL_LENGTH ? baseUrl : prefilled;
88
+ const omitted: string[] = [];
89
+ let url = baseUrl;
90
+ let added = 0;
91
+
92
+ for (const [key, value] of Object.entries(fields)) {
93
+ if (value.length === 0) {
94
+ continue;
95
+ }
96
+ const param = `${key}=${encodeURIComponent(value)}`;
97
+ const candidate = `${url}${added === 0 ? separator : "&"}${param}`;
98
+ if (candidate.length > MAX_PREFILL_URL_LENGTH) {
99
+ omitted.push(key);
100
+ continue;
101
+ }
102
+ url = candidate;
103
+ added += 1;
104
+ }
105
+
106
+ return { url, omitted };
96
107
  }
97
108
 
98
109
  function detailsSection(summary: string, body: string): string {
@@ -106,34 +117,34 @@ function detailsSection(summary: string, body: string): string {
106
117
  ].join("\n");
107
118
  }
108
119
 
109
- export function buildIssueDetails(input: IssueDetailsInput): string {
110
- const sections = [
111
- detailsSection(
112
- "Environment",
113
- markdownCodeFence("json", JSON.stringify(input.environment, null, 2)),
114
- ),
115
- ];
116
-
117
- if (input.errors.length > 0) {
118
- sections.push(
119
- detailsSection(
120
- "Current errors",
121
- markdownCodeFence(
122
- "text",
123
- input.errors.map(formatCellError).join("\n\n---\n\n"),
124
- ),
125
- ),
126
- );
127
- }
120
+ /**
121
+ * Format the environment as a collapsible section for the issue form's
122
+ * `env` field.
123
+ */
124
+ export function formatEnvironmentSection(
125
+ environment: EnvironmentDiagnostics,
126
+ ): string {
127
+ return detailsSection(
128
+ "Environment",
129
+ markdownCodeFence("json", JSON.stringify(environment, null, 2)),
130
+ );
131
+ }
128
132
 
129
- if (input.notebook) {
130
- sections.push(
131
- detailsSection(
132
- `Notebook source: ${Paths.basename(input.notebook.filename)}`,
133
- markdownCodeFence("python", input.notebook.contents),
134
- ),
135
- );
136
- }
133
+ /**
134
+ * Format cell errors as a collapsible section for the issue form's
135
+ * `bug-description` field.
136
+ */
137
+ export function formatErrorsSection(errors: CellErrorEntry[]): string {
138
+ return detailsSection(
139
+ "Errors",
140
+ markdownCodeFence("text", errors.map(formatCellError).join("\n\n---\n\n")),
141
+ );
142
+ }
137
143
 
138
- return sections.join("\n\n");
144
+ /**
145
+ * Format notebook source as a collapsible section for the issue form's
146
+ * `reproduction-code` field.
147
+ */
148
+ export function formatCodeSection(contents: string): string {
149
+ return detailsSection("Code", markdownCodeFence("python", contents));
139
150
  }
@@ -1 +0,0 @@
1
- import{s as T}from"./chunk-LvLJmgfZ.js";import{l as X,u as U}from"./useEvent-D91BmmQi.js";import{t as Y}from"./react-Bj1aDYRI.js";import{Li as Z}from"./cells-Cf7bHHq3.js";import"./react-dom-CSu739Rf.js";import{t as L}from"./compiler-runtime-B3qBwwSJ.js";import{S as ee}from"./ai-model-dropdown-DXgLphFa.js";import{m as le,t as te,u as ie}from"./useEventListener-B_w3A283.js";import{t as ae}from"./objects-BlG0ZrO0.js";import{C as oe,S as re,g as ne}from"./utils-Z80SV4_d.js";import"./readonly-python-code-CW_G5e4E.js";import{t as de}from"./jsx-runtime-Blw4afVn.js";import"./fullscreen-dUjPYOmm.js";import"./popover-DrHQ3KEt.js";import"./JsonOutput-DnGSkLeP.js";import"./download-BomYt3nl.js";import"./dist-12S8I4CH.js";import"./cjs-D5tzp-Y6.js";import"./main-BNL5rxQw.js";import"./useNonce-CbdaHKzX.js";import{r as se}from"./requests-9-v2bhoi.js";import"./layout-BOwE7yok.js";import{t as pe}from"./useCellActionButton-CRfIEVB5.js";import"./markdown-renderer-QvXG0CRk.js";import{a as me,t as he}from"./useNotebookActions-UvL5xEdt.js";import"./dist-DcwTQG1A.js";import"./dist-DnjsPBRJ.js";import"./dist-BJZAIIze.js";import"./dist-aRc_dRed.js";import"./dist-CPjTeT8p.js";import"./session-CEFnN9Cq.js";import"./purify.es-CWmnYhGI.js";import"./dates-D-kIKDYA.js";import{n as ce}from"./useHotkey-DIuRH8Wu.js";import"./share-CYpcX4N4.js";import"./tooltip-HLb6RxVp.js";import"./vega-loader.browser-Dun7Qe4B.js";import"./defaultLocale-DOVIEEPN.js";import"./defaultLocale-BUCH2FMc.js";import"./chunk-5FQGJX7Z-Cp0LZT-a.js";import"./html-to-image-CwmX28T9.js";import{r as ye}from"./focus-DiEyfiAG.js";import"./react-resizable-panels.browser.esm-Z-MD3n3J.js";import{a as fe,c as ue,i as V,l as z,n as be,o as J,r as ge,s as ke}from"./command-CAJLPEBq.js";import{t as Q}from"./renderShortcut-BZLr8D7H.js";import"./esm-BL7jQmzn.js";import"./name-cell-input-C6cukQ9k.js";import"./multi-icon-nrKPWjDU.js";import"./dist-D5ToCtv8.js";import"./dist-D35OyUMQ.js";import"./dist-ByK00N0T.js";import"./dist-C5kf6g-d.js";import"./dist-BaKJ0-Tb.js";import"./dist-DNGKAtWk.js";import"./dist-56ul6-mm.js";import"./dist-3N7-WLqi.js";import"./dist-CM-lWxt3.js";import"./esm-Cmv0Nuxi.js";var we=L(),Ce=T(Y(),1);function je(e,l){let t=(0,we.c)(11),n;t[0]===l?n=t[1]:(n=new Z(l),t[0]=l,t[1]=n);let d=n,r;t[2]!==e||t[3]!==d?(r=()=>d.get(e),t[2]=e,t[3]=d,t[4]=r):r=t[4];let[m,k]=(0,Ce.useState)(r),i;t[5]!==e||t[6]!==d?(i=w=>{k(w),d.set(e,w)},t[5]=e,t[6]=d,t[7]=i):i=t[7];let f=i,h;return t[8]!==f||t[9]!==m?(h=[m,f],t[8]=f,t[9]=m,t[10]=h):h=t[10],h}var xe=L(),Se=3;function ve(){let e=(0,xe.c)(7),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0];let[t,n]=je("marimo:commands",l),d;e[1]!==t||e[2]!==n?(d=m=>{n(_e([m,...t]).slice(0,Se))},e[1]=t,e[2]=n,e[3]=d):d=e[3];let r;return e[4]!==t||e[5]!==d?(r={recentCommands:t,addRecentCommand:d},e[4]=t,e[5]=d,e[6]=r):r=e[6],r}function _e(e){return[...new Set(e)]}function W(e){return e.dropdown!==void 0}function O(e,l=""){return e.flatMap(t=>t.label?W(t)?O(t.dropdown,`${l+t.label} > `):{...t,label:l+t.label,additionalKeywords:t.additionalKeywords}:[])}var Ke=L();function He(){let e=(0,Ke.c)(75),[l,t]=oe(),[n,d]=re(),{saveAppConfig:r,saveUserConfig:m}=se(),k;e[0]!==m||e[1]!==t?(k=async p=>{await m({config:p}).then(()=>{t(c=>({...c,...p}))})},e[0]=m,e[1]=t,e[2]=k):k=e[2];let i=k,f;e[3]!==r||e[4]!==d?(f=async p=>{await r({config:p}).then(()=>{d(p)})},e[3]=r,e[4]=d,e[5]=f):f=e[5];let h=f,w;if(e[6]!==n||e[7]!==l.completion||e[8]!==l.display||e[9]!==l.keymap||e[10]!==h||e[11]!==i){let p;e[13]===n?p=e[14]:(p=B=>B!==n.width,e[13]=n,e[14]=p);let c;e[15]!==n||e[16]!==h?(c=B=>({label:`App config > Set width=${B}`,handle:()=>{h({...n,width:B})}}),e[15]=n,e[16]=h,e[17]=c):c=e[17];let K;e[18]!==l.display||e[19]!==i?(K={label:"Config > Set theme: dark",handle:()=>{i({display:{...l.display,theme:"dark"}})}},e[18]=l.display,e[19]=i,e[20]=K):K=e[20];let C;e[21]!==l.display||e[22]!==i?(C={label:"Config > Set theme: light",handle:()=>{i({display:{...l.display,theme:"light"}})}},e[21]=l.display,e[22]=i,e[23]=C):C=e[23];let H;e[24]!==l.display||e[25]!==i?(H={label:"Config > Set theme: system",handle:()=>{i({display:{...l.display,theme:"system"}})}},e[24]=l.display,e[25]=i,e[26]=H):H=e[26];let E=l.keymap.preset==="vim",A;e[27]!==l.keymap||e[28]!==i?(A=()=>{i({keymap:{...l.keymap,preset:"vim"}})},e[27]=l.keymap,e[28]=i,e[29]=A):A=e[29];let M;e[30]!==E||e[31]!==A?(M={label:"Config > Switch keymap to VIM",hidden:E,handle:A},e[30]=E,e[31]=A,e[32]=M):M=e[32];let N=l.keymap.preset==="default",j;e[33]!==l.keymap||e[34]!==i?(j=()=>{i({keymap:{...l.keymap,preset:"default"}})},e[33]=l.keymap,e[34]=i,e[35]=j):j=e[35];let u;e[36]!==N||e[37]!==j?(u={label:"Config > Switch keymap to default (current: VIM)",hidden:N,handle:j},e[36]=N,e[37]=j,e[38]=u):u=e[38];let x;e[39]!==l.completion||e[40]!==i?(x=()=>{i({completion:{...l.completion,copilot:!1}})},e[39]=l.completion,e[40]=i,e[41]=x):x=e[41];let S=l.completion.copilot!=="github",P;e[42]!==x||e[43]!==S?(P={label:"Config > Disable GitHub Copilot",handle:x,hidden:S},e[42]=x,e[43]=S,e[44]=P):P=e[44];let v;e[45]!==l.completion||e[46]!==i?(v=()=>{i({completion:{...l.completion,copilot:"github"}})},e[45]=l.completion,e[46]=i,e[47]=v):v=e[47];let G=l.completion.copilot==="github",$;e[48]!==v||e[49]!==G?($={label:"Config > Enable GitHub Copilot",handle:v,hidden:G},e[48]=v,e[49]=G,e[50]=$):$=e[50];let q=!l.display.reference_highlighting,_;e[51]!==l.display||e[52]!==i?(_=()=>{i({display:{...l.display,reference_highlighting:!1}})},e[51]=l.display,e[52]=i,e[53]=_):_=e[53];let b;e[54]!==q||e[55]!==_?(b={label:"Config > Disable reference highlighting",hidden:q,handle:_},e[54]=q,e[55]=_,e[56]=b):b=e[56];let y;e[57]!==l.display||e[58]!==i?(y=()=>{i({display:{...l.display,reference_highlighting:!0}})},e[57]=l.display,e[58]=i,e[59]=y):y=e[59];let D;e[60]!==l.display.reference_highlighting||e[61]!==y?(D={label:"Config > Enable reference highlighting",hidden:l.display.reference_highlighting,handle:y},e[60]=l.display.reference_highlighting,e[61]=y,e[62]=D):D=e[62];let a=l.display.cell_output==="above",o;e[63]!==l.display||e[64]!==i?(o=()=>{i({display:{...l.display,cell_output:"above"}})},e[63]=l.display,e[64]=i,e[65]=o):o=e[65];let F;e[66]!==a||e[67]!==o?(F={label:"Config > Set cell output area: above",hidden:a,handle:o},e[66]=a,e[67]=o,e[68]=F):F=e[68];let g=l.display.cell_output==="below",R;e[69]!==l.display||e[70]!==i?(R=()=>{i({display:{...l.display,cell_output:"below"}})},e[69]=l.display,e[70]=i,e[71]=R):R=e[71];let I;e[72]!==g||e[73]!==R?(I={label:"Config > Set cell output area: below",hidden:g,handle:R},e[72]=g,e[73]=R,e[74]=I):I=e[74],w=[...ee().filter(p).map(c),K,C,H,M,u,P,$,b,D,F,I].filter(Ae),e[6]=n,e[7]=l.completion,e[8]=l.display,e[9]=l.keymap,e[10]=h,e[11]=i,e[12]=w}else w=e[12];return w}function Ae(e){return!e.hidden}var Me=L(),s=T(de(),1),Ne=()=>{let e=(0,Me.c)(37),[l,t]=X(me),n=ce(),d=U(ye),r=U(ne),m;e[0]===d?m=e[1]:(m={cell:d},e[0]=d,e[1]=m);let k=pe(m).flat();k=O(k);let i=He(),f=he();f=[...O(f),...O(i)];let h=f.filter(De),w=ae.keyBy(h,Fe),{recentCommands:p,addRecentCommand:c}=ve(),K;e[2]===p?K=e[3]:(K=new Set(p),e[2]=p,e[3]=K);let C=K,H;e[4]!==r||e[5]!==t?(H=a=>{le(r.getHotkey("global.commandPalette").key)(a)&&(a.preventDefault(),t(Re))},e[4]=r,e[5]=t,e[6]=H):H=e[6],te(document,"keydown",H);let E;e[7]!==c||e[8]!==r||e[9]!==n||e[10]!==t?(E=(a,o)=>{let F=n[a];if(!F)return null;let g=r.getHotkey(a);return(0,s.jsxs)(J,{disabled:o.disabled,keywords:g.additionalKeywords,onSelect:()=>{c(a),t(!1),requestAnimationFrame(()=>{F()})},value:g.name,children:[(0,s.jsxs)("span",{children:[g.name,o.tooltip&&(0,s.jsx)("span",{className:"ml-2",children:o.tooltip})]}),(0,s.jsx)(z,{children:(0,s.jsx)(Q,{shortcut:g.key})})]},a)},e[7]=c,e[8]=r,e[9]=n,e[10]=t,e[11]=E):E=e[11];let A=E,M;e[12]!==c||e[13]!==r||e[14]!==t?(M=a=>{let{label:o,handle:F,props:g,hotkey:R,additionalKeywords:I}=a,B=g===void 0?{}:g;return(0,s.jsxs)(J,{disabled:B.disabled,keywords:I,onSelect:()=>{c(o),t(!1),requestAnimationFrame(()=>{F()})},value:o,children:[(0,s.jsxs)("span",{children:[o,B.tooltip&&(0,s.jsxs)("span",{className:"ml-2",children:["(",B.tooltip,")"]})]}),R&&(0,s.jsx)(z,{children:(0,s.jsx)(Q,{shortcut:r.getHotkey(R).key})})]},o)},e[12]=c,e[13]=r,e[14]=t,e[15]=M):M=e[15];let N=M,j=be,u;e[16]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(fe,{placeholder:"Type to search..."}),e[16]=u):u=e[16];let x=ke,S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=(0,s.jsx)(ge,{children:"No results found."}),e[17]=S):S=e[17];let P=p.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(V,{heading:"Recently Used",children:p.map(a=>{let o=w[a];return ie(a)?A(a,{disabled:o==null?void 0:o.disabled,tooltip:o==null?void 0:o.tooltip}):o&&!W(o)?N({label:o.label,handle:o.handleHeadless||o.handle,props:{disabled:o.disabled,tooltip:o.tooltip},additionalKeywords:o.additionalKeywords}):null})}),(0,s.jsx)(ue,{})]}),v=V,G=r.iterate().map(a=>{if(C.has(a))return null;let o=w[a];return A(a,{disabled:o==null?void 0:o.disabled,tooltip:o==null?void 0:o.tooltip})}),$=h.map(a=>C.has(a.label)?null:N({label:a.label,handle:a.handleHeadless||a.handle,props:{disabled:a.disabled,tooltip:a.tooltip},additionalKeywords:a.additionalKeywords})),q;e[18]!==C||e[19]!==N?(q=a=>C.has(a.label)?null:N({label:`Cell > ${a.label}`,handle:a.handleHeadless||a.handle,props:{disabled:a.disabled,tooltip:a.tooltip},additionalKeywords:a.additionalKeywords}),e[18]=C,e[19]=N,e[20]=q):q=e[20];let _=k.map(q),b;e[21]!==v||e[22]!==$||e[23]!==_||e[24]!==G?(b=(0,s.jsxs)(v,{heading:"Commands",children:[G,$,_]}),e[21]=v,e[22]=$,e[23]=_,e[24]=G,e[25]=b):b=e[25];let y;e[26]!==x||e[27]!==b||e[28]!==S||e[29]!==P?(y=(0,s.jsxs)(x,{children:[S,P,b]}),e[26]=x,e[27]=b,e[28]=S,e[29]=P,e[30]=y):y=e[30];let D;return e[31]!==j||e[32]!==l||e[33]!==t||e[34]!==y||e[35]!==u?(D=(0,s.jsxs)(j,{open:l,onOpenChange:t,children:[u,y]}),e[31]=j,e[32]=l,e[33]=t,e[34]=y,e[35]=u,e[36]=D):D=e[36],D};function De(e){return!e.hotkey}function Fe(e){return e.label}function Re(e){return!e}export{Ne as default};
@@ -1,14 +0,0 @@
1
- import{s as De}from"./chunk-LvLJmgfZ.js";import{d as R,i as Nt,l as zt,p as Mt,u as v}from"./useEvent-D91BmmQi.js";import{t as Wt}from"./react-Bj1aDYRI.js";import{An as St,Cr as At,E as Pe,Fn as _t,Hi as Dt,Jt as Pt,Kn as It,Ln as Et,Lt,Nn as Tt,Nr as Ht,Or as Ot,Pn as Rt,T as Ft,Tr as Bt,ct as $t,ea as ye,g as qt,m as Ie,si as Ut,st as Vt,t as Yt,ut as Ee,wr as Le,y as Kt}from"./cells-Cf7bHHq3.js";import{t as N}from"./compiler-runtime-B3qBwwSJ.js";import{n as Gt,r as Jt,x as Xt}from"./ai-model-dropdown-DXgLphFa.js";import{g as F,n as Qt}from"./useEventListener-B_w3A283.js";import{t as Te}from"./objects-BlG0ZrO0.js";import{C as Zt,r as ea}from"./utils-Z80SV4_d.js";import{n as j,t as He}from"./constants-CDyU_g2F.js";import{T as te,v as Oe,w as Re}from"./config-BbOTTCYY.js";import{c as ta}from"./readonly-python-code-CW_G5e4E.js";import{t as aa}from"./cn-DYvqRARy.js";import{t as oa}from"./jsx-runtime-Blw4afVn.js";import{o as na}from"./alert-dialog-BXegNC0I.js";import{a as sa,c as ia,i as la,n as ra,r as da,s as ca,t as ha}from"./select-B5TFNjmU.js";import{It as ma}from"./JsonOutput-DnGSkLeP.js";import{c as Fe,d as we,n as pa,o as ua,r as ge,t as fa}from"./download-BomYt3nl.js";import{t as xa}from"./tooltip-CFX4fYHU.js";import{r as ba,t as S}from"./button-eIihcbUw.js";import{i as ka,t as je}from"./strings-Djnbwmfl.js";import{r as T}from"./requests-9-v2bhoi.js";import{t as b}from"./createLucideIcon-w-Qo9n0R.js";import{F as ya,I as wa,L as ga,R as Be,a as $e,d as ja,i as qe,u as Ue}from"./layout-BOwE7yok.js";import{t as ve}from"./check-rzLRd0j9.js";import{r as va}from"./useCellActionButton-CRfIEVB5.js";import{t as Ca}from"./code-B2aKtXoe.js";import{t as Na}from"./copy-3iHFdt22.js";import{t as Ve}from"./eye-off-BOZA7gbn.js";import{t as Ye}from"./external-link-BOlXZUla.js";import{t as ae}from"./file-CJH9JNGH.js";import{u as za}from"./form-CgWNb44_.js";import{n as Ma,r as Wa,t as Sa}from"./youtube-OwaksuQt.js";import{i as Aa,n as Ke}from"./add-connection-dialog-CEp3SJR2.js";import{t as _a}from"./house-DS0r7dNZ.js";import{t as Da}from"./image-5XI2VU-q.js";import{t as Pa}from"./link-CHdiBDr5.js";import{r as Ia}from"./input-CqrUjynb.js";import{t as Ea}from"./settings-D_PiwXwo.js";import{t as La}from"./sparkles-DUCpRFlS.js";import{y as Ta}from"./textarea-CpFfEUet.js";import{t as Ha}from"./square-DFICx2Qv.js";import{t as Oa}from"./triangle-alert-BL4YVsPy.js";import{t as z}from"./use-toast-BwJoaaDM.js";import{n as Ce,t as Ra}from"./paths-BKO-pHK6.js";import{o as Fa}from"./session-CEFnN9Cq.js";import{n as B}from"./copy-BtTOqPTS.js";import{t as Ba}from"./copy-icon-C2pG0ZNK.js";import{r as $a}from"./useRunCells-CSSF_mJ0.js";import{a as Ge,c as Je,i as qa,n as Xe,r as Qe}from"./dialog-D1DEsRZ2.js";import{n as oe}from"./ImperativeModal-BIavOiUv.js";import{r as Ua,t as Ze}from"./share-CYpcX4N4.js";import{a as Va}from"./cell-link-DqBkyAFe.js";import{n as et}from"./useAsyncData-Bg5iAViP.js";import{a as Ya}from"./renderShortcut-BZLr8D7H.js";import{t as Ka}from"./icons-CIPE8AIY.js";import{i as Ga,n as tt}from"./error-entries-Birw-8VX.js";import{t as Ja}from"./pair-with-agent-modal-CKOYwOYw.js";import{t as Xa}from"./github-_JH-0hIO.js";import{n as at}from"./marimo-icons-C_nFooxr.js";import{t as Qa}from"./links-CToBjIIj.js";import{i as Za,n as ot,t as Ne}from"./skeleton-B_4CZVEm.js";import{t as nt}from"./types-Da7lA5YC.js";var eo=b("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),to=b("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),st=b("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),it=b("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),lt=b("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),ao=b("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),oo=b("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),no=b("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),rt=b("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),so=b("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),io=b("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),dt=b("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),lo=b("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),ro=b("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),ct=b("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function co(e,t){return{...e,Binaries:{...e.Binaries,Browser:t}}}function ho(e,t,o,n){return{marimo:e,Locale:o||void 0,Binaries:{Browser:t},"Environment Collection Error":n}}function ze(e,t){let o=Math.max(2,...Array.from(t.matchAll(/`+/g),s=>s[0].length)),n="`".repeat(o+1);return`${n}${e}
2
- ${t}
3
- ${n}`}function mo(e,t){let o=`${e}${e.includes("?")?"&":"?"}env=${encodeURIComponent(t)}`;return o.length>6e3?e:o}function Me(e,t){return["<details>",`<summary>${je.htmlEscape(e)??""}</summary>`,"",t,"","</details>"].join(`
4
- `)}function ht(e){let t=[Me("Environment",ze("json",JSON.stringify(e.environment,null,2)))];return e.errors.length>0&&t.push(Me("Current errors",ze("text",e.errors.map(tt).join(`
5
-
6
- ---
7
-
8
- `)))),e.notebook&&t.push(Me(`Notebook source: ${Ce.basename(e.notebook.filename)}`,ze("python",e.notebook.contents))),t.join(`
9
-
10
- `)}var mt=N(),a=De(oa(),1),A=De(Wt(),1),po=Qt,pt=e=>{let t=(0,mt.c)(16),{content:o}=e,[n,s]=(0,A.useState)(!1),l=!n&&"max-h-24 overflow-hidden",i;t[0]===l?i=t[1]:(i=aa("text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap",l),t[0]=l,t[1]=i);let r;t[2]!==o||t[3]!==i?(r=(0,a.jsx)("pre",{className:i,children:o}),t[2]=o,t[3]=i,t[4]=r):r=t[4];let d;t[5]===n?d=t[6]:(d=!n&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 rounded-b bg-gradient-to-b from-transparent to-muted"}),t[5]=n,t[6]=d);let c;t[7]!==r||t[8]!==d?(c=(0,a.jsxs)("div",{className:"relative",children:[r,d]}),t[7]=r,t[8]=d,t[9]=c):c=t[9];let p;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=()=>s(fo),t[10]=p):p=t[10];let f=n?"Show less":"Show more",u;t[11]===f?u=t[12]:(u=(0,a.jsx)(S,{type:"button",variant:"link",size:"xs",className:"self-start",onClick:p,children:f}),t[11]=f,t[12]=u);let h;return t[13]!==c||t[14]!==u?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[c,u]}),t[13]=c,t[14]=u,t[15]=h):h=t[15],h};const uo=e=>{let t=(0,mt.c)(6),{children:o}=e,{openModal:n,closeModal:s}=oe(),l;t[0]!==s||t[1]!==n?(l=()=>n((0,a.jsx)(ut,{onClose:s})),t[0]=s,t[1]=n,t[2]=l):l=t[2];let i;return t[3]!==o||t[4]!==l?(i=(0,a.jsx)(po,{onClick:l,children:o}),t[3]=o,t[4]=l,t[5]=i):i=t[5],i},ut=()=>{let{getEnvironmentInfo:e,readCode:t}=T(),o=et(async()=>e(),[e]),n=v(Kt),s=(0,A.useMemo)(()=>Ga(Nt),[n]),l=ja(n.cellIds.inOrderIds.map(x=>n.cellData[x])),i=v(Dt),r=v(Oe),d=i!==null&&l&&r.state===Re.OPEN,[c,p]=(0,A.useState)(!1),f=d?void 0:i===null?"Save the notebook first.":l?"Connect the notebook to include its source.":"Notebook source is hidden in this view.",u=et(async()=>{if(!c||!d||i===null)return;let{contents:x}=await t();return{filename:i,contents:x}},[c,d,i,t]),h=o.data?co(o.data,navigator.userAgent):o.status==="error"?ho(ta(),navigator.userAgent,navigator.language,"Server environment information unavailable"):void 0,[k,y]=(0,A.useState)(!1),w=(0,A.useMemo)(()=>h?mo(j.bugReportUrl,ht({environment:h,errors:s})):j.bugReportUrl,[h,s]);return(0,a.jsxs)(Xe,{className:"w-[540px] max-w-[90vw]",children:[(0,a.jsxs)(Ge,{children:[(0,a.jsx)(Je,{children:"Report an issue"}),(0,a.jsx)(Qe,{children:"Copy your environment and any current errors to include in a GitHub bug report. Nothing is uploaded automatically; review the details before posting."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 max-h-[60vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsxs)(S,{type:"button",variant:"default",size:"xs",disabled:!h||c&&u.isFetching,onClick:async()=>{h&&(await B(ht({environment:h,errors:s,notebook:c?u.data:void 0})),y(!0),setTimeout(()=>y(!1),2e3),z({title:o.status==="error"?"Partial issue details copied":"Issue details copied"}))},children:[k&&(0,a.jsx)(ve,{className:"w-4 h-4 mr-2 text-(--grass-11)",color:"white"}),k?"Copied!":"Copy issue details"]}),(0,a.jsx)(S,{type:"button",variant:"outline",size:"xs",asChild:!0,children:(0,a.jsxs)("a",{href:w,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(Ye,{className:"w-4 h-4 mr-2"}),"Open GitHub issue"]})})]}),c&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"The GitHub link prefills your environment only. Use Copy issue details to include the full notebook source."}),o.status==="pending"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading environment details\u2026"}),(0,a.jsx)(Ne,{className:"h-4 w-full"}),(0,a.jsx)(Ne,{className:"h-4 w-3/4"}),(0,a.jsx)(Ne,{className:"h-4 w-1/2"})]}),o.status==="error"&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(Oa,{className:"w-4 h-4 text-(--yellow-11) shrink-0"}),(0,a.jsx)("span",{children:"Server environment information unavailable"}),(0,a.jsx)(S,{type:"button",variant:"link",size:"xs",onClick:()=>o.refetch(),children:"Retry"})]}),h&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Environment details"}),(0,a.jsx)(Ba,{className:"w-3.5 h-3.5",value:JSON.stringify(h,null,2),ariaLabel:"Copy environment JSON",toastTitle:"Environment details copied"})]}),(0,a.jsx)(pt,{content:JSON.stringify(h,null,2)})]}),h&&s.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Current errors"}),(0,a.jsx)(pt,{content:s.map(tt).join(`
11
-
12
- ---
13
-
14
- `)})]}),h&&s.length===0&&(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"No current errors detected."}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,a.jsx)(Lt,{id:"issue-include-notebook",className:"mt-0.5",checked:c,disabled:!d,onCheckedChange:x=>p(x===!0),"aria-label":"Include full notebook source"}),(0,a.jsx)("label",{htmlFor:"issue-include-notebook",children:"Include full notebook source"})]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground ml-6",children:["Copies the entire saved Python source, including comments, literal data, embedded credentials, and package metadata. Outputs and external files are not included. Review it before posting."," ",(0,a.jsx)("span",{className:"font-bold",children:"For private notebooks, paste a minimal reproduction instead."})]}),f&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-6",children:f}),c&&u.status==="error"&&(0,a.jsx)("span",{className:"text-xs text-(--red-11) ml-6",children:"Notebook source could not be loaded."})]}),(0,a.jsx)("div",{className:"border-t pt-3",children:(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Other feedback? Take our"," ",(0,a.jsx)("a",{href:j.feedbackForm,target:"_blank",rel:"noreferrer",className:"underline",children:"two-minute survey"})," ","or chat with us on"," ",(0,a.jsx)("a",{href:j.discordLink,target:"_blank",rel:"noreferrer",className:"underline",children:"Discord"}),"."]})})]})]})};function fo(e){return!e}var ft=N(),ne="https://static.marimo.app";const xo=e=>{let t=(0,ft.c)(25),{onClose:o}=e,[n,s]=(0,A.useState)(""),{exportAsHTML:l}=T(),i=`${n}-${Math.random().toString(36).slice(2,6)}`,r=`${ne}/static/${i}`,d;t[0]!==l||t[1]!==o||t[2]!==i?(d=async M=>{M.preventDefault(),o();let O=await l({download:!1,includeCode:!0,files:ya.INSTANCE.filenames()}),_=z({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ne}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:O,path:i})}).catch(()=>{_.dismiss(),z({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:j.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),_.dismiss(),z({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=l,t[1]=o,t[2]=i,t[3]=d):d=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Je,{children:"Share static notebook"}),t[4]=c):c=t[4];let p;t[5]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsxs)(Ge,{children:[c,(0,a.jsxs)(Qe,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:ne,target:"_blank",children:ne}),"."]})]}),t[5]=p):p=t[5];let f;t[6]===Symbol.for("react.memo_cache_sentinel")?(f=M=>{s(M.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=f):f=t[6];let u;t[7]===n?u=t[8]:(u=(0,a.jsx)(Ia,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:n,placeholder:"Notebook slug",onChange:f,required:!0,autoComplete:"off"}),t[7]=n,t[8]=u);let h;t[9]===r?h=t[10]:(h=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(bo,{text:r}),(0,a.jsx)("span",{className:"text-primary",children:r})]})]}),t[9]=r,t[10]=h);let k;t[11]!==u||t[12]!==h?(k=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[u,h]}),t[11]=u,t[12]=h,t[13]=k):k=t[13];let y;t[14]===o?y=t[15]:(y=(0,a.jsx)(S,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:o,children:"Cancel"}),t[14]=o,t[15]=y);let w;t[16]===r?w=t[17]:(w=(0,a.jsx)(S,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await B(r)},children:"Create"}),t[16]=r,t[17]=w);let x;t[18]!==y||t[19]!==w?(x=(0,a.jsxs)(qa,{children:[y,w]}),t[18]=y,t[19]=w,t[20]=x):x=t[20];let C;return t[21]!==d||t[22]!==x||t[23]!==k?(C=(0,a.jsx)(Xe,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:d,children:[p,k,x]})}),t[21]=d,t[22]=x,t[23]=k,t[24]=C):C=t[24],C};var bo=e=>{let t=(0,ft.c)(8),[o,n]=A.useState(!1),s;t[0]===e.text?s=t[1]:(s=ba.stopPropagation(async c=>{c.preventDefault(),await B(e.text),n(!0),setTimeout(()=>n(!1),2e3)}),t[0]=e.text,t[1]=s);let l=s,i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),t[2]=i):i=t[2];let r;t[3]===l?r=t[4]:(r=(0,a.jsx)(S,{"data-testid":"copy-static-notebook-url-button",onClick:l,size:"xs",variant:"secondary",children:i}),t[3]=l,t[4]=r);let d;return t[5]!==o||t[6]!==r?(d=(0,a.jsx)(xa,{content:"Copied!",open:o,children:r}),t[5]=o,t[6]=r,t[7]=d):d=t[7],d},ko=N();function yo(){let e=document.getElementsByClassName(He.outputArea);for(let t of e){let o=t.getBoundingClientRect();if(o.bottom>0&&o.top<window.innerHeight){let n=ye.findElement(t);if(!n){F.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ye.parse(n.id)}}}return F.warn("No visible output area found for scroll anchor"),null}function wo(e){if(!e){F.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ye.create(e.cellId));if(!t){F.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${He.outputArea}`)){F.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function xt(){let e=(0,ko.c)(2),t=R(Ee),o;return e[0]===t?o=e[1]:(o=()=>{let n=yo();t(s=>({mode:$t(s.mode),cellAnchor:(n==null?void 0:n.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{wo(n)})})},e[0]=t,e[1]=o),o}const bt=Mt(!1);var go=N();const jo=()=>{let e=(0,go.c)(7),{selectedLayout:t}=$e(),{setLayoutView:o}=qe();if(te()&&!It("wasm_layouts"))return null;let n;e[0]===o?n=e[1]:(n=r=>o(r),e[0]=o,e[1]=n);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ca,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(ia,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(ra,{children:(0,a.jsxs)(da,{children:[(0,a.jsx)(sa,{children:"View as"}),nt.map(Co)]})}),e[3]=l):l=e[3];let i;return e[4]!==t||e[5]!==n?(i=(0,a.jsxs)(ha,{"data-testid":"layout-select",value:t,onValueChange:n,children:[s,l]}),e[4]=t,e[5]=n,e[6]=i):i=e[6],i};function vo(e){return(0,a.jsx)(kt(e),{className:"h-4 w-4"})}function kt(e){switch(e){case"vertical":return no;case"grid":return Wa;case"slides":return dt;default:return ka(e),Ha}}function yt(e){return je.startCase(e)}function Co(e){return(0,a.jsx)(la,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[vo(e),(0,a.jsx)("span",{children:yt(e)})]})},e)}async function No(e){let{filename:t,preset:o,downloadPDF:n}=e;await n({filename:t,webpdf:!1,preset:o,includeInputs:!0,rasterServer:"static"})}var zo=N();function Mo(e){let t=(0,zo.c)(5),{openPrompt:o,closeModal:n}=oe(),{sendCopy:s}=T(),l;return t[0]!==n||t[1]!==o||t[2]!==s||t[3]!==e?(l=()=>{if(!e)return null;let i=Ra.guessDeliminator(e);o({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Ce.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:r=>{let d=i.join(Ce.dirname(e),r);s({source:e,destination:d}).then(()=>{n(),z({title:"Notebook copied",description:"A copy of the notebook has been created."}),Qa(d)})}})},t[0]=n,t[1]=o,t[2]=s,t[3]=e,t[4]=l):l=t[4],l}var Wo=N();function wt(){let e=(0,Wo.c)(4),{openConfirm:t}=oe(),o=R(Oe),{sendRestart:n}=T(),s;return e[0]!==t||e[1]!==n||e[2]!==o?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(na,{onClick:async()=>{o({state:Re.CLOSING}),await n(),Ua()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=n,e[2]=o,e[3]=s):s=e[3],s}var So=N(),Ao=new Pt,_o=e=>Ao.isSupported(e)?"markdown":"code";const gt=()=>{let e=(0,So.c)(3),{updateCellConfig:t}=Pe(),{saveCellConfig:o}=T(),n;return e[0]!==o||e[1]!==t?(n=async(s,l)=>{let i=Ie(),r={};for(let c of i.cellIds.inOrderIds){let p=i.cellData[c];p===void 0||p.config.hide_code===s||_o(p.code)===l&&(r[c]={hide_code:s})}let d=Te.entries(r);if(d.length!==0){await o({configs:r});for(let[c,p]of d)t({cellId:c,config:p})}},e[0]=o,e[1]=t,e[2]=n):n=e[2],n};var Do=N(),H=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Po(){var Se,Ae,_e;let e=(0,Do.c)(56),t=Va(),{openModal:o,closeModal:n}=oe(),{toggleApplication:s}=Tt(),{selectedPanel:l}=Rt(),[i]=zt(Ee),r=v(Vt),d=gt(),[c]=Zt(),p=v(St),f=v(ea),{updateCellConfig:u,undoDeleteCell:h,clearAllCellOutputs:k,addSetupCellIfDoesntExist:y,collapseAllCells:w,expandAllCells:x}=Pe(),C=wt(),M=$a(),O=Mo(t),_=R(bt),ie=R(Gt),{handleClick:le}=Jt(),re=R(Xt),{exportAsIPYNB:de,exportAsMarkdown:ce,readCode:D,saveCellConfig:he,updateCellOutputs:P}=T(),I=Za(),me=v(qt),pe=v(Yt),ue=v(Ft),{selectedLayout:$}=$e(),{setLayoutView:fe}=qe(),q=xt(),U=((Se=c.sharing)==null?void 0:Se.html)??!0,V=((Ae=c.sharing)==null?void 0:Ae.wasm)??!0,Y=((_e=c.sharing)==null?void 0:_e.molab)??!0,We=!te(),xe=$==="slides",jt=Xo,vt=Jo,K;e[0]!==t||e[1]!==I||e[2]!==P?(K=async m=>{let{preset:g,title:W}=m;if(!t){se();return}await Fe(W,async ke=>{await ot({takeScreenshots:()=>I({progress:ke}),updateCellOutputs:P}),await No({filename:t,preset:g,downloadPDF:pa})})},e[0]=t,e[1]=I,e[2]=P,e[3]=K):K=e[3];let E=K,G;e[4]===E?G=e[5]:(G=async()=>{if(We){await E({preset:"document",title:"Downloading Document PDF..."});return}let m=new Event("export-beforeprint"),g=new Event("export-afterprint");window.dispatchEvent(m),setTimeout(Go,0),setTimeout(()=>window.dispatchEvent(g),0)},e[4]=E,e[5]=G);let J=G,X;e[6]!==de||e[7]!==t||e[8]!==I||e[9]!==P?(X=async()=>{if(!t){se();return}await Fe("Downloading IPYNB...",async m=>{await ot({takeScreenshots:()=>I({progress:m}),updateCellOutputs:P});let g=await de({download:!1});ge(new Blob([g],{type:"application/x-ipynb+json"}),we.toIPYNB(document.title))})},e[6]=de,e[7]=t,e[8]=I,e[9]=P,e[10]=X):X=e[10];let be=X,Q;e[11]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,a.jsx)(ma,{size:14,strokeWidth:1.5}),e[11]=Q):Q=e[11];let Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),e[12]=Z):Z=e[12];let L;e[13]===t?L=e[14]:(L=async()=>{if(!t){se();return}await Ue({filename:t,includeCode:!0})},e[13]=t,e[14]=L);let ee;return e[15]!==y||e[16]!==f||e[17]!==pe||e[18]!==p||e[19]!==k||e[20]!==n||e[21]!==w||e[22]!==O||e[23]!==E||e[24]!==x||e[25]!==ce||e[26]!==t||e[27]!==J||e[28]!==be||e[29]!==me||e[30]!==xe||e[31]!==r||e[32]!==o||e[33]!==le||e[34]!==D||e[35]!==C||e[36]!==M||e[37]!==he||e[38]!==$||e[39]!==l||e[40]!==d||e[41]!==_||e[42]!==re||e[43]!==fe||e[44]!==ie||e[45]!==U||e[46]!==Y||e[47]!==V||e[48]!==L||e[49]!==s||e[50]!==q||e[51]!==h||e[52]!==ue||e[53]!==u||e[54]!==i.mode?(ee=[{icon:Q,label:"Download",handle:H,dropdown:[{icon:Z,label:"Download as HTML",handle:L},{icon:(0,a.jsx)(Be,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){se();return}await Ue({filename:t,includeCode:!1})}},{icon:(0,a.jsx)(Ka,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{let m=await ce({download:!1});ge(new Blob([m],{type:"text/plain"}),we.toMarkdown(document.title))}},{icon:(0,a.jsx)(so,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:be},{icon:(0,a.jsx)(Ca,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let m=await D();ge(new Blob([m.contents],{type:"text/plain"}),we.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:i.mode!=="present",tooltip:i.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Ya("global.hideCode",!1)]}),handle:Ko},xe?{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:H,dropdown:[{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:J},{icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:vt(!0),hidden:!We,handle:async()=>{await E({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(ae,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:J}]},{icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:te(),handle:async()=>{o((0,a.jsx)(Ja,{onClose:n}))}},{icon:(0,a.jsx)(lo,{size:14,strokeWidth:1.5}),label:"Share",handle:H,hidden:!U&&!V&&!Y,dropdown:[{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!U,handle:async()=>{o((0,a.jsx)(xo,{onClose:n}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!V,handle:async()=>{await B(Ze({code:(await D()).contents})),z({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!Y,handle:async()=>{let m=Ze({code:(await D()).contents,baseUrl:`${j.molab}/new`});window.open(m,"_blank")}}]},{icon:(0,a.jsx)(io,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:H,dropdown:_t.flatMap(m=>{let g=m.type==="ai"&&!f;if(Et({panel:m,capabilities:p,aiEnabled:f})&&!g)return[];let{type:W,Icon:ke,additionalKeywords:Ct}=m;return{label:je.startCase(W),rightElement:jt(l===W),icon:(0,a.jsx)(ke,{size:14,strokeWidth:1.5}),handle:()=>{if(g){le("ai","ai-features");return}s(W)},additionalKeywords:Ct}})},{icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Present as",handle:H,dropdown:[{icon:i.mode==="present"?(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}):(0,a.jsx)(wa,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...nt.map((m,g)=>{let W=kt(m);return{divider:g===0,label:yt(m),icon:(0,a.jsx)(W,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:$===m&&(0,a.jsx)(ve,{size:14})}),handle:()=>{fe(m),i.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(oo,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||te(),handle:O},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await B((await D()).contents),z({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(va,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!me||r,handle:async()=>{let m=Ut(Ie());await he({configs:Te.fromEntries(m.map(Yo))});for(let g of m)u({cellId:g,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(lt,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(Bt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{o((0,a.jsx)(Ke,{onClose:n}))}},{icon:(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{o((0,a.jsx)(Ke,{defaultTab:"storage",onClose:n}))}},{icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:ue,hidden:!pe||r,handle:()=>{h()}},{icon:(0,a.jsx)(ro,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:C,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(ao,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{M()}},{icon:(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{k()}},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Show all code",hotkey:"global.showAllCode",handle:()=>d(!1,"code"),redundant:!0},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Hide all code",hotkey:"global.hideAllCode",handle:()=>d(!0,"code"),redundant:!0},{icon:(0,a.jsx)(Le,{size:14,strokeWidth:1.5}),label:"Show all markdown code",hotkey:"global.showAllMarkdownCode",handle:()=>d(!1,"markdown"),redundant:!0},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",hotkey:"global.hideAllMarkdownCode",handle:()=>d(!0,"markdown"),redundant:!0},{icon:(0,a.jsx)(to,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:w,redundant:!0},{icon:(0,a.jsx)(eo,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:x,redundant:!0},{divider:!0,icon:(0,a.jsx)(it,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>_(Vo)},{icon:(0,a.jsx)(ga,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>re(Uo)},{icon:(0,a.jsx)(Ea,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>ie(qo),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(rt,{size:14,strokeWidth:1.5}),label:"Report an issue",additionalKeywords:["feedback","bug","issue","report","diagnostics"],handle:()=>o((0,a.jsx)(ut,{onClose:n}))},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Resources",handle:H,dropdown:[{icon:(0,a.jsx)(Ht,{size:14,strokeWidth:1.5}),label:"Documentation",handle:$o},{icon:(0,a.jsx)(Xa,{className:"h-3.5 w-3.5"}),label:"GitHub",handle:Bo},{icon:(0,a.jsx)(Ma,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Fo},{icon:(0,a.jsx)(Sa,{className:"h-3.5 w-3.5"}),label:"YouTube",handle:Ro},{icon:(0,a.jsx)(At,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Oo}]},{divider:!0,icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Open home",hidden:!location.search.includes("file"),handle:Ho},{icon:(0,a.jsx)(at,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:To}].filter(Lo).map(Io),e[15]=y,e[16]=f,e[17]=pe,e[18]=p,e[19]=k,e[20]=n,e[21]=w,e[22]=O,e[23]=E,e[24]=x,e[25]=ce,e[26]=t,e[27]=J,e[28]=be,e[29]=me,e[30]=xe,e[31]=r,e[32]=o,e[33]=le,e[34]=D,e[35]=C,e[36]=M,e[37]=he,e[38]=$,e[39]=l,e[40]=d,e[41]=_,e[42]=re,e[43]=fe,e[44]=ie,e[45]=U,e[46]=Y,e[47]=V,e[48]=L,e[49]=s,e[50]=q,e[51]=h,e[52]=ue,e[53]=u,e[54]=i.mode,e[55]=ee):ee=e[55],ee}function Io(e){return e.dropdown?{...e,dropdown:e.dropdown.filter(Eo)}:e}function Eo(e){return!e.hidden}function Lo(e){return!e.hidden}function To(){let e=Fa();window.open(e,"_blank")}function Ho(){let e=document.baseURI.split("?")[0];window.open(e,"_blank","noopener")}function Oo(){window.open(j.releasesPage,"_blank")}function Ro(){window.open(j.youtube,"_blank")}function Fo(){window.open(j.discordLink,"_blank")}function Bo(){window.open(j.githubPage,"_blank")}function $o(){window.open(j.docsPage,"_blank")}function qo(e){return!e}function Uo(e){return!e}function Vo(e){return!e}function Yo(e){return[e,{disabled:!1}]}async function Ko(){let e=document.getElementById("App");e&&await ua({element:e,filename:document.title,prepare:fa})}function Go(){return window.print()}function Jo(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function Xo(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(ve,{size:14})})}function se(){z({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{bt as a,ct as c,it as d,st as f,jo as i,rt as l,gt as n,xt as o,wt as r,uo as s,Po as t,lt as u};