@sheetxl/scripting 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,17 +1,17 @@
1
- import { DiagnosticCode as i, n as Le } from "./index.mjs";
2
- import { CommonUtils as Ee } from "@sheetxl/utils";
3
- import { InteropScalarType as he, ScalarType as _, ValueKind as ve } from "@sheetxl/primitives";
4
- var oe = /* @__PURE__ */ new Map([["IReferenceRange", "p"], ["IRange", "r"]]), ae = new Set(Object.values(ve).filter((r) => r !== ve.Omitted)), le = /* @__PURE__ */ new Map([["IWorkbook", "workbook"], ["ISheet", "sheet"], ["ICellRanges", "ranges"], ["ICellRange", "range"]]), Ie = Array.from(le.keys()), ie = (r, F) => {
1
+ import { n as Ee, r as i } from "./DfSFyaySrD6y1NJY.mjs";
2
+ import { CommonUtils as Ie } from "@sheetxl/utils";
3
+ import { InteropScalarType as ve, ScalarType as _, ValueKind as $e } from "@sheetxl/primitives";
4
+ var se = /* @__PURE__ */ new Map([["IReferenceRange", "p"], ["IRange", "r"]]), ie = new Set(Object.values($e).filter((r) => r !== $e.Omitted)), de = /* @__PURE__ */ new Map([["IWorkbook", "workbook"], ["IWorksheet", "sheet"], ["ICellRanges", "ranges"], ["ICellRange", "range"]]), Fe = Array.from(de.keys()), oe = (r, F) => {
5
5
  Array.from(F.keys()).forEach(($) => {
6
6
  const A = F.get($);
7
7
  F.set(`${r}.${$}`, A);
8
8
  });
9
- }, Fe = /* @__PURE__ */ new Map([["Scalar", "*"], ["Lambda", "l"], ["FormulaError.Known", _.Error], ["Date", he.Date], ["IRichData", he.RichData]]), xe = /* @__PURE__ */ new Map([["Repeating", "repeating"]]), De = /* @__PURE__ */ new Set(["Flatten", "SheetXL.Flatten"]), we = /* @__PURE__ */ new Set(["AcceptError"]), Se = /* @__PURE__ */ new Set(["Omittable"]), ke = /* @__PURE__ */ new Set(["NoLift"]), Ae = /* @__PURE__ */ new Set(["NoFilter"]), Re = /* @__PURE__ */ new Set(["Lazy"]), se = /* @__PURE__ */ new Set(["ReportType"]), Me = /^[a-zA-Z_-￿][a-zA-Z0-9_.-￿]*$/, Ce = /^([a-z]{1,3})([0-9]+)$/i, Ue = /^r[0-9]*c[0-9]*$/i, V = "SheetXL", q = (r) => {
9
+ }, De = /* @__PURE__ */ new Map([["Scalar", "*"], ["Lambda", "l"], ["FormulaError.Known", _.Error], ["Date", ve.Date], ["IRichData", ve.RichData]]), we = /* @__PURE__ */ new Map([["Repeating", "repeating"]]), Me = /* @__PURE__ */ new Set(["Flatten", "SheetXL.Flatten"]), Se = /* @__PURE__ */ new Set(["AcceptError"]), ke = /* @__PURE__ */ new Set(["Omittable"]), Ae = /* @__PURE__ */ new Set(["NoLift"]), Re = /* @__PURE__ */ new Set(["NoFilter"]), Ke = /* @__PURE__ */ new Set(["Lazy"]), le = /* @__PURE__ */ new Set(["ReportType"]), Ce = /^[a-zA-Z_-￿][a-zA-Z0-9_.-￿]*$/, Ue = /^([a-z]{1,3})([0-9]+)$/i, Pe = /^r[0-9]*c[0-9]*$/i, V = "SheetXL", q = (r) => {
10
10
  const F = r.typeName.getText();
11
11
  return F.startsWith(`${V}.`) ? F.slice(8) : F;
12
12
  };
13
- ie(V, oe), ie(V, le), ie(V, xe), we.add(V + ".AcceptError"), Se.add(`${V}.Omittable`), ke.add(`${V}.NoLift`), Ae.add(`${V}.NoFilter`), Re.add(`${V}.Lazy`), se.add(`${V}.ReportType`);
14
- var Pe = /* @__PURE__ */ new Map([["Promise", () => ({ async: !0 })], ["Observable", () => ({ stream: !0 })], ["Volatile", () => ({ volatile: !0 })], [`${V}.Volatile`, () => ({ volatile: !0 })]]), $e = "__scriptContext__", be = "script", ze = /* @__PURE__ */ new Set(["IScript.ScriptContext", `${V}.IScript.ScriptContext`, "ScriptContext"]), Te = (r, F) => {
13
+ oe(V, se), oe(V, de), oe(V, we), Se.add(V + ".AcceptError"), ke.add(`${V}.Omittable`), Ae.add(`${V}.NoLift`), Re.add(`${V}.NoFilter`), Ke.add(`${V}.Lazy`), le.add(`${V}.ReportType`);
14
+ var ze = /* @__PURE__ */ new Map([["Volatile", () => ({ volatile: !0 })], [`${V}.Volatile`, () => ({ volatile: !0 })]]), be = "__scriptContext__", xe = "script", Oe = /* @__PURE__ */ new Set(["IScript.ScriptContext", `${V}.IScript.ScriptContext`, "ScriptContext"]), Te = (r, F) => {
15
15
  const $ = F.literal;
16
16
  if ($ === void 0) return;
17
17
  const A = r.SyntaxKind;
@@ -51,372 +51,370 @@ var Pe = /* @__PURE__ */ new Map([["Promise", () => ({ async: !0 })], ["Observab
51
51
  `).map((A) => A.trim()).filter(Boolean).join(" ")).filter(Boolean).join(`
52
52
  `).trim();
53
53
  };
54
- function Oe(r, F, $, A) {
54
+ function Ve(r, F, $, A) {
55
55
  const B = A?.builtInNames?.length ? new Set(A.builtInNames.map((e) => e.toUpperCase())) : null, G = [], W = /* @__PURE__ */ new Map(), Q = [];
56
56
  let X = null;
57
- const U = (e, n, s, l) => {
58
- const { start: u, length: y } = ((x) => {
59
- if (!x || typeof x.getStart != "function") return { start: 0, length: 0 };
57
+ const U = (e, n, o, l) => {
58
+ const { start: u, length: y } = ((T) => {
59
+ if (!T || typeof T.getStart != "function") return { start: 0, length: 0 };
60
60
  try {
61
- return { start: x.getStart(), length: x.getWidth() };
61
+ return { start: T.getStart(), length: T.getWidth() };
62
62
  } catch {
63
63
  return { start: 0, length: 0 };
64
64
  }
65
65
  })(e);
66
- Q.push({ start: u, length: y, severity: s, code: n, message: l });
67
- }, o = (e, n, s) => {
68
- U(e, n, "error", s);
69
- }, N = (e) => e?.parent?.name?.escapedText, Z = (e, n, s, l, u = !1, y = !1, x = !1) => {
70
- const T = { count: 0 }, p = M(e, n, s, l, T, u, y, x);
71
- T.count >= 2 && (n.range || (n.range = "m", T.count -= 2), !l && T.count >= 1 && (T.count -= 1, T.count > 0 && o(e, i.ArrayDepth, `Arrays of more than 2 dimensions are not supported: '${N(e)}'.`))), T.count > 0 && (n.arrayDepth = T.count);
66
+ Q.push({ start: u, length: y, severity: o, code: n, message: l });
67
+ }, s = (e, n, o) => {
68
+ U(e, n, "error", o);
69
+ }, N = (e) => e?.parent?.name?.escapedText;
70
+ let Y = null;
71
+ const Z = (e, n, o, l, u = !1, y = !1, T = !1) => {
72
+ const x = { count: 0 }, p = M(e, n, o, l, x, u, y, T);
73
+ x.count >= 2 && (n.range || (n.range = "m", x.count -= 2), !l && x.count >= 1 && (x.count -= 1, x.count > 0 && s(e, i.ArrayDepth, `Arrays of more than 2 dimensions are not supported: '${N(e)}'.`))), x.count > 0 && (n.arrayDepth = x.count);
72
74
  const h = n.enum;
73
- return h && (T.count > (x ? 1 : 0) || n.range) && !pe.has(n) && (n.valueOrRange || (o(e, i.EnumPosition, `A list cannot hold the enum '${h.id}': '${n.name ?? N(e)}'. Its members reach the body as they are, so nothing checks them against the enum. Take one value per argument ('...x: ${h.id}[]'), or type the list by its scalar ('${h.type}').`), delete n.enum)), p;
74
- }, de = (e, n, s, l, u) => {
75
+ return h && (x.count > (T ? 1 : 0) || n.range) && !ge.has(n) && (n.valueOrRange || (s(e, i.EnumPosition, `A list cannot hold the enum '${h.id}': '${n.name ?? N(e)}'. Its members reach the body as they are, so nothing checks them against the enum. Take one value per argument ('...x: ${h.id}[]'), or type the list by its scalar ('${h.type}').`), delete n.enum)), p;
76
+ }, me = (e, n, o, l, u) => {
75
77
  if (n !== "Lambda" && n !== `${V}.Lambda`) return !1;
76
78
  const y = e.typeArguments;
77
- let x = "*";
78
- if (y && y.length === 2) if (u && y[0].kind === r.SyntaxKind.TupleType && (s.lambdaArity = y[0].elements.length), y[1].kind === r.SyntaxKind.AnyKeyword) x = "raw";
79
+ let T = "*";
80
+ if (y && y.length === 2) if (u && y[0].kind === r.SyntaxKind.TupleType && (o.lambdaArity = y[0].elements.length), y[1].kind === r.SyntaxKind.AnyKeyword) T = "raw";
79
81
  else {
80
- const T = {};
81
- M(y[1], T, l, !1, { count: 0 }), x = T.scalar ?? "*";
82
+ const x = {};
83
+ M(y[1], x, l, !1, { count: 0 }), T = x.scalar ?? "*";
82
84
  }
83
- else if (y && y.length === 1 && y[0].kind !== r.SyntaxKind.TupleType && y[0].kind !== r.SyntaxKind.ArrayType) if (u && (s.lambdaArity = 2), y[0].kind === r.SyntaxKind.AnyKeyword) x = "raw";
85
+ else if (y && y.length === 1 && y[0].kind !== r.SyntaxKind.TupleType && y[0].kind !== r.SyntaxKind.ArrayType) if (u && (o.lambdaArity = 2), y[0].kind === r.SyntaxKind.AnyKeyword) T = "raw";
84
86
  else {
85
- const T = {};
86
- M(y[0], T, l, !1, { count: 0 }), x = T.scalar ?? "*";
87
+ const x = {};
88
+ M(y[0], x, l, !1, { count: 0 }), T = x.scalar ?? "*";
87
89
  }
88
- return s.lambda = x, !0;
89
- }, ee = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Set(), pe = /* @__PURE__ */ new WeakSet(), ge = (e) => e !== void 0 && e.getSourceFile() === F, te = (e, n = !1) => e.getJsDocTags($).find((l) => l.name === "name")?.text?.map((l) => l.text).join("").trim() || (n ? Ee.camelToPrettyCase(e.name) : e.name), ye = (e) => {
90
- const n = e.getJsDocTags($).find((s) => s.name === "deprecated");
91
- if (n) return n.text?.map((s) => s.text).join("").trim() || !0;
92
- }, ne = (e, n) => {
93
- const s = r.isTypeReferenceNode(e) ? e.typeName : void 0, l = s ? $.getSymbolAtLocation(s) : void 0, u = l?.declarations?.length ? l : void 0;
94
- if (s) {
95
- if (u && u.flags & r.SymbolFlags.Alias) return void o(e, i.EnumNotLocal, `'${s.getText()}' is imported, so its declaration cannot be read: '${n}'. An enum must be declared in the module that uses it.`);
90
+ return o.lambda = T, !0;
91
+ }, te = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), ce = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Set(), ge = /* @__PURE__ */ new WeakSet(), ye = (e) => e !== void 0 && e.getSourceFile() === F, ne = (e, n = !1) => e.getJsDocTags($).find((l) => l.name === "name")?.text?.map((l) => l.text).join("").trim() || (n ? Ie.camelToPrettyCase(e.name) : e.name), fe = (e) => {
92
+ const n = e.getJsDocTags($).find((o) => o.name === "deprecated");
93
+ if (n) return n.text?.map((o) => o.text).join("").trim() || !0;
94
+ }, re = (e, n) => {
95
+ const o = r.isTypeReferenceNode(e) ? e.typeName : void 0, l = o ? $.getSymbolAtLocation(o) : void 0, u = l?.declarations?.length ? l : void 0;
96
+ if (o) {
97
+ if (u && u.flags & r.SymbolFlags.Alias) return void s(e, i.EnumNotLocal, `'${o.getText()}' is imported, so its declaration cannot be read: '${n}'. An enum must be declared in the module that uses it.`);
96
98
  if (!(u && u.flags & r.SymbolFlags.Type)) {
97
- const a = s.getText();
98
- return (u ? (u.flags & r.SymbolFlags.Variable) !== 0 : F.statements.some((d) => r.isVariableStatement(d) && d.declarationList.declarations.some((v) => r.isIdentifier(v.name) && v.name.text === a))) ? void o(e, i.EnumMissingAlias, `'${a}' is a value, not a type: '${n}'. Pair the object with a same-name type — 'type ${a} = typeof ${a}[keyof typeof ${a}];' — or declare it as 'enum ${a} { … }'.`) : null;
99
+ const a = o.getText();
100
+ return (u ? (u.flags & r.SymbolFlags.Variable) !== 0 : F.statements.some((m) => r.isVariableStatement(m) && m.declarationList.declarations.some((v) => r.isIdentifier(v.name) && v.name.text === a))) ? void s(e, i.EnumMissingAlias, `'${a}' is a value, not a type: '${n}'. Pair the object with a same-name type — 'type ${a} = typeof ${a}[keyof typeof ${a}];' — or declare it as 'enum ${a} { … }'.`) : null;
99
101
  }
100
- const t = ee.get(u);
102
+ const t = te.get(u);
101
103
  if (t !== void 0) return t;
102
- if (ce.has(u)) return;
104
+ if (pe.has(u)) return;
103
105
  }
104
106
  const y = [];
105
- let x = !1;
107
+ let T = !1;
106
108
  if (u && u.flags & r.SymbolFlags.Enum) {
107
- if (!u.declarations?.some(ge)) return void o(e, i.EnumNotLocal, `'${u.name}' is not declared in this module: '${n}'. An enum must be declared in the module that uses it.`);
108
- x = !0;
109
+ if (!u.declarations?.some(ye)) return void s(e, i.EnumNotLocal, `'${u.name}' is not declared in this module: '${n}'. An enum must be declared in the module that uses it.`);
110
+ T = !0;
109
111
  let t = !1;
110
112
  if (u.exports?.forEach((a) => {
111
- const d = a.valueDeclaration;
112
- if (!d || !r.isEnumMember(d)) return;
113
- const v = $.getConstantValue(d);
114
- if (v === void 0) return o(d, i.EnumMemberNotConstant, `'${u.name}.${a.name}' is not a constant number or string. A formula passes the VALUE, so every member needs one that can be read at compile time.`), void (t = !0);
115
- y.push([te(a, !0), v, d, H(a.getDocumentationComment($)), ye(a)]);
116
- }), t) return void ce.add(u);
113
+ const m = a.valueDeclaration;
114
+ if (!m || !r.isEnumMember(m)) return;
115
+ const v = $.getConstantValue(m);
116
+ if (v === void 0) return s(m, i.EnumMemberNotConstant, `'${u.name}.${a.name}' is not a constant number or string. A formula passes the VALUE, so every member needs one that can be read at compile time.`), void (t = !0);
117
+ y.push([ne(a, !0), v, m, H(a.getDocumentationComment($)), fe(a)]);
118
+ }), t) return void pe.add(u);
117
119
  } else {
118
- const t = $.getTypeFromTypeNode(e), a = r.TypeFlags.Null | r.TypeFlags.Undefined | r.TypeFlags.Void, d = (t.isUnion() ? t.types : [t]).filter((g) => !(g.flags & a)), v = [];
119
- for (const g of d) {
120
- if (!(g.flags & (r.TypeFlags.NumberLiteral | r.TypeFlags.StringLiteral))) return u && ee.set(u, null), null;
120
+ const t = $.getTypeFromTypeNode(e), a = r.TypeFlags.Null | r.TypeFlags.Undefined | r.TypeFlags.Void, m = (t.isUnion() ? t.types : [t]).filter((g) => !(g.flags & a)), v = [];
121
+ for (const g of m) {
122
+ if (!(g.flags & (r.TypeFlags.NumberLiteral | r.TypeFlags.StringLiteral))) return u && te.set(u, null), null;
121
123
  v.push(g.value);
122
124
  }
123
125
  if (v.length === 0) return null;
124
- const D = u?.declarations?.find((g) => r.isTypeAliasDeclaration(g)), L = r.isUnionTypeNode(e) ? e : D?.type;
125
- if (L && r.isUnionTypeNode(L)) {
126
- const g = L.types.map((m) => {
127
- const k = $.getTypeFromTypeNode(m);
126
+ const D = u?.declarations?.find((g) => r.isTypeAliasDeclaration(g)), E = r.isUnionTypeNode(e) ? e : D?.type;
127
+ if (E && r.isUnionTypeNode(E)) {
128
+ const g = E.types.map((d) => {
129
+ const k = $.getTypeFromTypeNode(d);
128
130
  return k.isLiteral() ? k.value : void 0;
129
- }), c = (m) => {
130
- const k = g.indexOf(m);
131
+ }), c = (d) => {
132
+ const k = g.indexOf(d);
131
133
  return k < 0 ? g.length : k;
132
134
  };
133
- v.sort((m, k) => c(m) - c(k));
135
+ v.sort((d, k) => c(d) - c(k));
134
136
  }
135
137
  const R = u && u.flags & r.SymbolFlags.Variable ? u.valueDeclaration : void 0, P = new Set(v);
136
- if (u && R && ge(R)) for (const g of $.getTypeOfSymbolAtLocation(u, R).getProperties()) {
137
- const c = g.valueDeclaration, m = $.getTypeOfSymbolAtLocation(g, c ?? R);
138
- if (!(m.flags & (r.TypeFlags.NumberLiteral | r.TypeFlags.StringLiteral))) continue;
139
- const k = m.value;
140
- v.includes(k) && (x = !0, P.delete(k), y.push([te(g, !0), k, c, H(g.getDocumentationComment($)), ye(g)]));
138
+ if (u && R && ye(R)) for (const g of $.getTypeOfSymbolAtLocation(u, R).getProperties()) {
139
+ const c = g.valueDeclaration, d = $.getTypeOfSymbolAtLocation(g, c ?? R);
140
+ if (!(d.flags & (r.TypeFlags.NumberLiteral | r.TypeFlags.StringLiteral))) continue;
141
+ const k = d.value;
142
+ v.includes(k) && (T = !0, P.delete(k), y.push([ne(g, !0), k, c, H(g.getDocumentationComment($)), fe(g)]));
141
143
  }
142
144
  for (const g of v) P.has(g) && y.push([String(g), g, void 0, null]);
143
145
  }
144
146
  if (y.length === 0) return null;
145
- const T = typeof y[0][1] == "number";
146
- if (y.some(([, t]) => typeof t == "number" !== T)) return void o(e, i.EnumMixed, `'${u?.name ?? e.getText()}' mixes number and string members: '${n}'. A parameter has one type, so an enum is all numbers or all strings.`);
147
- const p = u ? te(u) : y.map(([, t]) => String(t)).join("|"), h = u ? void 0 : me.get(p);
147
+ const x = typeof y[0][1] == "number";
148
+ if (y.some(([, t]) => typeof t == "number" !== x)) return void s(e, i.EnumMixed, `'${u?.name ?? e.getText()}' mixes number and string members: '${n}'. A parameter has one type, so an enum is all numbers or all strings.`);
149
+ const p = u ? ne(u) : y.map(([, t]) => String(t)).join("|"), h = u ? void 0 : ue.get(p);
148
150
  if (h) return h;
149
- if (x) {
151
+ if (T) {
150
152
  const t = /* @__PURE__ */ new Map();
151
- for (const [a, d, v, D] of y) {
152
- const L = v?.name?.getText() ?? a, R = t.get(d);
153
- R !== void 0 ? U(v ?? e, i.EnumDuplicateValue, "warning", `'${p}.${L}' has the same value as '${p}.${R}' (${JSON.stringify(d)}). A formula passes the value, so the two cannot be told apart.`) : t.set(d, L), D === "" && U(v ?? e, i.EnumMemberUndocumented, "warning", `'${p}.${L}' is missing a description. Add a doc comment above the member — it is what the argument dropdown shows.`);
153
+ for (const [a, m, v, D] of y) {
154
+ const E = v?.name?.getText() ?? a, R = t.get(m);
155
+ R !== void 0 ? U(v ?? e, i.EnumDuplicateValue, "warning", `'${p}.${E}' has the same value as '${p}.${R}' (${JSON.stringify(m)}). A formula passes the value, so the two cannot be told apart.`) : t.set(m, E), D === "" && U(v ?? e, i.EnumMemberUndocumented, "warning", `'${p}.${E}' is missing a description. Add a doc comment above the member — it is what the argument dropdown shows.`);
154
156
  }
155
157
  }
156
- const E = { id: p, type: T ? _.Number : _.String, members: y.map(([t, a, , , d]) => d ? [t, a, d] : [t, a]) };
157
- u ? ee.set(u, E) : me.set(p, E);
158
+ const L = { id: p, type: x ? _.Number : _.String, members: y.map(([t, a, , , m]) => m ? [t, a, m] : [t, a]) };
159
+ u ? te.set(u, L) : ue.set(p, L);
158
160
  const b = u ? H(u.getDocumentationComment($)) : "", f = {};
159
161
  for (const [t, , , a] of y) a && (f[t] = { description: a });
160
162
  if (b || Object.keys(f).length > 0) {
161
163
  const t = {};
162
- b && (t.summary = b), Object.keys(f).length > 0 && (t.members = f), ue.set(E, t);
164
+ b && (t.summary = b), Object.keys(f).length > 0 && (t.members = f), ce.set(L, t);
163
165
  }
164
- return E;
165
- }, M = (e, n, s, l, u, y = !1, x = !1, T = !1) => {
166
+ return L;
167
+ }, M = (e, n, o, l, u, y = !1, T = !1, x = !1) => {
166
168
  if (e) {
167
- if (e.kind === r.SyntaxKind.ParenthesizedType) return M(e.type, n, s, l, u, y, x, T);
169
+ if (e.kind === r.SyntaxKind.ParenthesizedType) return M(e.type, n, o, l, u, y, T, x);
168
170
  if (e.kind === r.SyntaxKind.UnionType) {
169
171
  const p = (b) => b.kind === r.SyntaxKind.UndefinedKeyword || b.kind === r.SyntaxKind.VoidKeyword || b.kind === r.SyntaxKind.NullKeyword || b.kind === r.SyntaxKind.LiteralType && b.literal?.kind === r.SyntaxKind.NullKeyword, h = e.types.filter((b) => !p(b));
170
- if (h.length === 1) return M(h[0], n, s, l, u, y, x, T);
171
- const E = ne(e, n.name ?? N(e));
172
- if (E === void 0) return;
173
- if (E !== null) return n.scalar = E.type, void (l && (n.enum = E));
172
+ if (h.length === 1) return M(h[0], n, o, l, u, y, T, x);
173
+ const L = re(e, n.name ?? N(e));
174
+ if (L === void 0) return;
175
+ if (L !== null) return n.scalar = L.type, void (l && (n.enum = L));
174
176
  if (!l) return void (n.scalar = "*");
175
177
  if (h.length === 2) {
176
178
  const b = (t) => t.kind === r.SyntaxKind.TypeReference && r.isTypeReferenceNode(t) && q(t) === "Lambda", f = h.findIndex(b);
177
- if (f >= 0 && !b(h[1 - f])) return M(h[1 - f], n, s, l, u, y, x, T), void de(h[f], q(h[f]), n, s, l);
179
+ if (f >= 0 && !b(h[1 - f])) return M(h[1 - f], n, o, l, u, y, T, x), void me(h[f], q(h[f]), n, o, l);
178
180
  }
179
181
  if (l && h.length === 2) {
180
182
  const b = (t) => {
181
- if (t.kind === r.SyntaxKind.TypeReference && !t.typeArguments?.length) return oe.get(q(t));
183
+ if (t.kind === r.SyntaxKind.TypeReference && !t.typeArguments?.length) return se.get(q(t));
182
184
  }, f = h.findIndex((t) => b(t) !== void 0);
183
185
  if (f >= 0 && b(h[1 - f]) === void 0) {
184
186
  const t = {}, a = u.count;
185
- if (M(h[1 - f], t, s, l, u, y, !1), t.scalar && !t.range && t.lambda == null && u.count === a) {
187
+ if (M(h[1 - f], t, o, l, u, y, !1), t.scalar && !t.range && t.lambda == null && u.count === a) {
186
188
  n.range = b(h[f]), n.scalar = t.scalar, n.valueOrRange = !0;
187
- const d = t.enum;
188
- return void (d && (n.enum = d));
189
+ const m = t.enum;
190
+ return void (m && (n.enum = m));
189
191
  }
190
192
  }
191
193
  }
192
194
  if (l && h.length === 2) {
193
195
  const b = (t) => t.kind === r.SyntaxKind.TypeReference && !t.typeArguments?.length && q(t) === "Scalar", f = h.findIndex(b);
194
196
  if (f >= 0 && !b(h[1 - f])) {
195
- const t = ne(h[1 - f], n.name ?? N(e));
197
+ const t = re(h[1 - f], n.name ?? N(e));
196
198
  if (t === void 0) return;
197
199
  if (t !== null) return n.scalar = "*", void (n.enum = t);
198
200
  }
199
201
  }
200
- return void o(e, i.InvalidParamType, `Union parameter types are not supported: '${N(e)}'. Use a single type, optionally with '| null' or '| undefined', 'T | Lambda<…>' for a value-or-lambda slot, 'IRange | Scalar' for a value-or-range slot, or 'E | Scalar' for an uncoerced slot whose values an enum documents.`);
202
+ return void s(e, i.InvalidParamType, `Union parameter types are not supported: '${N(e)}'. Use a single type, optionally with '| null' or '| undefined', 'T | Lambda<…>' for a value-or-lambda slot, 'IRange | Scalar' for a value-or-range slot, or 'E | Scalar' for an uncoerced slot whose values an enum documents.`);
201
203
  }
202
204
  if (e.kind === r.SyntaxKind.NumberKeyword) n.scalar = _.Number;
203
205
  else if (e.kind === r.SyntaxKind.StringKeyword) n.scalar = _.String;
204
206
  else if (e.kind === r.SyntaxKind.BooleanKeyword) n.scalar = _.Boolean;
205
207
  else if (e.kind === r.SyntaxKind.UndefinedKeyword || e.kind === r.SyntaxKind.NullKeyword || e.kind === r.SyntaxKind.VoidKeyword) {
206
- if (l) return void o(e, i.UndefinedInput, `'undefined' is not a valid type for input: '${N(e)}'.`);
208
+ if (l) return void s(e, i.UndefinedInput, `'undefined' is not a valid type for input: '${N(e)}'.`);
207
209
  n.scalar = _.Null;
208
210
  } else if (e.kind === r.SyntaxKind.BigIntKeyword) n.scalar = _.Number;
209
211
  else if (e.kind === r.SyntaxKind.AnyKeyword) l && (n.range = "*");
210
212
  else if (e.kind === r.SyntaxKind.ArrayType) {
211
213
  const p = e.elementType;
212
- if (!p) return void o(e, i.UntypedArray, `'Array' must be typed: '${N(e)}'.`);
213
- if (l && x) {
214
- const h = n, E = h.name ?? N(e) ?? "parameter", b = h.acceptError;
214
+ if (!p) return void s(e, i.UntypedArray, `'Array' must be typed: '${N(e)}'.`);
215
+ if (l && T) {
216
+ const h = n, L = h.name ?? N(e) ?? "parameter", b = h.acceptError;
215
217
  delete h.acceptError;
216
- const f = { name: E };
217
- return Z(p, f, s, !0), b && !f.acceptError && (f.acceptError = !0), void (h.repeating = [f]);
218
+ const f = { name: L };
219
+ return Z(p, f, o, !0), b && !f.acceptError && (f.acceptError = !0), void (h.repeating = [f]);
218
220
  }
219
- u.count++, M(p, n, s, l, u);
221
+ u.count++, M(p, n, o, l, u);
220
222
  } else if (e.kind !== r.SyntaxKind.TupleType) if (e.kind === r.SyntaxKind.TypeReference) {
221
223
  const p = q(e);
222
- if (we.has(p)) {
224
+ if (Se.has(p)) {
223
225
  const t = N(e);
224
- if (!l) return void o(e, i.InvalidReturnType, `'${p}' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
226
+ if (!l) return void s(e, i.InvalidReturnType, `'${p}' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
225
227
  const a = n;
226
- if (a.acceptError) return void o(e, i.InvalidParamType, `'${t}' declares 'AcceptError' more than once.`);
227
- const d = e.typeArguments;
228
- return d && d.length === 1 ? (a.acceptError = !0, M(d[0], n, s, l, u, y, x, T)) : void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
228
+ if (a.acceptError) return void s(e, i.InvalidParamType, `'${t}' declares 'AcceptError' more than once.`);
229
+ const m = e.typeArguments;
230
+ return m && m.length === 1 ? (a.acceptError = !0, M(m[0], n, o, l, u, y, T, x)) : void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
229
231
  }
230
- if (se.has(p)) {
232
+ if (le.has(p)) {
231
233
  const t = n.name ?? N(e);
232
- if (!l) return void o(e, i.InvalidReturnType, `'ReportType' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
234
+ if (!l) return void s(e, i.InvalidReturnType, `'ReportType' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
233
235
  const a = e.typeArguments;
234
- return a && a.length === 1 ? (n.reportType = !0, M(a[0], n, s, l, u, y, x, T)) : void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
236
+ return a && a.length === 1 ? (n.reportType = !0, M(a[0], n, o, l, u, y, T, x)) : void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
235
237
  }
236
- if (ke.has(p)) {
238
+ if (Ae.has(p)) {
237
239
  const t = n.name ?? N(e);
238
- if (!l) return void o(e, i.InvalidReturnType, `'NoLift' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
240
+ if (!l) return void s(e, i.InvalidReturnType, `'NoLift' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
239
241
  const a = e.typeArguments;
240
- if (!a || a.length !== 1) return void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
241
- const d = n;
242
- d.noLift = !0;
242
+ if (!a || a.length !== 1) return void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
243
+ const m = n;
244
+ m.noLift = !0;
243
245
  const v = u.count;
244
- return M(a[0], n, s, l, u, y, x, T), void ((d.range || d.lambda != null || d.repeating || u.count !== v) && o(e, i.InvalidParamType, `'${t}': 'NoLift' applies to a SCALAR parameter only - a range, list, repeating or lambda slot never lifts.`));
246
+ return M(a[0], n, o, l, u, y, T, x), void ((m.range || m.lambda != null || m.repeating || u.count !== v) && s(e, i.InvalidParamType, `'${t}': 'NoLift' applies to a SCALAR parameter only - a range, list, repeating or lambda slot never lifts.`));
245
247
  }
246
- if (Ae.has(p)) {
248
+ if (Re.has(p)) {
247
249
  const t = n.name ?? N(e);
248
- if (!l) return void o(e, i.InvalidReturnType, `'NoFilter' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
250
+ if (!l) return void s(e, i.InvalidReturnType, `'NoFilter' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
249
251
  const a = e.typeArguments;
250
- if (!a || a.length !== 1) return void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
251
- const d = n;
252
- d.noFilter = !0;
252
+ if (!a || a.length !== 1) return void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
253
+ const m = n;
254
+ m.noFilter = !0;
253
255
  const v = u.count;
254
- if (M(a[0], n, s, l, u, y, x, T), d.range || d.lambda != null || u.count !== v) return void o(e, i.InvalidParamType, `'${t}': 'NoFilter' applies to a SCALAR slot only - a range, list or lambda slot has no members to coerce.`);
255
- const D = d.repeating;
256
+ if (M(a[0], n, o, l, u, y, T, x), m.range || m.lambda != null || u.count !== v) return void s(e, i.InvalidParamType, `'${t}': 'NoFilter' applies to a SCALAR slot only - a range, list or lambda slot has no members to coerce.`);
257
+ const D = m.repeating;
256
258
  if (D) {
257
- if (delete d.noFilter, D.length !== 1) return void o(e, i.InvalidParamType, `'${t}': 'NoFilter' over a repeating group applies to a period-1 group only - write it on the slot that takes the members.`);
259
+ if (delete m.noFilter, D.length !== 1) return void s(e, i.InvalidParamType, `'${t}': 'NoFilter' over a repeating group applies to a period-1 group only - write it on the slot that takes the members.`);
258
260
  D[0].noFilter = !0;
259
- } else x && o(e, i.InvalidParamType, `'${t}': 'NoFilter' applies to a REPEATING slot only - a single scalar argument has no members to coerce.`);
261
+ } else T && s(e, i.InvalidParamType, `'${t}': 'NoFilter' applies to a REPEATING slot only - a single scalar argument has no members to coerce.`);
260
262
  return;
261
263
  }
262
- if (Se.has(p)) {
264
+ if (ke.has(p)) {
263
265
  const t = n.name ?? N(e);
264
- if (!l) return void o(e, i.InvalidReturnType, `'Omittable' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
266
+ if (!l) return void s(e, i.InvalidReturnType, `'Omittable' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
265
267
  const a = e.typeArguments;
266
- if (!a || a.length < 1 || a.length > 2) return void o(e, i.GenericArity, `'${p}' must be typed with 1 or 2 types: '${t}'.`);
267
- const d = n;
268
- if (d.omittable = !0, a.length === 2) {
269
- const L = Te(r, a[1]);
270
- if (L === void 0) return void o(e, i.InvalidParamType, `'${t}' declares '${p}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an omitted argument.`);
271
- d.omittedValue = L;
268
+ if (!a || a.length < 1 || a.length > 2) return void s(e, i.GenericArity, `'${p}' must be typed with 1 or 2 types: '${t}'.`);
269
+ const m = n;
270
+ if (m.omittable = !0, a.length === 2) {
271
+ const E = Te(r, a[1]);
272
+ if (E === void 0) return void s(e, i.InvalidParamType, `'${t}' declares '${p}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an omitted argument.`);
273
+ m.omittedValue = E;
272
274
  }
273
- const v = M(a[0], n, s, l, u, y, x, T), D = d.omittedValue;
274
- return d.enum && D != null && !d.enum.members.some(([, L]) => L === D) && o(a[1], i.EnumOmittedValue, `'${t}': ${JSON.stringify(D)} is not a member of '${d.enum.id}'. An omitted argument must mean a member (${d.enum.members.map(([, L]) => JSON.stringify(L)).join(", ")}) or null.`), v;
275
+ const v = M(a[0], n, o, l, u, y, T, x), D = m.omittedValue;
276
+ return m.enum && D != null && !m.enum.members.some(([, E]) => E === D) && s(a[1], i.EnumOmittedValue, `'${t}': ${JSON.stringify(D)} is not a member of '${m.enum.id}'. An omitted argument must mean a member (${m.enum.members.map(([, E]) => JSON.stringify(E)).join(", ")}) or null.`), v;
275
277
  }
276
- if (Re.has(p)) {
278
+ if (Ke.has(p)) {
277
279
  const t = n.name ?? N(e);
278
- if (!l) return void o(e, i.InvalidReturnType, `'Lazy' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
280
+ if (!l) return void s(e, i.InvalidReturnType, `'Lazy' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
279
281
  const a = n;
280
- if (a.lazy) return void o(e, i.InvalidParamType, `'${t}' declares 'Lazy' more than once.`);
281
- const d = e.typeArguments;
282
- if (!d || d.length < 1 || d.length > 2) return void o(e, i.GenericArity, `'${p}' must be typed with 1 or 2 types: '${t}'.`);
283
- if (a.lazy = !0, d.length === 2) {
284
- const v = Te(r, d[1]);
285
- if (v === void 0) return void o(e, i.InvalidParamType, `'${t}' declares '${p}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an absent argument.`);
282
+ if (a.lazy) return void s(e, i.InvalidParamType, `'${t}' declares 'Lazy' more than once.`);
283
+ const m = e.typeArguments;
284
+ if (!m || m.length < 1 || m.length > 2) return void s(e, i.GenericArity, `'${p}' must be typed with 1 or 2 types: '${t}'.`);
285
+ if (a.lazy = !0, m.length === 2) {
286
+ const v = Te(r, m[1]);
287
+ if (v === void 0) return void s(e, i.InvalidParamType, `'${t}' declares '${p}' with a second type that is not a literal value. Use a number, string, boolean or null - the engine substitutes it for an absent argument.`);
286
288
  a.optional = !0, a.defaultValue = v;
287
289
  }
288
- return M(d[0], n, s, l, u, y, x, T), void (a.enum ? (o(e, i.EnumPosition, `'${t}': 'Lazy' cannot hold the enum '${a.enum.id}'. The argument may never be evaluated, so there is no point at which it could be checked against the members.`), delete a.enum) : a.lambda != null ? o(e, i.InvalidParamType, `'${t}': 'Lazy' cannot be combined with a Lambda parameter - a callable slot is already the body's to call, or not.`) : a.repeating && o(e, i.InvalidParamType, `'${t}': 'Lazy' applies to a VALUE, not to a repeating group - mark the group's slots instead.`));
290
+ return M(m[0], n, o, l, u, y, T, x), void (a.enum ? (s(e, i.EnumPosition, `'${t}': 'Lazy' cannot hold the enum '${a.enum.id}'. The argument may never be evaluated, so there is no point at which it could be checked against the members.`), delete a.enum) : a.lambda != null ? s(e, i.InvalidParamType, `'${t}': 'Lazy' cannot be combined with a Lambda parameter - a callable slot is already the body's to call, or not.`) : a.repeating && s(e, i.InvalidParamType, `'${t}': 'Lazy' applies to a VALUE, not to a repeating group - mark the group's slots instead.`));
289
291
  }
290
- if (De.has(p)) {
292
+ if (Me.has(p)) {
291
293
  const t = n.name ?? N(e);
292
- if (!l) return void o(e, i.InvalidReturnType, `'Flatten' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
294
+ if (!l) return void s(e, i.InvalidReturnType, `'Flatten' is not a valid return type: '${t}'. It describes how an ARGUMENT is received.`);
293
295
  const a = e.typeArguments;
294
- return a && a.length === 1 ? (u.count++, M(a[0], n, s, l, u, y)) : void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
296
+ return a && a.length === 1 ? (u.count++, M(a[0], n, o, l, u, y)) : void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${t}'.`);
295
297
  }
296
- if (xe.get(p) === "repeating") {
298
+ if (we.get(p) === "repeating") {
297
299
  const t = n.name ?? N(e);
298
- if (!l) return void o(e, i.RepeatingPosition, `'Repeating' is not a valid return type: '${t}'.`);
299
- if (u.count !== 0) return void o(e, i.RepeatingPosition, `'Repeating' cannot be nested inside another type: '${t}'.`);
300
- const a = n, d = e.typeArguments;
301
- if (!d || d.length < 1 || d.length > 2) return void o(e, i.GenericArity, `'${p}' must be typed with 1 type, optionally followed by a maximum argument count: '${t}'.`);
300
+ if (!l) return void s(e, i.RepeatingPosition, `'Repeating' is not a valid return type: '${t}'.`);
301
+ if (u.count !== 0) return void s(e, i.RepeatingPosition, `'Repeating' cannot be nested inside another type: '${t}'.`);
302
+ const a = n, m = e.typeArguments;
303
+ if (!m || m.length < 1 || m.length > 2) return void s(e, i.GenericArity, `'${p}' must be typed with 1 type, optionally followed by a maximum argument count: '${t}'.`);
302
304
  let v;
303
- if (d.length === 2) {
304
- const R = d[1], P = R.kind === r.SyntaxKind.LiteralType ? R.literal : null, g = P && P.kind === r.SyntaxKind.NumericLiteral ? Number(P.text) : NaN;
305
- if (!Number.isInteger(g) || g < 1 || g > 255) return void o(R, i.RepeatingMax, `'${t}': '${p}'’s maximum must be a whole number between 1 and 255.`);
306
- v = g, s.maxArguments = g;
305
+ if (m.length === 2) {
306
+ const R = m[1], P = R.kind === r.SyntaxKind.LiteralType ? R.literal : null, g = P && P.kind === r.SyntaxKind.NumericLiteral ? Number(P.text) : NaN;
307
+ if (!Number.isInteger(g) || g < 1 || g > 255) return void s(R, i.RepeatingMax, `'${t}': '${p}'’s maximum must be a whole number between 1 and 255.`);
308
+ v = g, o.maxArguments = g;
307
309
  }
308
- if (T) return v === void 0 ? void o(e, i.RepeatingPosition, `'${t}' is a rest parameter and a repeating group. A group already repeats — drop the '...', or give the group a maximum ('Repeating<T, 254>') if the ceiling is all you meant.`) : M(d[0], n, s, l, u, y, x);
310
+ if (x) return v === void 0 ? void s(e, i.RepeatingPosition, `'${t}' is a rest parameter and a repeating group. A group already repeats — drop the '...', or give the group a maximum ('Repeating<T, 254>') if the ceiling is all you meant.`) : M(m[0], n, o, l, u, y, T);
309
311
  const D = a.acceptError;
310
312
  delete a.acceptError;
311
- const L = ((R, P, g, c) => {
312
- const m = (C, K, S) => {
313
+ const E = ((R, P, g, c) => {
314
+ const d = (C, K, S) => {
313
315
  const w = { name: C };
314
316
  return Z(K, w, g, !0), S && (w.optional = !0), c && !w.acceptError && (w.acceptError = !0), w;
315
317
  };
316
- if (R.kind !== r.SyntaxKind.TupleType) return [m(P, R, !1)];
318
+ if (R.kind !== r.SyntaxKind.TupleType) return [d(P, R, !1)];
317
319
  const k = R.elements;
318
- if (k.length < 2) return o(R, i.RepeatingSlots, `'${P}': a repeating group of period ${k.length} must be spelled 'Repeating<T>' without the tuple.`), null;
320
+ if (k.length < 2) return s(R, i.RepeatingSlots, `'${P}': a repeating group of period ${k.length} must be spelled 'Repeating<T>' without the tuple.`), null;
319
321
  const j = [];
320
322
  for (let C = 0; C < k.length; C++) {
321
323
  const K = k[C];
322
- if (K.kind !== r.SyntaxKind.NamedTupleMember) return o(K, i.RepeatingSlots, `'${P}': every slot of a repeating group must be labelled, e.g. 'Repeating<[criteriaRange: IRange, criteria: Scalar]>'.`), null;
324
+ if (K.kind !== r.SyntaxKind.NamedTupleMember) return s(K, i.RepeatingSlots, `'${P}': every slot of a repeating group must be labelled, e.g. 'Repeating<[criteriaRange: IRange, criteria: Scalar]>'.`), null;
323
325
  const S = !!K.questionToken;
324
- if (S && C !== k.length - 1) return o(K, i.RepeatingOptional, `'${P}': only the LAST slot of a repeating group may be optional (slot '${K.name?.getText?.()}' is not).`), null;
325
- j.push(m(K.name?.getText?.() ?? `${C}`, K.type, S));
326
+ if (S && C !== k.length - 1) return s(K, i.RepeatingOptional, `'${P}': only the LAST slot of a repeating group may be optional (slot '${K.name?.getText?.()}' is not).`), null;
327
+ j.push(d(K.name?.getText?.() ?? `${C}`, K.type, S));
326
328
  }
327
329
  return j;
328
- })(d[0], t ?? "parameter", s, D);
329
- return void (L && (a.repeating = L));
330
+ })(m[0], t ?? "parameter", o, D);
331
+ return void (E && (a.repeating = E));
330
332
  }
331
- const h = oe.get(p);
332
- let E = !1;
333
- h && (n.range = h, E = !0);
334
- const b = Fe.get(p);
335
- if (b && (n.scalar = b), b !== void 0 && (E = !0), de(e, p, n, s, l)) return;
333
+ const h = se.get(p);
334
+ let L = !1;
335
+ h && (n.range = h, L = !0);
336
+ const b = De.get(p);
337
+ if (b && (n.scalar = b), b !== void 0 && (L = !0), me(e, p, n, o, l)) return;
336
338
  if (l) {
337
- if (p === "Volatile" || p === `${V}.Volatile`) return void o(e, i.InvalidParamType, `'Volatile' is not a valid parameter type: '${N(e)}'. It describes the function's RESULT, so it belongs on the return type.`);
338
- if (ze.has(p)) return $e;
339
- const t = le.get(p);
339
+ if (p === "Volatile" || p === `${V}.Volatile`) return void s(e, i.InvalidParamType, `'Volatile' is not a valid parameter type: '${N(e)}'. It describes the function's RESULT, so it belongs on the return type.`);
340
+ if (Oe.has(p)) return be;
341
+ const t = de.get(p);
340
342
  if (t) return t;
341
- } else {
342
- const t = Pe.get(p);
343
- if (t) {
344
- const a = Object.assign(n, t());
345
- let d = 0;
346
- if (a.async && d++, a.stream && d++, d > 1) return void o(e, i.MultipleModifiers, `'${p}' cannot have multiple modifiers: '${N(e)}'.`);
347
- E = !0;
348
- }
343
+ } else if (p === "Promise") Y = e, L = !0;
344
+ else {
345
+ const t = ze.get(p);
346
+ t && (Object.assign(n, t()), L = !0);
349
347
  }
350
- if (!E) {
351
- const t = ne(e, n.name ?? N(e));
348
+ if (!L) {
349
+ const t = re(e, n.name ?? N(e));
352
350
  if (t === void 0) return;
353
351
  if (t !== null) return n.scalar = t.type, void (l && (n.enum = t));
354
352
  }
355
- if (!E) {
356
- const t = "number, string, boolean, Scalar, Lambda, Date, FormulaError.Known, IRichData, IRange, IReferenceRange (and arrays of these; optionally wrapped in AcceptError<T>, or grouped with Repeating<T>)", a = "number, string, boolean, Scalar, Date, FormulaError.Known, IRichData, IRange, Promise<T>, Observable<T>, Volatile<T> (and arrays of these)";
357
- let d;
358
- return d = l ? y ? `'${p}' is not a valid first parameter: '${N(e)}'. The first parameter is EITHER a macro target (making this a macro) OR a calculation input (making this a calculation function). Allowed: ${Ie.join(", ")} (macro target); ${t} (calculation input).` : `'${p}' is not a valid parameter type: '${N(e)}'. Allowed: ${t}.` : `'${p}' is not a valid return type: '${N(e)}'. Allowed: ${a}.`, void o(e, l ? i.InvalidParamType : i.InvalidReturnType, d);
353
+ if (!L) {
354
+ const t = "number, string, boolean, Scalar, Lambda, Date, FormulaError.Known, IRichData, IRange, IReferenceRange (and arrays of these; optionally wrapped in AcceptError<T>, or grouped with Repeating<T>)", a = "number, string, boolean, Scalar, Date, FormulaError.Known, IRichData, IRange, Volatile<T> (and arrays of these)";
355
+ let m;
356
+ return m = l ? y ? `'${p}' is not a valid first parameter: '${N(e)}'. The first parameter is EITHER a macro target (making this a macro) OR a calculation input (making this a calculation function). Allowed: ${Fe.join(", ")} (macro target); ${t} (calculation input).` : `'${p}' is not a valid parameter type: '${N(e)}'. Allowed: ${t}.` : `'${p}' is not a valid return type: '${N(e)}'. Allowed: ${a}.`, void s(e, l ? i.InvalidParamType : i.InvalidReturnType, m);
359
357
  }
360
358
  const f = e.typeArguments;
361
359
  if (f) {
362
- if (f.length !== 1) return void o(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${N(e)}'.`);
363
- const t = f[0], a = l && r.isTypeReferenceNode(t) && se.has(q(t)), d = n.reportType;
364
- a && pe.add(n), Z(t, n, s, l), a && d === void 0 && delete n.reportType;
360
+ if (f.length !== 1) return void s(e, i.GenericArity, `'${p}' must be typed with exactly 1 type: '${N(e)}'.`);
361
+ const t = f[0], a = l && r.isTypeReferenceNode(t) && le.has(q(t)), m = n.reportType;
362
+ a && ge.add(n), Z(t, n, o, l), a && m === void 0 && delete n.reportType;
365
363
  const v = n.enum;
366
- v && !a && (o(f[0], i.EnumPosition, `'${p}' cannot hold the enum '${v.id}': '${N(e)}'. The members of a range reach the body as they are, so nothing checks them against the enum. Take the enum as a value, or type the range by its scalar ('${p}<${v.type}>').`), delete n.enum);
364
+ v && !a && (s(f[0], i.EnumPosition, `'${p}' cannot hold the enum '${v.id}': '${N(e)}'. The members of a range reach the body as they are, so nothing checks them against the enum. Take the enum as a value, or type the range by its scalar ('${p}<${v.type}>').`), delete n.enum);
367
365
  }
368
- } else e.kind === r.SyntaxKind.FunctionType && ((p, h, E, b) => {
369
- if (!b) return void o(p, i.FunctionReturn, `Function type is not a valid return type: '${N(p)}'. Declare a 'Lambda' return instead.`);
366
+ } else e.kind === r.SyntaxKind.FunctionType && ((p, h, L, b) => {
367
+ if (!b) return void s(p, i.FunctionReturn, `Function type is not a valid return type: '${N(p)}'. Declare a 'Lambda' return instead.`);
370
368
  const f = p.type, t = {};
371
369
  let a = "*";
372
- f && (f.kind === r.SyntaxKind.AnyKeyword ? a = "raw" : (M(f, t, E, !1, { count: 0 }), a = t.scalar ?? "*"));
373
- const d = p.parameters;
374
- d && !d.some((v) => v.dotDotDotToken) && (h.lambdaArity = d.length), h.lambda = a;
375
- })(e, n, s, l);
376
- } else o(e, i.MissingType, `Type is not defined for '${n?.name ?? "return"}'.`);
370
+ f && (f.kind === r.SyntaxKind.AnyKeyword ? a = "raw" : (M(f, t, L, !1, { count: 0 }), a = t.scalar ?? "*"));
371
+ const m = p.parameters;
372
+ m && !m.some((v) => v.dotDotDotToken) && (h.lambdaArity = m.length), h.lambda = a;
373
+ })(e, n, o, l);
374
+ } else s(e, i.MissingType, `Type is not defined for '${n?.name ?? "return"}'.`);
377
375
  };
378
376
  try {
379
377
  r.forEachChild(F, (e) => {
380
378
  if (((n) => (r.getCombinedModifierFlags(n) & r.ModifierFlags.Export) !== 0)(e) && r.isFunctionDeclaration(e)) {
381
379
  const n = e?.name?.getText();
382
- if (!e.body) return void o(e, i.NoBody, `'${n}': function has no body.`);
383
- if (!n) return void o(e, i.Anonymous, "Anonymous exported functions are not allowed.");
384
- const s = {}, l = { parameters: {} };
380
+ if (!e.body) return void s(e, i.NoBody, `'${n}': function has no body.`);
381
+ if (!n) return void s(e, i.Anonymous, "Anonymous exported functions are not allowed.");
382
+ const o = {}, l = { parameters: {} };
385
383
  try {
386
- s.name = n;
384
+ o.name = n;
387
385
  const u = $.getSymbolAtLocation(e.name), y = H(u?.getDocumentationComment($));
388
386
  y && (l.summary = y);
389
- const x = {};
390
- Z(e.type, x, s, !1), s.returnType = x;
391
387
  const T = {};
392
- ((g) => (r.getCombinedModifierFlags(g) & r.ModifierFlags.Default) !== 0)(e) && (T.default = !0, X = n), s.parameters = [];
393
- const p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set();
394
- let b = null, f = null, t = null, a = 0, d = !1, v = 0;
388
+ Y = null, Z(e.type, T, o, !1), o.returnType = T;
389
+ const x = {};
390
+ ((g) => (r.getCombinedModifierFlags(g) & r.ModifierFlags.Default) !== 0)(e) && (x.default = !0, X = n), o.parameters = [];
391
+ const p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Set();
392
+ let b = null, f = null, t = null, a = 0, m = !1, v = 0;
395
393
  for (let g = 0; g < e.parameters.length; g++) {
396
- const c = e.parameters[g], m = {};
397
- m.name = c.name?.getText();
398
- const k = s.parameters.length === 0;
399
- if (A?.lenient && g === 0 && !c.type && T.default) {
400
- s.context = be;
394
+ const c = e.parameters[g], d = {};
395
+ d.name = c.name?.getText();
396
+ const k = o.parameters.length === 0;
397
+ if (A?.lenient && g === 0 && !c.type && x.default) {
398
+ o.context = xe;
401
399
  continue;
402
400
  }
403
- const j = Z(c.type, m, s, !0, k, !c.dotDotDotToken, !!c.dotDotDotToken);
404
- if (j === $e) {
405
- g === 0 && s.context === void 0 && (s.context = be);
401
+ const j = Z(c.type, d, o, !0, k, !c.dotDotDotToken, !!c.dotDotDotToken);
402
+ if (j === be) {
403
+ g === 0 && o.context === void 0 && (o.context = xe);
406
404
  continue;
407
405
  }
408
406
  if (j) {
409
- if (s.parameters.length !== 0) return void o(c, i.ContextNotFirst, `'${s.name}' contexts must be the first parameter: '${m.name}'.`);
410
- s.context = j;
407
+ if (o.parameters.length !== 0) return void s(c, i.ContextNotFirst, `'${o.name}' contexts must be the first parameter: '${d.name}'.`);
408
+ o.context = j;
411
409
  continue;
412
410
  }
413
- if (m.lambda !== void 0) {
414
- if (b !== null) return void o(c, i.MultipleLambda, `'${s.name}' has more than one Lambda parameter ('${b}' and '${m.name}'). Only one Lambda parameter is allowed.`);
415
- b = m.name;
416
- } else if (b !== null) return void o(c, i.LambdaNotLast, `'${s.name}' Lambda parameter ('${b}') must be the last parameter, but '${m.name}' follows it.`);
417
- const C = m.optional === !0 || c.initializer !== void 0 && c.initializer !== null || c.questionToken !== void 0 && c.questionToken !== null;
411
+ if (d.lambda !== void 0) {
412
+ if (b !== null) return void s(c, i.MultipleLambda, `'${o.name}' has more than one Lambda parameter ('${b}' and '${d.name}'). Only one Lambda parameter is allowed.`);
413
+ b = d.name;
414
+ } else if (b !== null) return void s(c, i.LambdaNotLast, `'${o.name}' Lambda parameter ('${b}') must be the last parameter, but '${d.name}' follows it.`);
415
+ const C = d.optional === !0 || c.initializer !== void 0 && c.initializer !== null || c.questionToken !== void 0 && c.questionToken !== null;
418
416
  let K;
419
- if (C && (m.optional = !0, c.initializer)) try {
417
+ if (C && (d.optional = !0, c.initializer)) try {
420
418
  if (c.initializer.kind === r.SyntaxKind.StringLiteral) K = c.initializer.text;
421
419
  else if (c.initializer.kind === r.SyntaxKind.NumericLiteral) K = parseFloat(c.initializer.text);
422
420
  else if (c.initializer.kind === r.SyntaxKind.TrueKeyword || c.initializer.kind === r.SyntaxKind.FalseKeyword) K = c.initializer.kind === r.SyntaxKind.TrueKeyword;
@@ -427,56 +425,56 @@ function Oe(r, F, $, A) {
427
425
  O.flags & (r.TypeFlags.NumberLiteral | r.TypeFlags.StringLiteral) && (K = O.value);
428
426
  }
429
427
  } catch (O) {
430
- console.warn(`Couldn't extract default value for parameter '${m.name}'`, O);
428
+ console.warn(`Couldn't extract default value for parameter '${d.name}'`, O);
431
429
  }
432
- c.dotDotDotToken && (m.rest = !0);
433
- const S = m.repeating;
430
+ c.dotDotDotToken && (d.rest = !0);
431
+ const S = d.repeating;
434
432
  if (S) {
435
- if (m.rest) return void o(c, i.RepeatingPosition, `'${s.name}' parameter '${m.name}' is both a rest parameter and a repeating group. A group already repeats — drop the '...'.`);
436
- if (C && S.length === 1) return void o(c, i.RepeatingOptional, `'${s.name}' parameter '${m.name}' cannot be an optional repeating group. Use '...${m.name}: T[]' for zero-or-more, or drop the '?' for one-or-more.`);
437
- if (f !== null) return void o(c, i.MultipleRepeating, `'${s.name}' has more than one repeating group ('${f}' and '${m.name}'). Only one is allowed — two would make the argument count ambiguous.`);
438
- if (t !== null) return void o(c, i.RepeatingOptional, `'${s.name}' parameter '${t}' is optional and precedes the repeating group '${m.name}'. Every parameter outside a group must be required.`);
439
- f = m.name, a = S.length, d = S[S.length - 1].optional === !0;
433
+ if (d.rest) return void s(c, i.RepeatingPosition, `'${o.name}' parameter '${d.name}' is both a rest parameter and a repeating group. A group already repeats — drop the '...'.`);
434
+ if (C && S.length === 1) return void s(c, i.RepeatingOptional, `'${o.name}' parameter '${d.name}' cannot be an optional repeating group. Use '...${d.name}: T[]' for zero-or-more, or drop the '?' for one-or-more.`);
435
+ if (f !== null) return void s(c, i.MultipleRepeating, `'${o.name}' has more than one repeating group ('${f}' and '${d.name}'). Only one is allowed — two would make the argument count ambiguous.`);
436
+ if (t !== null) return void s(c, i.RepeatingOptional, `'${o.name}' parameter '${t}' is optional and precedes the repeating group '${d.name}'. Every parameter outside a group must be required.`);
437
+ f = d.name, a = S.length, m = S[S.length - 1].optional === !0;
440
438
  } else {
441
- if (f !== null && m.rest) return void o(c, i.RepeatingOptional, `'${s.name}' parameter '${m.name}' is a rest parameter and follows the repeating group '${f}'. Two variadic tails would make the argument count ambiguous.`);
439
+ if (f !== null && d.rest) return void s(c, i.RepeatingOptional, `'${o.name}' parameter '${d.name}' is a rest parameter and follows the repeating group '${f}'. Two variadic tails would make the argument count ambiguous.`);
442
440
  if (f !== null && C) {
443
- if (v >= a - 1) return void o(c, i.RepeatingOptional, a === 1 ? `'${s.name}' parameter '${m.name}' is optional and follows the period-1 repeating group '${f}'. One more argument is indistinguishable from one more repetition — make it required, or give the group a period.` : `'${s.name}' has ${v + 1} optional parameters after the repeating group '${f}', which has period ${a}. At most ${a - 1} may be optional, or the argument count no longer decides the parse.`);
444
- if (d) return void o(c, i.RepeatingOptional, `'${s.name}' parameter '${m.name}' is optional and follows '${f}', whose own last slot is already optional. Both omissions reach the same argument count — drop one.`);
441
+ if (v >= a - 1) return void s(c, i.RepeatingOptional, a === 1 ? `'${o.name}' parameter '${d.name}' is optional and follows the period-1 repeating group '${f}'. One more argument is indistinguishable from one more repetition — make it required, or give the group a period.` : `'${o.name}' has ${v + 1} optional parameters after the repeating group '${f}', which has period ${a}. At most ${a - 1} may be optional, or the argument count no longer decides the parse.`);
442
+ if (m) return void s(c, i.RepeatingOptional, `'${o.name}' parameter '${d.name}' is optional and follows '${f}', whose own last slot is already optional. Both omissions reach the same argument count — drop one.`);
445
443
  v++;
446
444
  }
447
445
  }
448
- C && !S && (t = m.name);
449
- const w = (m.range ? 2 : 0) + (m.arrayDepth ?? 0), Y = m.range === "r" || m.range === "p" || m.range === "*", I = m.rest || Y ? 3 : 2;
450
- if (w > I) return void o(c, i.ArrayDepth, `'${s.name}' parameter '${m.name}' has an array depth of ${w}; the maximum is ${I}${m.rest ? " for a rest parameter" : " (use a rest parameter for one more level, or an IRange)"}.`);
451
- s.parameters.push(m);
446
+ C && !S && (t = d.name);
447
+ const w = (d.range ? 2 : 0) + (d.arrayDepth ?? 0), ee = d.range === "r" || d.range === "p" || d.range === "*", I = d.rest || ee ? 3 : 2;
448
+ if (w > I) return void s(c, i.ArrayDepth, `'${o.name}' parameter '${d.name}' has an array depth of ${w}; the maximum is ${I}${d.rest ? " for a rest parameter" : " (use a rest parameter for one more level, or an IRange)"}.`);
449
+ o.parameters.push(d);
452
450
  const z = { description: "" };
453
- l.parameters[m.name] = z;
454
- const re = $.getSymbolAtLocation(c.name);
455
- z.description = H(re?.getDocumentationComment($)), K !== void 0 && (m.defaultValue = K);
456
- for (const O of [m, ...m.repeating ?? []]) {
457
- const J = O.enum ? ue.get(O.enum) : void 0;
451
+ l.parameters[d.name] = z;
452
+ const ae = $.getSymbolAtLocation(c.name);
453
+ z.description = H(ae?.getDocumentationComment($)), K !== void 0 && (d.defaultValue = K);
454
+ for (const O of [d, ...d.repeating ?? []]) {
455
+ const J = O.enum ? ce.get(O.enum) : void 0;
458
456
  J && ((l.enums ??= {})[O.enum.id] = J);
459
457
  }
460
- if (p.set(m.name, m), h.set(m.name, c), S && S.length > 1) {
461
- E.add(m.name);
458
+ if (p.set(d.name, d), h.set(d.name, c), S && S.length > 1) {
459
+ L.add(d.name);
462
460
  for (const O of S) {
463
- const J = `${m.name}.${O.name}`;
461
+ const J = `${d.name}.${O.name}`;
464
462
  l.parameters[J] = { description: "" }, p.set(J, O), h.set(J, c);
465
463
  }
466
464
  }
467
465
  }
468
- const D = s.maxArguments;
466
+ const D = o.maxArguments;
469
467
  if (D !== void 0) {
470
- const g = s.parameters ?? [];
471
- if (!g.some((m) => m.rest === !0 || m.repeating !== void 0)) return void o(e, i.RepeatingMax, `'${s.name}' declares a maximum of ${D} arguments but takes a fixed ${g.length}. A maximum only means something on a variadic tail.`);
468
+ const g = o.parameters ?? [];
469
+ if (!g.some((d) => d.rest === !0 || d.repeating !== void 0)) return void s(e, i.RepeatingMax, `'${o.name}' declares a maximum of ${D} arguments but takes a fixed ${g.length}. A maximum only means something on a variadic tail.`);
472
470
  let c = 0;
473
- for (const m of g) m.rest !== !0 && m.optional !== !0 && (c += m.repeating ? m.repeating.length : 1);
474
- if (D < c) return void o(e, i.RepeatingMax, `'${s.name}' declares a maximum of ${D} arguments but requires ${c}.`);
471
+ for (const d of g) d.rest !== !0 && d.optional !== !0 && (c += d.repeating ? d.repeating.length : 1);
472
+ if (D < c) return void s(e, i.RepeatingMax, `'${o.name}' declares a maximum of ${D} arguments but requires ${c}.`);
475
473
  }
476
474
  if (e.jsDoc && e.jsDoc.length > 0) {
477
475
  const g = e.jsDoc, c = g.length;
478
- for (let m = 0; m < c; m++) {
479
- const k = g[m]?.tags;
476
+ for (let d = 0; d < c; d++) {
477
+ const k = g[d]?.tags;
480
478
  if (!k) continue;
481
479
  const j = k.length;
482
480
  for (let C = 0; C < j; C++) {
@@ -485,19 +483,19 @@ function Oe(r, F, $, A) {
485
483
  if (!S) continue;
486
484
  S = S.toLowerCase();
487
485
  let w = K.comment;
488
- const Y = Le(S);
489
- if (typeof w == "string" || Y) {
486
+ const ee = Ee(S);
487
+ if (typeof w == "string" || ee) {
490
488
  if (typeof w == "string" && (w = w.replace(/\r\n?/g, `
491
- `).trim()), Y || !w || (w = w.split(`
489
+ `).trim()), ee || !w || (w = w.split(`
492
490
  `)[0].trim(), w && w.length !== 0)) {
493
491
  if (w && typeof w == "string") {
494
492
  const I = /\{@link(code|plain)?\s+([^}|]+)(?:\s*\|\s*([^}]+))?\}/g;
495
- let z, re = w, O = [];
493
+ let z, ae = w, O = [];
496
494
  for (; (z = I.exec(w)) !== null; ) {
497
- const [J, Ve, Ke, fe] = z, Ne = [Ke.trim()];
498
- fe && Ne.push(fe.trim());
495
+ const [J, je, Ne, he] = z, Le = [Ne.trim()];
496
+ he && Le.push(he.trim());
499
497
  }
500
- w = re, O.length > 0 && S === "see" && (l.links || (l.links = []), l.links.push(...O));
498
+ w = ae, O.length > 0 && S === "see" && (l.links || (l.links = []), l.links.push(...O));
501
499
  }
502
500
  if (S === "name") {
503
501
  const I = w;
@@ -506,76 +504,77 @@ function Oe(r, F, $, A) {
506
504
  if (S === "param") {
507
505
  const I = K.name?.getText?.() ?? K.name?.text;
508
506
  if (!p.get(I)) {
509
- o(K, i.UnknownParam, `Parameter '${I}' not found in function '${n}'.`);
507
+ s(K, i.UnknownParam, `Parameter '${I}' not found in function '${n}'.`);
510
508
  continue;
511
509
  }
512
510
  const z = l.parameters?.[I];
513
511
  z && !z.description && typeof w == "string" && w && (z.description = w);
514
- } else if (S === "returns" || S === "return") s.returnType.description = w;
512
+ } else if (S === "returns" || S === "return") o.returnType.description = w;
515
513
  else if (S === "returnkind") {
516
514
  const I = (w ?? "").trim().toLowerCase();
517
- ae.has(I) ? s.returnType.kind = I : o(K, i.UnknownReturnKind, `'@returnKind ${I}' is not a known value kind. Known: ${[...ae].map((z) => `'${z}'`).join(", ")}.`);
515
+ ie.has(I) ? o.returnType.kind = I : s(K, i.UnknownReturnKind, `'@returnKind ${I}' is not a known value kind. Known: ${[...ie].map((z) => `'${z}'`).join(", ")}.`);
518
516
  } else if (S === "category") l.category = w;
519
517
  else if (S === "deprecated" || S === "hidden") {
520
518
  let I = !0;
521
519
  const z = w?.toLowerCase();
522
- z === "false" ? I = !1 : z !== "true" && (I = w), I !== !1 && (l.deprecated = I ?? !0, s.hidden = !0);
520
+ z === "false" ? I = !1 : z !== "true" && (I = w), I !== !1 && (l.deprecated = I ?? !0, o.hidden = !0);
523
521
  }
524
522
  }
525
523
  }
526
- } else S === "returnkind" && o(K, i.UnknownReturnKind, `'@returnKind' needs a value kind. Known: ${[...ae].map((I) => `'${I}'`).join(", ")}.`);
524
+ } else S === "returnkind" && s(K, i.UnknownReturnKind, `'@returnKind' needs a value kind. Known: ${[...ie].map((I) => `'${I}'`).join(", ")}.`);
527
525
  }
528
526
  }
529
527
  }
530
- Object.keys(s.returnType).length === 0 && delete s.returnType, Object.keys(T).length > 0 && (s.behavior = T), l.summary || U(e.name ?? e, i.MissingSummary, "warning", `'${n}': missing a description. Add a JSDoc comment above the function.`);
531
- const L = !s.context, R = L && l.name || n;
532
- if (L && !Me.test(R)) {
528
+ if (!o.context && Y) return void s(Y, i.InvalidReturnType, `'${n}': Promise<T> is not a valid return type for a calculation function. Return the value the cell shows now, and call FormulaContext.defer(executor, payload) to deliver the result later.`);
529
+ Object.keys(o.returnType).length === 0 && delete o.returnType, Object.keys(x).length > 0 && (o.behavior = x), l.summary || U(e.name ?? e, i.MissingSummary, "warning", `'${n}': missing a description. Add a JSDoc comment above the function.`);
530
+ const E = !o.context, R = E && l.name || n;
531
+ if (E && !Ce.test(R)) {
533
532
  const g = l.name ? `'@name ${l.name}'` : `'${R}'`;
534
- return void o(e.name ?? e, i.InvalidName, `'${n}': ${g} cannot be called from a formula. A function name starts with a letter or '_', and continues with letters, digits, '_' or '.'.` + (l.name ? "" : " Add an '@name' tag to register it under another name."));
533
+ return void s(e.name ?? e, i.InvalidName, `'${n}': ${g} cannot be called from a formula. A function name starts with a letter or '_', and continues with letters, digits, '_' or '.'.` + (l.name ? "" : " Add an '@name' tag to register it under another name."));
535
534
  }
536
- if (L && !A?.isBuiltIn && ((g) => {
537
- if (Ue.test(g)) return !0;
538
- const c = Ce.exec(g);
535
+ if (E && !A?.isBuiltIn && ((g) => {
536
+ if (Pe.test(g)) return !0;
537
+ const c = Ue.exec(g);
539
538
  if (!c) return !1;
540
- let m = 0;
541
- for (const j of c[1].toUpperCase()) m = 26 * m + (j.charCodeAt(0) - 64);
539
+ let d = 0;
540
+ for (const j of c[1].toUpperCase()) d = 26 * d + (j.charCodeAt(0) - 64);
542
541
  const k = Number(c[2]);
543
- return m <= 16384 && k >= 1 && k <= 1048576;
542
+ return d <= 16384 && k >= 1 && k <= 1048576;
544
543
  })(R)) {
545
544
  const g = l.name ? `'@name ${l.name}'` : `'${R}'`;
546
- return void o(e.name ?? e, i.InvalidName, `'${n}': ${g} cannot be called from a formula. It reads as a cell address.` + (l.name ? "" : " Add an '@name' tag to register it under another name."));
545
+ return void s(e.name ?? e, i.InvalidName, `'${n}': ${g} cannot be called from a formula. It reads as a cell address.` + (l.name ? "" : " Add an '@name' tag to register it under another name."));
547
546
  }
548
547
  const P = W.get(R.toUpperCase());
549
- if (P !== void 0) return void o(e.name ?? e, i.DuplicateName, `'${n}': '${R}' is already the name of '${P}' in this module.`);
550
- if (W.set(R.toUpperCase(), n), L && B?.has(R.toUpperCase())) return void o(e.name ?? e, i.BuiltInName, `'${R}' is a built-in function. Choose a different name - a calculation function cannot replace a built-in.`);
551
- if (L) {
548
+ if (P !== void 0) return void s(e.name ?? e, i.DuplicateName, `'${n}': '${R}' is already the name of '${P}' in this module.`);
549
+ if (W.set(R.toUpperCase(), n), E && B?.has(R.toUpperCase())) return void s(e.name ?? e, i.BuiltInName, `'${R}' is a built-in function. Choose a different name - a calculation function cannot replace a built-in.`);
550
+ if (E) {
552
551
  const g = l.parameters ?? {};
553
- for (const [c, m] of Object.entries(g)) if (!E.has(c) && !m.description) {
552
+ for (const [c, d] of Object.entries(g)) if (!L.has(c) && !d.description) {
554
553
  const k = h.get(c);
555
554
  U(k, i.MissingParamDescription, "warning", `'${n}': parameter '${c}' is missing a description. Add an '@param ${c}' tag.`);
556
555
  }
557
556
  }
558
- G.push([s, l]);
557
+ G.push([o, l]);
559
558
  } catch (u) {
560
- o(e, i.ParseError, `'${n}': ${u.message}`);
559
+ s(e, i.ParseError, `'${n}': ${u.message}`);
561
560
  }
562
561
  }
563
562
  });
564
563
  } catch (e) {
565
- o(void 0, i.ParseError, `Unable to analyze module: ${e?.message ?? e}`);
564
+ s(void 0, i.ParseError, `Unable to analyze module: ${e?.message ?? e}`);
566
565
  }
567
566
  return { functions: G, autoRun: X, diagnostics: Q };
568
567
  }
569
- function _e(r, F, $) {
568
+ function Je(r, F, $) {
570
569
  const A = "script.ts", B = "lib.d.ts", G = { [A]: F ?? "", [B]: "" }, W = r.createProgram([A], { allowJs: !0, noResolve: !0, noLib: !0, isolatedModules: !0, module: 99, target: r.ScriptTarget.ES2020 }, { getSourceFile: (U) => {
571
- const o = G[U];
572
- if (o !== void 0) return r.createSourceFile(U, o, r.ScriptTarget.Latest, !0);
570
+ const s = G[U];
571
+ if (s !== void 0) return r.createSourceFile(U, s, r.ScriptTarget.Latest, !0);
573
572
  }, fileExists: (U) => G[U] !== void 0, readFile: (U) => G[U], writeFile: () => {
574
573
  }, getCurrentDirectory: () => "./", getCanonicalFileName: (U) => U, useCaseSensitiveFileNames: () => !0, getDefaultLibFileName: () => B, getNewLine: () => `
575
574
  ` }), Q = W.getTypeChecker(), X = W.getSourceFile(A);
576
- return X ? Oe(r, X, Q, $).diagnostics : [];
575
+ return X ? Ve(r, X, Q, $).diagnostics : [];
577
576
  }
578
577
  export {
579
- Oe as analyzeModule,
580
- _e as lintScript
578
+ Ve as analyzeModule,
579
+ Je as lintScript
581
580
  };