@poe-platform/safe-bash 0.1.747 → 0.1.748

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.
@@ -3861,7 +3861,7 @@ var Interpreter = class _Interpreter {
3861
3861
  if (!isNumber(input)) throw new JqError(`${describe(input, budget)} cannot be ${name}ed`);
3862
3862
  budget.step();
3863
3863
  const n = numberValue(input);
3864
- yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.round(n) : Math.abs(n);
3864
+ yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.sign(n) * Math.round(Math.abs(n)) : Math.abs(n);
3865
3865
  return;
3866
3866
  }
3867
3867
  if (name === "implode") {
@@ -3874,10 +3874,11 @@ var Interpreter = class _Interpreter {
3874
3874
  }
3875
3875
  const el = input[i];
3876
3876
  const cp = isNumber(el) ? numberValue(el) : NaN;
3877
- if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {
3877
+ if (!isNumber(el)) {
3878
3878
  throw new JqError("implode elements must be Unicode codepoints");
3879
3879
  }
3880
- out += String.fromCodePoint(cp);
3880
+ const point = Math.trunc(cp);
3881
+ out += String.fromCodePoint(!Number.isFinite(point) || point < 0 || point > 1114111 || point >= 55296 && point <= 57343 ? 65533 : point);
3881
3882
  }
3882
3883
  budget.value(out);
3883
3884
  yield out;
@@ -5144,4 +5145,4 @@ export {
5144
5145
  moduleProgram,
5145
5146
  parse
5146
5147
  };
5147
- //# sourceMappingURL=chunk-JCXAGOEK.js.map
5148
+ //# sourceMappingURL=chunk-K3LGRJMX.js.map
@@ -48690,7 +48690,8 @@ var lookupSpecialForms = {
48690
48690
  if (!args.length || args.length > 4) return error("#VALUE!");
48691
48691
  let source = args[0];
48692
48692
  while (source.kind === "parentheses") source = source.child;
48693
- let value3 = host.evaluate(source, false);
48693
+ const areaSet = source.kind === "binary" && source.op === "union";
48694
+ let value3 = host.evaluate(source, areaSet);
48694
48695
  if (value3.kind === "error") return value3;
48695
48696
  const offsets = [0, 0, 0];
48696
48697
  for (let index2 = 1; index2 < args.length; index2++) {
@@ -48700,11 +48701,17 @@ var lookupSpecialForms = {
48700
48701
  if (n === void 0) return error("#VALUE!");
48701
48702
  offsets[index2 - 1] = Math.trunc(n) - 1;
48702
48703
  }
48703
- if (source.kind === "binary" && source.op === "union") {
48704
- if (value3.kind === "matrix") {
48705
- if (offsets[2] < 0 || offsets[2] >= value3.rows.length) return error("#REF!");
48706
- value3 = value3.rows[offsets[2]][0];
48707
- } else return error("#REF!");
48704
+ if (areaSet) {
48705
+ const areas = [], pending = [value3];
48706
+ while (pending.length) {
48707
+ host.tick();
48708
+ const area = pending.pop();
48709
+ if (area.kind === "set") for (let index2 = area.values.length - 1; index2 >= 0; index2--) pending.push(area.values[index2]);
48710
+ else areas.push(area);
48711
+ }
48712
+ if (offsets[2] < 0 || offsets[2] >= areas.length) return error("#REF!");
48713
+ value3 = areas[offsets[2]];
48714
+ if (value3.kind === "error") return value3;
48708
48715
  } else if (offsets[2] !== 0) return error("#REF!");
48709
48716
  const row = offsets[0], column = offsets[1], dims = dimensions(value3);
48710
48717
  if (row < 0 || column < 0 || row >= dims.height || column >= dims.width) return error("#REF!");
@@ -86932,6 +86939,7 @@ function lotusExternalVariable(name5) {
86932
86939
  async function lotusFormula(bytes, format3, group, row, column, sheetIndex, sheetName2, context2, consumeOperation, functions2 = lotusFunctions, names2, legacyReferenceLayout) {
86933
86940
  const b3 = new Binary(bytes), stack = [], modern = format3 !== "wk1";
86934
86941
  const relativeReferences = /* @__PURE__ */ new Map();
86942
+ const indexRanges = /* @__PURE__ */ new Map();
86935
86943
  let at = 0;
86936
86944
  const pop = async () => {
86937
86945
  if (stack.length) return stack.pop();
@@ -86939,7 +86947,8 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
86939
86947
  return "#REF!";
86940
86948
  };
86941
86949
  const ref = (r, c4, rr, cr) => {
86942
- if (r < 0 || c4 < 0) return "#REF!";
86950
+ const rows = modern || legacyReferenceLayout === void 0 ? 65536 : legacyReferenceLayout === "wk1" ? 2048 : 16384;
86951
+ if (r < 0 || r >= rows || c4 < 0 || c4 >= 256) return "#REF!";
86943
86952
  const a3 = formatA1(r, c4);
86944
86953
  let i4 = 0;
86945
86954
  while (a3[i4] >= "A" && a3[i4] <= "Z") i4++;
@@ -86949,13 +86958,13 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
86949
86958
  const c4 = b3.u16(p2), r = b3.u16(p2 + 2), cr = !!(c4 & 32768), rr = !!(r & 32768);
86950
86959
  if (legacyReferenceLayout === "works3" || legacyReferenceLayout === "symphony") {
86951
86960
  const axis = (raw, origin, bits3) => {
86952
- if (!(raw & 32768)) return raw;
86961
+ if (!(raw & 32768)) return raw & (1 << bits3) - 1;
86953
86962
  const shift = 32 - bits3, boundary = 2 ** (bits3 - 1);
86954
86963
  let delta = raw << shift >> shift;
86955
86964
  if (delta + origin >= boundary) delta -= boundary;
86956
86965
  return origin + delta;
86957
86966
  };
86958
- let targetColumn = c4;
86967
+ let targetColumn = c4 & 255;
86959
86968
  if (legacyReferenceLayout === "symphony" && cr) {
86960
86969
  let delta = c4 & 255;
86961
86970
  if (delta & 128 && delta + column >= 256) delta -= 256;
@@ -86983,6 +86992,10 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
86983
86992
  const target = b3.u8(p2 + 2), name5 = sheetName2(target);
86984
86993
  return (target === sheetIndex && !qualifySheet ? "" : quoteFormulaString(name5, "'", gnumericGrammar) + "!") + ref(b3.u16(p2), b3.u8(p2 + 3), !!(flags2 & 2), !!(flags2 & 1));
86985
86994
  };
86995
+ const rangeReference = (first, last2) => {
86996
+ if (first.endsWith("#REF!") || last2?.endsWith("#REF!")) return "#REF!";
86997
+ return first + (last2 === void 0 ? "" : ":" + last2);
86998
+ };
86986
86999
  while (at < bytes.length) {
86987
87000
  context2.signal.throwIfAborted();
86988
87001
  const op = b3.u8(at++);
@@ -87016,8 +87029,17 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
87016
87029
  const name5 = `LOTUS_SHEET_REFERENCE_${relativeReferences.size}`;
87017
87030
  relativeReferences.set(name5, { kind: "reference", start: 0, end: 0, first, ...last2 ? { last: last2 } : {} });
87018
87031
  stack.push(name5);
87019
- } else stack.push(newRef(at + 1, flags2 & 7, crossSheet) + (op === 2 ? `:${newRef(at + 5, flags2 >> 3 & 7, crossSheet)}` : ""));
87020
- } else stack.push(oldRef(at) + (op === 2 ? `:${oldRef(at + 4)}` : ""));
87032
+ } else {
87033
+ const source = rangeReference(newRef(at + 1, flags2 & 7, crossSheet), op === 2 ? newRef(at + 5, flags2 >> 3 & 7, crossSheet) : void 0);
87034
+ stack.push(source);
87035
+ if (crossSheet) indexRanges.set(source, {
87036
+ firstSheet: b3.u8(at + 3),
87037
+ lastSheet: b3.u8(at + 7),
87038
+ first: ref(b3.u16(at + 1), b3.u8(at + 4), !!(flags2 & 2), !!(flags2 & 1)),
87039
+ last: ref(b3.u16(at + 5), b3.u8(at + 8), !!(flags2 & 16), !!(flags2 & 8))
87040
+ });
87041
+ }
87042
+ } else stack.push(rangeReference(oldRef(at), op === 2 ? oldRef(at + 4) : void 0));
87021
87043
  at += length;
87022
87044
  } else if (op === 5) {
87023
87045
  const length = format3 === "123" ? 4 : 2;
@@ -87056,7 +87078,14 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
87056
87078
  const crossSheet = range5.first.sheet !== range5.last.sheet;
87057
87079
  const endpoint = (point) => (point.sheet === sheetIndex && !crossSheet ? "" : quoteFormulaString(sheetName2(point.sheet), "'", gnumericGrammar) + "!") + ref(point.row, point.column, op === 7, op === 7);
87058
87080
  const single = range5.first.row === range5.last.row && range5.first.column === range5.last.column && range5.first.sheet === range5.last.sheet;
87059
- stack.push(endpoint(range5.first) + (single ? "" : ":" + endpoint(range5.last)));
87081
+ const source = endpoint(range5.first) + (single ? "" : ":" + endpoint(range5.last));
87082
+ stack.push(source);
87083
+ if (crossSheet) indexRanges.set(source, {
87084
+ firstSheet: range5.first.sheet,
87085
+ lastSheet: range5.last.sheet,
87086
+ first: ref(range5.first.row, range5.first.column, op === 7, op === 7),
87087
+ last: ref(range5.last.row, range5.last.column, op === 7, op === 7)
87088
+ });
87060
87089
  }
87061
87090
  } else if (modern && op >= 9 && op <= 11) {
87062
87091
  const length = op === 9 ? 4 : op === 10 ? 5 : 11;
@@ -87100,7 +87129,7 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
87100
87129
  }
87101
87130
  const operands = [];
87102
87131
  for (let i4 = 0; i4 < args; i4++) operands.unshift(await pop());
87103
- let subtract3 = 0;
87132
+ let subtract3 = info?.[3] === "wk1_year_func" ? 1900 : 0;
87104
87133
  if (functions2 === lotusFunctions) {
87105
87134
  switch (info?.[1]) {
87106
87135
  case "CHOOSE":
@@ -87118,19 +87147,36 @@ async function lotusFormula(bytes, format3, group, row, column, sheetIndex, shee
87118
87147
  case "HLOOKUP":
87119
87148
  if (operands.length === 3) operands[2] = `(${operands[2]}+1)`;
87120
87149
  break;
87150
+ case "DSUM":
87151
+ case "DAVG":
87152
+ case "DCNT":
87153
+ case "DMIN":
87154
+ case "DMAX":
87155
+ case "DVAR":
87156
+ case "DSTD":
87157
+ case "DPURECOUNT":
87158
+ if (operands.length > 1) operands[1] = `(${operands[1]}+1)`;
87159
+ break;
87121
87160
  case "INDEX":
87122
- if (operands.length === 3) {
87161
+ if (operands.length === 3 || operands.length === 4) {
87123
87162
  const [, column2, row2] = operands;
87124
87163
  operands[1] = `(${row2}+1)`;
87125
87164
  operands[2] = `(${column2}+1)`;
87165
+ if (operands.length === 4) operands[3] = `(${operands[3]}+1)`;
87166
+ const span2 = indexRanges.get(operands[0]);
87167
+ if (span2) {
87168
+ const choices = [];
87169
+ for (let index2 = Math.min(span2.firstSheet, span2.lastSheet); index2 <= Math.max(span2.firstSheet, span2.lastSheet); index2++) {
87170
+ consumeOperation();
87171
+ choices.push(quoteFormulaString(sheetName2(index2), "'", gnumericGrammar) + "!" + span2.first + ":" + span2.last);
87172
+ }
87173
+ operands[0] = `(${choices.join(",")})`;
87174
+ }
87126
87175
  }
87127
87176
  break;
87128
87177
  case "STRING":
87129
87178
  operands.push("TRUE()");
87130
87179
  break;
87131
- case "YEAR":
87132
- subtract3 = 1900;
87133
- break;
87134
87180
  case "ROUNDUP":
87135
87181
  case "ROUNDDOWN":
87136
87182
  if (operands.length === 3) operands.pop();
@@ -164350,4 +164396,4 @@ tslib/tslib.js:
164350
164396
  @noble/ciphers/utils.js:
164351
164397
  (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
164352
164398
  */
164353
- //# sourceMappingURL=chunk-55AGFLG5.js.map
164399
+ //# sourceMappingURL=chunk-MSEZFB2F.js.map
@@ -11,7 +11,7 @@ import {
11
11
  tryProcessFlatJsonChunkSync,
12
12
  tryProcessFlatSelectProjectChunkSync,
13
13
  tryWriteCompactSync
14
- } from "./chunk-JCXAGOEK.js";
14
+ } from "./chunk-K3LGRJMX.js";
15
15
  import {
16
16
  Budget,
17
17
  JqError,
@@ -2530,4 +2530,4 @@ export {
2530
2530
  createXmlCommands,
2531
2531
  xmlCommands
2532
2532
  };
2533
- //# sourceMappingURL=chunk-OF2PDE3W.js.map
2533
+ //# sourceMappingURL=chunk-RPNX7NO2.js.map
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  Interpreter,
14
14
  parse
15
- } from "./chunk-JCXAGOEK.js";
15
+ } from "./chunk-K3LGRJMX.js";
16
16
  import {
17
17
  Budget,
18
18
  Decimal,
@@ -2879,4 +2879,4 @@ export {
2879
2879
  createYqCommands,
2880
2880
  yqCommands
2881
2881
  };
2882
- //# sourceMappingURL=chunk-BS6QFRNX.js.map
2882
+ //# sourceMappingURL=chunk-XIWFKWNM.js.map
@@ -81,7 +81,7 @@ import {
81
81
  updateWorkbook,
82
82
  validSheetSize,
83
83
  visitFormula
84
- } from "./chunk-55AGFLG5.js";
84
+ } from "./chunk-MSEZFB2F.js";
85
85
  import "./chunk-CVAVQZSF.js";
86
86
  import "./chunk-RCM5PZBN.js";
87
87
  import "./chunk-LSRHLNCR.js";
@@ -171,4 +171,4 @@ export {
171
171
  validSheetSize,
172
172
  visitFormula
173
173
  };
174
- //# sourceMappingURL=src-T672TQJC.js.map
174
+ //# sourceMappingURL=src-2MBSXQOA.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-S3BO2NJT.js";
4
4
  import {
5
5
  Interpreter
6
- } from "./chunk-6742OVAC.js";
6
+ } from "./chunk-WX5IUIQK.js";
7
7
  import {
8
8
  Budget,
9
9
  JqLimitError,
@@ -1526,7 +1526,7 @@ var Interpreter = class _Interpreter {
1526
1526
  throw new JqError(`${describe(input, budget)} cannot be ${name}ed`);
1527
1527
  budget.step();
1528
1528
  const n = numberValue(input);
1529
- yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.round(n) : Math.abs(n);
1529
+ yield name === "floor" ? Math.floor(n) : name === "ceil" ? Math.ceil(n) : name === "round" ? Math.sign(n) * Math.round(Math.abs(n)) : Math.abs(n);
1530
1530
  return;
1531
1531
  }
1532
1532
  if (name === "implode") {
@@ -1541,10 +1541,11 @@ var Interpreter = class _Interpreter {
1541
1541
  }
1542
1542
  const el = input[i];
1543
1543
  const cp = isNumber(el) ? numberValue(el) : NaN;
1544
- if (!Number.isInteger(cp) || cp < 0 || cp > 1114111) {
1544
+ if (!isNumber(el)) {
1545
1545
  throw new JqError("implode elements must be Unicode codepoints");
1546
1546
  }
1547
- out += String.fromCodePoint(cp);
1547
+ const point = Math.trunc(cp);
1548
+ out += String.fromCodePoint(!Number.isFinite(point) || point < 0 || point > 1114111 || point >= 55296 && point <= 57343 ? 65533 : point);
1548
1549
  }
1549
1550
  budget.value(out);
1550
1551
  yield out;