@univerjs/engine-formula 1.0.0-alpha.8 → 1.0.0-beta.0
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.
- package/lib/cjs/index.js +955 -857
- package/lib/es/index.js +955 -857
- package/lib/index.js +955 -857
- package/lib/types/basics/regex.d.ts +4 -4
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +4 -0
- package/lib/types/engine/analysis/lexer.d.ts +4 -2
- package/lib/types/engine/ast-node/base-ast-node.d.ts +1 -0
- package/lib/types/engine/ast-node/function-node.d.ts +1 -0
- package/lib/types/engine/ast-node/union-node.d.ts +8 -2
- package/lib/types/engine/reference-object/base-reference-object.d.ts +2 -1
- package/lib/types/engine/reference-object/multi-area-reference-object.d.ts +11 -3
- package/lib/types/engine/reference-object/table-reference-object.d.ts +1 -1
- package/lib/types/engine/utils/generate-ast-node.d.ts +1 -1
- package/lib/types/functions/base-function.d.ts +4 -0
- package/lib/types/functions/compatibility/rank/index.d.ts +1 -0
- package/lib/types/functions/information/isblank/index.d.ts +3 -3
- package/lib/types/functions/lookup/choose/index.d.ts +1 -0
- package/lib/types/functions/lookup/function-map.d.ts +4 -1
- package/lib/types/functions/lookup/match/index.d.ts +1 -0
- package/lib/types/functions/math/sumproduct/index.d.ts +1 -0
- package/lib/types/functions/statistical/median/index.d.ts +1 -0
- package/lib/types/functions/statistical/percentile-exc/index.d.ts +1 -0
- package/lib/types/functions/statistical/percentile-inc/index.d.ts +1 -0
- package/lib/types/functions/statistical/rank-avg/index.d.ts +1 -0
- package/lib/types/functions/statistical/rank-eq/index.d.ts +1 -0
- package/lib/types/functions/text/textjoin/index.d.ts +1 -0
- package/lib/umd/index.js +4 -4
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1259,13 +1259,8 @@ var InvertedIndexCache = class {
|
|
|
1259
1259
|
const rowsForEmpty = columnMap.get(DEFAULT_EMPTY_CELL_KEY);
|
|
1260
1260
|
if (rowsForEmpty) rows.push(...rowsForEmpty);
|
|
1261
1261
|
result.matchingRows = rows.filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1262
|
-
} else if (_value === DEFAULT_EMPTY_CELL_KEY)
|
|
1263
|
-
|
|
1264
|
-
result.matchingRows = Array.from((_columnMap$get = columnMap.get(DEFAULT_EMPTY_CELL_KEY)) !== null && _columnMap$get !== void 0 ? _columnMap$get : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1265
|
-
} else {
|
|
1266
|
-
var _columnMap$get2;
|
|
1267
|
-
result.matchingRows = Array.from((_columnMap$get2 = columnMap.get(_value)) !== null && _columnMap$get2 !== void 0 ? _columnMap$get2 : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1268
|
-
}
|
|
1262
|
+
} else if (_value === DEFAULT_EMPTY_CELL_KEY) result.matchingRows = Array.from(columnMap.get(DEFAULT_EMPTY_CELL_KEY) ?? []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1263
|
+
else result.matchingRows = Array.from(columnMap.get(_value) ?? []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
|
|
1269
1264
|
return result;
|
|
1270
1265
|
}
|
|
1271
1266
|
setContinueBuildingCache(unitId, sheetId, column, startRow, endRow) {
|
|
@@ -1478,9 +1473,9 @@ const REFERENCE_REGEX_SINGLE_ROW = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${"$"}?
|
|
|
1478
1473
|
const REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_ROW);
|
|
1479
1474
|
const REFERENCE_REGEX_SINGLE_COLUMN = `^${UNIT_NAME_SHEET_NAME_REGEX}\\s*?\\${"$"}?${COLUMN_REGEX}$`;
|
|
1480
1475
|
const REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING = new RegExp(REFERENCE_REGEX_SINGLE_COLUMN);
|
|
1481
|
-
const TABLE_NAME_REGEX = "((?![~!@#$%^&*()
|
|
1476
|
+
const TABLE_NAME_REGEX = "((?![~!@#$%^&*()+<>?:,./;’,。、‘:“《》?~!@#¥%……()【】\\[\\]\\/\\\\]).)+";
|
|
1482
1477
|
const TABLE_TITLE_REGEX = "\\[#.+\\]\\s*?,\\s*?";
|
|
1483
|
-
const TABLE_CONTENT_REGEX = "\\[
|
|
1478
|
+
const TABLE_CONTENT_REGEX = "\\[[^#]*#?\\]";
|
|
1484
1479
|
const TABLE_MULTIPLE_COLUMN_REGEX = `${TABLE_CONTENT_REGEX}${RANGE_SYMBOL}${TABLE_CONTENT_REGEX}`;
|
|
1485
1480
|
const TABLE_UNIT_QUALIFIER_REGEX = `(?:(?:${UNIT_NAME_REGEX}|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:${UNIT_NAME_REGEX})?`;
|
|
1486
1481
|
const REFERENCE_TABLE_ALL_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}$`;
|
|
@@ -2099,7 +2094,6 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
2099
2094
|
const nameMap = this._definedNameMap[unitId];
|
|
2100
2095
|
if (nameMap === void 0) return null;
|
|
2101
2096
|
if (sheetId) {
|
|
2102
|
-
var _workbookScope;
|
|
2103
2097
|
const normalizedName = name.toLowerCase();
|
|
2104
2098
|
let workbookScope = null;
|
|
2105
2099
|
let firstMatch = null;
|
|
@@ -2111,7 +2105,7 @@ let DefinedNamesService = class DefinedNamesService extends _univerjs_core.Dispo
|
|
|
2111
2105
|
if (workbookScope == null) workbookScope = item;
|
|
2112
2106
|
}
|
|
2113
2107
|
}
|
|
2114
|
-
return
|
|
2108
|
+
return workbookScope ?? firstMatch;
|
|
2115
2109
|
}
|
|
2116
2110
|
const cachedMap = this._nameCacheMap[unitId];
|
|
2117
2111
|
if (cachedMap) return cachedMap[name.toLowerCase()] || null;
|
|
@@ -2413,7 +2407,7 @@ var SuperTableService = class extends _univerjs_core.Disposable {
|
|
|
2413
2407
|
}
|
|
2414
2408
|
hasTable(unitId, tableName) {
|
|
2415
2409
|
const unitIdMap = this._tableMap.get(unitId);
|
|
2416
|
-
if (unitIdMap) return unitIdMap.keys().some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2410
|
+
if (unitIdMap) return Array.from(unitIdMap.keys()).some((name) => name.toLowerCase() === tableName.toLowerCase());
|
|
2417
2411
|
return false;
|
|
2418
2412
|
}
|
|
2419
2413
|
_update() {
|
|
@@ -3823,9 +3817,11 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3823
3817
|
return this._nodeMaker(formulaString);
|
|
3824
3818
|
}
|
|
3825
3819
|
treeBuilder(formulaString, transformSuffix = true, injectDefinedNameParam) {
|
|
3826
|
-
|
|
3820
|
+
const isCacheable = !/\b(?:LET|LAMBDA)\s*\(/iu.test(formulaString);
|
|
3821
|
+
const cacheKey = injectDefinedNameParam == null ? formulaString : `${injectDefinedNameParam.unitId ?? ""}\0${injectDefinedNameParam.sheetId ?? ""}\0${injectDefinedNameParam.refOffsetX}\0${injectDefinedNameParam.refOffsetY}\0${formulaString}`;
|
|
3822
|
+
if (transformSuffix === true && isCacheable) {
|
|
3827
3823
|
var _this$_simpleCheckDef;
|
|
3828
|
-
const lexerNode = FormulaLexerNodeCache.get(
|
|
3824
|
+
const lexerNode = FormulaLexerNodeCache.get(cacheKey);
|
|
3829
3825
|
const simpleCheckDefinedNameResult = injectDefinedNameParam && ((_this$_simpleCheckDef = this._simpleCheckDefinedName) === null || _this$_simpleCheckDef === void 0 ? void 0 : _this$_simpleCheckDef.call(this, formulaString, injectDefinedNameParam));
|
|
3830
3826
|
if (lexerNode && !simpleCheckDefinedNameResult) return lexerNode;
|
|
3831
3827
|
}
|
|
@@ -3857,13 +3853,13 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3857
3853
|
if (node) this._currentLexerNode = node;
|
|
3858
3854
|
if (transformSuffix) {
|
|
3859
3855
|
if (!this._suffixExpressionHandler(this._currentLexerNode)) return "#VALUE!";
|
|
3860
|
-
FormulaLexerNodeCache.set(
|
|
3856
|
+
if (isCacheable) FormulaLexerNodeCache.set(cacheKey, this._currentLexerNode);
|
|
3861
3857
|
}
|
|
3862
3858
|
if (currentHasDefinedName) this._currentLexerNode.setDefinedNames(currentDefinedNames);
|
|
3863
3859
|
return this._currentLexerNode;
|
|
3864
3860
|
}
|
|
3865
3861
|
_handleDefinedName(sequenceArray, param) {
|
|
3866
|
-
const { unitId, sheetId,
|
|
3862
|
+
const { unitId, sheetId, hasFunction, getValueByName } = param;
|
|
3867
3863
|
if (unitId == null) return {
|
|
3868
3864
|
sequenceString: "",
|
|
3869
3865
|
hasDefinedName: false,
|
|
@@ -3882,11 +3878,19 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3882
3878
|
const { nodeType, token: tokenRaw } = node;
|
|
3883
3879
|
let token = tokenRaw;
|
|
3884
3880
|
if (nodeType === 4 || nodeType === 3) {
|
|
3885
|
-
if (nodeType === 3)
|
|
3881
|
+
if (nodeType === 3) {
|
|
3882
|
+
const nextNode = sequenceNodes[i + 1];
|
|
3883
|
+
if (typeof nextNode === "string" && nextNode.trim() === "(" && hasFunction(tokenRaw.trim().toUpperCase())) {
|
|
3884
|
+
sequenceString += tokenRaw;
|
|
3885
|
+
continue;
|
|
3886
|
+
}
|
|
3887
|
+
token = this._getHasSheetNameDefinedName(tokenRaw, unitId, param);
|
|
3888
|
+
}
|
|
3886
3889
|
const definedNameToken = token.trim();
|
|
3887
3890
|
const definedContent = getValueByName(unitId, definedNameToken, sheetId);
|
|
3888
3891
|
if (definedContent) {
|
|
3889
|
-
const
|
|
3892
|
+
const refOffsetX = definedContent.localSheetId === "AllDefaultWorkbook" ? param.refOffsetX - 1 : param.refOffsetX;
|
|
3893
|
+
const refString = definedContent.formulaOrRefString.startsWith("=") ? definedContent.formulaOrRefString : this._moveDefinedNameRefOffset(definedContent.formulaOrRefString, refOffsetX, param.refOffsetY);
|
|
3890
3894
|
const nestedDefinedNameParam = this._handleNestedDefinedName(refString, param);
|
|
3891
3895
|
if (nestedDefinedNameParam == null || typeof nestedDefinedNameParam !== "object") {
|
|
3892
3896
|
sequenceString += nestedDefinedNameParam || "#NAME?";
|
|
@@ -3913,6 +3917,28 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
3913
3917
|
definedNames
|
|
3914
3918
|
};
|
|
3915
3919
|
}
|
|
3920
|
+
_moveDefinedNameRefOffset(formulaString, refOffsetX, refOffsetY) {
|
|
3921
|
+
const sequenceNodes = this.sequenceNodesBuilder(formulaString);
|
|
3922
|
+
if (sequenceNodes == null) return formulaString;
|
|
3923
|
+
return generateStringWithSequence(sequenceNodes.map((node) => {
|
|
3924
|
+
if (typeof node === "string" || node.nodeType !== 4) return node;
|
|
3925
|
+
const sequenceGrid = deserializeRangeWithSheetWithCache(node.token);
|
|
3926
|
+
const range = (0, _univerjs_core.moveRangeByOffset)(sequenceGrid.range, refOffsetX, refOffsetY);
|
|
3927
|
+
const wrap = (value, limit) => (value % limit + limit) % limit;
|
|
3928
|
+
range.startRow = wrap(range.startRow, _univerjs_core.MAX_ROW_COUNT);
|
|
3929
|
+
range.endRow = wrap(range.endRow, _univerjs_core.MAX_ROW_COUNT);
|
|
3930
|
+
range.startColumn = wrap(range.startColumn, _univerjs_core.MAX_COLUMN_COUNT);
|
|
3931
|
+
range.endColumn = wrap(range.endColumn, _univerjs_core.MAX_COLUMN_COUNT);
|
|
3932
|
+
return {
|
|
3933
|
+
...node,
|
|
3934
|
+
token: serializeRangeToRefString({
|
|
3935
|
+
range,
|
|
3936
|
+
unitId: sequenceGrid.unitId,
|
|
3937
|
+
sheetName: sequenceGrid.sheetName
|
|
3938
|
+
})
|
|
3939
|
+
};
|
|
3940
|
+
}));
|
|
3941
|
+
}
|
|
3916
3942
|
_getHasSheetNameDefinedName(tokenRaw, unitId, param) {
|
|
3917
3943
|
if (!tokenRaw.includes("!")) return tokenRaw;
|
|
3918
3944
|
const parts = tokenRaw.split("!");
|
|
@@ -4339,7 +4365,7 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
4339
4365
|
}
|
|
4340
4366
|
this._resetSegment();
|
|
4341
4367
|
continue;
|
|
4342
|
-
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4368
|
+
} else if (currentString === "(" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) if (this._segmentCount() > 0 || this.isLambdaOpen()) {
|
|
4343
4369
|
if (this.isLambdaClose()) {
|
|
4344
4370
|
this._newAndPushCurrentLexerNode(this._segment, cur);
|
|
4345
4371
|
this._resetSegment();
|
|
@@ -4367,7 +4393,7 @@ var LexerTreeBuilder = class extends _univerjs_core.Disposable {
|
|
|
4367
4393
|
this._openBracketNormalIndex();
|
|
4368
4394
|
this._resetSegment();
|
|
4369
4395
|
}
|
|
4370
|
-
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose()) {
|
|
4396
|
+
else if (currentString === ")" && this.isSingleQuotationClose() && this.isDoubleQuotationClose() && this.isSquareBracketClose()) {
|
|
4371
4397
|
if (this._formulaErrorLastTokenCheck(formulaChars, cur - 1)) this._formalErrorOccurred();
|
|
4372
4398
|
this._pushNodeToChildren(this._segment);
|
|
4373
4399
|
this._resetSegment();
|
|
@@ -5095,13 +5121,13 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5095
5121
|
const recordId = recordOrder[row];
|
|
5096
5122
|
if (!table.records[recordId]) continue;
|
|
5097
5123
|
for (let col = 0; col < table.fieldOrder.length; col++) {
|
|
5098
|
-
var _field$config
|
|
5124
|
+
var _field$config;
|
|
5099
5125
|
const fieldId = table.fieldOrder[col];
|
|
5100
5126
|
const field = table.fields[fieldId];
|
|
5101
5127
|
if (!field || field.type !== "formula") continue;
|
|
5102
|
-
const formula = String((
|
|
5128
|
+
const formula = String(((_field$config = field.config) === null || _field$config === void 0 ? void 0 : _field$config.formula) ?? "").trim();
|
|
5103
5129
|
if (!formula) continue;
|
|
5104
|
-
|
|
5130
|
+
tableFormulaData[row] ??= {};
|
|
5105
5131
|
tableFormulaData[row][col] = {
|
|
5106
5132
|
f: normalizeBaseFormulaForEngine(formula, table, snapshot),
|
|
5107
5133
|
si: field.id
|
|
@@ -5232,10 +5258,10 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5232
5258
|
const baseData = {};
|
|
5233
5259
|
const tableNameMap = {};
|
|
5234
5260
|
for (const table of Object.values(snapshot.tables)) {
|
|
5235
|
-
var _table$recordOrder
|
|
5261
|
+
var _table$recordOrder;
|
|
5236
5262
|
baseData[table.id] = {
|
|
5237
5263
|
cellData: new _univerjs_core.ObjectMatrix(buildBaseRuntimeCellData(table)),
|
|
5238
|
-
rowCount: (
|
|
5264
|
+
rowCount: ((_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.length) ?? 0,
|
|
5239
5265
|
columnCount: table.fieldOrder.length,
|
|
5240
5266
|
rowData: {},
|
|
5241
5267
|
columnData: {}
|
|
@@ -5278,7 +5304,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5278
5304
|
return rowData;
|
|
5279
5305
|
}
|
|
5280
5306
|
updateFormulaData(unitId, sheetId, cellValue) {
|
|
5281
|
-
var _this$_univerInstance, _formulaData$unitId
|
|
5307
|
+
var _this$_univerInstance, _formulaData$unitId;
|
|
5282
5308
|
const cellMatrix = new _univerjs_core.ObjectMatrix(cellValue);
|
|
5283
5309
|
const newSheetFormulaDataMatrix = new _univerjs_core.ObjectMatrix();
|
|
5284
5310
|
const worksheetCellMatrix = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(sheetId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getCellMatrix();
|
|
@@ -5313,7 +5339,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5313
5339
|
const formulaData = {};
|
|
5314
5340
|
initSheetFormulaData(formulaData, unitId, sheetId, sharedFormulaCellMatrix);
|
|
5315
5341
|
const deleteFormulaIdMap = /* @__PURE__ */ new Map();
|
|
5316
|
-
const sheetFormulaDataMatrix = new _univerjs_core.ObjectMatrix((
|
|
5342
|
+
const sheetFormulaDataMatrix = new _univerjs_core.ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
|
|
5317
5343
|
cellMatrix.forValue((r, c, cell) => {
|
|
5318
5344
|
var _worksheetCellMatrix$;
|
|
5319
5345
|
if (!(0, _univerjs_core.isFormulaId)(worksheetCellMatrix === null || worksheetCellMatrix === void 0 || (_worksheetCellMatrix$ = worksheetCellMatrix.getValue(r, c)) === null || _worksheetCellMatrix$ === void 0 ? void 0 : _worksheetCellMatrix$.si) && !(0, _univerjs_core.isFormulaId)(cell === null || cell === void 0 ? void 0 : cell.si)) return;
|
|
@@ -5510,7 +5536,7 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5510
5536
|
if ((0, _univerjs_core.isFormulaString)(cell === null || cell === void 0 ? void 0 : cell.f) && (0, _univerjs_core.isFormulaId)(formulaId)) formulaIds.add(String(formulaId));
|
|
5511
5537
|
});
|
|
5512
5538
|
cellMatrix.forValue((row, column, cell) => {
|
|
5513
|
-
var
|
|
5539
|
+
var _this$_arrayFormulaRa7, _this$_arrayFormulaCe5;
|
|
5514
5540
|
const ref = cell === null || cell === void 0 ? void 0 : cell.ref;
|
|
5515
5541
|
const formula = cell === null || cell === void 0 ? void 0 : cell.f;
|
|
5516
5542
|
const formulaId = cell === null || cell === void 0 ? void 0 : cell.si;
|
|
@@ -5522,8 +5548,8 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5522
5548
|
if (range.startRow === row && range.endRow === row && range.startColumn === column && range.endColumn === column && !isArrayConstantFormula(formula)) return true;
|
|
5523
5549
|
if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = {};
|
|
5524
5550
|
if (!this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId] = {};
|
|
5525
|
-
|
|
5526
|
-
|
|
5551
|
+
arrayFormulaRangeMatrix ??= new _univerjs_core.ObjectMatrix((_this$_arrayFormulaRa7 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa7 === void 0 ? void 0 : _this$_arrayFormulaRa7[sheetId]);
|
|
5552
|
+
arrayFormulaCellDataMatrix ??= new _univerjs_core.ObjectMatrix((_this$_arrayFormulaCe5 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe5 === void 0 ? void 0 : _this$_arrayFormulaCe5[sheetId]);
|
|
5527
5553
|
if (arrayFormulaRangeMatrix.getValue(row, column) == null) arrayFormulaRangeMatrix.setValue(row, column, range);
|
|
5528
5554
|
for (let r = range.startRow; r <= range.endRow; r++) for (let c = range.startColumn; c <= range.endColumn; c++) {
|
|
5529
5555
|
if (arrayFormulaCellDataMatrix.getValue(r, c) != null) continue;
|
|
@@ -5595,11 +5621,8 @@ function normalizeBaseFormulaForEngine(formula, currentTable, snapshot) {
|
|
|
5595
5621
|
};
|
|
5596
5622
|
return protectBaseExternalReferences(formula, hold).replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, snapshot))).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
|
|
5597
5623
|
const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot);
|
|
5598
|
-
return targetTable ? hold(
|
|
5599
|
-
}).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) =>
|
|
5600
|
-
var _refs$Number;
|
|
5601
|
-
return (_refs$Number = refs[Number(index)]) !== null && _refs$Number !== void 0 ? _refs$Number : "";
|
|
5602
|
-
});
|
|
5624
|
+
return targetTable ? hold(createEngineColumnRef(targetTable, fieldName, snapshot)) : `${sourceTableName}[${fieldName}]`;
|
|
5625
|
+
}).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => refs[Number(index)] ?? "");
|
|
5603
5626
|
}
|
|
5604
5627
|
function protectBaseExternalReferences(formula, replace) {
|
|
5605
5628
|
return protectBaseExternalStructuredReferences(formula.replace(BASE_EXTERNAL_A1_REF_PATTERN, (reference, offset) => isInsideBaseFormulaString(formula, offset) ? reference : replace(reference)), replace);
|
|
@@ -5651,6 +5674,9 @@ function isInsideBaseFormulaString(formula, position) {
|
|
|
5651
5674
|
function createEngineThisRowRef(table, fieldName, snapshot) {
|
|
5652
5675
|
return `${getEngineBaseTableName(table, snapshot)}[[#This Row],[${fieldName}]]`;
|
|
5653
5676
|
}
|
|
5677
|
+
function createEngineColumnRef(table, fieldName, snapshot) {
|
|
5678
|
+
return `${getEngineBaseTableName(table, snapshot)}[[#Data],[${fieldName}]]`;
|
|
5679
|
+
}
|
|
5654
5680
|
function getEngineBaseTableName(table, snapshot) {
|
|
5655
5681
|
const tables = Object.values(snapshot.tables);
|
|
5656
5682
|
let sameNameCount = 0;
|
|
@@ -5675,8 +5701,7 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5675
5701
|
if (table.records[recordId]) recordOrder.push(recordId);
|
|
5676
5702
|
}
|
|
5677
5703
|
} else {
|
|
5678
|
-
|
|
5679
|
-
const allRecords = Object.values((_table$records = table.records) !== null && _table$records !== void 0 ? _table$records : {});
|
|
5704
|
+
const allRecords = Object.values(table.records ?? {});
|
|
5680
5705
|
const records = [];
|
|
5681
5706
|
for (let i = 0; i < allRecords.length; i++) {
|
|
5682
5707
|
const record = allRecords[i];
|
|
@@ -5695,9 +5720,8 @@ function buildBaseRuntimeCellData(table) {
|
|
|
5695
5720
|
if (!record) continue;
|
|
5696
5721
|
cellData[row] = { ...cellData[row] };
|
|
5697
5722
|
for (let col = 0; col < fieldOrder.length; col++) {
|
|
5698
|
-
var _record$values;
|
|
5699
5723
|
const fieldId = fieldOrder[col];
|
|
5700
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
5724
|
+
if (!Object.prototype.hasOwnProperty.call(record.values ?? {}, fieldId)) continue;
|
|
5701
5725
|
cellData[row][col] = toBaseRuntimeCellData(record.values[fieldId], table.fields[fieldId]);
|
|
5702
5726
|
}
|
|
5703
5727
|
}
|
|
@@ -5714,10 +5738,9 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5714
5738
|
t: _univerjs_core.CellValueType.STRING
|
|
5715
5739
|
};
|
|
5716
5740
|
if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object") {
|
|
5717
|
-
var _ref, _link$text;
|
|
5718
5741
|
const link = value;
|
|
5719
5742
|
return {
|
|
5720
|
-
v: String(
|
|
5743
|
+
v: String(link.text ?? link.url ?? ""),
|
|
5721
5744
|
t: _univerjs_core.CellValueType.STRING
|
|
5722
5745
|
};
|
|
5723
5746
|
}
|
|
@@ -5731,8 +5754,7 @@ function toBaseRuntimeCellData(value, field) {
|
|
|
5731
5754
|
};
|
|
5732
5755
|
}
|
|
5733
5756
|
function normalizeBaseCellData(cell) {
|
|
5734
|
-
|
|
5735
|
-
const type = inferBaseRuntimeCellType((_cell$v = cell.v) !== null && _cell$v !== void 0 ? _cell$v : null);
|
|
5757
|
+
const type = inferBaseRuntimeCellType(cell.v ?? null);
|
|
5736
5758
|
return {
|
|
5737
5759
|
...cell,
|
|
5738
5760
|
t: type
|
|
@@ -5784,9 +5806,8 @@ var SheetRowFilteredService = class extends _univerjs_core.Disposable {
|
|
|
5784
5806
|
this._getRowFilteredCallback = callback;
|
|
5785
5807
|
}
|
|
5786
5808
|
getRowFiltered(unitId, subUnitId, row) {
|
|
5787
|
-
var _this$_getRowFiltered;
|
|
5788
5809
|
if (!this._getRowFilteredCallback) return false;
|
|
5789
|
-
return
|
|
5810
|
+
return this._getRowFilteredCallback(unitId, subUnitId, row) ?? false;
|
|
5790
5811
|
}
|
|
5791
5812
|
};
|
|
5792
5813
|
const ISheetRowFilteredService = (0, _univerjs_core.createIdentifier)("univer.formula.sheet-row-filtered.service");
|
|
@@ -5919,7 +5940,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5919
5940
|
return this._localeService.getCurrentLocale();
|
|
5920
5941
|
}
|
|
5921
5942
|
getSheetsInfo() {
|
|
5922
|
-
var _this$_sheetIdToNameM;
|
|
5923
5943
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
5924
5944
|
if (!workbook) return {
|
|
5925
5945
|
sheetOrder: [],
|
|
@@ -5928,7 +5948,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5928
5948
|
const { id, sheetOrder } = workbook.getSnapshot();
|
|
5929
5949
|
return {
|
|
5930
5950
|
sheetOrder,
|
|
5931
|
-
sheetNameMap:
|
|
5951
|
+
sheetNameMap: this._sheetIdToNameMap[id] ?? {}
|
|
5932
5952
|
};
|
|
5933
5953
|
}
|
|
5934
5954
|
getSheetRowColumnCount(unitId, sheetId) {
|
|
@@ -5955,7 +5975,6 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5955
5975
|
return filteredOutRows;
|
|
5956
5976
|
}
|
|
5957
5977
|
load(config) {
|
|
5958
|
-
var _config$externalRefer;
|
|
5959
5978
|
this._calculationGeneration++;
|
|
5960
5979
|
if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
|
|
5961
5980
|
this._unitData = config.allUnitData;
|
|
@@ -5981,7 +6000,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5981
6000
|
this._dirtySuperTableMap = config.dirtySuperTableMap || {};
|
|
5982
6001
|
this._dirtyUnitFeatureMap = config.dirtyUnitFeatureMap;
|
|
5983
6002
|
this._dirtyUnitOtherFormulaMap = config.dirtyUnitOtherFormulaMap;
|
|
5984
|
-
this._externalReferences =
|
|
6003
|
+
this._externalReferences = config.externalReferences ?? {};
|
|
5985
6004
|
this._excludedCell = config.excludedCell;
|
|
5986
6005
|
this._mergeNameMap(this._sheetNameMap, this._dirtyNameMap);
|
|
5987
6006
|
}
|
|
@@ -6045,13 +6064,12 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
6045
6064
|
});
|
|
6046
6065
|
}
|
|
6047
6066
|
_loadSheetData() {
|
|
6048
|
-
var _workbook$getUnitId, _worksheet$getSheetId;
|
|
6049
6067
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
6050
6068
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
6051
6069
|
const base = workbook ? null : this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_BASE);
|
|
6052
6070
|
const table = base ? getFirstBaseTable(base.getSnapshot().tables, base.getSnapshot().tableOrder) : null;
|
|
6053
|
-
this._executeUnitId = (
|
|
6054
|
-
this._executeSubUnitId = (
|
|
6071
|
+
this._executeUnitId = (workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId()) ?? (base === null || base === void 0 ? void 0 : base.getUnitId());
|
|
6072
|
+
this._executeSubUnitId = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId()) ?? (table === null || table === void 0 ? void 0 : table.id);
|
|
6055
6073
|
return this._formulaDataModel.getCalculateData();
|
|
6056
6074
|
}
|
|
6057
6075
|
/**
|
|
@@ -6083,29 +6101,334 @@ FormulaCurrentConfigService = __decorate([
|
|
|
6083
6101
|
__decorateParam(3, (0, _univerjs_core.Inject)(ISheetRowFilteredService))
|
|
6084
6102
|
], FormulaCurrentConfigService);
|
|
6085
6103
|
function getFirstBaseTable(tables, tableOrder) {
|
|
6086
|
-
var _Object$values$;
|
|
6087
6104
|
for (const tableId of tableOrder) {
|
|
6088
6105
|
const table = tables[tableId];
|
|
6089
6106
|
if (table) return table;
|
|
6090
6107
|
}
|
|
6091
|
-
return
|
|
6108
|
+
return Object.values(tables)[0] ?? null;
|
|
6092
6109
|
}
|
|
6093
6110
|
const IFormulaCurrentConfigService = (0, _univerjs_core.createIdentifier)("univer.formula.current-data.service");
|
|
6094
6111
|
|
|
6112
|
+
//#endregion
|
|
6113
|
+
//#region src/engine/ast-node/node-type.ts
|
|
6114
|
+
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
6115
|
+
[1, 7],
|
|
6116
|
+
[2, 9],
|
|
6117
|
+
[3, 8],
|
|
6118
|
+
[4, 6],
|
|
6119
|
+
[5, 1],
|
|
6120
|
+
[6, 2],
|
|
6121
|
+
[9, 10],
|
|
6122
|
+
[10, 3],
|
|
6123
|
+
[11, 4],
|
|
6124
|
+
[12, 5]
|
|
6125
|
+
]);
|
|
6126
|
+
|
|
6127
|
+
//#endregion
|
|
6128
|
+
//#region src/engine/ast-node/base-ast-node.ts
|
|
6129
|
+
var BaseAstNode = class {
|
|
6130
|
+
constructor(_token) {
|
|
6131
|
+
this._token = _token;
|
|
6132
|
+
_defineProperty(this, "_children", []);
|
|
6133
|
+
_defineProperty(this, "_definedNames", void 0);
|
|
6134
|
+
_defineProperty(this, "_parent", void 0);
|
|
6135
|
+
_defineProperty(this, "_valueObject", void 0);
|
|
6136
|
+
_defineProperty(this, "_calculateState", false);
|
|
6137
|
+
_defineProperty(this, "_async", false);
|
|
6138
|
+
_defineProperty(this, "_address", false);
|
|
6139
|
+
_defineProperty(this, "_isForcedCalculateFunction", false);
|
|
6140
|
+
}
|
|
6141
|
+
dispose() {
|
|
6142
|
+
var _this$_valueObject;
|
|
6143
|
+
this._children.forEach((node) => {
|
|
6144
|
+
node.dispose();
|
|
6145
|
+
});
|
|
6146
|
+
(_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
|
|
6147
|
+
this._valueObject = null;
|
|
6148
|
+
this._children = [];
|
|
6149
|
+
this._definedNames = null;
|
|
6150
|
+
this._parent = null;
|
|
6151
|
+
}
|
|
6152
|
+
get nodeType() {
|
|
6153
|
+
return 8;
|
|
6154
|
+
}
|
|
6155
|
+
resetCalculationState() {
|
|
6156
|
+
this._children.forEach((node) => {
|
|
6157
|
+
node.resetCalculationState();
|
|
6158
|
+
});
|
|
6159
|
+
this._valueObject = null;
|
|
6160
|
+
this._calculateState = false;
|
|
6161
|
+
}
|
|
6162
|
+
isAsync() {
|
|
6163
|
+
return this._async;
|
|
6164
|
+
}
|
|
6165
|
+
isAddress() {
|
|
6166
|
+
return this._address;
|
|
6167
|
+
}
|
|
6168
|
+
isForcedCalculateFunction() {
|
|
6169
|
+
return this._isForcedCalculateFunction;
|
|
6170
|
+
}
|
|
6171
|
+
setAsync() {
|
|
6172
|
+
this._async = true;
|
|
6173
|
+
}
|
|
6174
|
+
setAddress() {
|
|
6175
|
+
this._address = true;
|
|
6176
|
+
}
|
|
6177
|
+
getParent() {
|
|
6178
|
+
return this._parent;
|
|
6179
|
+
}
|
|
6180
|
+
setParent(node) {
|
|
6181
|
+
this._parent = node;
|
|
6182
|
+
node.addChildren(this);
|
|
6183
|
+
}
|
|
6184
|
+
setForcedCalculateFunction() {
|
|
6185
|
+
this._isForcedCalculateFunction = true;
|
|
6186
|
+
}
|
|
6187
|
+
getChildren() {
|
|
6188
|
+
return this._children;
|
|
6189
|
+
}
|
|
6190
|
+
addChildren(...astNode) {
|
|
6191
|
+
this._children.push(...astNode);
|
|
6192
|
+
}
|
|
6193
|
+
getToken() {
|
|
6194
|
+
return this._token;
|
|
6195
|
+
}
|
|
6196
|
+
setValue(value) {
|
|
6197
|
+
this._valueObject = value;
|
|
6198
|
+
}
|
|
6199
|
+
getValue() {
|
|
6200
|
+
return this._valueObject;
|
|
6201
|
+
}
|
|
6202
|
+
preservesLazyIfReferenceArray(_child) {
|
|
6203
|
+
return false;
|
|
6204
|
+
}
|
|
6205
|
+
isCalculated() {
|
|
6206
|
+
return this._calculateState;
|
|
6207
|
+
}
|
|
6208
|
+
setCalculated() {
|
|
6209
|
+
this._calculateState = true;
|
|
6210
|
+
}
|
|
6211
|
+
execute() {}
|
|
6212
|
+
setNotEmpty(state = true) {}
|
|
6213
|
+
async executeAsync() {
|
|
6214
|
+
return Promise.resolve(0);
|
|
6215
|
+
}
|
|
6216
|
+
serialize() {
|
|
6217
|
+
const token = this.getToken();
|
|
6218
|
+
const children = this.getChildren();
|
|
6219
|
+
const childrenSerialization = [];
|
|
6220
|
+
const childrenCount = children.length;
|
|
6221
|
+
for (let i = 0; i < childrenCount; i++) {
|
|
6222
|
+
const item = children[i];
|
|
6223
|
+
childrenSerialization.push(item.serialize());
|
|
6224
|
+
}
|
|
6225
|
+
const result = {
|
|
6226
|
+
token,
|
|
6227
|
+
nodeType: this.nodeType
|
|
6228
|
+
};
|
|
6229
|
+
if (childrenCount > 0) result.children = childrenSerialization;
|
|
6230
|
+
return result;
|
|
6231
|
+
}
|
|
6232
|
+
hasDefinedName(definedName) {
|
|
6233
|
+
var _this$_definedNames;
|
|
6234
|
+
return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
|
|
6235
|
+
}
|
|
6236
|
+
setDefinedNames(definedNames) {
|
|
6237
|
+
this._definedNames = definedNames;
|
|
6238
|
+
}
|
|
6239
|
+
getDefinedNames() {
|
|
6240
|
+
return this._definedNames;
|
|
6241
|
+
}
|
|
6242
|
+
};
|
|
6243
|
+
var ErrorNode = class ErrorNode extends BaseAstNode {
|
|
6244
|
+
constructor(errorType) {
|
|
6245
|
+
super(errorType);
|
|
6246
|
+
_defineProperty(this, "_errorValueObject", void 0);
|
|
6247
|
+
this._errorValueObject = ErrorValueObject.create(errorType);
|
|
6248
|
+
}
|
|
6249
|
+
get nodeType() {
|
|
6250
|
+
return 7;
|
|
6251
|
+
}
|
|
6252
|
+
static create(errorType) {
|
|
6253
|
+
return new ErrorNode(errorType);
|
|
6254
|
+
}
|
|
6255
|
+
getValue() {
|
|
6256
|
+
return this._errorValueObject;
|
|
6257
|
+
}
|
|
6258
|
+
};
|
|
6259
|
+
|
|
6260
|
+
//#endregion
|
|
6261
|
+
//#region src/engine/utils/generate-ast-node.ts
|
|
6262
|
+
const FORMULA_CACHE_LRU_COUNT$1 = 5e3;
|
|
6263
|
+
const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT$1);
|
|
6264
|
+
const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6265
|
+
const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
|
|
6266
|
+
function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService, subUnitId, definedNameRefOffsetX = 0, definedNameRefOffsetY = 0) {
|
|
6267
|
+
if (subUnitId) {
|
|
6268
|
+
currentConfigService.setExecuteUnitId(unitId);
|
|
6269
|
+
currentConfigService.setExecuteSubUnitId(subUnitId);
|
|
6270
|
+
}
|
|
6271
|
+
const cacheKey = `${unitId}:${subUnitId ?? currentConfigService.getExecuteSubUnitId() ?? ""}:${definedNameRefOffsetX}:${definedNameRefOffsetY}:${formulaString}`;
|
|
6272
|
+
let astNode = FORMULA_AST_CACHE.get(cacheKey);
|
|
6273
|
+
if (!(checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService)) && astNode && !isDirtyDefinedForNode(astNode, currentConfigService, unitId)) return astNode;
|
|
6274
|
+
const lexerNode = lexer.treeBuilder(formulaString, true, unitId, definedNameRefOffsetX, definedNameRefOffsetY);
|
|
6275
|
+
if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
|
|
6276
|
+
astNode = astTreeBuilder.parse(lexerNode);
|
|
6277
|
+
if (astNode == null) {
|
|
6278
|
+
console.error("generateAstNode astNode is null");
|
|
6279
|
+
return ErrorNode.create(lexerNode);
|
|
6280
|
+
}
|
|
6281
|
+
FORMULA_AST_CACHE.set(cacheKey, astNode);
|
|
6282
|
+
return astNode;
|
|
6283
|
+
}
|
|
6284
|
+
function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
|
|
6285
|
+
const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
|
|
6286
|
+
if (unitDefinedNameMap == null) return false;
|
|
6287
|
+
return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
|
|
6288
|
+
}
|
|
6289
|
+
function normalizeFormulaText(formula) {
|
|
6290
|
+
return formula.startsWith("=") ? formula.slice(1) : formula;
|
|
6291
|
+
}
|
|
6292
|
+
function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
|
|
6293
|
+
var _currentConfigService;
|
|
6294
|
+
const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
|
|
6295
|
+
const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
|
|
6296
|
+
const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
|
|
6297
|
+
if (unitSuperTableMap == null) return false;
|
|
6298
|
+
const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
|
|
6299
|
+
return (tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) ?? false;
|
|
6300
|
+
}
|
|
6301
|
+
function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
|
|
6302
|
+
let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
|
|
6303
|
+
if (normalizedNameSet == null) {
|
|
6304
|
+
normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
|
|
6305
|
+
DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
|
|
6306
|
+
}
|
|
6307
|
+
return normalizedNameSet;
|
|
6308
|
+
}
|
|
6309
|
+
function getDirtySuperTableReferencePattern(unitSuperTableMap) {
|
|
6310
|
+
let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
|
|
6311
|
+
if (tableReferencePattern === void 0) {
|
|
6312
|
+
const tableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0);
|
|
6313
|
+
tableReferencePattern = tableNames.length > 0 ? _univerjs_core.regexp.createRegExpFromSafeFragment(`(^|[^A-Za-z0-9_])${_univerjs_core.regexp.or(...tableNames)}(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
|
|
6314
|
+
DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
|
|
6315
|
+
}
|
|
6316
|
+
return tableReferencePattern;
|
|
6317
|
+
}
|
|
6318
|
+
function isDirtyDefinedForNode(node, currentConfigService, unitId) {
|
|
6319
|
+
const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
|
|
6320
|
+
const executeUnitId = unitId;
|
|
6321
|
+
if (executeUnitId != null && definedNameMap[executeUnitId] != null) {
|
|
6322
|
+
const names = Object.keys(definedNameMap[executeUnitId]);
|
|
6323
|
+
for (let i = 0, len = names.length; i < len; i++) {
|
|
6324
|
+
const name = names[i];
|
|
6325
|
+
if (node.hasDefinedName(name)) return true;
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
return false;
|
|
6329
|
+
}
|
|
6330
|
+
function includeDefinedName(tree, node, currentConfigService) {
|
|
6331
|
+
/**
|
|
6332
|
+
* Detect whether the dirty map contains a defined name.
|
|
6333
|
+
*/
|
|
6334
|
+
if (node != null) {
|
|
6335
|
+
if (isDirtyDefinedForNode(node, currentConfigService, tree.unitId)) return true;
|
|
6336
|
+
}
|
|
6337
|
+
return false;
|
|
6338
|
+
}
|
|
6339
|
+
|
|
6340
|
+
//#endregion
|
|
6341
|
+
//#region src/services/function.service.ts
|
|
6342
|
+
const IFunctionService = (0, _univerjs_core.createIdentifier)("univer.formula-function.service");
|
|
6343
|
+
var FunctionService = class extends _univerjs_core.Disposable {
|
|
6344
|
+
constructor(..._args) {
|
|
6345
|
+
super(..._args);
|
|
6346
|
+
_defineProperty(this, "_functionExecutors", /* @__PURE__ */ new Map());
|
|
6347
|
+
_defineProperty(this, "_functionDescriptions", /* @__PURE__ */ new Map());
|
|
6348
|
+
}
|
|
6349
|
+
dispose() {
|
|
6350
|
+
super.dispose();
|
|
6351
|
+
this._functionExecutors.clear();
|
|
6352
|
+
this._functionDescriptions.clear();
|
|
6353
|
+
}
|
|
6354
|
+
registerExecutors(...functions) {
|
|
6355
|
+
for (let i = 0; i < functions.length; i++) {
|
|
6356
|
+
const func = functions[i];
|
|
6357
|
+
this._functionExecutors.set(func.name, func);
|
|
6358
|
+
}
|
|
6359
|
+
}
|
|
6360
|
+
getExecutors() {
|
|
6361
|
+
return this._functionExecutors;
|
|
6362
|
+
}
|
|
6363
|
+
getExecutor(functionToken) {
|
|
6364
|
+
return this._functionExecutors.get(functionToken);
|
|
6365
|
+
}
|
|
6366
|
+
hasExecutor(functionToken) {
|
|
6367
|
+
return this._functionExecutors.has(functionToken);
|
|
6368
|
+
}
|
|
6369
|
+
unregisterExecutors(...functionTokens) {
|
|
6370
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6371
|
+
const functionToken = functionTokens[i];
|
|
6372
|
+
this._functionExecutors.delete(functionToken);
|
|
6373
|
+
}
|
|
6374
|
+
}
|
|
6375
|
+
registerDescriptions(...descriptions) {
|
|
6376
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6377
|
+
const description = descriptions[i];
|
|
6378
|
+
this._functionDescriptions.set(description.functionName, description);
|
|
6379
|
+
}
|
|
6380
|
+
return (0, _univerjs_core.toDisposable)(() => {
|
|
6381
|
+
for (let i = 0; i < descriptions.length; i++) {
|
|
6382
|
+
const description = descriptions[i];
|
|
6383
|
+
this._functionDescriptions.delete(description.functionName);
|
|
6384
|
+
}
|
|
6385
|
+
});
|
|
6386
|
+
}
|
|
6387
|
+
getDescriptions() {
|
|
6388
|
+
return this._functionDescriptions;
|
|
6389
|
+
}
|
|
6390
|
+
getDescription(functionToken) {
|
|
6391
|
+
return this._functionDescriptions.get(functionToken);
|
|
6392
|
+
}
|
|
6393
|
+
hasDescription(functionToken) {
|
|
6394
|
+
return this._functionDescriptions.has(functionToken);
|
|
6395
|
+
}
|
|
6396
|
+
unregisterDescriptions(...functionTokens) {
|
|
6397
|
+
for (let i = 0; i < functionTokens.length; i++) {
|
|
6398
|
+
const functionToken = functionTokens[i];
|
|
6399
|
+
this._functionDescriptions.delete(functionToken);
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
clearDescriptions() {
|
|
6403
|
+
this._functionDescriptions.clear();
|
|
6404
|
+
}
|
|
6405
|
+
deleteFormulaAstCacheKey(...functionToken) {
|
|
6406
|
+
FORMULA_AST_CACHE.forEach((_, key) => {
|
|
6407
|
+
functionToken.forEach((token) => {
|
|
6408
|
+
if (key.includes(token)) FORMULA_AST_CACHE.delete(key);
|
|
6409
|
+
});
|
|
6410
|
+
});
|
|
6411
|
+
}
|
|
6412
|
+
};
|
|
6413
|
+
|
|
6095
6414
|
//#endregion
|
|
6096
6415
|
//#region src/engine/analysis/lexer.ts
|
|
6097
6416
|
let Lexer = class Lexer extends _univerjs_core.Disposable {
|
|
6098
|
-
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService) {
|
|
6417
|
+
constructor(_definedNamesService, _lexerTreeBuilder, _formulaCurrentConfigService, _functionService) {
|
|
6099
6418
|
super();
|
|
6100
6419
|
this._definedNamesService = _definedNamesService;
|
|
6101
6420
|
this._lexerTreeBuilder = _lexerTreeBuilder;
|
|
6102
6421
|
this._formulaCurrentConfigService = _formulaCurrentConfigService;
|
|
6422
|
+
this._functionService = _functionService;
|
|
6103
6423
|
}
|
|
6104
|
-
treeBuilder(formulaString, transformSuffix = true, unitId) {
|
|
6424
|
+
treeBuilder(formulaString, transformSuffix = true, unitId, refOffsetX = 0, refOffsetY = 0) {
|
|
6105
6425
|
if (this._definedNamesService.getAllDefinedNamesIsEmpty()) return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix);
|
|
6106
6426
|
return this._lexerTreeBuilder.treeBuilder(formulaString, transformSuffix, {
|
|
6107
|
-
unitId: unitId
|
|
6427
|
+
unitId: unitId ?? this._formulaCurrentConfigService.getExecuteUnitId(),
|
|
6108
6428
|
sheetId: this._formulaCurrentConfigService.getExecuteSubUnitId(),
|
|
6429
|
+
refOffsetX,
|
|
6430
|
+
refOffsetY,
|
|
6431
|
+
hasFunction: this._functionService.hasExecutor.bind(this._functionService),
|
|
6109
6432
|
getValueByName: this._definedNamesService.getValueByName.bind(this._definedNamesService),
|
|
6110
6433
|
getDirtyDefinedNameMap: this._formulaCurrentConfigService.getDirtyDefinedNameMap.bind(this._formulaCurrentConfigService),
|
|
6111
6434
|
getSheetName: this._formulaCurrentConfigService.getSheetName.bind(this._formulaCurrentConfigService)
|
|
@@ -6115,13 +6438,13 @@ let Lexer = class Lexer extends _univerjs_core.Disposable {
|
|
|
6115
6438
|
Lexer = __decorate([
|
|
6116
6439
|
__decorateParam(0, IDefinedNamesService),
|
|
6117
6440
|
__decorateParam(1, (0, _univerjs_core.Inject)(LexerTreeBuilder)),
|
|
6118
|
-
__decorateParam(2, IFormulaCurrentConfigService)
|
|
6441
|
+
__decorateParam(2, IFormulaCurrentConfigService),
|
|
6442
|
+
__decorateParam(3, IFunctionService)
|
|
6119
6443
|
], Lexer);
|
|
6120
6444
|
|
|
6121
6445
|
//#endregion
|
|
6122
6446
|
//#region src/engine/utils/cell.ts
|
|
6123
6447
|
function getCellValue(cell) {
|
|
6124
|
-
var _cell$v;
|
|
6125
6448
|
if (cell === null) return 0;
|
|
6126
6449
|
if (cell === null || cell === void 0 ? void 0 : cell.p) {
|
|
6127
6450
|
const body = cell === null || cell === void 0 ? void 0 : cell.p.body;
|
|
@@ -6129,7 +6452,7 @@ function getCellValue(cell) {
|
|
|
6129
6452
|
const data = body.dataStream;
|
|
6130
6453
|
return normalizeRichTextFormulaValue(_univerjs_core.BuildTextUtils.transform.getPlainText(data));
|
|
6131
6454
|
}
|
|
6132
|
-
return (
|
|
6455
|
+
return (cell === null || cell === void 0 ? void 0 : cell.v) ?? 0;
|
|
6133
6456
|
}
|
|
6134
6457
|
function normalizeRichTextFormulaValue(value) {
|
|
6135
6458
|
return value.replace(/\r\n|\r|\n/g, "\r\n");
|
|
@@ -7295,9 +7618,8 @@ var StringValueObject = class StringValueObject extends BaseValueObject {
|
|
|
7295
7618
|
if (cached && options && this.checkCacheByOptions(cached, options)) return cached;
|
|
7296
7619
|
const instance = new StringValueObject(value);
|
|
7297
7620
|
if (options === null || options === void 0 ? void 0 : options.isHyperlink) {
|
|
7298
|
-
var _options$hyperlinkUrl;
|
|
7299
7621
|
instance._isHyperlink = options.isHyperlink;
|
|
7300
|
-
instance._hyperlinkUrl =
|
|
7622
|
+
instance._hyperlinkUrl = options.hyperlinkUrl ?? "";
|
|
7301
7623
|
}
|
|
7302
7624
|
if (options === null || options === void 0 ? void 0 : options.isImage) {
|
|
7303
7625
|
instance._isImage = options.isImage;
|
|
@@ -8605,6 +8927,7 @@ var ValueObjectFactory = class {
|
|
|
8605
8927
|
const rawValueUpper = rawValue.toLocaleUpperCase().trim();
|
|
8606
8928
|
if (ERROR_TYPE_SET.has(rawValueUpper)) return ErrorValueObject.create(rawValueUpper);
|
|
8607
8929
|
if (rawValueUpper === "TRUE" || rawValueUpper === "FALSE") return createBooleanValueObjectByRawValue(rawValue);
|
|
8930
|
+
if (isStringWrappedByDoubleQuotes(rawValue)) return createStringValueObjectByRawValue(rawValue);
|
|
8608
8931
|
if ((0, _univerjs_core.isRealNum)(rawValue) && Number(rawValue).toString() === rawValue.trim()) return NumberValueObject.create(Number(rawValue));
|
|
8609
8932
|
if (!isIgnoreNumberPattern) {
|
|
8610
8933
|
const { isNumberPattern, value, pattern } = stringIsNumberPattern(rawValue);
|
|
@@ -8625,8 +8948,8 @@ function isStringWrappedByDoubleQuotes(input) {
|
|
|
8625
8948
|
|
|
8626
8949
|
//#endregion
|
|
8627
8950
|
//#region src/engine/reference-object/base-reference-object.ts
|
|
8628
|
-
const FORMULA_CACHE_LRU_COUNT
|
|
8629
|
-
const FORMULA_REF_TO_ARRAY_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT
|
|
8951
|
+
const FORMULA_CACHE_LRU_COUNT = 1e4;
|
|
8952
|
+
const FORMULA_REF_TO_ARRAY_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
|
|
8630
8953
|
var BaseReferenceObject = class extends ObjectClassType {
|
|
8631
8954
|
constructor(_token) {
|
|
8632
8955
|
super();
|
|
@@ -8984,11 +9307,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
8984
9307
|
return getRuntimeFeatureCell(row, column, this.getSheetId(), this.getUnitId(), this._runtimeFeatureCellData);
|
|
8985
9308
|
}
|
|
8986
9309
|
getCellByPosition(rowRaw, columnRaw) {
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
const
|
|
8990
|
-
if (!row) row = rangeData.startRow;
|
|
8991
|
-
if (!column) column = rangeData.startColumn;
|
|
9310
|
+
const range = this.getRangePosition();
|
|
9311
|
+
const row = rowRaw ?? range.startRow;
|
|
9312
|
+
const column = columnRaw ?? range.startColumn;
|
|
8992
9313
|
const cell = this.getCellData(row, column);
|
|
8993
9314
|
if (!cell) return NullValueObject.create();
|
|
8994
9315
|
return this.getCellValueObject(cell);
|
|
@@ -9058,6 +9379,9 @@ var BaseReferenceObject = class extends ObjectClassType {
|
|
|
9058
9379
|
unitId: this.getUnitId()
|
|
9059
9380
|
};
|
|
9060
9381
|
}
|
|
9382
|
+
toUnitRanges() {
|
|
9383
|
+
return [this.toUnitRange()];
|
|
9384
|
+
}
|
|
9061
9385
|
_checkIfWorksheetMiss() {
|
|
9062
9386
|
if ((this._forcedSheetId == null || this._forcedSheetId.length === 0) && this._forcedSheetName.length > 0) return true;
|
|
9063
9387
|
return false;
|
|
@@ -9326,7 +9650,7 @@ function expandArrayValueObject(rowCount, columnCount, valueObject, defaultValue
|
|
|
9326
9650
|
continue;
|
|
9327
9651
|
}
|
|
9328
9652
|
if (r >= valueRowCount || c >= valueColumnCount) {
|
|
9329
|
-
row.push(defaultValue
|
|
9653
|
+
row.push(defaultValue ?? NullValueObject.create());
|
|
9330
9654
|
continue;
|
|
9331
9655
|
}
|
|
9332
9656
|
const value = valueObject.get(r, c);
|
|
@@ -9664,8 +9988,11 @@ function filterSameValueObjectResult(array, range, criteria) {
|
|
|
9664
9988
|
return array.mapValue((valueObject, r, c) => {
|
|
9665
9989
|
const rangeValueObject = range.get(r, c);
|
|
9666
9990
|
const isBlankStringCriteria = criteriaObject.isString() && criteriaObject.getValue() === "";
|
|
9991
|
+
if (isBlankStringCriteria && (operator === ">" || operator === ">=" || operator === "<" || operator === "<=")) return BooleanValueObject.create(false);
|
|
9667
9992
|
if (operator === "<>" && isBlankStringCriteria && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
9668
|
-
if (criteriaObject.isString() && criteriaObject.getValue()
|
|
9993
|
+
if (criteriaObject.isString() && isWildcard(`${criteriaObject.getValue()}`) && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return valueObject;
|
|
9994
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && rangeValueObject.getValue() === "") return BooleanValueObject.create(true);
|
|
9995
|
+
if (criteriaObject.isString() && criteriaObject.getValue() !== "" && (operator === "<" || operator === "<=") && (rangeValueObject == null || rangeValueObject.isNull())) return BooleanValueObject.create(false);
|
|
9669
9996
|
if (criteriaObject.isString() && (rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isString()) && (operator === "<" || operator === "<=") && isSameLowerBoundBucket(rangeValueObject.getValue(), criteriaObject.getValue())) return BooleanValueObject.create(false);
|
|
9670
9997
|
if ((rangeValueObject === null || rangeValueObject === void 0 ? void 0 : rangeValueObject.isNumber()) && criteriaObject.isString()) {
|
|
9671
9998
|
const criteriaNumber = criteriaObject.convertToNumberObjectValue();
|
|
@@ -9834,12 +10161,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
9834
10161
|
return this._currentColumn;
|
|
9835
10162
|
}
|
|
9836
10163
|
get currentRowCount() {
|
|
9837
|
-
var _this$_functionRefInf
|
|
9838
|
-
return (_this$_functionRefInf =
|
|
10164
|
+
var _this$_functionRefInf;
|
|
10165
|
+
return ((_this$_functionRefInf = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf === void 0 ? void 0 : _this$_functionRefInf.rowCount) ?? this._currentRowCount;
|
|
9839
10166
|
}
|
|
9840
10167
|
get currentColumnCount() {
|
|
9841
|
-
var _this$
|
|
9842
|
-
return (
|
|
10168
|
+
var _this$_functionRefInf2;
|
|
10169
|
+
return ((_this$_functionRefInf2 = this._functionRefInfoOverrideStack[this._functionRefInfoOverrideStack.length - 1]) === null || _this$_functionRefInf2 === void 0 ? void 0 : _this$_functionRefInf2.columnCount) ?? this._currentColumnCount;
|
|
9843
10170
|
}
|
|
9844
10171
|
get currentSubUnitId() {
|
|
9845
10172
|
return this._currentSubUnitId;
|
|
@@ -10275,151 +10602,6 @@ let FormulaRuntimeService = class FormulaRuntimeService extends _univerjs_core.D
|
|
|
10275
10602
|
FormulaRuntimeService = __decorate([__decorateParam(0, IFormulaCurrentConfigService), __decorateParam(1, IHyperlinkEngineFormulaService)], FormulaRuntimeService);
|
|
10276
10603
|
const IFormulaRuntimeService = (0, _univerjs_core.createIdentifier)("univer.formula.runtime.service");
|
|
10277
10604
|
|
|
10278
|
-
//#endregion
|
|
10279
|
-
//#region src/engine/ast-node/node-type.ts
|
|
10280
|
-
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
10281
|
-
[1, 7],
|
|
10282
|
-
[2, 9],
|
|
10283
|
-
[3, 8],
|
|
10284
|
-
[4, 6],
|
|
10285
|
-
[5, 1],
|
|
10286
|
-
[6, 2],
|
|
10287
|
-
[9, 10],
|
|
10288
|
-
[10, 3],
|
|
10289
|
-
[11, 4],
|
|
10290
|
-
[12, 5]
|
|
10291
|
-
]);
|
|
10292
|
-
|
|
10293
|
-
//#endregion
|
|
10294
|
-
//#region src/engine/ast-node/base-ast-node.ts
|
|
10295
|
-
var BaseAstNode = class {
|
|
10296
|
-
constructor(_token) {
|
|
10297
|
-
this._token = _token;
|
|
10298
|
-
_defineProperty(this, "_children", []);
|
|
10299
|
-
_defineProperty(this, "_definedNames", void 0);
|
|
10300
|
-
_defineProperty(this, "_parent", void 0);
|
|
10301
|
-
_defineProperty(this, "_valueObject", void 0);
|
|
10302
|
-
_defineProperty(this, "_calculateState", false);
|
|
10303
|
-
_defineProperty(this, "_async", false);
|
|
10304
|
-
_defineProperty(this, "_address", false);
|
|
10305
|
-
_defineProperty(this, "_isForcedCalculateFunction", false);
|
|
10306
|
-
}
|
|
10307
|
-
dispose() {
|
|
10308
|
-
var _this$_valueObject;
|
|
10309
|
-
this._children.forEach((node) => {
|
|
10310
|
-
node.dispose();
|
|
10311
|
-
});
|
|
10312
|
-
(_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
|
|
10313
|
-
this._valueObject = null;
|
|
10314
|
-
this._children = [];
|
|
10315
|
-
this._definedNames = null;
|
|
10316
|
-
this._parent = null;
|
|
10317
|
-
}
|
|
10318
|
-
get nodeType() {
|
|
10319
|
-
return 8;
|
|
10320
|
-
}
|
|
10321
|
-
resetCalculationState() {
|
|
10322
|
-
this._children.forEach((node) => {
|
|
10323
|
-
node.resetCalculationState();
|
|
10324
|
-
});
|
|
10325
|
-
this._valueObject = null;
|
|
10326
|
-
this._calculateState = false;
|
|
10327
|
-
}
|
|
10328
|
-
isAsync() {
|
|
10329
|
-
return this._async;
|
|
10330
|
-
}
|
|
10331
|
-
isAddress() {
|
|
10332
|
-
return this._address;
|
|
10333
|
-
}
|
|
10334
|
-
isForcedCalculateFunction() {
|
|
10335
|
-
return this._isForcedCalculateFunction;
|
|
10336
|
-
}
|
|
10337
|
-
setAsync() {
|
|
10338
|
-
this._async = true;
|
|
10339
|
-
}
|
|
10340
|
-
setAddress() {
|
|
10341
|
-
this._address = true;
|
|
10342
|
-
}
|
|
10343
|
-
getParent() {
|
|
10344
|
-
return this._parent;
|
|
10345
|
-
}
|
|
10346
|
-
setParent(node) {
|
|
10347
|
-
this._parent = node;
|
|
10348
|
-
node.addChildren(this);
|
|
10349
|
-
}
|
|
10350
|
-
setForcedCalculateFunction() {
|
|
10351
|
-
this._isForcedCalculateFunction = true;
|
|
10352
|
-
}
|
|
10353
|
-
getChildren() {
|
|
10354
|
-
return this._children;
|
|
10355
|
-
}
|
|
10356
|
-
addChildren(...astNode) {
|
|
10357
|
-
this._children.push(...astNode);
|
|
10358
|
-
}
|
|
10359
|
-
getToken() {
|
|
10360
|
-
return this._token;
|
|
10361
|
-
}
|
|
10362
|
-
setValue(value) {
|
|
10363
|
-
this._valueObject = value;
|
|
10364
|
-
}
|
|
10365
|
-
getValue() {
|
|
10366
|
-
return this._valueObject;
|
|
10367
|
-
}
|
|
10368
|
-
isCalculated() {
|
|
10369
|
-
return this._calculateState;
|
|
10370
|
-
}
|
|
10371
|
-
setCalculated() {
|
|
10372
|
-
this._calculateState = true;
|
|
10373
|
-
}
|
|
10374
|
-
execute() {}
|
|
10375
|
-
setNotEmpty(state = true) {}
|
|
10376
|
-
async executeAsync() {
|
|
10377
|
-
return Promise.resolve(0);
|
|
10378
|
-
}
|
|
10379
|
-
serialize() {
|
|
10380
|
-
const token = this.getToken();
|
|
10381
|
-
const children = this.getChildren();
|
|
10382
|
-
const childrenSerialization = [];
|
|
10383
|
-
const childrenCount = children.length;
|
|
10384
|
-
for (let i = 0; i < childrenCount; i++) {
|
|
10385
|
-
const item = children[i];
|
|
10386
|
-
childrenSerialization.push(item.serialize());
|
|
10387
|
-
}
|
|
10388
|
-
const result = {
|
|
10389
|
-
token,
|
|
10390
|
-
nodeType: this.nodeType
|
|
10391
|
-
};
|
|
10392
|
-
if (childrenCount > 0) result.children = childrenSerialization;
|
|
10393
|
-
return result;
|
|
10394
|
-
}
|
|
10395
|
-
hasDefinedName(definedName) {
|
|
10396
|
-
var _this$_definedNames;
|
|
10397
|
-
return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
|
|
10398
|
-
}
|
|
10399
|
-
setDefinedNames(definedNames) {
|
|
10400
|
-
this._definedNames = definedNames;
|
|
10401
|
-
}
|
|
10402
|
-
getDefinedNames() {
|
|
10403
|
-
return this._definedNames;
|
|
10404
|
-
}
|
|
10405
|
-
};
|
|
10406
|
-
var ErrorNode = class ErrorNode extends BaseAstNode {
|
|
10407
|
-
constructor(errorType) {
|
|
10408
|
-
super(errorType);
|
|
10409
|
-
_defineProperty(this, "_errorValueObject", void 0);
|
|
10410
|
-
this._errorValueObject = ErrorValueObject.create(errorType);
|
|
10411
|
-
}
|
|
10412
|
-
get nodeType() {
|
|
10413
|
-
return 7;
|
|
10414
|
-
}
|
|
10415
|
-
static create(errorType) {
|
|
10416
|
-
return new ErrorNode(errorType);
|
|
10417
|
-
}
|
|
10418
|
-
getValue() {
|
|
10419
|
-
return this._errorValueObject;
|
|
10420
|
-
}
|
|
10421
|
-
};
|
|
10422
|
-
|
|
10423
10605
|
//#endregion
|
|
10424
10606
|
//#region src/engine/ast-node/base-ast-node-factory.ts
|
|
10425
10607
|
var BaseAstNodeFactory = class {
|
|
@@ -10485,161 +10667,6 @@ const COLUMN_LIKE_FUNCTION_NAMES = new Set(ALL_GROUPS.flatMap((g) => Object.valu
|
|
|
10485
10667
|
return idx > 0 && idx <= _univerjs_core.MAX_COLUMN_COUNT;
|
|
10486
10668
|
}));
|
|
10487
10669
|
|
|
10488
|
-
//#endregion
|
|
10489
|
-
//#region src/engine/utils/generate-ast-node.ts
|
|
10490
|
-
const FORMULA_CACHE_LRU_COUNT = 5e3;
|
|
10491
|
-
const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
|
|
10492
|
-
const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10493
|
-
const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
|
|
10494
|
-
function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService, subUnitId) {
|
|
10495
|
-
var _ref;
|
|
10496
|
-
if (subUnitId) {
|
|
10497
|
-
currentConfigService.setExecuteUnitId(unitId);
|
|
10498
|
-
currentConfigService.setExecuteSubUnitId(subUnitId);
|
|
10499
|
-
}
|
|
10500
|
-
const cacheKey = `${unitId}:${(_ref = subUnitId !== null && subUnitId !== void 0 ? subUnitId : currentConfigService.getExecuteSubUnitId()) !== null && _ref !== void 0 ? _ref : ""}:${formulaString}`;
|
|
10501
|
-
let astNode = FORMULA_AST_CACHE.get(cacheKey);
|
|
10502
|
-
if (!(checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService)) && astNode && !isDirtyDefinedForNode(astNode, currentConfigService, unitId)) return astNode;
|
|
10503
|
-
const lexerNode = lexer.treeBuilder(formulaString, true, unitId);
|
|
10504
|
-
if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
|
|
10505
|
-
astNode = astTreeBuilder.parse(lexerNode);
|
|
10506
|
-
if (astNode == null) {
|
|
10507
|
-
console.error("generateAstNode astNode is null");
|
|
10508
|
-
return ErrorNode.create(lexerNode);
|
|
10509
|
-
}
|
|
10510
|
-
FORMULA_AST_CACHE.set(cacheKey, astNode);
|
|
10511
|
-
return astNode;
|
|
10512
|
-
}
|
|
10513
|
-
function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
|
|
10514
|
-
const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
|
|
10515
|
-
if (unitDefinedNameMap == null) return false;
|
|
10516
|
-
return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
|
|
10517
|
-
}
|
|
10518
|
-
function normalizeFormulaText(formula) {
|
|
10519
|
-
return formula.startsWith("=") ? formula.slice(1) : formula;
|
|
10520
|
-
}
|
|
10521
|
-
function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
|
|
10522
|
-
var _currentConfigService, _tableReferencePatter;
|
|
10523
|
-
const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
|
|
10524
|
-
const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
|
|
10525
|
-
const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
|
|
10526
|
-
if (unitSuperTableMap == null) return false;
|
|
10527
|
-
const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
|
|
10528
|
-
return (_tableReferencePatter = tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) !== null && _tableReferencePatter !== void 0 ? _tableReferencePatter : false;
|
|
10529
|
-
}
|
|
10530
|
-
function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
|
|
10531
|
-
let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
|
|
10532
|
-
if (normalizedNameSet == null) {
|
|
10533
|
-
normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
|
|
10534
|
-
DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
|
|
10535
|
-
}
|
|
10536
|
-
return normalizedNameSet;
|
|
10537
|
-
}
|
|
10538
|
-
function getDirtySuperTableReferencePattern(unitSuperTableMap) {
|
|
10539
|
-
let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
|
|
10540
|
-
if (tableReferencePattern === void 0) {
|
|
10541
|
-
const tableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0);
|
|
10542
|
-
tableReferencePattern = tableNames.length > 0 ? _univerjs_core.regexp.createRegExpFromSafeFragment(`(^|[^A-Za-z0-9_])${_univerjs_core.regexp.or(...tableNames)}(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
|
|
10543
|
-
DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
|
|
10544
|
-
}
|
|
10545
|
-
return tableReferencePattern;
|
|
10546
|
-
}
|
|
10547
|
-
function isDirtyDefinedForNode(node, currentConfigService, unitId) {
|
|
10548
|
-
const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
|
|
10549
|
-
const executeUnitId = unitId;
|
|
10550
|
-
if (executeUnitId != null && definedNameMap[executeUnitId] != null) {
|
|
10551
|
-
const names = Object.keys(definedNameMap[executeUnitId]);
|
|
10552
|
-
for (let i = 0, len = names.length; i < len; i++) {
|
|
10553
|
-
const name = names[i];
|
|
10554
|
-
if (node.hasDefinedName(name)) return true;
|
|
10555
|
-
}
|
|
10556
|
-
}
|
|
10557
|
-
return false;
|
|
10558
|
-
}
|
|
10559
|
-
function includeDefinedName(tree, node, currentConfigService) {
|
|
10560
|
-
/**
|
|
10561
|
-
* Detect whether the dirty map contains a defined name.
|
|
10562
|
-
*/
|
|
10563
|
-
if (node != null) {
|
|
10564
|
-
if (isDirtyDefinedForNode(node, currentConfigService, tree.unitId)) return true;
|
|
10565
|
-
}
|
|
10566
|
-
return false;
|
|
10567
|
-
}
|
|
10568
|
-
|
|
10569
|
-
//#endregion
|
|
10570
|
-
//#region src/services/function.service.ts
|
|
10571
|
-
const IFunctionService = (0, _univerjs_core.createIdentifier)("univer.formula-function.service");
|
|
10572
|
-
var FunctionService = class extends _univerjs_core.Disposable {
|
|
10573
|
-
constructor(..._args) {
|
|
10574
|
-
super(..._args);
|
|
10575
|
-
_defineProperty(this, "_functionExecutors", /* @__PURE__ */ new Map());
|
|
10576
|
-
_defineProperty(this, "_functionDescriptions", /* @__PURE__ */ new Map());
|
|
10577
|
-
}
|
|
10578
|
-
dispose() {
|
|
10579
|
-
super.dispose();
|
|
10580
|
-
this._functionExecutors.clear();
|
|
10581
|
-
this._functionDescriptions.clear();
|
|
10582
|
-
}
|
|
10583
|
-
registerExecutors(...functions) {
|
|
10584
|
-
for (let i = 0; i < functions.length; i++) {
|
|
10585
|
-
const func = functions[i];
|
|
10586
|
-
this._functionExecutors.set(func.name, func);
|
|
10587
|
-
}
|
|
10588
|
-
}
|
|
10589
|
-
getExecutors() {
|
|
10590
|
-
return this._functionExecutors;
|
|
10591
|
-
}
|
|
10592
|
-
getExecutor(functionToken) {
|
|
10593
|
-
return this._functionExecutors.get(functionToken);
|
|
10594
|
-
}
|
|
10595
|
-
hasExecutor(functionToken) {
|
|
10596
|
-
return this._functionExecutors.has(functionToken);
|
|
10597
|
-
}
|
|
10598
|
-
unregisterExecutors(...functionTokens) {
|
|
10599
|
-
for (let i = 0; i < functionTokens.length; i++) {
|
|
10600
|
-
const functionToken = functionTokens[i];
|
|
10601
|
-
this._functionExecutors.delete(functionToken);
|
|
10602
|
-
}
|
|
10603
|
-
}
|
|
10604
|
-
registerDescriptions(...descriptions) {
|
|
10605
|
-
for (let i = 0; i < descriptions.length; i++) {
|
|
10606
|
-
const description = descriptions[i];
|
|
10607
|
-
this._functionDescriptions.set(description.functionName, description);
|
|
10608
|
-
}
|
|
10609
|
-
return (0, _univerjs_core.toDisposable)(() => {
|
|
10610
|
-
for (let i = 0; i < descriptions.length; i++) {
|
|
10611
|
-
const description = descriptions[i];
|
|
10612
|
-
this._functionDescriptions.delete(description.functionName);
|
|
10613
|
-
}
|
|
10614
|
-
});
|
|
10615
|
-
}
|
|
10616
|
-
getDescriptions() {
|
|
10617
|
-
return this._functionDescriptions;
|
|
10618
|
-
}
|
|
10619
|
-
getDescription(functionToken) {
|
|
10620
|
-
return this._functionDescriptions.get(functionToken);
|
|
10621
|
-
}
|
|
10622
|
-
hasDescription(functionToken) {
|
|
10623
|
-
return this._functionDescriptions.has(functionToken);
|
|
10624
|
-
}
|
|
10625
|
-
unregisterDescriptions(...functionTokens) {
|
|
10626
|
-
for (let i = 0; i < functionTokens.length; i++) {
|
|
10627
|
-
const functionToken = functionTokens[i];
|
|
10628
|
-
this._functionDescriptions.delete(functionToken);
|
|
10629
|
-
}
|
|
10630
|
-
}
|
|
10631
|
-
clearDescriptions() {
|
|
10632
|
-
this._functionDescriptions.clear();
|
|
10633
|
-
}
|
|
10634
|
-
deleteFormulaAstCacheKey(...functionToken) {
|
|
10635
|
-
FORMULA_AST_CACHE.forEach((_, key) => {
|
|
10636
|
-
functionToken.forEach((token) => {
|
|
10637
|
-
if (key.includes(token)) FORMULA_AST_CACHE.delete(key);
|
|
10638
|
-
});
|
|
10639
|
-
});
|
|
10640
|
-
}
|
|
10641
|
-
};
|
|
10642
|
-
|
|
10643
10670
|
//#endregion
|
|
10644
10671
|
//#region src/services/unit-reference-resolver.service.ts
|
|
10645
10672
|
const IFormulaUnitReferenceResolver = (0, _univerjs_core.createIdentifier)("univer.formula.unit-reference-resolver");
|
|
@@ -10711,7 +10738,8 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10711
10738
|
this.setValue(result);
|
|
10712
10739
|
}
|
|
10713
10740
|
_handlerAT(value) {
|
|
10714
|
-
if (
|
|
10741
|
+
if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
|
|
10742
|
+
if (!value.isReferenceObject()) return value;
|
|
10715
10743
|
const currentValue = value;
|
|
10716
10744
|
if (currentValue.isCell()) return ErrorValueObject.create("#VALUE!");
|
|
10717
10745
|
if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
|
|
@@ -10731,7 +10759,7 @@ var PrefixNode = class extends BaseAstNode {
|
|
|
10731
10759
|
let parent = node.getParent();
|
|
10732
10760
|
let sawCompareOperator = false;
|
|
10733
10761
|
while (parent != null) {
|
|
10734
|
-
if (parent.nodeType === 3) sawCompareOperator
|
|
10762
|
+
if (parent.nodeType === 3) sawCompareOperator ||= OPERATOR_TOKEN_COMPARE_SET.has(parent.getToken());
|
|
10735
10763
|
if (parent.nodeType === 4) {
|
|
10736
10764
|
const functionName = parent.getToken().toUpperCase();
|
|
10737
10765
|
if (sawCompareOperator && functionName === "XMATCH") return parent.getChildren().indexOf(node) === 1;
|
|
@@ -10817,6 +10845,9 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10817
10845
|
get nodeType() {
|
|
10818
10846
|
return 4;
|
|
10819
10847
|
}
|
|
10848
|
+
preservesLazyIfReferenceArray(child) {
|
|
10849
|
+
return this._functionExecutor.lazyIfReferenceArrayArgumentIndexes.includes(this.getChildren().indexOf(child));
|
|
10850
|
+
}
|
|
10820
10851
|
async executeAsync() {
|
|
10821
10852
|
const children = this.getChildren();
|
|
10822
10853
|
this._compatibility();
|
|
@@ -10966,10 +10997,7 @@ var FunctionNode = class extends BaseAstNode {
|
|
|
10966
10997
|
if (minParams !== -1 && maxParams !== -1 && (children.length < minParams || children.length > maxParams)) return ErrorValueObject.create("#N/A");
|
|
10967
10998
|
this._setRefInfo();
|
|
10968
10999
|
this._handleAddressFunction();
|
|
10969
|
-
return this._functionExecutor.calculateAst(children, (node) =>
|
|
10970
|
-
var _this$_getChildVarian;
|
|
10971
|
-
return (_this$_getChildVarian = this._getChildVariant(node)) !== null && _this$_getChildVarian !== void 0 ? _this$_getChildVarian : null;
|
|
10972
|
-
});
|
|
11000
|
+
return this._functionExecutor.calculateAst(children, (node) => this._getChildVariant(node) ?? null);
|
|
10973
11001
|
}
|
|
10974
11002
|
async _calculateAsync(variants) {
|
|
10975
11003
|
const { minParams, maxParams } = this._functionExecutor;
|
|
@@ -11241,7 +11269,6 @@ let Interpreter = class Interpreter extends _univerjs_core.Disposable {
|
|
|
11241
11269
|
return true;
|
|
11242
11270
|
}
|
|
11243
11271
|
async _executeLazyIfErrorAsync(node, refOffsetX, refOffsetY) {
|
|
11244
|
-
var _children$1$getValue;
|
|
11245
11272
|
const children = node.getChildren();
|
|
11246
11273
|
if (children.length !== 2) return false;
|
|
11247
11274
|
await this._executeAsync(children[0], refOffsetX, refOffsetY);
|
|
@@ -11253,11 +11280,10 @@ let Interpreter = class Interpreter extends _univerjs_core.Disposable {
|
|
|
11253
11280
|
return true;
|
|
11254
11281
|
}
|
|
11255
11282
|
await this._executeAsync(children[1], refOffsetX, refOffsetY);
|
|
11256
|
-
node.setValue(
|
|
11283
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11257
11284
|
return true;
|
|
11258
11285
|
}
|
|
11259
11286
|
_executeLazyIfError(node, refOffsetX, refOffsetY) {
|
|
11260
|
-
var _children$1$getValue2;
|
|
11261
11287
|
const children = node.getChildren();
|
|
11262
11288
|
if (children.length !== 2) return false;
|
|
11263
11289
|
this._execute(children[0], refOffsetX, refOffsetY);
|
|
@@ -11269,7 +11295,7 @@ let Interpreter = class Interpreter extends _univerjs_core.Disposable {
|
|
|
11269
11295
|
return true;
|
|
11270
11296
|
}
|
|
11271
11297
|
this._execute(children[1], refOffsetX, refOffsetY);
|
|
11272
|
-
node.setValue(
|
|
11298
|
+
node.setValue(children[1].getValue() ?? ErrorValueObject.create("#VALUE!"));
|
|
11273
11299
|
return true;
|
|
11274
11300
|
}
|
|
11275
11301
|
_toLazyIfErrorValue(value) {
|
|
@@ -11285,12 +11311,13 @@ let Interpreter = class Interpreter extends _univerjs_core.Disposable {
|
|
|
11285
11311
|
}
|
|
11286
11312
|
_toLazyIfSelectedValue(value, node) {
|
|
11287
11313
|
if (value == null) return ErrorValueObject.create("#VALUE!");
|
|
11314
|
+
const preserveArray = this._preserveLazyIfSelectedReferenceArray(node);
|
|
11288
11315
|
if (value.isReferenceObject()) {
|
|
11289
11316
|
const reference = value;
|
|
11290
|
-
if (
|
|
11317
|
+
if (preserveArray) return reference.toArrayValueObject();
|
|
11291
11318
|
value = this._implicitLazyIfReferenceValue(reference);
|
|
11292
11319
|
}
|
|
11293
|
-
if (value.isArray()) value = this._implicitLazyIfArrayValue(value);
|
|
11320
|
+
if (value.isArray() && !preserveArray) value = this._implicitLazyIfArrayValue(value);
|
|
11294
11321
|
if (!value.isArray()) {
|
|
11295
11322
|
const baseValue = value;
|
|
11296
11323
|
return baseValue.isNull() ? NumberValueObject.create(0) : baseValue;
|
|
@@ -11311,7 +11338,7 @@ let Interpreter = class Interpreter extends _univerjs_core.Disposable {
|
|
|
11311
11338
|
let child = node;
|
|
11312
11339
|
let parent = child.getParent();
|
|
11313
11340
|
while (parent != null) {
|
|
11314
|
-
if (parent.nodeType === 4) return parent.
|
|
11341
|
+
if (parent.nodeType === 4) return parent.preservesLazyIfReferenceArray(child);
|
|
11315
11342
|
child = parent;
|
|
11316
11343
|
parent = parent.getParent();
|
|
11317
11344
|
}
|
|
@@ -11884,10 +11911,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11884
11911
|
* - Has comma: Left is Section, right is column/column range
|
|
11885
11912
|
*/
|
|
11886
11913
|
_parseStructuredRef(raw, titleMap) {
|
|
11887
|
-
var _range$startColumn, _range$endColumn;
|
|
11888
11914
|
const { range } = this._tableData;
|
|
11889
|
-
const fullStartCol =
|
|
11890
|
-
const fullEndCol =
|
|
11915
|
+
const fullStartCol = range.startColumn ?? 0;
|
|
11916
|
+
const fullEndCol = range.endColumn ?? 0;
|
|
11891
11917
|
if (!raw || raw.trim().length === 0) return {
|
|
11892
11918
|
startColumn: fullStartCol,
|
|
11893
11919
|
endColumn: fullEndCol,
|
|
@@ -11939,6 +11965,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11939
11965
|
const sectionRaw = body.slice(0, commaAt).trim();
|
|
11940
11966
|
const columnsRaw = body.slice(commaAt + 1).trim();
|
|
11941
11967
|
const section = this._parseSectionMaybeBracketed(sectionRaw);
|
|
11968
|
+
if (section === void 0) {
|
|
11969
|
+
const { startColumn, endColumn } = this._parseColumnOrRange(body, titleMap, fullStartCol);
|
|
11970
|
+
return {
|
|
11971
|
+
startColumn,
|
|
11972
|
+
endColumn,
|
|
11973
|
+
type: "#Data"
|
|
11974
|
+
};
|
|
11975
|
+
}
|
|
11942
11976
|
const { startColumn, endColumn } = this._parseColumnOrRange(columnsRaw, titleMap, fullStartCol);
|
|
11943
11977
|
return {
|
|
11944
11978
|
startColumn,
|
|
@@ -11967,13 +12001,12 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11967
12001
|
}
|
|
11968
12002
|
/**
|
|
11969
12003
|
* Parse Section, compatible with both "[#Data]" and "#Data" inputs
|
|
11970
|
-
* Returns TableOptionType if matched; returns
|
|
12004
|
+
* Returns TableOptionType if matched; returns undefined when the comma belongs to a column title.
|
|
11971
12005
|
*/
|
|
11972
12006
|
_parseSectionMaybeBracketed(raw) {
|
|
11973
12007
|
const x = raw.trim();
|
|
11974
12008
|
const inner = x.startsWith("[") && x.endsWith("]") ? this._stripOuterBracketOnce(x) : x;
|
|
11975
|
-
|
|
11976
|
-
return typeMaybe !== null && typeMaybe !== void 0 ? typeMaybe : "#Data";
|
|
12009
|
+
return this._mapSection(inner);
|
|
11977
12010
|
}
|
|
11978
12011
|
/**
|
|
11979
12012
|
* Section mapping: Only accepts keywords starting with #.
|
|
@@ -11998,6 +12031,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
|
|
|
11998
12031
|
*/
|
|
11999
12032
|
_parseColumnOrRange(raw, titleMap, fullStartCol) {
|
|
12000
12033
|
const s = raw.trim();
|
|
12034
|
+
const singleColumnIndex = this._titleToIndex(this._stripOuterBracketIfAny(s), titleMap);
|
|
12035
|
+
if (singleColumnIndex !== -1) {
|
|
12036
|
+
const column = fullStartCol + singleColumnIndex;
|
|
12037
|
+
return {
|
|
12038
|
+
startColumn: column,
|
|
12039
|
+
endColumn: column
|
|
12040
|
+
};
|
|
12041
|
+
}
|
|
12001
12042
|
const colonAt = this._findColonAtTopLevel(s);
|
|
12002
12043
|
if (colonAt === -1) {
|
|
12003
12044
|
const name = this._stripOuterBracketIfAny(s);
|
|
@@ -12239,12 +12280,11 @@ let ReferenceNodeFactory = class ReferenceNodeFactory extends BaseAstNodeFactory
|
|
|
12239
12280
|
return this._superTableService.getTableMap(unitId);
|
|
12240
12281
|
}
|
|
12241
12282
|
_getNode(tokenTrim, isLexerNode, isPrepareMerge, param) {
|
|
12242
|
-
var _tableMap$has;
|
|
12243
12283
|
const currentConfigService = this._currentConfigService;
|
|
12244
12284
|
const runtimeService = this._formulaRuntimeService;
|
|
12245
12285
|
const makeRef = (type) => new ReferenceNode(currentConfigService, runtimeService, tokenTrim, type, this._unitReferenceResolver, this._superTableService, this._externalReferenceDataLoader, isPrepareMerge);
|
|
12246
12286
|
const tableMap = this._getTableMap();
|
|
12247
|
-
if ((
|
|
12287
|
+
if ((tableMap === null || tableMap === void 0 ? void 0 : tableMap.has(tokenTrim)) ?? false) return this._getTableReferenceNode(tokenTrim, isPrepareMerge, true);
|
|
12248
12288
|
if (regexTestSingeRange(tokenTrim)) return makeRef(0);
|
|
12249
12289
|
const parentIsUnion = isLexerNode && this._checkParentIsUnionOperator(param);
|
|
12250
12290
|
if (parentIsUnion && regexTestSingleRow(tokenTrim)) return makeRef(2);
|
|
@@ -12359,11 +12399,253 @@ SuffixNodeFactory = __decorate([
|
|
|
12359
12399
|
__decorateParam(2, IFormulaCurrentConfigService)
|
|
12360
12400
|
], SuffixNodeFactory);
|
|
12361
12401
|
|
|
12402
|
+
//#endregion
|
|
12403
|
+
//#region src/engine/reference-object/multi-area-reference-object.ts
|
|
12404
|
+
var MultiAreaReferenceObject = class extends BaseReferenceObject {
|
|
12405
|
+
constructor(token, areas = [], _arrayMode = "first-cell-grid") {
|
|
12406
|
+
super(token);
|
|
12407
|
+
this._arrayMode = _arrayMode;
|
|
12408
|
+
_defineProperty(this, "_areas", []);
|
|
12409
|
+
this._areas = areas;
|
|
12410
|
+
}
|
|
12411
|
+
dispose() {
|
|
12412
|
+
this._areas.forEach((row) => {
|
|
12413
|
+
row.forEach((a) => a.dispose());
|
|
12414
|
+
});
|
|
12415
|
+
this._areas = [];
|
|
12416
|
+
super.dispose();
|
|
12417
|
+
}
|
|
12418
|
+
getAreas() {
|
|
12419
|
+
return this._areas;
|
|
12420
|
+
}
|
|
12421
|
+
setAreas(areas) {
|
|
12422
|
+
this._areas = areas;
|
|
12423
|
+
}
|
|
12424
|
+
/**
|
|
12425
|
+
* Append an area:
|
|
12426
|
+
* - If a single AreaValue is passed, it will be wrapped as one row.
|
|
12427
|
+
* - If an AreaValue[] is passed, it will be inserted as an entire row.
|
|
12428
|
+
*/
|
|
12429
|
+
addArea(area) {
|
|
12430
|
+
if (Array.isArray(area)) this._areas.push(area);
|
|
12431
|
+
else this._areas.push([area]);
|
|
12432
|
+
}
|
|
12433
|
+
/** Flatten the 2D areas to reuse 1D logic */
|
|
12434
|
+
_flatAreas() {
|
|
12435
|
+
return this._areas.flat();
|
|
12436
|
+
}
|
|
12437
|
+
isMultiArea() {
|
|
12438
|
+
return true;
|
|
12439
|
+
}
|
|
12440
|
+
isRange() {
|
|
12441
|
+
return false;
|
|
12442
|
+
}
|
|
12443
|
+
isCell() {
|
|
12444
|
+
return false;
|
|
12445
|
+
}
|
|
12446
|
+
isRow() {
|
|
12447
|
+
return false;
|
|
12448
|
+
}
|
|
12449
|
+
isColumn() {
|
|
12450
|
+
return false;
|
|
12451
|
+
}
|
|
12452
|
+
getRowCount() {
|
|
12453
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.length;
|
|
12454
|
+
let total = 0;
|
|
12455
|
+
for (const a of this._flatAreas()) if (a instanceof BaseReferenceObject) total += a.getRowCount();
|
|
12456
|
+
return total;
|
|
12457
|
+
}
|
|
12458
|
+
getColumnCount() {
|
|
12459
|
+
if (this._arrayMode === "first-cell-grid") return this._areas.reduce((max, row) => Math.max(max, row.length), 0);
|
|
12460
|
+
return this._flatAreas().reduce((max, area) => area instanceof BaseReferenceObject ? Math.max(max, area.getColumnCount()) : max, 0);
|
|
12461
|
+
}
|
|
12462
|
+
isExceedRange() {
|
|
12463
|
+
return this._flatAreas().some((a) => {
|
|
12464
|
+
return a instanceof BaseReferenceObject && a.isExceedRange();
|
|
12465
|
+
});
|
|
12466
|
+
}
|
|
12467
|
+
setRefOffset(x = 0, y = 0) {
|
|
12468
|
+
super.setRefOffset(x, y);
|
|
12469
|
+
this._flatAreas().forEach((a) => {
|
|
12470
|
+
if (a instanceof BaseReferenceObject) a.setRefOffset(x, y);
|
|
12471
|
+
});
|
|
12472
|
+
}
|
|
12473
|
+
_getReferenceArea() {
|
|
12474
|
+
return this._flatAreas().find((area) => area instanceof BaseReferenceObject);
|
|
12475
|
+
}
|
|
12476
|
+
/**
|
|
12477
|
+
* Multi-area reference may span multiple sheets, but Excel requires
|
|
12478
|
+
* them to be in the same sheet for most functions. We follow Excel semantics
|
|
12479
|
+
* by returning the first area’s identifiers.
|
|
12480
|
+
*/
|
|
12481
|
+
getUnitId() {
|
|
12482
|
+
var _this$_getReferenceAr;
|
|
12483
|
+
return ((_this$_getReferenceAr = this._getReferenceArea()) === null || _this$_getReferenceAr === void 0 ? void 0 : _this$_getReferenceAr.getUnitId()) ?? super.getUnitId();
|
|
12484
|
+
}
|
|
12485
|
+
getSheetId() {
|
|
12486
|
+
var _this$_getReferenceAr2;
|
|
12487
|
+
return ((_this$_getReferenceAr2 = this._getReferenceArea()) === null || _this$_getReferenceAr2 === void 0 ? void 0 : _this$_getReferenceAr2.getSheetId()) ?? super.getSheetId();
|
|
12488
|
+
}
|
|
12489
|
+
getActiveSheetRowCount() {
|
|
12490
|
+
var _this$_getReferenceAr3;
|
|
12491
|
+
return ((_this$_getReferenceAr3 = this._getReferenceArea()) === null || _this$_getReferenceAr3 === void 0 ? void 0 : _this$_getReferenceAr3.getActiveSheetRowCount()) ?? 0;
|
|
12492
|
+
}
|
|
12493
|
+
getActiveSheetColumnCount() {
|
|
12494
|
+
var _this$_getReferenceAr4;
|
|
12495
|
+
return ((_this$_getReferenceAr4 = this._getReferenceArea()) === null || _this$_getReferenceAr4 === void 0 ? void 0 : _this$_getReferenceAr4.getActiveSheetColumnCount()) ?? 0;
|
|
12496
|
+
}
|
|
12497
|
+
/**
|
|
12498
|
+
* Iterate through all areas in order, flattening the multi-area into
|
|
12499
|
+
* a sequence of cells.
|
|
12500
|
+
*
|
|
12501
|
+
* Note: The order here is "row-major":
|
|
12502
|
+
* iterate by the row order of _areas, then within each row by the area order.
|
|
12503
|
+
*/
|
|
12504
|
+
iterator(callback) {
|
|
12505
|
+
for (const row of this._areas) {
|
|
12506
|
+
let stopRow = false;
|
|
12507
|
+
for (const area of row) {
|
|
12508
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12509
|
+
let stopArea = false;
|
|
12510
|
+
area.iterator((v, r, c) => {
|
|
12511
|
+
const res = callback(v, r, c);
|
|
12512
|
+
if (res === false) {
|
|
12513
|
+
stopArea = true;
|
|
12514
|
+
stopRow = true;
|
|
12515
|
+
return false;
|
|
12516
|
+
}
|
|
12517
|
+
return res;
|
|
12518
|
+
});
|
|
12519
|
+
if (stopArea) break;
|
|
12520
|
+
}
|
|
12521
|
+
if (stopRow) return;
|
|
12522
|
+
}
|
|
12523
|
+
}
|
|
12524
|
+
/**
|
|
12525
|
+
* Excel defines the "first cell" of a multi-area reference
|
|
12526
|
+
* as the first cell of the first area.
|
|
12527
|
+
*/
|
|
12528
|
+
getFirstCell() {
|
|
12529
|
+
const first = this._getReferenceArea();
|
|
12530
|
+
if (!first) return super.getFirstCell();
|
|
12531
|
+
return first.getFirstCell();
|
|
12532
|
+
}
|
|
12533
|
+
/**
|
|
12534
|
+
* For multi-area, we only take the *first cell* of each area and
|
|
12535
|
+
* arrange them into a 2D ArrayValueObject:
|
|
12536
|
+
*
|
|
12537
|
+
* - outer `_areas` dimension => rows
|
|
12538
|
+
* - inner `_areas[row]` dimension => columns
|
|
12539
|
+
*/
|
|
12540
|
+
toArrayValueObject() {
|
|
12541
|
+
if (this._arrayMode === "stack-areas") return this._stackAreas();
|
|
12542
|
+
const rows = this._areas.length;
|
|
12543
|
+
if (rows === 0) return createNewArray([], 0, 0);
|
|
12544
|
+
const cols = this.getColumnCount();
|
|
12545
|
+
const result = [];
|
|
12546
|
+
for (let r = 0; r < rows; r++) {
|
|
12547
|
+
const rowAreas = this._areas[r] ?? [];
|
|
12548
|
+
result[r] = [];
|
|
12549
|
+
for (let c = 0; c < cols; c++) {
|
|
12550
|
+
const area = rowAreas[c];
|
|
12551
|
+
if (!area) {
|
|
12552
|
+
result[r][c] = NullValueObject.create();
|
|
12553
|
+
continue;
|
|
12554
|
+
}
|
|
12555
|
+
if (area instanceof ErrorValueObject) {
|
|
12556
|
+
result[r][c] = area;
|
|
12557
|
+
continue;
|
|
12558
|
+
}
|
|
12559
|
+
result[r][c] = area.toArrayValueObject(false).getRealValue(0, 0) ?? NullValueObject.create();
|
|
12560
|
+
}
|
|
12561
|
+
}
|
|
12562
|
+
return createNewArray(result, rows, cols);
|
|
12563
|
+
}
|
|
12564
|
+
_stackAreas() {
|
|
12565
|
+
const result = [];
|
|
12566
|
+
const cols = this.getColumnCount();
|
|
12567
|
+
for (const area of this._flatAreas()) {
|
|
12568
|
+
if (area instanceof ErrorValueObject) {
|
|
12569
|
+
const row = new Array(cols).fill(NullValueObject.create());
|
|
12570
|
+
row[0] = area;
|
|
12571
|
+
result.push(row);
|
|
12572
|
+
continue;
|
|
12573
|
+
}
|
|
12574
|
+
const array = area.toArrayValueObject(false);
|
|
12575
|
+
for (let r = 0; r < array.getRowCount(); r++) {
|
|
12576
|
+
const row = [];
|
|
12577
|
+
for (let c = 0; c < cols; c++) row[c] = array.getRealValue(r, c) ?? NullValueObject.create();
|
|
12578
|
+
result.push(row);
|
|
12579
|
+
}
|
|
12580
|
+
}
|
|
12581
|
+
return createNewArray(result, result.length, cols);
|
|
12582
|
+
}
|
|
12583
|
+
getRangePosition() {
|
|
12584
|
+
const flat = this._flatAreas();
|
|
12585
|
+
if (!flat.length) return super.getRangePosition();
|
|
12586
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12587
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12588
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12589
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12590
|
+
for (const area of flat) {
|
|
12591
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12592
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangePosition();
|
|
12593
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12594
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12595
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12596
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12597
|
+
if (endColumn > maxEndColumn) maxEndColumn = maxEndColumn < endColumn ? endColumn : maxEndColumn;
|
|
12598
|
+
}
|
|
12599
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangePosition();
|
|
12600
|
+
return {
|
|
12601
|
+
startRow: minStartRow,
|
|
12602
|
+
startColumn: minStartColumn,
|
|
12603
|
+
endRow: maxEndRow,
|
|
12604
|
+
endColumn: maxEndColumn
|
|
12605
|
+
};
|
|
12606
|
+
}
|
|
12607
|
+
toUnitRange() {
|
|
12608
|
+
return {
|
|
12609
|
+
range: this.getRangePosition(),
|
|
12610
|
+
sheetId: this.getSheetId(),
|
|
12611
|
+
unitId: this.getUnitId()
|
|
12612
|
+
};
|
|
12613
|
+
}
|
|
12614
|
+
toUnitRanges() {
|
|
12615
|
+
return this._flatAreas().filter((area) => area instanceof BaseReferenceObject).flatMap((area) => area.toUnitRanges());
|
|
12616
|
+
}
|
|
12617
|
+
getRangeData() {
|
|
12618
|
+
const flat = this._flatAreas();
|
|
12619
|
+
if (!flat.length) return super.getRangeData();
|
|
12620
|
+
let minStartRow = Number.POSITIVE_INFINITY;
|
|
12621
|
+
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
12622
|
+
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
12623
|
+
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
12624
|
+
for (const area of flat) {
|
|
12625
|
+
if (!(area instanceof BaseReferenceObject)) continue;
|
|
12626
|
+
const { startRow, startColumn, endRow, endColumn } = area.getRangeData();
|
|
12627
|
+
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
12628
|
+
if (startRow < minStartRow) minStartRow = startRow;
|
|
12629
|
+
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
12630
|
+
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
12631
|
+
if (endColumn > maxEndColumn) maxEndColumn = endColumn;
|
|
12632
|
+
}
|
|
12633
|
+
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangeData();
|
|
12634
|
+
return {
|
|
12635
|
+
startRow: minStartRow,
|
|
12636
|
+
startColumn: minStartColumn,
|
|
12637
|
+
endRow: maxEndRow,
|
|
12638
|
+
endColumn: maxEndColumn
|
|
12639
|
+
};
|
|
12640
|
+
}
|
|
12641
|
+
};
|
|
12642
|
+
|
|
12362
12643
|
//#endregion
|
|
12363
12644
|
//#region src/engine/ast-node/union-node.ts
|
|
12364
12645
|
var UnionNode = class extends BaseAstNode {
|
|
12365
|
-
constructor(operatorString) {
|
|
12646
|
+
constructor(operatorString, _currentConfigService) {
|
|
12366
12647
|
super(operatorString);
|
|
12648
|
+
this._currentConfigService = _currentConfigService;
|
|
12367
12649
|
}
|
|
12368
12650
|
get nodeType() {
|
|
12369
12651
|
return 10;
|
|
@@ -12380,28 +12662,74 @@ var UnionNode = class extends BaseAstNode {
|
|
|
12380
12662
|
return;
|
|
12381
12663
|
}
|
|
12382
12664
|
let result;
|
|
12383
|
-
if (this.getToken() === ":") result = this._unionFunction(leftNode, rightNode);
|
|
12665
|
+
if (this.getToken() === ":") result = this._createThreeDimensionalReference(leftChild.getToken(), rightNode) ?? this._unionFunction(leftNode, rightNode);
|
|
12384
12666
|
else result = ErrorValueObject.create("#NAME?");
|
|
12385
12667
|
this.setValue(result);
|
|
12386
12668
|
}
|
|
12669
|
+
_createThreeDimensionalReference(firstSheetToken, rightNode) {
|
|
12670
|
+
if (!(rightNode instanceof BaseReferenceObject)) return;
|
|
12671
|
+
const source = rightNode;
|
|
12672
|
+
const firstSheetName = this._normalizeSheetName(firstSheetToken);
|
|
12673
|
+
const lastSheetName = this._normalizeSheetName(source.getForcedSheetName());
|
|
12674
|
+
if (!firstSheetName || !lastSheetName) return;
|
|
12675
|
+
const { sheetOrder, sheetNameMap } = this._currentConfigService.getSheetsInfo();
|
|
12676
|
+
const sheetIdsByName = new Map(Object.entries(sheetNameMap).map(([sheetId, sheetName]) => [sheetName.toLocaleLowerCase(), sheetId]));
|
|
12677
|
+
const firstSheetId = sheetIdsByName.get(firstSheetName.toLocaleLowerCase());
|
|
12678
|
+
const lastSheetId = sheetIdsByName.get(lastSheetName.toLocaleLowerCase());
|
|
12679
|
+
const firstIndex = firstSheetId == null ? -1 : sheetOrder.indexOf(firstSheetId);
|
|
12680
|
+
const lastIndex = lastSheetId == null ? -1 : sheetOrder.indexOf(lastSheetId);
|
|
12681
|
+
if (firstIndex < 0 || lastIndex < 0) return;
|
|
12682
|
+
const startIndex = Math.min(firstIndex, lastIndex);
|
|
12683
|
+
const endIndex = Math.max(firstIndex, lastIndex);
|
|
12684
|
+
const areas = sheetOrder.slice(startIndex, endIndex + 1).map((sheetId) => {
|
|
12685
|
+
const reference = new RangeReferenceObject(source.getRangeData(), sheetId, source.getUnitId());
|
|
12686
|
+
this._copyReferenceContext(source, reference);
|
|
12687
|
+
reference.setForcedSheetIdDirect(sheetId);
|
|
12688
|
+
reference.setForcedSheetName(sheetNameMap[sheetId] ?? "");
|
|
12689
|
+
return [reference];
|
|
12690
|
+
});
|
|
12691
|
+
return new MultiAreaReferenceObject(`${firstSheetToken}:${source.getToken()}`, areas, "stack-areas");
|
|
12692
|
+
}
|
|
12693
|
+
_normalizeSheetName(token) {
|
|
12694
|
+
const trimmed = token.trim();
|
|
12695
|
+
if (trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed.slice(1, -1).replace(/''/g, "'");
|
|
12696
|
+
return trimmed;
|
|
12697
|
+
}
|
|
12698
|
+
_copyReferenceContext(source, target) {
|
|
12699
|
+
target.setDefaultUnitId(source.getDefaultUnitId());
|
|
12700
|
+
target.setDefaultSheetId(source.getDefaultSheetId());
|
|
12701
|
+
target.setUnitData(source.getUnitData());
|
|
12702
|
+
target.setUnitStylesData(source.getUnitStylesData());
|
|
12703
|
+
target.setFilteredOutRows(source.getFilteredOutRows());
|
|
12704
|
+
target.setRuntimeData(source.getRuntimeData());
|
|
12705
|
+
target.setArrayFormulaCellData(source.getArrayFormulaCellData());
|
|
12706
|
+
target.setArrayFormulaRange(source.getArrayFormulaRange());
|
|
12707
|
+
target.setRuntimeArrayFormulaCellData(source.getRuntimeArrayFormulaCellData());
|
|
12708
|
+
target.setRuntimeArrayFormulaRange(source.getRuntimeArrayFormulaRange());
|
|
12709
|
+
target.setRuntimeFeatureCellData(source.getRuntimeFeatureCellData());
|
|
12710
|
+
const currentRow = source.getCurrentRow();
|
|
12711
|
+
const currentColumn = source.getCurrentColumn();
|
|
12712
|
+
if (currentRow != null && currentColumn != null) target.setCurrentRowAndColumn(currentRow, currentColumn);
|
|
12713
|
+
const { x, y } = source.getRefOffset();
|
|
12714
|
+
target.setRefOffset(x, y);
|
|
12715
|
+
}
|
|
12387
12716
|
_unionFunction(variant1, variant2) {
|
|
12388
12717
|
if (variant1.isError() || variant2.isError()) return ErrorValueObject.create("#REF!");
|
|
12389
|
-
if (!variant1
|
|
12390
|
-
variant1 = variant1;
|
|
12391
|
-
variant2 = variant2;
|
|
12718
|
+
if (!(variant1 instanceof BaseReferenceObject) || !(variant2 instanceof BaseReferenceObject)) return ErrorValueObject.create("#REF!");
|
|
12392
12719
|
return getRangeReferenceObjectFromCache(variant1, variant2);
|
|
12393
12720
|
}
|
|
12394
12721
|
};
|
|
12395
12722
|
let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
12396
|
-
constructor(_functionService) {
|
|
12723
|
+
constructor(_functionService, _currentConfigService) {
|
|
12397
12724
|
super();
|
|
12398
12725
|
this._functionService = _functionService;
|
|
12726
|
+
this._currentConfigService = _currentConfigService;
|
|
12399
12727
|
}
|
|
12400
12728
|
get zIndex() {
|
|
12401
12729
|
return NODE_ORDER_MAP.get(10) || 100;
|
|
12402
12730
|
}
|
|
12403
12731
|
create(param) {
|
|
12404
|
-
return new UnionNode(param);
|
|
12732
|
+
return new UnionNode(param, this._currentConfigService);
|
|
12405
12733
|
}
|
|
12406
12734
|
checkAndCreateNodeType(param) {
|
|
12407
12735
|
if (!(param instanceof LexerNode)) return;
|
|
@@ -12411,7 +12739,7 @@ let UnionNodeFactory = class UnionNodeFactory extends BaseAstNodeFactory {
|
|
|
12411
12739
|
return this.create(tokenTrim);
|
|
12412
12740
|
}
|
|
12413
12741
|
};
|
|
12414
|
-
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService)], UnionNodeFactory);
|
|
12742
|
+
UnionNodeFactory = __decorate([__decorateParam(0, IFunctionService), __decorateParam(1, IFormulaCurrentConfigService)], UnionNodeFactory);
|
|
12415
12743
|
|
|
12416
12744
|
//#endregion
|
|
12417
12745
|
//#region src/engine/ast-node/value-node.ts
|
|
@@ -12432,8 +12760,8 @@ var ValueNode = class extends BaseAstNode {
|
|
|
12432
12760
|
const parent = this.getParent();
|
|
12433
12761
|
let isIgnoreNumberPattern = true;
|
|
12434
12762
|
if ((parent === null || parent === void 0 ? void 0 : parent.nodeType) === 4) {
|
|
12435
|
-
var _isFunctionExecutorAr
|
|
12436
|
-
isIgnoreNumberPattern = (_isFunctionExecutorAr =
|
|
12763
|
+
var _isFunctionExecutorAr;
|
|
12764
|
+
isIgnoreNumberPattern = ((_isFunctionExecutorAr = parent.isFunctionExecutorArgumentsIgnoreNumberPattern) === null || _isFunctionExecutorAr === void 0 ? void 0 : _isFunctionExecutorAr.call(parent)) ?? true;
|
|
12437
12765
|
}
|
|
12438
12766
|
this.setValue(ValueObjectFactory.create(token, isIgnoreNumberPattern));
|
|
12439
12767
|
}
|
|
@@ -12658,7 +12986,7 @@ let AstTreeBuilder = class AstTreeBuilder extends _univerjs_core.Disposable {
|
|
|
12658
12986
|
if (astNode == null) {
|
|
12659
12987
|
const aggregatorNode = this._createGroupByAggregatorTokenNode(item);
|
|
12660
12988
|
if (aggregatorNode != null) return aggregatorNode;
|
|
12661
|
-
return new ErrorFunctionNode();
|
|
12989
|
+
return new ErrorFunctionNode(typeof item === "string" ? item : item.getToken());
|
|
12662
12990
|
}
|
|
12663
12991
|
return astNode;
|
|
12664
12992
|
}
|
|
@@ -13317,8 +13645,8 @@ var FormulaDependencyTreeVirtual = class extends FormulaDependencyTreeCalculator
|
|
|
13317
13645
|
return this.refTree.subUnitId;
|
|
13318
13646
|
}
|
|
13319
13647
|
get formula() {
|
|
13320
|
-
var _this$refTree
|
|
13321
|
-
return (
|
|
13648
|
+
var _this$refTree;
|
|
13649
|
+
return ((_this$refTree = this.refTree) === null || _this$refTree === void 0 ? void 0 : _this$refTree.formula) ?? "";
|
|
13322
13650
|
}
|
|
13323
13651
|
get nodeData() {
|
|
13324
13652
|
return {
|
|
@@ -13552,13 +13880,12 @@ var FormulaDependencyTreeModel = class {
|
|
|
13552
13880
|
this.refOffsetY = tree.refOffsetY;
|
|
13553
13881
|
this.rangeList = tree.rangeList;
|
|
13554
13882
|
if (tree.isVirtual) {
|
|
13555
|
-
var _refTree
|
|
13556
|
-
this.refTreeId = (
|
|
13883
|
+
var _refTree;
|
|
13884
|
+
this.refTreeId = ((_refTree = tree.refTree) === null || _refTree === void 0 ? void 0 : _refTree.treeId) ?? -1;
|
|
13557
13885
|
} else {
|
|
13558
|
-
var _formulaId, _featureId;
|
|
13559
13886
|
this.formula = tree.formula;
|
|
13560
|
-
this.formulaId =
|
|
13561
|
-
this.featureId =
|
|
13887
|
+
this.formulaId = tree.formulaId ?? void 0;
|
|
13888
|
+
this.featureId = tree.featureId ?? void 0;
|
|
13562
13889
|
this.type = tree.type;
|
|
13563
13890
|
}
|
|
13564
13891
|
}
|
|
@@ -13746,14 +14073,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
13746
14073
|
const columnCount = sheetSize.columnCount > 0 ? sheetSize.columnCount : 1;
|
|
13747
14074
|
const subFormulaDataKeys = Object.keys(subFormulaData);
|
|
13748
14075
|
for (const subFormulaDataId of subFormulaDataKeys) {
|
|
13749
|
-
var _treeMatrix$getValue;
|
|
13750
14076
|
const hasOtherFormula = this._dependencyManagerService.hasOtherFormulaDataMainData(subFormulaDataId);
|
|
13751
14077
|
const { f: formulaString, ranges } = subFormulaData[subFormulaDataId];
|
|
13752
14078
|
let isCache = false;
|
|
13753
14079
|
if (hasOtherFormula) isCache = true;
|
|
13754
14080
|
const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
|
|
13755
14081
|
const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
|
|
13756
|
-
const firstFDtree = new FormulaDependencyTree((
|
|
14082
|
+
const firstFDtree = new FormulaDependencyTree((treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) ?? generateRandomDependencyTreeId(this._dependencyManagerService));
|
|
13757
14083
|
for (let i = 0; i < ranges.length; i++) {
|
|
13758
14084
|
const range = ranges[i];
|
|
13759
14085
|
const { startRow, startColumn } = range;
|
|
@@ -13887,7 +14213,7 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
13887
14213
|
return this._dependencyTreeCache.get(treeId);
|
|
13888
14214
|
}
|
|
13889
14215
|
_getTreeNode(tree) {
|
|
13890
|
-
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId);
|
|
14216
|
+
return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
13891
14217
|
}
|
|
13892
14218
|
*_traverse(treeList, skippedTreeIds) {
|
|
13893
14219
|
const stack = treeList;
|
|
@@ -14123,15 +14449,13 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
14123
14449
|
}
|
|
14124
14450
|
}
|
|
14125
14451
|
async _executeNode(node, refOffsetX = 0, refOffsetY = 0) {
|
|
14126
|
-
let value;
|
|
14127
14452
|
const nodeData = {
|
|
14128
14453
|
node,
|
|
14129
14454
|
refOffsetX,
|
|
14130
14455
|
refOffsetY
|
|
14131
14456
|
};
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
return value;
|
|
14457
|
+
const value = this._interpreter.checkAsyncNode(node) ? await this._interpreter.executeAsync(nodeData) : this._interpreter.execute(nodeData);
|
|
14458
|
+
return value instanceof BaseReferenceObject ? value : null;
|
|
14135
14459
|
}
|
|
14136
14460
|
/**
|
|
14137
14461
|
* Calculate the range required for collection in advance,
|
|
@@ -14148,8 +14472,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
14148
14472
|
const rangeList = [];
|
|
14149
14473
|
for (let i = 0, len = preCalculateNodeList.length; i < len; i++) {
|
|
14150
14474
|
const node = preCalculateNodeList[i];
|
|
14151
|
-
const
|
|
14152
|
-
rangeList.push(
|
|
14475
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14476
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14153
14477
|
node.setValue(null);
|
|
14154
14478
|
}
|
|
14155
14479
|
return rangeList;
|
|
@@ -14284,8 +14608,8 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends _unive
|
|
|
14284
14608
|
const rangeList = [];
|
|
14285
14609
|
for (let i = 0, len = referenceFunctionList.length; i < len; i++) {
|
|
14286
14610
|
const node = referenceFunctionList[i];
|
|
14287
|
-
const
|
|
14288
|
-
rangeList.push(
|
|
14611
|
+
const value = await this._executeNode(node, refOffsetX, refOffsetY);
|
|
14612
|
+
if (value != null) rangeList.push(...value.toUnitRanges());
|
|
14289
14613
|
node.setValue(null);
|
|
14290
14614
|
}
|
|
14291
14615
|
return rangeList;
|
|
@@ -14658,7 +14982,7 @@ let CalculateFormulaService = class CalculateFormulaService extends _univerjs_co
|
|
|
14658
14982
|
while (treeList.length > 0) {
|
|
14659
14983
|
const tree = treeList.pop();
|
|
14660
14984
|
this._runtimeService.setCurrent(tree.row, tree.column, tree.rowCount, tree.columnCount, tree.subUnitId, tree.unitId);
|
|
14661
|
-
const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId);
|
|
14985
|
+
const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService, tree.subUnitId, tree.column, tree.row);
|
|
14662
14986
|
const nodeData = {
|
|
14663
14987
|
node,
|
|
14664
14988
|
refOffsetX: tree.refOffsetX,
|
|
@@ -14940,7 +15264,7 @@ let CalculateController = class CalculateController extends _univerjs_core.Dispo
|
|
|
14940
15264
|
if (dependencyTreeModelData.length > 0) this._commandService.executeCommand(SetFormulaDependencyCalculationResultMutation.id, { result: dependencyTreeModelData }, { onlyLocal: true });
|
|
14941
15265
|
}
|
|
14942
15266
|
async _applyResult(data) {
|
|
14943
|
-
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData
|
|
15267
|
+
const { unitData, unitOtherData, arrayFormulaRange, arrayFormulaCellData, clearArrayFormulaCellData, arrayFormulaEmbedded, imageFormulaData } = data;
|
|
14944
15268
|
if (!unitData) {
|
|
14945
15269
|
this._applyTreeResult(data);
|
|
14946
15270
|
console.error("No sheetData from Formula Engine!");
|
|
@@ -15076,8 +15400,7 @@ var FormulaCalculationSessionService = class extends _univerjs_core.Disposable {
|
|
|
15076
15400
|
}
|
|
15077
15401
|
markResultApplied(type = "sheet", result) {
|
|
15078
15402
|
if (result && this._currentResult !== result) {
|
|
15079
|
-
|
|
15080
|
-
const types = (_this$_preAppliedResu = this._preAppliedResultTypes.get(result)) !== null && _this$_preAppliedResu !== void 0 ? _this$_preAppliedResu : /* @__PURE__ */ new Set();
|
|
15403
|
+
const types = this._preAppliedResultTypes.get(result) ?? /* @__PURE__ */ new Set();
|
|
15081
15404
|
types.add(type);
|
|
15082
15405
|
this._preAppliedResultTypes.set(result, types);
|
|
15083
15406
|
return;
|
|
@@ -15639,8 +15962,7 @@ function refactorReferenceSegment(segment, oldName, newName) {
|
|
|
15639
15962
|
const escapedName = newName.replace(/'/g, "''");
|
|
15640
15963
|
return quote ? `'[${escapedName}]${sheetName}'!` : `[${newName}]${sheetName}!`;
|
|
15641
15964
|
}).replace(TABLE_UNIT_QUALIFIER, (token, boundary, quoted, bracketed, plain) => {
|
|
15642
|
-
|
|
15643
|
-
if (!equalsQualifier((_ref = (_ref2 = quoted !== null && quoted !== void 0 ? quoted : bracketed) !== null && _ref2 !== void 0 ? _ref2 : plain) !== null && _ref !== void 0 ? _ref : "", oldName)) return token;
|
|
15965
|
+
if (!equalsQualifier(quoted ?? bracketed ?? plain ?? "", oldName)) return token;
|
|
15644
15966
|
if (quoted != null) return `${boundary}'${newName.replace(/'/g, "''")}'!`;
|
|
15645
15967
|
if (bracketed != null) return `${boundary}[${newName}]!`;
|
|
15646
15968
|
return `${boundary}${quoteQualifier(newName)}!`;
|
|
@@ -15698,11 +16020,10 @@ function shouldAppendOpenBracket(functionType) {
|
|
|
15698
16020
|
return functionType !== 16 && functionType !== 17;
|
|
15699
16021
|
}
|
|
15700
16022
|
function getFormulaReplaceResult(nodes, index, formulaName, functionType) {
|
|
15701
|
-
var _cloneNodes$pop;
|
|
15702
16023
|
if (index === -1) return;
|
|
15703
16024
|
const cloneNodes = [...nodes];
|
|
15704
16025
|
const lastNodes = cloneNodes.splice(index + 1);
|
|
15705
|
-
const oldNode =
|
|
16026
|
+
const oldNode = cloneNodes.pop() ?? "";
|
|
15706
16027
|
let offset = (typeof oldNode === "string" ? oldNode.length : oldNode.token.length) - formulaName.length;
|
|
15707
16028
|
cloneNodes.push(formulaName);
|
|
15708
16029
|
if (lastNodes[0] !== "(" && shouldAppendOpenBracket(functionType)) {
|
|
@@ -15764,12 +16085,11 @@ function isFormulaReferenceAddingTextContext(formulaText, offset) {
|
|
|
15764
16085
|
return Boolean(character && matchRefDrawToken(character) && (!nextCharacter || isFormulaLexerToken(nextCharacter) && nextCharacter !== "("));
|
|
15765
16086
|
}
|
|
15766
16087
|
function resolveFormulaReferenceEditingContext(options) {
|
|
15767
|
-
var _options$selectionSta, _options$selectionEnd;
|
|
15768
16088
|
const { formulaText, sequenceNodes } = options;
|
|
15769
16089
|
const offset = Math.max(0, Math.min(options.offset, formulaText.length));
|
|
15770
16090
|
let nodeIndex = getFormulaSequenceNodeIndex(sequenceNodes, offset);
|
|
15771
|
-
const selectionStart =
|
|
15772
|
-
const selectionEnd =
|
|
16091
|
+
const selectionStart = options.selectionStart ?? offset;
|
|
16092
|
+
const selectionEnd = options.selectionEnd ?? selectionStart;
|
|
15773
16093
|
if (selectionEnd > selectionStart) nodeIndex = sequenceNodes.findIndex((node) => typeof node !== "string" && isFormulaReferenceNode(node) && node.startIndex < selectionEnd && node.endIndex + 1 > selectionStart);
|
|
15774
16094
|
const referenceIndex = getFormulaReferenceIndex(sequenceNodes, nodeIndex);
|
|
15775
16095
|
if (referenceIndex !== -1) return {
|
|
@@ -15786,7 +16106,7 @@ function resolveFormulaReferenceEditingContext(options) {
|
|
|
15786
16106
|
};
|
|
15787
16107
|
}
|
|
15788
16108
|
function getFormulaHighlightDataStream(leadingCharacter, sequenceNodes, sourceText) {
|
|
15789
|
-
return `${leadingCharacter}${sourceText
|
|
16109
|
+
return `${leadingCharacter}${sourceText ?? sequenceNodes.map((node) => typeof node === "string" ? node : node.token).join("")}\r\n`;
|
|
15790
16110
|
}
|
|
15791
16111
|
function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options) {
|
|
15792
16112
|
const textRuns = [];
|
|
@@ -15796,16 +16116,15 @@ function buildFormulaTextRuns(descriptionService, colors, sequenceNodes, options
|
|
|
15796
16116
|
for (let index = 0; index < sequenceNodes.length; index++) {
|
|
15797
16117
|
const node = sequenceNodes[index];
|
|
15798
16118
|
if (typeof node === "string") {
|
|
15799
|
-
var _textRuns
|
|
15800
|
-
const start = (
|
|
16119
|
+
var _textRuns;
|
|
16120
|
+
const start = ((_textRuns = textRuns[textRuns.length - 1]) === null || _textRuns === void 0 ? void 0 : _textRuns.ed) ?? 0;
|
|
15801
16121
|
textRuns.push(createTextRun(start, start + node.length, colors.plainTextColor));
|
|
15802
16122
|
continue;
|
|
15803
16123
|
}
|
|
15804
16124
|
let color = colors.plainTextColor;
|
|
15805
16125
|
if (!descriptionService.hasDefinedNameDescription(node.token.trim())) {
|
|
15806
16126
|
if (isFormulaReferenceNode(node)) {
|
|
15807
|
-
|
|
15808
|
-
color = (_referenceColors$get = referenceColors.get(node.token)) !== null && _referenceColors$get !== void 0 ? _referenceColors$get : colors.formulaRefColors[refColorIndex % colors.formulaRefColors.length];
|
|
16127
|
+
color = referenceColors.get(node.token) ?? colors.formulaRefColors[refColorIndex % colors.formulaRefColors.length];
|
|
15809
16128
|
if (!referenceColors.has(node.token)) {
|
|
15810
16129
|
referenceColors.set(node.token, color);
|
|
15811
16130
|
refColorIndex += 1;
|
|
@@ -15857,13 +16176,13 @@ function applyTextRunColor(textRuns, start, end, color) {
|
|
|
15857
16176
|
continue;
|
|
15858
16177
|
}
|
|
15859
16178
|
if (run.st < start) {
|
|
15860
|
-
var _run$ts
|
|
15861
|
-
nextRuns.push(createTextRun(run.st, start, (
|
|
16179
|
+
var _run$ts;
|
|
16180
|
+
nextRuns.push(createTextRun(run.st, start, ((_run$ts = run.ts) === null || _run$ts === void 0 || (_run$ts = _run$ts.cl) === null || _run$ts === void 0 ? void 0 : _run$ts.rgb) ?? color));
|
|
15862
16181
|
}
|
|
15863
16182
|
nextRuns.push(createTextRun(Math.max(run.st, start), Math.min(run.ed, end), color));
|
|
15864
16183
|
if (run.ed > end) {
|
|
15865
|
-
var _run$
|
|
15866
|
-
nextRuns.push(createTextRun(end, run.ed, (
|
|
16184
|
+
var _run$ts2;
|
|
16185
|
+
nextRuns.push(createTextRun(end, run.ed, ((_run$ts2 = run.ts) === null || _run$ts2 === void 0 || (_run$ts2 = _run$ts2.cl) === null || _run$ts2 === void 0 ? void 0 : _run$ts2.rgb) ?? color));
|
|
15867
16186
|
}
|
|
15868
16187
|
}
|
|
15869
16188
|
textRuns.splice(0, textRuns.length, ...nextRuns);
|
|
@@ -16059,6 +16378,14 @@ var BaseFunction = class {
|
|
|
16059
16378
|
"needsAstChildren",
|
|
16060
16379
|
false
|
|
16061
16380
|
);
|
|
16381
|
+
_defineProperty(
|
|
16382
|
+
this,
|
|
16383
|
+
/**
|
|
16384
|
+
* Arguments that preserve a selected lazy IF branch as a reference array.
|
|
16385
|
+
*/
|
|
16386
|
+
"lazyIfReferenceArrayArgumentIndexes",
|
|
16387
|
+
[]
|
|
16388
|
+
);
|
|
16062
16389
|
_defineProperty(
|
|
16063
16390
|
this,
|
|
16064
16391
|
/**
|
|
@@ -18242,7 +18569,7 @@ function getAggregateResult(options, refs) {
|
|
|
18242
18569
|
return result;
|
|
18243
18570
|
}
|
|
18244
18571
|
function getArrayValuesByAggregateIgnoreOptions(array, options, formulaDataModel) {
|
|
18245
|
-
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options
|
|
18572
|
+
const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options ?? {};
|
|
18246
18573
|
const values = [];
|
|
18247
18574
|
if (array.isReferenceObject()) {
|
|
18248
18575
|
var _unitData$unitId2;
|
|
@@ -18368,8 +18695,8 @@ var BetaInv = class extends BaseFunction {
|
|
|
18368
18695
|
_defineProperty(this, "maxParams", 5);
|
|
18369
18696
|
}
|
|
18370
18697
|
calculate(probability, alpha, beta, A, B) {
|
|
18371
|
-
let _A = A
|
|
18372
|
-
let _B = B
|
|
18698
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
18699
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
18373
18700
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
18374
18701
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
18375
18702
|
const maxRowLength = Math.max(probability.isArray() ? probability.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -19172,6 +19499,7 @@ var PercentileInc = class extends BaseFunction {
|
|
|
19172
19499
|
super(..._args);
|
|
19173
19500
|
_defineProperty(this, "minParams", 2);
|
|
19174
19501
|
_defineProperty(this, "maxParams", 2);
|
|
19502
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
19175
19503
|
}
|
|
19176
19504
|
calculate(array, k) {
|
|
19177
19505
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -19201,7 +19529,7 @@ var PercentrankInc = class extends BaseFunction {
|
|
|
19201
19529
|
}
|
|
19202
19530
|
calculate(array, x, significance) {
|
|
19203
19531
|
const arrayValues = this._getValues(array);
|
|
19204
|
-
let _significance = significance
|
|
19532
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
19205
19533
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
19206
19534
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
19207
19535
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -19763,8 +20091,8 @@ var Betadist = class extends BaseFunction {
|
|
|
19763
20091
|
_defineProperty(this, "maxParams", 5);
|
|
19764
20092
|
}
|
|
19765
20093
|
calculate(x, alpha, beta, A, B) {
|
|
19766
|
-
let _A = A
|
|
19767
|
-
let _B = B
|
|
20094
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
20095
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
19768
20096
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
19769
20097
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
19770
20098
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -20020,12 +20348,13 @@ var Rank = class extends BaseFunction {
|
|
|
20020
20348
|
_defineProperty(this, "minParams", 2);
|
|
20021
20349
|
_defineProperty(this, "maxParams", 3);
|
|
20022
20350
|
_defineProperty(this, "needsReferenceObject", true);
|
|
20351
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
20023
20352
|
}
|
|
20024
20353
|
calculate(number, ref, order) {
|
|
20025
20354
|
let _number = number;
|
|
20026
20355
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
20027
20356
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
20028
|
-
let _order = order
|
|
20357
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
20029
20358
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
20030
20359
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
20031
20360
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -21062,7 +21391,7 @@ var Days360 = class extends BaseFunction {
|
|
|
21062
21391
|
_defineProperty(this, "maxParams", 3);
|
|
21063
21392
|
}
|
|
21064
21393
|
calculate(startDate, endDate, method) {
|
|
21065
|
-
const _method = method
|
|
21394
|
+
const _method = method ?? BooleanValueObject.create(false);
|
|
21066
21395
|
if (startDate.isError()) return startDate;
|
|
21067
21396
|
if (endDate.isError()) return endDate;
|
|
21068
21397
|
if (_method.isError()) return _method;
|
|
@@ -21176,7 +21505,7 @@ var Epochtodate = class extends BaseFunction {
|
|
|
21176
21505
|
_defineProperty(this, "needsReferenceObject", true);
|
|
21177
21506
|
}
|
|
21178
21507
|
calculate(timestamp, unit) {
|
|
21179
|
-
const _unit = unit
|
|
21508
|
+
const _unit = unit ?? NumberValueObject.create(1);
|
|
21180
21509
|
const { isError, errorObject, timestampIsReferenceObject, timestampObject, unitObject } = this._checkVariants(timestamp, _unit);
|
|
21181
21510
|
if (isError) return errorObject;
|
|
21182
21511
|
if (timestampObject.isNull() || timestampObject.isBoolean() || timestampObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -21683,7 +22012,7 @@ var Today = class extends BaseFunction {
|
|
|
21683
22012
|
}
|
|
21684
22013
|
calculate() {
|
|
21685
22014
|
const now = /* @__PURE__ */ new Date();
|
|
21686
|
-
const currentSerial = excelDateSerial(new Date(Date.UTC(now.
|
|
22015
|
+
const currentSerial = excelDateSerial(new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())));
|
|
21687
22016
|
return NumberValueObject.create(currentSerial, DEFAULT_DATE_FORMAT);
|
|
21688
22017
|
}
|
|
21689
22018
|
};
|
|
@@ -21789,7 +22118,7 @@ var Weekday = class extends BaseFunction {
|
|
|
21789
22118
|
});
|
|
21790
22119
|
}
|
|
21791
22120
|
calculate(serialNumber, returnType) {
|
|
21792
|
-
const _returnType = returnType
|
|
22121
|
+
const _returnType = returnType ?? NumberValueObject.create(1);
|
|
21793
22122
|
if (serialNumber.isError()) return serialNumber;
|
|
21794
22123
|
if (_returnType.isError()) return _returnType;
|
|
21795
22124
|
const maxRowLength = Math.max(serialNumber.isArray() ? serialNumber.getRowCount() : 1, _returnType.isArray() ? _returnType.getRowCount() : 1);
|
|
@@ -21843,7 +22172,7 @@ var Weeknum = class extends BaseFunction {
|
|
|
21843
22172
|
}
|
|
21844
22173
|
calculate(serialNumber, returnType) {
|
|
21845
22174
|
let _serialNumber = serialNumber;
|
|
21846
|
-
let _returnType = returnType
|
|
22175
|
+
let _returnType = returnType ?? NumberValueObject.create(1);
|
|
21847
22176
|
if (_serialNumber.isArray()) {
|
|
21848
22177
|
const rowCount = _serialNumber.getRowCount();
|
|
21849
22178
|
const columnCount = _serialNumber.getColumnCount();
|
|
@@ -21977,7 +22306,7 @@ var WorkdayIntl = class extends BaseFunction {
|
|
|
21977
22306
|
return this._handleSingleObject(startDate, days, weekend, holidays);
|
|
21978
22307
|
}
|
|
21979
22308
|
_handleSingleObject(startDate, days, weekend, holidays) {
|
|
21980
|
-
const _weekend = weekend
|
|
22309
|
+
const _weekend = weekend ?? NumberValueObject.create(1);
|
|
21981
22310
|
const _startDate = this._checkArrayError(startDate);
|
|
21982
22311
|
if (_startDate.isError()) return _startDate;
|
|
21983
22312
|
const _days = this._checkArrayError(days);
|
|
@@ -22074,7 +22403,7 @@ var Yearfrac = class extends BaseFunction {
|
|
|
22074
22403
|
_defineProperty(this, "maxParams", 3);
|
|
22075
22404
|
}
|
|
22076
22405
|
calculate(startDate, endDate, basis) {
|
|
22077
|
-
let _basis = basis
|
|
22406
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
22078
22407
|
const _startDate = checkVariantErrorIsArray(startDate);
|
|
22079
22408
|
if (_startDate.isError()) return _startDate;
|
|
22080
22409
|
const _endDate = checkVariantErrorIsArray(endDate);
|
|
@@ -22919,7 +23248,7 @@ var Complex = class extends BaseFunction {
|
|
|
22919
23248
|
_defineProperty(this, "maxParams", 3);
|
|
22920
23249
|
}
|
|
22921
23250
|
calculate(realNum, iNum, suffix) {
|
|
22922
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix
|
|
23251
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(realNum, iNum, suffix ?? StringValueObject.create("i"));
|
|
22923
23252
|
if (isError) return errorObject;
|
|
22924
23253
|
const [realNumObject, iNumObject, suffixObject] = variants;
|
|
22925
23254
|
const realNumValue = +realNumObject.getValue();
|
|
@@ -24719,7 +25048,7 @@ var Delta = class extends BaseFunction {
|
|
|
24719
25048
|
_defineProperty(this, "maxParams", 2);
|
|
24720
25049
|
}
|
|
24721
25050
|
calculate(number1, number2) {
|
|
24722
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2
|
|
25051
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number1, number2 ?? NumberValueObject.create(0));
|
|
24723
25052
|
if (isError) return errorObject;
|
|
24724
25053
|
const [number1Object, number2Object] = variants;
|
|
24725
25054
|
const number1Value = +number1Object.getValue();
|
|
@@ -24827,7 +25156,7 @@ var Gestep = class extends BaseFunction {
|
|
|
24827
25156
|
}
|
|
24828
25157
|
calculate(number, step) {
|
|
24829
25158
|
if (number.isNull()) return ErrorValueObject.create("#N/A");
|
|
24830
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step
|
|
25159
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(number, step ?? NumberValueObject.create(0));
|
|
24831
25160
|
if (isError) return errorObject;
|
|
24832
25161
|
const [numberObject, stepObject] = variants;
|
|
24833
25162
|
const numberValue = +numberObject.getValue();
|
|
@@ -25223,7 +25552,7 @@ var Imlog = class extends BaseFunction {
|
|
|
25223
25552
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(inumber);
|
|
25224
25553
|
if (isError) return errorObject;
|
|
25225
25554
|
const [inumberObject] = variants;
|
|
25226
|
-
let _base = base
|
|
25555
|
+
let _base = base ?? NumberValueObject.create(10);
|
|
25227
25556
|
if (_base.isArray()) {
|
|
25228
25557
|
const rowCount = _base.getRowCount();
|
|
25229
25558
|
const columnCount = _base.getColumnCount();
|
|
@@ -26086,8 +26415,8 @@ var Accrint = class extends BaseFunction {
|
|
|
26086
26415
|
_defineProperty(this, "maxParams", 8);
|
|
26087
26416
|
}
|
|
26088
26417
|
calculate(issue, firstInterest, settlement, rate, par, frequency, basis, calcMethod) {
|
|
26089
|
-
const _basis = basis
|
|
26090
|
-
const _calcMethod = calcMethod
|
|
26418
|
+
const _basis = basis ?? NumberValueObject.create(0);
|
|
26419
|
+
const _calcMethod = calcMethod ?? BooleanValueObject.create(true);
|
|
26091
26420
|
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, firstInterest, settlement, rate, par, frequency, _basis);
|
|
26092
26421
|
if (isError) return errorObject;
|
|
26093
26422
|
const [issueObject, firstInterestObject, settlementObject, rateObject, parObject, frequencyObject, basisObject] = variants;
|
|
@@ -26166,7 +26495,7 @@ var Accrintm = class extends BaseFunction {
|
|
|
26166
26495
|
_defineProperty(this, "maxParams", 5);
|
|
26167
26496
|
}
|
|
26168
26497
|
calculate(issue, settlement, rate, par, basis) {
|
|
26169
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis
|
|
26498
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(issue, settlement, rate, par, basis ?? NumberValueObject.create(0));
|
|
26170
26499
|
if (isError) return errorObject;
|
|
26171
26500
|
const [issueObject, settlementObject, rateObject, parObject, basisObject] = variants;
|
|
26172
26501
|
const issueSerialNumber = getDateSerialNumberByObject(issueObject);
|
|
@@ -26194,7 +26523,7 @@ var Amorlinc = class extends BaseFunction {
|
|
|
26194
26523
|
_defineProperty(this, "maxParams", 7);
|
|
26195
26524
|
}
|
|
26196
26525
|
calculate(cost, datePurchased, firstPeriod, salvage, period, rate, basis) {
|
|
26197
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis
|
|
26526
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(cost, datePurchased, firstPeriod, salvage, period, rate, basis ?? NumberValueObject.create(0));
|
|
26198
26527
|
if (isError) return errorObject;
|
|
26199
26528
|
const [costObject, datePurchasedObject, firstPeriodObject, salvageObject, periodObject, rateObject, basisObject] = variants;
|
|
26200
26529
|
const datePurchasedSerialNumber = getDateSerialNumberByObject(datePurchasedObject);
|
|
@@ -26241,7 +26570,7 @@ var Coupdaybs = class extends BaseFunction {
|
|
|
26241
26570
|
_defineProperty(this, "maxParams", 4);
|
|
26242
26571
|
}
|
|
26243
26572
|
calculate(settlement, maturity, frequency, basis) {
|
|
26244
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26573
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26245
26574
|
if (isError) return errorObject;
|
|
26246
26575
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26247
26576
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26270,7 +26599,7 @@ var Coupdays = class extends BaseFunction {
|
|
|
26270
26599
|
_defineProperty(this, "maxParams", 4);
|
|
26271
26600
|
}
|
|
26272
26601
|
calculate(settlement, maturity, frequency, basis) {
|
|
26273
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26602
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26274
26603
|
if (isError) return errorObject;
|
|
26275
26604
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26276
26605
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26299,7 +26628,7 @@ var Coupdaysnc = class extends BaseFunction {
|
|
|
26299
26628
|
_defineProperty(this, "maxParams", 4);
|
|
26300
26629
|
}
|
|
26301
26630
|
calculate(settlement, maturity, frequency, basis) {
|
|
26302
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26631
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26303
26632
|
if (isError) return errorObject;
|
|
26304
26633
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26305
26634
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26334,7 +26663,7 @@ var Coupncd = class extends BaseFunction {
|
|
|
26334
26663
|
_defineProperty(this, "maxParams", 4);
|
|
26335
26664
|
}
|
|
26336
26665
|
calculate(settlement, maturity, frequency, basis) {
|
|
26337
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26666
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26338
26667
|
if (isError) return errorObject;
|
|
26339
26668
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26340
26669
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26363,7 +26692,7 @@ var Coupnum = class extends BaseFunction {
|
|
|
26363
26692
|
_defineProperty(this, "maxParams", 4);
|
|
26364
26693
|
}
|
|
26365
26694
|
calculate(settlement, maturity, frequency, basis) {
|
|
26366
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26695
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26367
26696
|
if (isError) return errorObject;
|
|
26368
26697
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26369
26698
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26393,7 +26722,7 @@ var Couppcd = class extends BaseFunction {
|
|
|
26393
26722
|
_defineProperty(this, "maxParams", 4);
|
|
26394
26723
|
}
|
|
26395
26724
|
calculate(settlement, maturity, frequency, basis) {
|
|
26396
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis
|
|
26725
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, frequency, basis ?? NumberValueObject.create(0));
|
|
26397
26726
|
if (isError) return errorObject;
|
|
26398
26727
|
const [settlementObject, maturityObject, frequencyObject, basisObject] = variants;
|
|
26399
26728
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26506,7 +26835,7 @@ var Db = class extends BaseFunction {
|
|
|
26506
26835
|
_defineProperty(this, "needsLocale", true);
|
|
26507
26836
|
}
|
|
26508
26837
|
calculate(cost, salvage, life, period, month) {
|
|
26509
|
-
let _month = month
|
|
26838
|
+
let _month = month ?? NumberValueObject.create(12);
|
|
26510
26839
|
if (_month.isNull()) _month = NumberValueObject.create(12);
|
|
26511
26840
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, period.isArray() ? period.getRowCount() : 1, _month.isArray() ? _month.getRowCount() : 1);
|
|
26512
26841
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, period.isArray() ? period.getColumnCount() : 1, _month.isArray() ? _month.getColumnCount() : 1);
|
|
@@ -26562,7 +26891,7 @@ var Ddb = class extends BaseFunction {
|
|
|
26562
26891
|
_defineProperty(this, "needsLocale", true);
|
|
26563
26892
|
}
|
|
26564
26893
|
calculate(cost, salvage, life, period, factor) {
|
|
26565
|
-
let _factor = factor
|
|
26894
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
26566
26895
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
26567
26896
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, period.isArray() ? period.getRowCount() : 1, _factor.isArray() ? _factor.getRowCount() : 1);
|
|
26568
26897
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, period.isArray() ? period.getColumnCount() : 1, _factor.isArray() ? _factor.getColumnCount() : 1);
|
|
@@ -26600,7 +26929,7 @@ var Disc = class extends BaseFunction {
|
|
|
26600
26929
|
_defineProperty(this, "maxParams", 5);
|
|
26601
26930
|
}
|
|
26602
26931
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
26603
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis
|
|
26932
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, pr, redemption, basis ?? NumberValueObject.create(0));
|
|
26604
26933
|
if (isError) return errorObject;
|
|
26605
26934
|
const [settlementObject, maturityObject, prObject, redemptionObject, basisObject] = variants;
|
|
26606
26935
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26677,7 +27006,7 @@ var Duration = class extends BaseFunction {
|
|
|
26677
27006
|
_defineProperty(this, "maxParams", 6);
|
|
26678
27007
|
}
|
|
26679
27008
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26680
|
-
let _basis = basis
|
|
27009
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26681
27010
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26682
27011
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26683
27012
|
if (isError) return errorObject;
|
|
@@ -26734,8 +27063,8 @@ var Fv = class extends BaseFunction {
|
|
|
26734
27063
|
_defineProperty(this, "needsLocale", true);
|
|
26735
27064
|
}
|
|
26736
27065
|
calculate(rate, nper, pmt, pv, type) {
|
|
26737
|
-
const _pv = pv
|
|
26738
|
-
const _type = type
|
|
27066
|
+
const _pv = pv ?? NumberValueObject.create(0);
|
|
27067
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26739
27068
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, _pv.isArray() ? _pv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
26740
27069
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, _pv.isArray() ? _pv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
26741
27070
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26800,7 +27129,7 @@ var Intrate = class extends BaseFunction {
|
|
|
26800
27129
|
_defineProperty(this, "maxParams", 5);
|
|
26801
27130
|
}
|
|
26802
27131
|
calculate(settlement, maturity, investment, redemption, basis) {
|
|
26803
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis
|
|
27132
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArrayOrBoolean(settlement, maturity, investment, redemption, basis ?? NumberValueObject.create(0));
|
|
26804
27133
|
if (isError) return errorObject;
|
|
26805
27134
|
const [settlementObject, maturityObject, investmentObject, redemptionObject, basisObject] = variants;
|
|
26806
27135
|
const settlementSerialNumber = getDateSerialNumberByObject(settlementObject);
|
|
@@ -26828,8 +27157,8 @@ var Ipmt = class extends BaseFunction {
|
|
|
26828
27157
|
_defineProperty(this, "needsLocale", true);
|
|
26829
27158
|
}
|
|
26830
27159
|
calculate(rate, per, nper, pv, fv, type) {
|
|
26831
|
-
const _fv = fv
|
|
26832
|
-
const _type = type
|
|
27160
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27161
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
26833
27162
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, per.isArray() ? per.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
26834
27163
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, per.isArray() ? per.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
26835
27164
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -26868,7 +27197,7 @@ var Irr = class extends BaseFunction {
|
|
|
26868
27197
|
_defineProperty(this, "maxParams", 2);
|
|
26869
27198
|
}
|
|
26870
27199
|
calculate(values, guess) {
|
|
26871
|
-
let _guess = guess
|
|
27200
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
26872
27201
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
26873
27202
|
if (_guess.isArray()) return _guess.map((guessObject, rowIndex, columnIndex) => this._handleSingleObject(values, guessObject, rowIndex, columnIndex));
|
|
26874
27203
|
return this._handleSingleObject(values, _guess);
|
|
@@ -26967,7 +27296,7 @@ var Mduration = class extends BaseFunction {
|
|
|
26967
27296
|
_defineProperty(this, "maxParams", 6);
|
|
26968
27297
|
}
|
|
26969
27298
|
calculate(settlement, maturity, coupon, yld, frequency, basis) {
|
|
26970
|
-
let _basis = basis
|
|
27299
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
26971
27300
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
26972
27301
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, coupon, yld, frequency, _basis);
|
|
26973
27302
|
if (isError) return errorObject;
|
|
@@ -27123,8 +27452,8 @@ var Nper = class extends BaseFunction {
|
|
|
27123
27452
|
_defineProperty(this, "maxParams", 5);
|
|
27124
27453
|
}
|
|
27125
27454
|
calculate(rate, pmt, pv, fv, type) {
|
|
27126
|
-
const _fv = fv
|
|
27127
|
-
const _type = type
|
|
27455
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27456
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27128
27457
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27129
27458
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27130
27459
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27235,7 +27564,7 @@ var Oddfprice = class extends BaseFunction {
|
|
|
27235
27564
|
_defineProperty(this, "maxParams", 9);
|
|
27236
27565
|
}
|
|
27237
27566
|
calculate(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, basis) {
|
|
27238
|
-
let _basis = basis
|
|
27567
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27239
27568
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27240
27569
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, yld, redemption, frequency, _basis);
|
|
27241
27570
|
if (isError) return errorObject;
|
|
@@ -27279,7 +27608,7 @@ var Oddfyield = class extends BaseFunction {
|
|
|
27279
27608
|
_defineProperty(this, "maxParams", 9);
|
|
27280
27609
|
}
|
|
27281
27610
|
calculate(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, basis) {
|
|
27282
|
-
let _basis = basis
|
|
27611
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27283
27612
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27284
27613
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, firstCoupon, rate, pr, redemption, frequency, _basis);
|
|
27285
27614
|
if (isError) return errorObject;
|
|
@@ -27332,7 +27661,7 @@ var Oddlprice = class extends BaseFunction {
|
|
|
27332
27661
|
_defineProperty(this, "maxParams", 8);
|
|
27333
27662
|
}
|
|
27334
27663
|
calculate(settlement, maturity, lastInterest, rate, yld, redemption, frequency, basis) {
|
|
27335
|
-
let _basis = basis
|
|
27664
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27336
27665
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27337
27666
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, yld, redemption, frequency, _basis);
|
|
27338
27667
|
if (isError) return errorObject;
|
|
@@ -27417,7 +27746,7 @@ var Oddlyield = class extends BaseFunction {
|
|
|
27417
27746
|
_defineProperty(this, "maxParams", 9);
|
|
27418
27747
|
}
|
|
27419
27748
|
calculate(settlement, maturity, lastInterest, rate, pr, redemption, frequency, basis) {
|
|
27420
|
-
let _basis = basis
|
|
27749
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27421
27750
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27422
27751
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, lastInterest, rate, pr, redemption, frequency, _basis);
|
|
27423
27752
|
if (isError) return errorObject;
|
|
@@ -27534,8 +27863,8 @@ var Pmt = class extends BaseFunction {
|
|
|
27534
27863
|
_defineProperty(this, "needsLocale", true);
|
|
27535
27864
|
}
|
|
27536
27865
|
calculate(rate, nper, pv, fv, type) {
|
|
27537
|
-
const _fv = fv
|
|
27538
|
-
const _type = type
|
|
27866
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27867
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27539
27868
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27540
27869
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27541
27870
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27573,8 +27902,8 @@ var Ppmt = class extends BaseFunction {
|
|
|
27573
27902
|
_defineProperty(this, "needsLocale", true);
|
|
27574
27903
|
}
|
|
27575
27904
|
calculate(rate, per, nper, pv, fv, type) {
|
|
27576
|
-
const _fv = fv
|
|
27577
|
-
const _type = type
|
|
27905
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
27906
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27578
27907
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, per.isArray() ? per.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27579
27908
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, per.isArray() ? per.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27580
27909
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27613,7 +27942,7 @@ var Price = class extends BaseFunction {
|
|
|
27613
27942
|
_defineProperty(this, "maxParams", 7);
|
|
27614
27943
|
}
|
|
27615
27944
|
calculate(settlement, maturity, rate, yld, redemption, frequency, basis) {
|
|
27616
|
-
let _basis = basis
|
|
27945
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27617
27946
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27618
27947
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, yld, redemption, frequency, _basis);
|
|
27619
27948
|
if (isError) return errorObject;
|
|
@@ -27647,7 +27976,7 @@ var Pricedisc = class extends BaseFunction {
|
|
|
27647
27976
|
_defineProperty(this, "maxParams", 5);
|
|
27648
27977
|
}
|
|
27649
27978
|
calculate(settlement, maturity, discount, redemption, basis) {
|
|
27650
|
-
let _basis = basis
|
|
27979
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27651
27980
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27652
27981
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, discount, redemption, _basis);
|
|
27653
27982
|
if (isError) return errorObject;
|
|
@@ -27676,7 +28005,7 @@ var Pricemat = class extends BaseFunction {
|
|
|
27676
28005
|
_defineProperty(this, "maxParams", 6);
|
|
27677
28006
|
}
|
|
27678
28007
|
calculate(settlement, maturity, issue, rate, yld, basis) {
|
|
27679
|
-
let _basis = basis
|
|
28008
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27680
28009
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27681
28010
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, yld, _basis);
|
|
27682
28011
|
if (isError) return errorObject;
|
|
@@ -27715,8 +28044,8 @@ var Pv = class extends BaseFunction {
|
|
|
27715
28044
|
_defineProperty(this, "needsLocale", true);
|
|
27716
28045
|
}
|
|
27717
28046
|
calculate(rate, nper, pmt, fv, type) {
|
|
27718
|
-
const _fv = fv
|
|
27719
|
-
const _type = type
|
|
28047
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28048
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
27720
28049
|
const maxRowLength = Math.max(rate.isArray() ? rate.getRowCount() : 1, nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1);
|
|
27721
28050
|
const maxColumnLength = Math.max(rate.isArray() ? rate.getColumnCount() : 1, nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1);
|
|
27722
28051
|
const rateArray = expandArrayValueObject(maxRowLength, maxColumnLength, rate, ErrorValueObject.create("#N/A"));
|
|
@@ -27753,9 +28082,9 @@ var Rate = class extends BaseFunction {
|
|
|
27753
28082
|
_defineProperty(this, "maxParams", 6);
|
|
27754
28083
|
}
|
|
27755
28084
|
calculate(nper, pmt, pv, fv, type, guess) {
|
|
27756
|
-
const _fv = fv
|
|
27757
|
-
const _type = type
|
|
27758
|
-
const _guess = guess
|
|
28085
|
+
const _fv = fv ?? NumberValueObject.create(0);
|
|
28086
|
+
const _type = type ?? NumberValueObject.create(0);
|
|
28087
|
+
const _guess = guess ?? NumberValueObject.create(.1);
|
|
27759
28088
|
const maxRowLength = Math.max(nper.isArray() ? nper.getRowCount() : 1, pmt.isArray() ? pmt.getRowCount() : 1, pv.isArray() ? pv.getRowCount() : 1, _fv.isArray() ? _fv.getRowCount() : 1, _type.isArray() ? _type.getRowCount() : 1, _guess.isArray() ? _guess.getRowCount() : 1);
|
|
27760
28089
|
const maxColumnLength = Math.max(nper.isArray() ? nper.getColumnCount() : 1, pmt.isArray() ? pmt.getColumnCount() : 1, pv.isArray() ? pv.getColumnCount() : 1, _fv.isArray() ? _fv.getColumnCount() : 1, _type.isArray() ? _type.getColumnCount() : 1, _guess.isArray() ? _guess.getColumnCount() : 1);
|
|
27761
28090
|
const nperArray = expandArrayValueObject(maxRowLength, maxColumnLength, nper, ErrorValueObject.create("#N/A"));
|
|
@@ -27840,7 +28169,7 @@ var Received = class extends BaseFunction {
|
|
|
27840
28169
|
_defineProperty(this, "maxParams", 5);
|
|
27841
28170
|
}
|
|
27842
28171
|
calculate(settlement, maturity, investment, discount, basis) {
|
|
27843
|
-
let _basis = basis
|
|
28172
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
27844
28173
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
27845
28174
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, investment, discount, _basis);
|
|
27846
28175
|
if (isError) return errorObject;
|
|
@@ -28062,9 +28391,9 @@ var Vdb = class extends BaseFunction {
|
|
|
28062
28391
|
_defineProperty(this, "needsLocale", true);
|
|
28063
28392
|
}
|
|
28064
28393
|
calculate(cost, salvage, life, startPeriod, endPeriod, factor, noSwitch) {
|
|
28065
|
-
let _factor = factor
|
|
28394
|
+
let _factor = factor ?? NumberValueObject.create(2);
|
|
28066
28395
|
if (_factor.isNull()) _factor = NumberValueObject.create(2);
|
|
28067
|
-
let _noSwitch = noSwitch
|
|
28396
|
+
let _noSwitch = noSwitch ?? BooleanValueObject.create(false);
|
|
28068
28397
|
if (_noSwitch.isNull()) _noSwitch = BooleanValueObject.create(false);
|
|
28069
28398
|
const maxRowLength = Math.max(cost.isArray() ? cost.getRowCount() : 1, salvage.isArray() ? salvage.getRowCount() : 1, life.isArray() ? life.getRowCount() : 1, startPeriod.isArray() ? startPeriod.getRowCount() : 1, endPeriod.isArray() ? endPeriod.getRowCount() : 1, _factor.isArray() ? _factor.getRowCount() : 1, _noSwitch.isArray() ? _noSwitch.getRowCount() : 1);
|
|
28070
28399
|
const maxColumnLength = Math.max(cost.isArray() ? cost.getColumnCount() : 1, salvage.isArray() ? salvage.getColumnCount() : 1, life.isArray() ? life.getColumnCount() : 1, startPeriod.isArray() ? startPeriod.getColumnCount() : 1, endPeriod.isArray() ? endPeriod.getColumnCount() : 1, _factor.isArray() ? _factor.getColumnCount() : 1, _noSwitch.isArray() ? _noSwitch.getColumnCount() : 1);
|
|
@@ -28158,7 +28487,7 @@ var Xirr = class extends BaseFunction {
|
|
|
28158
28487
|
if (values.isNull() || dates.isNull()) return ErrorValueObject.create("#N/A");
|
|
28159
28488
|
const { isError, errorObejct, _values, _dates } = this._checkErrors(values, dates);
|
|
28160
28489
|
if (isError) return errorObejct;
|
|
28161
|
-
let _guess = guess
|
|
28490
|
+
let _guess = guess ?? NumberValueObject.create(.1);
|
|
28162
28491
|
if (_guess.isNull()) _guess = NumberValueObject.create(.1);
|
|
28163
28492
|
const { isError: _isError_guess, errorObject: _errorObject_guess, variants } = checkVariantsErrorIsArrayOrBoolean(_guess);
|
|
28164
28493
|
if (_isError_guess) return _errorObject_guess;
|
|
@@ -28501,7 +28830,7 @@ var Yield = class extends BaseFunction {
|
|
|
28501
28830
|
_defineProperty(this, "maxParams", 7);
|
|
28502
28831
|
}
|
|
28503
28832
|
calculate(settlement, maturity, rate, pr, redemption, frequency, basis) {
|
|
28504
|
-
let _basis = basis
|
|
28833
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28505
28834
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28506
28835
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, rate, pr, redemption, frequency, _basis);
|
|
28507
28836
|
if (isError) return errorObject;
|
|
@@ -28554,7 +28883,7 @@ var Yielddisc = class extends BaseFunction {
|
|
|
28554
28883
|
_defineProperty(this, "maxParams", 5);
|
|
28555
28884
|
}
|
|
28556
28885
|
calculate(settlement, maturity, pr, redemption, basis) {
|
|
28557
|
-
let _basis = basis
|
|
28886
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28558
28887
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28559
28888
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, pr, redemption, _basis);
|
|
28560
28889
|
if (isError) return errorObject;
|
|
@@ -28583,7 +28912,7 @@ var Yieldmat = class extends BaseFunction {
|
|
|
28583
28912
|
_defineProperty(this, "maxParams", 6);
|
|
28584
28913
|
}
|
|
28585
28914
|
calculate(settlement, maturity, issue, rate, pr, basis) {
|
|
28586
|
-
let _basis = basis
|
|
28915
|
+
let _basis = basis ?? NumberValueObject.create(0);
|
|
28587
28916
|
if (_basis.isNull()) _basis = NumberValueObject.create(0);
|
|
28588
28917
|
const { isError, errorObject, variants } = checkVariantsErrorIsNullorArrayOrBoolean(settlement, maturity, issue, rate, pr, _basis);
|
|
28589
28918
|
if (isError) return errorObject;
|
|
@@ -28718,6 +29047,7 @@ var Cell = class extends BaseFunction {
|
|
|
28718
29047
|
if (_reference.isError()) return _reference;
|
|
28719
29048
|
if (!_reference.isReferenceObject()) return ErrorValueObject.create("#N/A");
|
|
28720
29049
|
const { columnData, defaultColumnWidth } = _reference.getCurrentActiveSheetData();
|
|
29050
|
+
const forcedSheetName = _reference.getForcedSheetName();
|
|
28721
29051
|
_reference = _reference.toArrayValueObject();
|
|
28722
29052
|
const _currentRow = _reference.getCurrentRow();
|
|
28723
29053
|
const _currentColumn = _reference.getCurrentColumn();
|
|
@@ -28725,7 +29055,7 @@ var Cell = class extends BaseFunction {
|
|
|
28725
29055
|
const infoTypeValue = `${infoType.getValue()}`;
|
|
28726
29056
|
let result;
|
|
28727
29057
|
switch (infoTypeValue.toLocaleLowerCase()) {
|
|
28728
|
-
case "address": return StringValueObject.create(
|
|
29058
|
+
case "address": return StringValueObject.create(`${forcedSheetName ? `${addQuotesBothSides(forcedSheetName)}!` : ""}$${_univerjs_core.Tools.chatAtABC(_currentColumn)}$${_currentRow + 1}`);
|
|
28729
29059
|
case "col": return NumberValueObject.create(_currentColumn + 1);
|
|
28730
29060
|
case "color": return NumberValueObject.create(0);
|
|
28731
29061
|
case "contents": return _reference;
|
|
@@ -28794,7 +29124,7 @@ var Isbetween = class extends BaseFunction {
|
|
|
28794
29124
|
_defineProperty(this, "maxParams", 5);
|
|
28795
29125
|
}
|
|
28796
29126
|
calculate(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive, upperValueIsInclusive) {
|
|
28797
|
-
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive
|
|
29127
|
+
const { isError, errorObject, variants } = checkVariantsErrorIsArray(valueToCompare, lowerValue, upperValue, lowerValueIsInclusive ?? BooleanValueObject.create(true), upperValueIsInclusive ?? BooleanValueObject.create(true));
|
|
28798
29128
|
if (isError) return errorObject;
|
|
28799
29129
|
const [valueToCompareObject, lowerValueObject, upperValueObject, lowerValueIsInclusiveObject, upperValueIsInclusiveObject] = variants;
|
|
28800
29130
|
if (lowerValueIsInclusiveObject.isString() || upperValueIsInclusiveObject.isString()) return ErrorValueObject.create("#VALUE!");
|
|
@@ -28816,8 +29146,13 @@ var Isblank = class extends BaseFunction {
|
|
|
28816
29146
|
super(..._args);
|
|
28817
29147
|
_defineProperty(this, "minParams", 1);
|
|
28818
29148
|
_defineProperty(this, "maxParams", 1);
|
|
29149
|
+
_defineProperty(this, "needsReferenceObject", true);
|
|
28819
29150
|
}
|
|
28820
29151
|
calculate(value) {
|
|
29152
|
+
if (value instanceof BaseReferenceObject) {
|
|
29153
|
+
const array = value.toArrayValueObject(false).mapValue((valueObject) => BooleanValueObject.create(valueObject.isNull()));
|
|
29154
|
+
return array.getRowCount() === 1 && array.getColumnCount() === 1 ? array.getFirstCell() : array;
|
|
29155
|
+
}
|
|
28821
29156
|
if (value.isNull()) return BooleanValueObject.create(true);
|
|
28822
29157
|
else if (value.isArray()) return value.mapValue((valueObject) => {
|
|
28823
29158
|
if (valueObject.isNull()) return BooleanValueObject.create(true);
|
|
@@ -29580,10 +29915,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29580
29915
|
return {
|
|
29581
29916
|
rowCount: array.getRowCount(),
|
|
29582
29917
|
columnCount: array.getColumnCount(),
|
|
29583
|
-
valueAt: (row, column) =>
|
|
29584
|
-
var _array$get;
|
|
29585
|
-
return (_array$get = array.get(row, column)) !== null && _array$get !== void 0 ? _array$get : NullValueObject.create();
|
|
29586
|
-
}
|
|
29918
|
+
valueAt: (row, column) => array.get(row, column) ?? NullValueObject.create()
|
|
29587
29919
|
};
|
|
29588
29920
|
}
|
|
29589
29921
|
return {
|
|
@@ -29653,10 +29985,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29653
29985
|
}
|
|
29654
29986
|
}
|
|
29655
29987
|
_sum(values) {
|
|
29656
|
-
return values.reduce((sum, value) =>
|
|
29657
|
-
var _this$_numericValue;
|
|
29658
|
-
return sum + ((_this$_numericValue = this._numericValue(value)) !== null && _this$_numericValue !== void 0 ? _this$_numericValue : 0);
|
|
29659
|
-
}, 0);
|
|
29988
|
+
return values.reduce((sum, value) => sum + (this._numericValue(value) ?? 0), 0);
|
|
29660
29989
|
}
|
|
29661
29990
|
_numericValue(value) {
|
|
29662
29991
|
return value.isNumber() ? Number(value.getValue()) : void 0;
|
|
@@ -29664,10 +29993,7 @@ var Groupby = class extends BaseFunction {
|
|
|
29664
29993
|
_numberValue(variant) {
|
|
29665
29994
|
if (variant == null || variant.isError()) return 0;
|
|
29666
29995
|
if (variant.isReferenceObject()) variant = variant.getFirstCell();
|
|
29667
|
-
if (variant.isArray())
|
|
29668
|
-
var _get;
|
|
29669
|
-
variant = (_get = variant.get(0, 0)) !== null && _get !== void 0 ? _get : NullValueObject.create();
|
|
29670
|
-
}
|
|
29996
|
+
if (variant.isArray()) variant = variant.get(0, 0) ?? NullValueObject.create();
|
|
29671
29997
|
const value = variant.getValue();
|
|
29672
29998
|
return typeof value === "number" ? Math.trunc(value) : Math.trunc(Number(value) || 0);
|
|
29673
29999
|
}
|
|
@@ -30526,6 +30852,7 @@ var Choose = class extends BaseFunction {
|
|
|
30526
30852
|
super(..._args);
|
|
30527
30853
|
_defineProperty(this, "minParams", 2);
|
|
30528
30854
|
_defineProperty(this, "maxParams", 255);
|
|
30855
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 1 }, (_, index) => index + 1));
|
|
30529
30856
|
_defineProperty(this, "needsReferenceObject", true);
|
|
30530
30857
|
}
|
|
30531
30858
|
calculate(indexNum, ...variants) {
|
|
@@ -30710,7 +31037,7 @@ var Drop = class extends BaseFunction {
|
|
|
30710
31037
|
_defineProperty(this, "maxParams", 3);
|
|
30711
31038
|
}
|
|
30712
31039
|
calculate(array, rows, columns) {
|
|
30713
|
-
const _columns = columns
|
|
31040
|
+
const _columns = columns ?? NumberValueObject.create(0);
|
|
30714
31041
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30715
31042
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30716
31043
|
const maxRowLength = Math.max(rows.isArray() ? rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30785,8 +31112,8 @@ var Expand = class extends BaseFunction {
|
|
|
30785
31112
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
30786
31113
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
30787
31114
|
let _rows = rows;
|
|
30788
|
-
let _columns = columns
|
|
30789
|
-
const _padWith = padWith
|
|
31115
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
31116
|
+
const _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
30790
31117
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
30791
31118
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
30792
31119
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -30878,7 +31205,7 @@ var Filter = class extends BaseFunction {
|
|
|
30878
31205
|
_defineProperty(this, "maxParams", 3);
|
|
30879
31206
|
}
|
|
30880
31207
|
calculate(array, include, ifEmpty) {
|
|
30881
|
-
const _ifEmpty = ifEmpty
|
|
31208
|
+
const _ifEmpty = ifEmpty ?? ErrorValueObject.create("#CALC!");
|
|
30882
31209
|
if (array.isError()) return array;
|
|
30883
31210
|
if (include.isError()) return include;
|
|
30884
31211
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
@@ -31130,7 +31457,7 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31130
31457
|
if (altText.isBoolean()) altTextValue = altText.getValue() ? "TRUE" : "FALSE";
|
|
31131
31458
|
else if (!altText.isNull()) altTextValue = `${altText.getValue()}`;
|
|
31132
31459
|
}
|
|
31133
|
-
let _sizing = sizing
|
|
31460
|
+
let _sizing = sizing ?? NumberValueObject.create(0);
|
|
31134
31461
|
if (_sizing.isString()) _sizing = _sizing.convertToNumberObjectValue();
|
|
31135
31462
|
if (_sizing.isError()) return _sizing;
|
|
31136
31463
|
const sizingValue = Math.abs(Math.trunc(+_sizing.getValue()));
|
|
@@ -31140,11 +31467,11 @@ var ImageFunction = class extends BaseFunction {
|
|
|
31140
31467
|
1,
|
|
31141
31468
|
2
|
|
31142
31469
|
].includes(sizingValue) && (height || width)) return ErrorValueObject.create("#VALUE!");
|
|
31143
|
-
let _height = height
|
|
31470
|
+
let _height = height ?? NumberValueObject.create(0);
|
|
31144
31471
|
if (_height.isString()) _height = _height.convertToNumberObjectValue();
|
|
31145
31472
|
if (_height.isError()) return _height;
|
|
31146
31473
|
const heightValue = Math.ceil(+_height.getValue());
|
|
31147
|
-
let _width = width
|
|
31474
|
+
let _width = width ?? NumberValueObject.create(0);
|
|
31148
31475
|
if (_width.isString()) _width = _width.convertToNumberObjectValue();
|
|
31149
31476
|
if (_width.isError()) return _width;
|
|
31150
31477
|
const widthValue = Math.ceil(+_width.getValue());
|
|
@@ -31186,7 +31513,7 @@ var Index = class extends BaseFunction {
|
|
|
31186
31513
|
if (rowNum.isReferenceObject()) _rowNum = rowNum.toArrayValueObject();
|
|
31187
31514
|
let _columnNum = columnNum;
|
|
31188
31515
|
if (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isReferenceObject()) _columnNum = columnNum.toArrayValueObject();
|
|
31189
|
-
let _areaNum = areaNum
|
|
31516
|
+
let _areaNum = areaNum ?? NumberValueObject.create(1);
|
|
31190
31517
|
if (_areaNum.isReferenceObject()) _areaNum = areaNum.toArrayValueObject();
|
|
31191
31518
|
const maxRowLength = Math.max(_rowNum.isArray() ? _rowNum.getRowCount() : 1, (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isArray()) ? _columnNum.getRowCount() : 1, _areaNum.isArray() ? _areaNum.getRowCount() : 1);
|
|
31192
31519
|
const maxColumnLength = Math.max(_rowNum.isArray() ? _rowNum.getColumnCount() : 1, (_columnNum === null || _columnNum === void 0 ? void 0 : _columnNum.isArray()) ? _columnNum.getColumnCount() : 1, _areaNum.isArray() ? _areaNum.getColumnCount() : 1);
|
|
@@ -31446,6 +31773,7 @@ var Match = class extends BaseFunction {
|
|
|
31446
31773
|
super(..._args);
|
|
31447
31774
|
_defineProperty(this, "minParams", 2);
|
|
31448
31775
|
_defineProperty(this, "maxParams", 3);
|
|
31776
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
31449
31777
|
}
|
|
31450
31778
|
calculate(lookupValue, lookupArray, matchType) {
|
|
31451
31779
|
if (lookupValue.isError()) return lookupValue;
|
|
@@ -31478,236 +31806,6 @@ var Match = class extends BaseFunction {
|
|
|
31478
31806
|
}
|
|
31479
31807
|
};
|
|
31480
31808
|
|
|
31481
|
-
//#endregion
|
|
31482
|
-
//#region src/engine/reference-object/multi-area-reference-object.ts
|
|
31483
|
-
var MultiAreaReferenceObject = class extends BaseReferenceObject {
|
|
31484
|
-
constructor(token, areas = []) {
|
|
31485
|
-
super(token);
|
|
31486
|
-
_defineProperty(this, "_areas", []);
|
|
31487
|
-
this._areas = areas;
|
|
31488
|
-
}
|
|
31489
|
-
dispose() {
|
|
31490
|
-
this._areas.forEach((row) => {
|
|
31491
|
-
row.forEach((a) => a.dispose());
|
|
31492
|
-
});
|
|
31493
|
-
this._areas = [];
|
|
31494
|
-
super.dispose();
|
|
31495
|
-
}
|
|
31496
|
-
getAreas() {
|
|
31497
|
-
return this._areas;
|
|
31498
|
-
}
|
|
31499
|
-
setAreas(areas) {
|
|
31500
|
-
this._areas = areas;
|
|
31501
|
-
}
|
|
31502
|
-
/**
|
|
31503
|
-
* Append an area:
|
|
31504
|
-
* - If a single AreaValue is passed, it will be wrapped as one row.
|
|
31505
|
-
* - If an AreaValue[] is passed, it will be inserted as an entire row.
|
|
31506
|
-
*/
|
|
31507
|
-
addArea(area) {
|
|
31508
|
-
if (Array.isArray(area)) this._areas.push(area);
|
|
31509
|
-
else this._areas.push([area]);
|
|
31510
|
-
}
|
|
31511
|
-
/** Flatten the 2D areas to reuse 1D logic */
|
|
31512
|
-
_flatAreas() {
|
|
31513
|
-
return this._areas.flat();
|
|
31514
|
-
}
|
|
31515
|
-
isMultiArea() {
|
|
31516
|
-
return true;
|
|
31517
|
-
}
|
|
31518
|
-
isRange() {
|
|
31519
|
-
return false;
|
|
31520
|
-
}
|
|
31521
|
-
isCell() {
|
|
31522
|
-
return false;
|
|
31523
|
-
}
|
|
31524
|
-
isRow() {
|
|
31525
|
-
return false;
|
|
31526
|
-
}
|
|
31527
|
-
isColumn() {
|
|
31528
|
-
return false;
|
|
31529
|
-
}
|
|
31530
|
-
getRowCount() {
|
|
31531
|
-
let total = 0;
|
|
31532
|
-
for (const a of this._flatAreas()) {
|
|
31533
|
-
if (a.isError()) continue;
|
|
31534
|
-
total += a.getRowCount();
|
|
31535
|
-
}
|
|
31536
|
-
return total;
|
|
31537
|
-
}
|
|
31538
|
-
getColumnCount() {
|
|
31539
|
-
let total = 0;
|
|
31540
|
-
for (const a of this._flatAreas()) {
|
|
31541
|
-
if (a.isError()) continue;
|
|
31542
|
-
total += a.getColumnCount();
|
|
31543
|
-
}
|
|
31544
|
-
return total;
|
|
31545
|
-
}
|
|
31546
|
-
isExceedRange() {
|
|
31547
|
-
return this._flatAreas().some((a) => {
|
|
31548
|
-
if (a.isError()) return false;
|
|
31549
|
-
return a.isExceedRange();
|
|
31550
|
-
});
|
|
31551
|
-
}
|
|
31552
|
-
setRefOffset(x = 0, y = 0) {
|
|
31553
|
-
super.setRefOffset(x, y);
|
|
31554
|
-
this._flatAreas().forEach((a) => {
|
|
31555
|
-
if (a.isError()) return;
|
|
31556
|
-
a.setRefOffset(x, y);
|
|
31557
|
-
});
|
|
31558
|
-
}
|
|
31559
|
-
_getReferenceArea() {
|
|
31560
|
-
return this._flatAreas().find((a) => !a.isError());
|
|
31561
|
-
}
|
|
31562
|
-
/**
|
|
31563
|
-
* Multi-area reference may span multiple sheets, but Excel requires
|
|
31564
|
-
* them to be in the same sheet for most functions. We follow Excel semantics
|
|
31565
|
-
* by returning the first area’s identifiers.
|
|
31566
|
-
*/
|
|
31567
|
-
getUnitId() {
|
|
31568
|
-
var _this$_getReferenceAr, _this$_getReferenceAr2;
|
|
31569
|
-
return (_this$_getReferenceAr = (_this$_getReferenceAr2 = this._getReferenceArea()) === null || _this$_getReferenceAr2 === void 0 ? void 0 : _this$_getReferenceAr2.getUnitId()) !== null && _this$_getReferenceAr !== void 0 ? _this$_getReferenceAr : super.getUnitId();
|
|
31570
|
-
}
|
|
31571
|
-
getSheetId() {
|
|
31572
|
-
var _this$_getReferenceAr3, _this$_getReferenceAr4;
|
|
31573
|
-
return (_this$_getReferenceAr3 = (_this$_getReferenceAr4 = this._getReferenceArea()) === null || _this$_getReferenceAr4 === void 0 ? void 0 : _this$_getReferenceAr4.getSheetId()) !== null && _this$_getReferenceAr3 !== void 0 ? _this$_getReferenceAr3 : super.getSheetId();
|
|
31574
|
-
}
|
|
31575
|
-
getActiveSheetRowCount() {
|
|
31576
|
-
var _this$_getReferenceAr5, _this$_getReferenceAr6;
|
|
31577
|
-
return (_this$_getReferenceAr5 = (_this$_getReferenceAr6 = this._getReferenceArea()) === null || _this$_getReferenceAr6 === void 0 ? void 0 : _this$_getReferenceAr6.getActiveSheetRowCount()) !== null && _this$_getReferenceAr5 !== void 0 ? _this$_getReferenceAr5 : 0;
|
|
31578
|
-
}
|
|
31579
|
-
getActiveSheetColumnCount() {
|
|
31580
|
-
var _this$_getReferenceAr7, _this$_getReferenceAr8;
|
|
31581
|
-
return (_this$_getReferenceAr7 = (_this$_getReferenceAr8 = this._getReferenceArea()) === null || _this$_getReferenceAr8 === void 0 ? void 0 : _this$_getReferenceAr8.getActiveSheetColumnCount()) !== null && _this$_getReferenceAr7 !== void 0 ? _this$_getReferenceAr7 : 0;
|
|
31582
|
-
}
|
|
31583
|
-
/**
|
|
31584
|
-
* Iterate through all areas in order, flattening the multi-area into
|
|
31585
|
-
* a sequence of cells.
|
|
31586
|
-
*
|
|
31587
|
-
* Note: The order here is "row-major":
|
|
31588
|
-
* iterate by the row order of _areas, then within each row by the area order.
|
|
31589
|
-
*/
|
|
31590
|
-
iterator(callback) {
|
|
31591
|
-
for (const row of this._areas) {
|
|
31592
|
-
let stopRow = false;
|
|
31593
|
-
for (const area of row) {
|
|
31594
|
-
if (area.isError()) continue;
|
|
31595
|
-
let stopArea = false;
|
|
31596
|
-
area.iterator((v, r, c) => {
|
|
31597
|
-
const res = callback(v, r, c);
|
|
31598
|
-
if (res === false) {
|
|
31599
|
-
stopArea = true;
|
|
31600
|
-
stopRow = true;
|
|
31601
|
-
return false;
|
|
31602
|
-
}
|
|
31603
|
-
return res;
|
|
31604
|
-
});
|
|
31605
|
-
if (stopArea) break;
|
|
31606
|
-
}
|
|
31607
|
-
if (stopRow) return;
|
|
31608
|
-
}
|
|
31609
|
-
}
|
|
31610
|
-
/**
|
|
31611
|
-
* Excel defines the "first cell" of a multi-area reference
|
|
31612
|
-
* as the first cell of the first area.
|
|
31613
|
-
*/
|
|
31614
|
-
getFirstCell() {
|
|
31615
|
-
const first = this._getReferenceArea();
|
|
31616
|
-
if (!first) return super.getFirstCell();
|
|
31617
|
-
return first.getFirstCell();
|
|
31618
|
-
}
|
|
31619
|
-
/**
|
|
31620
|
-
* For multi-area, we only take the *first cell* of each area and
|
|
31621
|
-
* arrange them into a 2D ArrayValueObject:
|
|
31622
|
-
*
|
|
31623
|
-
* - outer `_areas` dimension => rows
|
|
31624
|
-
* - inner `_areas[row]` dimension => columns
|
|
31625
|
-
*/
|
|
31626
|
-
toArrayValueObject() {
|
|
31627
|
-
var _this$_areas$0$length, _this$_areas$;
|
|
31628
|
-
const rows = this._areas.length;
|
|
31629
|
-
if (rows === 0) return createNewArray([], 0, 0);
|
|
31630
|
-
const cols = (_this$_areas$0$length = (_this$_areas$ = this._areas[0]) === null || _this$_areas$ === void 0 ? void 0 : _this$_areas$.length) !== null && _this$_areas$0$length !== void 0 ? _this$_areas$0$length : 0;
|
|
31631
|
-
const result = [];
|
|
31632
|
-
for (let r = 0; r < rows; r++) {
|
|
31633
|
-
const rowAreas = this._areas[r];
|
|
31634
|
-
if (!rowAreas) continue;
|
|
31635
|
-
result[r] = result[r] || [];
|
|
31636
|
-
for (let c = 0; c < cols; c++) {
|
|
31637
|
-
const area = rowAreas[c];
|
|
31638
|
-
if (!area) continue;
|
|
31639
|
-
if (area.isError()) {
|
|
31640
|
-
result[r][c] = area;
|
|
31641
|
-
continue;
|
|
31642
|
-
}
|
|
31643
|
-
let firstValue = null;
|
|
31644
|
-
area.iterator((v) => {
|
|
31645
|
-
firstValue = v !== null && v !== void 0 ? v : null;
|
|
31646
|
-
return false;
|
|
31647
|
-
});
|
|
31648
|
-
if (firstValue != null) result[r][c] = firstValue;
|
|
31649
|
-
result[r][c] = NullValueObject.create();
|
|
31650
|
-
}
|
|
31651
|
-
}
|
|
31652
|
-
return createNewArray(result, rows, cols);
|
|
31653
|
-
}
|
|
31654
|
-
getRangePosition() {
|
|
31655
|
-
const flat = this._flatAreas();
|
|
31656
|
-
if (!flat.length) return super.getRangePosition();
|
|
31657
|
-
let minStartRow = Number.POSITIVE_INFINITY;
|
|
31658
|
-
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
31659
|
-
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
31660
|
-
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
31661
|
-
for (const area of flat) {
|
|
31662
|
-
if (area.isError()) continue;
|
|
31663
|
-
const { startRow, startColumn, endRow, endColumn } = area.getRangePosition();
|
|
31664
|
-
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
31665
|
-
if (startRow < minStartRow) minStartRow = startRow;
|
|
31666
|
-
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
31667
|
-
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
31668
|
-
if (endColumn > maxEndColumn) maxEndColumn = maxEndColumn < endColumn ? endColumn : maxEndColumn;
|
|
31669
|
-
}
|
|
31670
|
-
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangePosition();
|
|
31671
|
-
return {
|
|
31672
|
-
startRow: minStartRow,
|
|
31673
|
-
startColumn: minStartColumn,
|
|
31674
|
-
endRow: maxEndRow,
|
|
31675
|
-
endColumn: maxEndColumn
|
|
31676
|
-
};
|
|
31677
|
-
}
|
|
31678
|
-
toUnitRange() {
|
|
31679
|
-
return {
|
|
31680
|
-
range: this.getRangePosition(),
|
|
31681
|
-
sheetId: this.getSheetId(),
|
|
31682
|
-
unitId: this.getUnitId()
|
|
31683
|
-
};
|
|
31684
|
-
}
|
|
31685
|
-
getRangeData() {
|
|
31686
|
-
const flat = this._flatAreas();
|
|
31687
|
-
if (!flat.length) return super.getRangeData();
|
|
31688
|
-
let minStartRow = Number.POSITIVE_INFINITY;
|
|
31689
|
-
let minStartColumn = Number.POSITIVE_INFINITY;
|
|
31690
|
-
let maxEndRow = Number.NEGATIVE_INFINITY;
|
|
31691
|
-
let maxEndColumn = Number.NEGATIVE_INFINITY;
|
|
31692
|
-
for (const area of flat) {
|
|
31693
|
-
if (area.isError()) continue;
|
|
31694
|
-
const { startRow, startColumn, endRow, endColumn } = area.getRangeData();
|
|
31695
|
-
if (!Number.isFinite(startRow) || !Number.isFinite(startColumn) || !Number.isFinite(endRow) || !Number.isFinite(endColumn)) continue;
|
|
31696
|
-
if (startRow < minStartRow) minStartRow = startRow;
|
|
31697
|
-
if (startColumn < minStartColumn) minStartColumn = startColumn;
|
|
31698
|
-
if (endRow > maxEndRow) maxEndRow = endRow;
|
|
31699
|
-
if (endColumn > maxEndColumn) maxEndColumn = endColumn;
|
|
31700
|
-
}
|
|
31701
|
-
if (!Number.isFinite(minStartRow) || !Number.isFinite(minStartColumn) || !Number.isFinite(maxEndRow) || !Number.isFinite(maxEndColumn)) return super.getRangeData();
|
|
31702
|
-
return {
|
|
31703
|
-
startRow: minStartRow,
|
|
31704
|
-
startColumn: minStartColumn,
|
|
31705
|
-
endRow: maxEndRow,
|
|
31706
|
-
endColumn: maxEndColumn
|
|
31707
|
-
};
|
|
31708
|
-
}
|
|
31709
|
-
};
|
|
31710
|
-
|
|
31711
31809
|
//#endregion
|
|
31712
31810
|
//#region src/functions/lookup/offset/index.ts
|
|
31713
31811
|
var Offset = class extends BaseFunction {
|
|
@@ -31733,10 +31831,10 @@ var Offset = class extends BaseFunction {
|
|
|
31733
31831
|
if (_rows.isReferenceObject()) _rows = _rows.toArrayValueObject();
|
|
31734
31832
|
let _columns = columns;
|
|
31735
31833
|
if (_columns.isReferenceObject()) _columns = _columns.toArrayValueObject();
|
|
31736
|
-
let _height = height
|
|
31834
|
+
let _height = height ?? NumberValueObject.create(rowCount);
|
|
31737
31835
|
if (_height.isReferenceObject()) _height = _height.toArrayValueObject();
|
|
31738
31836
|
if (_height.isNull()) _height = NumberValueObject.create(rowCount);
|
|
31739
|
-
let _width = width
|
|
31837
|
+
let _width = width ?? NumberValueObject.create(columnCount);
|
|
31740
31838
|
if (_width.isReferenceObject()) _width = _width.toArrayValueObject();
|
|
31741
31839
|
if (_width.isNull()) _width = NumberValueObject.create(columnCount);
|
|
31742
31840
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1, _height.isArray() ? _height.getRowCount() : 1, _width.isArray() ? _width.getRowCount() : 1);
|
|
@@ -31873,9 +31971,9 @@ var Sort = class extends BaseFunction {
|
|
|
31873
31971
|
_defineProperty(this, "maxParams", 4);
|
|
31874
31972
|
}
|
|
31875
31973
|
calculate(array, sortIndex, sortOrder, byCol) {
|
|
31876
|
-
let _sortIndex = sortIndex
|
|
31877
|
-
let _sortOrder = sortOrder
|
|
31878
|
-
const _byCol = byCol
|
|
31974
|
+
let _sortIndex = sortIndex ?? NumberValueObject.create(1);
|
|
31975
|
+
let _sortOrder = sortOrder ?? NumberValueObject.create(1);
|
|
31976
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
31879
31977
|
if (_sortIndex.isNull()) _sortIndex = NumberValueObject.create(1);
|
|
31880
31978
|
if (_sortOrder.isNull()) _sortOrder = NumberValueObject.create(1);
|
|
31881
31979
|
if (_byCol.isArray()) {
|
|
@@ -32212,7 +32310,7 @@ var Take = class extends BaseFunction {
|
|
|
32212
32310
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32213
32311
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32214
32312
|
let _rows = rows;
|
|
32215
|
-
let _columns = columns
|
|
32313
|
+
let _columns = columns ?? NumberValueObject.create(arrayColumnCount);
|
|
32216
32314
|
if (rows.isNull()) _rows = NumberValueObject.create(arrayRowCount);
|
|
32217
32315
|
if (_columns.isNull()) _columns = NumberValueObject.create(arrayColumnCount);
|
|
32218
32316
|
const maxRowLength = Math.max(_rows.isArray() ? _rows.getRowCount() : 1, _columns.isArray() ? _columns.getRowCount() : 1);
|
|
@@ -32287,8 +32385,8 @@ var Tocol = class extends BaseFunction {
|
|
|
32287
32385
|
_defineProperty(this, "maxParams", 3);
|
|
32288
32386
|
}
|
|
32289
32387
|
calculate(array, ignore, scanByColumn) {
|
|
32290
|
-
const _ignore = ignore
|
|
32291
|
-
const _scanByColumn = scanByColumn
|
|
32388
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32389
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32292
32390
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32293
32391
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32294
32392
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32363,8 +32461,8 @@ var Torow = class extends BaseFunction {
|
|
|
32363
32461
|
_defineProperty(this, "maxParams", 3);
|
|
32364
32462
|
}
|
|
32365
32463
|
calculate(array, ignore, scanByColumn) {
|
|
32366
|
-
const _ignore = ignore
|
|
32367
|
-
const _scanByColumn = scanByColumn
|
|
32464
|
+
const _ignore = ignore ?? NumberValueObject.create(0);
|
|
32465
|
+
const _scanByColumn = scanByColumn ?? BooleanValueObject.create(false);
|
|
32368
32466
|
const maxRowLength = Math.max(_ignore.isArray() ? _ignore.getRowCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getRowCount() : 1);
|
|
32369
32467
|
const maxColumnLength = Math.max(_ignore.isArray() ? _ignore.getColumnCount() : 1, _scanByColumn.isArray() ? _scanByColumn.getColumnCount() : 1);
|
|
32370
32468
|
const ignoreArray = expandArrayValueObject(maxRowLength, maxColumnLength, _ignore, ErrorValueObject.create("#N/A"));
|
|
@@ -32459,8 +32557,8 @@ var Unique = class extends BaseFunction {
|
|
|
32459
32557
|
_defineProperty(this, "maxParams", 3);
|
|
32460
32558
|
}
|
|
32461
32559
|
calculate(array, byCol, exactlyOnce) {
|
|
32462
|
-
const _byCol = byCol
|
|
32463
|
-
const _exactlyOnce = exactlyOnce
|
|
32560
|
+
const _byCol = byCol ?? BooleanValueObject.create(false);
|
|
32561
|
+
const _exactlyOnce = exactlyOnce ?? BooleanValueObject.create(false);
|
|
32464
32562
|
const arrayRowCount = array.isArray() ? array.getRowCount() : 1;
|
|
32465
32563
|
const arrayColumnCount = array.isArray() ? array.getColumnCount() : 1;
|
|
32466
32564
|
const maxRowLength = Math.max(_byCol.isArray() ? _byCol.getRowCount() : 1, _exactlyOnce.isArray() ? _exactlyOnce.getRowCount() : 1);
|
|
@@ -32589,7 +32687,7 @@ var Vlookup = class extends BaseFunction {
|
|
|
32589
32687
|
if (!tableArray.isArray()) return ErrorValueObject.create("#VALUE!");
|
|
32590
32688
|
if (colIndexNum.isError()) return colIndexNum;
|
|
32591
32689
|
if (rangeLookup === null || rangeLookup === void 0 ? void 0 : rangeLookup.isError()) return rangeLookup;
|
|
32592
|
-
const _rangeLookup = rangeLookup
|
|
32690
|
+
const _rangeLookup = rangeLookup ?? BooleanValueObject.create(true);
|
|
32593
32691
|
if (isSingleValueObject(lookupValue) && isSingleValueObject(_rangeLookup) && colIndexNum.isArray()) return this._handleArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32594
32692
|
return this._handleNonArrayColIndexNum(lookupValue, tableArray, colIndexNum, _rangeLookup);
|
|
32595
32693
|
}
|
|
@@ -32712,7 +32810,7 @@ var Wrapcols = class extends BaseFunction {
|
|
|
32712
32810
|
_defineProperty(this, "maxParams", 3);
|
|
32713
32811
|
}
|
|
32714
32812
|
calculate(vector, wrapCount, padWith) {
|
|
32715
|
-
let _padWith = padWith
|
|
32813
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32716
32814
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32717
32815
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32718
32816
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32767,7 +32865,7 @@ var Wraprows = class extends BaseFunction {
|
|
|
32767
32865
|
_defineProperty(this, "maxParams", 3);
|
|
32768
32866
|
}
|
|
32769
32867
|
calculate(vector, wrapCount, padWith) {
|
|
32770
|
-
let _padWith = padWith
|
|
32868
|
+
let _padWith = padWith ?? ErrorValueObject.create("#N/A");
|
|
32771
32869
|
if (_padWith.isNull()) _padWith = ErrorValueObject.create("#N/A");
|
|
32772
32870
|
const vectorRowCount = vector.isArray() ? vector.getRowCount() : 1;
|
|
32773
32871
|
const vectorColumnCount = vector.isArray() ? vector.getColumnCount() : 1;
|
|
@@ -32825,13 +32923,13 @@ var Xlookup = class extends BaseFunction {
|
|
|
32825
32923
|
_defineProperty(this, "maxParams", 6);
|
|
32826
32924
|
}
|
|
32827
32925
|
calculate(lookupValue, lookupArray, returnArray, ifNotFound, matchMode, searchMode) {
|
|
32828
|
-
let _ifNotFound = ifNotFound
|
|
32926
|
+
let _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
32829
32927
|
if (ifNotFound === null || ifNotFound === void 0 ? void 0 : ifNotFound.isNull()) _ifNotFound = ErrorValueObject.create("#N/A");
|
|
32830
|
-
let _matchMode = matchMode
|
|
32928
|
+
let _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
32831
32929
|
if (matchMode === null || matchMode === void 0 ? void 0 : matchMode.isNull()) _matchMode = NumberValueObject.create(0);
|
|
32832
|
-
let _searchMode = searchMode
|
|
32930
|
+
let _searchMode = searchMode ?? NumberValueObject.create(1);
|
|
32833
32931
|
if (searchMode === null || searchMode === void 0 ? void 0 : searchMode.isNull()) _searchMode = NumberValueObject.create(1);
|
|
32834
|
-
const _lookupValue = this._legacyImplicitLookupValue(lookupValue);
|
|
32932
|
+
const _lookupValue = this.currentFormulaRowCount > 1 || this.currentFormulaColumnCount > 1 ? lookupValue : this._legacyImplicitLookupValue(lookupValue);
|
|
32835
32933
|
if (_lookupValue.isError()) return _lookupValue;
|
|
32836
32934
|
const rowCountLookup = lookupArray.isArray() ? lookupArray.getRowCount() : 1;
|
|
32837
32935
|
const columnCountLookup = lookupArray.isArray() ? lookupArray.getColumnCount() : 1;
|
|
@@ -33467,7 +33565,7 @@ var Base = class extends BaseFunction {
|
|
|
33467
33565
|
_defineProperty(this, "maxParams", 3);
|
|
33468
33566
|
}
|
|
33469
33567
|
calculate(number, radix, minLength) {
|
|
33470
|
-
const _minLength = minLength
|
|
33568
|
+
const _minLength = minLength ?? NumberValueObject.create(0);
|
|
33471
33569
|
if (number.isError()) return number;
|
|
33472
33570
|
if (radix.isError()) return radix;
|
|
33473
33571
|
if (_minLength.isError()) return _minLength;
|
|
@@ -33549,8 +33647,8 @@ var CeilingMath = class extends BaseFunction {
|
|
|
33549
33647
|
_defineProperty(this, "maxParams", 3);
|
|
33550
33648
|
}
|
|
33551
33649
|
calculate(number, significance, mode) {
|
|
33552
|
-
const _significance = significance
|
|
33553
|
-
const _mode = mode
|
|
33650
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33651
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
33554
33652
|
if (number.isError()) return number;
|
|
33555
33653
|
if (_significance.isError()) return _significance;
|
|
33556
33654
|
if (_mode.isError()) return _mode;
|
|
@@ -33595,7 +33693,7 @@ var CeilingPrecise = class extends BaseFunction {
|
|
|
33595
33693
|
_defineProperty(this, "maxParams", 2);
|
|
33596
33694
|
}
|
|
33597
33695
|
calculate(number, significance) {
|
|
33598
|
-
const _significance = significance
|
|
33696
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
33599
33697
|
if (number.isError()) return number;
|
|
33600
33698
|
if (_significance.isError()) return _significance;
|
|
33601
33699
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -34009,8 +34107,8 @@ var FloorMath = class extends BaseFunction {
|
|
|
34009
34107
|
_defineProperty(this, "maxParams", 3);
|
|
34010
34108
|
}
|
|
34011
34109
|
calculate(number, significance, mode) {
|
|
34012
|
-
const _significance = significance
|
|
34013
|
-
const _mode = mode
|
|
34110
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34111
|
+
const _mode = mode ?? NumberValueObject.create(0);
|
|
34014
34112
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1, _mode.isArray() ? _mode.getRowCount() : 1);
|
|
34015
34113
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1, _mode.isArray() ? _mode.getColumnCount() : 1);
|
|
34016
34114
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -34049,7 +34147,7 @@ var FloorPrecise = class extends BaseFunction {
|
|
|
34049
34147
|
_defineProperty(this, "maxParams", 2);
|
|
34050
34148
|
}
|
|
34051
34149
|
calculate(number, significance) {
|
|
34052
|
-
const _significance = significance
|
|
34150
|
+
const _significance = significance ?? NumberValueObject.create(1);
|
|
34053
34151
|
if (number.isError()) return number;
|
|
34054
34152
|
if (_significance.isError()) return _significance;
|
|
34055
34153
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
@@ -34249,7 +34347,7 @@ var Log = class extends BaseFunction {
|
|
|
34249
34347
|
_defineProperty(this, "maxParams", 2);
|
|
34250
34348
|
}
|
|
34251
34349
|
calculate(number, base) {
|
|
34252
|
-
const _base = base
|
|
34350
|
+
const _base = base ?? NumberValueObject.create(10);
|
|
34253
34351
|
if (number.isError()) return number;
|
|
34254
34352
|
if (_base.isError()) return _base;
|
|
34255
34353
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _base.isArray() ? _base.getRowCount() : 1);
|
|
@@ -34762,11 +34860,11 @@ var Randarray = class extends BaseFunction {
|
|
|
34762
34860
|
if (min === null || min === void 0 ? void 0 : min.isError()) return min;
|
|
34763
34861
|
if (max === null || max === void 0 ? void 0 : max.isError()) return max;
|
|
34764
34862
|
if (wholeNumber === null || wholeNumber === void 0 ? void 0 : wholeNumber.isError()) return wholeNumber;
|
|
34765
|
-
const _rows = rows
|
|
34766
|
-
const _columns = columns
|
|
34767
|
-
const _min = min
|
|
34768
|
-
const _max = max
|
|
34769
|
-
const _wholeNumber = wholeNumber
|
|
34863
|
+
const _rows = rows ?? NumberValueObject.create(1);
|
|
34864
|
+
const _columns = columns ?? NumberValueObject.create(1);
|
|
34865
|
+
const _min = min ?? NumberValueObject.create(0);
|
|
34866
|
+
const _max = max ?? NumberValueObject.create(1);
|
|
34867
|
+
const _wholeNumber = wholeNumber ?? NumberValueObject.create(0);
|
|
34770
34868
|
return this._calculateResult(_rows, _columns, _min, _max, _wholeNumber);
|
|
34771
34869
|
}
|
|
34772
34870
|
_calculateResult(rows, columns, min, max, wholeNumber) {
|
|
@@ -34913,7 +35011,7 @@ var Roman = class extends BaseFunction {
|
|
|
34913
35011
|
_defineProperty(this, "maxParams", 2);
|
|
34914
35012
|
}
|
|
34915
35013
|
calculate(number, form) {
|
|
34916
|
-
const _form = form
|
|
35014
|
+
const _form = form ?? NumberValueObject.create(0);
|
|
34917
35015
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _form.isArray() ? _form.getRowCount() : 1);
|
|
34918
35016
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _form.isArray() ? _form.getColumnCount() : 1);
|
|
34919
35017
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -35120,9 +35218,9 @@ var Sequence = class extends BaseFunction {
|
|
|
35120
35218
|
}
|
|
35121
35219
|
calculate(rows, columns, start, step) {
|
|
35122
35220
|
let _rows = rows;
|
|
35123
|
-
let _columns = columns
|
|
35124
|
-
let _start = start
|
|
35125
|
-
let _step = step
|
|
35221
|
+
let _columns = columns ?? NumberValueObject.create(1);
|
|
35222
|
+
let _start = start ?? NumberValueObject.create(1);
|
|
35223
|
+
let _step = step ?? NumberValueObject.create(1);
|
|
35126
35224
|
if (_rows.isNull()) _rows = NumberValueObject.create(1);
|
|
35127
35225
|
if (_columns.isNull()) _columns = NumberValueObject.create(1);
|
|
35128
35226
|
if (_start.isNull()) _start = NumberValueObject.create(1);
|
|
@@ -35476,8 +35574,7 @@ var Subtotal = class extends BaseFunction {
|
|
|
35476
35574
|
multiAreaRefs.forEach((ref) => {
|
|
35477
35575
|
const rowAreas = ref.getAreas().map((row) => {
|
|
35478
35576
|
if (!row || row.length === 0) return ref;
|
|
35479
|
-
|
|
35480
|
-
return firstNonError !== null && firstNonError !== void 0 ? firstNonError : row[0];
|
|
35577
|
+
return row.find((a) => !a.isError()) ?? row[0];
|
|
35481
35578
|
});
|
|
35482
35579
|
multiAreaInfoMap.set(ref, {
|
|
35483
35580
|
ref,
|
|
@@ -35626,6 +35723,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35626
35723
|
super(..._args);
|
|
35627
35724
|
_defineProperty(this, "minParams", 1);
|
|
35628
35725
|
_defineProperty(this, "maxParams", 255);
|
|
35726
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
35629
35727
|
}
|
|
35630
35728
|
calculate(array1, ...variants) {
|
|
35631
35729
|
if (array1.isError()) return array1;
|
|
@@ -35688,8 +35786,7 @@ var Sumproduct = class extends BaseFunction {
|
|
|
35688
35786
|
*/
|
|
35689
35787
|
_getVariantCell(variant, row, col) {
|
|
35690
35788
|
if (!variant.isArray()) return variant;
|
|
35691
|
-
|
|
35692
|
-
return cell !== null && cell !== void 0 ? cell : null;
|
|
35789
|
+
return variant.get(row, col) ?? null;
|
|
35693
35790
|
}
|
|
35694
35791
|
_initArray1(array1) {
|
|
35695
35792
|
let _array1 = array1;
|
|
@@ -35971,7 +36068,7 @@ var Trunc = class extends BaseFunction {
|
|
|
35971
36068
|
_defineProperty(this, "maxParams", 2);
|
|
35972
36069
|
}
|
|
35973
36070
|
calculate(number, numDigits) {
|
|
35974
|
-
const _numDigits = numDigits
|
|
36071
|
+
const _numDigits = numDigits ?? NumberValueObject.create(0);
|
|
35975
36072
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _numDigits.isArray() ? _numDigits.getRowCount() : 1);
|
|
35976
36073
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _numDigits.isArray() ? _numDigits.getColumnCount() : 1);
|
|
35977
36074
|
const numberArray = expandArrayValueObject(maxRowLength, maxColumnLength, number, ErrorValueObject.create("#N/A"));
|
|
@@ -36616,8 +36713,8 @@ var BetaDist = class extends BaseFunction {
|
|
|
36616
36713
|
_defineProperty(this, "maxParams", 6);
|
|
36617
36714
|
}
|
|
36618
36715
|
calculate(x, alpha, beta, cumulative, A, B) {
|
|
36619
|
-
let _A = A
|
|
36620
|
-
let _B = B
|
|
36716
|
+
let _A = A ?? NumberValueObject.create(0);
|
|
36717
|
+
let _B = B ?? NumberValueObject.create(1);
|
|
36621
36718
|
if (_A.isNull()) _A = NumberValueObject.create(0);
|
|
36622
36719
|
if (_B.isNull()) _B = NumberValueObject.create(1);
|
|
36623
36720
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, alpha.isArray() ? alpha.getRowCount() : 1, beta.isArray() ? beta.getRowCount() : 1, cumulative.isArray() ? cumulative.getRowCount() : 1, _A.isArray() ? _A.getRowCount() : 1, _B.isArray() ? _B.getRowCount() : 1);
|
|
@@ -36672,7 +36769,7 @@ var BinomDistRange = class extends BaseFunction {
|
|
|
36672
36769
|
_defineProperty(this, "maxParams", 4);
|
|
36673
36770
|
}
|
|
36674
36771
|
calculate(trials, probabilityS, numberS, numberS2) {
|
|
36675
|
-
let _numberS2 = numberS2
|
|
36772
|
+
let _numberS2 = numberS2 ?? numberS;
|
|
36676
36773
|
if (_numberS2.isNull()) _numberS2 = numberS;
|
|
36677
36774
|
const maxRowLength = Math.max(trials.isArray() ? trials.getRowCount() : 1, probabilityS.isArray() ? probabilityS.getRowCount() : 1, numberS.isArray() ? numberS.getRowCount() : 1, _numberS2.isArray() ? _numberS2.getRowCount() : 1);
|
|
36678
36775
|
const maxColumnLength = Math.max(trials.isArray() ? trials.getColumnCount() : 1, probabilityS.isArray() ? probabilityS.getColumnCount() : 1, numberS.isArray() ? numberS.getColumnCount() : 1, _numberS2.isArray() ? _numberS2.getColumnCount() : 1);
|
|
@@ -37545,7 +37642,7 @@ var Growth = class extends BaseFunction {
|
|
|
37545
37642
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37546
37643
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
37547
37644
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
37548
|
-
let _constb = constb
|
|
37645
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37549
37646
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37550
37647
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
37551
37648
|
if (_constb.isError()) return _constb;
|
|
@@ -37825,9 +37922,9 @@ var Linest = class extends BaseFunction {
|
|
|
37825
37922
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37826
37923
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37827
37924
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37828
|
-
let _constb = constb
|
|
37925
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37829
37926
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37830
|
-
let _stats = stats
|
|
37927
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37831
37928
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37832
37929
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37833
37930
|
if (_isError) return _errorObject;
|
|
@@ -37982,9 +38079,9 @@ var Logest = class extends BaseFunction {
|
|
|
37982
38079
|
if (knownYsValues instanceof ErrorValueObject) return knownYsValues;
|
|
37983
38080
|
const knownXsValues = this._getKnownXsValues(knownYsValues, knownXs);
|
|
37984
38081
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
37985
|
-
let _constb = constb
|
|
38082
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
37986
38083
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
37987
|
-
let _stats = stats
|
|
38084
|
+
let _stats = stats ?? BooleanValueObject.create(false);
|
|
37988
38085
|
if (_stats.isArray()) _stats = _stats.get(0, 0);
|
|
37989
38086
|
const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(_constb, _stats);
|
|
37990
38087
|
if (_isError) return _errorObject;
|
|
@@ -38324,6 +38421,7 @@ var Median = class extends BaseFunction {
|
|
|
38324
38421
|
super(..._args);
|
|
38325
38422
|
_defineProperty(this, "minParams", 1);
|
|
38326
38423
|
_defineProperty(this, "maxParams", 255);
|
|
38424
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams }, (_, index) => index));
|
|
38327
38425
|
}
|
|
38328
38426
|
calculate(...variants) {
|
|
38329
38427
|
const values = [];
|
|
@@ -38654,6 +38752,7 @@ var PercentileExc = class extends BaseFunction {
|
|
|
38654
38752
|
super(..._args);
|
|
38655
38753
|
_defineProperty(this, "minParams", 2);
|
|
38656
38754
|
_defineProperty(this, "maxParams", 2);
|
|
38755
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [0]);
|
|
38657
38756
|
}
|
|
38658
38757
|
calculate(array, k) {
|
|
38659
38758
|
const arrayValues = getArrayValuesByAggregateIgnoreOptions(array);
|
|
@@ -38683,7 +38782,7 @@ var PercentrankExc = class extends BaseFunction {
|
|
|
38683
38782
|
}
|
|
38684
38783
|
calculate(array, x, significance) {
|
|
38685
38784
|
const arrayValues = this._getValues(array);
|
|
38686
|
-
let _significance = significance
|
|
38785
|
+
let _significance = significance ?? NumberValueObject.create(3);
|
|
38687
38786
|
if (_significance.isNull()) _significance = NumberValueObject.create(3);
|
|
38688
38787
|
const maxRowLength = Math.max(x.isArray() ? x.getRowCount() : 1, _significance.isArray() ? _significance.getRowCount() : 1);
|
|
38689
38788
|
const maxColumnLength = Math.max(x.isArray() ? x.getColumnCount() : 1, _significance.isArray() ? _significance.getColumnCount() : 1);
|
|
@@ -38846,7 +38945,7 @@ var Prob = class extends BaseFunction {
|
|
|
38846
38945
|
}
|
|
38847
38946
|
calculate(xRange, probRange, lowerLimit, upperLimit) {
|
|
38848
38947
|
const { isError, errorObject, xRangeValues, probRangeValues } = this._handleXRangeAndProbRange(xRange, probRange);
|
|
38849
|
-
let _upperLimit = upperLimit
|
|
38948
|
+
let _upperLimit = upperLimit ?? lowerLimit;
|
|
38850
38949
|
if (upperLimit === null || upperLimit === void 0 ? void 0 : upperLimit.isNull()) _upperLimit = lowerLimit;
|
|
38851
38950
|
const maxRowLength = Math.max(lowerLimit.isArray() ? lowerLimit.getRowCount() : 1, _upperLimit.isArray() ? _upperLimit.getRowCount() : 1);
|
|
38852
38951
|
const maxColumnLength = Math.max(lowerLimit.isArray() ? lowerLimit.getColumnCount() : 1, _upperLimit.isArray() ? _upperLimit.getColumnCount() : 1);
|
|
@@ -38971,12 +39070,13 @@ var RankAvg = class extends BaseFunction {
|
|
|
38971
39070
|
_defineProperty(this, "minParams", 2);
|
|
38972
39071
|
_defineProperty(this, "maxParams", 3);
|
|
38973
39072
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39073
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
38974
39074
|
}
|
|
38975
39075
|
calculate(number, ref, order) {
|
|
38976
39076
|
let _number = number;
|
|
38977
39077
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
38978
39078
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
38979
|
-
let _order = order
|
|
39079
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
38980
39080
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
38981
39081
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
38982
39082
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39045,12 +39145,13 @@ var RankEq = class extends BaseFunction {
|
|
|
39045
39145
|
_defineProperty(this, "minParams", 2);
|
|
39046
39146
|
_defineProperty(this, "maxParams", 3);
|
|
39047
39147
|
_defineProperty(this, "needsReferenceObject", true);
|
|
39148
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", [1]);
|
|
39048
39149
|
}
|
|
39049
39150
|
calculate(number, ref, order) {
|
|
39050
39151
|
let _number = number;
|
|
39051
39152
|
if (_number.isReferenceObject()) _number = _number.toArrayValueObject();
|
|
39052
39153
|
const { refHasError, refErrorObject, refNumbers } = this._checkRefReferenceObject(ref);
|
|
39053
|
-
let _order = order
|
|
39154
|
+
let _order = order ?? NumberValueObject.create(0);
|
|
39054
39155
|
if (_order.isReferenceObject()) _order = _order.toArrayValueObject();
|
|
39055
39156
|
const maxRowLength = Math.max(_number.isArray() ? _number.getRowCount() : 1, _order.isArray() ? _order.getRowCount() : 1);
|
|
39056
39157
|
const maxColumnLength = Math.max(_number.isArray() ? _number.getColumnCount() : 1, _order.isArray() ? _order.getColumnCount() : 1);
|
|
@@ -39609,7 +39710,7 @@ var Trend = class extends BaseFunction {
|
|
|
39609
39710
|
if (knownXsValues instanceof ErrorValueObject) return knownXsValues;
|
|
39610
39711
|
const newXsValues = this._getNewXsValues(knownXsValues, newXs);
|
|
39611
39712
|
if (newXsValues instanceof ErrorValueObject) return newXsValues;
|
|
39612
|
-
let _constb = constb
|
|
39713
|
+
let _constb = constb ?? BooleanValueObject.create(true);
|
|
39613
39714
|
if (_constb.isArray()) _constb = _constb.get(0, 0);
|
|
39614
39715
|
if (_constb.isString()) _constb = _constb.convertToNumberObjectValue();
|
|
39615
39716
|
if (_constb.isError()) return _constb;
|
|
@@ -39878,7 +39979,7 @@ var Arraytotext = class extends BaseFunction {
|
|
|
39878
39979
|
_defineProperty(this, "maxParams", 2);
|
|
39879
39980
|
}
|
|
39880
39981
|
calculate(array, format) {
|
|
39881
|
-
let _format = format
|
|
39982
|
+
let _format = format ?? NumberValueObject.create(0);
|
|
39882
39983
|
if (format === null || format === void 0 ? void 0 : format.isNull()) _format = NumberValueObject.create(0);
|
|
39883
39984
|
if (_format.isArray()) {
|
|
39884
39985
|
const resultArray = _format.mapValue((formatObject) => this._handleSingleObject(array, formatObject));
|
|
@@ -40188,12 +40289,11 @@ var Concatenate = class extends BaseFunction {
|
|
|
40188
40289
|
return arrayValue.getUnitId() !== "" && arrayValue.getSheetId() !== "" && arrayValue.getCurrentRow() >= 0 && arrayValue.getCurrentColumn() >= 0;
|
|
40189
40290
|
});
|
|
40190
40291
|
for (const textValue of textValues) result = expandArrayValueObject(maxRowLength, maxColumnLength, textValue, ErrorValueObject.create("#N/A")).mapValue((textValueObject, rowIndex, columnIndex) => {
|
|
40191
|
-
var _resultValueObject$ge, _textValueObject$getV;
|
|
40192
40292
|
const resultValueObject = result && result.get(rowIndex, columnIndex);
|
|
40193
40293
|
if (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isError()) return resultValueObject;
|
|
40194
40294
|
if (textValueObject.isError()) return textValueObject;
|
|
40195
|
-
const resultValueObjectString = (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isNull()) ? "" : formatValueForFormulaText((
|
|
40196
|
-
const textValueObjectString = (textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.isNull()) ? "" : formatValueForFormulaText((
|
|
40295
|
+
const resultValueObjectString = (resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.isNull()) ? "" : formatValueForFormulaText((resultValueObject === null || resultValueObject === void 0 ? void 0 : resultValueObject.getValue()) ?? null);
|
|
40296
|
+
const textValueObjectString = (textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.isNull()) ? "" : formatValueForFormulaText((textValueObject === null || textValueObject === void 0 ? void 0 : textValueObject.getValue()) ?? null);
|
|
40197
40297
|
return StringValueObject.create(`${resultValueObjectString}${textValueObjectString}`);
|
|
40198
40298
|
});
|
|
40199
40299
|
if (!result) return ErrorValueObject.create("#VALUE!");
|
|
@@ -40249,7 +40349,7 @@ var Dollar = class extends BaseFunction {
|
|
|
40249
40349
|
_defineProperty(this, "needsLocale", true);
|
|
40250
40350
|
}
|
|
40251
40351
|
calculate(number, decimals) {
|
|
40252
|
-
let _decimals = decimals
|
|
40352
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40253
40353
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40254
40354
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1);
|
|
40255
40355
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1);
|
|
@@ -40348,7 +40448,7 @@ var Find = class extends BaseFunction {
|
|
|
40348
40448
|
_defineProperty(this, "maxParams", 3);
|
|
40349
40449
|
}
|
|
40350
40450
|
calculate(findText, withinText, startNum) {
|
|
40351
|
-
const _startNum = startNum
|
|
40451
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40352
40452
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40353
40453
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40354
40454
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40442,7 +40542,7 @@ var Findb = class extends BaseFunction {
|
|
|
40442
40542
|
_defineProperty(this, "maxParams", 3);
|
|
40443
40543
|
}
|
|
40444
40544
|
calculate(findText, withinText, startNum) {
|
|
40445
|
-
const _startNum = startNum
|
|
40545
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
40446
40546
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
40447
40547
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
40448
40548
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -40484,9 +40584,9 @@ var Fixed = class extends BaseFunction {
|
|
|
40484
40584
|
_defineProperty(this, "maxParams", 3);
|
|
40485
40585
|
}
|
|
40486
40586
|
calculate(number, decimals, noCommas) {
|
|
40487
|
-
let _decimals = decimals
|
|
40587
|
+
let _decimals = decimals ?? NumberValueObject.create(2);
|
|
40488
40588
|
if (_decimals.isNull()) _decimals = NumberValueObject.create(2);
|
|
40489
|
-
let _noCommas = noCommas
|
|
40589
|
+
let _noCommas = noCommas ?? BooleanValueObject.create(false);
|
|
40490
40590
|
if (_noCommas.isNull()) _noCommas = BooleanValueObject.create(false);
|
|
40491
40591
|
const maxRowLength = Math.max(number.isArray() ? number.getRowCount() : 1, _decimals.isArray() ? _decimals.getRowCount() : 1, _noCommas.isArray() ? _noCommas.getRowCount() : 1);
|
|
40492
40592
|
const maxColumnLength = Math.max(number.isArray() ? number.getColumnCount() : 1, _decimals.isArray() ? _decimals.getColumnCount() : 1, _noCommas.isArray() ? _noCommas.getColumnCount() : 1);
|
|
@@ -40533,7 +40633,7 @@ var Left = class extends BaseFunction {
|
|
|
40533
40633
|
_defineProperty(this, "maxParams", 2);
|
|
40534
40634
|
}
|
|
40535
40635
|
calculate(text, numChars) {
|
|
40536
|
-
const _numChars = numChars
|
|
40636
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
40537
40637
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
40538
40638
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
40539
40639
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -40570,7 +40670,7 @@ var Leftb = class extends BaseFunction {
|
|
|
40570
40670
|
_defineProperty(this, "maxParams", 2);
|
|
40571
40671
|
}
|
|
40572
40672
|
calculate(text, numBytes) {
|
|
40573
|
-
const _numBytes = numBytes
|
|
40673
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
40574
40674
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
40575
40675
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
40576
40676
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, NullValueObject.create());
|
|
@@ -40885,7 +40985,7 @@ var Numbervalue = class extends BaseFunction {
|
|
|
40885
40985
|
return true;
|
|
40886
40986
|
}
|
|
40887
40987
|
calculate(text, decimalSeparator, groupSeparator) {
|
|
40888
|
-
const _decimalSeparator = decimalSeparator
|
|
40988
|
+
const _decimalSeparator = decimalSeparator ?? StringValueObject.create(".");
|
|
40889
40989
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _decimalSeparator.isArray() ? _decimalSeparator.getRowCount() : 1, (groupSeparator === null || groupSeparator === void 0 ? void 0 : groupSeparator.isArray()) ? groupSeparator.getRowCount() : 1);
|
|
40890
40990
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _decimalSeparator.isArray() ? _decimalSeparator.getColumnCount() : 1, (groupSeparator === null || groupSeparator === void 0 ? void 0 : groupSeparator.isArray()) ? groupSeparator.getColumnCount() : 1);
|
|
40891
40991
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41416,8 +41516,7 @@ function isValidRegExp(regExpString) {
|
|
|
41416
41516
|
return !(/\(\?<=.*?\)/g.test(regExpString) && !/\[.*?(\?<=.*?)\]/g.test(regExpString) || /\(\?<!.*?\)/g.test(regExpString) && !/\[.*?(\?<!.*?)\]/g.test(regExpString));
|
|
41417
41517
|
}
|
|
41418
41518
|
function isSafeRegExp(regExp, options) {
|
|
41419
|
-
|
|
41420
|
-
const limit = (_options$limit = options === null || options === void 0 ? void 0 : options.limit) !== null && _options$limit !== void 0 ? _options$limit : 25;
|
|
41519
|
+
const limit = (options === null || options === void 0 ? void 0 : options.limit) ?? 25;
|
|
41421
41520
|
let str;
|
|
41422
41521
|
if (Object.prototype.toString.call(regExp) === "[object RegExp]") str = regExp.source;
|
|
41423
41522
|
else if (regExp && typeof regExp !== "string") str = `${regExp}`;
|
|
@@ -41697,7 +41796,7 @@ var Right = class extends BaseFunction {
|
|
|
41697
41796
|
_defineProperty(this, "maxParams", 2);
|
|
41698
41797
|
}
|
|
41699
41798
|
calculate(text, numChars) {
|
|
41700
|
-
const _numChars = numChars
|
|
41799
|
+
const _numChars = numChars ?? NumberValueObject.create(1);
|
|
41701
41800
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numChars.isArray() ? _numChars.getRowCount() : 1);
|
|
41702
41801
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numChars.isArray() ? _numChars.getColumnCount() : 1);
|
|
41703
41802
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41734,7 +41833,7 @@ var Rightb = class extends BaseFunction {
|
|
|
41734
41833
|
_defineProperty(this, "maxParams", 2);
|
|
41735
41834
|
}
|
|
41736
41835
|
calculate(text, numBytes) {
|
|
41737
|
-
const _numBytes = numBytes
|
|
41836
|
+
const _numBytes = numBytes ?? NumberValueObject.create(1);
|
|
41738
41837
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _numBytes.isArray() ? _numBytes.getRowCount() : 1);
|
|
41739
41838
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _numBytes.isArray() ? _numBytes.getColumnCount() : 1);
|
|
41740
41839
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -41777,7 +41876,7 @@ var Search = class extends BaseFunction {
|
|
|
41777
41876
|
_defineProperty(this, "maxParams", 3);
|
|
41778
41877
|
}
|
|
41779
41878
|
calculate(findText, withinText, startNum) {
|
|
41780
|
-
const _startNum = startNum
|
|
41879
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41781
41880
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41782
41881
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41783
41882
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41818,7 +41917,7 @@ var Searchb = class extends BaseFunction {
|
|
|
41818
41917
|
_defineProperty(this, "maxParams", 3);
|
|
41819
41918
|
}
|
|
41820
41919
|
calculate(findText, withinText, startNum) {
|
|
41821
|
-
const _startNum = startNum
|
|
41920
|
+
const _startNum = startNum ?? NumberValueObject.create(1);
|
|
41822
41921
|
const maxRowLength = Math.max(findText.isArray() ? findText.getRowCount() : 1, withinText.isArray() ? withinText.getRowCount() : 1, _startNum.isArray() ? _startNum.getRowCount() : 1);
|
|
41823
41922
|
const maxColumnLength = Math.max(findText.isArray() ? findText.getColumnCount() : 1, withinText.isArray() ? withinText.getColumnCount() : 1, _startNum.isArray() ? _startNum.getColumnCount() : 1);
|
|
41824
41923
|
const findTextArray = expandArrayValueObject(maxRowLength, maxColumnLength, findText, ErrorValueObject.create("#N/A"));
|
|
@@ -41991,15 +42090,15 @@ var Textafter = class extends BaseFunction {
|
|
|
41991
42090
|
}
|
|
41992
42091
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
41993
42092
|
let instanceNumIsNull = false;
|
|
41994
|
-
let _instanceNum = instanceNum
|
|
42093
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
41995
42094
|
if (_instanceNum.isNull()) {
|
|
41996
42095
|
instanceNumIsNull = true;
|
|
41997
42096
|
_instanceNum = NumberValueObject.create(1);
|
|
41998
42097
|
}
|
|
41999
42098
|
const onlyThreeVariant = !matchMode;
|
|
42000
|
-
const _matchMode = matchMode
|
|
42001
|
-
const _matchEnd = matchEnd
|
|
42002
|
-
const _ifNotFound = ifNotFound
|
|
42099
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42100
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42101
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
42003
42102
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _instanceNum.isArray() ? _instanceNum.getRowCount() : 1, _matchMode.isArray() ? _matchMode.getRowCount() : 1, _matchEnd.isArray() ? _matchEnd.getRowCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getRowCount() : 1);
|
|
42004
42103
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _instanceNum.isArray() ? _instanceNum.getColumnCount() : 1, _matchMode.isArray() ? _matchMode.getColumnCount() : 1, _matchEnd.isArray() ? _matchEnd.getColumnCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1);
|
|
42005
42104
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42134,15 +42233,15 @@ var Textbefore = class extends BaseFunction {
|
|
|
42134
42233
|
}
|
|
42135
42234
|
calculate(text, delimiter, instanceNum, matchMode, matchEnd, ifNotFound) {
|
|
42136
42235
|
let instanceNumIsNull = false;
|
|
42137
|
-
let _instanceNum = instanceNum
|
|
42236
|
+
let _instanceNum = instanceNum ?? NumberValueObject.create(1);
|
|
42138
42237
|
if (_instanceNum.isNull()) {
|
|
42139
42238
|
instanceNumIsNull = true;
|
|
42140
42239
|
_instanceNum = NumberValueObject.create(1);
|
|
42141
42240
|
}
|
|
42142
42241
|
const onlyThreeVariant = !matchMode;
|
|
42143
|
-
const _matchMode = matchMode
|
|
42144
|
-
const _matchEnd = matchEnd
|
|
42145
|
-
const _ifNotFound = ifNotFound
|
|
42242
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42243
|
+
const _matchEnd = matchEnd ?? NumberValueObject.create(0);
|
|
42244
|
+
const _ifNotFound = ifNotFound ?? ErrorValueObject.create("#N/A");
|
|
42146
42245
|
const maxRowLength = Math.max(text.isArray() ? text.getRowCount() : 1, _instanceNum.isArray() ? _instanceNum.getRowCount() : 1, _matchMode.isArray() ? _matchMode.getRowCount() : 1, _matchEnd.isArray() ? _matchEnd.getRowCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getRowCount() : 1);
|
|
42147
42246
|
const maxColumnLength = Math.max(text.isArray() ? text.getColumnCount() : 1, _instanceNum.isArray() ? _instanceNum.getColumnCount() : 1, _matchMode.isArray() ? _matchMode.getColumnCount() : 1, _matchEnd.isArray() ? _matchEnd.getColumnCount() : 1, _ifNotFound.isArray() ? _ifNotFound.getColumnCount() : 1);
|
|
42148
42247
|
const textArray = expandArrayValueObject(maxRowLength, maxColumnLength, text, ErrorValueObject.create("#N/A"));
|
|
@@ -42273,6 +42372,7 @@ var Textjoin = class extends BaseFunction {
|
|
|
42273
42372
|
super(..._args);
|
|
42274
42373
|
_defineProperty(this, "minParams", 3);
|
|
42275
42374
|
_defineProperty(this, "maxParams", 255);
|
|
42375
|
+
_defineProperty(this, "lazyIfReferenceArrayArgumentIndexes", Array.from({ length: this.maxParams - 2 }, (_, index) => index + 2));
|
|
42276
42376
|
}
|
|
42277
42377
|
calculate(delimiter, ignoreEmpty, ...variants) {
|
|
42278
42378
|
const delimiterValues = this._getDelimiterValues(delimiter);
|
|
@@ -42350,10 +42450,10 @@ var Textsplit = class extends BaseFunction {
|
|
|
42350
42450
|
_defineProperty(this, "maxParams", 6);
|
|
42351
42451
|
}
|
|
42352
42452
|
calculate(text, colDelimiter, rowDelimiter, ignoreEmpty, matchMode, padWith) {
|
|
42353
|
-
let _rowDelimiter = rowDelimiter
|
|
42354
|
-
const _ignoreEmpty = ignoreEmpty
|
|
42355
|
-
const _matchMode = matchMode
|
|
42356
|
-
const _padWith = padWith
|
|
42453
|
+
let _rowDelimiter = rowDelimiter ?? StringValueObject.create("\\s");
|
|
42454
|
+
const _ignoreEmpty = ignoreEmpty ?? NumberValueObject.create(0);
|
|
42455
|
+
const _matchMode = matchMode ?? NumberValueObject.create(0);
|
|
42456
|
+
const _padWith = padWith ?? StringValueObject.create("#N/A");
|
|
42357
42457
|
const { _variant, values: rowDelimiterValue } = this._getStringValues(_rowDelimiter, false);
|
|
42358
42458
|
_rowDelimiter = _variant;
|
|
42359
42459
|
const allowBlankColDelimiter = rowDelimiter != null && !rowDelimiter.isNull() && !_rowDelimiter.isError() && rowDelimiterValue.length > 0;
|
|
@@ -42629,7 +42729,7 @@ var Valuetotext = class extends BaseFunction {
|
|
|
42629
42729
|
_defineProperty(this, "maxParams", 2);
|
|
42630
42730
|
}
|
|
42631
42731
|
calculate(value, format) {
|
|
42632
|
-
const _format = format
|
|
42732
|
+
const _format = format ?? NumberValueObject.create(0);
|
|
42633
42733
|
const maxRowLength = Math.max(value.isArray() ? value.getRowCount() : 1, _format.isArray() ? _format.getRowCount() : 1);
|
|
42634
42734
|
const maxColumnLength = Math.max(value.isArray() ? value.getColumnCount() : 1, _format.isArray() ? _format.getColumnCount() : 1);
|
|
42635
42735
|
const valueArray = expandArrayValueObject(maxRowLength, maxColumnLength, value, ErrorValueObject.create("#N/A"));
|
|
@@ -42907,7 +43007,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
42907
43007
|
//#endregion
|
|
42908
43008
|
//#region package.json
|
|
42909
43009
|
var name = "@univerjs/engine-formula";
|
|
42910
|
-
var version = "1.0.0-
|
|
43010
|
+
var version = "1.0.0-beta.0";
|
|
42911
43011
|
|
|
42912
43012
|
//#endregion
|
|
42913
43013
|
//#region src/services/global-computing-status.service.ts
|
|
@@ -43099,14 +43199,13 @@ function createEmptyDirtyData() {
|
|
|
43099
43199
|
};
|
|
43100
43200
|
}
|
|
43101
43201
|
function mergeDirtyData(left, right) {
|
|
43102
|
-
var _right$dirtyRanges, _left$dirtySuperTable;
|
|
43103
43202
|
const dirtyRanges = [...left.dirtyRanges];
|
|
43104
|
-
mergeDirtyRanges(dirtyRanges,
|
|
43203
|
+
mergeDirtyRanges(dirtyRanges, right.dirtyRanges ?? []);
|
|
43105
43204
|
return {
|
|
43106
43205
|
dirtyRanges,
|
|
43107
43206
|
dirtyNameMap: mergeDirtyUnitStringMap(left.dirtyNameMap, right.dirtyNameMap),
|
|
43108
43207
|
dirtyDefinedNameMap: mergeDirtyUnitStringMap(left.dirtyDefinedNameMap, right.dirtyDefinedNameMap),
|
|
43109
|
-
dirtySuperTableMap: mergeDirtyUnitStringMap(
|
|
43208
|
+
dirtySuperTableMap: mergeDirtyUnitStringMap(left.dirtySuperTableMap ?? {}, right.dirtySuperTableMap),
|
|
43110
43209
|
dirtyUnitFeatureMap: mergeDirtyUnitNestedMap(left.dirtyUnitFeatureMap, right.dirtyUnitFeatureMap),
|
|
43111
43210
|
dirtyUnitOtherFormulaMap: mergeDirtyUnitNestedMap(left.dirtyUnitOtherFormulaMap, right.dirtyUnitOtherFormulaMap),
|
|
43112
43211
|
clearDependencyTreeCache: mergeDirtyUnitStringMap(left.clearDependencyTreeCache, right.clearDependencyTreeCache),
|
|
@@ -43136,7 +43235,7 @@ function getDirtyRangeKey({ unitId, sheetId, range }) {
|
|
|
43136
43235
|
}
|
|
43137
43236
|
function mergeDirtyUnitStringMap(left, right) {
|
|
43138
43237
|
const result = { ...left };
|
|
43139
|
-
Object.entries(right
|
|
43238
|
+
Object.entries(right ?? {}).forEach(([unitId, values]) => {
|
|
43140
43239
|
result[unitId] = {
|
|
43141
43240
|
...result[unitId],
|
|
43142
43241
|
...values
|
|
@@ -43146,9 +43245,9 @@ function mergeDirtyUnitStringMap(left, right) {
|
|
|
43146
43245
|
}
|
|
43147
43246
|
function mergeDirtyUnitNestedMap(left, right) {
|
|
43148
43247
|
const result = { ...left };
|
|
43149
|
-
Object.entries(right
|
|
43248
|
+
Object.entries(right ?? {}).forEach(([unitId, sheets]) => {
|
|
43150
43249
|
const unitResult = { ...result[unitId] };
|
|
43151
|
-
Object.entries(sheets
|
|
43250
|
+
Object.entries(sheets ?? {}).forEach(([sheetId, values]) => {
|
|
43152
43251
|
unitResult[sheetId] = {
|
|
43153
43252
|
...unitResult[sheetId],
|
|
43154
43253
|
...values
|
|
@@ -43179,7 +43278,7 @@ function dirtyDataIntersects(left, right) {
|
|
|
43179
43278
|
].some(([leftMap, rightMap]) => hasSameNestedKey(leftMap, rightMap));
|
|
43180
43279
|
}
|
|
43181
43280
|
function clearedSheetIntersects(cleared, dirty) {
|
|
43182
|
-
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets
|
|
43281
|
+
return Object.entries(cleared.clearDependencyTreeCache).some(([unitId, sheets]) => Object.keys(sheets ?? {}).some((sheetId) => {
|
|
43183
43282
|
var _dirty$dirtyNameMap$u, _dirty$dirtyUnitFeatu, _dirty$dirtyUnitOther;
|
|
43184
43283
|
return dirty.dirtyRanges.some((range) => range.unitId === unitId && range.sheetId === sheetId) || ((_dirty$dirtyNameMap$u = dirty.dirtyNameMap[unitId]) === null || _dirty$dirtyNameMap$u === void 0 ? void 0 : _dirty$dirtyNameMap$u[sheetId]) != null || ((_dirty$dirtyUnitFeatu = dirty.dirtyUnitFeatureMap[unitId]) === null || _dirty$dirtyUnitFeatu === void 0 ? void 0 : _dirty$dirtyUnitFeatu[sheetId]) != null || ((_dirty$dirtyUnitOther = dirty.dirtyUnitOtherFormulaMap[unitId]) === null || _dirty$dirtyUnitOther === void 0 ? void 0 : _dirty$dirtyUnitOther[sheetId]) != null;
|
|
43185
43284
|
}));
|
|
@@ -43292,9 +43391,8 @@ let FormulaController = class FormulaController extends _univerjs_core.Disposabl
|
|
|
43292
43391
|
});
|
|
43293
43392
|
}
|
|
43294
43393
|
_registerFunctions() {
|
|
43295
|
-
var _config$function;
|
|
43296
43394
|
const config = this._configService.getConfig(ENGINE_FORMULA_PLUGIN_CONFIG_KEY);
|
|
43297
|
-
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((
|
|
43395
|
+
const functions = ALL_IMPLEMENTED_FUNCTIONS.concat((config === null || config === void 0 ? void 0 : config.function) ?? []).map((registerObject) => {
|
|
43298
43396
|
const Func = registerObject[0];
|
|
43299
43397
|
const name = registerObject[1];
|
|
43300
43398
|
return new Func(name);
|
|
@@ -56493,7 +56591,7 @@ let RegisterFunctionService = class RegisterFunctionService extends _univerjs_co
|
|
|
56493
56591
|
const { locales, description, calculate } = params;
|
|
56494
56592
|
if (locales) this._localeService.load(locales);
|
|
56495
56593
|
const disposables = new _univerjs_core.DisposableCollection();
|
|
56496
|
-
const descriptions = description
|
|
56594
|
+
const descriptions = description ?? calculate.map(([_func, functionName, functionIntroduction]) => {
|
|
56497
56595
|
return {
|
|
56498
56596
|
functionName,
|
|
56499
56597
|
functionType: 15,
|