@sheetxl/scripting-react 0.8.0-beta.10 → 0.8.0-beta.12

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,11 +1,11 @@
1
1
  (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`._script-editor_1kuph_5{& .monaco-editor{position:absolute;& .margin-icon{background-position:50%;background-repeat:no-repeat;background-size:contain;width:16px;height:16px;display:block}& .formula{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 12.106007,8.1692949 c 0.124174,-0.1578352 0.181773,-0.3565642 0.283755,-0.5271169 0.10273,-0.1715492 0.04413,-0.2027176 -0.129161,-0.2014713 -0.685452,0.00576 -1.371152,-0.00277 -2.056604,0.00501 C 10.021228,7.4479573 9.9586414,7.407817 9.9935503,7.2080883 10.145401,6.3413623 10.291269,5.4736396 10.51219,4.6213758 10.642847,4.1167002 10.782479,3.6117747 11.061498,3.1622046 11.339518,2.7138809 11.726751,2.5974365 12.2035,2.829328 c 0.398455,0.1934923 0.722604,0.4827333 0.990152,0.8340617 0.116944,0.1535968 0.27079,0.2740306 0.449073,0.1715499 0.343348,-0.1974819 0.644807,-0.4383502 0.819599,-0.826332 0.100985,-0.2244112 0.157836,-0.476001 0.04039,-0.7058977 C 14.339646,1.9840253 14.038187,1.7618584 13.707056,1.6394296 13.156999,1.4362128 12.562559,1.4840872 12.017239,1.6758341 11.38789,1.8970037 10.783727,2.2625445 10.259602,2.6724688 10.066109,2.8238217 9.8783519,2.9839017 9.7013165,3.1547035 9.0502751,3.7823067 8.5657962,4.529097 8.2246919,5.3651534 7.9823276,5.9595939 7.7888351,6.5660026 7.6913412,7.2015842 7.673637,7.318528 7.6357391,7.423253 7.5065759,7.4432009 7.3472438,7.4678879 7.1592376,7.4436995 6.9974121,7.4441728 6.6351128,7.4451447 6.2598478,7.3676233 5.9915515,7.6815496 5.8721151,7.8211835 5.7461952,7.9840062 5.6439635,8.1371045 c -0.1009847,0.1518511 -0.093255,0.3002122 0.085027,0.367535 0.1957362,0.073561 0.4528118,0.026182 0.6530361,0.0197 0.2645558,-0.00847 0.5291116,0.00501 0.7936674,-7.476e-4 0.1820229,-0.00374 0.2413669,0.030421 0.2064588,0.2358807 C 7.3487406,8.9587006 7.3095941,9.1492003 7.2804197,9.3464333 7.1804317,10.024404 7.0667304,10.700629 6.9525298,11.376606 6.7936963,12.314146 6.6371075,13.252434 6.4655575,14.188478 6.3017374,15.082631 6.1855427,15.985013 5.983074,16.873433 5.8249883,17.568607 5.7240037,18.277248 5.5556954,18.969682 5.4145655,19.550158 5.293882,20.143601 4.9722259,20.665731 4.7380909,21.045734 4.3959882,21.206312 3.9663652,21.104829 3.5778849,21.012322 3.2115961,20.866205 2.8951763,20.608631 2.6862246,20.438328 2.4473513,20.31141 2.1920214,20.458026 1.9519014,20.595915 1.7791048,20.851743 1.646453,21.088123 1.2205704,21.847879 1.915497,22.569984 2.6655289,22.684434 3.1692071,22.760986 3.666153,22.580208 4.1087416,22.356046 4.6996913,22.056582 5.2103511,21.635437 5.6387269,21.13874 5.9898058,20.731558 6.3575906,20.343327 6.6500737,19.890016 6.8450616,19.58756 7.0238427,19.274881 7.1866655,18.954471 7.7639005,17.817206 8.1227091,16.589926 8.4189318,15.354418 8.5613081,14.760227 8.716401,14.169777 8.8478064,13.572843 9.0268365,12.760724 9.1741996,11.934891 9.3083481,11.114294 9.3749255,10.707112 9.4310263,10.300679 9.5160532,9.8967389 9.5861222,9.5636133 9.6442168,9.2185186 9.6890985,8.8814035 9.7414633,8.4891827 9.990308,8.5136187 10.329668,8.4762164 c 0.286249,-0.03167 0.574492,-0.046376 0.861739,-0.067571 0.230395,-0.016703 0.494951,0.00396 0.711881,-0.088019 0.07754,-0.032911 0.147613,-0.080788 0.202719,-0.1513533 z\\"/><path d=\\"M 22.473802,7.8481382 C 22.426924,7.6912996 22.341898,7.5501696 22.231437,7.4294861 22.130452,7.3192756 21.987827,7.1749046 21.851933,7.1098255 21.411589,6.8988785 20.817398,7.0838898 20.436149,7.3422154 20.23343,7.479854 20.052405,7.6519026 19.871131,7.8167201 19.691352,7.9802913 19.517061,8.1488492 19.35723,8.3321177 19.025101,8.7128687 18.724639,9.1210479 18.436396,9.5354601 18.296263,9.7374301 17.901549,10.472252 17.781115,10.399942 17.654198,10.323892 17.495365,9.5905657 17.435023,9.3843566 17.351243,9.0978583 17.29539,8.8016361 17.161741,8.5323425 16.97922,8.1643081 16.865268,7.7623629 16.608941,7.4307332 16.325934,7.0639457 16.001036,6.9584722 15.558946,7.092371 c -0.43436,0.1314054 -0.78469,0.4049374 -1.128539,0.6819608 -0.503927,0.4056851 -0.879442,0.926319 -1.256951,1.4439609 -0.28226,0.387483 -0.284753,0.3857373 0.04488,0.7380631 0.206458,0.2211702 0.202718,0.2184272 0.389229,-0.00847 0.2663,-0.3251469 0.524872,-0.6595196 0.882433,-0.8934057 0.261315,-0.1713009 0.417904,-0.1368908 0.57948,0.1326518 0.07929,0.1326517 0.146866,0.2752777 0.200225,0.4208957 0.335619,0.9141014 0.590201,1.8541344 0.89191,2.7784594 0.03815,0.117691 -0.01122,0.193991 -0.06707,0.278519 -0.356565,0.538837 -0.719363,1.074182 -1.123054,1.578607 -0.320409,0.401198 -0.643312,0.803891 -1.073932,1.097621 -0.187757,0.128912 -0.40768,0.217679 -0.635831,0.156839 -0.233887,-0.06283 -0.37377,-0.27478 -0.587459,-0.373521 -0.006,-0.003 -0.01272,-0.0052 -0.01895,-0.0079 -0.09974,-0.04064 -0.249845,-0.0389 -0.353074,-0.01571 -0.454059,0.102482 -0.697669,0.614139 -0.790177,1.023813 -0.08379,0.371776 -0.0013,0.778209 0.261315,1.062463 0.228899,0.24785 0.572248,0.351327 0.901634,0.356315 0.189003,0.0028 0.39995,-0.04663 0.57549,-0.11445 0.670241,-0.262062 1.181649,-0.887172 1.605038,-1.441717 0.285501,-0.374517 0.550555,-0.763994 0.829573,-1.143499 0.230645,-0.313677 0.68595,-1.247726 0.81586,-1.250718 0.07854,-0.0017 0.09924,0.185762 0.114199,0.241117 0.03341,0.123675 0.06658,0.247351 0.102232,0.370279 0.167561,0.578481 0.343848,1.156464 0.525122,1.730458 0.120934,0.384242 0.315921,0.782697 0.560779,1.103356 0.07431,0.09749 0.167311,0.190749 0.26306,0.266799 0.371276,0.296972 0.838799,0.27453 1.266177,0.123177 0.191498,-0.06757 0.370029,-0.163071 0.539335,-0.275527 0.781948,-0.519886 1.340732,-1.244235 1.868598,-2.002495 0.124423,-0.178781 0.107467,-0.278769 -0.03441,-0.428127 -0.367286,-0.386237 -0.357062,-0.389727 -0.705149,0.01995 -0.261066,0.306446 -0.527117,0.612643 -0.879442,0.818851 -0.245855,0.144621 -0.413416,0.103229 -0.592696,-0.118439 -0.14861,-0.183518 -0.246353,-0.396709 -0.33138,-0.614886 -0.349831,-0.901136 -0.588954,-1.838675 -0.885177,-2.757515 -0.21743,-0.674231 -0.223414,-0.680464 0.20945,-1.248723 0.447575,-0.587708 0.875703,-1.1968602 1.462163,-1.6613914 0.431119,-0.3416031 0.73183,-0.3226534 1.129037,0.059094 0.0788,0.075801 0.207456,0.1388856 0.316919,0.1476127 0.369781,0.029674 0.691187,-0.3024566 0.880939,-0.5792304 0.188006,-0.2727835 0.259319,-0.6183768 0.163072,-0.9392845 z\\"/></svg>")}& .macro{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 7.3808594,2.8925781 c 0.6501558,0 1.3048608,0.1705676 1.8886719,0.5078125 l 9.2343747,5.3242188 c 1.167878,0.6758404 1.882813,1.9216266 1.882813,3.2675786 0,1.306438 -0.674828,2.517089 -1.783203,3.205078 L 9.2617188,20.595703 C 8.1035923,21.277644 6.6635531,21.275631 5.4960937,20.589844 4.3295773,19.917617 3.6132812,18.67473 3.6132813,17.330078 V 6.6660156 c 0,-1.3461361 0.7160606,-2.5932648 1.8828124,-3.265625 C 6.0817308,3.0628871 6.7318751,2.8925781 7.3808594,2.8925781 Z M 7.375,5.1835937 C 7.1238145,5.188954 6.883074,5.2521559 6.6601562,5.3691406 l -0.00781,0.00586 -0.00781,0.00391 C 6.1849913,5.6446615 5.9023438,6.1366335 5.9023437,6.6660156 V 17.330078 c 0,0.524949 0.2791508,1.016586 0.7363282,1.275391 0.4554716,0.266714 1.013907,0.272881 1.4785156,0.0098 l 9.2441405,-5.34375 c 0.450764,-0.263898 0.736328,-0.74603 0.736328,-1.27539 0,-0.52882 -0.290494,-1.018444 -0.742187,-1.277344 L 8.1171875,5.3789062 C 7.8951499,5.2512094 7.6461047,5.183439 7.375,5.1835937 Z\\"/></svg>")}& .autorun{cursor:pointer;background-image:url("data:image/svg+xml;utf8,<svg xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"0 0 24 24\\" fill=\\"grey\\"><path d=\\"m 11.999964,1.7500508 c -0.462401,0 -0.923676,0.3281109 -0.924272,0.9260918 V 13.159721 c -0.0012,1.23176 1.847315,1.231936 1.848545,0 V 2.6761426 c 5.97e-4,-0.598201 -0.461872,-0.9260918 -0.924273,-0.9260918 z m 5.998674,2.6454569 c -0.728133,0.068914 -1.207022,1.0512547 -0.5149,1.63931 1.880223,1.6037705 2.962848,3.9512403 2.962038,6.4226023 -4.23e-4,4.655627 -3.790565,8.443993 -8.445812,8.443993 -4.6552096,0 -8.443993,-3.789762 -8.443993,-8.445813 C 3.5560359,10.008191 4.6172167,7.6804932 6.4634264,6.0784841 7.4240529,5.2735715 6.1821863,3.8462722 5.2535029,4.6829783 -1.9571321,10.940557 2.4945266,22.78839 12.039992,22.749957 21.585452,22.711525 25.944958,10.82919 18.684564,4.6302147 18.515847,4.4852865 18.331563,4.4098479 18.146012,4.3955077 c -0.05049,-0.0039 -0.09883,-0.00459 -0.147374,0 z\\"/></svg>")}}}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
2
2
  /**
3
- * @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.10
3
+ * @license @sheetxl/scripting-react - Scripting React - Monaco based script editor and scripting UI for SheetXL. - v0.8.0-beta.12
4
4
  *
5
5
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
6
6
  * License: The license can be found at https://www.sheetxl.com/license.
7
7
  */
8
- import { n as e } from "./D2pLdOQduUDnV2hi.mjs";
8
+ import { n as e } from "./mch8JXdWV66us17h.mjs";
9
9
  import { Suspense as t, forwardRef as n, memo as r, useEffect as i, useMemo as a, useRef as o, useState as s, version as c } from "react";
10
10
  import { createRoot as l } from "react-dom/client";
11
11
  import { CommonUtils as u, TimerUtils as d, defineLazyModule as f, messageKey as p } from "@sheetxl/utils";
@@ -14,31 +14,31 @@ import { IScript as h } from "@sheetxl/sdk";
14
14
  import { Command as g, lazyComponent as _, useCallbackRef as v, useCommands as ee, useImperativeElement as te, useLazyRetry as y, useNotifier as ne, useTranslator as re } from "@sheetxl/utils-react";
15
15
  import { jsx as b, jsxs as ie } from "react/jsx-runtime";
16
16
  import { DefaultTaskPaneRegistry as x, useModelListener as ae, useTaskPaneArea as S, useWorkbook as oe } from "@sheetxl/react";
17
- function C(e) {
17
+ function se(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 = C(e[t])) && (r && (r += " "), r += n);
23
+ for (t = 0; t < i; t++) e[t] && (n = se(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 se() {
29
- for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = C(e)) && (r && (r += " "), r += t);
28
+ function ce() {
29
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = se(e)) && (r && (r += " "), r += t);
30
30
  return r;
31
31
  }
32
- function w(e, t) {
32
+ function C(e, t) {
33
33
  if (typeof e == "function") return e(t);
34
34
  e && (e.current = t);
35
35
  }
36
- var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
36
+ var le = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
37
37
  return (t) => {
38
38
  let n = [];
39
39
  for (let r of e) {
40
- let e = w(r, t), i = typeof e == "function";
41
- n.push(i ? e : () => w(r, null));
40
+ let e = C(r, t), i = typeof e == "function";
41
+ n.push(i ? e : () => C(r, null));
42
42
  }
43
43
  return () => {
44
44
  for (let e of n) e();
@@ -46,9 +46,9 @@ var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
46
46
  };
47
47
  } : function(e) {
48
48
  return (t) => {
49
- for (let n of e) w(n, t);
49
+ for (let n of e) C(n, t);
50
50
  };
51
- }, T = {
51
+ }, w = {
52
52
  defaultToken: "invalid",
53
53
  tokenPostfix: ".ts",
54
54
  keywords: /* @__PURE__ */ "abstract.any.as.asserts.bigint.boolean.break.case.catch.class.continue.const.constructor.debugger.declare.default.delete.do.else.enum.export.extends.false.finally.for.from.function.get.if.implements.import.in.infer.instanceof.interface.is.keyof.let.module.namespace.never.new.null.number.object.out.package.private.protected.public.override.readonly.require.global.return.satisfies.set.static.string.super.switch.symbol.this.throw.true.try.type.typeof.undefined.unique.unknown.var.void.while.with.yield.async.await.of".split("."),
@@ -265,32 +265,32 @@ var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
265
265
  { include: "common" }
266
266
  ]
267
267
  }
268
- }, E = /(?:\s|\/\/[^\n]*|\/\*[\s\S]*?\*\/)*/y, D = /(import\b\s*(?:type\s+(?!from\b))?)(?:([^'";]*?)\s*\bfrom\s*)?(['"])([^'"\n]+)\3[ \t]*;?/y, O = (e) => e.replace(/\s+/g, " ").trim(), k = (e) => {
268
+ }, T = /(?:\s|\/\/[^\n]*|\/\*[\s\S]*?\*\/)*/y, E = /(import\b\s*(?:type\s+(?!from\b))?)(?:([^'";]*?)\s*\bfrom\s*)?(['"])([^'"\n]+)\3[ \t]*;?/y, D = (e) => e.replace(/\s+/g, " ").trim(), ue = (e) => {
269
269
  let t = [], n = 0;
270
270
  for (;;) {
271
- E.lastIndex = n, E.exec(e), D.lastIndex = E.lastIndex;
272
- let r = D.exec(e);
271
+ T.lastIndex = n, T.exec(e), E.lastIndex = T.lastIndex;
272
+ let r = E.exec(e);
273
273
  if (!r) return t;
274
274
  let i = r[2] ?? "", a = r.index + r[1].length, o = i.indexOf("{"), s = i.lastIndexOf("}"), c = o >= 0 && s > o, l = c ? i.slice(0, o) + i.slice(s + 1) : i;
275
275
  t.push({
276
276
  start: r.index,
277
- end: D.lastIndex,
277
+ end: E.lastIndex,
278
278
  text: r[0],
279
279
  module: r[4],
280
280
  quote: r[3],
281
281
  typeOnly: /\btype\s+$/.test(r[1]),
282
- binding: O(l).replace(/\s*,$/, ""),
283
- names: c ? i.slice(o + 1, s).split(",").map(O).filter(Boolean) : null,
282
+ binding: D(l).replace(/\s*,$/, ""),
283
+ names: c ? i.slice(o + 1, s).split(",").map(D).filter(Boolean) : null,
284
284
  namesStart: a + o + 1,
285
285
  namesEnd: a + s
286
- }), n = D.lastIndex;
286
+ }), n = E.lastIndex;
287
287
  }
288
- }, A = (e) => [
288
+ }, O = (e) => [
289
289
  e.typeOnly,
290
290
  e.binding,
291
291
  e.names?.join(","),
292
292
  e.module
293
- ].join("|"), le = (e) => `${e.typeOnly ? "type " : ""}${e.module}`, ue = (e, t, n) => {
293
+ ].join("|"), k = (e) => `${e.typeOnly ? "type " : ""}${e.module}`, de = (e, t, n) => {
294
294
  let r = e.slice(t.namesStart, t.namesEnd), i = r.trimEnd();
295
295
  if (i.trim() === "") return {
296
296
  offset: t.namesStart,
@@ -306,7 +306,7 @@ var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
306
306
  offset: a,
307
307
  text: `${o ? "" : ","}\n${c}${n.join(`,\n${c}`)}${o ? "," : ""}`
308
308
  };
309
- }, de = {
309
+ }, fe = {
310
310
  lightbulb: { enabled: !1 },
311
311
  tabSize: 2,
312
312
  acceptSuggestionOnCommitCharacter: !0,
@@ -369,28 +369,34 @@ var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
369
369
  wordWrapColumn: 80,
370
370
  wordWrapMinified: !0,
371
371
  wrappingIndent: "none"
372
- }, fe = "_script-editor_1kuph_5", pe = (e) => {
372
+ }, pe = "_script-editor_1kuph_5", me = (e) => {
373
373
  let t = e?.getModules();
374
374
  return t && t.getByName(h.DEFAULT_MODULE), h.DEFAULT_MODULE;
375
- }, j = (e) => e?.getModules()?.getByName(pe(e)) ?? null, M, me = f("scripting-react:monaco", async () => (function() {
376
- if (typeof window > "u") return;
377
- let e = window;
378
- if (e.__sxlDefineShim) return;
379
- e.__sxlDefineShim = !0;
380
- let t = [], n = null, r = (...e) => {
381
- typeof n == "function" ? n(...e) : t.push(e);
382
- };
383
- Object.defineProperty(e, "define", {
384
- configurable: !1,
385
- enumerable: !0,
386
- get: () => typeof n == "function" ? n : r,
387
- set(e) {
388
- if (typeof e == "function") for (n = e; t.length;) try {
389
- e(...t.shift());
390
- } catch {}
391
- }
392
- });
393
- }(), import("./C4dnHSqs5tpSawv4.mjs")), { prefetch: !1 }), N = ({ error: e }) => {
375
+ }, A = (e) => e?.getModules()?.getByName(me(e)) ?? null, j, he = f("scripting-react:monaco", async () => {
376
+ (function() {
377
+ if (typeof window > "u") return;
378
+ let e = window;
379
+ if (e.__sxlDefineShim) return;
380
+ e.__sxlDefineShim = !0;
381
+ let t = [], n = null, r = (...e) => {
382
+ typeof n == "function" ? n(...e) : t.push(e);
383
+ };
384
+ Object.defineProperty(e, "define", {
385
+ configurable: !1,
386
+ enumerable: !0,
387
+ get: () => typeof n == "function" ? n : r,
388
+ set(e) {
389
+ if (typeof e == "function") for (n = e; t.length;) try {
390
+ e(...t.shift());
391
+ } catch {}
392
+ }
393
+ });
394
+ })();
395
+ let [e] = await Promise.all([import("./K1R6A31jQIuhvsdS.mjs"), _e().catch((e) => {
396
+ console.warn("cant load types", e);
397
+ })]);
398
+ return e;
399
+ }, { prefetch: !1 }), M = ({ error: e }) => {
394
400
  let t = y(), n = re();
395
401
  return ie("div", {
396
402
  style: {
@@ -407,24 +413,26 @@ var ce = parseInt(c.split(".")[0], 10) >= 19 ? function(e) {
407
413
  children: n("scriptEditor.retry")
408
414
  }) : null]
409
415
  });
410
- }, P = _(me.load, { renderError: (e) => b(N, { error: e }) }), F = ["define", "require"], he = !1, I = "@0.8.0-beta.10";
411
- I !== "@local" && I !== "@0.0.0" || (I = "");
412
- var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R = (e) => {
416
+ }, N = _(he.load, { renderError: ({ error: e }) => b(M, { error: e }) }), P = ["define", "require"], ge = !1, F = "@0.8.0-beta.12";
417
+ F !== "@local" && F !== "@0.0.0" || (F = "");
418
+ var I = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${F}/types/scripting.d.ts`, L = null, R = null, _e = () => (R || (R = (async () => await (await fetch(I)).text())().then((e) => (L = e, e))).catch(() => {
419
+ R = null;
420
+ }), R), z = (e) => {
413
421
  try {
414
- e.languages.setMonarchTokensProvider("typescript", T);
422
+ e.languages.setMonarchTokensProvider("typescript", w);
415
423
  } catch {}
416
- }, z = !1, ge = async (e, t, n) => {
424
+ }, B = !1, ve = async (e, t, n) => {
417
425
  let r = e.getModel();
418
426
  if (!r) return;
419
427
  let i = await (await (await t.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = e.getPosition(), o = { ...a };
420
428
  o.lineNumber = 1, o.column = 1;
421
429
  let s = !1;
422
430
  for (let e = a.lineNumber; e >= 1; e--) if (r.getLineContent(e).trim() === "") {
423
- let t = H(i, r.getOffsetAt({
431
+ let t = be(i, r.getOffsetAt({
424
432
  lineNumber: e,
425
433
  column: 1
426
434
  }), "function");
427
- if (!t || _e(t)) {
435
+ if (!t || H(t)) {
428
436
  s = !0, o.lineNumber = e + 1;
429
437
  break;
430
438
  }
@@ -434,7 +442,7 @@ var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R
434
442
  }
435
443
  }
436
444
  let c = ((e, t) => {
437
- let n = k(e), r = n.length > 0 ? n[n.length - 1].end : 0, i = k(t);
445
+ let n = ue(e), r = n.length > 0 ? n[n.length - 1].end : 0, i = ue(t);
438
446
  if (i.length === 0) return {
439
447
  body: t,
440
448
  inserts: [],
@@ -445,8 +453,8 @@ var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R
445
453
  a = (a + t.slice(o)).replace(/^(?:[ \t]*\r?\n)+/, "");
446
454
  let s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
447
455
  for (let e of n) {
448
- if (s.add(A(e)), !e.names) continue;
449
- let t = le(e);
456
+ if (s.add(O(e)), !e.names) continue;
457
+ let t = k(e);
450
458
  l.has(t) || l.set(t, e);
451
459
  let n = c.get(t);
452
460
  n || c.set(t, n = /* @__PURE__ */ new Set());
@@ -455,12 +463,12 @@ var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R
455
463
  let u = /* @__PURE__ */ new Map(), d = [], f = /* @__PURE__ */ new Map();
456
464
  for (let e of i) {
457
465
  if (!e.names || e.binding) {
458
- let t = A(e);
466
+ let t = O(e);
459
467
  if (s.has(t)) continue;
460
468
  s.add(t), d.push(e.text);
461
469
  continue;
462
470
  }
463
- let t = le(e), n = c.get(t);
471
+ let t = k(e), n = c.get(t);
464
472
  n || c.set(t, n = /* @__PURE__ */ new Set());
465
473
  let r = e.typeOnly ? c.get(e.module) : void 0, i = e.names.filter((e) => !n.has(e) && !r?.has(e));
466
474
  if (i.length === 0) continue;
@@ -483,7 +491,7 @@ var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R
483
491
  f.set(t, p), d.push(p);
484
492
  }
485
493
  let p = [];
486
- for (let [t, n] of u) p.push(ue(e, t, n));
494
+ for (let [t, n] of u) p.push(de(e, t, n));
487
495
  if (p.sort((e, t) => e.offset - t.offset), d.length > 0) {
488
496
  let t = d.map((e) => {
489
497
  if (typeof e == "string") return e;
@@ -528,7 +536,7 @@ var L = `https://cdn.jsdelivr.net/npm/@sheetxl/sdk${I}/types/scripting.d.ts`, R
528
536
  endColumn: v.startColumn
529
537
  });
530
538
  };
531
- function B(e, t) {
539
+ function ye(e, t) {
532
540
  let n = null, r = e.length;
533
541
  for (let i = 0; !n && i < r; i++) {
534
542
  let r = e[i];
@@ -541,42 +549,59 @@ function V(e, t, n, r, i = []) {
541
549
  let t = r.spans[0].start, a = e.getPositionAt(t);
542
550
  i.push({
543
551
  name: r.text,
544
- type: B(n, r),
552
+ type: ye(n, r),
545
553
  lineNumber: a.lineNumber
546
554
  });
547
555
  }
548
556
  if (r.childItems) for (let a of r.childItems) V(e, t, n, a, i);
549
557
  return i;
550
558
  }
551
- function H(e, t, n = "function", r) {
559
+ function be(e, t, n = "function", r) {
552
560
  let i = e.spans, a = i.length;
553
561
  for (let o = 0; o < a; o++) {
554
562
  let a = i[o];
555
563
  if (a.start <= t && t < a.start + a.length) {
556
564
  if (e.kind === n && (!r || e.kindModifiers === r)) return e;
557
565
  for (let i of e.childItems || []) {
558
- let e = H(i, t, n, r);
566
+ let e = be(i, t, n, r);
559
567
  if (e) return e;
560
568
  }
561
569
  }
562
570
  return null;
563
571
  }
564
572
  }
565
- function _e(e) {
573
+ function H(e) {
566
574
  return e.kind === "comment";
567
575
  }
568
- var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { current: null }, xe = (e, t) => {
576
+ var U = null, W = null, G = null, K = null, xe = !1, Se = !1, q = !1, J = { current: null }, Ce = (e, t) => {
569
577
  W = {
570
578
  editor: e,
571
579
  monaco: t
572
580
  }, G && (K = G(e, t));
573
- }, Se = (e) => {
574
- be || (be = !0, e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
575
- noSemanticValidation: !0,
581
+ }, we = (e) => {
582
+ if (q) return;
583
+ q = !0;
584
+ let t = e.languages.typescript;
585
+ t.typescriptDefaults.setCompilerOptions({
586
+ ...t.typescriptDefaults.getCompilerOptions(),
587
+ target: t.ScriptTarget.ES2020,
588
+ lib: [
589
+ "webworker",
590
+ "es2020",
591
+ "esnext.asynciterable"
592
+ ],
593
+ strict: !0,
594
+ downlevelIteration: !0,
595
+ moduleResolution: t.ModuleResolutionKind.NodeJs,
596
+ allowSyntheticDefaultImports: !0,
597
+ baseUrl: "inmemory://model/",
598
+ allowNonTsExtensions: !0
599
+ }), t.typescriptDefaults.setDiagnosticsOptions({
600
+ noSemanticValidation: !1,
576
601
  noSyntaxValidation: !1,
577
602
  diagnosticCodesToIgnore: [2307]
578
- }), e.languages.typescript.typescriptDefaults.setEagerModelSync(!0), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), R(e), ((e) => {
579
- z || (z = !0, e.languages.registerCompletionItemProvider("typescript", {
603
+ }), t.typescriptDefaults.setEagerModelSync(!0), L !== null && (t.typescriptDefaults.addExtraLib(L, "inmemory://model/sheetxl.d.ts"), t.typescriptDefaults.addExtraLib("declare module '@sheetxl/primitives' { export = SheetXL; }\n", "inmemory://model/sheetxl-module-shims.d.ts")), e.languages.json.jsonDefaults.setDiagnosticsOptions({ validate: !0 }), z(e), ((e) => {
604
+ B || (B = !0, e.languages.registerCompletionItemProvider("typescript", {
580
605
  triggerCharacters: ["@"],
581
606
  provideCompletionItems: (t, n) => {
582
607
  let r = t.getValueInRange({
@@ -650,84 +675,48 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
650
675
  }
651
676
  ],
652
677
  colors: {}
653
- }), (async () => {
654
- let t = !1;
655
- try {
656
- let n = await (async () => await (await fetch(L)).text())(), r = e.Uri.parse("inmemory://model/\"sheetxl-models\".d.ts"), i = e.editor.getModel(r);
657
- i ? t = !0 : i = e.editor.createModel(n, "typescript", r), e.editor.setModelMarkers(i, "default", []);
658
- } catch (e) {
659
- console.warn("cant load types", e);
660
- }
661
- try {
662
- if (e.languages.registerLinkProvider("*", { provideLinks: (t, n) => {
663
- let r = [], i = { links: r }, a = t.getLinesContent(), o = a.length;
664
- for (let n = 1; n <= o; n++) {
665
- let i = a[n - 1], o = e.editor.tokenize(i, "typescript"), s = o[0].length;
666
- for (let a = 0; a < s; a++) {
667
- let s = o[0]?.[a];
668
- if (s && s.type.startsWith("string")) {
669
- let c = s.offset, l = o[0]?.[a + 1]?.offset ?? i.length, u = new e.Range(n, c + 1, n, l + 1), d = t.getValueInRange(u), f = d[0];
670
- f !== "`" && f !== "'" && f !== "\"" || (c++, d = d.substring(1));
671
- let p = d[d.length - 1];
672
- p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
673
- try {
674
- q.current?.getRanges(d) && r.push({
675
- range: {
676
- endColumn: l,
677
- endLineNumber: n,
678
- startColumn: c,
679
- startLineNumber: n
680
- },
681
- tooltip: `Goto range '${d}'`,
682
- url: `/range/${d}`
683
- });
684
- } catch {}
685
- }
686
- }
687
- }
688
- return i;
689
- } }), e.editor.registerLinkOpener({ open(e) {
690
- if (e?.path?.startsWith("/range/")) {
678
+ }), e.languages.registerLinkProvider("*", { provideLinks: (t, n) => {
679
+ let r = [], i = { links: r }, a = t.getLinesContent(), o = a.length;
680
+ for (let n = 1; n <= o; n++) {
681
+ let i = a[n - 1], o = e.editor.tokenize(i, "typescript"), s = o[0].length;
682
+ for (let a = 0; a < s; a++) {
683
+ let s = o[0]?.[a];
684
+ if (s && s.type.startsWith("string")) {
685
+ let c = s.offset, l = o[0]?.[a + 1]?.offset ?? i.length, u = new e.Range(n, c + 1, n, l + 1), d = t.getValueInRange(u), f = d[0];
686
+ f !== "`" && f !== "'" && f !== "\"" || (c++, d = d.substring(1));
687
+ let p = d[d.length - 1];
688
+ p !== "`" && p !== "'" && p !== "\"" || (c++, d = d.substring(0, d.length - 1));
691
689
  try {
692
- q.current?.getRanges(e.path.substring(7))?.select();
693
- } catch (e) {
694
- console.warn("invalid range", e);
695
- }
696
- return !0;
690
+ J.current?.getRanges(d) && r.push({
691
+ range: {
692
+ endColumn: l,
693
+ endLineNumber: n,
694
+ startColumn: c,
695
+ startLineNumber: n
696
+ },
697
+ tooltip: `Goto range '${d}'`,
698
+ url: `/range/${d}`
699
+ });
700
+ } catch {}
697
701
  }
698
- return !1;
699
- } }), !t) {
700
- let t = e.languages.typescript.typescriptDefaults.getCompilerOptions();
701
- e.languages.typescript.typescriptDefaults.setCompilerOptions({
702
- ...t,
703
- target: e.languages.typescript.ScriptTarget.ES2020,
704
- lib: [
705
- "webworker",
706
- "es2020",
707
- "esnext.asynciterable"
708
- ],
709
- strict: !0,
710
- downlevelIteration: !0,
711
- moduleResolution: e.languages.typescript.ModuleResolutionKind.NodeJs,
712
- allowSyntheticDefaultImports: !0,
713
- baseUrl: "inmemory://model/",
714
- allowNonTsExtensions: !0
715
- });
716
702
  }
717
- } finally {
718
- (() => {
719
- let t = e.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
720
- e.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
721
- ...t,
722
- noSemanticValidation: !1
723
- });
724
- })();
725
703
  }
726
- })());
727
- }, Ce = (e) => {
704
+ return i;
705
+ } }), e.editor.registerLinkOpener({ open(e) {
706
+ if (e?.path?.startsWith("/range/")) {
707
+ try {
708
+ J.current?.getRanges(e.path.substring(7))?.select();
709
+ } catch (e) {
710
+ console.warn("invalid range", e);
711
+ }
712
+ return !0;
713
+ }
714
+ return !1;
715
+ } });
716
+ }, Te = (e) => {
728
717
  let t = !1, n = e ? e.length : 0;
729
718
  for (let r = 0; !t && r < n; r++) e[r].severity === 8 && (t = !0);
730
- }, we = () => {
719
+ }, Ee = () => {
731
720
  let [e, n] = s(() => U.props);
732
721
  return i(() => (U && (U.setProps = n), () => {
733
722
  U && (U.setProps = null);
@@ -738,74 +727,74 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
738
727
  width: "100%",
739
728
  height: "100%"
740
729
  },
741
- children: b(t, { children: b(P, {
730
+ children: b(t, { children: b(N, {
742
731
  theme: e.theme,
743
732
  options: e.options,
744
733
  language: "typescript",
745
734
  value: e.value,
746
735
  onValidate: e.onValidate,
747
736
  beforeMount: e.beforeMount,
748
- onMount: xe
737
+ onMount: Ce
749
738
  }) })
750
739
  });
751
- }, J = r(n((t, n) => {
752
- let { className: r, style: c, readOnly: f = !1, darkMode: m, loadingPanel: h, autoFocus: _ = !0, frame: y, scripts: x, onStatusChange: S, ...C } = t, w = re(), T = o(null), [E, D] = s(!1), O = oe(), [k] = ee(["insertFunction"]), [A, le] = s({
740
+ }, De = r(n((t, n) => {
741
+ let { className: r, style: c, readOnly: f = !1, darkMode: m, loadingPanel: h, autoFocus: _ = !0, frame: y, scripts: x, onStatusChange: S, ...se } = t, C = re(), w = o(null), [T, E] = s(!1), D = oe(), [ue] = ee(["insertFunction"]), [O, k] = s({
753
742
  message: "Loading",
754
743
  cursor: "",
755
744
  dirty: !1
756
- }), [ue, me] = s({
745
+ }), [de, he] = s({
757
746
  loading: !1,
758
747
  compiling: !1,
759
748
  errors: [],
760
749
  warnings: []
761
- }), N = v((e) => {
762
- le((t) => {
750
+ }), M = v((e) => {
751
+ k((t) => {
763
752
  let n = {
764
753
  ...t,
765
754
  ...e
766
755
  };
767
- return u.deepEqual(n, t) ? t : (D(n.dirty ?? !1), n);
756
+ return u.deepEqual(n, t) ? t : (E(n.dirty ?? !1), n);
768
757
  });
769
758
  }, [S]);
770
759
  i(() => {
771
- S?.(A);
772
- }, [S, A]);
773
- let P = ne(), I = v(async (e) => {
760
+ S?.(O);
761
+ }, [S, O]);
762
+ let N = ne(), F = v(async (e) => {
774
763
  let t = null, n = null;
775
764
  try {
776
- e && (n = await P.showBusy(w("scriptEditor.saving")), t = await x.createModule({ source: e })), x.addModule(pe(x), t, { replace: !0 }), n?.();
765
+ e && (n = await N.showBusy(C("scriptEditor.saving")), t = await x.createModule({ source: e })), x.addModule(me(x), t, { replace: !0 }), n?.();
777
766
  } catch (e) {
778
- n?.(), console.warn("Unable to compile", e), P.showError(e);
767
+ n?.(), console.warn("Unable to compile", e), N.showError(e);
779
768
  }
780
769
  return t;
781
- }, [x]), L = v(async () => {
782
- if (!T.current || f) return;
783
- let e = T.current.editor, t;
784
- if (A.dirty) {
770
+ }, [x]), I = v(async () => {
771
+ if (!w.current || f) return;
772
+ let e = w.current.editor, t;
773
+ if (O.dirty) {
785
774
  let n = e.getValue();
786
- await I(n), t = j(x);
775
+ await F(n), t = A(x);
787
776
  let r = t?.getSource(), i = e.getValue(), a = (r?.length ?? 0) !== n.length || r !== i;
788
- N({ dirty: a });
789
- } else t = j(x);
777
+ M({ dirty: a });
778
+ } else t = A(x);
790
779
  return t;
791
- }, [A, x]);
780
+ }, [O, x]);
792
781
  i(() => {
793
- let e = y?.addListener({ onBeforeHide: async () => (await L(), !0) });
782
+ let e = y?.addListener({ onBeforeHide: async () => (await I(), !0) });
794
783
  return () => {
795
784
  e?.();
796
785
  };
797
786
  }, [y]), i(() => {
798
- if (x) return x.addListeners({ onBeforeSearch: () => L() });
799
- }, [x]), ae(O, {
787
+ if (x) return x.addListeners({ onBeforeSearch: () => I() });
788
+ }, [x]), ae(D, {
800
789
  onBeforeSave: async () => {
801
- await L();
790
+ await I();
802
791
  },
803
792
  onLoad: () => {
804
- let e = T.current?.editor;
805
- e && e.setValue(j(x)?.getSource() ?? "");
793
+ let e = w.current?.editor;
794
+ e && e.setValue(A(x)?.getSource() ?? "");
806
795
  }
807
796
  });
808
- let z = v(async (e) => {
797
+ let L = v(async (e) => {
809
798
  if (!x) return;
810
799
  let t = typeof e == "string" ? { functionName: e } : e ?? {}, n = null;
811
800
  if (t?.declaration || t?.functionName) {
@@ -818,11 +807,11 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
818
807
  if (n) try {
819
808
  await x.executeMacro(n);
820
809
  } catch (e) {
821
- P.showError(e);
810
+ N.showError(e);
822
811
  }
823
- }, [x, P]), [B, _e] = s(!1), be = v(async () => {
824
- if (!T.current) return null;
825
- let e = T.current, t = e.editor;
812
+ }, [x, N]), [R, _e] = s(!1), B = v(async () => {
813
+ if (!w.current) return null;
814
+ let e = w.current, t = e.editor;
826
815
  if (!t) return null;
827
816
  let n = await (async (e, t, n = "export") => {
828
817
  let r = e.getModel();
@@ -831,7 +820,7 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
831
820
  if (!o) return null;
832
821
  let s = o.startLineNumber === o.endLineNumber && o.startColumn === o.endColumn ? r.getLineCount() : Math.min(o.endLineNumber, r.getLineCount());
833
822
  for (let e = o.startLineNumber; !a && e <= s; e++) {
834
- let t = H(i, r.getOffsetAt({
823
+ let t = be(i, r.getOffsetAt({
835
824
  lineNumber: e,
836
825
  column: 1
837
826
  }), "function", n);
@@ -839,14 +828,14 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
839
828
  }
840
829
  return a;
841
830
  })(t, e.monaco);
842
- return N({ message: (n ?? "").toUpperCase() }), n ? {
831
+ return M({ message: (n ?? "").toUpperCase() }), n ? {
843
832
  source: t.getValue(),
844
833
  name: n
845
834
  } : null;
846
835
  }, []);
847
- v(d.debounce(L, 200), []);
848
- let xe = v(async (e, t, n) => {
849
- me((e) => ({
836
+ v(d.debounce(I, 200), []);
837
+ let ye = v(async (e, t, n) => {
838
+ he((e) => ({
850
839
  ...e,
851
840
  compiling: !0
852
841
  }));
@@ -875,7 +864,7 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
875
864
  })(e, t, i), async function(e, t, n, r) {
876
865
  let i = V(e, t, r, await (await (await t.languages.typescript.getTypeScriptWorker())(e.uri)).getNavigationTree(e.uri.toString())).map((e) => {
877
866
  let n = null, r = null;
878
- return e.type === "formula" ? (n = "formula.margin-icon", r = w("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = w("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = w("scriptEditor.glyph.autoRun")), {
867
+ return e.type === "formula" ? (n = "formula.margin-icon", r = C("scriptEditor.glyph.formula")) : e.type === "macro" ? (n = "macro.margin-icon", r = C("scriptEditor.glyph.macro")) : e.type === "autoRun" && (n = "autorun.margin-icon", r = C("scriptEditor.glyph.autoRun")), {
879
868
  range: new t.Range(e.lineNumber, 1, e.lineNumber, 1),
880
869
  options: {
881
870
  isWholeLine: !1,
@@ -885,33 +874,33 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
885
874
  }
886
875
  };
887
876
  });
888
- Z.current && Z.current.clear(), Z.current = n.createDecorationsCollection(i);
889
- }(e, t, n, r ? r.getFunctions().getItems({ includeHidden: !0 }) : u.EmptyArray), me((e) => ({
877
+ X.current && X.current.clear(), X.current = n.createDecorationsCollection(i);
878
+ }(e, t, n, r ? r.getFunctions().getItems({ includeHidden: !0 }) : u.EmptyArray), he((e) => ({
890
879
  ...e,
891
880
  compiling: !1,
892
881
  errors: i.filter((e) => e.severity === "error").map((e) => `${e.code}: ${e.message}`),
893
882
  warnings: i.filter((e) => e.severity === "warning").map((e) => `${e.code}: ${e.message}`)
894
883
  }));
895
- }, [x]), J = v(d.debounce(xe, 580), []), Y = v(async (e) => {
896
- if (!T.current) return;
897
- let t = T.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
898
- e !== void 0 && (n.message = e), N(n);
884
+ }, [x]), H = v(d.debounce(ye, 580), []), q = v(async (e) => {
885
+ if (!w.current) return;
886
+ let t = w.current.editor.getPosition(), n = { cursor: t ? t.toString() : "" };
887
+ e !== void 0 && (n.message = e), M(n);
899
888
  }, []);
900
- i(() => {}, [ue]);
901
- let Te = o(null), Ee = v(async () => {
902
- await L(), y?.close();
903
- }, [y]), X = v((e) => {
904
- let t = T.current?.editor;
889
+ i(() => {}, [de]);
890
+ let Ce = o(null), De = v(async () => {
891
+ await I(), y?.close();
892
+ }, [y]), Oe = v((e) => {
893
+ let t = w.current?.editor;
905
894
  return !!t && (t.focus(e), !0);
906
- }, [A]), De = v(async () => {
907
- let e = T.current?.editor, t = e?.getModel(), n = e?.getSelection();
895
+ }, [O]), ke = v(async () => {
896
+ let e = w.current?.editor, t = e?.getModel(), n = e?.getSelection();
908
897
  if (!t || !n) return;
909
898
  let r = n.isEmpty() ? t.getLineContent(n.positionLineNumber) + "\n" : t.getValueInRange(n);
910
899
  try {
911
900
  await navigator.clipboard?.writeText(r);
912
901
  } catch {}
913
- }, []), Oe = v(async () => {
914
- let e = T.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
902
+ }, []), Ae = v(async () => {
903
+ let e = w.current, t = e?.editor, n = t?.getModel(), r = t?.getSelection();
915
904
  if (!n || !r) return;
916
905
  let i = r.isEmpty() ? new e.monaco.Range(r.positionLineNumber, 1, r.positionLineNumber + 1, 1) : r, a = n.getValueInRange(i);
917
906
  try {
@@ -924,8 +913,8 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
924
913
  text: "",
925
914
  forceMoveMarkers: !0
926
915
  }]), t.pushUndoStop(), t.focus();
927
- }, []), ke = v(async () => {
928
- let e = T.current?.editor;
916
+ }, []), Y = v(async () => {
917
+ let e = w.current?.editor;
929
918
  if (!e) return;
930
919
  let t;
931
920
  try {
@@ -940,23 +929,29 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
940
929
  text: t,
941
930
  forceMoveMarkers: !0
942
931
  }]), e.pushUndoStop(), e.focus();
943
- }, []), Z = o(null), Ae = v((t, n) => {
944
- T.current = {
932
+ }, []), X = o(null), je = v((t, n) => {
933
+ w.current = {
945
934
  monaco: n,
946
935
  editor: t
947
- }, q.current = O ?? null;
936
+ }, J.current = D ?? null;
948
937
  let r = t.getModel(), i = [];
949
938
  _e(!0);
950
- let a = j(x)?.getSource() ?? "";
951
- return t.getValue() !== a && t.setValue(a), ve ? (Y(""), J(r, n, t), R(n)) : (ve = !0, Y("Loading Types"), import("./B1-evL6_FxctVica.mjs").then((t) => e(t.default, 1)).then(async (e) => {
952
- Y(""), e.AutoTypings.create(t, {
939
+ let a = A(x)?.getSource() ?? "";
940
+ return t.getValue() !== a && t.setValue(a), xe ? (q(""), H(r, n, t), z(n)) : (xe = !0, q("Loading Types"), import("./WrV6tIDJzFg4tGhv.mjs").then((t) => e(t.default, 1)).then(async (e) => {
941
+ q("");
942
+ let r = e.AutoTypings, i = new e.JsDelivrSourceResolver(), a = (e) => e.startsWith("@sheetxl/") || e.startsWith("@types/sheetxl__");
943
+ r.create(t, {
944
+ sourceResolver: {
945
+ resolvePackageJson: (e, t, n) => a(e) ? Promise.resolve(void 0) : i.resolvePackageJson(e, t, n),
946
+ resolveSourceFile: (e, t, n) => a(e) ? Promise.resolve(void 0) : i.resolveSourceFile(e, t, n)
947
+ },
953
948
  shareCache: !0,
954
949
  dontAdaptEditorOptions: !0,
955
950
  monaco: n,
956
951
  onUpdate: (e, t) => {
957
- if (e.type === "LookedUpPackage" && e.success !== void 0) {
952
+ if (e.type === "LookedUpPackage" && !0 === e.success) {
958
953
  let e = n.languages.typescript.typescriptDefaults.getDiagnosticsOptions();
959
- n.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
954
+ e.diagnosticCodesToIgnore?.length && n.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
960
955
  ...e,
961
956
  diagnosticCodesToIgnore: []
962
957
  });
@@ -966,8 +961,8 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
966
961
  e === "Not implemented yet" && (e = "Compile Errors"), console.warn("Error compiling types", e);
967
962
  }
968
963
  }).then((e) => {
969
- Te.current = e, J(t.getModel(), n, t), (() => {
970
- if (he) return;
964
+ Ce.current = e, H(t.getModel(), n, t), (() => {
965
+ if (ge) return;
971
966
  let e = (e, t) => {
972
967
  try {
973
968
  if (t === void 0) try {
@@ -979,17 +974,17 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
979
974
  }
980
975
  else globalThis[e] = t;
981
976
  } catch {}
982
- }, t = F.length;
977
+ }, t = P.length;
983
978
  for (let n = 0; n < t; n++) {
984
- let t = F[n];
985
- e(t, M[t]);
979
+ let t = P[n];
980
+ e(t, j[t]);
986
981
  }
987
- M = void 0, he = !0;
988
- })(), R(n);
982
+ j = void 0, ge = !0;
983
+ })(), z(n);
989
984
  });
990
985
  }).catch((e) => {
991
- ve = !1, Y(""), console.warn("Auto typings could not be loaded:", e);
992
- })), ye || (ye = !0, function(e, t) {
986
+ xe = !1, q(""), console.warn("Auto typings could not be loaded:", e);
987
+ })), Se || (Se = !0, function(e, t) {
993
988
  t.languages.registerInlayHintsProvider("typescript", { provideInlayHints(e, n, r) {
994
989
  let i = [];
995
990
  for (let n = 1; n < e.getLineCount() + 1; n++) {
@@ -1018,56 +1013,56 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1018
1013
  label: "Execute",
1019
1014
  keybindings: [n.KeyCode.F8],
1020
1015
  run: async (e) => {
1021
- let t = await be();
1022
- z(t);
1016
+ let t = await B();
1017
+ L(t);
1023
1018
  }
1024
1019
  })), i.push(t.addAction({
1025
1020
  id: "saveScript",
1026
1021
  label: "Save Script",
1027
1022
  keybindings: [n.KeyMod.CtrlCmd | n.KeyCode.KeyS],
1028
1023
  run: (e) => {
1029
- L();
1024
+ I();
1030
1025
  }
1031
1026
  })), i.push(t.onMouseDown(async (e) => {
1032
1027
  if (e.target.type === n.editor.MouseTargetType.GUTTER_GLYPH_MARGIN) {
1033
1028
  e.event.browserEvent.preventDefault();
1034
- let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await L();
1029
+ let t = e.target.position.lineNumber, i = await (await (await n.languages.typescript.getTypeScriptWorker())(r.uri)).getNavigationTree(r.uri.toString()), a = await I();
1035
1030
  if (!a) return;
1036
1031
  let o = a.getFunctions().getItems({ includeHidden: !0 }), s = V(r, n, o, i).find((e) => e.lineNumber === t);
1037
1032
  if (s) {
1038
1033
  let t = e.event.browserEvent.button;
1039
1034
  if (t === 0) {
1040
- if (s.type === "macro" || s.type === "autoRun") z({ functionName: s.name });
1035
+ if (s.type === "macro" || s.type === "autoRun") L({ functionName: s.name });
1041
1036
  else if (s.type === "formula") {
1042
1037
  let e = o?.find((e) => e.getName() === s.name);
1043
- e && k?.execute(e);
1038
+ e && ue?.execute(e);
1044
1039
  }
1045
1040
  } else t === 2 && (console.log("Context menu for function:", s.name), e.event.browserEvent.preventDefault());
1046
1041
  }
1047
1042
  }
1048
1043
  })), i.push(t.onDidChangeModelContent(() => {
1049
- N({ dirty: !0 }), J(r, n, t);
1044
+ M({ dirty: !0 }), H(r, n, t);
1050
1045
  })), i.push(n.editor.onDidChangeMarkers((e) => {
1051
1046
  e.some((e) => e.toString() === r.uri.toString());
1052
1047
  })), i.push(r.onDidChangeContent((e) => {
1053
- let n = j(x)?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
1054
- N({ dirty: i });
1048
+ let n = A(x)?.getSource(), r = t.getValue(), i = (n?.length ?? 0) !== r.length || n !== r;
1049
+ M({ dirty: i });
1055
1050
  })), i.push(t.onDidChangeCursorPosition((e) => {
1056
- Y();
1051
+ q();
1057
1052
  })), () => {
1058
1053
  for (let e of i) try {
1059
1054
  e.dispose();
1060
1055
  } catch {}
1061
1056
  };
1062
- }, [x, O]), je = a(() => B ? null : h || b("div", {
1057
+ }, [x, D]), Me = a(() => R ? null : h || b("div", {
1063
1058
  style: {
1064
1059
  position: "absolute",
1065
1060
  width: "100%",
1066
1061
  height: "100%"
1067
1062
  },
1068
- children: w("scriptEditor.loading")
1069
- }), [B, h]), Me = a(() => ({
1070
- ...de,
1063
+ children: C("scriptEditor.loading")
1064
+ }), [R, h]), Z = a(() => ({
1065
+ ...fe,
1071
1066
  fixedOverflowWidgets: !1,
1072
1067
  contextmenu: !1,
1073
1068
  readOnly: f
@@ -1075,18 +1070,18 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1075
1070
  i(() => {
1076
1071
  let e = {
1077
1072
  theme: m ? "extended-dark" : "extended",
1078
- options: Me,
1079
- value: j(x)?.getSource() ?? "",
1080
- beforeMount: Se,
1081
- onValidate: Ce
1073
+ options: Z,
1074
+ value: A(x)?.getSource() ?? "",
1075
+ beforeMount: we,
1076
+ onValidate: Te
1082
1077
  }, t = ((e) => {
1083
1078
  if (U) return U;
1084
- if (!M) {
1085
- M = {};
1086
- let e = F.length;
1079
+ if (!j) {
1080
+ j = {};
1081
+ let e = P.length;
1087
1082
  for (let t = 0; t < e; t++) {
1088
- let e = F[t];
1089
- M[e] = globalThis[e];
1083
+ let e = P[t];
1084
+ j[e] = globalThis[e];
1090
1085
  }
1091
1086
  }
1092
1087
  let t = document.createElement("div");
@@ -1100,26 +1095,26 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1100
1095
  stashEl: t,
1101
1096
  props: e,
1102
1097
  setProps: null
1103
- }, r.render(b(we, {})), U;
1098
+ }, r.render(b(Ee, {})), U;
1104
1099
  })(e);
1105
- return t.props = e, t.setProps?.(e), G = (e, t) => Ae(e, t), Ne.current?.appendChild(t.hostEl), W && (K = Ae(W.editor, W.monaco)), () => {
1106
- K?.(), K = null, G = null, T.current = null, U?.stashEl.appendChild(U.hostEl);
1100
+ return t.props = e, t.setProps?.(e), G = (e, t) => je(e, t), Ne.current?.appendChild(t.hostEl), W && (K = je(W.editor, W.monaco)), () => {
1101
+ K?.(), K = null, G = null, w.current = null, U?.stashEl.appendChild(U.hostEl);
1107
1102
  };
1108
1103
  }, []), i(() => {
1109
1104
  if (!U) return;
1110
1105
  let e = {
1111
1106
  ...U.props,
1112
1107
  theme: m ? "extended-dark" : "extended",
1113
- options: Me
1108
+ options: Z
1114
1109
  };
1115
1110
  U.props = e, U.setProps?.(e);
1116
- }, [m, Me]), i(() => {
1117
- let e = T.current, t = e?.editor;
1111
+ }, [m, Z]), i(() => {
1112
+ let e = w.current, t = e?.editor;
1118
1113
  if (!t) return;
1119
- q.current = O ?? null;
1120
- let n = j(x)?.getSource() ?? "";
1121
- t.getValue() !== n && (t.setValue(n), J(t.getModel(), e.monaco, t), N({ dirty: !1 }));
1122
- }, [x, O]);
1114
+ J.current = D ?? null;
1115
+ let n = A(x)?.getSource() ?? "";
1116
+ t.getValue() !== n && (t.setValue(n), H(t.getModel(), e.monaco, t), M({ dirty: !1 }));
1117
+ }, [x, D]);
1123
1118
  let Pe = ie("div", {
1124
1119
  style: {
1125
1120
  display: "flex",
@@ -1137,29 +1132,29 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1137
1132
  width: "100%",
1138
1133
  position: "relative"
1139
1134
  }
1140
- }), je]
1135
+ }), Me]
1141
1136
  }), Q = te(n, () => ({
1142
1137
  isScriptEditorElement: () => !0,
1143
1138
  showCommandPalette: () => {
1144
- T.current?.editor && T.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
1139
+ w.current?.editor && w.current.editor.trigger("keyboard", "editor.action.quickCommand", null);
1145
1140
  },
1146
1141
  getScripts: () => x,
1147
1142
  focus: (e) => {
1148
- X(e);
1143
+ Oe(e);
1149
1144
  },
1150
- close: () => Ee(),
1151
- insertSnippet: (e) => T.current?.editor ? ge(T.current.editor, T.current.monaco, e) : Promise.resolve(),
1145
+ close: () => De(),
1146
+ insertSnippet: (e) => w.current?.editor ? ve(w.current.editor, w.current.monaco, e) : Promise.resolve(),
1152
1147
  saveSource: async () => {
1153
- await L();
1148
+ await I();
1154
1149
  },
1155
1150
  runAction: (e) => {
1156
- let t = T.current?.editor;
1151
+ let t = w.current?.editor;
1157
1152
  t && (t.focus(), t.trigger("source", e, null));
1158
1153
  },
1159
- copy: () => De(),
1160
- cut: () => Oe(),
1161
- paste: () => ke()
1162
- }), [O]), [Fe, Ie] = s(null), Le = v((e) => {
1154
+ copy: () => ke(),
1155
+ cut: () => Ae(),
1156
+ paste: () => Y()
1157
+ }), [D]), [Fe, Ie] = s(null), Le = v((e) => {
1163
1158
  e !== null && Ie(e);
1164
1159
  }, []), $ = g.useCommandScope();
1165
1160
  i(() => {
@@ -1184,7 +1179,7 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1184
1179
  }), e.updateCommand("copy", { callback: () => n.copy() }), e.updateCommand("cut", { callback: () => n.cut() }), e.updateCommand("paste", { callback: () => n.paste() }), e.updateCommand("selectAll", { callback: () => n.runAction("editor.action.selectAll") }), e.updateCommand("find", { callback: () => n.runAction("actions.find") }), e.updateCommand("findReplace", { callback: () => n.runAction("editor.action.startFindReplaceAction") }), e.updateCommand("goto", { callback: () => n.runAction("editor.action.gotoLine") });
1185
1180
  }(e, {
1186
1181
  scriptEditor: Fe,
1187
- isDirty: E,
1182
+ isDirty: T,
1188
1183
  readOnly: f
1189
1184
  }), () => {
1190
1185
  e.remove();
@@ -1192,19 +1187,19 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1192
1187
  }, [
1193
1188
  $,
1194
1189
  Fe,
1195
- E,
1190
+ T,
1196
1191
  f
1197
1192
  ]), i(() => (_ && requestAnimationFrame(() => {
1198
1193
  Q.current?.focus();
1199
1194
  }), () => {
1200
- T.current?.editor && requestAnimationFrame(() => {
1195
+ w.current?.editor && requestAnimationFrame(() => {
1201
1196
  Q.current?.contains(document.activeElement) && Q.current?.focus();
1202
1197
  });
1203
1198
  }), []);
1204
- let Re = a(() => ce(ze), ze = [Q, Le]);
1199
+ let Re = a(() => le(ze), ze = [Q, Le]);
1205
1200
  var ze;
1206
1201
  return b("div", {
1207
- className: se("script-editor", fe, r),
1202
+ className: ce("script-editor", pe, r),
1208
1203
  style: {
1209
1204
  display: "flex",
1210
1205
  flexDirection: "row",
@@ -1213,12 +1208,12 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1213
1208
  ...c
1214
1209
  },
1215
1210
  ref: Re,
1216
- ...C,
1211
+ ...se,
1217
1212
  children: Pe
1218
1213
  });
1219
- })), Y = null, Te = (e) => {
1220
- Y = e;
1221
- }, Ee = () => Y, X = r((e) => {
1214
+ })), Oe = null, ke = (e) => {
1215
+ Oe = e;
1216
+ }, Ae = () => Oe, Y = r((e) => {
1222
1217
  let { scope: t, data: n } = e, { workbook: r } = n, a = ne(), o = S(), s = o.getOpen(), c = v(async (e) => {
1223
1218
  if (!r) return;
1224
1219
  let t = null, n = r.getScripts();
@@ -1236,7 +1231,7 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1236
1231
  return;
1237
1232
  }
1238
1233
  }, [r, a]), l = v(() => {
1239
- let e = Ee();
1234
+ let e = Ae();
1240
1235
  e ? r && e({ workbook: r }) : o.getOpen().includes("scriptEditor") ? o.close("scriptEditor") : o.activate("scriptEditor", {});
1241
1236
  }, [r, o]), u = s.includes("scriptEditor");
1242
1237
  return i(() => {
@@ -1260,8 +1255,8 @@ var U = null, W = null, G = null, K = null, ve = !1, ye = !1, be = !1, q = { cur
1260
1255
  r?.getScripts().start();
1261
1256
  } }), null;
1262
1257
  });
1263
- X.displayName = "WorkbookScriptCommands";
1264
- var De = {
1258
+ Y.displayName = "WorkbookScriptCommands";
1259
+ var X = {
1265
1260
  "reason.noChangesToSave": "No changes to save",
1266
1261
  "reason.scriptsReadOnly": "Scripts can't be changed while the workbook structure is protected.",
1267
1262
  "scriptEditor.glyph.autoRun": "Auto Run",
@@ -1270,7 +1265,7 @@ var De = {
1270
1265
  "scriptEditor.loading": "Loading...",
1271
1266
  "scriptEditor.retry": "Retry",
1272
1267
  "scriptEditor.saving": "Saving Scripts..."
1273
- }, Oe = [
1268
+ }, je = [
1274
1269
  {
1275
1270
  sourceId: "groups",
1276
1271
  catalog: {
@@ -1352,29 +1347,29 @@ var De = {
1352
1347
  }
1353
1348
  }
1354
1349
  }
1355
- ], { DefaultCommandCatalogService: ke } = g, Z = !1, Ae = (e) => {
1350
+ ], { DefaultCommandCatalogService: Me } = g, Z = !1, Ne = (e) => {
1356
1351
  let { model: t, entryKey: n, frame: r, ref: i, ...a } = e;
1357
- return b(J, {
1352
+ return b(De, {
1358
1353
  ref: i,
1359
1354
  frame: r,
1360
1355
  scripts: t?.getScripts(),
1361
1356
  ...a
1362
1357
  });
1363
- }, je = () => {
1358
+ }, Pe = () => {
1364
1359
  x.registerTaskPane({
1365
1360
  key: "scriptEditor",
1366
1361
  getTitle: () => "Script (Typescript)",
1367
1362
  getIcon: () => "ScriptRun",
1368
- component: Ae,
1363
+ component: Ne,
1369
1364
  keepMounted: !0
1370
1365
  }, !0), function() {
1371
1366
  if (Z) return;
1372
1367
  Z = !0;
1373
- let e = ke;
1368
+ let e = Me;
1374
1369
  e.registerFromManifest("@sheetxl/scripting-react", import.meta.url, {
1375
- messages: De,
1376
- catalogs: Oe
1370
+ messages: X,
1371
+ catalogs: je
1377
1372
  }), e.prefetch();
1378
- }(), g.DefaultCommandRegistry.registerDynamic("workbook", X);
1373
+ }(), g.DefaultCommandRegistry.registerDynamic("workbook", Y);
1379
1374
  };
1380
- export { J as ScriptEditor, je as ScriptingReactPlugin, X as WorkbookScriptCommands, Ee as getScriptEditorOpener, Te as setScriptEditorOpener };
1375
+ export { De as ScriptEditor, Pe as ScriptingReactPlugin, Y as WorkbookScriptCommands, Ae as getScriptEditorOpener, ke as setScriptEditorOpener };