@sheetxl/scripting-mui 0.8.0-beta.10 → 0.8.0-beta.11

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.10
2
+ * @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.11
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -8,31 +8,32 @@ import e, { createElement as t, forwardRef as n, memo as r, useCallback as i, us
8
8
  import { Box as u, Button as d, CircularProgress as f, Paper as p, Typography as m, useTheme as h } from "@mui/material";
9
9
  import { Command as g, CommandButtonType as _, DefaultCommandButtonRegistry as v, DefaultIconService as y, DynamicIcon as b, KeyCodes as x, ReactUtils as S, useCallbackRef as C, useCommandButtonEntry as w, useCommands as T, useImperativeElement as E, useTranslator as D } from "@sheetxl/utils-react";
10
10
  import { AnimatedLoadingPanel as ee, CommandButton as O, CommandPopupButton as k, CommandToolbar as A, ExhibitDivider as j, ExhibitMenuItem as M, OverflowPalette as N, defaultCreatePopupPanel as P } from "@sheetxl/utils-mui";
11
- import { DefaultTaskPaneRegistry as F, InputClipboardInjector as I, useModelSync as L, useWorkbook as R } from "@sheetxl/react";
12
- import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
13
- import { alpha as te } from "@mui/system";
14
- import { VERSION as H } from "@sheetxl/sdk";
15
- import { ChainedError as U } from "@sheetxl/utils";
16
- import { ScriptEditor as ne, ScriptingReactPlugin as re } from "@sheetxl/scripting-react";
17
- function ie(e) {
11
+ import { DefaultTaskPaneRegistry as te, InputClipboardInjector as F, useModelSync as I, useWorkbook as L } from "@sheetxl/react";
12
+ import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
13
+ import { alpha as V } from "@mui/system";
14
+ import { listResources as H, releaseChannel as ne } from "@sheetxl/utils";
15
+ import { VERSION as re } from "@sheetxl/sdk";
16
+ import { ScriptEditor as ie, ScriptingReactPlugin as ae } from "@sheetxl/scripting-react";
17
+ function oe(e) {
18
18
  var t, n, r = "";
19
19
  if (typeof e == "string" || typeof e == "number") r += e;
20
20
  else if (typeof e == "object") {
21
21
  if (Array.isArray(e)) {
22
22
  var i = e.length;
23
- for (t = 0; t < i; t++) e[t] && (n = ie(e[t])) && (r && (r += " "), r += n);
23
+ for (t = 0; t < i; t++) e[t] && (n = oe(e[t])) && (r && (r += " "), r += n);
24
24
  } else for (n in e) e[n] && (r && (r += " "), r += n);
25
25
  }
26
26
  return r;
27
27
  }
28
- function W() {
29
- for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = ie(e)) && (r && (r += " "), r += t);
28
+ function U() {
29
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = oe(e)) && (r && (r += " "), r += t);
30
30
  return r;
31
31
  }
32
- var ae = {
32
+ var se = {
33
33
  "insertFunction.fallbackLabel": "Function",
34
34
  "insertFunction.insertNamed": "Insert {name}",
35
35
  "insertScript.fallbackLabel": "Insert Script",
36
+ "insertScript.loadFailedRetry": "Couldn’t load templates. Retry",
36
37
  "insertScript.loading": "Loading...",
37
38
  "runScript.executeNamed": "Execute {name}",
38
39
  "runScript.fallbackLabel": "Macro",
@@ -44,13 +45,13 @@ var ae = {
44
45
  "templateSelect.loadFailed": "Failed to load scripts",
45
46
  "templateSelect.title": "Script Template",
46
47
  "templateSelect.untitled": "Untitled"
47
- }, { DefaultCommandCatalogService: oe } = g, se = !1;
48
+ }, { DefaultCommandCatalogService: ce } = g, W = !1;
48
49
  function G() {
49
- se || (se = !0, oe.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: ae }));
50
+ W || (W = !0, ce.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: se }));
50
51
  }
51
52
  G();
52
- var ce = r(n((e, n) => {
53
- let { groupKey: r, ...i } = e, o = R(), s = D(), [c, d] = l([]), [f, p] = l(!1);
53
+ var le = r(n((e, n) => {
54
+ let { groupKey: r, ...i } = e, o = L(), s = D(), [c, d] = l([]), [f, p] = l(!1);
54
55
  a(() => {
55
56
  let e = o?.getScripts();
56
57
  e && (async () => {
@@ -66,16 +67,16 @@ var ce = r(n((e, n) => {
66
67
  }, h = [], g = c ? c.length : 0;
67
68
  for (let e = 0; e < g; e++) {
68
69
  let t = c[e];
69
- h.push(B(O, {
70
+ h.push(z(O, {
70
71
  ...m,
71
72
  commandKey: "executeScript",
72
73
  commandState: { declaration: t },
73
74
  propsTooltip: { description: s("runScript.executeNamed", { name: t.getName() ?? s("runScript.fallbackLabel") }) },
74
- icon: B(b, { iconKey: "ScriptMacro" }),
75
+ icon: z(b, { iconKey: "ScriptMacro" }),
75
76
  label: t.getName() ?? s("runScript.fallbackLabel")
76
77
  }, `macro-${t.getName()}-${e}`));
77
78
  }
78
- let v = V(u, {
79
+ let v = B(u, {
79
80
  ref: n,
80
81
  sx: {
81
82
  display: "flex",
@@ -83,13 +84,13 @@ var ce = r(n((e, n) => {
83
84
  flex: "1 1 100%",
84
85
  overflow: "hidden"
85
86
  },
86
- children: [h.length > 0 ? V(z, { children: [B(u, {
87
+ children: [h.length > 0 ? B(R, { children: [z(u, {
87
88
  sx: {
88
89
  overflow: "auto",
89
90
  flex: "1 1 100%"
90
91
  },
91
92
  children: h
92
- }), B(j, { orientation: "horizontal" })] }) : null, t(O, {
93
+ }), z(j, { orientation: "horizontal" })] }) : null, t(O, {
93
94
  ...m,
94
95
  key: "show-editor",
95
96
  commandKey: "showScriptEditor"
@@ -100,10 +101,10 @@ var ce = r(n((e, n) => {
100
101
  children: v
101
102
  });
102
103
  }));
103
- ce.displayName = "RunScriptPopupPanel";
104
- var K = r(n((e, t) => {
104
+ le.displayName = "RunScriptPopupPanel";
105
+ var ue = r(n((e, t) => {
105
106
  let { groupKey: n, disabled: r, ...a } = e, o = T(["showScriptEditor"])[0], s = w("scriptsOptions"), c = i((e) => {
106
- let t = B(ce, {
107
+ let t = z(le, {
107
108
  disabled: r,
108
109
  groupKey: n,
109
110
  ...e
@@ -113,7 +114,7 @@ var K = r(n((e, t) => {
113
114
  children: t
114
115
  });
115
116
  }, [r, n]);
116
- return B(k, {
117
+ return z(k, {
117
118
  ref: t,
118
119
  disabled: r,
119
120
  createPopupPanel: c,
@@ -123,50 +124,45 @@ var K = r(n((e, t) => {
123
124
  quickCommand: "showScriptEditor",
124
125
  ...a
125
126
  });
126
- })), le = /^\d+\.\d+\.\d+-([0-9A-Za-z-]+)/.exec(H)?.[1], q = `https://unpkg.com/@sheetxl/templates-scripting${le ? `@${le}` : ""}/dist`, J = (e, t) => {
127
+ })), K = ne(re), q = `https://unpkg.com/@sheetxl/templates-scripting${K ? `@${K}` : ""}/dist`, de = "templates-scripting", fe = [
128
+ "formula",
129
+ "macro",
130
+ "autostart"
131
+ ], pe = (e) => typeof e == "string" && e ? e : void 0, me = (e, t) => {
132
+ let n = (e.split("/").pop() ?? "").replace(/\.[^/.]+$/, "");
133
+ return t === "formula" ? n.toUpperCase() : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
134
+ }, he = async (e, t) => {
135
+ if (!/\.ts$/i.test(t.path)) return null;
136
+ let n = fe.includes(t.icon) ? t.icon : void 0, r = ((e, t) => {
137
+ let n = `${e}${e.endsWith("/") ? "" : "/"}${de}/${t}`;
138
+ return typeof document > "u" ? n : new URL(n, document.baseURI).href;
139
+ })(e, t.path), i;
127
140
  try {
128
- return new URL(t).href;
129
- } catch {}
130
- if (t.startsWith("/") || /^[a-zA-Z]:/.test(t)) return t;
131
- let n = e.startsWith("http") ? e : `file:///${e.replace(/\\/g, "/")}`;
132
- return n.endsWith("/") || (n += "/"), new URL(t, n).href;
133
- }, ue = (e) => {
134
- if (e.metadata?.name) return e.metadata.name;
135
- let t = (e.path.split("/").pop() || "").replace(/\.[^/.]+$/, "");
136
- return e.metadata?.icon === "formula" ? t.toUpperCase() : (t = t.replace(/([a-z])([A-Z])/g, "$1 $2"), t.replace(/[-_]/g, " ").trim().split(/\s+/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "));
137
- }, de = async (e) => {
138
- let t = J(e, "./manifest.json"), n = await fetch(t);
139
- if (!n.ok) throw new U(`Failed to retrieve directory at '${e}': ${n.statusText}`);
140
- let r = await n.text();
141
- if (r.trim().toLowerCase().startsWith("<!doctype html") || r.trim().toLowerCase().startsWith("<html")) throw new U(`Failed to retrieve directory at '${e}'`);
142
- let i;
143
- try {
144
- i = JSON.parse(r);
141
+ let e = await fetch(r);
142
+ if (!e.ok || (e.headers.get("content-type") ?? "").includes("text/html")) throw Error(e.ok ? "not found" : e.statusText || String(e.status));
143
+ i = await e.text();
145
144
  } catch (e) {
146
- throw Error(`Failed to parse directory: ${e.message}. Ensure the file is valid JSON.`);
145
+ return console.warn(`Script template '${r}' did not load: ${e?.message ?? e}`), null;
147
146
  }
148
- let a = i.map(async (t) => {
149
- try {
150
- let n = J(e, t.path), r = await fetch(n);
151
- if (!r.ok) throw Error(`Failed to fetch file at '${t.path}': ${r.statusText}`);
152
- let i = await r.text(), a = t.metadata;
153
- return a?.title || (a = {
154
- title: ue(t),
155
- ...a
156
- }), {
157
- path: t.path,
158
- content: i,
159
- metadata: a
160
- };
161
- } catch (e) {
162
- console.error(e.message);
163
- }
164
- return null;
165
- });
166
- return (await Promise.all(a)).filter((e) => e !== null);
167
- }, Y = { marginRight: "4px" }, X = "1em", fe = r((e) => {
168
- let { disabled: t, snippet: n, description: r, handleInsert: i, sx: a, ...o } = e, s, c = n.metadata?.icon;
169
- return s = B(b, c === "formula" ? {
147
+ return {
148
+ path: t.path,
149
+ title: pe(t.title) ?? me(t.path, n),
150
+ summary: pe(t.summary),
151
+ icon: n,
152
+ content: i
153
+ };
154
+ }, J = /* @__PURE__ */ new Map(), ge = (e = q) => {
155
+ let t = J.get(e);
156
+ return t || (t = (async () => {
157
+ let t = (await H("templates", de, e)).find((e) => e.meta?.schema !== void 0);
158
+ if (!t) throw Error(`No script templates found at '${e}'.`);
159
+ return Math.floor(Number(t.meta?.schema)) === 1 ? (await Promise.all(t.entries.map((t) => he(e, t)))).filter((e) => e !== null) : (console.warn(`Script template catalog at '${e}' has schema ${t.meta?.schema}; expected 1.`), []);
160
+ })(), J.set(e, t), t.catch(() => {
161
+ J.delete(e);
162
+ })), t;
163
+ }, Y = { marginRight: "4px" }, X = "1em", _e = r((e) => {
164
+ let { disabled: t, snippet: n, description: r, handleInsert: i, sx: a, ...o } = e, s, c = n.icon;
165
+ return s = z(b, c === "formula" ? {
170
166
  iconKey: "ScriptFormula",
171
167
  size: X,
172
168
  style: Y
@@ -178,7 +174,7 @@ var K = r(n((e, t) => {
178
174
  iconKey: "ScriptAutoRun",
179
175
  size: X,
180
176
  style: Y
181
- }), B(M, {
177
+ }), z(M, {
182
178
  sx: {
183
179
  maxWidth: "460px",
184
180
  display: "flex",
@@ -197,57 +193,69 @@ var K = r(n((e, t) => {
197
193
  e.keyCode !== x.Enter && e.keyCode !== x.Space || i(n);
198
194
  },
199
195
  ...o,
200
- children: V(u, {
196
+ children: B(u, {
201
197
  sx: {
202
198
  display: "flex",
203
199
  flex: "1 1 100%",
204
200
  flexDirection: "column",
205
201
  overflow: "hidden"
206
202
  },
207
- children: [B(m, {
203
+ children: [z(m, {
208
204
  component: "div",
209
- children: n.metadata?.title ?? n.path
210
- }), B(m, {
205
+ children: n.title
206
+ }), z(m, {
211
207
  variant: "caption",
212
208
  component: "div",
213
209
  sx: {
214
- color: (e) => te(e.palette.text.secondary ?? e.palette.text.primary, .6),
210
+ color: (e) => V(e.palette.text.secondary ?? e.palette.text.primary, .6),
215
211
  overflow: "hidden",
216
212
  textOverflow: "ellipsis"
217
213
  },
218
- children: n.metadata?.summary
214
+ children: n.summary
219
215
  })]
220
216
  })
221
217
  });
222
- }), pe = r(n((e, n) => {
223
- let { groupKey: r, disabled: o, scriptPath: s = q, ...c } = e, d = D(), [f, p] = l([]), [m, h] = l(!0), [g] = T(["insertScript"]), v = o || (g?.disabled() ?? !1);
218
+ }), ve = r(n((e, n) => {
219
+ let { groupKey: r, disabled: o, scriptPath: s = q, ...c } = e, d = D(), [f, p] = l([]), [m, h] = l("loading"), [g, v] = l(0), [y] = T(["insertScript"]), b = o || (y?.disabled() ?? !1);
224
220
  a(() => {
225
- (async () => {
226
- try {
227
- let e = await de(s);
228
- p(e);
229
- } catch {} finally {
230
- h(!1);
231
- }
232
- })();
233
- }, [s]);
234
- let y = i((e) => {
235
- if (m) return B("div", { children: d("insertScript.loading") });
221
+ let e = !1;
222
+ return h("loading"), ge(s).then((t) => {
223
+ e || (p(t), h("ready"));
224
+ }, () => {
225
+ e || (p([]), h("error"));
226
+ }), () => {
227
+ e = !0;
228
+ };
229
+ }, [s, g]);
230
+ let S = i((e) => {
231
+ if (m === "loading") return z("div", { children: d("insertScript.loading") });
236
232
  let n = {
237
233
  variant: _.Menuitem,
238
234
  groupKey: "scriptsOptions",
239
- disabled: v
235
+ disabled: b
240
236
  }, r = (t) => {
241
- g?.execute(t.content), e.closeFloat?.();
242
- }, i = [];
237
+ y?.execute(t.content), e.closeFloat?.();
238
+ }, i = () => v((e) => e + 1), a = [];
239
+ m === "error" && a.push(z(M, {
240
+ onMouseDown: (e) => {
241
+ e.button === 0 && e.preventDefault();
242
+ },
243
+ onMouseUp: (e) => {
244
+ e.button === 0 && i();
245
+ },
246
+ onKeyDown: (e) => {
247
+ e.keyCode !== x.Enter && e.keyCode !== x.Space || i();
248
+ },
249
+ children: d("insertScript.loadFailedRetry")
250
+ }, "retry"));
243
251
  for (let e = 0; e < f.length; e++) {
244
252
  let t = f[e];
245
- t && i.push(B(fe, {
253
+ t && a.push(z(_e, {
246
254
  handleInsert: r,
247
255
  snippet: t
248
256
  }, t.path));
249
257
  }
250
- let a = V(u, {
258
+ let o = B(u, {
251
259
  sx: {
252
260
  display: "flex",
253
261
  flexDirection: "column",
@@ -255,13 +263,13 @@ var K = r(n((e, t) => {
255
263
  overflow: "hidden"
256
264
  },
257
265
  children: [
258
- i.length > 0 ? V(z, { children: [B(u, {
266
+ a.length > 0 ? B(R, { children: [z(u, {
259
267
  sx: {
260
268
  overflow: "auto",
261
269
  flex: "1 1 100%"
262
270
  },
263
- children: i
264
- }), B(j, { orientation: "horizontal" })] }) : null,
271
+ children: a
272
+ }), z(j, { orientation: "horizontal" })] }) : null,
265
273
  t(O, {
266
274
  ...n,
267
275
  key: "showKeyboardShortcuts",
@@ -276,50 +284,51 @@ var K = r(n((e, t) => {
276
284
  });
277
285
  return P({
278
286
  ...e,
279
- children: a
287
+ children: o
280
288
  });
281
289
  }, [
282
- v,
290
+ b,
283
291
  r,
284
292
  m,
285
- g,
293
+ f,
294
+ y,
286
295
  d
287
296
  ]);
288
- return B(k, {
297
+ return z(k, {
289
298
  ref: n,
290
- disabled: v,
299
+ disabled: b,
291
300
  groupKey: r,
292
- label: g?.getLabel(r) ?? d("insertScript.fallbackLabel"),
293
- tooltip: g?.getDescription(),
294
- createPopupPanel: y,
295
- icon: g?.getIcon() ?? "ScriptInsert",
301
+ label: y?.getLabel(r) ?? d("insertScript.fallbackLabel"),
302
+ tooltip: y?.getDescription(),
303
+ createPopupPanel: S,
304
+ icon: y?.getIcon() ?? "ScriptInsert",
296
305
  ...c
297
306
  });
298
307
  })), Z = r(n((e, t) => {
299
308
  let { propsCommandButton: n, ...r } = e, i = C((e) => {
300
309
  let { propsCommandButton: t, propsCommandPopup: n } = e;
301
- return B(z, { children: V("div", {
310
+ return z(R, { children: B("div", {
302
311
  style: {
303
312
  display: "flex",
304
313
  flex: "1 1 100%"
305
314
  },
306
315
  children: [
307
- B("div", { children: B(N, {
316
+ z("div", { children: z(N, {
308
317
  style: {},
309
- children: B(O, {
318
+ children: z(O, {
310
319
  ...t,
311
320
  commandKey: "saveScripts"
312
321
  })
313
322
  }) }),
314
- B("div", { style: { flex: "1 1 100%" } }),
315
- B("div", { children: B(N, {
323
+ z("div", { style: { flex: "1 1 100%" } }),
324
+ z("div", { children: z(N, {
316
325
  style: {},
317
- children: B(pe, { ...t })
326
+ children: z(ve, { ...t })
318
327
  }) })
319
328
  ]
320
329
  }) });
321
330
  }, []);
322
- return B(A, {
331
+ return z(A, {
323
332
  ref: t,
324
333
  propsCommandButton: n,
325
334
  renderToolbarPalette: i,
@@ -327,33 +336,26 @@ var K = r(n((e, t) => {
327
336
  });
328
337
  }));
329
338
  Z.displayName = "ScriptEditorToolbar", G();
330
- var me = r(n((e, t) => {
339
+ var ye = r(n((e, t) => {
331
340
  let { scriptPath: n = q, onScriptSelect: r, disabled: i = !1, sx: o = S.EmptyCssProperties, className: s, buttonMinWidth: c = 210, buttonMinHeight: p = 80, gap: h = 12, ...g } = e, _ = D(), [v, y] = l([]), [x, C] = l(!0), [w, T] = l(null);
332
341
  if (a(() => {
333
- (async () => {
334
- let e = [{
335
- path: null,
336
- metadata: {
337
- title: _("templateSelect.blankTitle"),
338
- summary: _("templateSelect.blankSummary")
339
- },
340
- content: ""
341
- }];
342
- try {
343
- C(!0), T(null);
344
- let t = await de(n);
345
- for (let n = 0; n < t.length; n++) {
346
- let r = t[n];
347
- r && e.push(r);
348
- }
349
- } catch (e) {
350
- T(e instanceof Error ? e.message : _("templateSelect.loadFailed")), e instanceof U || console.error("Error loading scripts:", e);
351
- } finally {
352
- y(e), C(!1);
353
- }
354
- })();
355
- }, [n, _]), x) return B(u, {
356
- className: W(s, "script-select"),
342
+ let e = !1, t = {
343
+ path: null,
344
+ title: _("templateSelect.blankTitle"),
345
+ summary: _("templateSelect.blankSummary"),
346
+ content: ""
347
+ };
348
+ return C(!0), T(null), ge(n).then((n) => {
349
+ e || y([t, ...n]);
350
+ }, (n) => {
351
+ e || (y([t]), T(n instanceof Error ? n.message : _("templateSelect.loadFailed")));
352
+ }).finally(() => {
353
+ e || C(!1);
354
+ }), () => {
355
+ e = !0;
356
+ };
357
+ }, [n, _]), x) return z(u, {
358
+ className: U(s, "script-select"),
357
359
  ...g,
358
360
  sx: [{
359
361
  display: "flex",
@@ -364,11 +366,11 @@ var me = r(n((e, t) => {
364
366
  zIndex: 1e3,
365
367
  ...Array.isArray(o) ? {} : o
366
368
  }, ...Array.isArray(o) ? o : []],
367
- children: B(f, {})
369
+ children: z(f, {})
368
370
  });
369
371
  let E = null;
370
- w && (E = V(u, {
371
- className: W(s, "script-select", "error-results"),
372
+ w && (E = B(u, {
373
+ className: U(s, "script-select", "error-results"),
372
374
  ...g,
373
375
  sx: [{
374
376
  display: "flex",
@@ -383,41 +385,41 @@ var me = r(n((e, t) => {
383
385
  borderBottomLeftRadius: 1,
384
386
  borderBottomRightRadius: 1
385
387
  }, ...Array.isArray(o) ? o : [o]],
386
- children: [B(m, {
388
+ children: [z(m, {
387
389
  color: "error",
388
390
  variant: "h6",
389
391
  component: "div",
390
392
  gutterBottom: !0,
391
393
  children: _("templateSelect.errorTitle")
392
- }), B(m, {
394
+ }), z(m, {
393
395
  color: "error",
394
396
  component: "div",
395
397
  children: w
396
398
  })]
397
399
  }));
398
400
  let ee = (e) => {
399
- let t = e.metadata?.icon;
400
- return t === "macro" ? B(b, {
401
+ let t = e.icon;
402
+ return t === "macro" ? z(b, {
401
403
  iconKey: "ScriptMacro",
402
404
  size: "1em"
403
- }) : t === "formula" ? B(b, {
405
+ }) : t === "formula" ? z(b, {
404
406
  iconKey: "ScriptFormula",
405
407
  size: "1em"
406
- }) : t === "autostart" ? B(b, {
408
+ }) : t === "autostart" ? z(b, {
407
409
  iconKey: "ScriptAutoRun",
408
410
  size: "1em"
409
411
  }) : null;
410
412
  };
411
- return V(u, {
413
+ return B(u, {
412
414
  ref: t,
413
- className: W(s, "script-select"),
415
+ className: U(s, "script-select"),
414
416
  sx: {
415
417
  background: (e) => e.palette.background.paper,
416
418
  zIndex: 1e3,
417
419
  ...o
418
420
  },
419
421
  ...g,
420
- children: [V(u, {
422
+ children: [B(u, {
421
423
  className: "script-select-content",
422
424
  sx: {
423
425
  p: 3,
@@ -425,26 +427,26 @@ var me = r(n((e, t) => {
425
427
  flex: "1 1 auto"
426
428
  },
427
429
  children: [
428
- B(m, {
430
+ z(m, {
429
431
  variant: "h6",
430
432
  gutterBottom: !0,
431
433
  children: _("templateSelect.title")
432
434
  }),
433
- B(m, {
435
+ z(m, {
434
436
  variant: "body2",
435
437
  component: "div",
436
438
  gutterBottom: !0,
437
439
  sx: { color: "text.secondary" },
438
440
  children: _("templateSelect.intro")
439
441
  }),
440
- B(m, {
442
+ z(m, {
441
443
  variant: "body2",
442
444
  component: "div",
443
445
  gutterBottom: !0,
444
446
  sx: { color: "text.secondary" },
445
447
  children: _("templateSelect.intro2")
446
448
  }),
447
- B(u, {
449
+ z(u, {
448
450
  sx: {
449
451
  display: "grid",
450
452
  gridTemplateColumns: `repeat(auto-fill, minmax(${c}px, 1fr))`,
@@ -453,7 +455,7 @@ var me = r(n((e, t) => {
453
455
  paddingLeft: "0px",
454
456
  paddingRight: "0px"
455
457
  },
456
- children: v.map((e, t) => V(d, {
458
+ children: v.map((e, t) => B(d, {
457
459
  variant: "outlined",
458
460
  disabled: i,
459
461
  sx: {
@@ -474,7 +476,7 @@ var me = r(n((e, t) => {
474
476
  ...t === 1 && { gridColumn: "1" }
475
477
  },
476
478
  onClick: () => r?.(e),
477
- children: [V(u, {
479
+ children: [B(u, {
478
480
  sx: {
479
481
  display: "flex",
480
482
  flexDirection: "row",
@@ -483,12 +485,12 @@ var me = r(n((e, t) => {
483
485
  width: "100%",
484
486
  marginBottom: .5
485
487
  },
486
- children: [B(m, {
488
+ children: [z(m, {
487
489
  variant: "subtitle2",
488
490
  component: "div",
489
- children: e.metadata?.title || e.path?.split("/").pop()?.replace(/\.\w+$/, "") || _("templateSelect.untitled")
491
+ children: e.title || _("templateSelect.untitled")
490
492
  }), ee(e)]
491
- }), e.metadata?.summary && B(m, {
493
+ }), e.summary && z(m, {
492
494
  variant: "body2",
493
495
  component: "div",
494
496
  sx: {
@@ -499,7 +501,7 @@ var me = r(n((e, t) => {
499
501
  textOverflow: "ellipsis",
500
502
  alignItems: "flex-start"
501
503
  },
502
- children: e.metadata.summary
504
+ children: e.summary
503
505
  })]
504
506
  }, `${e.path}-${t}`))
505
507
  })
@@ -507,7 +509,7 @@ var me = r(n((e, t) => {
507
509
  }), E]
508
510
  });
509
511
  }));
510
- me.displayName = "TemplateSelectPanel";
512
+ ye.displayName = "TemplateSelectPanel";
511
513
  var Q = r(n((e, t) => {
512
514
  let { className: n, sx: r, propsScriptEditor: s, readOnly: d = !1, frame: f, autoFocusSel: g, autoFocus: _ = !0, scripts: v, ...y } = e, b = h(), [x, S] = l(!1), w = c(!1), [T, D] = l({
513
515
  message: "Loading",
@@ -530,7 +532,7 @@ var Q = r(n((e, t) => {
530
532
  ...t,
531
533
  ...e
532
534
  }));
533
- }, []), j = c(null), [M, N] = l(null), P = c(null), F = C((e) => {
535
+ }, []), j = c(null), [M, N] = l(null), P = c(null), te = C((e) => {
534
536
  if (M) return M.focus(e), !0;
535
537
  if (g) {
536
538
  let t = j.current?.querySelectorAll?.(g);
@@ -541,7 +543,7 @@ var Q = r(n((e, t) => {
541
543
  M,
542
544
  g,
543
545
  _
544
- ]), I = o(() => B(ee, {
546
+ ]), F = o(() => z(ee, {
545
547
  transitionDelay: "160ms",
546
548
  style: {
547
549
  position: "absolute",
@@ -549,7 +551,7 @@ var Q = r(n((e, t) => {
549
551
  height: "100%"
550
552
  },
551
553
  transparentBackground: !1
552
- }), []), L = o(() => B(p, {
554
+ }), []), I = o(() => z(p, {
553
555
  elevation: 1,
554
556
  tabIndex: 0,
555
557
  sx: {
@@ -562,9 +564,9 @@ var Q = r(n((e, t) => {
562
564
  marginTop: (e) => e.spacing(1),
563
565
  marginBottom: (e) => e.spacing(1)
564
566
  },
565
- children: B(Z, {})
566
- }), [b]), R = o(() => B(u, {
567
- className: W("script-status-panel", "status-panel"),
567
+ children: z(Z, {})
568
+ }), [b]), L = o(() => z(u, {
569
+ className: U("script-status-panel", "status-panel"),
568
570
  sx: {
569
571
  display: "flex",
570
572
  alignItems: "stretch",
@@ -578,7 +580,7 @@ var Q = r(n((e, t) => {
578
580
  margin: 0,
579
581
  borderTop: `solid 1px ${b.palette.divider}`
580
582
  },
581
- children: V("div", {
583
+ children: B("div", {
582
584
  style: {
583
585
  flex: "1 1 100%",
584
586
  display: "flex",
@@ -587,7 +589,7 @@ var Q = r(n((e, t) => {
587
589
  justifyContent: "center"
588
590
  },
589
591
  children: [
590
- B(m, {
592
+ z(m, {
591
593
  component: "div",
592
594
  sx: {
593
595
  userSelect: "none",
@@ -600,7 +602,7 @@ var Q = r(n((e, t) => {
600
602
  variant: "caption",
601
603
  children: T.message
602
604
  }),
603
- B(m, {
605
+ z(m, {
604
606
  component: "div",
605
607
  sx: {
606
608
  userSelect: "none",
@@ -613,7 +615,7 @@ var Q = r(n((e, t) => {
613
615
  variant: "caption",
614
616
  children: T.dirty ? "Unsaved" : ""
615
617
  }),
616
- B(m, {
618
+ z(m, {
617
619
  component: "div",
618
620
  sx: {
619
621
  userSelect: "none",
@@ -632,8 +634,8 @@ var Q = r(n((e, t) => {
632
634
  })
633
635
  ]
634
636
  })
635
- }), [T]), z = o(() => V(u, {
636
- className: W("script-editor-content"),
637
+ }), [T]), R = o(() => B(u, {
638
+ className: U("script-editor-content"),
637
639
  sx: {
638
640
  display: "flex",
639
641
  flex: "1 1 100%",
@@ -642,8 +644,8 @@ var Q = r(n((e, t) => {
642
644
  boxSizing: "border-box"
643
645
  },
644
646
  children: [
645
- L,
646
- B(u, {
647
+ I,
648
+ z(u, {
647
649
  sx: {
648
650
  display: "flex",
649
651
  flex: "1 1 100%",
@@ -652,9 +654,9 @@ var Q = r(n((e, t) => {
652
654
  position: "relative",
653
655
  boxSizing: "border-box"
654
656
  },
655
- children: B(ne, {
657
+ children: z(ie, {
656
658
  ref: j,
657
- loadingPanel: I,
659
+ loadingPanel: F,
658
660
  readOnly: d,
659
661
  frame: f,
660
662
  scripts: v,
@@ -664,23 +666,23 @@ var Q = r(n((e, t) => {
664
666
  ...s
665
667
  })
666
668
  }),
667
- R
669
+ L
668
670
  ]
669
671
  }), [
670
672
  b,
673
+ I,
671
674
  L,
672
- R,
673
675
  x,
674
- I,
676
+ F,
675
677
  d,
676
678
  s,
677
679
  _,
678
680
  g,
679
681
  f,
680
682
  A
681
- ]), te = o(() => {
683
+ ]), V = o(() => {
682
684
  let e;
683
- return O === null ? I : (O.source === null && (e = B(me, {
685
+ return O === null ? F : (O.source === null && (e = z(ye, {
684
686
  sx: {
685
687
  display: "flex",
686
688
  flex: "1 1 100%",
@@ -695,9 +697,9 @@ var Q = r(n((e, t) => {
695
697
  onScriptSelect: (e) => {
696
698
  j.current?.insertSnippet(e.content), k({ source: e.content ?? "" }), requestAnimationFrame(() => j.current?.focus());
697
699
  }
698
- })), B(u, {
700
+ })), z(u, {
699
701
  tabIndex: 0,
700
- className: W("script-workspace", n),
702
+ className: U("script-workspace", n),
701
703
  sx: {
702
704
  display: "flex",
703
705
  flex: "1 1 100%",
@@ -711,13 +713,13 @@ var Q = r(n((e, t) => {
711
713
  onPointerDown: (e) => {
712
714
  e.isDefaultPrevented() || j.current?.focus();
713
715
  },
714
- children: V(u, {
716
+ children: B(u, {
715
717
  sx: {
716
718
  flex: "1 1 100%",
717
719
  position: "relative",
718
720
  display: "flex"
719
721
  },
720
- children: [B(u, {
722
+ children: [z(u, {
721
723
  sx: {
722
724
  display: "flex",
723
725
  flex: "1 1 100%",
@@ -725,24 +727,24 @@ var Q = r(n((e, t) => {
725
727
  minHeight: 0,
726
728
  visibility: e ? "hidden" : "visible"
727
729
  },
728
- children: z
730
+ children: R
729
731
  }), e]
730
732
  })
731
733
  }));
732
734
  }, [
733
- L,
734
- z,
735
+ I,
736
+ R,
735
737
  n,
736
738
  O,
737
- I,
739
+ F,
738
740
  d
739
741
  ]), H = E(t, () => ({
740
742
  isScriptWorkspaceElement: () => !0,
741
743
  focus: (e) => {
742
- F(e);
744
+ te(e);
743
745
  }
744
746
  }), []);
745
- return B(u, {
747
+ return z(u, {
746
748
  sx: {
747
749
  display: "flex",
748
750
  flexDirection: "row",
@@ -758,40 +760,40 @@ var Q = r(n((e, t) => {
758
760
  onBlur: (e) => {
759
761
  H?.current?.contains(e.relatedTarget) || H?.current === e.relatedTarget || (P.current = null, w.current = !1, S(!1)), y?.onBlur?.(e);
760
762
  },
761
- children: te
763
+ children: V
762
764
  });
763
765
  }));
764
766
  Q.displayName = "ScriptWorkspace";
765
- var { FocusActivation: he, CommandScopeProvider: ge, CommandAnchorProvider: _e, useCommandScope: ve } = g, ye = { scopeName: "scriptEditor" }, be = ({ children: e }) => {
766
- let t = ve(), n = c(null);
767
- return t ? B(ge, {
768
- spec: ye,
767
+ var { FocusActivation: be, CommandScopeProvider: xe, CommandAnchorProvider: Se, useCommandScope: Ce } = g, we = { scopeName: "scriptEditor" }, Te = ({ children: e }) => {
768
+ let t = Ce(), n = c(null);
769
+ return t ? z(xe, {
770
+ spec: we,
769
771
  elementRef: n,
770
772
  region: !0,
771
- children: B(xe, {
773
+ children: z(Ee, {
772
774
  paneRef: n,
773
775
  children: e
774
776
  })
775
777
  }) : e;
776
- }, xe = ({ paneRef: e, children: t }) => {
777
- let n = ve(), r = o(() => n ? new he(n.getRoot(), n) : null, [n]);
778
- return r ? V(_e, {
778
+ }, Ee = ({ paneRef: e, children: t }) => {
779
+ let n = Ce(), r = o(() => n ? new be(n.getRoot(), n) : null, [n]);
780
+ return r ? B(Se, {
779
781
  tracker: r,
780
782
  keyBindings: !1,
781
783
  debounce: 100,
782
784
  elementRef: e,
783
- children: [B(I, {}), B("div", {
785
+ children: [z(F, {}), z("div", {
784
786
  className: "script-editor-pane",
785
787
  style: { display: "contents" },
786
788
  ref: e,
787
789
  children: t
788
790
  })]
789
791
  }) : t;
790
- }, Se = (e) => {
791
- let { model: t, entryKey: n, frame: r, ref: i, ...a } = e, o = R() ?? t;
792
- L(o, ["onProtectionChange"]);
792
+ }, De = (e) => {
793
+ let { model: t, entryKey: n, frame: r, ref: i, ...a } = e, o = L() ?? t;
794
+ I(o, ["onProtectionChange"]);
793
795
  let s = o?.getScripts().isReadOnly() ?? !1;
794
- return B(be, { children: B(Q, {
796
+ return z(Te, { children: z(Q, {
795
797
  ref: i,
796
798
  readOnly: s,
797
799
  frame: r,
@@ -799,7 +801,7 @@ var { FocusActivation: he, CommandScopeProvider: ge, CommandAnchorProvider: _e,
799
801
  ...a
800
802
  }) });
801
803
  }, $ = r((e) => {
802
- let { alwaysShow: t = !1, ...n } = e, [r, i] = s((e) => e + 1, 0), [o] = T(["showScriptEditor"], { onChange: () => i() }), c = R(), [u, d] = l(t);
804
+ let { alwaysShow: t = !1, ...n } = e, [r, i] = s((e) => e + 1, 0), [o] = T(["showScriptEditor"], { onChange: () => i() }), c = L(), [u, d] = l(t);
803
805
  return a(() => {
804
806
  if (t) return void d(!0);
805
807
  let e = c?.getScripts();
@@ -820,11 +822,11 @@ var { FocusActivation: he, CommandScopeProvider: ge, CommandAnchorProvider: _e,
820
822
  c,
821
823
  o,
822
824
  r
823
- ]), u ? V(z, { children: [B(j, {}), B(K, { ...n })] }) : null;
825
+ ]), u ? B(R, { children: [z(j, {}), z(ue, { ...n })] }) : null;
824
826
  });
825
827
  $.displayName = "RunScriptContribution", G();
826
- var Ce = r(n((e, n) => {
827
- let { ...r } = e, i = R(), o = D(), [s, c] = l([]);
828
+ var Oe = r(n((e, n) => {
829
+ let { ...r } = e, i = L(), o = D(), [s, c] = l([]);
828
830
  a(() => {
829
831
  let e = i?.getScripts();
830
832
  if (!e) return;
@@ -846,16 +848,16 @@ var Ce = r(n((e, n) => {
846
848
  }, f = [], p = s ? s.length : 0;
847
849
  for (let e = 0; e < p; e++) {
848
850
  let t = s[e];
849
- f.push(B(O, {
851
+ f.push(z(O, {
850
852
  ...d,
851
853
  commandKey: "insertFunction",
852
854
  commandState: t,
853
855
  propsTooltip: { description: o("insertFunction.insertNamed", { name: t.getName() ?? o("insertFunction.fallbackLabel") }) },
854
- icon: B(b, { iconKey: "FormulaCustom" }),
856
+ icon: z(b, { iconKey: "FormulaCustom" }),
855
857
  label: t.getName() ?? o("insertFunction.fallbackLabel")
856
858
  }, `function-${t.getName()}-${e}`));
857
859
  }
858
- let m = V(u, {
860
+ let m = B(u, {
859
861
  ref: n,
860
862
  sx: {
861
863
  display: "flex",
@@ -863,13 +865,13 @@ var Ce = r(n((e, n) => {
863
865
  flex: "1 1 100%",
864
866
  overflow: "hidden"
865
867
  },
866
- children: [f.length > 0 ? V(z, { children: [B(u, {
868
+ children: [f.length > 0 ? B(R, { children: [z(u, {
867
869
  sx: {
868
870
  overflow: "auto",
869
871
  flex: "1 1 100%"
870
872
  },
871
873
  children: f
872
- }), B(j, { orientation: "horizontal" })] }) : null, t(O, {
874
+ }), z(j, { orientation: "horizontal" })] }) : null, t(O, {
873
875
  ...d,
874
876
  key: "show-editor",
875
877
  commandKey: "showScriptEditor"
@@ -880,10 +882,10 @@ var Ce = r(n((e, n) => {
880
882
  children: m
881
883
  });
882
884
  }));
883
- Ce.displayName = "InsertFunctionPopupPanel";
884
- var we = r(n((e, t) => {
885
+ Oe.displayName = "InsertFunctionPopupPanel";
886
+ var ke = r(n((e, t) => {
885
887
  let { disabled: n, groupKey: r, ...a } = e, o = w("customFunctionOptions"), s = i((e) => {
886
- let t = B(Ce, {
888
+ let t = z(Oe, {
887
889
  disabled: n,
888
890
  groupKey: r,
889
891
  ...e
@@ -893,7 +895,7 @@ var we = r(n((e, t) => {
893
895
  children: t
894
896
  });
895
897
  }, [n, r]);
896
- return B(k, {
898
+ return z(k, {
897
899
  ref: t,
898
900
  disabled: n,
899
901
  createPopupPanel: s,
@@ -903,13 +905,13 @@ var we = r(n((e, t) => {
903
905
  ...a
904
906
  });
905
907
  }));
906
- we.displayName = "InsertFunctionContribution";
907
- var Te = () => {
908
- re(), y.register("plugin-scripts", { icons: {} }), F.registerTaskPane({
908
+ ke.displayName = "InsertFunctionContribution";
909
+ var Ae = () => {
910
+ ae(), y.register("plugin-scripts", { icons: {} }), te.registerTaskPane({
909
911
  key: "scriptEditor",
910
912
  getTitle: () => "Script (Typescript)",
911
913
  getIcon: () => "ScriptRun",
912
- component: Se,
914
+ component: De,
913
915
  keepMounted: !0
914
916
  }, !0), v.register({ key: "scriptsOptions" }, !0), v.register({ key: "customFunctionOptions" }, !0), v.register({
915
917
  key: "scripting.runScript.home",
@@ -929,7 +931,7 @@ var Te = () => {
929
931
  anchor: "formulaCategory.web",
930
932
  order: 1
931
933
  } },
932
- render: (t) => e.createElement(we, { ...t })
934
+ render: (t) => e.createElement(ke, { ...t })
933
935
  }, !0);
934
936
  };
935
- export { pe as InsertScriptCommandButton, K as RunScriptCommandButton, Z as ScriptEditorToolbar, Se as ScriptTaskPane, Q as ScriptWorkspace, Te as ScriptingPlugin };
937
+ export { ve as InsertScriptCommandButton, ue as RunScriptCommandButton, Z as ScriptEditorToolbar, De as ScriptTaskPane, Q as ScriptWorkspace, Ae as ScriptingPlugin };