@odoo/o-spreadsheet 17.4.0-alpha.2 → 17.4.0-alpha.4

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.
@@ -3,9 +3,9 @@
3
3
  /**
4
4
  * This file is generated by o-spreadsheet build tools. Do not edit it.
5
5
  * @see https://github.com/odoo/o-spreadsheet
6
- * @version 17.4.0-alpha.2
7
- * @date 2024-06-06T13:31:21.327Z
8
- * @hash e07794d
6
+ * @version 17.4.0-alpha.4
7
+ * @date 2024-06-12T14:00:22.046Z
8
+ * @hash cefb0e4
9
9
  */
10
10
 
11
11
  (function (exports, owl) {
@@ -310,7 +310,10 @@
310
310
  * Check if the object is a plain old javascript object.
311
311
  */
312
312
  function isPlainObject(obj) {
313
- return typeof obj === "object" && obj?.constructor === Object;
313
+ return (typeof obj === "object" &&
314
+ obj !== null &&
315
+ // obj.constructor can be undefined when there's no prototype (`Object.create(null, {})`)
316
+ (obj?.constructor === Object || obj?.constructor === undefined));
314
317
  }
315
318
  /**
316
319
  * Sanitize the name of a sheet, by eventually removing quotes
@@ -1824,22 +1827,28 @@
1824
1827
  */
1825
1828
  const getFormulaNumberRegex = memoize(function getFormulaNumberRegex(decimalSeparator) {
1826
1829
  decimalSeparator = escapeRegExp(decimalSeparator);
1827
- return new RegExp(`(^-?\\d+(${decimalSeparator}?\\d*(e\\d+)?)?|^-?${decimalSeparator}\\d+)(?!\\w|!)`);
1830
+ return new RegExp(`(?:^-?\\d+(?:${decimalSeparator}?\\d*(?:e\\d+)?)?|^-?${decimalSeparator}\\d+)(?!\\w|!)`);
1828
1831
  });
1829
1832
  const getNumberRegex = memoize(function getNumberRegex(locale) {
1830
1833
  const decimalSeparator = escapeRegExp(locale.decimalSeparator);
1831
1834
  const thousandsSeparator = escapeRegExp(locale.thousandsSeparator);
1832
- const pIntegerAndDecimals = `(\\d+(${thousandsSeparator}\\d{3,})*(${decimalSeparator}\\d*)?)`; // pattern that match integer number with or without decimal digits
1833
- const pOnlyDecimals = `(${decimalSeparator}\\d+)`; // pattern that match only expression with decimal digits
1834
- const pScientificFormat = "(e(\\+|-)?\\d+)?"; // pattern that match scientific format between zero and one time (should be placed before pPercentFormat)
1835
- const pPercentFormat = "(\\s*%)?"; // pattern that match percent symbol between zero and one time
1836
- const pNumber = "(\\s*" + pIntegerAndDecimals + "|" + pOnlyDecimals + ")" + pScientificFormat + pPercentFormat;
1837
- const pMinus = "(\\s*-)?"; // pattern that match negative symbol between zero and one time
1838
- const pCurrencyFormat = "(\\s*[\\$€])?";
1835
+ const pIntegerAndDecimals = `(?:\\d+(?:${thousandsSeparator}\\d{3,})*(?:${decimalSeparator}\\d*)?)`; // pattern that match integer number with or without decimal digits
1836
+ const pOnlyDecimals = `(?:${decimalSeparator}\\d+)`; // pattern that match only expression with decimal digits
1837
+ const pScientificFormat = "(?:e(?:\\+|-)?\\d+)?"; // pattern that match scientific format between zero and one time (should be placed before pPercentFormat)
1838
+ const pPercentFormat = "(?:\\s*%)?"; // pattern that match percent symbol between zero and one time
1839
+ const pNumber = "(?:\\s*" +
1840
+ pIntegerAndDecimals +
1841
+ "|" +
1842
+ pOnlyDecimals +
1843
+ ")" +
1844
+ pScientificFormat +
1845
+ pPercentFormat;
1846
+ const pMinus = "(?:\\s*-)?"; // pattern that match negative symbol between zero and one time
1847
+ const pCurrencyFormat = "(?:\\s*[\\$€])?";
1839
1848
  const p1 = pMinus + pCurrencyFormat + pNumber;
1840
1849
  const p2 = pMinus + pNumber + pCurrencyFormat;
1841
1850
  const p3 = pCurrencyFormat + pMinus + pNumber;
1842
- const pNumberExp = "^((" + [p1, p2, p3].join(")|(") + "))$";
1851
+ const pNumberExp = "^(?:(?:" + [p1, p2, p3].join(")|(?:") + "))$";
1843
1852
  const numberRegexp = new RegExp(pNumberExp, "i");
1844
1853
  return numberRegexp;
1845
1854
  });
@@ -2777,7 +2786,7 @@
2777
2786
  return false;
2778
2787
  }
2779
2788
  if (typeof operand === "number" && operator === "=") {
2780
- return toString(value) === toString(operand);
2789
+ return value.toString() === operand.toString();
2781
2790
  }
2782
2791
  if (operator === "<>" || operator === "=") {
2783
2792
  let result;
@@ -2837,14 +2846,13 @@
2837
2846
  if (countArg % 2 === 1) {
2838
2847
  throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));
2839
2848
  }
2840
- const dimRow = args[0].length;
2841
- const dimCol = args[0][0].length;
2849
+ const firstArg = toMatrix(args[0]);
2850
+ const dimRow = firstArg.length;
2851
+ const dimCol = firstArg[0].length;
2842
2852
  let predicates = [];
2843
2853
  for (let i = 0; i < countArg - 1; i += 2) {
2844
- const criteriaRange = args[i];
2845
- if (!isMatrix(criteriaRange) ||
2846
- criteriaRange.length !== dimRow ||
2847
- criteriaRange[0].length !== dimCol) {
2854
+ const criteriaRange = toMatrix(args[i]);
2855
+ if (criteriaRange.length !== dimRow || criteriaRange[0].length !== dimCol) {
2848
2856
  throw new EvaluationError(_t("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));
2849
2857
  }
2850
2858
  const description = toString(args[i + 1]);
@@ -2858,7 +2866,7 @@
2858
2866
  for (let j = 0; j < dimCol; j++) {
2859
2867
  let validatedPredicates = true;
2860
2868
  for (let k = 0; k < countArg - 1; k += 2) {
2861
- const criteriaValue = args[k][i][j].value;
2869
+ const criteriaValue = toMatrix(args[k])[i][j].value;
2862
2870
  const criterion = predicates[k / 2];
2863
2871
  validatedPredicates = evaluatePredicate(criteriaValue ?? undefined, criterion);
2864
2872
  if (!validatedPredicates) {
@@ -3523,10 +3531,8 @@
3523
3531
  const internalDate = parseDateTime(content, locale);
3524
3532
  return internalDate.format;
3525
3533
  }
3534
+ /** use this function only if the content corresponds to a number (means that isNumber(content) return true */
3526
3535
  function detectNumberFormat(content) {
3527
- if (!isNumber(content, DEFAULT_LOCALE)) {
3528
- return undefined;
3529
- }
3530
3536
  const digitBase = content.includes(".") ? "0.00" : "0";
3531
3537
  const matchedCurrencies = content.match(/[\$€]/);
3532
3538
  if (matchedCurrencies) {
@@ -4729,21 +4735,16 @@
4729
4735
  * Check if two zones are contiguous, ie. that they share a border
4730
4736
  */
4731
4737
  function areZoneContiguous(zone1, zone2) {
4732
- const u = union(zone1, zone2);
4733
4738
  if (zone1.right + 1 === zone2.left || zone1.left === zone2.right + 1) {
4734
- return getZoneHeight(u) <= getZoneHeight(zone1) + getZoneHeight(zone2);
4739
+ return ((zone1.top <= zone2.bottom && zone1.top >= zone2.top) ||
4740
+ (zone2.top <= zone1.bottom && zone2.top >= zone1.top));
4735
4741
  }
4736
4742
  if (zone1.bottom + 1 === zone2.top || zone1.top === zone2.bottom + 1) {
4737
- return getZoneWidth(u) <= getZoneWidth(zone1) + getZoneWidth(zone2);
4743
+ return ((zone1.left <= zone2.right && zone1.left >= zone2.left) ||
4744
+ (zone2.left <= zone1.right && zone2.left >= zone1.left));
4738
4745
  }
4739
4746
  return false;
4740
4747
  }
4741
- function getZoneHeight(zone) {
4742
- return zone.bottom - zone.top + 1;
4743
- }
4744
- function getZoneWidth(zone) {
4745
- return zone.right - zone.left + 1;
4746
- }
4747
4748
  /**
4748
4749
  * Merge contiguous and overlapping zones that are in the array into bigger zones
4749
4750
  */
@@ -5499,7 +5500,7 @@
5499
5500
  }
5500
5501
  }
5501
5502
 
5502
- function getClipboardDataPositions(zones) {
5503
+ function getClipboardDataPositions(sheetId, zones) {
5503
5504
  const lefts = new Set(zones.map((z) => z.left));
5504
5505
  const rights = new Set(zones.map((z) => z.right));
5505
5506
  const tops = new Set(zones.map((z) => z.top));
@@ -5513,7 +5514,7 @@
5513
5514
  const cellsPosition = clippedZones.map((zone) => positions(zone)).flat();
5514
5515
  const columnsIndexes = [...new Set(cellsPosition.map((p) => p.col))].sort((a, b) => a - b);
5515
5516
  const rowsIndexes = [...new Set(cellsPosition.map((p) => p.row))].sort((a, b) => a - b);
5516
- return { zones, clippedZones, columnsIndexes, rowsIndexes };
5517
+ return { sheetId, zones, clippedZones, columnsIndexes, rowsIndexes };
5517
5518
  }
5518
5519
  /**
5519
5520
  * The clipped zone is copied as many times as it fits in the target.
@@ -5563,8 +5564,8 @@
5563
5564
  isCutAllowed(data) {
5564
5565
  return "Success" /* CommandResult.Success */;
5565
5566
  }
5566
- getPasteTarget(target, content, options) {
5567
- return { zones: [] };
5567
+ getPasteTarget(sheetId, target, content, options) {
5568
+ return { zones: [], sheetId };
5568
5569
  }
5569
5570
  convertOSClipboardData(data) {
5570
5571
  return;
@@ -5602,7 +5603,7 @@
5602
5603
 
5603
5604
  class BorderClipboardHandler extends AbstractCellClipboardHandler {
5604
5605
  copy(data) {
5605
- const sheetId = this.getters.getActiveSheetId();
5606
+ const sheetId = data.sheetId;
5606
5607
  if (data.zones.length === 0) {
5607
5608
  return;
5608
5609
  }
@@ -5622,7 +5623,7 @@
5622
5623
  if (!content) {
5623
5624
  return;
5624
5625
  }
5625
- const sheetId = this.getters.getActiveSheetId();
5626
+ const sheetId = target.sheetId;
5626
5627
  if (options?.pasteOption === "asValue") {
5627
5628
  return;
5628
5629
  }
@@ -6152,7 +6153,7 @@
6152
6153
  if (!("zones" in data) || !data.zones.length) {
6153
6154
  return;
6154
6155
  }
6155
- const sheetId = this.getters.getActiveSheetId();
6156
+ const sheetId = data.sheetId;
6156
6157
  const zones = data.zones;
6157
6158
  if (!zones.length) {
6158
6159
  return {
@@ -6181,6 +6182,7 @@
6181
6182
  format: evaluatedCell.format,
6182
6183
  content,
6183
6184
  isFormula: false,
6185
+ parsedValue: evaluatedCell.value,
6184
6186
  };
6185
6187
  }
6186
6188
  cellsInRow.push({
@@ -6195,7 +6197,7 @@
6195
6197
  return {
6196
6198
  cells: clippedCells,
6197
6199
  zones: clippedZones,
6198
- sheetId: this.getters.getActiveSheetId(),
6200
+ sheetId: data.sheetId,
6199
6201
  };
6200
6202
  }
6201
6203
  isPasteAllowed(sheetId, target, content, clipboardOptions) {
@@ -6223,7 +6225,7 @@
6223
6225
  return;
6224
6226
  }
6225
6227
  const zones = target.zones;
6226
- const sheetId = this.getters.getActiveSheetId();
6228
+ const sheetId = target.sheetId;
6227
6229
  if (!options?.isCutOperation) {
6228
6230
  this.pasteFromCopy(sheetId, zones, content.cells, options);
6229
6231
  }
@@ -6231,11 +6233,12 @@
6231
6233
  this.pasteFromCut(sheetId, zones, content, options);
6232
6234
  }
6233
6235
  }
6234
- getPasteTarget(target, content, options) {
6236
+ getPasteTarget(sheetId, target, content, options) {
6235
6237
  const width = content.cells[0].length;
6236
6238
  const height = content.cells.length;
6237
6239
  if (options?.isCutOperation) {
6238
6240
  return {
6241
+ sheetId,
6239
6242
  zones: [
6240
6243
  {
6241
6244
  left: target[0].left,
@@ -6247,11 +6250,9 @@
6247
6250
  };
6248
6251
  }
6249
6252
  if (width === 1 && height === 1) {
6250
- return { zones: [] };
6253
+ return { zones: [], sheetId };
6251
6254
  }
6252
- return {
6253
- zones: getPasteZones(target, content.cells),
6254
- };
6255
+ return { sheetId, zones: getPasteZones(target, content.cells) };
6255
6256
  }
6256
6257
  pasteFromCut(sheetId, target, content, options) {
6257
6258
  this.clearClippedZones(content);
@@ -6374,7 +6375,7 @@
6374
6375
 
6375
6376
  class ChartClipboardHandler extends AbstractFigureClipboardHandler {
6376
6377
  copy(data) {
6377
- const sheetId = this.getters.getActiveSheetId();
6378
+ const sheetId = data.sheetId;
6378
6379
  const figure = this.getters.getFigure(sheetId, data.figureId);
6379
6380
  if (!figure) {
6380
6381
  throw new Error(`No figure for the given id: ${data.figureId}`);
@@ -6394,22 +6395,19 @@
6394
6395
  copiedChart,
6395
6396
  };
6396
6397
  }
6397
- getPasteTarget(target, content, options) {
6398
+ getPasteTarget(sheetId, target, content, options) {
6398
6399
  if (!content?.copiedFigure || !content?.copiedChart) {
6399
- return { zones: [] };
6400
+ return { zones: [], sheetId };
6400
6401
  }
6401
6402
  const newId = new UuidGenerator().uuidv4();
6402
- return {
6403
- zones: [],
6404
- figureId: newId,
6405
- };
6403
+ return { zones: [], figureId: newId, sheetId };
6406
6404
  }
6407
6405
  paste(target, clippedContent, options) {
6408
6406
  if (!clippedContent?.copiedFigure || !clippedContent?.copiedChart || !target.figureId) {
6409
6407
  return;
6410
6408
  }
6411
6409
  const { zones, figureId } = target;
6412
- const sheetId = this.getters.getActiveSheetId();
6410
+ const sheetId = target.sheetId;
6413
6411
  const numCols = this.getters.getNumberCols(sheetId);
6414
6412
  const numRows = this.getters.getNumberRows(sheetId);
6415
6413
  const targetX = this.getters.getColDimensions(sheetId, zones[0].left).start;
@@ -6455,7 +6453,7 @@
6455
6453
  return;
6456
6454
  }
6457
6455
  const { rowsIndexes, columnsIndexes } = data;
6458
- const sheetId = this.getters.getActiveSheetId();
6456
+ const sheetId = data.sheetId;
6459
6457
  const cellPositions = rowsIndexes.map((row) => columnsIndexes.map((col) => ({ col, row, sheetId })));
6460
6458
  return {
6461
6459
  cellPositions,
@@ -6469,7 +6467,7 @@
6469
6467
  return;
6470
6468
  }
6471
6469
  const zones = target.zones;
6472
- const sheetId = this.getters.getActiveSheetId();
6470
+ const sheetId = target.sheetId;
6473
6471
  if (!options?.isCutOperation) {
6474
6472
  this.pasteFromCopy(sheetId, zones, clippedContent.cellPositions);
6475
6473
  }
@@ -6550,7 +6548,7 @@
6550
6548
  return;
6551
6549
  }
6552
6550
  const { rowsIndexes, columnsIndexes } = data;
6553
- const sheetId = this.getters.getActiveSheetId();
6551
+ const sheetId = data.sheetId;
6554
6552
  const cellPositions = rowsIndexes.map((row) => columnsIndexes.map((col) => ({ col, row, sheetId })));
6555
6553
  return {
6556
6554
  cellPositions,
@@ -6567,7 +6565,7 @@
6567
6565
  return;
6568
6566
  }
6569
6567
  const zones = target.zones;
6570
- const sheetId = this.getters.getActiveSheetId();
6568
+ const sheetId = target.sheetId;
6571
6569
  if (!options?.isCutOperation) {
6572
6570
  this.pasteFromCopy(sheetId, zones, clippedContent.cellPositions);
6573
6571
  }
@@ -6646,7 +6644,7 @@
6646
6644
 
6647
6645
  class ImageClipboardHandler extends AbstractFigureClipboardHandler {
6648
6646
  copy(data) {
6649
- const sheetId = this.getters.getActiveSheetId();
6647
+ const sheetId = data.sheetId;
6650
6648
  const figure = this.getters.getFigure(sheetId, data.figureId);
6651
6649
  if (!figure) {
6652
6650
  throw new Error(`No figure for the given id: ${data.figureId}`);
@@ -6664,15 +6662,12 @@
6664
6662
  sheetId,
6665
6663
  };
6666
6664
  }
6667
- getPasteTarget(target, content, options) {
6665
+ getPasteTarget(sheetId, target, content, options) {
6668
6666
  if (!content?.copiedFigure || !content?.copiedImage) {
6669
- return { zones: [] };
6667
+ return { zones: [], sheetId };
6670
6668
  }
6671
6669
  const newId = new UuidGenerator().uuidv4();
6672
- return {
6673
- zones: [],
6674
- figureId: newId,
6675
- };
6670
+ return { sheetId, zones: [], figureId: newId };
6676
6671
  }
6677
6672
  paste(target, clippedContent, options) {
6678
6673
  if (!clippedContent?.copiedFigure || !clippedContent?.copiedImage || !target.figureId) {
@@ -6743,8 +6738,7 @@
6743
6738
  if (options?.isCutOperation || !("zones" in target) || !target.zones.length) {
6744
6739
  return;
6745
6740
  }
6746
- const sheetId = this.getters.getActiveSheetId();
6747
- this.pasteFromCopy(sheetId, target.zones, content.cells, options);
6741
+ this.pasteFromCopy(target.sheetId, target.zones, content.cells, options);
6748
6742
  }
6749
6743
  pasteZone(sheetId, col, row, cells) {
6750
6744
  for (const [r, rowCells] of cells.entries()) {
@@ -6804,7 +6798,7 @@
6804
6798
 
6805
6799
  class TableClipboardHandler extends AbstractCellClipboardHandler {
6806
6800
  copy(data) {
6807
- const sheetId = this.getters.getActiveSheetId();
6801
+ const sheetId = data.sheetId;
6808
6802
  const { rowsIndexes, columnsIndexes, zones } = data;
6809
6803
  if (!zones || !rowsIndexes.length || !columnsIndexes.length) {
6810
6804
  return { tableCells: [[]], sheetId };
@@ -6846,7 +6840,7 @@
6846
6840
  }
6847
6841
  return {
6848
6842
  tableCells,
6849
- sheetId: this.getters.getActiveSheetId(),
6843
+ sheetId: data.sheetId,
6850
6844
  };
6851
6845
  }
6852
6846
  /**
@@ -6868,7 +6862,7 @@
6868
6862
  return;
6869
6863
  }
6870
6864
  const zones = target.zones;
6871
- const sheetId = this.getters.getActiveSheetId();
6865
+ const sheetId = target.sheetId;
6872
6866
  if (!options?.isCutOperation) {
6873
6867
  this.pasteFromCopy(sheetId, zones, content.tableCells, options);
6874
6868
  }
@@ -7630,10 +7624,8 @@
7630
7624
  return undefined;
7631
7625
  }
7632
7626
 
7633
- function evaluateLiteral(content = "", localeFormat) {
7634
- const value = localeFormat.format === PLAIN_TEXT_FORMAT
7635
- ? content
7636
- : parseLiteral(content, localeFormat.locale);
7627
+ function evaluateLiteral(literalCell, localeFormat) {
7628
+ const value = localeFormat.format === PLAIN_TEXT_FORMAT ? literalCell.content : literalCell.parsedValue;
7637
7629
  const fPayload = { value, format: localeFormat.format };
7638
7630
  return createEvaluatedCell(fPayload, localeFormat.locale);
7639
7631
  }
@@ -7645,10 +7637,11 @@
7645
7637
  return null;
7646
7638
  }
7647
7639
  if (isNumber(content, DEFAULT_LOCALE)) {
7648
- return toNumber(content, DEFAULT_LOCALE);
7640
+ return parseNumber(content, DEFAULT_LOCALE);
7649
7641
  }
7650
- if (isDateTime(content, locale)) {
7651
- return toNumber(content, locale);
7642
+ const internalDate = parseDateTime(content, locale);
7643
+ if (internalDate) {
7644
+ return internalDate.value;
7652
7645
  }
7653
7646
  if (isBoolean(content)) {
7654
7647
  return content.toUpperCase() === "TRUE" ? true : false;
@@ -7660,9 +7653,14 @@
7660
7653
  if (!link) {
7661
7654
  return _createEvaluatedCell(fPayload, locale, cell);
7662
7655
  }
7656
+ const value = parseLiteral(link.label, locale);
7657
+ const format = fPayload.format ||
7658
+ (typeof value === "number"
7659
+ ? detectDateFormat(link.label, locale) || detectNumberFormat(link.label)
7660
+ : undefined);
7663
7661
  const linkPayload = {
7664
- value: parseLiteral(link.label, locale),
7665
- format: fPayload.format || detectDateFormat(link.label, locale) || detectNumberFormat(link.label),
7662
+ value,
7663
+ format,
7666
7664
  };
7667
7665
  return {
7668
7666
  ..._createEvaluatedCell(linkPayload, locale, cell),
@@ -10986,6 +10984,9 @@ stores.inject(MyMetaStore, storeInstance);
10986
10984
  if (types.some((t) => t.startsWith("RANGE"))) {
10987
10985
  result.acceptMatrix = true;
10988
10986
  }
10987
+ if (types.every((t) => t.startsWith("RANGE"))) {
10988
+ result.acceptMatrixOnly = true;
10989
+ }
10989
10990
  return result;
10990
10991
  }
10991
10992
  /**
@@ -11240,7 +11241,6 @@ stores.inject(MyMetaStore, storeInstance);
11240
11241
  arg("rows (number)", _t("The number of rows in the constrained array.")),
11241
11242
  arg("columns (number)", _t("The number of columns in the constrained array.")),
11242
11243
  ],
11243
- returns: ["RANGE<ANY>"],
11244
11244
  compute: function (array, rows, columns) {
11245
11245
  const _array = toMatrix(array);
11246
11246
  const _rowsArg = toInteger(rows?.value, this.locale);
@@ -11263,15 +11263,19 @@ stores.inject(MyMetaStore, storeInstance);
11263
11263
  arg("col_num (number, range<number>)", _t("The first column index of the columns to be returned.")),
11264
11264
  arg("col_num2 (number, range<number>, repeating)", _t("The columns indexes of the columns to be returned.")),
11265
11265
  ],
11266
- returns: ["RANGE<ANY>"],
11267
11266
  compute: function (array, ...columns) {
11268
11267
  const _array = toMatrix(array);
11269
11268
  const _columns = flattenRowFirst(columns, (item) => toInteger(item?.value, this.locale));
11270
- assert(() => _columns.every((col) => col > 0 && col <= _array.length), _t("The columns arguments must be between 1 and %s (got %s).", _array.length.toString(), (_columns.find((col) => col <= 0 || col > _array.length) || 0).toString()));
11269
+ const argOutOfRange = _columns.filter((col) => col === 0 || _array.length < Math.abs(col));
11270
+ assert(() => argOutOfRange.length === 0, _t("The columns arguments must be between -%s and %s (got %s), excluding 0.", _array.length.toString(), _array.length.toString(), argOutOfRange.join(",")));
11271
11271
  const result = Array(_columns.length);
11272
11272
  for (let col = 0; col < _columns.length; col++) {
11273
- const colIndex = _columns[col] - 1; // -1 because columns arguments are 1-indexed
11274
- result[col] = _array[colIndex];
11273
+ if (_columns[col] > 0) {
11274
+ result[col] = _array[_columns[col] - 1]; // -1 because columns arguments are 1-indexed
11275
+ }
11276
+ else {
11277
+ result[col] = _array[_array.length + _columns[col]];
11278
+ }
11275
11279
  }
11276
11280
  return result;
11277
11281
  },
@@ -11287,13 +11291,18 @@ stores.inject(MyMetaStore, storeInstance);
11287
11291
  arg("row_num (number, range<number>)", _t("The first row index of the rows to be returned.")),
11288
11292
  arg("row_num2 (number, range<number>, repeating)", _t("The rows indexes of the rows to be returned.")),
11289
11293
  ],
11290
- returns: ["RANGE<ANY>"],
11291
11294
  compute: function (array, ...rows) {
11292
11295
  const _array = toMatrix(array);
11293
11296
  const _rows = flattenRowFirst(rows, (item) => toInteger(item?.value, this.locale));
11294
11297
  const _nbColumns = _array.length;
11295
- assert(() => _rows.every((row) => row > 0 && row <= _array[0].length), _t("The rows arguments must be between 1 and %s (got %s).", _array[0].length.toString(), (_rows.find((row) => row <= 0 || row > _array[0].length) || 0).toString()));
11296
- return generateMatrix(_nbColumns, _rows.length, (col, row) => _array[col][_rows[row] - 1]); // -1 because rows arguments are 1-indexed
11298
+ const argOutOfRange = _rows.filter((row) => row === 0 || _array[0].length < Math.abs(row));
11299
+ assert(() => argOutOfRange.length === 0, _t("The rows arguments must be between -%s and %s (got %s), excluding 0.", _array[0].length.toString(), _array[0].length.toString(), argOutOfRange.join(",")));
11300
+ return generateMatrix(_nbColumns, _rows.length, (col, row) => {
11301
+ if (_rows[row] > 0) {
11302
+ return _array[col][_rows[row] - 1]; // -1 because columns arguments are 1-indexed
11303
+ }
11304
+ return _array[col][_array[col].length + _rows[row]];
11305
+ });
11297
11306
  },
11298
11307
  isExported: true,
11299
11308
  };
@@ -11308,7 +11317,6 @@ stores.inject(MyMetaStore, storeInstance);
11308
11317
  arg("columns (number, optional)", _t("The number of columns in the expanded array. If missing, columns will not be expanded.")),
11309
11318
  arg("pad_with (any, default=0)", _t("The value with which to pad.")), // @compatibility: on Excel, pad with #N/A
11310
11319
  ],
11311
- returns: ["RANGE<ANY>"],
11312
11320
  compute: function (arg, rows, columns, padWith = { value: 0 } // TODO : Replace with #N/A errors once it's supported
11313
11321
  ) {
11314
11322
  const _array = toMatrix(arg);
@@ -11329,7 +11337,6 @@ stores.inject(MyMetaStore, storeInstance);
11329
11337
  arg("range (any, range<any>)", _t("The first range to flatten.")),
11330
11338
  arg("range2 (any, range<any>, repeating)", _t("Additional ranges to flatten.")),
11331
11339
  ],
11332
- returns: ["RANGE<ANY>"],
11333
11340
  compute: function (...ranges) {
11334
11341
  return [flattenRowFirst(ranges, (val) => (val === undefined ? { value: "" } : val))];
11335
11342
  },
@@ -11344,7 +11351,6 @@ stores.inject(MyMetaStore, storeInstance);
11344
11351
  arg("data (range<number>)", _t("The array of ranges containing the values to be counted.")),
11345
11352
  arg("classes (number, range<number>)", _t("The range containing the set of classes.")),
11346
11353
  ],
11347
- returns: ["RANGE<NUMBER>"],
11348
11354
  compute: function (data, classes) {
11349
11355
  const _data = flattenRowFirst([data], (data) => data.value).filter((val) => typeof val === "number");
11350
11356
  const _classes = flattenRowFirst([classes], (data) => data.value).filter((val) => typeof val === "number");
@@ -11392,7 +11398,6 @@ stores.inject(MyMetaStore, storeInstance);
11392
11398
  arg("range1 (any, range<any>)", _t("The first range to be appended.")),
11393
11399
  arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
11394
11400
  ],
11395
- returns: ["RANGE<ANY>"],
11396
11401
  compute: function (...ranges) {
11397
11402
  const nbRows = Math.max(...ranges.map((r) => r?.[0]?.length ?? 0));
11398
11403
  const result = [];
@@ -11419,7 +11424,6 @@ stores.inject(MyMetaStore, storeInstance);
11419
11424
  args: [
11420
11425
  arg("square_matrix (number, range<number>)", _t("An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.")),
11421
11426
  ],
11422
- returns: ["NUMBER"],
11423
11427
  compute: function (matrix) {
11424
11428
  const _matrix = toNumberMatrix(matrix, "square_matrix");
11425
11429
  assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
@@ -11435,7 +11439,6 @@ stores.inject(MyMetaStore, storeInstance);
11435
11439
  args: [
11436
11440
  arg("square_matrix (number, range<number>)", _t("An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.")),
11437
11441
  ],
11438
- returns: ["RANGE<NUMBER>"],
11439
11442
  compute: function (matrix) {
11440
11443
  const _matrix = toNumberMatrix(matrix, "square_matrix");
11441
11444
  assertSquareMatrix(_t("The argument square_matrix must have the same number of columns and rows."), _matrix);
@@ -11456,7 +11459,6 @@ stores.inject(MyMetaStore, storeInstance);
11456
11459
  arg("matrix1 (number, range<number>)", _t("The first matrix in the matrix multiplication operation.")),
11457
11460
  arg("matrix2 (number, range<number>)", _t("The second matrix in the matrix multiplication operation.")),
11458
11461
  ],
11459
- returns: ["RANGE<NUMBER>"],
11460
11462
  compute: function (matrix1, matrix2) {
11461
11463
  const _matrix1 = toNumberMatrix(matrix1, "matrix1");
11462
11464
  const _matrix2 = toNumberMatrix(matrix2, "matrix2");
@@ -11475,7 +11477,6 @@ stores.inject(MyMetaStore, storeInstance);
11475
11477
  arg("range1 (number, range<number>)", _t("The first range whose entries will be multiplied with corresponding entries in the other ranges.")),
11476
11478
  arg("range2 (number, range<number>, repeating)", _t("The other range whose entries will be multiplied with corresponding entries in the other ranges.")),
11477
11479
  ],
11478
- returns: ["NUMBER"],
11479
11480
  compute: function (...args) {
11480
11481
  assertSameDimensions(_t("All the ranges must have the same dimensions."), ...args);
11481
11482
  const _args = args.map(toMatrix);
@@ -11532,7 +11533,6 @@ stores.inject(MyMetaStore, storeInstance);
11532
11533
  arg("array_x (number, range<number>)", _t("The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.")),
11533
11534
  arg("array_y (number, range<number>)", _t("The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.")),
11534
11535
  ],
11535
- returns: ["NUMBER"],
11536
11536
  compute: function (arrayX, arrayY) {
11537
11537
  return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 - y ** 2);
11538
11538
  },
@@ -11547,7 +11547,6 @@ stores.inject(MyMetaStore, storeInstance);
11547
11547
  arg("array_x (number, range<number>)", _t("The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.")),
11548
11548
  arg("array_y (number, range<number>)", _t("The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.")),
11549
11549
  ],
11550
- returns: ["NUMBER"],
11551
11550
  compute: function (arrayX, arrayY) {
11552
11551
  return getSumXAndY(arrayX, arrayY, (x, y) => x ** 2 + y ** 2);
11553
11552
  },
@@ -11562,7 +11561,6 @@ stores.inject(MyMetaStore, storeInstance);
11562
11561
  arg("array_x (number, range<number>)", _t("The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.")),
11563
11562
  arg("array_y (number, range<number>)", _t("The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.")),
11564
11563
  ],
11565
- returns: ["NUMBER"],
11566
11564
  compute: function (arrayX, arrayY) {
11567
11565
  return getSumXAndY(arrayX, arrayY, (x, y) => (x - y) ** 2);
11568
11566
  },
@@ -11598,7 +11596,6 @@ stores.inject(MyMetaStore, storeInstance);
11598
11596
  const TOCOL = {
11599
11597
  description: _t("Transforms a range of cells into a single column."),
11600
11598
  args: TO_COL_ROW_ARGS,
11601
- returns: ["RANGE<ANY>"],
11602
11599
  compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
11603
11600
  const _array = toMatrix(array);
11604
11601
  const _ignore = toNumber(ignore.value, this.locale);
@@ -11619,7 +11616,6 @@ stores.inject(MyMetaStore, storeInstance);
11619
11616
  const TOROW = {
11620
11617
  description: _t("Transforms a range of cells into a single row."),
11621
11618
  args: TO_COL_ROW_ARGS,
11622
- returns: ["RANGE<ANY>"],
11623
11619
  compute: function (array, ignore = { value: TO_COL_ROW_DEFAULT_IGNORE }, scanByColumn = { value: TO_COL_ROW_DEFAULT_SCAN }) {
11624
11620
  const _array = toMatrix(array);
11625
11621
  const _ignore = toNumber(ignore.value, this.locale);
@@ -11641,7 +11637,6 @@ stores.inject(MyMetaStore, storeInstance);
11641
11637
  const TRANSPOSE = {
11642
11638
  description: _t("Transposes the rows and columns of a range."),
11643
11639
  args: [arg("range (any, range<any>)", _t("The range to be transposed."))],
11644
- returns: ["RANGE"],
11645
11640
  compute: function (arg) {
11646
11641
  const _array = toMatrix(arg);
11647
11642
  const nbColumns = _array[0].length;
@@ -11659,7 +11654,6 @@ stores.inject(MyMetaStore, storeInstance);
11659
11654
  arg("range1 (any, range<any>)", _t("The first range to be appended.")),
11660
11655
  arg("range2 (any, range<any>, repeating)", _t("Additional ranges to add to range1.")),
11661
11656
  ],
11662
- returns: ["RANGE<ANY>"],
11663
11657
  compute: function (...ranges) {
11664
11658
  const nbColumns = Math.max(...ranges.map((range) => toMatrix(range).length));
11665
11659
  const nbRows = ranges.reduce((acc, range) => acc + toMatrix(range)[0].length, 0);
@@ -11691,7 +11685,6 @@ stores.inject(MyMetaStore, storeInstance);
11691
11685
  arg("pad_with (any, default=0)", // TODO : replace with #N/A
11692
11686
  _t("The value with which to fill the extra cells in the range.")),
11693
11687
  ],
11694
- returns: ["RANGE<ANY>"],
11695
11688
  compute: function (range, wrapCount, padWith = { value: 0 }) {
11696
11689
  const _array = toMatrix(range);
11697
11690
  const nbRows = toInteger(wrapCount?.value, this.locale);
@@ -11716,7 +11709,6 @@ stores.inject(MyMetaStore, storeInstance);
11716
11709
  arg("pad_with (any, default=0)", // TODO : replace with #N/A
11717
11710
  _t("The value with which to fill the extra cells in the range.")),
11718
11711
  ],
11719
- returns: ["RANGE<ANY>"],
11720
11712
  compute: function (range, wrapCount, padWith = { value: 0 }) {
11721
11713
  const _array = toMatrix(range);
11722
11714
  const nbColumns = toInteger(wrapCount?.value, this.locale);
@@ -11764,7 +11756,6 @@ stores.inject(MyMetaStore, storeInstance);
11764
11756
  arg("value (number)", _t("The number.")),
11765
11757
  arg("unit (string, optional)", _t("The formatting unit. Use 'k', 'm', or 'b' to force the unit")),
11766
11758
  ],
11767
- returns: ["NUMBER"],
11768
11759
  compute: function (value, unite) {
11769
11760
  return {
11770
11761
  value: toNumber(value, this.locale),
@@ -11796,7 +11787,6 @@ stores.inject(MyMetaStore, storeInstance);
11796
11787
  const ABS = {
11797
11788
  description: _t("Absolute value of a number."),
11798
11789
  args: [arg("value (number)", _t("The number of which to return the absolute value."))],
11799
- returns: ["NUMBER"],
11800
11790
  compute: function (value) {
11801
11791
  return Math.abs(toNumber(value, this.locale));
11802
11792
  },
@@ -11810,7 +11800,6 @@ stores.inject(MyMetaStore, storeInstance);
11810
11800
  args: [
11811
11801
  arg("value (number)", _t("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")),
11812
11802
  ],
11813
- returns: ["NUMBER"],
11814
11803
  compute: function (value) {
11815
11804
  const _value = toNumber(value, this.locale);
11816
11805
  assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
@@ -11826,7 +11815,6 @@ stores.inject(MyMetaStore, storeInstance);
11826
11815
  args: [
11827
11816
  arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")),
11828
11817
  ],
11829
- returns: ["NUMBER"],
11830
11818
  compute: function (value) {
11831
11819
  const _value = toNumber(value, this.locale);
11832
11820
  assert(() => _value >= 1, _t("The value (%s) must be greater than or equal to 1.", _value.toString()));
@@ -11840,7 +11828,6 @@ stores.inject(MyMetaStore, storeInstance);
11840
11828
  const ACOT = {
11841
11829
  description: _t("Inverse cotangent of a value."),
11842
11830
  args: [arg("value (number)", _t("The value for which to calculate the inverse cotangent."))],
11843
- returns: ["NUMBER"],
11844
11831
  compute: function (value) {
11845
11832
  const _value = toNumber(value, this.locale);
11846
11833
  const sign = Math.sign(_value) || 1;
@@ -11859,7 +11846,6 @@ stores.inject(MyMetaStore, storeInstance);
11859
11846
  args: [
11860
11847
  arg("value (number)", _t("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")),
11861
11848
  ],
11862
- returns: ["NUMBER"],
11863
11849
  compute: function (value) {
11864
11850
  const _value = toNumber(value, this.locale);
11865
11851
  assert(() => Math.abs(_value) > 1, _t("The value (%s) cannot be between -1 and 1 inclusive.", _value.toString()));
@@ -11875,7 +11861,6 @@ stores.inject(MyMetaStore, storeInstance);
11875
11861
  args: [
11876
11862
  arg("value (number)", _t("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")),
11877
11863
  ],
11878
- returns: ["NUMBER"],
11879
11864
  compute: function (value) {
11880
11865
  const _value = toNumber(value, this.locale);
11881
11866
  assert(() => Math.abs(_value) <= 1, _t("The value (%s) must be between -1 and 1 inclusive.", _value.toString()));
@@ -11891,7 +11876,6 @@ stores.inject(MyMetaStore, storeInstance);
11891
11876
  args: [
11892
11877
  arg("value (number)", _t("The value for which to calculate the inverse hyperbolic sine.")),
11893
11878
  ],
11894
- returns: ["NUMBER"],
11895
11879
  compute: function (value) {
11896
11880
  return Math.asinh(toNumber(value, this.locale));
11897
11881
  },
@@ -11903,7 +11887,6 @@ stores.inject(MyMetaStore, storeInstance);
11903
11887
  const ATAN = {
11904
11888
  description: _t("Inverse tangent of a value, in radians."),
11905
11889
  args: [arg("value (number)", _t("The value for which to calculate the inverse tangent."))],
11906
- returns: ["NUMBER"],
11907
11890
  compute: function (value) {
11908
11891
  return Math.atan(toNumber(value, this.locale));
11909
11892
  },
@@ -11918,7 +11901,6 @@ stores.inject(MyMetaStore, storeInstance);
11918
11901
  arg("x (number)", _t("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),
11919
11902
  arg("y (number)", _t("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),
11920
11903
  ],
11921
- returns: ["NUMBER"],
11922
11904
  compute: function (x, y) {
11923
11905
  const _x = toNumber(x, this.locale);
11924
11906
  const _y = toNumber(y, this.locale);
@@ -11935,7 +11917,6 @@ stores.inject(MyMetaStore, storeInstance);
11935
11917
  args: [
11936
11918
  arg("value (number)", _t("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")),
11937
11919
  ],
11938
- returns: ["NUMBER"],
11939
11920
  compute: function (value) {
11940
11921
  const _value = toNumber(value, this.locale);
11941
11922
  assert(() => Math.abs(_value) < 1, _t("The value (%s) must be between -1 and 1 exclusive.", _value.toString()));
@@ -11952,7 +11933,6 @@ stores.inject(MyMetaStore, storeInstance);
11952
11933
  arg("value (number)", _t("The value to round up to the nearest integer multiple of factor.")),
11953
11934
  arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
11954
11935
  ],
11955
- returns: ["NUMBER"],
11956
11936
  compute: function (value, factor = { value: DEFAULT_FACTOR }) {
11957
11937
  const _value = toNumber(value, this.locale);
11958
11938
  const _factor = toNumber(factor, this.locale);
@@ -11987,7 +11967,6 @@ stores.inject(MyMetaStore, storeInstance);
11987
11967
  arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
11988
11968
  arg(`mode (number, default=${DEFAULT_MODE})`, _t("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")),
11989
11969
  ],
11990
- returns: ["NUMBER"],
11991
11970
  compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
11992
11971
  const _significance = toNumber(significance, this.locale);
11993
11972
  const _number = toNumber(number, this.locale);
@@ -12008,7 +11987,6 @@ stores.inject(MyMetaStore, storeInstance);
12008
11987
  arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
12009
11988
  arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
12010
11989
  ],
12011
- returns: ["NUMBER"],
12012
11990
  compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
12013
11991
  const _significance = toNumber(significance, this.locale);
12014
11992
  const _number = toNumber(number, this.locale);
@@ -12025,7 +12003,6 @@ stores.inject(MyMetaStore, storeInstance);
12025
12003
  const COS = {
12026
12004
  description: _t("Cosine of an angle provided in radians."),
12027
12005
  args: [arg("angle (number)", _t("The angle to find the cosine of, in radians."))],
12028
- returns: ["NUMBER"],
12029
12006
  compute: function (angle) {
12030
12007
  return Math.cos(toNumber(angle, this.locale));
12031
12008
  },
@@ -12037,7 +12014,6 @@ stores.inject(MyMetaStore, storeInstance);
12037
12014
  const COSH = {
12038
12015
  description: _t("Hyperbolic cosine of any real number."),
12039
12016
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosine of."))],
12040
- returns: ["NUMBER"],
12041
12017
  compute: function (value) {
12042
12018
  return Math.cosh(toNumber(value, this.locale));
12043
12019
  },
@@ -12049,7 +12025,6 @@ stores.inject(MyMetaStore, storeInstance);
12049
12025
  const COT = {
12050
12026
  description: _t("Cotangent of an angle provided in radians."),
12051
12027
  args: [arg("angle (number)", _t("The angle to find the cotangent of, in radians."))],
12052
- returns: ["NUMBER"],
12053
12028
  compute: function (angle) {
12054
12029
  const _angle = toNumber(angle, this.locale);
12055
12030
  assertNotZero(_angle);
@@ -12063,7 +12038,6 @@ stores.inject(MyMetaStore, storeInstance);
12063
12038
  const COTH = {
12064
12039
  description: _t("Hyperbolic cotangent of any real number."),
12065
12040
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cotangent of."))],
12066
- returns: ["NUMBER"],
12067
12041
  compute: function (value) {
12068
12042
  const _value = toNumber(value, this.locale);
12069
12043
  assertNotZero(_value);
@@ -12080,7 +12054,6 @@ stores.inject(MyMetaStore, storeInstance);
12080
12054
  arg("value1 (any, range)", _t("The first value or range in which to count the number of blanks.")),
12081
12055
  arg("value2 (any, range, repeating)", _t("Additional values or ranges in which to count the number of blanks.")),
12082
12056
  ],
12083
- returns: ["NUMBER"],
12084
12057
  compute: function (...args) {
12085
12058
  return reduceAny(args, (acc, a) => {
12086
12059
  if (a === undefined) {
@@ -12106,7 +12079,6 @@ stores.inject(MyMetaStore, storeInstance);
12106
12079
  arg("range (range)", _t("The range that is tested against criterion.")),
12107
12080
  arg("criterion (string)", _t("The pattern or test to apply to range.")),
12108
12081
  ],
12109
- returns: ["NUMBER"],
12110
12082
  compute: function (...args) {
12111
12083
  let count = 0;
12112
12084
  visitMatchingRanges(args, (i, j) => {
@@ -12127,7 +12099,6 @@ stores.inject(MyMetaStore, storeInstance);
12127
12099
  arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
12128
12100
  arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
12129
12101
  ],
12130
- returns: ["NUMBER"],
12131
12102
  compute: function (...args) {
12132
12103
  let count = 0;
12133
12104
  visitMatchingRanges(args, (i, j) => {
@@ -12146,7 +12117,6 @@ stores.inject(MyMetaStore, storeInstance);
12146
12117
  arg("value1 (any, range)", _t("The first value or range to consider for uniqueness.")),
12147
12118
  arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider for uniqueness.")),
12148
12119
  ],
12149
- returns: ["NUMBER"],
12150
12120
  compute: function (...args) {
12151
12121
  return countUnique(args);
12152
12122
  },
@@ -12163,7 +12133,6 @@ stores.inject(MyMetaStore, storeInstance);
12163
12133
  arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
12164
12134
  arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
12165
12135
  ],
12166
- returns: ["NUMBER"],
12167
12136
  compute: function (range, ...args) {
12168
12137
  let uniqueValues = new Set();
12169
12138
  visitMatchingRanges(args, (i, j) => {
@@ -12181,7 +12150,6 @@ stores.inject(MyMetaStore, storeInstance);
12181
12150
  const CSC = {
12182
12151
  description: _t("Cosecant of an angle provided in radians."),
12183
12152
  args: [arg("angle (number)", _t("The angle to find the cosecant of, in radians."))],
12184
- returns: ["NUMBER"],
12185
12153
  compute: function (angle) {
12186
12154
  const _angle = toNumber(angle, this.locale);
12187
12155
  assertNotZero(_angle);
@@ -12195,7 +12163,6 @@ stores.inject(MyMetaStore, storeInstance);
12195
12163
  const CSCH = {
12196
12164
  description: _t("Hyperbolic cosecant of any real number."),
12197
12165
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic cosecant of."))],
12198
- returns: ["NUMBER"],
12199
12166
  compute: function (value) {
12200
12167
  const _value = toNumber(value, this.locale);
12201
12168
  assertNotZero(_value);
@@ -12212,7 +12179,6 @@ stores.inject(MyMetaStore, storeInstance);
12212
12179
  arg("value (string)", _t("The number to convert.")),
12213
12180
  arg("base (number)", _t("The base to convert the value from.")),
12214
12181
  ],
12215
- returns: ["NUMBER"],
12216
12182
  compute: function (value, base) {
12217
12183
  let _base = toNumber(base, this.locale);
12218
12184
  _base = Math.floor(_base);
@@ -12239,7 +12205,6 @@ stores.inject(MyMetaStore, storeInstance);
12239
12205
  const DEGREES = {
12240
12206
  description: _t("Converts an angle value in radians to degrees."),
12241
12207
  args: [arg("angle (number)", _t("The angle to convert from radians to degrees."))],
12242
- returns: ["NUMBER"],
12243
12208
  compute: function (angle) {
12244
12209
  return (toNumber(angle, this.locale) * 180) / Math.PI;
12245
12210
  },
@@ -12251,7 +12216,6 @@ stores.inject(MyMetaStore, storeInstance);
12251
12216
  const EXP = {
12252
12217
  description: _t("Euler's number, e (~2.718) raised to a power."),
12253
12218
  args: [arg("value (number)", _t("The exponent to raise e."))],
12254
- returns: ["NUMBER"],
12255
12219
  compute: function (value) {
12256
12220
  return Math.exp(toNumber(value, this.locale));
12257
12221
  },
@@ -12266,7 +12230,6 @@ stores.inject(MyMetaStore, storeInstance);
12266
12230
  arg("value (number)", _t("The value to round down to the nearest integer multiple of factor.")),
12267
12231
  arg(`factor (number, default=${DEFAULT_FACTOR})`, _t("The number to whose multiples value will be rounded.")),
12268
12232
  ],
12269
- returns: ["NUMBER"],
12270
12233
  compute: function (value, factor = { value: DEFAULT_FACTOR }) {
12271
12234
  const _value = toNumber(value, this.locale);
12272
12235
  const _factor = toNumber(factor, this.locale);
@@ -12301,7 +12264,6 @@ stores.inject(MyMetaStore, storeInstance);
12301
12264
  arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),
12302
12265
  arg(`mode (number, default=${DEFAULT_MODE})`, _t("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")),
12303
12266
  ],
12304
- returns: ["NUMBER"],
12305
12267
  compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }, mode = { value: DEFAULT_MODE }) {
12306
12268
  const _significance = toNumber(significance, this.locale);
12307
12269
  const _number = toNumber(number, this.locale);
@@ -12322,7 +12284,6 @@ stores.inject(MyMetaStore, storeInstance);
12322
12284
  arg("number (number)", _t("The value to round down to the nearest integer multiple of significance.")),
12323
12285
  arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
12324
12286
  ],
12325
- returns: ["NUMBER"],
12326
12287
  compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
12327
12288
  const _significance = toNumber(significance, this.locale);
12328
12289
  const _number = toNumber(number, this.locale);
@@ -12339,7 +12300,6 @@ stores.inject(MyMetaStore, storeInstance);
12339
12300
  const ISEVEN = {
12340
12301
  description: _t("Whether the provided value is even."),
12341
12302
  args: [arg("value (number)", _t("The value to be verified as even."))],
12342
- returns: ["BOOLEAN"],
12343
12303
  compute: function (value) {
12344
12304
  const _value = strictToNumber(value, this.locale);
12345
12305
  return Math.floor(Math.abs(_value)) & 1 ? false : true;
@@ -12355,7 +12315,6 @@ stores.inject(MyMetaStore, storeInstance);
12355
12315
  arg("number (number)", _t("The value to round up to the nearest integer multiple of significance.")),
12356
12316
  arg(`significance (number, default=${DEFAULT_SIGNIFICANCE})`, _t("The number to whose multiples number will be rounded.")),
12357
12317
  ],
12358
- returns: ["NUMBER"],
12359
12318
  compute: function (number, significance = { value: DEFAULT_SIGNIFICANCE }) {
12360
12319
  const _number = toNumber(number, this.locale);
12361
12320
  const _significance = toNumber(significance, this.locale);
@@ -12372,7 +12331,6 @@ stores.inject(MyMetaStore, storeInstance);
12372
12331
  const ISODD = {
12373
12332
  description: _t("Whether the provided value is even."),
12374
12333
  args: [arg("value (number)", _t("The value to be verified as even."))],
12375
- returns: ["BOOLEAN"],
12376
12334
  compute: function (value) {
12377
12335
  const _value = strictToNumber(value, this.locale);
12378
12336
  return Math.floor(Math.abs(_value)) & 1 ? true : false;
@@ -12385,7 +12343,6 @@ stores.inject(MyMetaStore, storeInstance);
12385
12343
  const LN = {
12386
12344
  description: _t("The logarithm of a number, base e (euler's number)."),
12387
12345
  args: [arg("value (number)", _t("The value for which to calculate the logarithm, base e."))],
12388
- returns: ["NUMBER"],
12389
12346
  compute: function (value) {
12390
12347
  const _value = toNumber(value, this.locale);
12391
12348
  assert(() => _value > 0, _t("The value (%s) must be strictly positive.", _value.toString()));
@@ -12411,7 +12368,6 @@ stores.inject(MyMetaStore, storeInstance);
12411
12368
  arg("dividend (number)", _t("The number to be divided to find the remainder.")),
12412
12369
  arg("divisor (number)", _t("The number to divide by.")),
12413
12370
  ],
12414
- returns: ["NUMBER"],
12415
12371
  compute: function (dividend, divisor) {
12416
12372
  const _divisor = toNumber(divisor, this.locale);
12417
12373
  const _dividend = toNumber(dividend, this.locale);
@@ -12430,7 +12386,6 @@ stores.inject(MyMetaStore, storeInstance);
12430
12386
  args: [
12431
12387
  arg("dimension (number)", _t("An integer specifying the dimension size of the unit matrix. It must be positive.")),
12432
12388
  ],
12433
- returns: ["RANGE<NUMBER>"],
12434
12389
  compute: function (n) {
12435
12390
  const _n = toInteger(n, this.locale);
12436
12391
  assertPositive(_t("The argument dimension must be positive"), _n);
@@ -12444,7 +12399,6 @@ stores.inject(MyMetaStore, storeInstance);
12444
12399
  const ODD = {
12445
12400
  description: _t("Rounds a number up to the nearest odd integer."),
12446
12401
  args: [arg("value (number)", _t("The value to round to the next greatest odd number."))],
12447
- returns: ["NUMBER"],
12448
12402
  compute: function (value) {
12449
12403
  const _value = toNumber(value, this.locale);
12450
12404
  let temp = Math.ceil(Math.abs(_value));
@@ -12462,7 +12416,6 @@ stores.inject(MyMetaStore, storeInstance);
12462
12416
  const PI = {
12463
12417
  description: _t("The number pi."),
12464
12418
  args: [],
12465
- returns: ["NUMBER"],
12466
12419
  compute: function () {
12467
12420
  return Math.PI;
12468
12421
  },
@@ -12477,7 +12430,6 @@ stores.inject(MyMetaStore, storeInstance);
12477
12430
  arg("base (number)", _t("The number to raise to the exponent power.")),
12478
12431
  arg("exponent (number)", _t("The exponent to raise base to.")),
12479
12432
  ],
12480
- returns: ["NUMBER"],
12481
12433
  compute: function (base, exponent) {
12482
12434
  const _base = toNumber(base, this.locale);
12483
12435
  const _exponent = toNumber(exponent, this.locale);
@@ -12495,7 +12447,6 @@ stores.inject(MyMetaStore, storeInstance);
12495
12447
  arg("factor1 (number, range<number>)", _t("The first number or range to calculate for the product.")),
12496
12448
  arg("factor2 (number, range<number>, repeating)", _t("More numbers or ranges to calculate for the product.")),
12497
12449
  ],
12498
- returns: ["NUMBER"],
12499
12450
  compute: function (...factors) {
12500
12451
  let count = 0;
12501
12452
  let acc = 1;
@@ -12532,7 +12483,6 @@ stores.inject(MyMetaStore, storeInstance);
12532
12483
  const RAND = {
12533
12484
  description: _t("A random number between 0 inclusive and 1 exclusive."),
12534
12485
  args: [],
12535
- returns: ["NUMBER"],
12536
12486
  compute: function () {
12537
12487
  return Math.random();
12538
12488
  },
@@ -12550,7 +12500,6 @@ stores.inject(MyMetaStore, storeInstance);
12550
12500
  arg("max (number, default=1)", _t("The maximum number you would like returned.")),
12551
12501
  arg("whole_number (number, default=FALSE)", _t("Return a whole number or a decimal value.")),
12552
12502
  ],
12553
- returns: ["RANGE<NUMBER>"],
12554
12503
  compute: function (rows = { value: 1 }, columns = { value: 1 }, min = { value: 0 }, max = { value: 1 }, wholeNumber = { value: false }) {
12555
12504
  const _cols = toInteger(columns, this.locale);
12556
12505
  const _rows = toInteger(rows, this.locale);
@@ -12588,7 +12537,6 @@ stores.inject(MyMetaStore, storeInstance);
12588
12537
  arg("low (number)", _t("The low end of the random range.")),
12589
12538
  arg("high (number)", _t("The high end of the random range.")),
12590
12539
  ],
12591
- returns: ["NUMBER"],
12592
12540
  compute: function (low, high) {
12593
12541
  let _low = toNumber(low, this.locale);
12594
12542
  if (!Number.isInteger(_low)) {
@@ -12615,7 +12563,6 @@ stores.inject(MyMetaStore, storeInstance);
12615
12563
  arg("value (number)", _t("The value to round to places number of places.")),
12616
12564
  arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
12617
12565
  ],
12618
- returns: ["NUMBER"],
12619
12566
  compute: function (value, places = { value: DEFAULT_PLACES }) {
12620
12567
  const _value = toNumber(value, this.locale);
12621
12568
  let _places = toNumber(places, this.locale);
@@ -12646,7 +12593,6 @@ stores.inject(MyMetaStore, storeInstance);
12646
12593
  arg("value (number)", _t("The value to round to places number of places, always rounding down.")),
12647
12594
  arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
12648
12595
  ],
12649
- returns: ["NUMBER"],
12650
12596
  compute: function (value, places = { value: DEFAULT_PLACES }) {
12651
12597
  const _value = toNumber(value, this.locale);
12652
12598
  let _places = toNumber(places, this.locale);
@@ -12677,7 +12623,6 @@ stores.inject(MyMetaStore, storeInstance);
12677
12623
  arg("value (number)", _t("The value to round to places number of places, always rounding up.")),
12678
12624
  arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of decimal places to which to round.")),
12679
12625
  ],
12680
- returns: ["NUMBER"],
12681
12626
  compute: function (value, places = { value: DEFAULT_PLACES }) {
12682
12627
  const _value = toNumber(value, this.locale);
12683
12628
  let _places = toNumber(places, this.locale);
@@ -12705,7 +12650,6 @@ stores.inject(MyMetaStore, storeInstance);
12705
12650
  const SEC = {
12706
12651
  description: _t("Secant of an angle provided in radians."),
12707
12652
  args: [arg("angle (number)", _t("The angle to find the secant of, in radians."))],
12708
- returns: ["NUMBER"],
12709
12653
  compute: function (angle) {
12710
12654
  return 1 / Math.cos(toNumber(angle, this.locale));
12711
12655
  },
@@ -12717,7 +12661,6 @@ stores.inject(MyMetaStore, storeInstance);
12717
12661
  const SECH = {
12718
12662
  description: _t("Hyperbolic secant of any real number."),
12719
12663
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic secant of."))],
12720
- returns: ["NUMBER"],
12721
12664
  compute: function (value) {
12722
12665
  return 1 / Math.cosh(toNumber(value, this.locale));
12723
12666
  },
@@ -12729,7 +12672,6 @@ stores.inject(MyMetaStore, storeInstance);
12729
12672
  const SIN = {
12730
12673
  description: _t("Sine of an angle provided in radians."),
12731
12674
  args: [arg("angle (number)", _t("The angle to find the sine of, in radians."))],
12732
- returns: ["NUMBER"],
12733
12675
  compute: function (angle) {
12734
12676
  return Math.sin(toNumber(angle, this.locale));
12735
12677
  },
@@ -12741,7 +12683,6 @@ stores.inject(MyMetaStore, storeInstance);
12741
12683
  const SINH = {
12742
12684
  description: _t("Hyperbolic sine of any real number."),
12743
12685
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic sine of."))],
12744
- returns: ["NUMBER"],
12745
12686
  compute: function (value) {
12746
12687
  return Math.sinh(toNumber(value, this.locale));
12747
12688
  },
@@ -12753,7 +12694,6 @@ stores.inject(MyMetaStore, storeInstance);
12753
12694
  const SQRT = {
12754
12695
  description: _t("Positive square root of a positive number."),
12755
12696
  args: [arg("value (number)", _t("The number for which to calculate the positive square root."))],
12756
- returns: ["NUMBER"],
12757
12697
  compute: function (value) {
12758
12698
  const _value = toNumber(value, this.locale);
12759
12699
  assert(() => _value >= 0, _t("The value (%s) must be positive or null.", _value.toString()));
@@ -12770,7 +12710,6 @@ stores.inject(MyMetaStore, storeInstance);
12770
12710
  arg("value1 (number, range<number>)", _t("The first number or range to add together.")),
12771
12711
  arg("value2 (number, range<number>, repeating)", _t("Additional numbers or ranges to add to value1.")),
12772
12712
  ],
12773
- returns: ["NUMBER"],
12774
12713
  compute: function (...values) {
12775
12714
  const v1 = values[0];
12776
12715
  return {
@@ -12790,7 +12729,6 @@ stores.inject(MyMetaStore, storeInstance);
12790
12729
  arg("criterion (string)", _t("The pattern or test to apply to range.")),
12791
12730
  arg("sum_range (range, default=criteria_range)", _t("The range to be summed, if different from range.")),
12792
12731
  ],
12793
- returns: ["NUMBER"],
12794
12732
  compute: function (criteriaRange, criterion, sumRange) {
12795
12733
  if (sumRange === undefined) {
12796
12734
  sumRange = criteriaRange;
@@ -12818,7 +12756,6 @@ stores.inject(MyMetaStore, storeInstance);
12818
12756
  arg("criteria_range2 (any, range, repeating)", _t("Additional ranges to check.")),
12819
12757
  arg("criterion2 (string, repeating)", _t("Additional criteria to check.")),
12820
12758
  ],
12821
- returns: ["NUMBER"],
12822
12759
  compute: function (sumRange, ...criters) {
12823
12760
  let sum = 0;
12824
12761
  visitMatchingRanges(criters, (i, j) => {
@@ -12837,7 +12774,6 @@ stores.inject(MyMetaStore, storeInstance);
12837
12774
  const TAN = {
12838
12775
  description: _t("Tangent of an angle provided in radians."),
12839
12776
  args: [arg("angle (number)", _t("The angle to find the tangent of, in radians."))],
12840
- returns: ["NUMBER"],
12841
12777
  compute: function (angle) {
12842
12778
  return Math.tan(toNumber(angle, this.locale));
12843
12779
  },
@@ -12849,7 +12785,6 @@ stores.inject(MyMetaStore, storeInstance);
12849
12785
  const TANH = {
12850
12786
  description: _t("Hyperbolic tangent of any real number."),
12851
12787
  args: [arg("value (number)", _t("Any real value to calculate the hyperbolic tangent of."))],
12852
- returns: ["NUMBER"],
12853
12788
  compute: function (value) {
12854
12789
  return Math.tanh(toNumber(value, this.locale));
12855
12790
  },
@@ -12873,7 +12808,6 @@ stores.inject(MyMetaStore, storeInstance);
12873
12808
  arg("value (number)", _t("The value to be truncated.")),
12874
12809
  arg(`places (number, default=${DEFAULT_PLACES})`, _t("The number of significant digits to the right of the decimal point to retain.")),
12875
12810
  ],
12876
- returns: ["NUMBER"],
12877
12811
  compute: function (value, places = { value: DEFAULT_PLACES }) {
12878
12812
  const _value = toNumber(value, this.locale);
12879
12813
  const _places = toNumber(places, this.locale);
@@ -12887,7 +12821,6 @@ stores.inject(MyMetaStore, storeInstance);
12887
12821
  const INT = {
12888
12822
  description: _t("Rounds a number down to the nearest integer that is less than or equal to it."),
12889
12823
  args: [arg("value (number)", _t("The number to round down to the nearest integer."))],
12890
- returns: ["NUMBER"],
12891
12824
  compute: function (value) {
12892
12825
  return Math.floor(toNumber(value, this.locale));
12893
12826
  },
@@ -13246,7 +13179,6 @@ stores.inject(MyMetaStore, storeInstance);
13246
13179
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
13247
13180
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
13248
13181
  ],
13249
- returns: ["NUMBER"],
13250
13182
  compute: function (...values) {
13251
13183
  let count = 0;
13252
13184
  const sum = reduceNumbers(values, (acc, a) => {
@@ -13268,7 +13200,6 @@ stores.inject(MyMetaStore, storeInstance);
13268
13200
  arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
13269
13201
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
13270
13202
  ],
13271
- returns: ["NUMBER"],
13272
13203
  compute: function (...values) {
13273
13204
  return {
13274
13205
  value: average(values, this.locale),
@@ -13290,7 +13221,6 @@ stores.inject(MyMetaStore, storeInstance);
13290
13221
  arg("additional_values (number, range<number>, repeating)", _t("Additional values to average.")),
13291
13222
  arg("additional_weights (number, range<number>, repeating)", _t("Additional weights.")),
13292
13223
  ],
13293
- returns: ["NUMBER"],
13294
13224
  compute: function (...args) {
13295
13225
  let sum = 0;
13296
13226
  let count = 0;
@@ -13338,7 +13268,6 @@ stores.inject(MyMetaStore, storeInstance);
13338
13268
  arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the average value.")),
13339
13269
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the average value.")),
13340
13270
  ],
13341
- returns: ["NUMBER"],
13342
13271
  compute: function (...args) {
13343
13272
  let count = 0;
13344
13273
  const sum = reduceNumbersTextAs0(args, (acc, a) => {
@@ -13363,7 +13292,6 @@ stores.inject(MyMetaStore, storeInstance);
13363
13292
  arg("criterion (string)", _t("The pattern or test to apply to criteria_range.")),
13364
13293
  arg("average_range (number, range<number>, default=criteria_range)", _t("The range to average. If not included, criteria_range is used for the average instead.")),
13365
13294
  ],
13366
- returns: ["NUMBER"],
13367
13295
  compute: function (criteriaRange, criterion, averageRange) {
13368
13296
  const _averageRange = averageRange === undefined ? toMatrix(criteriaRange) : toMatrix(averageRange);
13369
13297
  let count = 0;
@@ -13392,7 +13320,6 @@ stores.inject(MyMetaStore, storeInstance);
13392
13320
  arg("criteria_range2 (any, range, repeating)", _t("Additional criteria_range and criterion to check.")),
13393
13321
  arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
13394
13322
  ],
13395
- returns: ["NUMBER"],
13396
13323
  compute: function (averageRange, ...args) {
13397
13324
  const _averageRange = toMatrix(averageRange);
13398
13325
  let count = 0;
@@ -13418,7 +13345,6 @@ stores.inject(MyMetaStore, storeInstance);
13418
13345
  arg("value1 (number, range<number>)", _t("The first value or range to consider when counting.")),
13419
13346
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when counting.")),
13420
13347
  ],
13421
- returns: ["NUMBER"],
13422
13348
  compute: function (...values) {
13423
13349
  return countNumbers(values, this.locale);
13424
13350
  },
@@ -13433,7 +13359,6 @@ stores.inject(MyMetaStore, storeInstance);
13433
13359
  arg("value1 (any, range)", _t("The first value or range to consider when counting.")),
13434
13360
  arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when counting.")),
13435
13361
  ],
13436
- returns: ["NUMBER"],
13437
13362
  compute: function (...values) {
13438
13363
  return countAny(values);
13439
13364
  },
@@ -13450,7 +13375,6 @@ stores.inject(MyMetaStore, storeInstance);
13450
13375
  arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
13451
13376
  arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
13452
13377
  ],
13453
- returns: ["NUMBER"],
13454
13378
  compute: function (dataY, dataX) {
13455
13379
  return covariance(dataY, dataX, false);
13456
13380
  },
@@ -13465,7 +13389,6 @@ stores.inject(MyMetaStore, storeInstance);
13465
13389
  arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
13466
13390
  arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
13467
13391
  ],
13468
- returns: ["NUMBER"],
13469
13392
  compute: function (dataY, dataX) {
13470
13393
  return covariance(dataY, dataX, false);
13471
13394
  },
@@ -13480,7 +13403,6 @@ stores.inject(MyMetaStore, storeInstance);
13480
13403
  arg("data_y (any, range)", _t("The range representing the array or matrix of dependent data.")),
13481
13404
  arg("data_x (any, range)", _t("The range representing the array or matrix of independent data.")),
13482
13405
  ],
13483
- returns: ["NUMBER"],
13484
13406
  compute: function (dataY, dataX) {
13485
13407
  return covariance(dataY, dataX, true);
13486
13408
  },
@@ -13496,7 +13418,6 @@ stores.inject(MyMetaStore, storeInstance);
13496
13418
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
13497
13419
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
13498
13420
  ],
13499
- returns: ["NUMBER"],
13500
13421
  compute: function (x, dataY, dataX) {
13501
13422
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
13502
13423
  return predictLinearValues([flatDataY], [flatDataX], matrixMap(toMatrix(x), (value) => toNumber(value, this.locale)), true);
@@ -13514,7 +13435,6 @@ stores.inject(MyMetaStore, storeInstance);
13514
13435
  arg("new_data_x (any, range, default=known_data_x)", _t("The data points to return the y values for on the ideal curve fit.")),
13515
13436
  arg("b (boolean, default=TRUE)", _t("Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.")),
13516
13437
  ],
13517
- returns: ["NUMBER"],
13518
13438
  compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
13519
13439
  return expM(predictLinearValues(logM(toNumberMatrix(knownDataY, "the first argument (known_data_y)")), toNumberMatrix(knownDataX, "the second argument (known_data_x)"), toNumberMatrix(newDataX, "the third argument (new_data_y)"), toBoolean(b)));
13520
13440
  },
@@ -13528,7 +13448,6 @@ stores.inject(MyMetaStore, storeInstance);
13528
13448
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
13529
13449
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
13530
13450
  ],
13531
- returns: ["NUMBER"],
13532
13451
  compute: function (dataY, dataX) {
13533
13452
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
13534
13453
  const [[], [intercept]] = fullLinearRegression([flatDataX], [flatDataY]);
@@ -13545,7 +13464,6 @@ stores.inject(MyMetaStore, storeInstance);
13545
13464
  arg("data (any, range)", _t("Array or range containing the dataset to consider.")),
13546
13465
  arg("n (number)", _t("The rank from largest to smallest of the element to return.")),
13547
13466
  ],
13548
- returns: ["NUMBER"],
13549
13467
  compute: function (data, n) {
13550
13468
  const _n = Math.trunc(toNumber(n?.value, this.locale));
13551
13469
  let largests = [];
@@ -13580,7 +13498,6 @@ stores.inject(MyMetaStore, storeInstance);
13580
13498
  arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
13581
13499
  arg("verbose (boolean, default=FALSE)", _t("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept")),
13582
13500
  ],
13583
- returns: ["NUMBER"],
13584
13501
  compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
13585
13502
  return fullLinearRegression(toNumberMatrix(dataX, "the first argument (data_y)"), toNumberMatrix(dataY, "the second argument (data_x)"), toBoolean(calculateB), toBoolean(verbose));
13586
13503
  },
@@ -13597,7 +13514,6 @@ stores.inject(MyMetaStore, storeInstance);
13597
13514
  arg("calculate_b (boolean, default=TRUE)", _t("A flag specifying wheter to compute the slope or not")),
13598
13515
  arg("verbose (boolean, default=FALSE)", _t("A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept")),
13599
13516
  ],
13600
- returns: ["NUMBER"],
13601
13517
  compute: function (dataY, dataX = [[]], calculateB = { value: true }, verbose = { value: false }) {
13602
13518
  const coeffs = fullLinearRegression(toNumberMatrix(dataX, "the second argument (data_x)"), logM(toNumberMatrix(dataY, "the first argument (data_y)")), toBoolean(calculateB), toBoolean(verbose));
13603
13519
  for (let i = 0; i < coeffs.length; i++) {
@@ -13616,7 +13532,6 @@ stores.inject(MyMetaStore, storeInstance);
13616
13532
  arg("data_x (range)", _t("The range representing the array or matrix of observed data.")),
13617
13533
  arg("data_y (range)", _t("The range representing the array or matrix of predicted data.")),
13618
13534
  ],
13619
- returns: ["NUMBER"],
13620
13535
  compute: function (dataX, dataY) {
13621
13536
  const flatX = dataX.flat();
13622
13537
  const flatY = dataY.flat();
@@ -13660,7 +13575,6 @@ stores.inject(MyMetaStore, storeInstance);
13660
13575
  arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the maximum value.")),
13661
13576
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
13662
13577
  ],
13663
- returns: ["NUMBER"],
13664
13578
  compute: function (...values) {
13665
13579
  return {
13666
13580
  value: max(values, this.locale),
@@ -13678,7 +13592,6 @@ stores.inject(MyMetaStore, storeInstance);
13678
13592
  arg("value1 (any, range)", _t("The first value or range to consider when calculating the maximum value.")),
13679
13593
  arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the maximum value.")),
13680
13594
  ],
13681
- returns: ["NUMBER"],
13682
13595
  compute: function (...args) {
13683
13596
  const maxa = reduceNumbersTextAs0(args, (acc, a) => {
13684
13597
  return Math.max(a, acc);
@@ -13699,7 +13612,6 @@ stores.inject(MyMetaStore, storeInstance);
13699
13612
  arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
13700
13613
  arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
13701
13614
  ],
13702
- returns: ["NUMBER"],
13703
13615
  compute: function (range, ...args) {
13704
13616
  let result = -Infinity;
13705
13617
  visitMatchingRanges(args, (i, j) => {
@@ -13721,7 +13633,6 @@ stores.inject(MyMetaStore, storeInstance);
13721
13633
  arg("value1 (any, range)", _t("The first value or range to consider when calculating the median value.")),
13722
13634
  arg("value2 (any, range, repeating)", _t("Additional values or ranges to consider when calculating the median value.")),
13723
13635
  ],
13724
- returns: ["NUMBER"],
13725
13636
  compute: function (...values) {
13726
13637
  let data = [];
13727
13638
  visitNumbers(values, (value) => {
@@ -13743,7 +13654,6 @@ stores.inject(MyMetaStore, storeInstance);
13743
13654
  arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
13744
13655
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
13745
13656
  ],
13746
- returns: ["NUMBER"],
13747
13657
  compute: function (...values) {
13748
13658
  return {
13749
13659
  value: min(values, this.locale),
@@ -13761,7 +13671,6 @@ stores.inject(MyMetaStore, storeInstance);
13761
13671
  arg("value1 (number, range<number>)", _t("The first value or range to consider when calculating the minimum value.")),
13762
13672
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to consider when calculating the minimum value.")),
13763
13673
  ],
13764
- returns: ["NUMBER"],
13765
13674
  compute: function (...args) {
13766
13675
  const mina = reduceNumbersTextAs0(args, (acc, a) => {
13767
13676
  return Math.min(a, acc);
@@ -13782,7 +13691,6 @@ stores.inject(MyMetaStore, storeInstance);
13782
13691
  arg("criteria_range2 (any, range, repeating)", _t("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),
13783
13692
  arg("criterion2 (string, repeating)", _t("The pattern or test to apply to criteria_range2.")),
13784
13693
  ],
13785
- returns: ["NUMBER"],
13786
13694
  compute: function (range, ...args) {
13787
13695
  let result = Infinity;
13788
13696
  visitMatchingRanges(args, (i, j) => {
@@ -13825,7 +13733,6 @@ stores.inject(MyMetaStore, storeInstance);
13825
13733
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
13826
13734
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
13827
13735
  ],
13828
- returns: ["NUMBER"],
13829
13736
  compute: function (dataY, dataX) {
13830
13737
  return pearson(dataY, dataX);
13831
13738
  },
@@ -13842,7 +13749,6 @@ stores.inject(MyMetaStore, storeInstance);
13842
13749
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13843
13750
  arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
13844
13751
  ],
13845
- returns: ["NUMBER"],
13846
13752
  compute: function (data, percentile) {
13847
13753
  return PERCENTILE_INC.compute.bind(this)(data, percentile);
13848
13754
  },
@@ -13857,7 +13763,6 @@ stores.inject(MyMetaStore, storeInstance);
13857
13763
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13858
13764
  arg("percentile (number)", _t("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")),
13859
13765
  ],
13860
- returns: ["NUMBER"],
13861
13766
  compute: function (data, percentile) {
13862
13767
  return {
13863
13768
  value: centile([data], percentile, false, this.locale),
@@ -13875,7 +13780,6 @@ stores.inject(MyMetaStore, storeInstance);
13875
13780
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13876
13781
  arg("percentile (number)", _t("The percentile whose value within data will be calculated and returned.")),
13877
13782
  ],
13878
- returns: ["NUMBER"],
13879
13783
  compute: function (data, percentile) {
13880
13784
  return {
13881
13785
  value: centile([data], percentile, true, this.locale),
@@ -13895,7 +13799,6 @@ stores.inject(MyMetaStore, storeInstance);
13895
13799
  arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
13896
13800
  arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
13897
13801
  ],
13898
- returns: ["RANGE<NUMBER>"],
13899
13802
  compute: function (dataY, dataX, order, intercept = { value: true }) {
13900
13803
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
13901
13804
  return polynomialRegression(flatDataY, flatDataX, toNumber(order, this.locale), toBoolean(intercept));
@@ -13914,7 +13817,6 @@ stores.inject(MyMetaStore, storeInstance);
13914
13817
  arg("order (number)", _t("The order of the polynomial to fit the data, between 1 and 6.")),
13915
13818
  arg("intercept (boolean, default=TRUE)", _t("A flag specifying whether to compute the intercept or not.")),
13916
13819
  ],
13917
- returns: ["NUMBER"],
13918
13820
  compute: function (x, dataY, dataX, order, intercept = { value: true }) {
13919
13821
  const _order = toNumber(order, this.locale);
13920
13822
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
@@ -13932,7 +13834,6 @@ stores.inject(MyMetaStore, storeInstance);
13932
13834
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13933
13835
  arg("quartile_number (number)", _t("Which quartile value to return.")),
13934
13836
  ],
13935
- returns: ["NUMBER"],
13936
13837
  compute: function (data, quartileNumber) {
13937
13838
  return QUARTILE_INC.compute.bind(this)(data, quartileNumber);
13938
13839
  },
@@ -13947,7 +13848,6 @@ stores.inject(MyMetaStore, storeInstance);
13947
13848
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13948
13849
  arg("quartile_number (number)", _t("Which quartile value, exclusive of 0 and 4, to return.")),
13949
13850
  ],
13950
- returns: ["NUMBER"],
13951
13851
  compute: function (data, quartileNumber) {
13952
13852
  const _quartileNumber = Math.trunc(toNumber(quartileNumber, this.locale));
13953
13853
  const percent = { value: 0.25 * _quartileNumber };
@@ -13967,7 +13867,6 @@ stores.inject(MyMetaStore, storeInstance);
13967
13867
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
13968
13868
  arg("quartile_number (number)", _t("Which quartile value to return.")),
13969
13869
  ],
13970
- returns: ["NUMBER"],
13971
13870
  compute: function (data, quartileNumber) {
13972
13871
  const percent = { value: 0.25 * Math.trunc(toNumber(quartileNumber, this.locale)) };
13973
13872
  return {
@@ -13986,7 +13885,6 @@ stores.inject(MyMetaStore, storeInstance);
13986
13885
  arg("data (range)", _t("The range containing the dataset to consider.")),
13987
13886
  arg("is_ascending (boolean, default=FALSE)", _t("Whether to consider the values in data in descending or ascending order.")),
13988
13887
  ],
13989
- returns: ["ANY"],
13990
13888
  compute: function (value, data, isAscending = { value: false }) {
13991
13889
  const _isAscending = toBoolean(isAscending);
13992
13890
  const _value = toNumber(value, this.locale);
@@ -14022,7 +13920,6 @@ stores.inject(MyMetaStore, storeInstance);
14022
13920
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
14023
13921
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
14024
13922
  ],
14025
- returns: ["NUMBER"],
14026
13923
  compute: function (dataY, dataX) {
14027
13924
  return Math.pow(pearson(dataX, dataY), 2.0);
14028
13925
  },
@@ -14037,7 +13934,6 @@ stores.inject(MyMetaStore, storeInstance);
14037
13934
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
14038
13935
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
14039
13936
  ],
14040
- returns: ["NUMBER"],
14041
13937
  compute: function (dataY, dataX) {
14042
13938
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
14043
13939
  const [[slope]] = fullLinearRegression([flatDataX], [flatDataY]);
@@ -14054,7 +13950,6 @@ stores.inject(MyMetaStore, storeInstance);
14054
13950
  arg("data (any, range)", _t("The array or range containing the dataset to consider.")),
14055
13951
  arg("n (number)", _t("The rank from smallest to largest of the element to return.")),
14056
13952
  ],
14057
- returns: ["NUMBER"],
14058
13953
  compute: function (data, n) {
14059
13954
  const _n = Math.trunc(toNumber(n?.value, this.locale));
14060
13955
  let largests = [];
@@ -14087,7 +13982,6 @@ stores.inject(MyMetaStore, storeInstance);
14087
13982
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
14088
13983
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
14089
13984
  ],
14090
- returns: ["NUMBER"],
14091
13985
  compute: function (dataX, dataY) {
14092
13986
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
14093
13987
  const n = flatDataX.length;
@@ -14114,7 +14008,6 @@ stores.inject(MyMetaStore, storeInstance);
14114
14008
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14115
14009
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14116
14010
  ],
14117
- returns: ["NUMBER"],
14118
14011
  compute: function (...args) {
14119
14012
  return Math.sqrt(VAR.compute.bind(this)(...args));
14120
14013
  },
@@ -14129,7 +14022,6 @@ stores.inject(MyMetaStore, storeInstance);
14129
14022
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14130
14023
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14131
14024
  ],
14132
- returns: ["NUMBER"],
14133
14025
  compute: function (...args) {
14134
14026
  return Math.sqrt(VAR_P.compute.bind(this)(...args));
14135
14027
  },
@@ -14144,7 +14036,6 @@ stores.inject(MyMetaStore, storeInstance);
14144
14036
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14145
14037
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14146
14038
  ],
14147
- returns: ["NUMBER"],
14148
14039
  compute: function (...args) {
14149
14040
  return Math.sqrt(VAR_S.compute.bind(this)(...args));
14150
14041
  },
@@ -14159,7 +14050,6 @@ stores.inject(MyMetaStore, storeInstance);
14159
14050
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14160
14051
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14161
14052
  ],
14162
- returns: ["NUMBER"],
14163
14053
  compute: function (...args) {
14164
14054
  return Math.sqrt(VARA.compute.bind(this)(...args));
14165
14055
  },
@@ -14174,7 +14064,6 @@ stores.inject(MyMetaStore, storeInstance);
14174
14064
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14175
14065
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14176
14066
  ],
14177
- returns: ["NUMBER"],
14178
14067
  compute: function (...args) {
14179
14068
  return Math.sqrt(VARP.compute.bind(this)(...args));
14180
14069
  },
@@ -14189,7 +14078,6 @@ stores.inject(MyMetaStore, storeInstance);
14189
14078
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14190
14079
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14191
14080
  ],
14192
- returns: ["NUMBER"],
14193
14081
  compute: function (...args) {
14194
14082
  return Math.sqrt(VARPA.compute.bind(this)(...args));
14195
14083
  },
@@ -14204,7 +14092,6 @@ stores.inject(MyMetaStore, storeInstance);
14204
14092
  arg("data_y (range<number>)", _t("The range representing the array or matrix of dependent data.")),
14205
14093
  arg("data_x (range<number>)", _t("The range representing the array or matrix of independent data.")),
14206
14094
  ],
14207
- returns: ["NUMBER"],
14208
14095
  compute: function (dataY, dataX) {
14209
14096
  const { flatDataX, flatDataY } = filterAndFlatData(dataY, dataX);
14210
14097
  const data = fullLinearRegression([flatDataX], [flatDataY], true, true);
@@ -14223,7 +14110,6 @@ stores.inject(MyMetaStore, storeInstance);
14223
14110
  arg("new_data_x (number, range<number>, optional, default=known_data_x)", _t("The data points to return the y values for on the ideal curve fit.")),
14224
14111
  arg("b (boolean, optional, default=TRUE)", _t("Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.")),
14225
14112
  ],
14226
- returns: ["NUMBER"],
14227
14113
  compute: function (knownDataY, knownDataX = [[]], newDataX = [[]], b = { value: true }) {
14228
14114
  return predictLinearValues(toNumberMatrix(knownDataY, "the first argument (known_data_y)"), toNumberMatrix(knownDataX, "the second argument (known_data_x)"), toNumberMatrix(newDataX, "the third argument (new_data_y)"), toBoolean(b));
14229
14115
  },
@@ -14237,7 +14123,6 @@ stores.inject(MyMetaStore, storeInstance);
14237
14123
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14238
14124
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14239
14125
  ],
14240
- returns: ["NUMBER"],
14241
14126
  compute: function (...args) {
14242
14127
  return variance(args, true, false, this.locale);
14243
14128
  },
@@ -14252,7 +14137,6 @@ stores.inject(MyMetaStore, storeInstance);
14252
14137
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14253
14138
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14254
14139
  ],
14255
- returns: ["NUMBER"],
14256
14140
  compute: function (...args) {
14257
14141
  return variance(args, false, false, this.locale);
14258
14142
  },
@@ -14267,7 +14151,6 @@ stores.inject(MyMetaStore, storeInstance);
14267
14151
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14268
14152
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14269
14153
  ],
14270
- returns: ["NUMBER"],
14271
14154
  compute: function (...args) {
14272
14155
  return variance(args, true, false, this.locale);
14273
14156
  },
@@ -14282,7 +14165,6 @@ stores.inject(MyMetaStore, storeInstance);
14282
14165
  arg("value1 (number, range<number>)", _t("The first value or range of the sample.")),
14283
14166
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the sample.")),
14284
14167
  ],
14285
- returns: ["NUMBER"],
14286
14168
  compute: function (...args) {
14287
14169
  return variance(args, true, true, this.locale);
14288
14170
  },
@@ -14297,7 +14179,6 @@ stores.inject(MyMetaStore, storeInstance);
14297
14179
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14298
14180
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14299
14181
  ],
14300
- returns: ["NUMBER"],
14301
14182
  compute: function (...args) {
14302
14183
  return variance(args, false, false, this.locale);
14303
14184
  },
@@ -14312,7 +14193,6 @@ stores.inject(MyMetaStore, storeInstance);
14312
14193
  arg("value1 (number, range<number>)", _t("The first value or range of the population.")),
14313
14194
  arg("value2 (number, range<number>, repeating)", _t("Additional values or ranges to include in the population.")),
14314
14195
  ],
14315
- returns: ["NUMBER"],
14316
14196
  compute: function (...args) {
14317
14197
  return variance(args, false, true, this.locale);
14318
14198
  },
@@ -14478,7 +14358,6 @@ stores.inject(MyMetaStore, storeInstance);
14478
14358
  const DAVERAGE = {
14479
14359
  description: _t("Average of a set of values from a table-like range."),
14480
14360
  args: databaseArgs,
14481
- returns: ["NUMBER"],
14482
14361
  compute: function (database, field, criteria) {
14483
14362
  const cells = getMatchingCells(database, field, criteria, this.locale);
14484
14363
  return AVERAGE.compute.bind(this)([cells]);
@@ -14491,7 +14370,6 @@ stores.inject(MyMetaStore, storeInstance);
14491
14370
  const DCOUNT = {
14492
14371
  description: _t("Counts values from a table-like range."),
14493
14372
  args: databaseArgs,
14494
- returns: ["NUMBER"],
14495
14373
  compute: function (database, field, criteria) {
14496
14374
  const cells = getMatchingCells(database, field, criteria, this.locale);
14497
14375
  return COUNT.compute.bind(this)([cells]);
@@ -14504,7 +14382,6 @@ stores.inject(MyMetaStore, storeInstance);
14504
14382
  const DCOUNTA = {
14505
14383
  description: _t("Counts values and text from a table-like range."),
14506
14384
  args: databaseArgs,
14507
- returns: ["NUMBER"],
14508
14385
  compute: function (database, field, criteria) {
14509
14386
  const cells = getMatchingCells(database, field, criteria, this.locale);
14510
14387
  return COUNTA.compute.bind(this)([cells]);
@@ -14517,7 +14394,6 @@ stores.inject(MyMetaStore, storeInstance);
14517
14394
  const DGET = {
14518
14395
  description: _t("Single value from a table-like range."),
14519
14396
  args: databaseArgs,
14520
- returns: ["NUMBER"],
14521
14397
  compute: function (database, field, criteria) {
14522
14398
  const cells = getMatchingCells(database, field, criteria, this.locale);
14523
14399
  assert(() => cells.length === 1, _t("More than one match found in DGET evaluation."));
@@ -14531,7 +14407,6 @@ stores.inject(MyMetaStore, storeInstance);
14531
14407
  const DMAX = {
14532
14408
  description: _t("Maximum of values from a table-like range."),
14533
14409
  args: databaseArgs,
14534
- returns: ["NUMBER"],
14535
14410
  compute: function (database, field, criteria) {
14536
14411
  const cells = getMatchingCells(database, field, criteria, this.locale);
14537
14412
  return MAX.compute.bind(this)([cells]);
@@ -14544,7 +14419,6 @@ stores.inject(MyMetaStore, storeInstance);
14544
14419
  const DMIN = {
14545
14420
  description: _t("Minimum of values from a table-like range."),
14546
14421
  args: databaseArgs,
14547
- returns: ["NUMBER"],
14548
14422
  compute: function (database, field, criteria) {
14549
14423
  const cells = getMatchingCells(database, field, criteria, this.locale);
14550
14424
  return MIN.compute.bind(this)([cells]);
@@ -14557,7 +14431,6 @@ stores.inject(MyMetaStore, storeInstance);
14557
14431
  const DPRODUCT = {
14558
14432
  description: _t("Product of values from a table-like range."),
14559
14433
  args: databaseArgs,
14560
- returns: ["NUMBER"],
14561
14434
  compute: function (database, field, criteria) {
14562
14435
  const cells = getMatchingCells(database, field, criteria, this.locale);
14563
14436
  return PRODUCT.compute.bind(this)([cells]);
@@ -14570,7 +14443,6 @@ stores.inject(MyMetaStore, storeInstance);
14570
14443
  const DSTDEV = {
14571
14444
  description: _t("Standard deviation of population sample from table."),
14572
14445
  args: databaseArgs,
14573
- returns: ["NUMBER"],
14574
14446
  compute: function (database, field, criteria) {
14575
14447
  const cells = getMatchingCells(database, field, criteria, this.locale);
14576
14448
  return STDEV.compute.bind(this)([cells]);
@@ -14583,7 +14455,6 @@ stores.inject(MyMetaStore, storeInstance);
14583
14455
  const DSTDEVP = {
14584
14456
  description: _t("Standard deviation of entire population from table."),
14585
14457
  args: databaseArgs,
14586
- returns: ["NUMBER"],
14587
14458
  compute: function (database, field, criteria) {
14588
14459
  const cells = getMatchingCells(database, field, criteria, this.locale);
14589
14460
  return STDEVP.compute.bind(this)([cells]);
@@ -14596,7 +14467,6 @@ stores.inject(MyMetaStore, storeInstance);
14596
14467
  const DSUM = {
14597
14468
  description: _t("Sum of values from a table-like range."),
14598
14469
  args: databaseArgs,
14599
- returns: ["NUMBER"],
14600
14470
  compute: function (database, field, criteria) {
14601
14471
  const cells = getMatchingCells(database, field, criteria, this.locale);
14602
14472
  return SUM.compute.bind(this)([cells]);
@@ -14609,7 +14479,6 @@ stores.inject(MyMetaStore, storeInstance);
14609
14479
  const DVAR = {
14610
14480
  description: _t("Variance of population sample from table-like range."),
14611
14481
  args: databaseArgs,
14612
- returns: ["NUMBER"],
14613
14482
  compute: function (database, field, criteria) {
14614
14483
  const cells = getMatchingCells(database, field, criteria, this.locale);
14615
14484
  return VAR.compute.bind(this)([cells]);
@@ -14622,7 +14491,6 @@ stores.inject(MyMetaStore, storeInstance);
14622
14491
  const DVARP = {
14623
14492
  description: _t("Variance of a population from a table-like range."),
14624
14493
  args: databaseArgs,
14625
- returns: ["NUMBER"],
14626
14494
  compute: function (database, field, criteria) {
14627
14495
  const cells = getMatchingCells(database, field, criteria, this.locale);
14628
14496
  return VARP.compute.bind(this)([cells]);
@@ -14667,7 +14535,6 @@ stores.inject(MyMetaStore, storeInstance);
14667
14535
  arg("month (number)", _t("The month component of the date.")),
14668
14536
  arg("day (number)", _t("The day component of the date.")),
14669
14537
  ],
14670
- returns: ["DATE"],
14671
14538
  compute: function (year, month, day) {
14672
14539
  let _year = Math.trunc(toNumber(year, this.locale));
14673
14540
  const _month = Math.trunc(toNumber(month, this.locale));
@@ -14698,7 +14565,6 @@ stores.inject(MyMetaStore, storeInstance);
14698
14565
  arg("end_date (date)", _t("The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.")),
14699
14566
  arg("unit (string)", _t('A text abbreviation for unit of time. Accepted values are "Y" (the number of whole years between start_date and end_date), "M" (the number of whole months between start_date and end_date), "D" (the number of days between start_date and end_date), "MD" (the number of days between start_date and end_date after subtracting whole months), "YM" (the number of whole months between start_date and end_date after subtracting whole years), "YD" (the number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart).')),
14700
14567
  ],
14701
- returns: ["NUMBER"],
14702
14568
  compute: function (startDate, endDate, unit) {
14703
14569
  const _unit = toString(unit).toUpperCase();
14704
14570
  assert(() => Object.values(TIME_UNIT).includes(_unit), expectStringSetError(Object.values(TIME_UNIT), toString(unit)));
@@ -14751,7 +14617,6 @@ stores.inject(MyMetaStore, storeInstance);
14751
14617
  const DATEVALUE = {
14752
14618
  description: _t("Converts a date string to a date value."),
14753
14619
  args: [arg("date_string (string)", _t("The string representing the date."))],
14754
- returns: ["NUMBER"],
14755
14620
  compute: function (dateString) {
14756
14621
  const _dateString = toString(dateString);
14757
14622
  const internalDate = parseDateTime(_dateString, this.locale);
@@ -14766,7 +14631,6 @@ stores.inject(MyMetaStore, storeInstance);
14766
14631
  const DAY = {
14767
14632
  description: _t("Day of the month that a specific date falls on."),
14768
14633
  args: [arg("date (string)", _t("The date from which to extract the day."))],
14769
- returns: ["NUMBER"],
14770
14634
  compute: function (date) {
14771
14635
  return toJsDate(date, this.locale).getDate();
14772
14636
  },
@@ -14781,7 +14645,6 @@ stores.inject(MyMetaStore, storeInstance);
14781
14645
  arg("end_date (date)", _t("The end of the date range.")),
14782
14646
  arg("start_date (date)", _t("The start of the date range.")),
14783
14647
  ],
14784
- returns: ["NUMBER"],
14785
14648
  compute: function (endDate, startDate) {
14786
14649
  const _endDate = toJsDate(endDate, this.locale);
14787
14650
  const _startDate = toJsDate(startDate, this.locale);
@@ -14801,7 +14664,6 @@ stores.inject(MyMetaStore, storeInstance);
14801
14664
  arg("end_date (date)", _t("The end date to consider in the calculation.")),
14802
14665
  arg(`method (number, default=${DEFAULT_DAY_COUNT_METHOD})`, _t("An indicator of what day count method to use. (0) US NASD method (1) European method")),
14803
14666
  ],
14804
- returns: ["NUMBER"],
14805
14667
  compute: function (startDate, endDate, method = { value: DEFAULT_DAY_COUNT_METHOD }) {
14806
14668
  const _startDate = Math.trunc(toNumber(startDate, this.locale));
14807
14669
  const _endDate = Math.trunc(toNumber(endDate, this.locale));
@@ -14820,7 +14682,6 @@ stores.inject(MyMetaStore, storeInstance);
14820
14682
  arg("start_date (date)", _t("The date from which to calculate the result.")),
14821
14683
  arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to calculate.")),
14822
14684
  ],
14823
- returns: ["DATE"],
14824
14685
  compute: function (startDate, months) {
14825
14686
  const _startDate = toJsDate(startDate, this.locale);
14826
14687
  const _months = Math.trunc(toNumber(months, this.locale));
@@ -14841,7 +14702,6 @@ stores.inject(MyMetaStore, storeInstance);
14841
14702
  arg("start_date (date)", _t("The date from which to calculate the result.")),
14842
14703
  arg("months (number)", _t("The number of months before (negative) or after (positive) 'start_date' to consider.")),
14843
14704
  ],
14844
- returns: ["DATE"],
14845
14705
  compute: function (startDate, months) {
14846
14706
  const _startDate = toJsDate(startDate, this.locale);
14847
14707
  const _months = Math.trunc(toNumber(months, this.locale));
@@ -14861,7 +14721,6 @@ stores.inject(MyMetaStore, storeInstance);
14861
14721
  const HOUR = {
14862
14722
  description: _t("Hour component of a specific time."),
14863
14723
  args: [arg("time (date)", _t("The time from which to calculate the hour component."))],
14864
- returns: ["NUMBER"],
14865
14724
  compute: function (date) {
14866
14725
  return toJsDate(date, this.locale).getHours();
14867
14726
  },
@@ -14875,7 +14734,6 @@ stores.inject(MyMetaStore, storeInstance);
14875
14734
  args: [
14876
14735
  arg("date (date)", _t("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
14877
14736
  ],
14878
- returns: ["NUMBER"],
14879
14737
  compute: function (date) {
14880
14738
  const _date = toJsDate(date, this.locale);
14881
14739
  const y = _date.getFullYear();
@@ -14947,7 +14805,6 @@ stores.inject(MyMetaStore, storeInstance);
14947
14805
  const MINUTE = {
14948
14806
  description: _t("Minute component of a specific time."),
14949
14807
  args: [arg("time (date)", _t("The time from which to calculate the minute component."))],
14950
- returns: ["NUMBER"],
14951
14808
  compute: function (date) {
14952
14809
  return toJsDate(date, this.locale).getMinutes();
14953
14810
  },
@@ -14959,7 +14816,6 @@ stores.inject(MyMetaStore, storeInstance);
14959
14816
  const MONTH = {
14960
14817
  description: _t("Month of the year a specific date falls in"),
14961
14818
  args: [arg("date (date)", _t("The date from which to extract the month."))],
14962
- returns: ["NUMBER"],
14963
14819
  compute: function (date) {
14964
14820
  return toJsDate(date, this.locale).getMonth() + 1;
14965
14821
  },
@@ -14975,7 +14831,6 @@ stores.inject(MyMetaStore, storeInstance);
14975
14831
  arg("end_date (date)", _t("The end date of the period from which to calculate the number of net working days.")),
14976
14832
  arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the date serial numbers to consider holidays.")),
14977
14833
  ],
14978
- returns: ["NUMBER"],
14979
14834
  compute: function (startDate, endDate, holidays) {
14980
14835
  return NETWORKDAYS_INTL.compute.bind(this)(startDate, endDate, { value: 1 }, holidays);
14981
14836
  },
@@ -15056,7 +14911,6 @@ stores.inject(MyMetaStore, storeInstance);
15056
14911
  arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
15057
14912
  arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider as holidays.")),
15058
14913
  ],
15059
- returns: ["NUMBER"],
15060
14914
  compute: function (startDate, endDate, weekend = { value: DEFAULT_WEEKEND }, holidays) {
15061
14915
  const _startDate = toJsDate(startDate, this.locale);
15062
14916
  const _endDate = toJsDate(endDate, this.locale);
@@ -15091,7 +14945,6 @@ stores.inject(MyMetaStore, storeInstance);
15091
14945
  const NOW = {
15092
14946
  description: _t("Current date and time as a date value."),
15093
14947
  args: [],
15094
- returns: ["DATE"],
15095
14948
  compute: function () {
15096
14949
  const today = DateTime.now();
15097
14950
  const delta = today.getTime() - INITIAL_1900_DAY.getTime();
@@ -15109,7 +14962,6 @@ stores.inject(MyMetaStore, storeInstance);
15109
14962
  const SECOND = {
15110
14963
  description: _t("Minute component of a specific time."),
15111
14964
  args: [arg("time (date)", _t("The time from which to calculate the second component."))],
15112
- returns: ["NUMBER"],
15113
14965
  compute: function (date) {
15114
14966
  return toJsDate(date, this.locale).getSeconds();
15115
14967
  },
@@ -15125,7 +14977,6 @@ stores.inject(MyMetaStore, storeInstance);
15125
14977
  arg("minute (number)", _t("The minute component of the time.")),
15126
14978
  arg("second (number)", _t("The second component of the time.")),
15127
14979
  ],
15128
- returns: ["DATE"],
15129
14980
  compute: function (hour, minute, second) {
15130
14981
  let _hour = Math.trunc(toNumber(hour, this.locale));
15131
14982
  let _minute = Math.trunc(toNumber(minute, this.locale));
@@ -15149,7 +15000,6 @@ stores.inject(MyMetaStore, storeInstance);
15149
15000
  const TIMEVALUE = {
15150
15001
  description: _t("Converts a time string into its serial number representation."),
15151
15002
  args: [arg("time_string (string)", _t("The string that holds the time representation."))],
15152
- returns: ["NUMBER"],
15153
15003
  compute: function (timeString) {
15154
15004
  const _timeString = toString(timeString);
15155
15005
  const internalDate = parseDateTime(_timeString, this.locale);
@@ -15165,7 +15015,6 @@ stores.inject(MyMetaStore, storeInstance);
15165
15015
  const TODAY = {
15166
15016
  description: _t("Current date as a date value."),
15167
15017
  args: [],
15168
- returns: ["DATE"],
15169
15018
  compute: function () {
15170
15019
  const today = DateTime.now();
15171
15020
  const jsDate = new DateTime(today.getFullYear(), today.getMonth(), today.getDate());
@@ -15185,7 +15034,6 @@ stores.inject(MyMetaStore, storeInstance);
15185
15034
  arg("date (date)", _t("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
15186
15035
  arg(`type (number, default=${DEFAULT_TYPE})`, _t("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")),
15187
15036
  ],
15188
- returns: ["NUMBER"],
15189
15037
  compute: function (date, type = { value: DEFAULT_TYPE }) {
15190
15038
  const _date = toJsDate(date, this.locale);
15191
15039
  const _type = Math.round(toNumber(type, this.locale));
@@ -15208,7 +15056,6 @@ stores.inject(MyMetaStore, storeInstance);
15208
15056
  arg("date (date)", _t("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
15209
15057
  arg(`type (number, default=${DEFAULT_TYPE})`, _t("A number representing the day that a week starts on. Sunday = 1.")),
15210
15058
  ],
15211
- returns: ["NUMBER"],
15212
15059
  compute: function (date, type = { value: DEFAULT_TYPE }) {
15213
15060
  const _date = toJsDate(date, this.locale);
15214
15061
  const _type = Math.round(toNumber(type, this.locale));
@@ -15249,7 +15096,6 @@ stores.inject(MyMetaStore, storeInstance);
15249
15096
  arg("num_days (number)", _t("The number of working days to advance from start_date. If negative, counts backwards.")),
15250
15097
  arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
15251
15098
  ],
15252
- returns: ["NUMBER"],
15253
15099
  compute: function (startDate, numDays, holidays = { value: null }) {
15254
15100
  return WORKDAY_INTL.compute.bind(this)(startDate, numDays, { value: 1 }, holidays);
15255
15101
  },
@@ -15266,7 +15112,6 @@ stores.inject(MyMetaStore, storeInstance);
15266
15112
  arg(`weekend (any, default=${DEFAULT_WEEKEND})`, _t("A number or string representing which days of the week are considered weekends.")),
15267
15113
  arg("holidays (date, range<date>, optional)", _t("A range or array constant containing the dates to consider holidays.")),
15268
15114
  ],
15269
- returns: ["DATE"],
15270
15115
  compute: function (startDate, numDays, weekend = { value: DEFAULT_WEEKEND }, holidays) {
15271
15116
  let _startDate = toJsDate(startDate, this.locale);
15272
15117
  let _numDays = Math.trunc(toNumber(numDays, this.locale));
@@ -15306,7 +15151,6 @@ stores.inject(MyMetaStore, storeInstance);
15306
15151
  const YEAR = {
15307
15152
  description: _t("Year specified by a given date."),
15308
15153
  args: [arg("date (date)", _t("The date from which to extract the year."))],
15309
- returns: ["NUMBER"],
15310
15154
  compute: function (date) {
15311
15155
  return toJsDate(date, this.locale).getFullYear();
15312
15156
  },
@@ -15323,7 +15167,6 @@ stores.inject(MyMetaStore, storeInstance);
15323
15167
  arg("end_date (date)", _t("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")),
15324
15168
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION$1})`, _t("An indicator of what day count method to use.")),
15325
15169
  ],
15326
- returns: ["NUMBER"],
15327
15170
  compute: function (startDate, endDate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION$1 }) {
15328
15171
  let _startDate = Math.trunc(toNumber(startDate, this.locale));
15329
15172
  let _endDate = Math.trunc(toNumber(endDate, this.locale));
@@ -15340,7 +15183,6 @@ stores.inject(MyMetaStore, storeInstance);
15340
15183
  const MONTH_START = {
15341
15184
  description: _t("First day of the month preceding a date."),
15342
15185
  args: [arg("date (date)", _t("The date from which to calculate the result."))],
15343
- returns: ["DATE"],
15344
15186
  compute: function (date) {
15345
15187
  const _startDate = toJsDate(date, this.locale);
15346
15188
  const yStart = _startDate.getFullYear();
@@ -15358,7 +15200,6 @@ stores.inject(MyMetaStore, storeInstance);
15358
15200
  const MONTH_END = {
15359
15201
  description: _t("Last day of the month following a date."),
15360
15202
  args: [arg("date (date)", _t("The date from which to calculate the result."))],
15361
- returns: ["DATE"],
15362
15203
  compute: function (date) {
15363
15204
  return EOMONTH.compute.bind(this)(date, { value: 0 });
15364
15205
  },
@@ -15369,7 +15210,6 @@ stores.inject(MyMetaStore, storeInstance);
15369
15210
  const QUARTER = {
15370
15211
  description: _t("Quarter of the year a specific date falls in"),
15371
15212
  args: [arg("date (date)", _t("The date from which to extract the quarter."))],
15372
- returns: ["NUMBER"],
15373
15213
  compute: function (date) {
15374
15214
  return Math.ceil((toJsDate(date, this.locale).getMonth() + 1) / 3);
15375
15215
  },
@@ -15380,7 +15220,6 @@ stores.inject(MyMetaStore, storeInstance);
15380
15220
  const QUARTER_START = {
15381
15221
  description: _t("First day of the quarter of the year a specific date falls in."),
15382
15222
  args: [arg("date (date)", _t("The date from which to calculate the start of quarter."))],
15383
- returns: ["DATE"],
15384
15223
  compute: function (date) {
15385
15224
  const quarter = QUARTER.compute.bind(this)(date);
15386
15225
  const year = YEAR.compute.bind(this)(date);
@@ -15397,7 +15236,6 @@ stores.inject(MyMetaStore, storeInstance);
15397
15236
  const QUARTER_END = {
15398
15237
  description: _t("Last day of the quarter of the year a specific date falls in."),
15399
15238
  args: [arg("date (date)", _t("The date from which to calculate the end of quarter."))],
15400
- returns: ["DATE"],
15401
15239
  compute: function (date) {
15402
15240
  const quarter = QUARTER.compute.bind(this)(date);
15403
15241
  const year = YEAR.compute.bind(this)(date);
@@ -15414,7 +15252,6 @@ stores.inject(MyMetaStore, storeInstance);
15414
15252
  const YEAR_START = {
15415
15253
  description: _t("First day of the year a specific date falls in."),
15416
15254
  args: [arg("date (date)", _t("The date from which to calculate the start of the year."))],
15417
- returns: ["DATE"],
15418
15255
  compute: function (date) {
15419
15256
  const year = YEAR.compute.bind(this)(date);
15420
15257
  const jsDate = new DateTime(year, 0, 1);
@@ -15430,7 +15267,6 @@ stores.inject(MyMetaStore, storeInstance);
15430
15267
  const YEAR_END = {
15431
15268
  description: _t("Last day of the year a specific date falls in."),
15432
15269
  args: [arg("date (date)", _t("The date from which to calculate the end of the year."))],
15433
- returns: ["DATE"],
15434
15270
  compute: function (date) {
15435
15271
  const year = YEAR.compute.bind(this)(date);
15436
15272
  const jsDate = new DateTime(year + 1, 0, 0);
@@ -15487,7 +15323,6 @@ stores.inject(MyMetaStore, storeInstance);
15487
15323
  arg("number1 (number)", _t("The first number to compare.")),
15488
15324
  arg(`number2 (number, default=${DEFAULT_DELTA_ARG})`, _t("The second number to compare.")),
15489
15325
  ],
15490
- returns: ["NUMBER"],
15491
15326
  compute: function (number1, number2 = { value: DEFAULT_DELTA_ARG }) {
15492
15327
  const _number1 = toNumber(number1, this.locale);
15493
15328
  const _number2 = toNumber(number2, this.locale);
@@ -15678,7 +15513,6 @@ stores.inject(MyMetaStore, storeInstance);
15678
15513
  arg("condition1 (boolean, range<boolean>)", _t("A column or row containing true or false values corresponding to the first column or row of range.")),
15679
15514
  arg("condition2 (boolean, range<boolean>, repeating)", _t("Additional column or row containing true or false values.")),
15680
15515
  ],
15681
- returns: ["RANGE<ANY>"],
15682
15516
  compute: function (range, ...conditions) {
15683
15517
  let _array = toMatrix(range);
15684
15518
  const _conditionsMatrices = conditions.map((cond) => matrixMap(toMatrix(cond), (data) => data.value));
@@ -15712,7 +15546,6 @@ stores.inject(MyMetaStore, storeInstance);
15712
15546
  arg("sort_column (any, range<number>, repeating)", _t("The index of the column in range or a range outside of range containing the values by which to sort.")),
15713
15547
  arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
15714
15548
  ],
15715
- returns: ["RANGE"],
15716
15549
  compute: function (range, ...sortingCriteria) {
15717
15550
  const _range = transposeMatrix(range);
15718
15551
  return transposeMatrix(sortMatrix(_range, this.locale, ...sortingCriteria));
@@ -15731,7 +15564,6 @@ stores.inject(MyMetaStore, storeInstance);
15731
15564
  arg("sort_column (number, range<number>, repeating)", _t("The index of the column in range or a range outside of range containing the values by which to sort.")),
15732
15565
  arg("is_ascending (boolean, repeating)", _t("TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.")),
15733
15566
  ],
15734
- returns: ["RANGE"],
15735
15567
  compute: function (range, n, displayTiesMode, ...sortingCriteria) {
15736
15568
  const _n = toNumber(n?.value ?? 1, this.locale);
15737
15569
  assert(() => _n >= 0, _t("Wrong value of 'n'. Expected a positive number. Got %s.", _n));
@@ -15799,7 +15631,6 @@ stores.inject(MyMetaStore, storeInstance);
15799
15631
  arg("by_column (boolean, default=FALSE)", _t("Whether to filter the data by columns or by rows.")),
15800
15632
  arg("exactly_once (boolean, default=FALSE)", _t("Whether to return only entries with no duplicates.")),
15801
15633
  ],
15802
- returns: ["RANGE<NUMBER>"],
15803
15634
  compute: function (range = { value: "" }, byColumn, exactlyOnce) {
15804
15635
  if (!isMatrix(range)) {
15805
15636
  return [[range]];
@@ -16024,7 +15855,6 @@ stores.inject(MyMetaStore, storeInstance);
16024
15855
  arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
16025
15856
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
16026
15857
  ],
16027
- returns: ["NUMBER"],
16028
15858
  compute: function (issue, maturity, rate, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16029
15859
  const start = Math.trunc(toNumber(issue, this.locale));
16030
15860
  const end = Math.trunc(toNumber(maturity, this.locale));
@@ -16055,7 +15885,6 @@ stores.inject(MyMetaStore, storeInstance);
16055
15885
  arg("rate (number)", _t("The deprecation rate.")),
16056
15886
  arg("day_count_convention (number, optional)", _t("An indicator of what day count method to use.")),
16057
15887
  ],
16058
- returns: ["NUMBER"],
16059
15888
  compute: function (cost, purchaseDate, firstPeriodEnd, salvage, period, rate, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16060
15889
  dayCountConvention = dayCountConvention || 0;
16061
15890
  const _cost = toNumber(cost, this.locale);
@@ -16104,7 +15933,6 @@ stores.inject(MyMetaStore, storeInstance);
16104
15933
  const COUPDAYS = {
16105
15934
  description: _t("Days in coupon period containing settlement date."),
16106
15935
  args: COUPON_FUNCTION_ARGS,
16107
- returns: ["NUMBER"],
16108
15936
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16109
15937
  dayCountConvention = dayCountConvention || 0;
16110
15938
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16131,7 +15959,6 @@ stores.inject(MyMetaStore, storeInstance);
16131
15959
  const COUPDAYBS = {
16132
15960
  description: _t("Days from settlement until next coupon."),
16133
15961
  args: COUPON_FUNCTION_ARGS,
16134
- returns: ["NUMBER"],
16135
15962
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16136
15963
  dayCountConvention = dayCountConvention || 0;
16137
15964
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16188,7 +16015,6 @@ stores.inject(MyMetaStore, storeInstance);
16188
16015
  const COUPDAYSNC = {
16189
16016
  description: _t("Days from settlement until next coupon."),
16190
16017
  args: COUPON_FUNCTION_ARGS,
16191
- returns: ["NUMBER"],
16192
16018
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16193
16019
  dayCountConvention = dayCountConvention || 0;
16194
16020
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16218,7 +16044,6 @@ stores.inject(MyMetaStore, storeInstance);
16218
16044
  const COUPNCD = {
16219
16045
  description: _t("Next coupon date after the settlement date."),
16220
16046
  args: COUPON_FUNCTION_ARGS,
16221
- returns: ["NUMBER"],
16222
16047
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16223
16048
  dayCountConvention = dayCountConvention || 0;
16224
16049
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16244,7 +16069,6 @@ stores.inject(MyMetaStore, storeInstance);
16244
16069
  const COUPNUM = {
16245
16070
  description: _t("Number of coupons between settlement and maturity."),
16246
16071
  args: COUPON_FUNCTION_ARGS,
16247
- returns: ["NUMBER"],
16248
16072
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16249
16073
  dayCountConvention = dayCountConvention || 0;
16250
16074
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16271,7 +16095,6 @@ stores.inject(MyMetaStore, storeInstance);
16271
16095
  const COUPPCD = {
16272
16096
  description: _t("Last coupon date prior to or on the settlement date."),
16273
16097
  args: COUPON_FUNCTION_ARGS,
16274
- returns: ["NUMBER"],
16275
16098
  compute: function (settlement, maturity, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16276
16099
  dayCountConvention = dayCountConvention || 0;
16277
16100
  const start = Math.trunc(toNumber(settlement, this.locale));
@@ -16304,7 +16127,6 @@ stores.inject(MyMetaStore, storeInstance);
16304
16127
  arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
16305
16128
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
16306
16129
  ],
16307
- returns: ["NUMBER"],
16308
16130
  compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
16309
16131
  const first = toNumber(firstPeriod, this.locale);
16310
16132
  const last = toNumber(lastPeriod, this.locale);
@@ -16336,7 +16158,6 @@ stores.inject(MyMetaStore, storeInstance);
16336
16158
  arg("last_period (number)", _t("The number of the payment period to end the cumulative calculation.")),
16337
16159
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
16338
16160
  ],
16339
- returns: ["NUMBER"],
16340
16161
  compute: function (rate, numberOfPeriods, presentValue, firstPeriod, lastPeriod, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
16341
16162
  const first = toNumber(firstPeriod, this.locale);
16342
16163
  const last = toNumber(lastPeriod, this.locale);
@@ -16367,7 +16188,6 @@ stores.inject(MyMetaStore, storeInstance);
16367
16188
  arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
16368
16189
  arg("month (number, optional)", _t("The number of months in the first year of depreciation.")),
16369
16190
  ],
16370
- returns: ["NUMBER"],
16371
16191
  // to do: replace by dollar format
16372
16192
  compute: function (cost, salvage, life, period, ...args) {
16373
16193
  const _cost = toNumber(cost, this.locale);
@@ -16436,7 +16256,6 @@ stores.inject(MyMetaStore, storeInstance);
16436
16256
  arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
16437
16257
  arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The factor by which depreciation decreases.")),
16438
16258
  ],
16439
- returns: ["NUMBER"],
16440
16259
  compute: function (cost, salvage, life, period, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }) {
16441
16260
  const _cost = toNumber(cost, this.locale);
16442
16261
  const _salvage = toNumber(salvage, this.locale);
@@ -16462,7 +16281,6 @@ stores.inject(MyMetaStore, storeInstance);
16462
16281
  arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
16463
16282
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
16464
16283
  ],
16465
- returns: ["NUMBER"],
16466
16284
  compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16467
16285
  dayCountConvention = dayCountConvention || 0;
16468
16286
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -16498,7 +16316,6 @@ stores.inject(MyMetaStore, storeInstance);
16498
16316
  arg("fractional_price (number)", _t("The price quotation given using fractional decimal conventions.")),
16499
16317
  arg("unit (number)", _t("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
16500
16318
  ],
16501
- returns: ["NUMBER"],
16502
16319
  compute: function (fractionalPrice, unit) {
16503
16320
  const price = toNumber(fractionalPrice, this.locale);
16504
16321
  const _unit = Math.trunc(toNumber(unit, this.locale));
@@ -16519,7 +16336,6 @@ stores.inject(MyMetaStore, storeInstance);
16519
16336
  arg("decimal_price (number)", _t("The price quotation given as a decimal value.")),
16520
16337
  arg("unit (number)", _t("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")),
16521
16338
  ],
16522
- returns: ["NUMBER"],
16523
16339
  compute: function (decimalPrice, unit) {
16524
16340
  const price = toNumber(decimalPrice, this.locale);
16525
16341
  const _unit = Math.trunc(toNumber(unit, this.locale));
@@ -16544,7 +16360,6 @@ stores.inject(MyMetaStore, storeInstance);
16544
16360
  arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
16545
16361
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
16546
16362
  ],
16547
- returns: ["NUMBER"],
16548
16363
  compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16549
16364
  const start = Math.trunc(toNumber(settlement, this.locale));
16550
16365
  const end = Math.trunc(toNumber(maturity, this.locale));
@@ -16585,7 +16400,6 @@ stores.inject(MyMetaStore, storeInstance);
16585
16400
  arg("nominal_rate (number)", _t("The nominal interest rate per year.")),
16586
16401
  arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
16587
16402
  ],
16588
- returns: ["NUMBER"],
16589
16403
  compute: function (nominal_rate, periods_per_year) {
16590
16404
  const nominal = toNumber(nominal_rate, this.locale);
16591
16405
  const periods = Math.trunc(toNumber(periods_per_year, this.locale));
@@ -16615,7 +16429,6 @@ stores.inject(MyMetaStore, storeInstance);
16615
16429
  arg(`present_value (number, default=${DEFAULT_PRESENT_VALUE})`, _t("The current value of the annuity.")),
16616
16430
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
16617
16431
  ],
16618
- returns: ["NUMBER"],
16619
16432
  // to do: replace by dollar format
16620
16433
  compute: function (rate, numberOfPeriods, paymentAmount, presentValue = { value: DEFAULT_PRESENT_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
16621
16434
  presentValue = presentValue || 0;
@@ -16641,7 +16454,6 @@ stores.inject(MyMetaStore, storeInstance);
16641
16454
  arg("principal (number)", _t("The amount of initial capital or value to compound against.")),
16642
16455
  arg("rate_schedule (number, range<number>)", _t("A series of interest rates to compound against the principal.")),
16643
16456
  ],
16644
- returns: ["NUMBER"],
16645
16457
  compute: function (principalAmount, rateSchedule) {
16646
16458
  const principal = toNumber(principalAmount, this.locale);
16647
16459
  return reduceAny([rateSchedule], (acc, rate) => acc * (1 + toNumber(rate, this.locale)), principal);
@@ -16660,7 +16472,6 @@ stores.inject(MyMetaStore, storeInstance);
16660
16472
  arg("redemption (number)", _t("The amount to be received at maturity.")),
16661
16473
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
16662
16474
  ],
16663
- returns: ["NUMBER"],
16664
16475
  compute: function (settlement, maturity, investment, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16665
16476
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
16666
16477
  const _maturity = Math.trunc(toNumber(maturity, this.locale));
@@ -16699,7 +16510,6 @@ stores.inject(MyMetaStore, storeInstance);
16699
16510
  arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
16700
16511
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
16701
16512
  ],
16702
- returns: ["NUMBER"],
16703
16513
  compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
16704
16514
  const r = toNumber(rate, this.locale);
16705
16515
  const period = toNumber(currentPeriod, this.locale);
@@ -16724,7 +16534,6 @@ stores.inject(MyMetaStore, storeInstance);
16724
16534
  arg("cashflow_amounts (number, range<number>)", _t("An array or range containing the income or payments associated with the investment.")),
16725
16535
  arg(`rate_guess (number, default=${DEFAULT_RATE_GUESS})`, _t("An estimate for what the internal rate of return will be.")),
16726
16536
  ],
16727
- returns: ["NUMBER"],
16728
16537
  compute: function (cashFlowAmounts, rateGuess = { value: DEFAULT_RATE_GUESS }) {
16729
16538
  const _rateGuess = toNumber(rateGuess, this.locale);
16730
16539
  assertRateGuessStrictlyGreaterThanMinusOne(_rateGuess);
@@ -16786,7 +16595,6 @@ stores.inject(MyMetaStore, storeInstance);
16786
16595
  arg("number_of_periods (number)", _t("The number of payments to be made.")),
16787
16596
  arg("present_value (number)", _t("The current value of the annuity.")),
16788
16597
  ],
16789
- returns: ["NUMBER"],
16790
16598
  compute: function (rate, currentPeriod, numberOfPeriods, presentValue) {
16791
16599
  const interestRate = toNumber(rate, this.locale);
16792
16600
  const period = toNumber(currentPeriod, this.locale);
@@ -16811,7 +16619,6 @@ stores.inject(MyMetaStore, storeInstance);
16811
16619
  arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
16812
16620
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
16813
16621
  ],
16814
- returns: ["NUMBER"],
16815
16622
  compute: function (settlement, maturity, rate, securityYield, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
16816
16623
  const duration = DURATION.compute.bind(this)(settlement, maturity, rate, securityYield, frequency, dayCountConvention);
16817
16624
  const y = toNumber(securityYield, this.locale);
@@ -16830,7 +16637,6 @@ stores.inject(MyMetaStore, storeInstance);
16830
16637
  arg("financing_rate (number)", _t("The interest rate paid on funds invested.")),
16831
16638
  arg("reinvestment_return_rate (number)", _t("The return (as a percentage) earned on reinvestment of income received from the investment.")),
16832
16639
  ],
16833
- returns: ["NUMBER"],
16834
16640
  compute: function (cashflowAmount, financingRate, reinvestmentRate) {
16835
16641
  const fRate = toNumber(financingRate, this.locale);
16836
16642
  const rRate = toNumber(reinvestmentRate, this.locale);
@@ -16882,7 +16688,6 @@ stores.inject(MyMetaStore, storeInstance);
16882
16688
  arg("effective_rate (number)", _t("The effective interest rate per year.")),
16883
16689
  arg("periods_per_year (number)", _t("The number of compounding periods per year.")),
16884
16690
  ],
16885
- returns: ["NUMBER"],
16886
16691
  compute: function (effective_rate, periods_per_year) {
16887
16692
  const effective = toNumber(effective_rate, this.locale);
16888
16693
  const periods = Math.trunc(toNumber(periods_per_year, this.locale));
@@ -16905,7 +16710,6 @@ stores.inject(MyMetaStore, storeInstance);
16905
16710
  arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
16906
16711
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
16907
16712
  ],
16908
- returns: ["NUMBER"],
16909
16713
  compute: function (rate, paymentAmount, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
16910
16714
  futureValue = futureValue || 0;
16911
16715
  endOrBeginning = endOrBeginning || 0;
@@ -16953,7 +16757,6 @@ stores.inject(MyMetaStore, storeInstance);
16953
16757
  arg("cashflow1 (number, range<number>)", _t("The first future cash flow.")),
16954
16758
  arg("cashflow2 (number, range<number>, repeating)", _t("Additional future cash flows.")),
16955
16759
  ],
16956
- returns: ["NUMBER"],
16957
16760
  // to do: replace by dollar format
16958
16761
  compute: function (discount, ...values) {
16959
16762
  const _discount = toNumber(discount, this.locale);
@@ -16975,7 +16778,6 @@ stores.inject(MyMetaStore, storeInstance);
16975
16778
  arg("present_value (number)", _t("The investment's current value.")),
16976
16779
  arg("future_value (number)", _t("The investment's desired future value.")),
16977
16780
  ],
16978
- returns: ["NUMBER"],
16979
16781
  compute: function (rate, presentValue, futureValue) {
16980
16782
  const _rate = toNumber(rate, this.locale);
16981
16783
  const _presentValue = toNumber(presentValue, this.locale);
@@ -17015,7 +16817,6 @@ stores.inject(MyMetaStore, storeInstance);
17015
16817
  arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
17016
16818
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
17017
16819
  ],
17018
- returns: ["NUMBER"],
17019
16820
  compute: function (rate, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
17020
16821
  const n = toNumber(numberOfPeriods, this.locale);
17021
16822
  const r = toNumber(rate, this.locale);
@@ -17051,7 +16852,6 @@ stores.inject(MyMetaStore, storeInstance);
17051
16852
  arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
17052
16853
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
17053
16854
  ],
17054
- returns: ["NUMBER"],
17055
16855
  compute: function (rate, currentPeriod, numberOfPeriods, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
17056
16856
  const n = toNumber(numberOfPeriods, this.locale);
17057
16857
  const r = toNumber(rate, this.locale);
@@ -17078,7 +16878,6 @@ stores.inject(MyMetaStore, storeInstance);
17078
16878
  arg(`future_value (number, default=${DEFAULT_FUTURE_VALUE})`, _t("The future value remaining after the final payment has been made.")),
17079
16879
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
17080
16880
  ],
17081
- returns: ["NUMBER"],
17082
16881
  // to do: replace by dollar format
17083
16882
  compute: function (rate, numberOfPeriods, paymentAmount, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }) {
17084
16883
  futureValue = futureValue || 0;
@@ -17112,7 +16911,6 @@ stores.inject(MyMetaStore, storeInstance);
17112
16911
  arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
17113
16912
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17114
16913
  ],
17115
- returns: ["NUMBER"],
17116
16914
  compute: function (settlement, maturity, rate, securityYield, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17117
16915
  dayCountConvention = dayCountConvention || 0;
17118
16916
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17160,7 +16958,6 @@ stores.inject(MyMetaStore, storeInstance);
17160
16958
  arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
17161
16959
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17162
16960
  ],
17163
- returns: ["NUMBER"],
17164
16961
  compute: function (settlement, maturity, discount, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17165
16962
  dayCountConvention = dayCountConvention || 0;
17166
16963
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17198,7 +16995,6 @@ stores.inject(MyMetaStore, storeInstance);
17198
16995
  arg("yield (number)", _t("The expected annual yield of the security.")),
17199
16996
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17200
16997
  ],
17201
- returns: ["NUMBER"],
17202
16998
  compute: function (settlement, maturity, issue, rate, securityYield, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17203
16999
  dayCountConvention = dayCountConvention || 0;
17204
17000
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17262,7 +17058,6 @@ stores.inject(MyMetaStore, storeInstance);
17262
17058
  arg(`end_or_beginning (number, default=${DEFAULT_END_OR_BEGINNING})`, _t("Whether payments are due at the end (0) or beginning (1) of each period.")),
17263
17059
  arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the interest rate will be.")),
17264
17060
  ],
17265
- returns: ["NUMBER"],
17266
17061
  compute: function (numberOfPeriods, paymentPerPeriod, presentValue, futureValue = { value: DEFAULT_FUTURE_VALUE }, endOrBeginning = { value: DEFAULT_END_OR_BEGINNING }, rateGuess = { value: RATE_GUESS_DEFAULT }) {
17267
17062
  const n = toNumber(numberOfPeriods, this.locale);
17268
17063
  const payment = toNumber(paymentPerPeriod, this.locale);
@@ -17308,7 +17103,6 @@ stores.inject(MyMetaStore, storeInstance);
17308
17103
  arg("discount (number)", _t("The discount rate of the security invested in.")),
17309
17104
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17310
17105
  ],
17311
- returns: ["NUMBER"],
17312
17106
  compute: function (settlement, maturity, investment, discount, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17313
17107
  dayCountConvention = dayCountConvention || 0;
17314
17108
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17346,7 +17140,6 @@ stores.inject(MyMetaStore, storeInstance);
17346
17140
  arg("present_value (number)", _t("The present value of the investment.")),
17347
17141
  arg("future_value (number)", _t("The future value of the investment.")),
17348
17142
  ],
17349
- returns: ["NUMBER"],
17350
17143
  compute: function (numberOfPeriods, presentValue, futureValue) {
17351
17144
  const n = toNumber(numberOfPeriods, this.locale);
17352
17145
  const pv = toNumber(presentValue, this.locale);
@@ -17371,7 +17164,6 @@ stores.inject(MyMetaStore, storeInstance);
17371
17164
  arg("salvage (number)", _t("The value of the asset at the end of depreciation.")),
17372
17165
  arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
17373
17166
  ],
17374
- returns: ["NUMBER"],
17375
17167
  compute: function (cost, salvage, life) {
17376
17168
  const _cost = toNumber(cost, this.locale);
17377
17169
  const _salvage = toNumber(salvage, this.locale);
@@ -17396,7 +17188,6 @@ stores.inject(MyMetaStore, storeInstance);
17396
17188
  arg("life (number)", _t("The number of periods over which the asset is depreciated.")),
17397
17189
  arg("period (number)", _t("The single period within life for which to calculate depreciation.")),
17398
17190
  ],
17399
- returns: ["NUMBER"],
17400
17191
  compute: function (cost, salvage, life, period) {
17401
17192
  const _cost = toNumber(cost, this.locale);
17402
17193
  const _salvage = toNumber(salvage, this.locale);
@@ -17445,7 +17236,6 @@ stores.inject(MyMetaStore, storeInstance);
17445
17236
  arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
17446
17237
  arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
17447
17238
  ],
17448
- returns: ["NUMBER"],
17449
17239
  compute: function (settlement, maturity, discount) {
17450
17240
  const start = Math.trunc(toNumber(settlement, this.locale));
17451
17241
  const end = Math.trunc(toNumber(maturity, this.locale));
@@ -17468,7 +17258,6 @@ stores.inject(MyMetaStore, storeInstance);
17468
17258
  arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
17469
17259
  arg("discount (number)", _t("The discount rate of the bill at time of purchase.")),
17470
17260
  ],
17471
- returns: ["NUMBER"],
17472
17261
  compute: function (settlement, maturity, discount) {
17473
17262
  const start = Math.trunc(toNumber(settlement, this.locale));
17474
17263
  const end = Math.trunc(toNumber(maturity, this.locale));
@@ -17526,7 +17315,6 @@ stores.inject(MyMetaStore, storeInstance);
17526
17315
  arg("maturity (date)", _t("The maturity or end date of the security, when it can be redeemed at face, or par value.")),
17527
17316
  arg("price (number)", _t("The price at which the security is bought per 100 face value.")),
17528
17317
  ],
17529
- returns: ["NUMBER"],
17530
17318
  compute: function (settlement, maturity, price) {
17531
17319
  const start = Math.trunc(toNumber(settlement, this.locale));
17532
17320
  const end = Math.trunc(toNumber(maturity, this.locale));
@@ -17566,7 +17354,6 @@ stores.inject(MyMetaStore, storeInstance);
17566
17354
  arg(`factor (number, default=${DEFAULT_DDB_DEPRECIATION_FACTOR})`, _t("The number of months in the first year of depreciation.")),
17567
17355
  arg(`no_switch (number, default=${DEFAULT_VDB_NO_SWITCH})`, _t("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")),
17568
17356
  ],
17569
- returns: ["NUMBER"],
17570
17357
  compute: function (cost, salvage, life, startPeriod, endPeriod, factor = { value: DEFAULT_DDB_DEPRECIATION_FACTOR }, noSwitch = { value: DEFAULT_VDB_NO_SWITCH }) {
17571
17358
  factor = factor || 0;
17572
17359
  const _cost = toNumber(cost, this.locale);
@@ -17631,7 +17418,6 @@ stores.inject(MyMetaStore, storeInstance);
17631
17418
  arg("cashflow_dates (range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
17632
17419
  arg(`rate_guess (number, default=${RATE_GUESS_DEFAULT})`, _t("An estimate for what the internal rate of return will be.")),
17633
17420
  ],
17634
- returns: ["NUMBER"],
17635
17421
  compute: function (cashflowAmounts, cashflowDates, rateGuess = { value: RATE_GUESS_DEFAULT }) {
17636
17422
  const guess = toNumber(rateGuess, this.locale);
17637
17423
  const _cashFlows = cashflowAmounts.flat().map((val) => toNumber(val, this.locale));
@@ -17702,7 +17488,6 @@ stores.inject(MyMetaStore, storeInstance);
17702
17488
  arg("cashflow_amounts (number, range<number>)", _t("An range containing the income or payments associated with the investment.")),
17703
17489
  arg("cashflow_dates (number, range<number>)", _t("An range with dates corresponding to the cash flows in cashflow_amounts.")),
17704
17490
  ],
17705
- returns: ["NUMBER"],
17706
17491
  compute: function (discount, cashflowAmounts, cashflowDates) {
17707
17492
  const rate = toNumber(discount, this.locale);
17708
17493
  const _cashFlows = isMatrix(cashflowAmounts)
@@ -17769,7 +17554,6 @@ stores.inject(MyMetaStore, storeInstance);
17769
17554
  arg("frequency (number)", _t("The number of interest or coupon payments per year (1, 2, or 4).")),
17770
17555
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17771
17556
  ],
17772
- returns: ["NUMBER"],
17773
17557
  compute: function (settlement, maturity, rate, price, redemption, frequency, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17774
17558
  dayCountConvention = dayCountConvention || 0;
17775
17559
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17844,7 +17628,6 @@ stores.inject(MyMetaStore, storeInstance);
17844
17628
  arg("redemption (number)", _t("The redemption amount per 100 face value, or par.")),
17845
17629
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17846
17630
  ],
17847
- returns: ["NUMBER"],
17848
17631
  compute: function (settlement, maturity, price, redemption, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17849
17632
  dayCountConvention = dayCountConvention || 0;
17850
17633
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17881,7 +17664,6 @@ stores.inject(MyMetaStore, storeInstance);
17881
17664
  arg("price (number)", _t("The price at which the security is bought.")),
17882
17665
  arg(`day_count_convention (number, default=${DEFAULT_DAY_COUNT_CONVENTION} )`, _t("An indicator of what day count method to use.")),
17883
17666
  ],
17884
- returns: ["NUMBER"],
17885
17667
  compute: function (settlement, maturity, issue, rate, price, dayCountConvention = { value: DEFAULT_DAY_COUNT_CONVENTION }) {
17886
17668
  dayCountConvention = dayCountConvention || 0;
17887
17669
  const _settlement = Math.trunc(toNumber(settlement, this.locale));
@@ -17968,7 +17750,6 @@ stores.inject(MyMetaStore, storeInstance);
17968
17750
  arg("info_type (string)", _t("The type of information requested. Can be one of %s", CELL_INFO_TYPES.join(", "))),
17969
17751
  arg("reference (meta)", _t("The reference to the cell.")),
17970
17752
  ],
17971
- returns: ["ANY"],
17972
17753
  compute: function (info, reference) {
17973
17754
  const _info = toString(info).toLowerCase();
17974
17755
  assert(() => CELL_INFO_TYPES.includes(_info), _t("The info_type should be one of %s.", CELL_INFO_TYPES.join(", ")));
@@ -18019,7 +17800,6 @@ stores.inject(MyMetaStore, storeInstance);
18019
17800
  const ISERR = {
18020
17801
  description: _t("Whether a value is an error other than #N/A."),
18021
17802
  args: [arg("value (any)", _t("The value to be verified as an error type."))],
18022
- returns: ["BOOLEAN"],
18023
17803
  compute: function (data) {
18024
17804
  const value = data?.value;
18025
17805
  return isEvaluationError(value) && value !== CellErrorType.NotAvailable;
@@ -18032,7 +17812,6 @@ stores.inject(MyMetaStore, storeInstance);
18032
17812
  const ISERROR = {
18033
17813
  description: _t("Whether a value is an error."),
18034
17814
  args: [arg("value (any)", _t("The value to be verified as an error type."))],
18035
- returns: ["BOOLEAN"],
18036
17815
  compute: function (data) {
18037
17816
  const value = data?.value;
18038
17817
  return isEvaluationError(value);
@@ -18045,7 +17824,6 @@ stores.inject(MyMetaStore, storeInstance);
18045
17824
  const ISLOGICAL = {
18046
17825
  description: _t("Whether a value is `true` or `false`."),
18047
17826
  args: [arg("value (any)", _t("The value to be verified as a logical TRUE or FALSE."))],
18048
- returns: ["BOOLEAN"],
18049
17827
  compute: function (value) {
18050
17828
  return typeof value?.value === "boolean";
18051
17829
  },
@@ -18057,7 +17835,6 @@ stores.inject(MyMetaStore, storeInstance);
18057
17835
  const ISNA = {
18058
17836
  description: _t("Whether a value is the error #N/A."),
18059
17837
  args: [arg("value (any)", _t("The value to be verified as an error type."))],
18060
- returns: ["BOOLEAN"],
18061
17838
  compute: function (data) {
18062
17839
  return data?.value === CellErrorType.NotAvailable;
18063
17840
  },
@@ -18069,7 +17846,6 @@ stores.inject(MyMetaStore, storeInstance);
18069
17846
  const ISNONTEXT = {
18070
17847
  description: _t("Whether a value is non-textual."),
18071
17848
  args: [arg("value (any)", _t("The value to be checked."))],
18072
- returns: ["BOOLEAN"],
18073
17849
  compute: function (value) {
18074
17850
  return !ISTEXT.compute.bind(this)(value);
18075
17851
  },
@@ -18081,7 +17857,6 @@ stores.inject(MyMetaStore, storeInstance);
18081
17857
  const ISNUMBER = {
18082
17858
  description: _t("Whether a value is a number."),
18083
17859
  args: [arg("value (any)", _t("The value to be verified as a number."))],
18084
- returns: ["BOOLEAN"],
18085
17860
  compute: function (value) {
18086
17861
  return typeof value?.value === "number";
18087
17862
  },
@@ -18093,7 +17868,6 @@ stores.inject(MyMetaStore, storeInstance);
18093
17868
  const ISTEXT = {
18094
17869
  description: _t("Whether a value is text."),
18095
17870
  args: [arg("value (any)", _t("The value to be verified as text."))],
18096
- returns: ["BOOLEAN"],
18097
17871
  compute: function (value) {
18098
17872
  return typeof value?.value === "string" && isEvaluationError(value?.value) === false;
18099
17873
  },
@@ -18105,7 +17879,6 @@ stores.inject(MyMetaStore, storeInstance);
18105
17879
  const ISBLANK = {
18106
17880
  description: _t("Whether the referenced cell is empty"),
18107
17881
  args: [arg("value (any)", _t("Reference to the cell that will be checked for emptiness."))],
18108
- returns: ["BOOLEAN"],
18109
17882
  compute: function (value) {
18110
17883
  return value?.value === null;
18111
17884
  },
@@ -18117,7 +17890,6 @@ stores.inject(MyMetaStore, storeInstance);
18117
17890
  const NA = {
18118
17891
  description: _t("Returns the error value #N/A."),
18119
17892
  args: [],
18120
- returns: ["BOOLEAN"],
18121
17893
  compute: function () {
18122
17894
  return { value: CellErrorType.NotAvailable };
18123
17895
  },
@@ -18174,7 +17946,6 @@ stores.inject(MyMetaStore, storeInstance);
18174
17946
  arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
18175
17947
  arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that represent logical values.")),
18176
17948
  ],
18177
- returns: ["BOOLEAN"],
18178
17949
  compute: function (...logicalExpressions) {
18179
17950
  const { result, foundBoolean } = boolAnd(logicalExpressions);
18180
17951
  assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
@@ -18188,7 +17959,6 @@ stores.inject(MyMetaStore, storeInstance);
18188
17959
  const FALSE = {
18189
17960
  description: _t("Logical value `false`."),
18190
17961
  args: [],
18191
- returns: ["BOOLEAN"],
18192
17962
  compute: function () {
18193
17963
  return false;
18194
17964
  },
@@ -18204,7 +17974,6 @@ stores.inject(MyMetaStore, storeInstance);
18204
17974
  arg("value_if_true (any)", _t("The value the function returns if logical_expression is TRUE.")),
18205
17975
  arg("value_if_false (any, default=FALSE)", _t("The value the function returns if logical_expression is FALSE.")),
18206
17976
  ],
18207
- returns: ["ANY"],
18208
17977
  compute: function (logicalExpression, valueIfTrue, valueIfFalse) {
18209
17978
  const result = toBoolean(logicalExpression?.value) ? valueIfTrue : valueIfFalse;
18210
17979
  if (result === undefined) {
@@ -18226,7 +17995,6 @@ stores.inject(MyMetaStore, storeInstance);
18226
17995
  arg("value (any)", _t("The value to return if value itself is not an error.")),
18227
17996
  arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an error.")),
18228
17997
  ],
18229
- returns: ["ANY"],
18230
17998
  compute: function (value, valueIfError = { value: "" }) {
18231
17999
  const result = isEvaluationError(value?.value) ? valueIfError : value;
18232
18000
  if (result === undefined) {
@@ -18248,7 +18016,6 @@ stores.inject(MyMetaStore, storeInstance);
18248
18016
  arg("value (any)", _t("The value to return if value itself is not #N/A an error.")),
18249
18017
  arg(`value_if_error (any, default="empty")`, _t("The value the function returns if value is an #N/A error.")),
18250
18018
  ],
18251
- returns: ["ANY"],
18252
18019
  compute: function (value, valueIfError = { value: "" }) {
18253
18020
  const result = value?.value === CellErrorType.NotAvailable ? valueIfError : value;
18254
18021
  if (result === undefined) {
@@ -18272,7 +18039,6 @@ stores.inject(MyMetaStore, storeInstance);
18272
18039
  arg("condition2 (boolean, repeating)", _t("Additional conditions to be evaluated if the previous ones are FALSE.")),
18273
18040
  arg("value2 (any, repeating)", _t("Additional values to be returned if their corresponding conditions are TRUE.")),
18274
18041
  ],
18275
- returns: ["ANY"],
18276
18042
  compute: function (...values) {
18277
18043
  assert(() => values.length % 2 === 0, _t("Wrong number of arguments. Expected an even number of arguments."));
18278
18044
  for (let n = 0; n < values.length - 1; n += 2) {
@@ -18299,7 +18065,6 @@ stores.inject(MyMetaStore, storeInstance);
18299
18065
  args: [
18300
18066
  arg("logical_expression (boolean)", _t("An expression or reference to a cell holding an expression that represents some logical value.")),
18301
18067
  ],
18302
- returns: ["BOOLEAN"],
18303
18068
  compute: function (logicalExpression) {
18304
18069
  return !toBoolean(logicalExpression);
18305
18070
  },
@@ -18314,7 +18079,6 @@ stores.inject(MyMetaStore, storeInstance);
18314
18079
  arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
18315
18080
  arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
18316
18081
  ],
18317
- returns: ["BOOLEAN"],
18318
18082
  compute: function (...logicalExpressions) {
18319
18083
  const { result, foundBoolean } = boolOr(logicalExpressions);
18320
18084
  assert(() => foundBoolean, _t("[[FUNCTION_NAME]] has no valid input data."));
@@ -18328,7 +18092,6 @@ stores.inject(MyMetaStore, storeInstance);
18328
18092
  const TRUE = {
18329
18093
  description: _t("Logical value `true`."),
18330
18094
  args: [],
18331
- returns: ["BOOLEAN"],
18332
18095
  compute: function () {
18333
18096
  return true;
18334
18097
  },
@@ -18343,7 +18106,6 @@ stores.inject(MyMetaStore, storeInstance);
18343
18106
  arg("logical_expression1 (boolean, range<boolean>)", _t("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),
18344
18107
  arg("logical_expression2 (boolean, range<boolean>, repeating)", _t("More expressions that evaluate to logical values.")),
18345
18108
  ],
18346
- returns: ["BOOLEAN"],
18347
18109
  compute: function (...logicalExpressions) {
18348
18110
  let foundBoolean = false;
18349
18111
  let acc = false;
@@ -18372,9 +18134,229 @@ stores.inject(MyMetaStore, storeInstance);
18372
18134
  XOR: XOR
18373
18135
  });
18374
18136
 
18375
- //TODO This registry is only used to disable the support of exploded pivot for spreadsheet
18376
- const supportedPivotExplodedFormulaRegistry = new Registry();
18377
- supportedPivotExplodedFormulaRegistry.add("SPREADSHEET", false);
18137
+ const pivotTimeAdapterRegistry = new Registry();
18138
+ function pivotTimeAdapter(granularity) {
18139
+ return pivotTimeAdapterRegistry.get(granularity);
18140
+ }
18141
+ /**
18142
+ * The Time Adapter: Managing Time Periods for Pivot Functions
18143
+ *
18144
+ * Overview:
18145
+ * A time adapter is responsible for managing time periods associated with pivot functions.
18146
+ * Each type of period (day, week, month, quarter, etc.) has its own dedicated adapter.
18147
+ * The adapter's primary role is to normalize period values between spreadsheet functions,
18148
+ * and the pivot.
18149
+ * By normalizing the period value, it can be stored consistently in the pivot.
18150
+ *
18151
+ * Normalization Process:
18152
+ * When working with functions in the spreadsheet, the time adapter normalizes
18153
+ * the provided period to facilitate accurate lookup of values in the pivot.
18154
+ * For instance, if the spreadsheet function represents a day period as a number generated
18155
+ * by the DATE function (DATE(2023, 12, 25)), the time adapter will normalize it accordingly.
18156
+ *
18157
+ */
18158
+ /**
18159
+ * Normalized value: "12/25/2023"
18160
+ *
18161
+ * Note: Those two format are equivalent:
18162
+ * - "MM/dd/yyyy" (luxon format)
18163
+ * - "mm/dd/yyyy" (spreadsheet format)
18164
+ **/
18165
+ const dayAdapter = {
18166
+ normalizeFunctionValue(value) {
18167
+ const date = toNumber(value, DEFAULT_LOCALE);
18168
+ return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/dd/yyyy" });
18169
+ },
18170
+ getFormat(locale) {
18171
+ return (locale ?? DEFAULT_LOCALE).dateFormat;
18172
+ },
18173
+ formatValue(normalizedValue, locale) {
18174
+ locale = locale ?? DEFAULT_LOCALE;
18175
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18176
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18177
+ },
18178
+ toCellValue(normalizedValue) {
18179
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18180
+ },
18181
+ };
18182
+ /**
18183
+ * normalizes day of month number
18184
+ */
18185
+ const dayOfMonthAdapter = {
18186
+ normalizeFunctionValue(value) {
18187
+ const day = toNumber(value, DEFAULT_LOCALE);
18188
+ if (day < 1 || day > 31) {
18189
+ throw new EvaluationError(_t("%s is not a valid day of month (it should be a number between 1 and 31)", day));
18190
+ }
18191
+ return day;
18192
+ },
18193
+ getFormat() {
18194
+ return "0";
18195
+ },
18196
+ formatValue(normalizedValue, locale) {
18197
+ locale = locale ?? DEFAULT_LOCALE;
18198
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18199
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18200
+ },
18201
+ toCellValue(normalizedValue) {
18202
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18203
+ },
18204
+ };
18205
+ /**
18206
+ * Normalized value: "2/2023" for week 2 of 2023
18207
+ */
18208
+ const weekAdapter = {
18209
+ normalizeFunctionValue(value) {
18210
+ const [week, year] = value.split("/");
18211
+ return `${Number(week)}/${Number(year)}`;
18212
+ },
18213
+ getFormat() {
18214
+ return undefined;
18215
+ },
18216
+ formatValue(normalizedValue) {
18217
+ const [week, year] = normalizedValue.split("/");
18218
+ return _t("W%(week)s %(year)s", { week, year });
18219
+ },
18220
+ toCellValue(normalizedValue) {
18221
+ return this.formatValue(normalizedValue);
18222
+ },
18223
+ };
18224
+ /**
18225
+ * normalizes iso week number
18226
+ */
18227
+ const isoWeekNumberAdapter = {
18228
+ normalizeFunctionValue(value) {
18229
+ const isoWeek = toNumber(value, DEFAULT_LOCALE);
18230
+ if (isoWeek < 0 || isoWeek > 53) {
18231
+ throw new EvaluationError(_t("%s is not a valid week (it should be a number between 0 and 53)", isoWeek));
18232
+ }
18233
+ return isoWeek;
18234
+ },
18235
+ getFormat() {
18236
+ return "0";
18237
+ },
18238
+ formatValue(normalizedValue, locale) {
18239
+ locale = locale ?? DEFAULT_LOCALE;
18240
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18241
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18242
+ },
18243
+ toCellValue(normalizedValue) {
18244
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18245
+ },
18246
+ };
18247
+ /**
18248
+ * normalized month value is a string formatted as "MM/yyyy" (luxon format)
18249
+ * e.g. "01/2020" for January 2020
18250
+ */
18251
+ const monthAdapter = {
18252
+ normalizeFunctionValue(value) {
18253
+ const date = toNumber(value, DEFAULT_LOCALE);
18254
+ return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
18255
+ },
18256
+ getFormat() {
18257
+ return "mmmm yyyy";
18258
+ },
18259
+ formatValue(normalizedValue, locale) {
18260
+ locale = locale ?? DEFAULT_LOCALE;
18261
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18262
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18263
+ },
18264
+ toCellValue(normalizedValue) {
18265
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18266
+ },
18267
+ };
18268
+ /**
18269
+ * normalizes month number
18270
+ */
18271
+ const monthNumberAdapter = {
18272
+ normalizeFunctionValue(value) {
18273
+ const month = toNumber(value, DEFAULT_LOCALE);
18274
+ if (month < 1 || month > 12) {
18275
+ throw new EvaluationError(_t("%s is not a valid month (it should be a number between 1 and 12)", month));
18276
+ }
18277
+ return month;
18278
+ },
18279
+ getFormat() {
18280
+ return "0";
18281
+ },
18282
+ formatValue(normalizedValue, locale) {
18283
+ locale = locale ?? DEFAULT_LOCALE;
18284
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18285
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18286
+ },
18287
+ toCellValue(normalizedValue) {
18288
+ return MONTHS[toNumber(normalizedValue, DEFAULT_LOCALE) - 1].toString();
18289
+ },
18290
+ };
18291
+ /**
18292
+ * normalized quarter value is "quarter/year"
18293
+ * e.g. "1/2020" for Q1 2020
18294
+ */
18295
+ const quarterAdapter = {
18296
+ normalizeFunctionValue(value) {
18297
+ const [quarter, year] = value.split("/");
18298
+ return `${quarter}/${year}`;
18299
+ },
18300
+ getFormat() {
18301
+ return undefined;
18302
+ },
18303
+ formatValue(normalizedValue) {
18304
+ const [quarter, year] = normalizedValue.split("/");
18305
+ return _t("Q%(quarter)s %(year)s", { quarter, year });
18306
+ },
18307
+ toCellValue(normalizedValue) {
18308
+ return this.formatValue(normalizedValue);
18309
+ },
18310
+ };
18311
+ /**
18312
+ * normalizes quarter number
18313
+ */
18314
+ const quarterNumberAdapter = {
18315
+ normalizeFunctionValue(value) {
18316
+ const quarter = toNumber(value, DEFAULT_LOCALE);
18317
+ if (quarter < 1 || quarter > 4) {
18318
+ throw new EvaluationError(_t("%s is not a valid quarter (it should be a number between 1 and 4)", quarter));
18319
+ }
18320
+ return quarter;
18321
+ },
18322
+ getFormat() {
18323
+ return "0";
18324
+ },
18325
+ formatValue(normalizedValue, locale) {
18326
+ locale = locale ?? DEFAULT_LOCALE;
18327
+ const value = toNumber(normalizedValue, DEFAULT_LOCALE);
18328
+ return formatValue(value, { locale, format: this.getFormat(locale) });
18329
+ },
18330
+ toCellValue(normalizedValue) {
18331
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18332
+ },
18333
+ };
18334
+ const yearAdapter = {
18335
+ normalizeFunctionValue(value) {
18336
+ return toNumber(value, DEFAULT_LOCALE);
18337
+ },
18338
+ getFormat() {
18339
+ return "0";
18340
+ },
18341
+ formatValue(normalizedValue, locale) {
18342
+ locale = locale ?? DEFAULT_LOCALE;
18343
+ return formatValue(normalizedValue, { locale, format: "0" });
18344
+ },
18345
+ toCellValue(normalizedValue) {
18346
+ return toNumber(normalizedValue, DEFAULT_LOCALE);
18347
+ },
18348
+ };
18349
+ pivotTimeAdapterRegistry
18350
+ .add("day", dayAdapter)
18351
+ .add("week", weekAdapter)
18352
+ .add("month", monthAdapter)
18353
+ .add("quarter", quarterAdapter)
18354
+ .add("year", yearAdapter)
18355
+ .add("day_of_month", dayOfMonthAdapter)
18356
+ .add("iso_week_number", isoWeekNumberAdapter)
18357
+ .add("month_number", monthNumberAdapter)
18358
+ .add("quarter_number", quarterNumberAdapter)
18359
+ .add("year_number", yearAdapter);
18378
18360
 
18379
18361
  const AGGREGATOR_NAMES = {
18380
18362
  count: _t("Count"),
@@ -18390,7 +18372,7 @@ stores.inject(MyMetaStore, storeInstance);
18390
18372
  const AGGREGATORS_BY_FIELD_TYPE = {
18391
18373
  integer: NUMBER_CHAR_AGGREGATORS,
18392
18374
  char: NUMBER_CHAR_AGGREGATORS,
18393
- //TODO Support for date and boolean
18375
+ boolean: ["count_distinct", "count", "bool_and", "bool_or"],
18394
18376
  };
18395
18377
  const AGGREGATORS = {};
18396
18378
  for (const type in AGGREGATORS_BY_FIELD_TYPE) {
@@ -18500,6 +18482,44 @@ stores.inject(MyMetaStore, storeInstance);
18500
18482
  function flatPivotDomain(domain) {
18501
18483
  return domain.flatMap((arg) => [arg.field, arg.value]);
18502
18484
  }
18485
+ /**
18486
+ * Parses the value defining a pivot group in a PIVOT formula
18487
+ * e.g. given the following formula PIVOT.VALUE("1", "stage_id", "42", "status", "won"),
18488
+ * the two group values are "42" and "won".
18489
+ */
18490
+ function toNormalizedPivotValue(dimension, groupValue) {
18491
+ if (groupValue === null || groupValue === "null") {
18492
+ return null;
18493
+ }
18494
+ const groupValueString = typeof groupValue === "boolean"
18495
+ ? toString(groupValue).toLocaleLowerCase()
18496
+ : toString(groupValue);
18497
+ if (!pivotNormalizationValueRegistry.contains(dimension.type)) {
18498
+ throw new EvaluationError(_t("Field %(field)s is not supported because of its type (%(type)s)", {
18499
+ field: dimension.displayName,
18500
+ type: dimension.type,
18501
+ }));
18502
+ }
18503
+ // represents a field which is not set (=False server side)
18504
+ if (groupValueString === "false") {
18505
+ return false;
18506
+ }
18507
+ const normalizer = pivotNormalizationValueRegistry.get(dimension.type);
18508
+ return normalizer(groupValueString, dimension.granularity);
18509
+ }
18510
+ function normalizeDateTime(value, granularity) {
18511
+ if (!granularity) {
18512
+ throw "";
18513
+ }
18514
+ return pivotTimeAdapter(granularity).normalizeFunctionValue(value);
18515
+ }
18516
+ const pivotNormalizationValueRegistry = new Registry();
18517
+ pivotNormalizationValueRegistry
18518
+ .add("date", normalizeDateTime)
18519
+ .add("datetime", normalizeDateTime)
18520
+ .add("integer", (value) => toNumber(value, DEFAULT_LOCALE))
18521
+ .add("boolean", (value) => toBoolean(value))
18522
+ .add("char", (value) => toString(value));
18503
18523
 
18504
18524
  /**
18505
18525
  * Get the pivot ID from the formula pivot ID.
@@ -18576,7 +18596,6 @@ stores.inject(MyMetaStore, storeInstance);
18576
18596
  arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
18577
18597
  arg("sheet (string, optional)", _t("A string indicating the name of the sheet into which the address points.")),
18578
18598
  ],
18579
- returns: ["STRING"],
18580
18599
  compute: function (row, column, absoluteRelativeMode = { value: DEFAULT_ABSOLUTE_RELATIVE_MODE }, useA1Notation = { value: true }, sheet) {
18581
18600
  const rowNumber = strictToInteger(row, this.locale);
18582
18601
  const colNumber = strictToInteger(column, this.locale);
@@ -18613,7 +18632,6 @@ stores.inject(MyMetaStore, storeInstance);
18613
18632
  args: [
18614
18633
  arg("cell_reference (meta, default='this cell')", _t("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.")),
18615
18634
  ],
18616
- returns: ["NUMBER"],
18617
18635
  compute: function (cellReference) {
18618
18636
  if (isEvaluationError(cellReference?.value)) {
18619
18637
  throw cellReference;
@@ -18631,7 +18649,6 @@ stores.inject(MyMetaStore, storeInstance);
18631
18649
  const COLUMNS = {
18632
18650
  description: _t("Number of columns in a specified array or range."),
18633
18651
  args: [arg("range (meta)", _t("The range whose column count will be returned."))],
18634
- returns: ["NUMBER"],
18635
18652
  compute: function (range) {
18636
18653
  if (isEvaluationError(range?.value)) {
18637
18654
  throw range;
@@ -18652,7 +18669,6 @@ stores.inject(MyMetaStore, storeInstance);
18652
18669
  arg("index (number)", _t("The row index of the value to be returned, where the first row in range is numbered 1.")),
18653
18670
  arg(`is_sorted (boolean, default=${DEFAULT_IS_SORTED})`, _t("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")),
18654
18671
  ],
18655
- returns: ["ANY"],
18656
18672
  compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
18657
18673
  const _index = Math.trunc(toNumber(index?.value, this.locale));
18658
18674
  assert(() => 1 <= _index && _index <= range[0].length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
@@ -18682,7 +18698,6 @@ stores.inject(MyMetaStore, storeInstance);
18682
18698
  arg("row (number, default=0)", _t("The index of the row to be returned from within the reference range of cells.")),
18683
18699
  arg("column (number, default=0)", _t("The index of the column to be returned from within the reference range of cells.")),
18684
18700
  ],
18685
- returns: ["ANY"],
18686
18701
  compute: function (reference, row = { value: 0 }, column = { value: 0 }) {
18687
18702
  const _reference = toMatrix(reference);
18688
18703
  const _row = toNumber(row.value, this.locale);
@@ -18713,7 +18728,6 @@ stores.inject(MyMetaStore, storeInstance);
18713
18728
  arg("reference (string)", _t("The range of cells from which the values are returned.")),
18714
18729
  arg("use_a1_notation (boolean, default=TRUE)", _t("A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).")),
18715
18730
  ],
18716
- returns: ["ANY"],
18717
18731
  compute: function (reference, useA1Notation = { value: true }) {
18718
18732
  let _reference = reference?.value?.toString();
18719
18733
  if (!_reference) {
@@ -18768,7 +18782,6 @@ stores.inject(MyMetaStore, storeInstance);
18768
18782
  arg("search_array (range)", _t("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")),
18769
18783
  arg("result_range (range, optional)", _t("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")),
18770
18784
  ],
18771
- returns: ["ANY"],
18772
18785
  compute: function (searchKey, searchArray, resultRange) {
18773
18786
  let nbCol = searchArray.length;
18774
18787
  let nbRow = searchArray[0].length;
@@ -18809,7 +18822,6 @@ stores.inject(MyMetaStore, storeInstance);
18809
18822
  arg("range (any, range)", _t("The one-dimensional array to be searched.")),
18810
18823
  arg(`search_type (number, default=${DEFAULT_SEARCH_TYPE})`, _t("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")),
18811
18824
  ],
18812
- returns: ["NUMBER"],
18813
18825
  compute: function (searchKey, range, searchType = { value: DEFAULT_SEARCH_TYPE }) {
18814
18826
  let _searchType = toNumber(searchType, this.locale);
18815
18827
  const nbCol = range.length;
@@ -18848,7 +18860,6 @@ stores.inject(MyMetaStore, storeInstance);
18848
18860
  args: [
18849
18861
  arg("cell_reference (meta, default='this cell')", _t("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.")),
18850
18862
  ],
18851
- returns: ["NUMBER"],
18852
18863
  compute: function (cellReference) {
18853
18864
  if (isEvaluationError(cellReference?.value)) {
18854
18865
  throw cellReference;
@@ -18866,7 +18877,6 @@ stores.inject(MyMetaStore, storeInstance);
18866
18877
  const ROWS = {
18867
18878
  description: _t("Number of rows in a specified array or range."),
18868
18879
  args: [arg("range (meta)", _t("The range whose row count will be returned."))],
18869
- returns: ["NUMBER"],
18870
18880
  compute: function (range) {
18871
18881
  if (isEvaluationError(range?.value)) {
18872
18882
  throw range;
@@ -18887,7 +18897,6 @@ stores.inject(MyMetaStore, storeInstance);
18887
18897
  arg("index (number)", _t("The column index of the value to be returned, where the first column in range is numbered 1.")),
18888
18898
  arg(`is_sorted (boolean, default=${DEFAULT_IS_SORTED})`, _t("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")),
18889
18899
  ],
18890
- returns: ["ANY"],
18891
18900
  compute: function (searchKey, range, index, isSorted = { value: DEFAULT_IS_SORTED }) {
18892
18901
  const _index = Math.trunc(toNumber(index?.value, this.locale));
18893
18902
  assert(() => 1 <= _index && _index <= range.length, _t("[[FUNCTION_NAME]] evaluates to an out of bounds range."));
@@ -18933,7 +18942,6 @@ stores.inject(MyMetaStore, storeInstance);
18933
18942
  (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned.\
18934
18943
  ")),
18935
18944
  ],
18936
- returns: ["ANY"],
18937
18945
  compute: function (searchKey, lookupRange, returnRange, defaultValue, matchMode = { value: DEFAULT_MATCH_MODE }, searchMode = { value: DEFAULT_SEARCH_MODE }) {
18938
18946
  const _matchMode = Math.trunc(toNumber(matchMode.value, this.locale));
18939
18947
  const _searchMode = Math.trunc(toNumber(searchMode.value, this.locale));
@@ -18989,12 +18997,6 @@ stores.inject(MyMetaStore, storeInstance);
18989
18997
  assertDomainLength(_domainArgs);
18990
18998
  const pivot = this.getters.getPivot(pivotId);
18991
18999
  const coreDefinition = this.getters.getPivotCoreDefinition(pivotId);
18992
- if (!supportedPivotExplodedFormulaRegistry.get(coreDefinition.type)) {
18993
- return {
18994
- value: CellErrorType.GenericError,
18995
- message: _t("This pivot does not support PIVOT.VALUE formula"),
18996
- };
18997
- }
18998
19000
  addPivotDependencies(this, coreDefinition);
18999
19001
  const error = pivot.assertIsValid({ throwOnError: false });
19000
19002
  if (error) {
@@ -19010,7 +19012,6 @@ stores.inject(MyMetaStore, storeInstance);
19010
19012
  }
19011
19013
  return { value, format };
19012
19014
  },
19013
- returns: ["NUMBER", "STRING"],
19014
19015
  };
19015
19016
  const PIVOT_HEADER = {
19016
19017
  description: _t("Get the header of a pivot."),
@@ -19026,12 +19027,6 @@ stores.inject(MyMetaStore, storeInstance);
19026
19027
  assertDomainLength(_domainArgs);
19027
19028
  const pivot = this.getters.getPivot(_pivotId);
19028
19029
  const coreDefinition = this.getters.getPivotCoreDefinition(_pivotId);
19029
- if (!supportedPivotExplodedFormulaRegistry.get(coreDefinition.type)) {
19030
- return {
19031
- value: CellErrorType.GenericError,
19032
- message: _t("This pivot does not support PIVOT.VALUE formula"),
19033
- };
19034
- }
19035
19030
  addPivotDependencies(this, coreDefinition);
19036
19031
  const error = pivot.assertIsValid({ throwOnError: false });
19037
19032
  if (error) {
@@ -19056,7 +19051,6 @@ stores.inject(MyMetaStore, storeInstance);
19056
19051
  : format,
19057
19052
  };
19058
19053
  },
19059
- returns: ["NUMBER", "STRING"],
19060
19054
  };
19061
19055
  const PIVOT = {
19062
19056
  description: _t("Get a pivot table."),
@@ -19123,7 +19117,6 @@ stores.inject(MyMetaStore, storeInstance);
19123
19117
  }
19124
19118
  return result;
19125
19119
  },
19126
- returns: ["RANGE<ANY>"],
19127
19120
  };
19128
19121
 
19129
19122
  var lookup = /*#__PURE__*/Object.freeze({
@@ -19154,7 +19147,6 @@ stores.inject(MyMetaStore, storeInstance);
19154
19147
  arg("value1 (number)", _t("The first addend.")),
19155
19148
  arg("value2 (number)", _t("The second addend.")),
19156
19149
  ],
19157
- returns: ["NUMBER"],
19158
19150
  compute: function (value1, value2) {
19159
19151
  return {
19160
19152
  value: toNumber(value1, this.locale) + toNumber(value2, this.locale),
@@ -19171,7 +19163,6 @@ stores.inject(MyMetaStore, storeInstance);
19171
19163
  arg("value1 (string)", _t("The value to which value2 will be appended.")),
19172
19164
  arg("value2 (string)", _t("The value to append to value1.")),
19173
19165
  ],
19174
- returns: ["STRING"],
19175
19166
  compute: function (value1, value2) {
19176
19167
  return toString(value1) + toString(value2);
19177
19168
  },
@@ -19186,7 +19177,6 @@ stores.inject(MyMetaStore, storeInstance);
19186
19177
  arg("dividend (number)", _t("The number to be divided.")),
19187
19178
  arg("divisor (number)", _t("The number to divide by.")),
19188
19179
  ],
19189
- returns: ["NUMBER"],
19190
19180
  compute: function (dividend, divisor) {
19191
19181
  const _divisor = toNumber(divisor, this.locale);
19192
19182
  assert(() => _divisor !== 0, _t("The divisor must be different from zero."), CellErrorType.DivisionByZero);
@@ -19209,7 +19199,6 @@ stores.inject(MyMetaStore, storeInstance);
19209
19199
  arg("value1 (any)", _t("The first value.")),
19210
19200
  arg("value2 (any)", _t("The value to test against value1 for equality.")),
19211
19201
  ],
19212
- returns: ["BOOLEAN"],
19213
19202
  compute: function (value1, value2) {
19214
19203
  let _value1 = isEmpty(value1) ? getNeutral[typeof value2?.value] : value1?.value;
19215
19204
  let _value2 = isEmpty(value2) ? getNeutral[typeof value1?.value] : value2?.value;
@@ -19262,7 +19251,6 @@ stores.inject(MyMetaStore, storeInstance);
19262
19251
  arg("value1 (any)", _t("The value to test as being greater than value2.")),
19263
19252
  arg("value2 (any)", _t("The second value.")),
19264
19253
  ],
19265
- returns: ["BOOLEAN"],
19266
19254
  compute: function (value1, value2) {
19267
19255
  return applyRelationalOperator(value1, value2, (v1, v2) => {
19268
19256
  return v1 > v2;
@@ -19278,7 +19266,6 @@ stores.inject(MyMetaStore, storeInstance);
19278
19266
  arg("value1 (any)", _t("The value to test as being greater than or equal to value2.")),
19279
19267
  arg("value2 (any)", _t("The second value.")),
19280
19268
  ],
19281
- returns: ["BOOLEAN"],
19282
19269
  compute: function (value1, value2) {
19283
19270
  return applyRelationalOperator(value1, value2, (v1, v2) => {
19284
19271
  return v1 >= v2;
@@ -19294,7 +19281,6 @@ stores.inject(MyMetaStore, storeInstance);
19294
19281
  arg("value1 (any)", _t("The value to test as being less than value2.")),
19295
19282
  arg("value2 (any)", _t("The second value.")),
19296
19283
  ],
19297
- returns: ["BOOLEAN"],
19298
19284
  compute: function (value1, value2) {
19299
19285
  return !GTE.compute.bind(this)(value1, value2);
19300
19286
  },
@@ -19308,7 +19294,6 @@ stores.inject(MyMetaStore, storeInstance);
19308
19294
  arg("value1 (any)", _t("The value to test as being less than or equal to value2.")),
19309
19295
  arg("value2 (any)", _t("The second value.")),
19310
19296
  ],
19311
- returns: ["BOOLEAN"],
19312
19297
  compute: function (value1, value2) {
19313
19298
  return !GT.compute.bind(this)(value1, value2);
19314
19299
  },
@@ -19322,7 +19307,6 @@ stores.inject(MyMetaStore, storeInstance);
19322
19307
  arg("value1 (number)", _t("The minuend, or number to be subtracted from.")),
19323
19308
  arg("value2 (number)", _t("The subtrahend, or number to subtract from value1.")),
19324
19309
  ],
19325
- returns: ["NUMBER"],
19326
19310
  compute: function (value1, value2) {
19327
19311
  return {
19328
19312
  value: toNumber(value1, this.locale) - toNumber(value2, this.locale),
@@ -19339,7 +19323,6 @@ stores.inject(MyMetaStore, storeInstance);
19339
19323
  arg("factor1 (number)", _t("The first multiplicand.")),
19340
19324
  arg("factor2 (number)", _t("The second multiplicand.")),
19341
19325
  ],
19342
- returns: ["NUMBER"],
19343
19326
  compute: function (factor1, factor2) {
19344
19327
  return {
19345
19328
  value: toNumber(factor1, this.locale) * toNumber(factor2, this.locale),
@@ -19356,7 +19339,6 @@ stores.inject(MyMetaStore, storeInstance);
19356
19339
  arg("value1 (any)", _t("The first value.")),
19357
19340
  arg("value2 (any)", _t("The value to test against value1 for inequality.")),
19358
19341
  ],
19359
- returns: ["BOOLEAN"],
19360
19342
  compute: function (value1, value2) {
19361
19343
  return !EQ.compute.bind(this)(value1, value2);
19362
19344
  },
@@ -19370,7 +19352,6 @@ stores.inject(MyMetaStore, storeInstance);
19370
19352
  arg("base (number)", _t("The number to raise to the exponent power.")),
19371
19353
  arg("exponent (number)", _t("The exponent to raise base to.")),
19372
19354
  ],
19373
- returns: ["NUMBER"],
19374
19355
  compute: function (base, exponent) {
19375
19356
  return POWER.compute.bind(this)(base, exponent);
19376
19357
  },
@@ -19383,7 +19364,6 @@ stores.inject(MyMetaStore, storeInstance);
19383
19364
  args: [
19384
19365
  arg("value (number)", _t("The number to have its sign reversed. Equivalently, the number to multiply by -1.")),
19385
19366
  ],
19386
- returns: ["NUMBER"],
19387
19367
  compute: function (value) {
19388
19368
  return {
19389
19369
  value: -toNumber(value, this.locale),
@@ -19397,7 +19377,6 @@ stores.inject(MyMetaStore, storeInstance);
19397
19377
  const UNARY_PERCENT = {
19398
19378
  description: _t("Value interpreted as a percentage."),
19399
19379
  args: [arg("percentage (number)", _t("The value to interpret as a percentage."))],
19400
- returns: ["NUMBER"],
19401
19380
  compute: function (percentage) {
19402
19381
  return toNumber(percentage, this.locale) / 100;
19403
19382
  },
@@ -19408,7 +19387,6 @@ stores.inject(MyMetaStore, storeInstance);
19408
19387
  const UPLUS = {
19409
19388
  description: _t("A specified number, unchanged."),
19410
19389
  args: [arg("value (any)", _t("The number to return."))],
19411
- returns: ["ANY"],
19412
19390
  compute: function (value = { value: null }) {
19413
19391
  return value;
19414
19392
  },
@@ -19444,7 +19422,6 @@ stores.inject(MyMetaStore, storeInstance);
19444
19422
  args: [
19445
19423
  arg("table_number (number)", _t("The number of the character to look up from the current Unicode table in decimal format.")),
19446
19424
  ],
19447
- returns: ["STRING"],
19448
19425
  compute: function (tableNumber) {
19449
19426
  const _tableNumber = Math.trunc(toNumber(tableNumber, this.locale));
19450
19427
  assert(() => _tableNumber >= 1, _t("The table_number (%s) is out of range.", _tableNumber.toString()));
@@ -19458,7 +19435,6 @@ stores.inject(MyMetaStore, storeInstance);
19458
19435
  const CLEAN = {
19459
19436
  description: _t("Remove non-printable characters from a piece of text."),
19460
19437
  args: [arg("text (string)", _t("The text whose non-printable characters are to be removed."))],
19461
- returns: ["STRING"],
19462
19438
  compute: function (text) {
19463
19439
  const _text = toString(text);
19464
19440
  let cleanedStr = "";
@@ -19480,7 +19456,6 @@ stores.inject(MyMetaStore, storeInstance);
19480
19456
  arg("string1 (string, range<string>)", _t("The initial string.")),
19481
19457
  arg("string2 (string, range<string>, repeating)", _t("More strings to append in sequence.")),
19482
19458
  ],
19483
- returns: ["STRING"],
19484
19459
  compute: function (...datas) {
19485
19460
  return reduceAny(datas, (acc, a) => acc + toString(a), "");
19486
19461
  },
@@ -19495,7 +19470,6 @@ stores.inject(MyMetaStore, storeInstance);
19495
19470
  arg("string1 (string)", _t("The first string to compare.")),
19496
19471
  arg("string2 (string)", _t("The second string to compare.")),
19497
19472
  ],
19498
- returns: ["BOOLEAN"],
19499
19473
  compute: function (string1, string2) {
19500
19474
  return toString(string1) === toString(string2);
19501
19475
  },
@@ -19511,7 +19485,6 @@ stores.inject(MyMetaStore, storeInstance);
19511
19485
  arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
19512
19486
  arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
19513
19487
  ],
19514
- returns: ["NUMBER"],
19515
19488
  compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
19516
19489
  const _searchFor = toString(searchFor);
19517
19490
  const _textToSearch = toString(textToSearch);
@@ -19534,7 +19507,6 @@ stores.inject(MyMetaStore, storeInstance);
19534
19507
  arg("value_or_array1 (string, range<string>)", _t("The value or values to be appended using delimiter.")),
19535
19508
  arg("value_or_array2 (string, range<string>, repeating)", _t("More values to be appended using delimiter.")),
19536
19509
  ],
19537
- returns: ["STRING"],
19538
19510
  compute: function (delimiter, ...valuesOrArrays) {
19539
19511
  const _delimiter = toString(delimiter);
19540
19512
  return reduceAny(valuesOrArrays, (acc, a) => (acc ? acc + _delimiter : "") + toString(a), "");
@@ -19549,7 +19521,6 @@ stores.inject(MyMetaStore, storeInstance);
19549
19521
  arg("text (string)", _t("The string from which the left portion will be returned.")),
19550
19522
  arg("number_of_characters (number, optional)", _t("The number of characters to return from the left side of string.")),
19551
19523
  ],
19552
- returns: ["STRING"],
19553
19524
  compute: function (text, ...args) {
19554
19525
  const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
19555
19526
  assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
@@ -19563,7 +19534,6 @@ stores.inject(MyMetaStore, storeInstance);
19563
19534
  const LEN = {
19564
19535
  description: _t("Length of a string."),
19565
19536
  args: [arg("text (string)", _t("The string whose length will be returned."))],
19566
- returns: ["NUMBER"],
19567
19537
  compute: function (text) {
19568
19538
  return toString(text).length;
19569
19539
  },
@@ -19575,7 +19545,6 @@ stores.inject(MyMetaStore, storeInstance);
19575
19545
  const LOWER = {
19576
19546
  description: _t("Converts a specified string to lowercase."),
19577
19547
  args: [arg("text (string)", _t("The string to convert to lowercase."))],
19578
- returns: ["STRING"],
19579
19548
  compute: function (text) {
19580
19549
  return toString(text).toLowerCase();
19581
19550
  },
@@ -19591,7 +19560,6 @@ stores.inject(MyMetaStore, storeInstance);
19591
19560
  arg("starting_at (number)", _t("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),
19592
19561
  arg("extract_length (number)", _t("The length of the segment to extract.")),
19593
19562
  ],
19594
- returns: ["STRING"],
19595
19563
  compute: function (text, starting_at, extract_length) {
19596
19564
  const _text = toString(text);
19597
19565
  const _starting_at = toNumber(starting_at, this.locale);
@@ -19610,7 +19578,6 @@ stores.inject(MyMetaStore, storeInstance);
19610
19578
  args: [
19611
19579
  arg("text_to_capitalize (string)", _t("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")),
19612
19580
  ],
19613
- returns: ["STRING"],
19614
19581
  compute: function (text) {
19615
19582
  const _text = toString(text);
19616
19583
  return _text.replace(wordRegex, (word) => {
@@ -19630,7 +19597,6 @@ stores.inject(MyMetaStore, storeInstance);
19630
19597
  arg("length (number)", _t("The number of characters in the text to be replaced.")),
19631
19598
  arg("new_text (string)", _t("The text which will be inserted into the original text.")),
19632
19599
  ],
19633
- returns: ["STRING"],
19634
19600
  compute: function (text, position, length, newText) {
19635
19601
  const _position = toNumber(position, this.locale);
19636
19602
  assert(() => _position >= 1, _t("The position (%s) must be greater than or equal to 1.", _position.toString()));
@@ -19650,7 +19616,6 @@ stores.inject(MyMetaStore, storeInstance);
19650
19616
  arg("text (string)", _t("The string from which the right portion will be returned.")),
19651
19617
  arg("number_of_characters (number, optional)", _t("The number of characters to return from the right side of string.")),
19652
19618
  ],
19653
- returns: ["STRING"],
19654
19619
  compute: function (text, ...args) {
19655
19620
  const _numberOfCharacters = args.length ? toNumber(args[0], this.locale) : 1;
19656
19621
  assert(() => _numberOfCharacters >= 0, _t("The number_of_characters (%s) must be positive or null.", _numberOfCharacters.toString()));
@@ -19670,7 +19635,6 @@ stores.inject(MyMetaStore, storeInstance);
19670
19635
  arg("text_to_search (string)", _t("The text to search for the first occurrence of search_for.")),
19671
19636
  arg(`starting_at (number, default=${DEFAULT_STARTING_AT})`, _t("The character within text_to_search at which to start the search.")),
19672
19637
  ],
19673
- returns: ["NUMBER"],
19674
19638
  compute: function (searchFor, textToSearch, startingAt = { value: DEFAULT_STARTING_AT }) {
19675
19639
  const _searchFor = toString(searchFor).toLowerCase();
19676
19640
  const _textToSearch = toString(textToSearch).toLowerCase();
@@ -19697,7 +19661,6 @@ stores.inject(MyMetaStore, storeInstance);
19697
19661
  arg(`remove_empty_text (boolean, default=${SPLIT_DEFAULT_REMOVE_EMPTY_TEXT})`, _t("Whether or not to remove empty text messages from the split results. The default behavior is to treat \
19698
19662
  consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.")),
19699
19663
  ],
19700
- returns: ["RANGE<STRING>"],
19701
19664
  compute: function (text, delimiter, splitByEach = { value: SPLIT_DEFAULT_SPLIT_BY_EACH }, removeEmptyText = { value: SPLIT_DEFAULT_REMOVE_EMPTY_TEXT }) {
19702
19665
  const _text = toString(text);
19703
19666
  const _delimiter = escapeRegExp(toString(delimiter));
@@ -19724,7 +19687,6 @@ stores.inject(MyMetaStore, storeInstance);
19724
19687
  arg("replace_with (string)", _t("The string that will replace search_for.")),
19725
19688
  arg("occurrence_number (number, optional)", _t("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")),
19726
19689
  ],
19727
- returns: ["NUMBER"],
19728
19690
  compute: function (textToSearch, searchFor, replaceWith, occurrenceNumber) {
19729
19691
  const _occurrenceNumber = toNumber(occurrenceNumber, this.locale);
19730
19692
  assert(() => _occurrenceNumber >= 0, _t("The occurrenceNumber (%s) must be positive or null.", _occurrenceNumber.toString()));
@@ -19754,7 +19716,6 @@ stores.inject(MyMetaStore, storeInstance);
19754
19716
  arg("text1 (string, range<string>)", _t("Any text item. This could be a string, or an array of strings in a range.")),
19755
19717
  arg("text2 (string, range<string>, repeating)", _t("Additional text item(s).")),
19756
19718
  ],
19757
- returns: ["STRING"],
19758
19719
  compute: function (delimiter, ignoreEmpty, ...textsOrArrays) {
19759
19720
  const _delimiter = toString(delimiter);
19760
19721
  const _ignoreEmpty = toBoolean(ignoreEmpty);
@@ -19771,7 +19732,6 @@ stores.inject(MyMetaStore, storeInstance);
19771
19732
  args: [
19772
19733
  arg("text (string)", _t("The text or reference to a cell containing text to be trimmed.")),
19773
19734
  ],
19774
- returns: ["STRING"],
19775
19735
  compute: function (text) {
19776
19736
  return trimContent(toString(text));
19777
19737
  },
@@ -19783,7 +19743,6 @@ stores.inject(MyMetaStore, storeInstance);
19783
19743
  const UPPER = {
19784
19744
  description: _t("Converts a specified string to uppercase."),
19785
19745
  args: [arg("text (string)", _t("The string to convert to uppercase."))],
19786
- returns: ["STRING"],
19787
19746
  compute: function (text) {
19788
19747
  return toString(text).toUpperCase();
19789
19748
  },
@@ -19798,7 +19757,6 @@ stores.inject(MyMetaStore, storeInstance);
19798
19757
  arg("number (number)", _t("The number, date or time to format.")),
19799
19758
  arg("format (string)", _t("The pattern by which to format the number, enclosed in quotation marks.")),
19800
19759
  ],
19801
- returns: ["STRING"],
19802
19760
  compute: function (number, format) {
19803
19761
  const _number = toNumber(number, this.locale);
19804
19762
  return formatValue(_number, { format: toString(format), locale: this.locale });
@@ -19839,7 +19797,6 @@ stores.inject(MyMetaStore, storeInstance);
19839
19797
  arg("url (string)", _t("The full URL of the link enclosed in quotation marks.")),
19840
19798
  arg("link_label (string, optional)", _t("The text to display in the cell, enclosed in quotation marks.")),
19841
19799
  ],
19842
- returns: ["STRING"],
19843
19800
  compute: function (url, linkLabel) {
19844
19801
  const processedUrl = toString(url).trim();
19845
19802
  const processedLabel = toString(linkLabel) || processedUrl;
@@ -19898,6 +19855,9 @@ stores.inject(MyMetaStore, storeInstance);
19898
19855
  }
19899
19856
  args[i] = arg[0][0];
19900
19857
  }
19858
+ if (!isMatrix(arg) && argDefinition.acceptMatrixOnly) {
19859
+ throw new BadExpressionError(_t("Function [[FUNCTION_NAME]] expects the parameter '%s' to be reference to a cell or range.", (i + 1).toString()));
19860
+ }
19901
19861
  }
19902
19862
  return descr.compute.apply(this, args);
19903
19863
  }
@@ -21492,12 +21452,6 @@ stores.inject(MyMetaStore, storeInstance);
21492
21452
  // detect when an argument need to be evaluated as a meta argument
21493
21453
  const isMeta = argTypes.includes("META");
21494
21454
  const hasRange = argTypes.some((t) => isRangeType(t));
21495
- const isRangeOnly = argTypes.every((t) => isRangeType(t));
21496
- if (isRangeOnly) {
21497
- if (!isRangeInput(currentArg)) {
21498
- throw new BadExpressionError(_t("Function %(function_name)s expects the parameter %(arg_index)s to be a reference to a cell or a range.", { function_name: functionName, arg_index: i + 1 }));
21499
- }
21500
- }
21501
21455
  compiledArgs.push(compileAST(currentArg, isMeta, hasRange));
21502
21456
  }
21503
21457
  return compiledArgs;
@@ -21662,16 +21616,6 @@ stores.inject(MyMetaStore, storeInstance);
21662
21616
  function isRangeType(type) {
21663
21617
  return type.startsWith("RANGE");
21664
21618
  }
21665
- function isRangeInput(arg) {
21666
- if (arg.type === "REFERENCE") {
21667
- return true;
21668
- }
21669
- if (arg.type === "FUNCALL") {
21670
- const fnDef = functions$1[arg.value.toUpperCase()];
21671
- return fnDef && isRangeType(fnDef.returns[0]);
21672
- }
21673
- return false;
21674
- }
21675
21619
 
21676
21620
  const functions = functionRegistry.content;
21677
21621
  function isExportableToExcel(tokens) {
@@ -21715,11 +21659,14 @@ stores.inject(MyMetaStore, storeInstance);
21715
21659
  function makeFieldProposal(field, granularity) {
21716
21660
  const groupBy = granularity ? `${field.name}:${granularity}` : field.name;
21717
21661
  const quotedGroupBy = `"${groupBy}"`;
21662
+ const fuzzySearchKey = field.string !== field.name
21663
+ ? field.string + quotedGroupBy // search on translated name and on technical name
21664
+ : quotedGroupBy;
21718
21665
  return {
21719
21666
  text: quotedGroupBy,
21720
21667
  description: field.string + (field.help ? ` (${field.help})` : ""),
21721
21668
  htmlContent: [{ value: quotedGroupBy, color: tokenColors.STRING }],
21722
- fuzzySearchKey: field.string + quotedGroupBy, // search on translated name and on technical name
21669
+ fuzzySearchKey,
21723
21670
  };
21724
21671
  }
21725
21672
  /**
@@ -21779,6 +21726,14 @@ stores.inject(MyMetaStore, storeInstance);
21779
21726
  return getFunctionsFromTokens(tokens, PIVOT_FUNCTIONS).length;
21780
21727
  }
21781
21728
 
21729
+ /**
21730
+ * Registry to enable or disable the support of positional arguments
21731
+ * (with a leading #) in pivot functions
21732
+ * e.g. =PIVOT.VALUE(1,"probability","#stage",1)
21733
+ */
21734
+ const supportedPivotPositionalFormulaRegistry = new Registry();
21735
+ supportedPivotPositionalFormulaRegistry.add("SPREADSHEET", false);
21736
+
21782
21737
  autoCompleteProviders.add("pivot_ids", {
21783
21738
  sequence: 50,
21784
21739
  autoSelectFirstProposal: true,
@@ -21797,10 +21752,6 @@ stores.inject(MyMetaStore, storeInstance);
21797
21752
  return pivotIds
21798
21753
  .map((pivotId) => {
21799
21754
  const definition = this.getters.getPivotCoreDefinition(pivotId);
21800
- if (functionContext.parent.toUpperCase() !== "PIVOT" &&
21801
- !supportedPivotExplodedFormulaRegistry.get(definition.type)) {
21802
- return undefined;
21803
- }
21804
21755
  const formulaId = this.getters.getPivotFormulaId(pivotId);
21805
21756
  const str = `${formulaId}`;
21806
21757
  return {
@@ -21828,15 +21779,13 @@ stores.inject(MyMetaStore, storeInstance);
21828
21779
  if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
21829
21780
  return [];
21830
21781
  }
21831
- const dataSource = this.getters.getPivot(pivotId);
21832
- const fields = dataSource.getFields();
21782
+ const pivot = this.getters.getPivot(pivotId);
21783
+ pivot.init();
21784
+ const fields = pivot.getFields();
21833
21785
  if (!fields) {
21834
21786
  return [];
21835
21787
  }
21836
21788
  const definition = this.getters.getPivotCoreDefinition(pivotId);
21837
- if (!supportedPivotExplodedFormulaRegistry.get(definition.type)) {
21838
- return [];
21839
- }
21840
21789
  return definition.measures
21841
21790
  .map((measure) => {
21842
21791
  if (measure.name === "__count") {
@@ -21872,16 +21821,13 @@ stores.inject(MyMetaStore, storeInstance);
21872
21821
  if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
21873
21822
  return;
21874
21823
  }
21875
- const dataSource = this.getters.getPivot(pivotId);
21876
- const fields = dataSource.getFields();
21824
+ const pivot = this.getters.getPivot(pivotId);
21825
+ pivot.init();
21826
+ const fields = pivot.getFields();
21877
21827
  if (!fields) {
21878
21828
  return;
21879
21829
  }
21880
- const { type } = this.getters.getPivotCoreDefinition(pivotId);
21881
- const { columns, rows } = dataSource.definition;
21882
- if (!supportedPivotExplodedFormulaRegistry.get(type)) {
21883
- return [];
21884
- }
21830
+ const { columns, rows } = pivot.definition;
21885
21831
  let args = functionContext.args;
21886
21832
  if (functionContext?.parent.toUpperCase() === "PIVOT.VALUE") {
21887
21833
  args = args.filter((ast, index) => index % 2 === 0); // keep only the field names
@@ -21918,6 +21864,9 @@ stores.inject(MyMetaStore, storeInstance);
21918
21864
  return field ? makeFieldProposal(field, granularity) : undefined;
21919
21865
  })
21920
21866
  .concat(groupBys.map((groupBy) => {
21867
+ if (!supportedPivotPositionalFormulaRegistry.get(pivot.type)) {
21868
+ return undefined;
21869
+ }
21921
21870
  const fieldName = groupBy.split(":")[0];
21922
21871
  const field = fields[fieldName];
21923
21872
  if (!field) {
@@ -21966,12 +21915,8 @@ stores.inject(MyMetaStore, storeInstance);
21966
21915
  if (!pivotId || !this.getters.isExistingPivot(pivotId)) {
21967
21916
  return;
21968
21917
  }
21969
- const { type } = this.getters.getPivotCoreDefinition(pivotId);
21970
- if (!supportedPivotExplodedFormulaRegistry.get(type)) {
21971
- return [];
21972
- }
21973
- const dataSource = this.getters.getPivot(pivotId);
21974
- if (!dataSource.isValid()) {
21918
+ const pivot = this.getters.getPivot(pivotId);
21919
+ if (!pivot.isValid()) {
21975
21920
  return;
21976
21921
  }
21977
21922
  const argPosition = functionContext.argPosition;
@@ -21979,7 +21924,46 @@ stores.inject(MyMetaStore, storeInstance);
21979
21924
  if (!groupByField) {
21980
21925
  return;
21981
21926
  }
21982
- return dataSource.getPossibleFieldValues(groupByField.split(":")[0]).map(({ value, label }) => {
21927
+ let dimension;
21928
+ try {
21929
+ dimension = pivot.definition.getDimension(groupByField);
21930
+ }
21931
+ catch (error) {
21932
+ return undefined;
21933
+ }
21934
+ if (dimension.granularity === "month_number") {
21935
+ return Object.values(MONTHS).map((monthDisplayName, index) => ({
21936
+ text: `${index + 1}`,
21937
+ fuzzySearchKey: monthDisplayName.toString(),
21938
+ description: monthDisplayName.toString(),
21939
+ htmlContent: [{ value: `${index + 1}`, color: tokenColors.NUMBER }],
21940
+ }));
21941
+ }
21942
+ else if (dimension.granularity === "quarter_number") {
21943
+ return [1, 2, 3, 4].map((quarter) => ({
21944
+ text: `${quarter}`,
21945
+ fuzzySearchKey: `${quarter}`,
21946
+ description: _t("Quarter %s", quarter),
21947
+ htmlContent: [{ value: `${quarter}`, color: tokenColors.NUMBER }],
21948
+ }));
21949
+ }
21950
+ else if (dimension.granularity === "day_of_month") {
21951
+ return range(1, 32).map((dayOfMonth) => ({
21952
+ text: `${dayOfMonth}`,
21953
+ fuzzySearchKey: `${dayOfMonth}`,
21954
+ description: "",
21955
+ htmlContent: [{ value: `${dayOfMonth}`, color: tokenColors.NUMBER }],
21956
+ }));
21957
+ }
21958
+ else if (dimension.granularity === "iso_week_number") {
21959
+ return range(0, 54).map((isoWeekNumber) => ({
21960
+ text: `${isoWeekNumber}`,
21961
+ fuzzySearchKey: `${isoWeekNumber}`,
21962
+ description: "",
21963
+ htmlContent: [{ value: `${isoWeekNumber}`, color: tokenColors.NUMBER }],
21964
+ }));
21965
+ }
21966
+ return pivot.getPossibleFieldValues(dimension).map(({ value, label }) => {
21983
21967
  const isString = typeof value === "string";
21984
21968
  const text = isString ? `"${value}"` : value.toString();
21985
21969
  const color = isString ? tokenColors.STRING : tokenColors.NUMBER;
@@ -22086,7 +22070,9 @@ stores.inject(MyMetaStore, storeInstance);
22086
22070
  tooltip: content
22087
22071
  ? {
22088
22072
  props: {
22089
- content: evaluateLiteral(data.cell?.content, localeFormat).formattedValue,
22073
+ content: data.cell
22074
+ ? evaluateLiteral(data.cell, localeFormat).formattedValue
22075
+ : "",
22090
22076
  },
22091
22077
  }
22092
22078
  : undefined,
@@ -22149,9 +22135,7 @@ stores.inject(MyMetaStore, storeInstance);
22149
22135
  if (x === cell) {
22150
22136
  found = true;
22151
22137
  }
22152
- const cellValue = x?.isFormula
22153
- ? undefined
22154
- : evaluateLiteral(x?.content, { locale: DEFAULT_LOCALE });
22138
+ const cellValue = x === undefined || x.isFormula ? undefined : evaluateLiteral(x, { locale: DEFAULT_LOCALE });
22155
22139
  if (cellValue && filter(cellValue)) {
22156
22140
  group.push(cellValue);
22157
22141
  }
@@ -22199,7 +22183,7 @@ stores.inject(MyMetaStore, storeInstance);
22199
22183
  })
22200
22184
  .add("increment_alphanumeric_value", {
22201
22185
  condition: (cell) => !cell.isFormula &&
22202
- evaluateLiteral(cell.content, { locale: DEFAULT_LOCALE }).type === CellValueType.text &&
22186
+ evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text &&
22203
22187
  alphaNumericValueRegExp.test(cell.content),
22204
22188
  generateRule: (cell, cells) => {
22205
22189
  const numberPostfix = parseInt(cell.content.match(numberPostfixRegExp)[0]);
@@ -22222,7 +22206,7 @@ stores.inject(MyMetaStore, storeInstance);
22222
22206
  })
22223
22207
  .add("copy_text", {
22224
22208
  condition: (cell) => !cell.isFormula &&
22225
- evaluateLiteral(cell.content, { locale: DEFAULT_LOCALE }).type === CellValueType.text,
22209
+ evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.text,
22226
22210
  generateRule: () => {
22227
22211
  return { type: "COPY_MODIFIER" };
22228
22212
  },
@@ -22237,11 +22221,11 @@ stores.inject(MyMetaStore, storeInstance);
22237
22221
  })
22238
22222
  .add("increment_number", {
22239
22223
  condition: (cell) => !cell.isFormula &&
22240
- evaluateLiteral(cell.content, { locale: DEFAULT_LOCALE }).type === CellValueType.number,
22224
+ evaluateLiteral(cell, { locale: DEFAULT_LOCALE }).type === CellValueType.number,
22241
22225
  generateRule: (cell, cells) => {
22242
22226
  const group = getGroup(cell, cells, (evaluatedCell) => evaluatedCell.type === CellValueType.number).map((cell) => Number(cell.value));
22243
22227
  const increment = calculateIncrementBasedOnGroup(group);
22244
- const evaluation = evaluateLiteral(cell.content, { locale: DEFAULT_LOCALE });
22228
+ const evaluation = evaluateLiteral(cell, { locale: DEFAULT_LOCALE });
22245
22229
  return {
22246
22230
  type: "INCREMENT_MODIFIER",
22247
22231
  increment,
@@ -25343,8 +25327,7 @@ stores.inject(MyMetaStore, storeInstance);
25343
25327
  */
25344
25328
  function useSpreadsheetRect() {
25345
25329
  const position = owl.useState({ x: 0, y: 0, width: 0, height: 0 });
25346
- let spreadsheetElement = document.querySelector(".o-spreadsheet");
25347
- updatePosition();
25330
+ let spreadsheetElement = null;
25348
25331
  function updatePosition() {
25349
25332
  if (!spreadsheetElement) {
25350
25333
  spreadsheetElement = document.querySelector(".o-spreadsheet");
@@ -25466,7 +25449,7 @@ stores.inject(MyMetaStore, storeInstance);
25466
25449
  if (!anchor)
25467
25450
  return;
25468
25451
  const propsMaxSize = { width: this.props.maxWidth, height: this.props.maxHeight };
25469
- const elDims = {
25452
+ let elDims = {
25470
25453
  width: el.getBoundingClientRect().width,
25471
25454
  height: el.getBoundingClientRect().height,
25472
25455
  };
@@ -25474,7 +25457,14 @@ stores.inject(MyMetaStore, storeInstance);
25474
25457
  const popoverPositionHelper = this.props.positioning === "BottomLeft"
25475
25458
  ? new BottomLeftPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect)
25476
25459
  : new TopRightPopoverContext(anchor, this.containerRect, propsMaxSize, spreadsheetRect);
25477
- const style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
25460
+ el.style["max-height"] = popoverPositionHelper.getMaxHeight(elDims.height) + "px";
25461
+ el.style["max-width"] = popoverPositionHelper.getMaxWidth(elDims.width) + "px";
25462
+ // Re-compute the dimensions after setting the max-width and max-height
25463
+ elDims = {
25464
+ width: el.getBoundingClientRect().width,
25465
+ height: el.getBoundingClientRect().height,
25466
+ };
25467
+ let style = popoverPositionHelper.getCss(elDims, this.props.verticalOffset);
25478
25468
  for (const property of Object.keys(style)) {
25479
25469
  el.style[property] = style[property];
25480
25470
  }
@@ -25537,8 +25527,6 @@ stores.inject(MyMetaStore, storeInstance);
25537
25527
  const shouldRenderAtRight = this.shouldRenderAtRight(elDims.width);
25538
25528
  verticalOffset = shouldRenderAtBottom ? verticalOffset : -verticalOffset;
25539
25529
  const cssProperties = {
25540
- "max-height": maxHeight + "px",
25541
- "max-width": maxWidth + "px",
25542
25530
  top: this.getTopCoordinate(actualHeight, shouldRenderAtBottom) -
25543
25531
  this.spreadsheetOffset.y -
25544
25532
  verticalOffset +
@@ -31352,10 +31340,8 @@ stores.inject(MyMetaStore, storeInstance);
31352
31340
 
31353
31341
  class AxisDesignEditor extends owl.Component {
31354
31342
  static template = "o-spreadsheet-AxisDesignEditor";
31355
- static components = {
31356
- Section,
31357
- ChartTitle,
31358
- };
31343
+ static components = { Section, ChartTitle };
31344
+ static props = { figureId: String, definition: Object, updateChart: Function, axesList: Array };
31359
31345
  state = owl.useState({ currentAxis: "x" });
31360
31346
  get axisTitleStyle() {
31361
31347
  const axisDesign = this.props.definition.axesDesign?.[this.state.currentAxis] ?? {};
@@ -31506,6 +31492,12 @@ stores.inject(MyMetaStore, storeInstance);
31506
31492
  AxisDesignEditor,
31507
31493
  RoundColorPicker,
31508
31494
  };
31495
+ static props = {
31496
+ figureId: String,
31497
+ definition: Object,
31498
+ canUpdateChart: Function,
31499
+ updateChart: Function,
31500
+ };
31509
31501
  state = owl.useState({ index: 0 });
31510
31502
  get axesList() {
31511
31503
  const { useLeftAxis, useRightAxis } = getDefinedAxis(this.props.definition);
@@ -33450,13 +33442,17 @@ stores.inject(MyMetaStore, storeInstance);
33450
33442
  class: { type: String, optional: true },
33451
33443
  };
33452
33444
  static components = { Menu };
33445
+ menuId = new UuidGenerator().uuidv4();
33453
33446
  selectRef = owl.useRef("select");
33454
33447
  selectRect = useAbsoluteBoundingRect(this.selectRef);
33455
33448
  state = owl.useState({
33456
33449
  isMenuOpen: false,
33457
33450
  });
33458
- onClick() {
33459
- this.state.isMenuOpen = true;
33451
+ onClick(ev) {
33452
+ if (ev.closedMenuId === this.menuId) {
33453
+ return;
33454
+ }
33455
+ this.state.isMenuOpen = !this.state.isMenuOpen;
33460
33456
  }
33461
33457
  onMenuClosed() {
33462
33458
  this.state.isMenuOpen = false;
@@ -33464,7 +33460,7 @@ stores.inject(MyMetaStore, storeInstance);
33464
33460
  get menuPosition() {
33465
33461
  return {
33466
33462
  x: this.selectRect.x,
33467
- y: this.selectRect.y,
33463
+ y: this.selectRect.y + this.selectRect.height,
33468
33464
  };
33469
33465
  }
33470
33466
  }
@@ -34404,9 +34400,9 @@ stores.inject(MyMetaStore, storeInstance);
34404
34400
  static props = {
34405
34401
  onCloseSidePanel: Function,
34406
34402
  };
34407
- dataRange = "";
34408
34403
  searchInput = owl.useRef("searchInput");
34409
34404
  store;
34405
+ state;
34410
34406
  get hasSearchResult() {
34411
34407
  return this.store.selectedMatchIndex !== null;
34412
34408
  }
@@ -34436,6 +34432,7 @@ stores.inject(MyMetaStore, storeInstance);
34436
34432
  }
34437
34433
  setup() {
34438
34434
  this.store = useLocalStore(FindAndReplaceStore);
34435
+ this.state = owl.useState({ dataRange: "" });
34439
34436
  owl.onMounted(() => this.searchInput.el?.focus());
34440
34437
  }
34441
34438
  onFocusSearch() {
@@ -34472,13 +34469,13 @@ stores.inject(MyMetaStore, storeInstance);
34472
34469
  this.store.updateSearchOptions({ searchScope });
34473
34470
  }
34474
34471
  onSearchRangeChanged(ranges) {
34475
- this.dataRange = ranges[0];
34472
+ this.state.dataRange = ranges[0];
34476
34473
  }
34477
34474
  updateDataRange() {
34478
- if (!this.dataRange || this.searchOptions.searchScope !== "specificRange") {
34475
+ if (!this.state.dataRange || this.searchOptions.searchScope !== "specificRange") {
34479
34476
  return;
34480
34477
  }
34481
- const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.dataRange);
34478
+ const specificRange = this.env.model.getters.getRangeFromSheetXC(this.env.model.getters.getActiveSheetId(), this.state.dataRange);
34482
34479
  this.store.updateSearchOptions({ specificRange });
34483
34480
  }
34484
34481
  }
@@ -34523,28 +34520,30 @@ stores.inject(MyMetaStore, storeInstance);
34523
34520
  }
34524
34521
  }
34525
34522
 
34526
- /** @odoo-module */
34527
- class EditableName extends owl.Component {
34528
- static template = "o-spreadsheet-EditableName";
34523
+ css /* scss */ `
34524
+ .pivot-defer-update {
34525
+ min-height: 35px;
34526
+ background-color: #f8f9fa;
34527
+ }
34528
+ `;
34529
+ class PivotDeferUpdate extends owl.Component {
34530
+ static template = "o-spreadsheet-PivotDeferUpdate";
34529
34531
  static props = {
34530
- name: String,
34531
- displayName: String,
34532
- onChanged: Function,
34532
+ deferUpdate: Boolean,
34533
+ isDirty: Boolean,
34534
+ toggleDeferUpdate: Function,
34535
+ discard: Function,
34536
+ apply: Function,
34533
34537
  };
34534
- state;
34535
- setup() {
34536
- this.state = owl.useState({
34537
- isEditing: false,
34538
- name: "",
34539
- });
34540
- }
34541
- rename() {
34542
- this.state.isEditing = true;
34543
- this.state.name = this.props.name;
34538
+ static components = {
34539
+ Section,
34540
+ Checkbox,
34541
+ };
34542
+ get deferUpdatesLabel() {
34543
+ return _t("Defer updates");
34544
34544
  }
34545
- save() {
34546
- this.props.onChanged(this.state.name.trim());
34547
- this.state.isEditing = false;
34545
+ get deferUpdatesTooltip() {
34546
+ return _t("Changing the pivot definition requires to reload the data. It may take some time.");
34548
34547
  }
34549
34548
  }
34550
34549
 
@@ -34886,6 +34885,135 @@ stores.inject(MyMetaStore, storeInstance);
34886
34885
  }
34887
34886
  }
34888
34887
 
34888
+ css /* scss */ `
34889
+ .os-cog-wheel-menu-icon {
34890
+ cursor: pointer;
34891
+ }
34892
+
34893
+ .os-cog-wheel-menu {
34894
+ background: white;
34895
+ .btn-link {
34896
+ text-decoration: none;
34897
+ color: #017e84;
34898
+ font-weight: 500;
34899
+ &:hover {
34900
+ color: #01585c;
34901
+ }
34902
+ }
34903
+ }
34904
+ `;
34905
+ class CogWheelMenu extends owl.Component {
34906
+ static template = "o-spreadsheet-CogWheelMenu";
34907
+ static components = { Popover };
34908
+ static props = {
34909
+ items: Array,
34910
+ };
34911
+ buttonRef = owl.useRef("button");
34912
+ popover = owl.useState({ isOpen: false });
34913
+ setup() {
34914
+ owl.useExternalListener(window, "click", (ev) => {
34915
+ if (ev.target !== this.buttonRef.el) {
34916
+ this.popover.isOpen = false;
34917
+ }
34918
+ });
34919
+ }
34920
+ get popoverProps() {
34921
+ const { x, y, width, height } = this.buttonRef.el.getBoundingClientRect();
34922
+ return {
34923
+ anchorRect: { x, y, width, height },
34924
+ positioning: "BottomLeft",
34925
+ };
34926
+ }
34927
+ togglePopover() {
34928
+ this.popover.isOpen = !this.popover.isOpen;
34929
+ }
34930
+ }
34931
+
34932
+ /** @odoo-module */
34933
+ class EditableName extends owl.Component {
34934
+ static template = "o-spreadsheet-EditableName";
34935
+ static props = {
34936
+ name: String,
34937
+ displayName: String,
34938
+ onChanged: Function,
34939
+ };
34940
+ state;
34941
+ setup() {
34942
+ this.state = owl.useState({
34943
+ isEditing: false,
34944
+ name: "",
34945
+ });
34946
+ }
34947
+ rename() {
34948
+ this.state.isEditing = true;
34949
+ this.state.name = this.props.name;
34950
+ }
34951
+ save() {
34952
+ this.props.onChanged(this.state.name.trim());
34953
+ this.state.isEditing = false;
34954
+ }
34955
+ }
34956
+
34957
+ class PivotTitleSection extends owl.Component {
34958
+ static template = "o-spreadsheet-PivotTitleSection";
34959
+ static components = { CogWheelMenu, Section, EditableName };
34960
+ static props = {
34961
+ pivotId: String,
34962
+ };
34963
+ get cogWheelMenuItems() {
34964
+ return [
34965
+ {
34966
+ name: "Duplicate",
34967
+ icon: "fa-copy",
34968
+ onClick: () => this.duplicatePivot(),
34969
+ },
34970
+ {
34971
+ name: "Delete",
34972
+ icon: "fa-trash",
34973
+ onClick: () => this.delete(),
34974
+ },
34975
+ ];
34976
+ }
34977
+ get name() {
34978
+ return this.env.model.getters.getPivotName(this.props.pivotId);
34979
+ }
34980
+ get displayName() {
34981
+ return this.env.model.getters.getPivotDisplayName(this.props.pivotId);
34982
+ }
34983
+ duplicatePivot() {
34984
+ const newPivotId = this.env.model.uuidGenerator.uuidv4();
34985
+ const result = this.env.model.dispatch("DUPLICATE_PIVOT", {
34986
+ pivotId: this.props.pivotId,
34987
+ newPivotId,
34988
+ });
34989
+ const text = result.isSuccessful ? _t("Pivot duplicated.") : _t("Pivot duplication failed");
34990
+ const type = result.isSuccessful ? "success" : "danger";
34991
+ this.env.notifyUser({
34992
+ text,
34993
+ sticky: false,
34994
+ type,
34995
+ });
34996
+ if (result.isSuccessful) {
34997
+ this.env.openSidePanel("PivotSidePanel", { pivotId: newPivotId });
34998
+ }
34999
+ }
35000
+ delete() {
35001
+ this.env.askConfirmation(_t("Are you sure you want to delete this pivot?"), () => {
35002
+ this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
35003
+ });
35004
+ }
35005
+ onNameChanged(name) {
35006
+ const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
35007
+ this.env.model.dispatch("UPDATE_PIVOT", {
35008
+ pivotId: this.props.pivotId,
35009
+ pivot: {
35010
+ ...pivot,
35011
+ name,
35012
+ },
35013
+ });
35014
+ }
35015
+ }
35016
+
34889
35017
  /**
34890
35018
  * Represent a pivot runtime definition. A pivot runtime definition is a pivot
34891
35019
  * definition that has been enriched to include the display name of its attributes
@@ -35190,7 +35318,7 @@ stores.inject(MyMetaStore, storeInstance);
35190
35318
  }
35191
35319
  const row = rows[index];
35192
35320
  const rowName = row.nameWithGranularity;
35193
- const groups = groupBy(dataEntries, row);
35321
+ const groups = groupPivotDataEntriesBy(dataEntries, row);
35194
35322
  const orderedKeys = orderDataEntriesKeys(groups, row);
35195
35323
  const pivotTableRows = [];
35196
35324
  const _fields = fields.concat(rowName);
@@ -35220,7 +35348,7 @@ stores.inject(MyMetaStore, storeInstance);
35220
35348
  }
35221
35349
  const column = columns[index];
35222
35350
  const colName = columns[index].nameWithGranularity;
35223
- const groups = groupBy(dataEntries, column);
35351
+ const groups = groupPivotDataEntriesBy(dataEntries, column);
35224
35352
  const orderedKeys = orderDataEntriesKeys(groups, columns[index]);
35225
35353
  return orderedKeys.map((value) => {
35226
35354
  return {
@@ -35318,7 +35446,7 @@ stores.inject(MyMetaStore, storeInstance);
35318
35446
  /**
35319
35447
  * Group the dataEntries based on the given dimension
35320
35448
  */
35321
- function groupBy(dataEntries, dimension) {
35449
+ function groupPivotDataEntriesBy(dataEntries, dimension) {
35322
35450
  return Object.groupBy(dataEntries, keySelector(dimension));
35323
35451
  }
35324
35452
  /**
@@ -35368,7 +35496,7 @@ stores.inject(MyMetaStore, storeInstance);
35368
35496
  number = Math.floor(date.getMonth() / 3) + 1;
35369
35497
  break;
35370
35498
  case "month_number":
35371
- number = date.getMonth();
35499
+ number = date.getMonth() + 1;
35372
35500
  break;
35373
35501
  case "iso_week_number":
35374
35502
  number = date.getIsoWeek();
@@ -35380,7 +35508,7 @@ stores.inject(MyMetaStore, storeInstance);
35380
35508
  number = Math.floor(toNumber(value, locale));
35381
35509
  break;
35382
35510
  }
35383
- MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = number;
35511
+ MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`] = toNormalizedPivotValue(dimension, number);
35384
35512
  }
35385
35513
  return MAP_VALUE_DIMENSION_DATE[granularity].values[`${value}`];
35386
35514
  }
@@ -35526,7 +35654,7 @@ stores.inject(MyMetaStore, storeInstance);
35526
35654
  return this._definition;
35527
35655
  }
35528
35656
  isValid() {
35529
- if (this.invalidRangeError || !this._definition) {
35657
+ if (this.invalidRangeError || !this.definition) {
35530
35658
  return false;
35531
35659
  }
35532
35660
  for (const measure of this.definition.measures) {
@@ -35583,25 +35711,19 @@ stores.inject(MyMetaStore, storeInstance);
35583
35711
  const dimension = this.getDimension(lastNode.field);
35584
35712
  const cells = this.filterDataEntriesFromDomain(this.dataEntries, domain);
35585
35713
  const finalCell = cells[0]?.[dimension.nameWithGranularity];
35714
+ if (dimension.type === "date") {
35715
+ const adapter = pivotTimeAdapter(dimension.granularity);
35716
+ return {
35717
+ value: adapter.toCellValue(toNormalizedPivotValue(dimension, lastNode.value)),
35718
+ format: adapter.getFormat(this.getters.getLocale()),
35719
+ };
35720
+ }
35586
35721
  if (!finalCell) {
35587
35722
  return { value: "" };
35588
35723
  }
35589
35724
  if (finalCell.value === null) {
35590
35725
  return { value: _t("(Undefined)") };
35591
35726
  }
35592
- if (dimension.type === "date") {
35593
- if (dimension.granularity === "day") {
35594
- return {
35595
- value: toNumber(finalCell.value, this.getters.getLocale()),
35596
- format: this.getters.getLocale().dateFormat,
35597
- };
35598
- }
35599
- if (dimension.granularity === "month_number") {
35600
- return {
35601
- value: MONTHS[toNumber(finalCell.value, this.getters.getLocale())].toString(),
35602
- };
35603
- }
35604
- }
35605
35727
  return {
35606
35728
  value: finalCell.value,
35607
35729
  format: finalCell.format,
@@ -35626,9 +35748,12 @@ stores.inject(MyMetaStore, storeInstance);
35626
35748
  format: operator.format(values[0]),
35627
35749
  };
35628
35750
  }
35629
- getPossibleFieldValues(groupBy) {
35630
- //TODO This method should be implemented for the autocomplete feature
35631
- throw new Error("Method not implemented.");
35751
+ getPossibleFieldValues(dimension) {
35752
+ const values = [];
35753
+ for (const value in groupPivotDataEntriesBy(this.dataEntries, dimension)) {
35754
+ values.push({ value, label: "" });
35755
+ }
35756
+ return values;
35632
35757
  }
35633
35758
  getTableStructure() {
35634
35759
  if (!this.isValid()) {
@@ -35648,7 +35773,8 @@ stores.inject(MyMetaStore, storeInstance);
35648
35773
  filterDataEntriesFromDomainNode(dataEntries, domain) {
35649
35774
  const { field, value } = domain;
35650
35775
  const dimension = this.getDimension(field);
35651
- return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` === value);
35776
+ return dataEntries.filter((entry) => `${entry[dimension.nameWithGranularity]?.value}` ===
35777
+ `${toNormalizedPivotValue(dimension, value)}`);
35652
35778
  }
35653
35779
  getDimension(nameWithGranularity) {
35654
35780
  return this.definition.getDimension(nameWithGranularity);
@@ -35784,15 +35910,8 @@ stores.inject(MyMetaStore, storeInstance);
35784
35910
 
35785
35911
  class PivotSidePanelStore extends SpreadsheetStore {
35786
35912
  pivotId;
35787
- mutators = [
35788
- "reset",
35789
- "deferUpdates",
35790
- "applyUpdate",
35791
- "discardPendingUpdate",
35792
- "renamePivot",
35793
- "update",
35794
- ];
35795
- updatesAreDeferred = true;
35913
+ mutators = ["reset", "deferUpdates", "applyUpdate", "discardPendingUpdate", "update"];
35914
+ updatesAreDeferred = false;
35796
35915
  draft = null;
35797
35916
  constructor(get, pivotId) {
35798
35917
  super(get);
@@ -35909,16 +36028,6 @@ stores.inject(MyMetaStore, storeInstance);
35909
36028
  discardPendingUpdate() {
35910
36029
  this.draft = null;
35911
36030
  }
35912
- renamePivot(name) {
35913
- const pivot = this.getters.getPivotCoreDefinition(this.pivotId);
35914
- this.model.dispatch("UPDATE_PIVOT", {
35915
- pivotId: this.pivotId,
35916
- pivot: {
35917
- ...pivot,
35918
- name,
35919
- },
35920
- });
35921
- }
35922
36031
  update(definitionUpdate) {
35923
36032
  const coreDefinition = this.getters.getPivotCoreDefinition(this.pivotId);
35924
36033
  const definition = { ...coreDefinition, ...this.draft, ...definitionUpdate };
@@ -36001,8 +36110,9 @@ stores.inject(MyMetaStore, storeInstance);
36001
36110
  PivotLayoutConfigurator,
36002
36111
  Section,
36003
36112
  SelectionInput,
36004
- EditableName,
36005
36113
  Checkbox,
36114
+ PivotDeferUpdate,
36115
+ PivotTitleSection,
36006
36116
  };
36007
36117
  store;
36008
36118
  state;
@@ -36031,21 +36141,9 @@ stores.inject(MyMetaStore, storeInstance);
36031
36141
  get pivot() {
36032
36142
  return this.store.pivot;
36033
36143
  }
36034
- get name() {
36035
- return this.env.model.getters.getPivotName(this.props.pivotId);
36036
- }
36037
- get displayName() {
36038
- return this.env.model.getters.getPivotDisplayName(this.props.pivotId);
36039
- }
36040
36144
  get definition() {
36041
36145
  return this.store.definition;
36042
36146
  }
36043
- get deferUpdatesLabel() {
36044
- return _t("Defer updates");
36045
- }
36046
- get deferUpdatesTooltip() {
36047
- return _t("Changing the pivot definition requires to reload the data. It may take some time.");
36048
- }
36049
36147
  onSelectionChanged(ranges) {
36050
36148
  this.state.rangeHasChanged = true;
36051
36149
  this.state.range = ranges[0];
@@ -36066,35 +36164,9 @@ stores.inject(MyMetaStore, storeInstance);
36066
36164
  this.store.applyUpdate();
36067
36165
  }
36068
36166
  }
36069
- duplicatePivot() {
36070
- const newPivotId = this.env.model.uuidGenerator.uuidv4();
36071
- const result = this.env.model.dispatch("DUPLICATE_PIVOT", {
36072
- pivotId: this.props.pivotId,
36073
- newPivotId,
36074
- });
36075
- const text = result.isSuccessful ? _t("Pivot duplicated.") : _t("Pivot duplication failed");
36076
- const type = result.isSuccessful ? "success" : "danger";
36077
- this.env.notifyUser({
36078
- text,
36079
- sticky: false,
36080
- type,
36081
- });
36082
- if (result.isSuccessful) {
36083
- this.env.openSidePanel("PivotSidePanel", { pivotId: newPivotId });
36084
- }
36085
- }
36086
- onNameChanged(name) {
36087
- this.store.renamePivot(name);
36088
- }
36089
36167
  onDimensionsUpdated(definition) {
36090
36168
  this.store.update(definition);
36091
36169
  }
36092
- back() {
36093
- this.env.openSidePanel("PivotSidePanel", {});
36094
- }
36095
- delete() {
36096
- this.env.model.dispatch("REMOVE_PIVOT", { pivotId: this.props.pivotId });
36097
- }
36098
36170
  }
36099
36171
 
36100
36172
  const pivotSidePanelRegistry = new Registry();
@@ -36102,44 +36174,17 @@ stores.inject(MyMetaStore, storeInstance);
36102
36174
  editor: PivotSpreadsheetSidePanel,
36103
36175
  });
36104
36176
 
36105
- css /* scss */ `
36106
- .o_pivot_list_item {
36107
- cursor: pointer;
36108
- &:hover {
36109
- background-color: #f1f3f4;
36110
- }
36111
- }
36112
- `;
36113
- class PivotListItem extends owl.Component {
36114
- static template = "o-spreadsheet-PivotListItem";
36115
- static props = { pivotId: String };
36116
- setup() {
36117
- const previewRef = owl.useRef("pivotListItem");
36118
- useHighlightsOnHover(previewRef, this);
36119
- }
36120
- selectPivot() {
36121
- this.env.openSidePanel("PivotSidePanel", { pivotId: this.props.pivotId });
36122
- }
36123
- get highlights() {
36124
- return getPivotHighlights(this.env.model.getters, this.props.pivotId);
36125
- }
36126
- }
36127
-
36128
36177
  class PivotSidePanel extends owl.Component {
36129
36178
  static template = "o-spreadsheet-PivotSidePanel";
36130
36179
  static props = {
36131
- pivotId: { type: String, optional: true },
36180
+ pivotId: String,
36132
36181
  onCloseSidePanel: Function,
36133
36182
  };
36134
36183
  static components = {
36135
36184
  PivotLayoutConfigurator,
36136
36185
  Section,
36137
- PivotListItem,
36138
36186
  };
36139
36187
  get sidePanelEditor() {
36140
- if (!this.props.pivotId) {
36141
- throw new Error("pivotId is required to call this function.");
36142
- }
36143
36188
  const pivot = this.env.model.getters.getPivotCoreDefinition(this.props.pivotId);
36144
36189
  if (!pivot) {
36145
36190
  throw new Error("pivotId does not correspond to a pivot.");
@@ -36156,6 +36201,7 @@ stores.inject(MyMetaStore, storeInstance);
36156
36201
  class RemoveDuplicatesPanel extends owl.Component {
36157
36202
  static template = "o-spreadsheet-RemoveDuplicatesPanel";
36158
36203
  static components = { ValidationMessages, Section, Checkbox };
36204
+ static props = { onCloseSidePanel: Function };
36159
36205
  state = owl.useState({
36160
36206
  hasHeader: false,
36161
36207
  columns: {},
@@ -37298,21 +37344,15 @@ stores.inject(MyMetaStore, storeInstance);
37298
37344
  });
37299
37345
  sidePanelRegistry.add("PivotSidePanel", {
37300
37346
  title: (env, props) => {
37301
- if (props.pivotId) {
37302
- return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
37303
- }
37304
- return _t("List of Pivots");
37347
+ return _t("Pivot #%s", env.model.getters.getPivotFormulaId(props.pivotId));
37305
37348
  },
37306
37349
  Body: PivotSidePanel,
37307
- computeState: (getters, initialProps) => {
37308
- if (!getters.getPivotIds().length) {
37309
- return { isOpen: false };
37310
- }
37311
- let { pivotId } = initialProps;
37312
- if (pivotId && !getters.isExistingPivot(pivotId)) {
37313
- pivotId = undefined;
37314
- }
37315
- return { isOpen: true, props: { pivotId }, key: `pivot_key_${pivotId}` };
37350
+ computeState: (getters, props) => {
37351
+ return {
37352
+ isOpen: getters.isExistingPivot(props.pivotId),
37353
+ props,
37354
+ key: `pivot_key_${props.pivotId}`,
37355
+ };
37316
37356
  },
37317
37357
  });
37318
37358
 
@@ -41570,133 +41610,6 @@ stores.inject(MyMetaStore, storeInstance);
41570
41610
  }
41571
41611
  }
41572
41612
 
41573
- const pivotTimeAdapterRegistry = new Registry();
41574
- function pivotTimeAdapter(granularity) {
41575
- return pivotTimeAdapterRegistry.get(granularity);
41576
- }
41577
- /**
41578
- * The Time Adapter: Managing Time Periods for Pivot Functions
41579
- *
41580
- * Overview:
41581
- * A time adapter is responsible for managing time periods associated with pivot functions.
41582
- * Each type of period (day, week, month, quarter, etc.) has its own dedicated adapter.
41583
- * The adapter's primary role is to normalize period values between spreadsheet functions,
41584
- * and the pivot.
41585
- * By normalizing the period value, it can be stored consistently in the pivot.
41586
- *
41587
- * Normalization Process:
41588
- * When working with functions in the spreadsheet, the time adapter normalizes
41589
- * the provided period to facilitate accurate lookup of values in the pivot.
41590
- * For instance, if the spreadsheet function represents a day period as a number generated
41591
- * by the DATE function (DATE(2023, 12, 25)), the time adapter will normalize it accordingly.
41592
- *
41593
- */
41594
- /**
41595
- * Normalized value: "12/25/2023"
41596
- *
41597
- * Note: Those two format are equivalent:
41598
- * - "MM/dd/yyyy" (luxon format)
41599
- * - "mm/dd/yyyy" (spreadsheet format)
41600
- **/
41601
- const dayAdapter = {
41602
- normalizeFunctionValue(value) {
41603
- const date = toNumber(value, DEFAULT_LOCALE);
41604
- return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/dd/yyyy" });
41605
- },
41606
- getFormat(locale) {
41607
- return (locale ?? DEFAULT_LOCALE).dateFormat;
41608
- },
41609
- formatValue(normalizedValue, locale) {
41610
- locale = locale ?? DEFAULT_LOCALE;
41611
- const value = toNumber(normalizedValue, DEFAULT_LOCALE);
41612
- return formatValue(value, { locale, format: this.getFormat(locale) });
41613
- },
41614
- toCellValue(normalizedValue) {
41615
- return toNumber(normalizedValue, DEFAULT_LOCALE);
41616
- },
41617
- };
41618
- /**
41619
- * Normalized value: "2/2023" for week 2 of 2023
41620
- */
41621
- const weekAdapter = {
41622
- normalizeFunctionValue(value) {
41623
- const [week, year] = value.split("/");
41624
- return `${Number(week)}/${Number(year)}`;
41625
- },
41626
- getFormat() {
41627
- return undefined;
41628
- },
41629
- formatValue(normalizedValue) {
41630
- const [week, year] = normalizedValue.split("/");
41631
- return _t("W%(week)s %(year)s", { week, year });
41632
- },
41633
- toCellValue(normalizedValue) {
41634
- return this.formatValue(normalizedValue);
41635
- },
41636
- };
41637
- /**
41638
- * normalized month value is a string formatted as "MM/yyyy" (luxon format)
41639
- * e.g. "01/2020" for January 2020
41640
- */
41641
- const monthAdapter = {
41642
- normalizeFunctionValue(value) {
41643
- const date = toNumber(value, DEFAULT_LOCALE);
41644
- return formatValue(date, { locale: DEFAULT_LOCALE, format: "mm/yyyy" });
41645
- },
41646
- getFormat() {
41647
- return "mmmm yyyy";
41648
- },
41649
- formatValue(normalizedValue, locale) {
41650
- locale = locale ?? DEFAULT_LOCALE;
41651
- const value = toNumber(normalizedValue, DEFAULT_LOCALE);
41652
- return formatValue(value, { locale, format: this.getFormat(locale) });
41653
- },
41654
- toCellValue(normalizedValue) {
41655
- return toNumber(normalizedValue, DEFAULT_LOCALE);
41656
- },
41657
- };
41658
- /**
41659
- * normalized quarter value is "quarter/year"
41660
- * e.g. "1/2020" for Q1 2020
41661
- */
41662
- const quarterAdapter = {
41663
- normalizeFunctionValue(value) {
41664
- const [quarter, year] = value.split("/");
41665
- return `${quarter}/${year}`;
41666
- },
41667
- getFormat() {
41668
- return undefined;
41669
- },
41670
- formatValue(normalizedValue) {
41671
- const [quarter, year] = normalizedValue.split("/");
41672
- return _t("Q%(quarter)s %(year)s", { quarter, year });
41673
- },
41674
- toCellValue(normalizedValue) {
41675
- return this.formatValue(normalizedValue);
41676
- },
41677
- };
41678
- const yearAdapter = {
41679
- normalizeFunctionValue(value) {
41680
- return toNumber(value, DEFAULT_LOCALE);
41681
- },
41682
- getFormat() {
41683
- return "0";
41684
- },
41685
- formatValue(normalizedValue, locale) {
41686
- locale = locale ?? DEFAULT_LOCALE;
41687
- return formatValue(normalizedValue, { locale, format: "0" });
41688
- },
41689
- toCellValue(normalizedValue) {
41690
- return normalizedValue;
41691
- },
41692
- };
41693
- pivotTimeAdapterRegistry
41694
- .add("day", dayAdapter)
41695
- .add("week", weekAdapter)
41696
- .add("month", monthAdapter)
41697
- .add("quarter", quarterAdapter)
41698
- .add("year", yearAdapter);
41699
-
41700
41613
  /**
41701
41614
  * Represent a raw XML string
41702
41615
  */
@@ -46895,9 +46808,14 @@ stores.inject(MyMetaStore, storeInstance);
46895
46808
  }
46896
46809
  createLiteralCell(id, content, format, style) {
46897
46810
  const locale = this.getters.getLocale();
46898
- format = format || detectDateFormat(content, locale) || detectNumberFormat(content);
46811
+ const parsedValue = parseLiteral(content, locale);
46812
+ format =
46813
+ format ||
46814
+ (typeof parsedValue === "number"
46815
+ ? detectDateFormat(content, locale) || detectNumberFormat(content)
46816
+ : undefined);
46899
46817
  if (format !== PLAIN_TEXT_FORMAT && !isEvaluationError(content)) {
46900
- content = toString(parseLiteral(content, locale));
46818
+ content = toString(parsedValue);
46901
46819
  }
46902
46820
  return {
46903
46821
  id,
@@ -46905,6 +46823,7 @@ stores.inject(MyMetaStore, storeInstance);
46905
46823
  style,
46906
46824
  format,
46907
46825
  isFormula: false,
46826
+ parsedValue,
46908
46827
  };
46909
46828
  }
46910
46829
  createFormulaCell(id, content, format, style, sheetId) {
@@ -51647,6 +51566,9 @@ stores.inject(MyMetaStore, storeInstance);
51647
51566
  get({ sheetId, col, row }) {
51648
51567
  return this.map[sheetId]?.[col]?.[row];
51649
51568
  }
51569
+ getSheet(sheetId) {
51570
+ return this.map[sheetId];
51571
+ }
51650
51572
  has({ sheetId, col, row }) {
51651
51573
  return this.map[sheetId]?.[col]?.[row] !== undefined;
51652
51574
  }
@@ -51665,6 +51587,19 @@ stores.inject(MyMetaStore, storeInstance);
51665
51587
  }
51666
51588
  return keys;
51667
51589
  }
51590
+ keysForSheet(sheetId) {
51591
+ const map = this.map[sheetId];
51592
+ if (!map) {
51593
+ return [];
51594
+ }
51595
+ const keys = [];
51596
+ for (const col in map) {
51597
+ for (const row in map[col]) {
51598
+ keys.push({ sheetId, col: parseInt(col), row: parseInt(row) });
51599
+ }
51600
+ }
51601
+ return keys;
51602
+ }
51668
51603
  }
51669
51604
 
51670
51605
  function quickselect(arr, k, left, right, compare) {
@@ -52743,6 +52678,9 @@ stores.inject(MyMetaStore, storeInstance);
52743
52678
  getEvaluatedPositions() {
52744
52679
  return this.evaluatedCells.keys();
52745
52680
  }
52681
+ getEvaluatedPositionsInSheet(sheetId) {
52682
+ return this.evaluatedCells.keysForSheet(sheetId);
52683
+ }
52746
52684
  getArrayFormulaSpreadingOn(position) {
52747
52685
  if (!this.spreadingRelations.hasArrayFormulaResult(position)) {
52748
52686
  return this.spreadingRelations.isArrayFormula(position) ? position : undefined;
@@ -52751,6 +52689,9 @@ stores.inject(MyMetaStore, storeInstance);
52751
52689
  return Array.from(arrayFormulas).find((position) => !this.blockedArrayFormulas.has(position));
52752
52690
  }
52753
52691
  updateDependencies(position) {
52692
+ // removing dependencies is slow because it requires
52693
+ // to traverse the entire r-tree.
52694
+ // The data structure is optimized for searches the other way around
52754
52695
  this.formulaDependencies().removeAllDependencies(position);
52755
52696
  const dependencies = this.getDirectDependencies(position);
52756
52697
  this.formulaDependencies().addDependencies(position, dependencies);
@@ -52916,7 +52857,7 @@ stores.inject(MyMetaStore, storeInstance);
52916
52857
  this.cellsBeingComputed.add(cellId);
52917
52858
  return cell.isFormula
52918
52859
  ? this.computeFormulaCell(position.sheetId, cell)
52919
- : evaluateLiteral(cell.content, localeFormat);
52860
+ : evaluateLiteral(cell, localeFormat);
52920
52861
  }
52921
52862
  catch (e) {
52922
52863
  e.value = e?.value || CellErrorType.GenericError;
@@ -53186,6 +53127,7 @@ stores.inject(MyMetaStore, storeInstance);
53186
53127
  "getEvaluatedCell",
53187
53128
  "getEvaluatedCells",
53188
53129
  "getEvaluatedCellsInZone",
53130
+ "getEvaluatedCellsPositions",
53189
53131
  "getSpreadZone",
53190
53132
  "getArrayFormulaSpreadingOn",
53191
53133
  "isEmpty",
@@ -53277,13 +53219,12 @@ stores.inject(MyMetaStore, storeInstance);
53277
53219
  return this.evaluator.getEvaluatedCell(position);
53278
53220
  }
53279
53221
  getEvaluatedCells(sheetId) {
53280
- const rawCells = this.getters.getCells(sheetId) || {};
53281
- const record = {};
53282
- for (let cellId of Object.keys(rawCells)) {
53283
- const position = this.getters.getCellPosition(cellId);
53284
- record[cellId] = this.getEvaluatedCell(position);
53285
- }
53286
- return record;
53222
+ return this.evaluator
53223
+ .getEvaluatedPositionsInSheet(sheetId)
53224
+ .map((position) => this.getEvaluatedCell(position));
53225
+ }
53226
+ getEvaluatedCellsPositions(sheetId) {
53227
+ return this.evaluator.getEvaluatedPositionsInSheet(sheetId);
53287
53228
  }
53288
53229
  getEvaluatedCellsInZone(sheetId, zone) {
53289
53230
  return positions(zone).map(({ col, row }) => this.getters.getEvaluatedCell({ sheetId, col, row }));
@@ -54620,17 +54561,18 @@ stores.inject(MyMetaStore, storeInstance);
54620
54561
  if (pivotCell.type === "EMPTY") {
54621
54562
  return undefined;
54622
54563
  }
54623
- const domain = pivotCell.domain;
54564
+ let domain = pivotCell.domain;
54624
54565
  if (domain.at(-1)?.field === "measure") {
54625
- return domain.slice(0, -1);
54566
+ domain = domain.slice(0, -1);
54626
54567
  }
54627
- return domain;
54568
+ return { domainArgs: domain, isHeader: pivotCell.type === "HEADER" };
54628
54569
  }
54629
- const domain = toPivotDomain(args.slice(functionName === "PIVOT.VALUE" ? 2 : 1).map((x) => `${x}`));
54570
+ let domain = toPivotDomain(args.slice(functionName === "PIVOT.VALUE" ? 2 : 1).map((x) => `${x}`));
54630
54571
  if (domain.at(-1)?.field === "measure") {
54631
- return domain.slice(0, -1);
54572
+ domain = domain.slice(0, -1);
54632
54573
  }
54633
- return domain;
54574
+ const isHeader = functionName === "PIVOT.HEADER";
54575
+ return { domainArgs: domain, isHeader };
54634
54576
  }
54635
54577
  getPivot(pivotId) {
54636
54578
  return this.pivots[pivotId];
@@ -55950,7 +55892,10 @@ stores.inject(MyMetaStore, storeInstance);
55950
55892
  /**
55951
55893
  * Notify the server that the user client left the collaborative session
55952
55894
  */
55953
- leave() {
55895
+ leave(data) {
55896
+ if (Object.keys(this.clients).length === 1 && this.processedRevisions.size) {
55897
+ this.snapshot(data);
55898
+ }
55954
55899
  delete this.clients[this.clientId];
55955
55900
  this.transportService.leave(this.clientId);
55956
55901
  this.transportService.sendMessage({
@@ -56364,7 +56309,7 @@ stores.inject(MyMetaStore, storeInstance);
56364
56309
  bottom: rowIndex,
56365
56310
  }));
56366
56311
  const handler = new CellClipboardHandler(this.getters, this.dispatch);
56367
- const data = handler.copy(getClipboardDataPositions(rowsToKeep));
56312
+ const data = handler.copy(getClipboardDataPositions(sheetId, rowsToKeep));
56368
56313
  if (!data) {
56369
56314
  return;
56370
56315
  }
@@ -56377,7 +56322,7 @@ stores.inject(MyMetaStore, storeInstance);
56377
56322
  right: zone.left,
56378
56323
  bottom: zone.top,
56379
56324
  };
56380
- handler.paste({ zones: [zonePasted] }, data, { isCutOperation: false });
56325
+ handler.paste({ zones: [zonePasted], sheetId }, data, { isCutOperation: false });
56381
56326
  const remainingZone = {
56382
56327
  left: zone.left,
56383
56328
  top: zone.top - (hasHeader ? 1 : 0),
@@ -58251,12 +58196,14 @@ stores.inject(MyMetaStore, storeInstance);
58251
58196
  }
58252
58197
  let zone = undefined;
58253
58198
  let selectedZones = [];
58199
+ const sheetId = this.getters.getActiveSheetId();
58254
58200
  let target = {
58201
+ sheetId,
58255
58202
  zones,
58256
58203
  };
58257
58204
  const handlers = this.selectClipboardHandlers(copiedData);
58258
58205
  for (const handler of handlers) {
58259
- const currentTarget = handler.getPasteTarget(zones, copiedData, options);
58206
+ const currentTarget = handler.getPasteTarget(sheetId, zones, copiedData, options);
58260
58207
  if (currentTarget.figureId) {
58261
58208
  target.figureId = currentTarget.figureId;
58262
58209
  }
@@ -58425,11 +58372,12 @@ stores.inject(MyMetaStore, storeInstance);
58425
58372
  return { cut: [cut], paste: [paste] };
58426
58373
  }
58427
58374
  getClipboardData(zones) {
58375
+ const sheetId = this.getters.getActiveSheetId();
58428
58376
  const selectedFigureId = this.getters.getSelectedFigureId();
58429
58377
  if (selectedFigureId) {
58430
- return { figureId: selectedFigureId };
58378
+ return { figureId: selectedFigureId, sheetId };
58431
58379
  }
58432
- return getClipboardDataPositions(zones);
58380
+ return getClipboardDataPositions(sheetId, zones);
58433
58381
  }
58434
58382
  // ---------------------------------------------------------------------------
58435
58383
  // Grid rendering
@@ -59095,8 +59043,9 @@ stores.inject(MyMetaStore, storeInstance);
59095
59043
  bottom: !isCol ? end + deltaRow : this.getters.getNumberRows(cmd.sheetId) - 1,
59096
59044
  },
59097
59045
  ];
59046
+ const sheetId = this.getActiveSheetId();
59098
59047
  const handler = new CellClipboardHandler(this.getters, this.dispatch);
59099
- const data = handler.copy(getClipboardDataPositions(target));
59048
+ const data = handler.copy(getClipboardDataPositions(sheetId, target));
59100
59049
  if (!data) {
59101
59050
  return;
59102
59051
  }
@@ -59109,7 +59058,7 @@ stores.inject(MyMetaStore, storeInstance);
59109
59058
  bottom: !isCol ? base + thickness - 1 : this.getters.getNumberRows(cmd.sheetId) - 1,
59110
59059
  },
59111
59060
  ];
59112
- handler.paste({ zones: pasteTarget }, data, { isCutOperation: true });
59061
+ handler.paste({ zones: pasteTarget, sheetId }, data, { isCutOperation: true });
59113
59062
  const toRemove = isBasedBefore ? cmd.elements.map((el) => el + thickness) : cmd.elements;
59114
59063
  let currentIndex = cmd.base;
59115
59064
  for (const element of toRemove) {
@@ -66473,7 +66422,7 @@ stores.inject(MyMetaStore, storeInstance);
66473
66422
  this.session.join(this.config.client);
66474
66423
  }
66475
66424
  leaveSession() {
66476
- this.session.leave();
66425
+ this.session.leave(this.exportData());
66477
66426
  }
66478
66427
  setupUiPlugin(Plugin) {
66479
66428
  const plugin = new Plugin(this.uiPluginConfig);
@@ -66880,7 +66829,8 @@ stores.inject(MyMetaStore, storeInstance);
66880
66829
  pivotRegistry,
66881
66830
  pivotTimeAdapterRegistry,
66882
66831
  pivotSidePanelRegistry,
66883
- supportedPivotExplodedFormulaRegistry,
66832
+ pivotNormalizationValueRegistry,
66833
+ supportedPivotPositionalFormulaRegistry,
66884
66834
  };
66885
66835
  const helpers = {
66886
66836
  arg,
@@ -66889,6 +66839,7 @@ stores.inject(MyMetaStore, storeInstance);
66889
66839
  toJsDate,
66890
66840
  toNumber,
66891
66841
  toString,
66842
+ toNormalizedPivotValue,
66892
66843
  toXC,
66893
66844
  toZone,
66894
66845
  toUnboundedZone,
@@ -66983,6 +66934,9 @@ stores.inject(MyMetaStore, storeInstance);
66983
66934
  PivotDimension,
66984
66935
  PivotLayoutConfigurator,
66985
66936
  EditableName,
66937
+ PivotDeferUpdate,
66938
+ PivotTitleSection,
66939
+ CogWheelMenu,
66986
66940
  };
66987
66941
  const hooks = {
66988
66942
  useDragAndDropListItems,
@@ -67066,9 +67020,9 @@ stores.inject(MyMetaStore, storeInstance);
67066
67020
  exports.tokenize = tokenize;
67067
67021
 
67068
67022
 
67069
- __info__.version = "17.4.0-alpha.2";
67070
- __info__.date = "2024-06-06T13:31:21.327Z";
67071
- __info__.hash = "e07794d";
67023
+ __info__.version = "17.4.0-alpha.4";
67024
+ __info__.date = "2024-06-12T14:00:22.046Z";
67025
+ __info__.hash = "cefb0e4";
67072
67026
 
67073
67027
 
67074
67028
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);