@gridsheet/preact-core 3.4.1 → 3.4.3

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.
@@ -233,16 +233,16 @@ const Cs = 20, rt = 24, he = 90, jr = 500, Gr = 1e3, $e = 24, Le = 50, Zr = 5, q
233
233
  let l = o.y, h = o.x, u = o.y, c = o.x;
234
234
  const f = [o];
235
235
  for (i.add(a); f.length > 0; ) {
236
- const { y: d, x: p } = f.shift();
237
- d < l && (l = d), d > u && (u = d), p < h && (h = p), p > c && (c = p);
238
- for (const [m, y] of [
236
+ const { y: d, x: m } = f.shift();
237
+ d < l && (l = d), d > u && (u = d), m < h && (h = m), m > c && (c = m);
238
+ for (const [p, y] of [
239
239
  [0, 1],
240
240
  [0, -1],
241
241
  [1, 0],
242
242
  [-1, 0]
243
243
  ]) {
244
- const g = e(d + m, p + y);
245
- s.has(g) && !i.has(g) && (i.add(g), f.push({ y: d + m, x: p + y }));
244
+ const g = e(d + p, m + y);
245
+ s.has(g) && !i.has(g) && (i.add(g), f.push({ y: d + p, x: m + y }));
246
246
  }
247
247
  }
248
248
  n.push({ top: l, left: h, bottom: u, right: c });
@@ -850,7 +850,7 @@ const ei = (r, t) => {
850
850
  for (let h = 0; h < i.length; h++) {
851
851
  if (n.has(h))
852
852
  continue;
853
- const u = i[h], c = u.replace(l, (f, d, p) => `${d || ""}#${a}${p || ""}`);
853
+ const u = i[h], c = u.replace(l, (f, d, m) => `${d || ""}#${a}${m || ""}`);
854
854
  c !== u && (i[h] = c, n.add(h));
855
855
  }
856
856
  }), `${e}!${i.join(":")}`;
@@ -964,13 +964,13 @@ const Rt = (r, { sheet: t, operation: e, dependency: s }) => {
964
964
  return { sheet: t, sheetName: i, addresses: n, ids: o };
965
965
  const a = [];
966
966
  for (let h = 0; h < n.length; h++) {
967
- const u = n[h], { y: c, x: f, absX: d, absY: p } = T(u);
968
- let m = t.getId({ y: c, x: f });
969
- if (m === s && (e === "removeRows" ? m = t.getId({ y: c - 1, x: f }) : e === "removeCols" && (m = t.getId({ y: c, x: f - 1 }))), m == null) {
970
- a.push(Ke(u, !!d, !!p) || "?");
967
+ const u = n[h], { y: c, x: f, absX: d, absY: m } = T(u);
968
+ let p = t.getId({ y: c, x: f });
969
+ if (p === s && (e === "removeRows" ? p = t.getId({ y: c - 1, x: f }) : e === "removeCols" && (p = t.getId({ y: c, x: f - 1 }))), p == null) {
970
+ a.push(Ke(u, !!d, !!m) || "?");
971
971
  continue;
972
972
  }
973
- o.push(m), a.push(`${d ? "$" : ""}#${m}${p ? "$" : ""}`);
973
+ o.push(p), a.push(`${d ? "$" : ""}#${p}${m ? "$" : ""}`);
974
974
  }
975
975
  let l = `#${t.id}!${a.join(":")}`;
976
976
  return {
@@ -1022,10 +1022,10 @@ const Rt = (r, { sheet: t, operation: e, dependency: s }) => {
1022
1022
  const a = {};
1023
1023
  if (i) {
1024
1024
  for (const f of i) {
1025
- const d = T(f), p = is(r, f, { resolution: t, raise: e }) ?? {};
1026
- if (s(p)) {
1027
- let m = p.value;
1028
- o && (m = r.getPolicy(d).toScalar({ value: p.value, cell: p, sheet: r.__raw__, point: d })), a[f] = m;
1025
+ const d = T(f), m = is(r, f, { resolution: t, raise: e }) ?? {};
1026
+ if (s(m)) {
1027
+ let p = m.value;
1028
+ o && (p = r.getPolicy(d).toScalar({ value: m.value, cell: m, sheet: r.__raw__, point: d })), a[f] = p;
1029
1029
  }
1030
1030
  }
1031
1031
  return a;
@@ -1033,37 +1033,37 @@ const Rt = (r, { sheet: t, operation: e, dependency: s }) => {
1033
1033
  const { top: l, left: h, bottom: u, right: c } = n ?? r.area;
1034
1034
  for (let f = l; f <= u; f++)
1035
1035
  for (let d = h; d <= c; d++) {
1036
- const p = r.getCell({ y: f, x: d }, { resolution: t, raise: e }) ?? {};
1037
- if (s(p)) {
1038
- let m = p.value;
1039
- o && (m = r.getPolicy({ y: f, x: d }).toScalar({ value: p.value, cell: p, sheet: r.__raw__, point: { y: f, x: d } })), a[M({ y: f, x: d })] = m;
1036
+ const m = r.getCell({ y: f, x: d }, { resolution: t, raise: e }) ?? {};
1037
+ if (s(m)) {
1038
+ let p = m.value;
1039
+ o && (p = r.getPolicy({ y: f, x: d }).toScalar({ value: m.value, cell: m, sheet: r.__raw__, point: { y: f, x: d } })), a[M({ y: f, x: d })] = p;
1040
1040
  }
1041
1041
  }
1042
1042
  return a;
1043
1043
  }, Rn = (r, { resolution: t = "RESOLVED", raise: e = false, filter: s = st, rows: i, area: n, asScalar: o = false } = {}) => {
1044
- const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ?? Array.from({ length: r.numRows }, (d, p) => l + p);
1044
+ const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ?? Array.from({ length: r.numRows }, (d, m) => l + m);
1045
1045
  for (const d of f) {
1046
- const p = {};
1047
- a.push(p);
1048
- for (let m = h; m <= c; m++) {
1049
- const y = r.getCell({ y: d, x: m }, { resolution: t, raise: e }) ?? {};
1046
+ const m = {};
1047
+ a.push(m);
1048
+ for (let p = h; p <= c; p++) {
1049
+ const y = r.getCell({ y: d, x: p }, { resolution: t, raise: e }) ?? {};
1050
1050
  if (s(y)) {
1051
1051
  let g = y.value;
1052
- o && (g = r.getPolicy({ y: d, x: m }).toScalar({ value: y.value, cell: y, sheet: r.__raw__, point: { y: d, x: m } })), p[G$1(m)] = g;
1052
+ o && (g = r.getPolicy({ y: d, x: p }).toScalar({ value: y.value, cell: y, sheet: r.__raw__, point: { y: d, x: p } })), m[G$1(p)] = g;
1053
1053
  }
1054
1054
  }
1055
1055
  }
1056
1056
  return a;
1057
1057
  }, En = (r, { resolution: t = "RESOLVED", raise: e = false, filter: s = st, cols: i, area: n, asScalar: o = false } = {}) => {
1058
- const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ? i.map((d) => typeof d == "string" ? Ht(d) : d) : Array.from({ length: r.numCols }, (d, p) => h + p);
1058
+ const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ? i.map((d) => typeof d == "string" ? Ht(d) : d) : Array.from({ length: r.numCols }, (d, m) => h + m);
1059
1059
  for (const d of f) {
1060
- const p = {};
1061
- a.push(p);
1062
- for (let m = l; m <= u; m++) {
1063
- const y = r.getCell({ y: m, x: d }, { resolution: t, raise: e }) ?? {};
1060
+ const m = {};
1061
+ a.push(m);
1062
+ for (let p = l; p <= u; p++) {
1063
+ const y = r.getCell({ y: p, x: d }, { resolution: t, raise: e }) ?? {};
1064
1064
  if (s(y)) {
1065
1065
  let g = y.value;
1066
- o && (g = r.getPolicy({ y: m, x: d }).toScalar({ value: y.value, cell: y, sheet: r.__raw__, point: { y: m, x: d } })), p[bt(m)] = g;
1066
+ o && (g = r.getPolicy({ y: p, x: d }).toScalar({ value: y.value, cell: y, sheet: r.__raw__, point: { y: p, x: d } })), m[bt(p)] = g;
1067
1067
  }
1068
1068
  }
1069
1069
  }
@@ -1074,8 +1074,8 @@ const Rt = (r, { sheet: t, operation: e, dependency: s }) => {
1074
1074
  for (let f = a; f <= h; f++) {
1075
1075
  const d = r.getCell({ y: c, x: f }, { resolution: e, raise: s }) ?? {};
1076
1076
  if (i(d)) {
1077
- const p = Bt(d, n);
1078
- u[c - o][f - a] = p;
1077
+ const m = Bt(d, n);
1078
+ u[c - o][f - a] = m;
1079
1079
  }
1080
1080
  }
1081
1081
  return u;
@@ -1098,29 +1098,29 @@ const Rt = (r, { sheet: t, operation: e, dependency: s }) => {
1098
1098
  const { top: l, left: h, bottom: u, right: c } = n ?? r.area;
1099
1099
  for (let f = l; f <= u; f++)
1100
1100
  for (let d = h; d <= c; d++) {
1101
- const p = r.getCell({ y: f, x: d }, { resolution: t, raise: e }) ?? {};
1102
- s(p) && (a[M({ y: f, x: d })] = Bt(p, o));
1101
+ const m = r.getCell({ y: f, x: d }, { resolution: t, raise: e }) ?? {};
1102
+ s(m) && (a[M({ y: f, x: d })] = Bt(m, o));
1103
1103
  }
1104
1104
  return a;
1105
1105
  }, Cn = (r, { resolution: t = "RESOLVED", raise: e = false, filter: s = st, rows: i, area: n, ignoreFields: o = [] } = {}) => {
1106
- const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ?? Array.from({ length: r.numRows }, (d, p) => l + p);
1106
+ const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ?? Array.from({ length: r.numRows }, (d, m) => l + m);
1107
1107
  for (const d of f) {
1108
- const p = {};
1109
- a.push(p);
1110
- for (let m = h; m <= c; m++) {
1111
- const y = r.getCell({ y: d, x: m }, { resolution: t, raise: e }) ?? {};
1112
- s(y) && (p[G$1(m)] = Bt(y, o));
1108
+ const m = {};
1109
+ a.push(m);
1110
+ for (let p = h; p <= c; p++) {
1111
+ const y = r.getCell({ y: d, x: p }, { resolution: t, raise: e }) ?? {};
1112
+ s(y) && (m[G$1(p)] = Bt(y, o));
1113
1113
  }
1114
1114
  }
1115
1115
  return a;
1116
1116
  }, rs = (r) => `'${r.replace(/'/g, "''")}'`, ri = (r) => r ? `${rs(r)}!` : "", Tn = (r, { resolution: t = "RESOLVED", raise: e = false, filter: s = st, cols: i, area: n, ignoreFields: o = [] } = {}) => {
1117
- const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ? i.map((d) => typeof d == "string" ? Ht(d) : d) : Array.from({ length: r.numCols }, (d, p) => h + p);
1117
+ const a = [], { top: l, left: h, bottom: u, right: c } = n ?? r.area, f = i ? i.map((d) => typeof d == "string" ? Ht(d) : d) : Array.from({ length: r.numCols }, (d, m) => h + m);
1118
1118
  for (const d of f) {
1119
- const p = {};
1120
- a.push(p);
1121
- for (let m = l; m <= u; m++) {
1122
- const y = r.getCell({ y: m, x: d }, { resolution: t, raise: e }) ?? {};
1123
- s(y) && (p[bt(m)] = Bt(y, o));
1119
+ const m = {};
1120
+ a.push(m);
1121
+ for (let p = l; p <= u; p++) {
1122
+ const y = r.getCell({ y: p, x: d }, { resolution: t, raise: e }) ?? {};
1123
+ s(y) && (m[bt(p)] = Bt(y, o));
1124
1124
  }
1125
1125
  }
1126
1126
  return a;
@@ -1884,15 +1884,15 @@ let Y$1 = class Y {
1884
1884
  f != null && f.sortFixed ? i.add(c) : n.push(c);
1885
1885
  }
1886
1886
  n.sort((c, f) => {
1887
- const d = this.getCell({ y: c, x: t }, { resolution: "RESOLVED" }), p = this.getCell({ y: f, x: t }, { resolution: "RESOLVED" }), m = d == null ? void 0 : d.value, y = p == null ? void 0 : p.value;
1888
- if (m == null && y == null)
1887
+ const d = this.getCell({ y: c, x: t }, { resolution: "RESOLVED" }), m = this.getCell({ y: f, x: t }, { resolution: "RESOLVED" }), p = d == null ? void 0 : d.value, y = m == null ? void 0 : m.value;
1888
+ if (p == null && y == null)
1889
1889
  return 0;
1890
- if (m == null)
1890
+ if (p == null)
1891
1891
  return 1;
1892
1892
  if (y == null)
1893
1893
  return -1;
1894
1894
  let g = 0;
1895
- return typeof m == "number" && typeof y == "number" ? g = m - y : m instanceof Date && y instanceof Date ? g = m.getTime() - y.getTime() : g = String(m).localeCompare(String(y)), e === "asc" ? g : -g;
1895
+ return typeof p == "number" && typeof y == "number" ? g = p - y : p instanceof Date && y instanceof Date ? g = p.getTime() - y.getTime() : g = String(p).localeCompare(String(y)), e === "asc" ? g : -g;
1896
1896
  });
1897
1897
  const o = [];
1898
1898
  for (let c = 1; c <= s; c++)
@@ -1959,9 +1959,10 @@ let Y$1 = class Y {
1959
1959
  }
1960
1960
  /** @internal */
1961
1961
  processFormula(t, { idMap: e, ...s }) {
1962
+ var i, n;
1962
1963
  if ((typeof t == "string" || t instanceof String) && t.charAt(0) === "=") {
1963
- const i = new te$1(t.substring(1));
1964
- return i.tokenize(e), i.identify({ ...s, sheet: this }), i.dependencyIds.forEach((n) => this.addDependency(n, s.dependency)), s.dependency != null && (this._formulaHasAsync(i) ? this.registry.asyncFormulaCells.add(s.dependency) : this.registry.asyncFormulaCells.delete(s.dependency)), "=" + i.identifiedFormula;
1964
+ const o = new te$1(t.substring(1));
1965
+ return o.tokenize(e), o.identify({ ...s, sheet: this }), o.dependencyIds.forEach((a) => this.addDependency(a, s.dependency)), s.dependency != null && (this._formulaHasAsync(o) ? this.registry.asyncFormulaCells.add(s.dependency) : this.registry.asyncFormulaCells.delete(s.dependency), (n = (i = this.registry).onFormula) == null || n.call(i)), "=" + o.identifiedFormula;
1965
1966
  }
1966
1967
  return s.dependency != null && this.registry.asyncFormulaCells.delete(s.dependency), t;
1967
1968
  }
@@ -2061,8 +2062,8 @@ let Y$1 = class Y {
2061
2062
  const u = T(h), { y: c, x: f } = u;
2062
2063
  if (c === 0 && f === 0 || c === 0 || f === 0 || c <= 0 || f <= 0 || c > e.numRows || f > e.numCols)
2063
2064
  continue;
2064
- const p = this._ensureIdRow(c)[f];
2065
- p != null && this._ensureCellPopulated(c, f, p);
2065
+ const m = this._ensureIdRow(c)[f];
2066
+ m != null && this._ensureCellPopulated(c, f, m);
2066
2067
  }
2067
2068
  this.status = 1, this.registry.sheetIdsByName[this.name] = this.id;
2068
2069
  }
@@ -2118,43 +2119,43 @@ let Y$1 = class Y {
2118
2119
  const i = this._initCells, n = Date.now();
2119
2120
  let o;
2120
2121
  if (t === 0 && e > 0) {
2121
- const u = this._colLetters[e] || G$1(e), c = i == null ? void 0 : i[u], { style: f, ...d } = c ?? {}, p = i == null ? void 0 : i[u + "0"];
2122
+ const u = this._colLetters[e] || G$1(e), c = i == null ? void 0 : i[u], { style: f, ...d } = c ?? {}, m = i == null ? void 0 : i[u + "0"];
2122
2123
  o = {
2123
2124
  ...this._commonCol,
2124
2125
  ...d,
2125
- ...p,
2126
- ...Y._stack(this._commonCol, p)
2126
+ ...m,
2127
+ ...Y._stack(this._commonCol, m)
2127
2128
  };
2128
2129
  } else if (e === 0 && t > 0) {
2129
- const u = bt(t), c = i == null ? void 0 : i[u], { style: f, ...d } = c ?? {}, p = i == null ? void 0 : i["0" + u];
2130
+ const u = bt(t), c = i == null ? void 0 : i[u], { style: f, ...d } = c ?? {}, m = i == null ? void 0 : i["0" + u];
2130
2131
  o = {
2131
2132
  ...this._commonRow,
2132
2133
  ...d,
2133
- ...p,
2134
- ...Y._stack(this._commonRow, p)
2134
+ ...m,
2135
+ ...Y._stack(this._commonRow, m)
2135
2136
  };
2136
2137
  } else if (t === 0 && e === 0) {
2137
2138
  const u = i == null ? void 0 : i["0"];
2138
2139
  o = { ...u, ...Y._stack(u) };
2139
2140
  } else {
2140
- const u = this._colLetters[e] || G$1(e), c = bt(t), f = `${u}${c}`, d = i == null ? void 0 : i[c], p = i == null ? void 0 : i[u];
2141
- let m = i == null ? void 0 : i[f];
2142
- if ((m == null || !("value" in m)) && this._matrixByBase.length > 0)
2141
+ const u = this._colLetters[e] || G$1(e), c = bt(t), f = `${u}${c}`, d = i == null ? void 0 : i[c], m = i == null ? void 0 : i[u];
2142
+ let p = i == null ? void 0 : i[f];
2143
+ if ((p == null || !("value" in p)) && this._matrixByBase.length > 0)
2143
2144
  for (const { baseY: y, baseX: g, matrix: b } of this._matrixByBase) {
2144
2145
  const _2 = t - y, x = e - g;
2145
2146
  if (_2 >= 0 && _2 < b.length && x >= 0 && x < b[_2].length) {
2146
2147
  const w2 = b[_2][x];
2147
2148
  let E;
2148
- this._initFlattenAs ? E = { [this._initFlattenAs]: w2 } : E = w2, m = m ? { ...E, ...m } : E;
2149
+ this._initFlattenAs ? E = { [this._initFlattenAs]: w2 } : E = w2, p = p ? { ...E, ...p } : E;
2149
2150
  break;
2150
2151
  }
2151
2152
  }
2152
2153
  o = {
2153
2154
  ...this._common,
2154
2155
  ...d,
2155
- ...p,
2156
2156
  ...m,
2157
- ...Y._stack(this._common, d, p, m)
2157
+ ...p,
2158
+ ...Y._stack(this._common, d, m, p)
2158
2159
  };
2159
2160
  }
2160
2161
  (h = (l = o == null ? void 0 : o.value) == null ? void 0 : l.startsWith) != null && h.call(l, "=") && ((o == null ? void 0 : o.formulaEnabled) ?? true) && this.idsToBeIdentified.push(s), t === 0 ? o.width == null && (o.width = he) : e === 0 ? (o.height == null && (o.height = rt), o.height !== (this.defaultRowHeight || rt) && this._rowHeightOverrides.set(t, o.height), o.filtered && this._filteredRows.add(t)) : (delete o.height, delete o.width, delete o.label), o = (this.policies[o.policy ?? ""] ?? this.defaultPolicy).deserializeValue(o.value, o) ?? {}, this.registry.systems[s] = { ...this.registry.systems[s], id: s, changedTime: n, sheetId: this.id }, this.registry.data[s] = o;
@@ -2229,8 +2230,8 @@ let Y$1 = class Y {
2229
2230
  }
2230
2231
  }
2231
2232
  getRectSize({ top: t, left: e, bottom: s, right: i }) {
2232
- var d, p;
2233
- const n = e || 1, o = t || 1, a = ((d = this.registry.systems[this.getId({ y: 0, x: i })]) == null ? void 0 : d.offsetLeft) ?? 0, l = ((p = this.registry.systems[this.getId({ y: 0, x: n })]) == null ? void 0 : p.offsetLeft) ?? 0, h = this.getOffsetTop(s), u = this.getOffsetTop(o), c = Math.max(0, a - l), f = Math.max(0, h - u);
2233
+ var d, m;
2234
+ const n = e || 1, o = t || 1, a = ((d = this.registry.systems[this.getId({ y: 0, x: i })]) == null ? void 0 : d.offsetLeft) ?? 0, l = ((m = this.registry.systems[this.getId({ y: 0, x: n })]) == null ? void 0 : m.offsetLeft) ?? 0, h = this.getOffsetTop(s), u = this.getOffsetTop(o), c = Math.max(0, a - l), f = Math.max(0, h - u);
2234
2235
  return { y: o, x: n, height: f, width: c };
2235
2236
  }
2236
2237
  /** @internal */
@@ -2418,8 +2419,8 @@ let Y$1 = class Y {
2418
2419
  throw new S$1("#REF!", "References are circulating.");
2419
2420
  const d = this.getCell({ y: e, x: c }, { resolution: a, raise: l }) ?? {};
2420
2421
  if (h(d)) {
2421
- let p = d.value;
2422
- u && (p = this.getPolicy({ y: e, x: c }).toScalar({ value: d.value, cell: d, sheet: this, point: { y: e, x: c } })), t[e - s][c - i] = p;
2422
+ let m = d.value;
2423
+ u && (m = this.getPolicy({ y: e, x: c }).toScalar({ value: d.value, cell: d, sheet: this, point: { y: e, x: c } })), t[e - s][c - i] = m;
2423
2424
  }
2424
2425
  }
2425
2426
  }
@@ -2458,12 +2459,12 @@ let Y$1 = class Y {
2458
2459
  onProgress: l,
2459
2460
  yieldControl: h
2460
2461
  } = {}) {
2461
- const { top: u, left: c, bottom: f, right: d } = t ?? this.area, p = Math.max(0, f - u + 1), m = Jt(p, d - c + 1), y = h ?? (() => Promise.resolve());
2462
- l == null || l({ done: 0, total: p });
2462
+ const { top: u, left: c, bottom: f, right: d } = t ?? this.area, m = Math.max(0, f - u + 1), p = Jt(m, d - c + 1), y = h ?? (() => Promise.resolve());
2463
+ l == null || l({ done: 0, total: m });
2463
2464
  let g = Date.now(), b = 0;
2464
2465
  for (let _2 = u; _2 <= f; _2++)
2465
- this._fillValueRow(m, _2, { top: u, left: c, right: d, at: e, resolution: s, raise: i, filter: n, asScalar: o }), b++, Date.now() - g >= a && (l == null || l({ done: b, total: p }), await y(), g = Date.now());
2466
- return l == null || l({ done: p, total: p }), m;
2466
+ this._fillValueRow(p, _2, { top: u, left: c, right: d, at: e, resolution: s, raise: i, filter: n, asScalar: o }), b++, Date.now() - g >= a && (l == null || l({ done: b, total: m }), await y(), g = Date.now());
2467
+ return l == null || l({ done: m, total: m }), p;
2467
2468
  }
2468
2469
  /** @internal */
2469
2470
  _pushHistory(t) {
@@ -2547,28 +2548,28 @@ let Y$1 = class Y {
2547
2548
  const { top: n, left: o, bottom: a, right: l } = e, { top: h, left: u } = i, c = s.numRows, f = s.numCols, d = [];
2548
2549
  for (let x = n; x <= a; x++)
2549
2550
  t.isRowFiltered(x) || d.push(x);
2550
- const p = l - o + 1, m = d.length, y = [];
2551
+ const m = l - o + 1, p = d.length, y = [];
2551
2552
  {
2552
2553
  let x = 0, w2 = h;
2553
- for (; x < m; )
2554
+ for (; x < p; )
2554
2555
  s.isRowFiltered(w2) || (y.push(w2), x++), w2++;
2555
2556
  }
2556
2557
  const g = /* @__PURE__ */ new Set();
2557
- for (let x = 0; x < m; x++)
2558
- for (let w2 = 0; w2 < p; w2++)
2558
+ for (let x = 0; x < p; x++)
2559
+ for (let w2 = 0; w2 < m; w2++)
2559
2560
  g.add(M({ y: d[x], x: o + w2 }));
2560
2561
  const b = /* @__PURE__ */ new Set();
2561
- for (let x = 0; x < m; x++) {
2562
+ for (let x = 0; x < p; x++) {
2562
2563
  const w2 = y[x];
2563
- for (let E = 0; E < p; E++) {
2564
+ for (let E = 0; E < m; E++) {
2564
2565
  const D = u + E;
2565
2566
  w2 <= c && D <= f && b.add(M({ y: w2, x: D }));
2566
2567
  }
2567
2568
  }
2568
2569
  const _2 = [];
2569
- for (let x = 0; x < m; x++) {
2570
+ for (let x = 0; x < p; x++) {
2570
2571
  const w2 = d[x], E = y[x];
2571
- for (let D = 0; D < p; D++) {
2572
+ for (let D = 0; D < m; D++) {
2572
2573
  const k2 = o + D, N = u + D, B2 = M({ y: w2, x: k2 }), Z2 = E <= c && N <= f, q2 = Z2 ? M({ y: E, x: N }) : void 0;
2573
2574
  let C;
2574
2575
  t === s && b.has(B2) || (C = t._generateId());
@@ -2614,7 +2615,7 @@ let Y$1 = class Y {
2614
2615
  const o = {}, a = new wt(e), l = {}, h = [], u = [];
2615
2616
  if (i)
2616
2617
  for (const {
2617
- before: m,
2618
+ before: p,
2618
2619
  after: y,
2619
2620
  src: g,
2620
2621
  dst: b,
@@ -2639,7 +2640,7 @@ let Y$1 = class Y {
2639
2640
  }
2640
2641
  else
2641
2642
  for (const {
2642
- before: m,
2643
+ before: p,
2643
2644
  after: y,
2644
2645
  src: g,
2645
2646
  dst: b,
@@ -2649,7 +2650,7 @@ let Y$1 = class Y {
2649
2650
  const w2 = T(g), E = t.getId(w2), D = b != null ? T(b) : void 0, k2 = D != null ? e.getId(D) : void 0, N = E != null ? t.registry.data[E] : void 0, B2 = k2 != null ? e.registry.data[k2] : void 0;
2650
2651
  if (!(n === "USER" && (F(N == null ? void 0 : N.prevention, Ut) || F(B2 == null ? void 0 : B2.prevention, Vt)))) {
2651
2652
  if (_2 != null) {
2652
- const Z2 = m || Nt, C = (t.policies[Z2] ?? t.defaultPolicy).select({
2653
+ const Z2 = p || Nt, C = (t.policies[Z2] ?? t.defaultPolicy).select({
2653
2654
  sheet: t,
2654
2655
  point: w2,
2655
2656
  next: { value: null },
@@ -2658,11 +2659,11 @@ let Y$1 = class Y {
2658
2659
  });
2659
2660
  l[_2] = {
2660
2661
  ...C,
2661
- policy: m
2662
+ policy: p
2662
2663
  }, this.registry.systems[_2] = { id: _2, sheetId: t.id, changedTime: Date.now() }, h.push({ y: w2.y, x: w2.x, id: _2 });
2663
2664
  }
2664
2665
  if (k2 != null && D != null && b != null) {
2665
- const Z2 = y || Nt, q2 = m || Nt, C = e.policies[Z2] ?? e.defaultPolicy, v = t.policies[q2] ?? t.defaultPolicy, X = v.priority > C.priority, U2 = (X ? v : C).select({
2666
+ const Z2 = y || Nt, q2 = p || Nt, C = e.policies[Z2] ?? e.defaultPolicy, v = t.policies[q2] ?? t.defaultPolicy, X = v.priority > C.priority, U2 = (X ? v : C).select({
2666
2667
  sheet: e,
2667
2668
  point: D,
2668
2669
  next: N,
@@ -2672,7 +2673,7 @@ let Y$1 = class Y {
2672
2673
  if (U2 && (o[E] = N ?? {}, l[E] = {
2673
2674
  ...N,
2674
2675
  ...U2,
2675
- policy: X ? m : y
2676
+ policy: X ? p : y
2676
2677
  }), N != null) {
2677
2678
  const K = this.registry.systems[E];
2678
2679
  K && (K.changedTime = Date.now());
@@ -2684,21 +2685,21 @@ let Y$1 = class Y {
2684
2685
  i || (t._materializeIdMatrix(), t !== e && e._materializeIdMatrix());
2685
2686
  const c = i ? null : t.idMatrix.flat(), f = !i && t !== e ? e.idMatrix.flat() : null;
2686
2687
  Object.assign(this.registry.data, l);
2687
- for (const { y: m, x: y, id: g } of h)
2688
- t._ensureIdRow(m)[y] = g;
2689
- for (const { y: m, x: y, id: g } of u)
2690
- e._ensureIdRow(m)[y] = g;
2691
- const d = s.filter((m) => m.dst != null).map((m) => m.dst), p = s.map((m) => m.src);
2692
- if (t === e ? e.lastChangedAddresses = [.../* @__PURE__ */ new Set([...p, ...d])] : (e.lastChangedAddresses = d, t.lastChangedAddresses = p), !i) {
2688
+ for (const { y: p, x: y, id: g } of h)
2689
+ t._ensureIdRow(p)[y] = g;
2690
+ for (const { y: p, x: y, id: g } of u)
2691
+ e._ensureIdRow(p)[y] = g;
2692
+ const d = s.filter((p) => p.dst != null).map((p) => p.dst), m = s.map((p) => p.src);
2693
+ if (t === e ? e.lastChangedAddresses = [.../* @__PURE__ */ new Set([...m, ...d])] : (e.lastChangedAddresses = d, t.lastChangedAddresses = m), !i) {
2693
2694
  a.buildMap(c.flat(), t.idMatrix.flat()), t !== e && a.buildMap(f.flat(), e.idMatrix.flat());
2694
- const m = a.resolveDependents("move");
2695
- Object.assign(o, m);
2695
+ const p = a.resolveDependents("move");
2696
+ Object.assign(o, p);
2696
2697
  }
2697
2698
  return { diffBefore: o, diffAfter: {} };
2698
2699
  }
2699
2700
  /** Build the paste (copy) diff without applying it. Shared by copy()/copyAsync(). @internal */
2700
2701
  _buildCopyDiff({ srcSheet: t = this, src: e, dst: s, onlyValue: i = false }) {
2701
- const n = t !== this, { top: o, left: a, bottom: l, right: h } = e, { top: u, left: c, bottom: f, right: d } = s, p = {}, m = Date.now(), y = [];
2702
+ const n = t !== this, { top: o, left: a, bottom: l, right: h } = e, { top: u, left: c, bottom: f, right: d } = s, m = {}, p = Date.now(), y = [];
2702
2703
  for (let w2 = o; w2 <= l; w2++)
2703
2704
  t.isRowFiltered(w2) || y.push(w2);
2704
2705
  const g = [];
@@ -2722,16 +2723,16 @@ let Y$1 = class Y {
2722
2723
  slideY: Z2,
2723
2724
  slideX: q2
2724
2725
  }) : C == null ? void 0 : C.value, P = this.getId(v), et = this.registry.systems[P];
2725
- et != null && (et.changedTime = m);
2726
+ et != null && (et.changedTime = p);
2726
2727
  const yt = M(v);
2727
2728
  if (i) {
2728
2729
  const $ = this.getCell(v, { resolution: "SYSTEM" });
2729
2730
  C.style = $ == null ? void 0 : $.style, C.justifyContent = $ == null ? void 0 : $.justifyContent, C.alignItems = $ == null ? void 0 : $.alignItems;
2730
2731
  }
2731
- p[yt] = { ...C, value: Tt };
2732
+ m[yt] = { ...C, value: Tt };
2732
2733
  }
2733
2734
  }
2734
- return p;
2735
+ return m;
2735
2736
  }
2736
2737
  copy(t) {
2737
2738
  const { operator: e = "SYSTEM", undoReflection: s, redoReflection: i } = t;
@@ -2753,8 +2754,8 @@ let Y$1 = class Y {
2753
2754
  * target) never reads an already-pasted value. @internal
2754
2755
  */
2755
2756
  async copyAsync(t, e) {
2756
- const { srcSheet: s = this, src: i, dst: n, onlyValue: o = false, operator: a = "SYSTEM", undoReflection: l, redoReflection: h } = t, { onProgress: u, yieldControl: c, frameBudgetMs: f = 12 } = e, d = c ?? (() => Promise.resolve()), p = s !== this, { top: m, left: y, bottom: g, right: b } = i, { top: _2, left: x, bottom: w2, right: E } = n, D = Date.now(), k2 = [];
2757
- for (let P = m; P <= g; P++)
2757
+ const { srcSheet: s = this, src: i, dst: n, onlyValue: o = false, operator: a = "SYSTEM", undoReflection: l, redoReflection: h } = t, { onProgress: u, yieldControl: c, frameBudgetMs: f = 12 } = e, d = c ?? (() => Promise.resolve()), m = s !== this, { top: p, left: y, bottom: g, right: b } = i, { top: _2, left: x, bottom: w2, right: E } = n, D = Date.now(), k2 = [];
2758
+ for (let P = p; P <= g; P++)
2758
2759
  s.isRowFiltered(P) || k2.push(P);
2759
2760
  const N = k2.length, B2 = b - y + 1, Z2 = E - x + 1, q2 = [], C = [];
2760
2761
  for (let P = 0; P < N; P++) {
@@ -2788,7 +2789,7 @@ let Y$1 = class Y {
2788
2789
  const ot = x + $;
2789
2790
  if (ot > this.numCols)
2790
2791
  continue;
2791
- const gt = $ % B2, xs = y + gt, bs = p ? 0 : P - yt, Ss = p ? 0 : ot - xs, J2 = q2[et][gt], Xt = { y: P, x: ot }, Mt = this.getId(Xt), H = this.registry.data[Mt] ?? this.getCell(Xt, { resolution: "SYSTEM" }), _s = (H == null ? void 0 : H.policy) == null ? this.defaultPolicy : this.policies[H.policy] ?? this.defaultPolicy, Rs = C[et][gt].priority > _s.priority;
2792
+ const gt = $ % B2, xs = y + gt, bs = m ? 0 : P - yt, Ss = m ? 0 : ot - xs, J2 = q2[et][gt], Xt = { y: P, x: ot }, Mt = this.getId(Xt), H = this.registry.data[Mt] ?? this.getCell(Xt, { resolution: "SYSTEM" }), _s = (H == null ? void 0 : H.policy) == null ? this.defaultPolicy : this.policies[H.policy] ?? this.defaultPolicy, Rs = C[et][gt].priority > _s.priority;
2792
2793
  this.clearDependencies(Mt);
2793
2794
  const jt = J2 == null ? void 0 : J2.value, Es = typeof jt == "string" && jt.charCodeAt(0) === 61 && ((J2 == null ? void 0 : J2.formulaEnabled) ?? true) ? this.processFormula(jt, { dependency: Mt, slideY: bs, slideX: Ss }) : jt, ke = this.registry.systems[Mt];
2794
2795
  ke != null && (ke.changedTime = D);
@@ -2849,14 +2850,14 @@ let Y$1 = class Y {
2849
2850
  * never diverge. Returns whether this cell triggered a resize. @internal
2850
2851
  */
2851
2852
  _applyUpdateCell(t, e, s, i, n, o, a = false) {
2852
- var f, d, p, m, y;
2853
+ var f, d, m, p, y;
2853
2854
  const l = this.registry.data[e];
2854
2855
  if (n.operator === "USER" && F(l == null ? void 0 : l.prevention, xt))
2855
2856
  return false;
2856
2857
  let h = a ? i : { ...i };
2857
2858
  n.formulaIdentify && "value" in h && (h.formulaEnabled ?? (l == null ? void 0 : l.formulaEnabled) ?? true) && (this.clearDependencies(e), h.value = this.processFormula(h.value, { dependency: e })), n.ignoreFields.forEach((g) => {
2858
2859
  h[g] = l == null ? void 0 : l[g];
2859
- }), n.operator === "USER" && F(l == null ? void 0 : l.prevention, St) && delete h.value, n.operator === "USER" && F(l == null ? void 0 : l.prevention, ae$1) && ((f = h == null ? void 0 : h.style) == null || delete f.justifyContent, (d = h == null ? void 0 : h.style) == null || delete d.alignItems), n.operator === "USER" && F(l == null ? void 0 : l.prevention, ce$1) && ((p = h == null ? void 0 : h.style) == null || delete p.width, (m = h == null ? void 0 : h.style) == null || delete m.height);
2860
+ }), n.operator === "USER" && F(l == null ? void 0 : l.prevention, St) && delete h.value, n.operator === "USER" && F(l == null ? void 0 : l.prevention, ae$1) && ((f = h == null ? void 0 : h.style) == null || delete f.justifyContent, (d = h == null ? void 0 : h.style) == null || delete d.alignItems), n.operator === "USER" && F(l == null ? void 0 : l.prevention, ce$1) && ((m = h == null ? void 0 : h.style) == null || delete m.width, (p = h == null ? void 0 : h.style) == null || delete p.height);
2860
2861
  let u = false;
2861
2862
  if ((h.width != null || h.height != null) && (u = true), o.diffBefore[e] = l ?? {}, h = (this.policies[(l == null ? void 0 : l.policy) || Nt] ?? this.defaultPolicy).select({ sheet: this, point: t, next: h, current: l, operation: n.op }) ?? h, n.updateChangedTime) {
2862
2863
  const g = this.registry.systems[e];
@@ -2926,7 +2927,7 @@ let Y$1 = class Y {
2926
2927
  yieldControl: c,
2927
2928
  frameBudgetMs: f = 12
2928
2929
  }) {
2929
- const d = { diffBefore: {}, diffAfter: {}, changedAddresses: [] }, p = {
2930
+ const d = { diffBefore: {}, diffAfter: {}, changedAddresses: [] }, m = {
2930
2931
  partial: e,
2931
2932
  updateChangedTime: s,
2932
2933
  ignoreFields: a,
@@ -2934,12 +2935,12 @@ let Y$1 = class Y {
2934
2935
  op: o,
2935
2936
  formulaIdentify: true,
2936
2937
  changedTime: Date.now()
2937
- }, m = Object.keys(t), y = m.length, g = c ?? (() => Promise.resolve());
2938
+ }, p = Object.keys(t), y = p.length, g = c ?? (() => Promise.resolve());
2938
2939
  let b = false, _2 = Date.now();
2939
2940
  u == null || u({ done: 0, total: y });
2940
2941
  for (let x = 0; x < y; x++) {
2941
- const w2 = m[x], E = T(w2);
2942
- this._applyUpdateCell(E, this.getId(E), w2, t[w2], p, d) && (b = true), Date.now() - _2 >= f && (u == null || u({ done: x + 1, total: y }), await g(), _2 = Date.now());
2942
+ const w2 = p[x], E = T(w2);
2943
+ this._applyUpdateCell(E, this.getId(E), w2, t[w2], m, d) && (b = true), Date.now() - _2 >= f && (u == null || u({ done: x + 1, total: y }), await g(), _2 = Date.now());
2943
2944
  }
2944
2945
  return this.lastChangedAddresses = d.changedAddresses, u == null || u({ done: y, total: y }), i && this._pushHistory({
2945
2946
  applyed: true,
@@ -2971,12 +2972,12 @@ let Y$1 = class Y {
2971
2972
  d++;
2972
2973
  continue;
2973
2974
  }
2974
- e[f].forEach((m, y) => {
2975
+ e[f].forEach((p, y) => {
2975
2976
  const g = u + y;
2976
2977
  if (g > this.right)
2977
2978
  return;
2978
- const b = { y: d, x: g }, _2 = this.parse(b, m.value ?? "");
2979
- if (_2.style = { ...m.style, ..._2.style }, n) {
2979
+ const b = { y: d, x: g }, _2 = this.parse(b, p.value ?? "");
2980
+ if (_2.style = { ...p.style, ..._2.style }, n) {
2980
2981
  const x = this.getCell(b, { resolution: "SYSTEM" });
2981
2982
  _2.style = x == null ? void 0 : x.style, _2.justifyContent = x == null ? void 0 : x.justifyContent, _2.alignItems = x == null ? void 0 : x.alignItems;
2982
2983
  }
@@ -3025,14 +3026,14 @@ let Y$1 = class Y {
3025
3026
  return console.error(`Rows are limited to ${this.maxNumRows}.`), this;
3026
3027
  const u = this.numCols, c = [], f = Date.now();
3027
3028
  for (let d = 0; d < e; d++) {
3028
- const p = [];
3029
- for (let m = 0; m <= u; m++) {
3029
+ const m = [];
3030
+ for (let p = 0; p <= u; p++) {
3030
3031
  const y = this._generateId();
3031
- p.push(y);
3032
- const g = this.getCell({ y: s, x: m }, { resolution: "SYSTEM" }), b = this._copyCellLayout(g);
3032
+ m.push(y);
3033
+ const g = this.getCell({ y: s, x: p }, { resolution: "SYSTEM" }), b = this._copyCellLayout(g);
3033
3034
  this.registry.data[y] = { ...b }, this.registry.systems[y] = { id: y, sheetId: this.id, changedTime: f };
3034
3035
  }
3035
- c.push(p);
3036
+ c.push(m);
3036
3037
  }
3037
3038
  if (this.idMatrix.splice(t, 0, ...c), this.area.bottom += e, this._shiftRowMetaForInsert(t, e), this._seedRowMeta(t, e), this._pushHistory({
3038
3039
  applyed: true,
@@ -3074,8 +3075,8 @@ let Y$1 = class Y {
3074
3075
  if (s === "USER" && F(f == null ? void 0 : f.prevention, ne$1))
3075
3076
  return console.warn(`Cannot delete row ${c}.`), this;
3076
3077
  for (let d = 1; d <= this.numCols; d++) {
3077
- const p = this.getId({ y: c, x: d });
3078
- p != null && (o.collectDependents(p), o.map[p] = this.getId({ y: c + e, x: d }));
3078
+ const m = this.getId({ y: c, x: d });
3079
+ m != null && (o.collectDependents(m), o.map[m] = this.getId({ y: c + e, x: d }));
3079
3080
  }
3080
3081
  a.unshift(c);
3081
3082
  }
@@ -3121,14 +3122,14 @@ let Y$1 = class Y {
3121
3122
  return console.error(`Columns are limited to ${this.maxNumCols}.`), this;
3122
3123
  const u = this.numRows, c = [], f = Date.now();
3123
3124
  for (let d = 0; d <= u; d++) {
3124
- const p = [];
3125
- for (let m = 0; m < e; m++) {
3125
+ const m = [];
3126
+ for (let p = 0; p < e; p++) {
3126
3127
  const y = this._generateId();
3127
- p.push(y);
3128
+ m.push(y);
3128
3129
  const g = this.getCell({ y: d, x: s }, { resolution: "SYSTEM" }), b = this._copyCellLayout(g);
3129
3130
  this._ensureIdRow(d).splice(t, 0, y), this.registry.data[y] = { ...b }, this.registry.systems[y] = { id: y, sheetId: this.id, changedTime: f };
3130
3131
  }
3131
- c.push(p);
3132
+ c.push(m);
3132
3133
  }
3133
3134
  if (this.area.right += e, this._pushHistory({
3134
3135
  applyed: true,
@@ -3172,8 +3173,8 @@ let Y$1 = class Y {
3172
3173
  continue;
3173
3174
  }
3174
3175
  for (let d = 1; d <= this.numRows; d++) {
3175
- const p = this.getId({ y: d, x: c });
3176
- p != null && (o.collectDependents(p), o.map[p] = this.getId({ y: d, x: c + e }));
3176
+ const m = this.getId({ y: d, x: c });
3177
+ m != null && (o.collectDependents(m), o.map[m] = this.getId({ y: d, x: c + e }));
3177
3178
  }
3178
3179
  a.unshift(c);
3179
3180
  }
@@ -3687,12 +3688,12 @@ const we = ({ value: r, sheet: t, point: e, raise: s = true, resolution: i = "RE
3687
3688
  if (d != null)
3688
3689
  return d;
3689
3690
  r.setSolvingCache(c);
3690
- const p = we({ value: l, sheet: r, point: c, raise: t, at: e, resolution: "RESOLVED" });
3691
- return r.finishSolvedCache(c, p), p;
3692
- } catch (p) {
3693
- if (r.finishSolvedCache(c, p), t)
3694
- throw p;
3695
- return p;
3691
+ const m = we({ value: l, sheet: r, point: c, raise: t, at: e, resolution: "RESOLVED" });
3692
+ return r.finishSolvedCache(c, m), m;
3693
+ } catch (m) {
3694
+ if (r.finishSolvedCache(c, m), t)
3695
+ throw m;
3696
+ return m;
3696
3697
  }
3697
3698
  });
3698
3699
  });
@@ -3735,7 +3736,8 @@ const we = ({ value: r, sheet: t, point: e, raise: s = true, resolution: i = "RE
3735
3736
  const c = i.data[t];
3736
3737
  c != null && ee$1(c, e, { value: u, expireTime: h.expireTime });
3737
3738
  }).finally(() => {
3738
- i.asyncPending.delete(a);
3739
+ var u;
3740
+ i.asyncPending.delete(a), (u = i.onAsyncResolve) == null || u.call(i, t);
3739
3741
  }), h.pending;
3740
3742
  }
3741
3743
  return xe;
@@ -3749,7 +3751,8 @@ const we = ({ value: r, sheet: t, point: e, raise: s = true, resolution: i = "RE
3749
3751
  const c = o.data[e];
3750
3752
  c != null && ee$1(c, s, { value: u, expireTime: a });
3751
3753
  }).finally(() => {
3752
- o.asyncPending.delete(l), n && o.asyncInflight && o.asyncInflight.delete(s), o.solvedCaches.clear(), o.transmit();
3754
+ var u;
3755
+ o.asyncPending.delete(l), n && o.asyncInflight && o.asyncInflight.delete(s), (u = o.onAsyncResolve) == null || u.call(o, e), o.solvedCaches.clear(), o.transmit();
3753
3756
  }), h;
3754
3757
  }, de$1 = () => new L(Promise.resolve()), Me = (r, t) => {
3755
3758
  if (typeof r == "string" || typeof t == "string")
@@ -4129,10 +4132,10 @@ const vi = /^(<=|>=|<>|>|<|=)?(.*)$/, ki = (r, t) => {
4129
4132
  for (let h = 0; h < n; h++) {
4130
4133
  const u = [];
4131
4134
  for (let c = 0; c < o; c++) {
4132
- const f = i.map((d, p) => {
4135
+ const f = i.map((d, m) => {
4133
4136
  var y;
4134
- const m = s[p];
4135
- return m ? ((y = m == null ? void 0 : m[h]) == null ? void 0 : y[c]) ?? null : d;
4137
+ const p = s[m];
4138
+ return p ? ((y = p == null ? void 0 : p[h]) == null ? void 0 : y[c]) ?? null : d;
4136
4139
  });
4137
4140
  try {
4138
4141
  if (Ci(f))
@@ -4767,18 +4770,20 @@ class Hr {
4767
4770
  onInsertCols: h,
4768
4771
  onSelect: u,
4769
4772
  onKeyUp: c,
4770
- onInit: f
4773
+ onInit: f,
4774
+ onFormula: d,
4775
+ onAsyncResolve: m
4771
4776
  } = {}) {
4772
- this.sheetHead = 0, this.cellHead = 0, this.data = {}, this.systems = {}, this.sheetIdsByName = {}, this.contextsBySheetId = {}, this.choosingSheetId = 0, this.choosingAddress = "", this.editingSheetId = 0, this.editingAddress = "", this.paletteBySheetName = {}, this.lastFocused = null, this.solvedCaches = /* @__PURE__ */ new Map(), this.lastSpilledTargetIds = /* @__PURE__ */ new Set(), this.asyncFormulaCells = /* @__PURE__ */ new Set(), this.asyncPending = /* @__PURE__ */ new Map(), this.copyingSheetId = 0, this.copyingZone = Ms, this.cutting = false, this.histories = [], this.historyIndex = -1, this.historyLimit = Cs, this._componentSheetIds = /* @__PURE__ */ new Map(), this.ready = false, this.functions = {}, this.policies = {}, this.transmit = (d) => {
4773
- }, this.updateSheet = (d) => ({ type: 0, value: d }), t != null && (this.historyLimit = t), this.functions = {
4777
+ this.sheetHead = 0, this.cellHead = 0, this.data = {}, this.systems = {}, this.sheetIdsByName = {}, this.contextsBySheetId = {}, this.choosingSheetId = 0, this.choosingAddress = "", this.editingSheetId = 0, this.editingAddress = "", this.paletteBySheetName = {}, this.lastFocused = null, this.solvedCaches = /* @__PURE__ */ new Map(), this.lastSpilledTargetIds = /* @__PURE__ */ new Set(), this.asyncFormulaCells = /* @__PURE__ */ new Set(), this.asyncPending = /* @__PURE__ */ new Map(), this.copyingSheetId = 0, this.copyingZone = Ms, this.cutting = false, this.histories = [], this.historyIndex = -1, this.historyLimit = Cs, this._componentSheetIds = /* @__PURE__ */ new Map(), this.ready = false, this.functions = {}, this.policies = {}, this.transmit = (p) => {
4778
+ }, this.updateSheet = (p) => ({ type: 0, value: p }), t != null && (this.historyLimit = t), this.functions = {
4774
4779
  ...gs,
4775
4780
  ...e
4776
4781
  };
4777
- for (const d in this.functions) {
4778
- const p = this.functions[d];
4779
- p.__name = d;
4782
+ for (const p in this.functions) {
4783
+ const y = this.functions[p];
4784
+ y.__name = p;
4780
4785
  }
4781
- this.policies = s, this.onSave = i, this.onChange = n, this.onRemoveRows = o, this.onRemoveCols = a, this.onInsertRows = l, this.onInsertCols = h, this.onSelect = u, this.onKeyUp = c, this.onInit = f;
4786
+ this.policies = s, this.onSave = i, this.onChange = n, this.onRemoveRows = o, this.onRemoveCols = a, this.onInsertRows = l, this.onInsertCols = h, this.onSelect = u, this.onKeyUp = c, this.onInit = f, this.onFormula = d, this.onAsyncResolve = m;
4782
4787
  }
4783
4788
  boot() {
4784
4789
  if (this.ready || Object.keys(this.contextsBySheetId).length === 0)
@@ -4853,14 +4858,14 @@ class Hn {
4853
4858
  var c, f;
4854
4859
  const [t, e] = Ze[this.direction], { top: s, left: i, bottom: n, right: o } = this.src, a = Jt(n - s + 1, o - i + 1);
4855
4860
  for (let d = s; d <= n; d++)
4856
- for (let p = i; p <= o; p++)
4857
- a[d - s][p - i] = this.sheet.getCell({ y: d, x: p }, { resolution: "SYSTEM" }) ?? null;
4861
+ for (let m = i; m <= o; m++)
4862
+ a[d - s][m - i] = this.sheet.getCell({ y: d, x: m }, { resolution: "SYSTEM" }) ?? null;
4858
4863
  const l = me$1(this.src), h = me$1(this.dst), u = {};
4859
4864
  if (t === "horizontal")
4860
4865
  for (let d = 0; d < h.rows; d++) {
4861
- const p = this.getChangePatterns(a[d], "");
4862
- for (let m = 0; m < h.cols; m++) {
4863
- const y = (c = a[d % l.rows]) == null ? void 0 : c[m % l.cols], g = e > 0 ? this.dst.left + m : this.dst.right - m, b = e > 0 ? m % l.cols : (l.cols - 1 - m % l.cols) % l.cols, _2 = { y: this.dst.top + d, x: g }, x = this.sheet.getId(_2), w2 = p[b].next().value, E = (y == null ? void 0 : y.formulaEnabled) ?? true ? this.sheet.processFormula(w2, {
4866
+ const m = this.getChangePatterns(a[d], "");
4867
+ for (let p = 0; p < h.cols; p++) {
4868
+ const y = (c = a[d % l.rows]) == null ? void 0 : c[p % l.cols], g = e > 0 ? this.dst.left + p : this.dst.right - p, b = e > 0 ? p % l.cols : (l.cols - 1 - p % l.cols) % l.cols, _2 = { y: this.dst.top + d, x: g }, x = this.sheet.getId(_2), w2 = m[b].next().value, E = (y == null ? void 0 : y.formulaEnabled) ?? true ? this.sheet.processFormula(w2, {
4864
4869
  dependency: x
4865
4870
  }) : w2;
4866
4871
  u[M(_2)] = {
@@ -4871,12 +4876,12 @@ class Hn {
4871
4876
  }
4872
4877
  else if (t === "vertical")
4873
4878
  for (let d = 0; d < h.cols; d++) {
4874
- const p = this.getChangePatterns(
4875
- a.map((m) => m[d]),
4879
+ const m = this.getChangePatterns(
4880
+ a.map((p) => p[d]),
4876
4881
  ""
4877
4882
  );
4878
- for (let m = 0; m < h.rows; m++) {
4879
- const y = (f = a[m % l.rows]) == null ? void 0 : f[d % l.cols], g = e > 0 ? this.dst.top + m : this.dst.bottom - m, b = e > 0 ? m % l.rows : (l.rows - 1 - m % l.rows) % l.rows, _2 = p[b].next().value;
4883
+ for (let p = 0; p < h.rows; p++) {
4884
+ const y = (f = a[p % l.rows]) == null ? void 0 : f[d % l.cols], g = e > 0 ? this.dst.top + p : this.dst.bottom - p, b = e > 0 ? p % l.rows : (l.rows - 1 - p % l.rows) % l.rows, _2 = m[b].next().value;
4880
4885
  u[M({ y: g, x: this.dst.left + d })] = { ...y, value: _2 };
4881
4886
  }
4882
4887
  }
@@ -5001,9 +5006,9 @@ class Hn {
5001
5006
  function* h() {
5002
5007
  const { prefix: c } = lt(a.first), { number: f } = lt(l);
5003
5008
  let d = f;
5004
- const p = a.numericDelta * o;
5009
+ const m = a.numericDelta * o;
5005
5010
  for (; ; )
5006
- d += p, yield `${c}${Math.abs(d)}`;
5011
+ d += m, yield `${c}${Math.abs(d)}`;
5007
5012
  }
5008
5013
  const u = h();
5009
5014
  s.push(u, ...a.nexts.map(() => u));
@@ -7186,4 +7191,4 @@ export {
7186
7191
  arrow as y,
7187
7192
  escape as z
7188
7193
  };
7189
- //# sourceMappingURL=hooks-BHtHkTAN.mjs.map
7194
+ //# sourceMappingURL=hooks-CWD7gJMA.mjs.map