@univerjs/engine-formula 0.22.1 → 0.23.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/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createIdentifier, generateRandomId, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
2
- import { BehaviorSubject, Observable, Subject, bufferWhen, combineLatest, distinctUntilChanged, filter, map, shareReplay, skip } from "rxjs";
3
2
  import IntervalTree from "@flatten-js/interval-tree";
3
+ import { BehaviorSubject, Observable, Subject, bufferWhen, combineLatest, distinctUntilChanged, filter, map, shareReplay, skip } from "rxjs";
4
4
  import Decimal from "decimal.js";
5
5
  import { DataSyncPrimaryController } from "@univerjs/rpc";
6
6
 
@@ -1102,6 +1102,181 @@ let FunctionType = /* @__PURE__ */ function(FunctionType) {
1102
1102
  return FunctionType;
1103
1103
  }({});
1104
1104
 
1105
+ //#endregion
1106
+ //#region src/basics/inverted-index-cache.ts
1107
+ const DEFAULT_EMPTY_CELL_KEY = Symbol("EMPTY_CELL");
1108
+ const normalizedValueMap = /* @__PURE__ */ new Map();
1109
+ function normalizeValue(value) {
1110
+ if (normalizedValueMap.has(value)) return normalizedValueMap.get(value);
1111
+ let _value;
1112
+ if (value === null || value === void 0 || value === "") _value = DEFAULT_EMPTY_CELL_KEY;
1113
+ else if (isRealNum(value) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
1114
+ else if (typeof value === "string") _value = value.toLowerCase();
1115
+ else _value = value;
1116
+ normalizedValueMap.set(value, _value);
1117
+ return _value;
1118
+ }
1119
+ var InvertedIndexCache = class {
1120
+ constructor() {
1121
+ _defineProperty(this, "_cache", /* @__PURE__ */ new Map());
1122
+ _defineProperty(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
1123
+ }
1124
+ set(unitId, sheetId, column, value, row, isForceUpdate = false) {
1125
+ if (!this.shouldContinueBuildingCache(unitId, sheetId, column, row) && !isForceUpdate) return;
1126
+ let unitMap = this._cache.get(unitId);
1127
+ if (unitMap == null) {
1128
+ unitMap = /* @__PURE__ */ new Map();
1129
+ this._cache.set(unitId, unitMap);
1130
+ }
1131
+ let sheetMap = unitMap.get(sheetId);
1132
+ if (sheetMap == null) {
1133
+ sheetMap = /* @__PURE__ */ new Map();
1134
+ unitMap.set(sheetId, sheetMap);
1135
+ }
1136
+ let columnMap = sheetMap.get(column);
1137
+ if (columnMap == null) {
1138
+ columnMap = /* @__PURE__ */ new Map();
1139
+ sheetMap.set(column, columnMap);
1140
+ }
1141
+ if (isForceUpdate) {
1142
+ for (const [_, _cellList] of columnMap) if (_cellList.has(row)) {
1143
+ _cellList.delete(row);
1144
+ break;
1145
+ }
1146
+ }
1147
+ const _value = normalizeValue(value);
1148
+ let cellList = columnMap.get(_value);
1149
+ if (cellList == null) {
1150
+ cellList = /* @__PURE__ */ new Set();
1151
+ columnMap.set(_value, cellList);
1152
+ }
1153
+ cellList.add(row);
1154
+ }
1155
+ getCellValuePositions(unitId, sheetId, column) {
1156
+ var _this$_cache$get;
1157
+ return (_this$_cache$get = this._cache.get(unitId)) === null || _this$_cache$get === void 0 || (_this$_cache$get = _this$_cache$get.get(sheetId)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.get(column);
1158
+ }
1159
+ getCellPositions(unitId, sheetId, column, value, rowsInCache) {
1160
+ var _this$_cache$get2;
1161
+ const columnMap = (_this$_cache$get2 = this._cache.get(unitId)) === null || _this$_cache$get2 === void 0 || (_this$_cache$get2 = _this$_cache$get2.get(sheetId)) === null || _this$_cache$get2 === void 0 ? void 0 : _this$_cache$get2.get(column);
1162
+ if (!columnMap) return;
1163
+ const result = {
1164
+ errorType: null,
1165
+ matchingRows: []
1166
+ };
1167
+ const _value = normalizeValue(value);
1168
+ if (ERROR_TYPE_SET.has(_value)) result.errorType = _value;
1169
+ else if (_value === 0 || _value === DEFAULT_EMPTY_CELL_KEY) {
1170
+ const rows = [];
1171
+ const rowsForZero = columnMap.get(0);
1172
+ if (rowsForZero) rows.push(...rowsForZero);
1173
+ const rowsForEmpty = columnMap.get(DEFAULT_EMPTY_CELL_KEY);
1174
+ if (rowsForEmpty) rows.push(...rowsForEmpty);
1175
+ result.matchingRows = rows.filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
1176
+ } else {
1177
+ var _columnMap$get;
1178
+ result.matchingRows = Array.from((_columnMap$get = columnMap.get(_value)) !== null && _columnMap$get !== void 0 ? _columnMap$get : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
1179
+ }
1180
+ return result;
1181
+ }
1182
+ setContinueBuildingCache(unitId, sheetId, column, startRow, endRow) {
1183
+ if (column === -1 || startRow === -1 || endRow === -1) return;
1184
+ let unitMap = this._continueBuildingCache.get(unitId);
1185
+ if (unitMap == null) {
1186
+ unitMap = /* @__PURE__ */ new Map();
1187
+ this._continueBuildingCache.set(unitId, unitMap);
1188
+ }
1189
+ let sheetMap = unitMap.get(sheetId);
1190
+ if (sheetMap == null) {
1191
+ sheetMap = /* @__PURE__ */ new Map();
1192
+ unitMap.set(sheetId, sheetMap);
1193
+ }
1194
+ let columnMap = sheetMap.get(column);
1195
+ if (columnMap == null) {
1196
+ columnMap = new IntervalTree();
1197
+ columnMap.insert([startRow, endRow]);
1198
+ sheetMap.set(column, columnMap);
1199
+ return;
1200
+ }
1201
+ this._handleNewInterval(columnMap, startRow, endRow);
1202
+ }
1203
+ shouldContinueBuildingCache(unitId, sheetId, column, row) {
1204
+ var _this$_continueBuildi;
1205
+ if (column === -1 || row === -1) return false;
1206
+ const columnMap = (_this$_continueBuildi = this._continueBuildingCache.get(unitId)) === null || _this$_continueBuildi === void 0 || (_this$_continueBuildi = _this$_continueBuildi.get(sheetId)) === null || _this$_continueBuildi === void 0 ? void 0 : _this$_continueBuildi.get(column);
1207
+ if (!columnMap) return true;
1208
+ return columnMap.search([row, row]).length === 0;
1209
+ }
1210
+ canUseCache(unitId, sheetId, column, rangeStartRow, rangeEndRow) {
1211
+ var _this$_continueBuildi2;
1212
+ const columnMap = (_this$_continueBuildi2 = this._continueBuildingCache.get(unitId)) === null || _this$_continueBuildi2 === void 0 || (_this$_continueBuildi2 = _this$_continueBuildi2.get(sheetId)) === null || _this$_continueBuildi2 === void 0 ? void 0 : _this$_continueBuildi2.get(column);
1213
+ if (column === -1 || rangeStartRow === -1 || rangeEndRow === -1 || !columnMap) return {
1214
+ rowsInCache: [],
1215
+ rowsNotInCache: []
1216
+ };
1217
+ const result = columnMap.search([rangeStartRow, rangeEndRow]);
1218
+ if (result.length === 0) return {
1219
+ rowsInCache: [],
1220
+ rowsNotInCache: []
1221
+ };
1222
+ result.sort((a, b) => a[0] - b[0]);
1223
+ const rowsInCache = [];
1224
+ const rowsNotInCache = [];
1225
+ let _rangeStartRow = rangeStartRow;
1226
+ for (let i = 0; i < result.length; i++) {
1227
+ const [start, end] = result[i];
1228
+ if (_rangeStartRow >= start) {
1229
+ if (rangeEndRow <= end) {
1230
+ rowsInCache.push([_rangeStartRow, rangeEndRow]);
1231
+ break;
1232
+ }
1233
+ rowsInCache.push([_rangeStartRow, end]);
1234
+ _rangeStartRow = end + 1;
1235
+ if (i === result.length - 1 && _rangeStartRow <= rangeEndRow) rowsNotInCache.push([_rangeStartRow, rangeEndRow]);
1236
+ } else {
1237
+ if (rangeEndRow > end) {
1238
+ rowsInCache.push([start, end]);
1239
+ rowsNotInCache.push([_rangeStartRow, start - 1]);
1240
+ _rangeStartRow = end + 1;
1241
+ if (i === result.length - 1 && _rangeStartRow <= rangeEndRow) rowsNotInCache.push([_rangeStartRow, rangeEndRow]);
1242
+ continue;
1243
+ }
1244
+ rowsInCache.push([start, rangeEndRow]);
1245
+ rowsNotInCache.push([_rangeStartRow, start - 1]);
1246
+ }
1247
+ }
1248
+ return {
1249
+ rowsInCache,
1250
+ rowsNotInCache
1251
+ };
1252
+ }
1253
+ clear() {
1254
+ this._cache.clear();
1255
+ this._continueBuildingCache.clear();
1256
+ normalizedValueMap.clear();
1257
+ }
1258
+ _handleNewInterval(columnMap, startRow, endRow) {
1259
+ let result = columnMap.search([startRow, endRow]);
1260
+ if (result.length === 0) {
1261
+ const adjacentRange = [startRow - 1 < 0 ? 0 : startRow - 1, endRow + 1];
1262
+ result = columnMap.search(adjacentRange);
1263
+ if (result.length === 0) {
1264
+ columnMap.insert([startRow, endRow]);
1265
+ return;
1266
+ }
1267
+ }
1268
+ let min = startRow;
1269
+ let max = endRow;
1270
+ for (const interval of result) {
1271
+ min = Math.min(min, interval[0]);
1272
+ max = Math.max(max, interval[1]);
1273
+ columnMap.remove(interval);
1274
+ }
1275
+ columnMap.insert([min, max]);
1276
+ }
1277
+ };
1278
+ const CELL_INVERTED_INDEX_CACHE = new InvertedIndexCache();
1279
+
1105
1280
  //#endregion
1106
1281
  //#region src/basics/match-token.ts
1107
1282
  /**
@@ -2136,159 +2311,986 @@ const SetSuperTableOptionMutation = {
2136
2311
  //#endregion
2137
2312
  //#region src/config/config.ts
2138
2313
  const ENGINE_FORMULA_PLUGIN_CONFIG_KEY = "engine-formula.config";
2314
+ const DEFAULT_CYCLE_REFERENCE_COUNT = 1;
2139
2315
  const ENGINE_FORMULA_CYCLE_REFERENCE_COUNT = "CYCLE_REFERENCE_COUNT";
2140
2316
  const ENGINE_FORMULA_RETURN_DEPENDENCY_TREE = "RETURN_DEPENDENCY_TREE";
2141
2317
  const configSymbol = Symbol(ENGINE_FORMULA_PLUGIN_CONFIG_KEY);
2142
2318
  const defaultPluginConfig = {};
2143
2319
 
2144
2320
  //#endregion
2145
- //#region src/engine/utils/reference-cache.ts
2146
- const referenceToRangeCache = new FormulaAstLRU(1e5);
2147
- function deserializeRangeWithSheetWithCache(refString) {
2148
- const refCache = referenceToRangeCache.get(refString);
2149
- if (refCache) return refCache;
2150
- const result = deserializeRangeWithSheet(refString);
2151
- referenceToRangeCache.set(refString, result);
2152
- return deserializeRangeWithSheet(refString);
2153
- }
2154
- function clearReferenceToRangeCache() {
2155
- referenceToRangeCache.clear();
2156
- }
2321
+ //#region src/functions/date/function-names.ts
2322
+ /**
2323
+ * Copyright 2023-present DreamNum Co., Ltd.
2324
+ *
2325
+ * Licensed under the Apache License, Version 2.0 (the "License");
2326
+ * you may not use this file except in compliance with the License.
2327
+ * You may obtain a copy of the License at
2328
+ *
2329
+ * http://www.apache.org/licenses/LICENSE-2.0
2330
+ *
2331
+ * Unless required by applicable law or agreed to in writing, software
2332
+ * distributed under the License is distributed on an "AS IS" BASIS,
2333
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2334
+ * See the License for the specific language governing permissions and
2335
+ * limitations under the License.
2336
+ */
2337
+ let FUNCTION_NAMES_DATE = /* @__PURE__ */ function(FUNCTION_NAMES_DATE) {
2338
+ FUNCTION_NAMES_DATE["DATE"] = "DATE";
2339
+ FUNCTION_NAMES_DATE["DATEDIF"] = "DATEDIF";
2340
+ FUNCTION_NAMES_DATE["DATEVALUE"] = "DATEVALUE";
2341
+ FUNCTION_NAMES_DATE["DAY"] = "DAY";
2342
+ FUNCTION_NAMES_DATE["DAYS"] = "DAYS";
2343
+ FUNCTION_NAMES_DATE["DAYS360"] = "DAYS360";
2344
+ FUNCTION_NAMES_DATE["EDATE"] = "EDATE";
2345
+ FUNCTION_NAMES_DATE["EOMONTH"] = "EOMONTH";
2346
+ FUNCTION_NAMES_DATE["EPOCHTODATE"] = "EPOCHTODATE";
2347
+ FUNCTION_NAMES_DATE["HOUR"] = "HOUR";
2348
+ FUNCTION_NAMES_DATE["ISOWEEKNUM"] = "ISOWEEKNUM";
2349
+ FUNCTION_NAMES_DATE["MINUTE"] = "MINUTE";
2350
+ FUNCTION_NAMES_DATE["MONTH"] = "MONTH";
2351
+ FUNCTION_NAMES_DATE["NETWORKDAYS"] = "NETWORKDAYS";
2352
+ FUNCTION_NAMES_DATE["NETWORKDAYS_INTL"] = "NETWORKDAYS.INTL";
2353
+ FUNCTION_NAMES_DATE["NOW"] = "NOW";
2354
+ FUNCTION_NAMES_DATE["SECOND"] = "SECOND";
2355
+ FUNCTION_NAMES_DATE["TIME"] = "TIME";
2356
+ FUNCTION_NAMES_DATE["TIMEVALUE"] = "TIMEVALUE";
2357
+ FUNCTION_NAMES_DATE["TO_DATE"] = "TO_DATE";
2358
+ FUNCTION_NAMES_DATE["TODAY"] = "TODAY";
2359
+ FUNCTION_NAMES_DATE["WEEKDAY"] = "WEEKDAY";
2360
+ FUNCTION_NAMES_DATE["WEEKNUM"] = "WEEKNUM";
2361
+ FUNCTION_NAMES_DATE["WORKDAY"] = "WORKDAY";
2362
+ FUNCTION_NAMES_DATE["WORKDAY_INTL"] = "WORKDAY.INTL";
2363
+ FUNCTION_NAMES_DATE["YEAR"] = "YEAR";
2364
+ FUNCTION_NAMES_DATE["YEARFRAC"] = "YEARFRAC";
2365
+ return FUNCTION_NAMES_DATE;
2366
+ }({});
2157
2367
 
2158
2368
  //#endregion
2159
- //#region src/engine/utils/sequence.ts
2160
- let sequenceNodeType = /* @__PURE__ */ function(sequenceNodeType) {
2161
- sequenceNodeType[sequenceNodeType["NORMAL"] = 0] = "NORMAL";
2162
- sequenceNodeType[sequenceNodeType["NUMBER"] = 1] = "NUMBER";
2163
- sequenceNodeType[sequenceNodeType["STRING"] = 2] = "STRING";
2164
- sequenceNodeType[sequenceNodeType["FUNCTION"] = 3] = "FUNCTION";
2165
- sequenceNodeType[sequenceNodeType["REFERENCE"] = 4] = "REFERENCE";
2166
- sequenceNodeType[sequenceNodeType["ARRAY"] = 5] = "ARRAY";
2167
- sequenceNodeType[sequenceNodeType["DEFINED_NAME"] = 6] = "DEFINED_NAME";
2168
- sequenceNodeType[sequenceNodeType["TABLE"] = 7] = "TABLE";
2169
- return sequenceNodeType;
2369
+ //#region src/functions/engineering/function-names.ts
2370
+ /**
2371
+ * Copyright 2023-present DreamNum Co., Ltd.
2372
+ *
2373
+ * Licensed under the Apache License, Version 2.0 (the "License");
2374
+ * you may not use this file except in compliance with the License.
2375
+ * You may obtain a copy of the License at
2376
+ *
2377
+ * http://www.apache.org/licenses/LICENSE-2.0
2378
+ *
2379
+ * Unless required by applicable law or agreed to in writing, software
2380
+ * distributed under the License is distributed on an "AS IS" BASIS,
2381
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2382
+ * See the License for the specific language governing permissions and
2383
+ * limitations under the License.
2384
+ */
2385
+ let FUNCTION_NAMES_ENGINEERING = /* @__PURE__ */ function(FUNCTION_NAMES_ENGINEERING) {
2386
+ FUNCTION_NAMES_ENGINEERING["BESSELI"] = "BESSELI";
2387
+ FUNCTION_NAMES_ENGINEERING["BESSELJ"] = "BESSELJ";
2388
+ FUNCTION_NAMES_ENGINEERING["BESSELK"] = "BESSELK";
2389
+ FUNCTION_NAMES_ENGINEERING["BESSELY"] = "BESSELY";
2390
+ FUNCTION_NAMES_ENGINEERING["BIN2DEC"] = "BIN2DEC";
2391
+ FUNCTION_NAMES_ENGINEERING["BIN2HEX"] = "BIN2HEX";
2392
+ FUNCTION_NAMES_ENGINEERING["BIN2OCT"] = "BIN2OCT";
2393
+ FUNCTION_NAMES_ENGINEERING["BITAND"] = "BITAND";
2394
+ FUNCTION_NAMES_ENGINEERING["BITLSHIFT"] = "BITLSHIFT";
2395
+ FUNCTION_NAMES_ENGINEERING["BITOR"] = "BITOR";
2396
+ FUNCTION_NAMES_ENGINEERING["BITRSHIFT"] = "BITRSHIFT";
2397
+ FUNCTION_NAMES_ENGINEERING["BITXOR"] = "BITXOR";
2398
+ FUNCTION_NAMES_ENGINEERING["COMPLEX"] = "COMPLEX";
2399
+ FUNCTION_NAMES_ENGINEERING["CONVERT"] = "CONVERT";
2400
+ FUNCTION_NAMES_ENGINEERING["DEC2BIN"] = "DEC2BIN";
2401
+ FUNCTION_NAMES_ENGINEERING["DEC2HEX"] = "DEC2HEX";
2402
+ FUNCTION_NAMES_ENGINEERING["DEC2OCT"] = "DEC2OCT";
2403
+ FUNCTION_NAMES_ENGINEERING["DELTA"] = "DELTA";
2404
+ FUNCTION_NAMES_ENGINEERING["ERF"] = "ERF";
2405
+ FUNCTION_NAMES_ENGINEERING["ERF_PRECISE"] = "ERF.PRECISE";
2406
+ FUNCTION_NAMES_ENGINEERING["ERFC"] = "ERFC";
2407
+ FUNCTION_NAMES_ENGINEERING["ERFC_PRECISE"] = "ERFC.PRECISE";
2408
+ FUNCTION_NAMES_ENGINEERING["GESTEP"] = "GESTEP";
2409
+ FUNCTION_NAMES_ENGINEERING["HEX2BIN"] = "HEX2BIN";
2410
+ FUNCTION_NAMES_ENGINEERING["HEX2DEC"] = "HEX2DEC";
2411
+ FUNCTION_NAMES_ENGINEERING["HEX2OCT"] = "HEX2OCT";
2412
+ FUNCTION_NAMES_ENGINEERING["IMABS"] = "IMABS";
2413
+ FUNCTION_NAMES_ENGINEERING["IMAGINARY"] = "IMAGINARY";
2414
+ FUNCTION_NAMES_ENGINEERING["IMARGUMENT"] = "IMARGUMENT";
2415
+ FUNCTION_NAMES_ENGINEERING["IMCONJUGATE"] = "IMCONJUGATE";
2416
+ FUNCTION_NAMES_ENGINEERING["IMCOS"] = "IMCOS";
2417
+ FUNCTION_NAMES_ENGINEERING["IMCOSH"] = "IMCOSH";
2418
+ FUNCTION_NAMES_ENGINEERING["IMCOT"] = "IMCOT";
2419
+ FUNCTION_NAMES_ENGINEERING["IMCOTH"] = "IMCOTH";
2420
+ FUNCTION_NAMES_ENGINEERING["IMCSC"] = "IMCSC";
2421
+ FUNCTION_NAMES_ENGINEERING["IMCSCH"] = "IMCSCH";
2422
+ FUNCTION_NAMES_ENGINEERING["IMDIV"] = "IMDIV";
2423
+ FUNCTION_NAMES_ENGINEERING["IMEXP"] = "IMEXP";
2424
+ FUNCTION_NAMES_ENGINEERING["IMLN"] = "IMLN";
2425
+ FUNCTION_NAMES_ENGINEERING["IMLOG"] = "IMLOG";
2426
+ FUNCTION_NAMES_ENGINEERING["IMLOG10"] = "IMLOG10";
2427
+ FUNCTION_NAMES_ENGINEERING["IMLOG2"] = "IMLOG2";
2428
+ FUNCTION_NAMES_ENGINEERING["IMPOWER"] = "IMPOWER";
2429
+ FUNCTION_NAMES_ENGINEERING["IMPRODUCT"] = "IMPRODUCT";
2430
+ FUNCTION_NAMES_ENGINEERING["IMREAL"] = "IMREAL";
2431
+ FUNCTION_NAMES_ENGINEERING["IMSEC"] = "IMSEC";
2432
+ FUNCTION_NAMES_ENGINEERING["IMSECH"] = "IMSECH";
2433
+ FUNCTION_NAMES_ENGINEERING["IMSIN"] = "IMSIN";
2434
+ FUNCTION_NAMES_ENGINEERING["IMSINH"] = "IMSINH";
2435
+ FUNCTION_NAMES_ENGINEERING["IMSQRT"] = "IMSQRT";
2436
+ FUNCTION_NAMES_ENGINEERING["IMSUB"] = "IMSUB";
2437
+ FUNCTION_NAMES_ENGINEERING["IMSUM"] = "IMSUM";
2438
+ FUNCTION_NAMES_ENGINEERING["IMTAN"] = "IMTAN";
2439
+ FUNCTION_NAMES_ENGINEERING["IMTANH"] = "IMTANH";
2440
+ FUNCTION_NAMES_ENGINEERING["OCT2BIN"] = "OCT2BIN";
2441
+ FUNCTION_NAMES_ENGINEERING["OCT2DEC"] = "OCT2DEC";
2442
+ FUNCTION_NAMES_ENGINEERING["OCT2HEX"] = "OCT2HEX";
2443
+ return FUNCTION_NAMES_ENGINEERING;
2170
2444
  }({});
2445
+
2446
+ //#endregion
2447
+ //#region src/functions/financial/function-names.ts
2171
2448
  /**
2172
- * Deserialize Sequence to text.
2173
- * @param newSequenceNodes
2174
- * @returns
2449
+ * Copyright 2023-present DreamNum Co., Ltd.
2450
+ *
2451
+ * Licensed under the Apache License, Version 2.0 (the "License");
2452
+ * you may not use this file except in compliance with the License.
2453
+ * You may obtain a copy of the License at
2454
+ *
2455
+ * http://www.apache.org/licenses/LICENSE-2.0
2456
+ *
2457
+ * Unless required by applicable law or agreed to in writing, software
2458
+ * distributed under the License is distributed on an "AS IS" BASIS,
2459
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2460
+ * See the License for the specific language governing permissions and
2461
+ * limitations under the License.
2175
2462
  */
2176
- function generateStringWithSequence(newSequenceNodes) {
2177
- let sequenceString = "";
2178
- for (const node of newSequenceNodes) if (typeof node === "string") sequenceString += node;
2179
- else sequenceString += node.token;
2180
- return sequenceString;
2181
- }
2463
+ let FUNCTION_NAMES_FINANCIAL = /* @__PURE__ */ function(FUNCTION_NAMES_FINANCIAL) {
2464
+ FUNCTION_NAMES_FINANCIAL["ACCRINT"] = "ACCRINT";
2465
+ FUNCTION_NAMES_FINANCIAL["ACCRINTM"] = "ACCRINTM";
2466
+ FUNCTION_NAMES_FINANCIAL["AMORDEGRC"] = "AMORDEGRC";
2467
+ FUNCTION_NAMES_FINANCIAL["AMORLINC"] = "AMORLINC";
2468
+ FUNCTION_NAMES_FINANCIAL["COUPDAYBS"] = "COUPDAYBS";
2469
+ FUNCTION_NAMES_FINANCIAL["COUPDAYS"] = "COUPDAYS";
2470
+ FUNCTION_NAMES_FINANCIAL["COUPDAYSNC"] = "COUPDAYSNC";
2471
+ FUNCTION_NAMES_FINANCIAL["COUPNCD"] = "COUPNCD";
2472
+ FUNCTION_NAMES_FINANCIAL["COUPNUM"] = "COUPNUM";
2473
+ FUNCTION_NAMES_FINANCIAL["COUPPCD"] = "COUPPCD";
2474
+ FUNCTION_NAMES_FINANCIAL["CUMIPMT"] = "CUMIPMT";
2475
+ FUNCTION_NAMES_FINANCIAL["CUMPRINC"] = "CUMPRINC";
2476
+ FUNCTION_NAMES_FINANCIAL["DB"] = "DB";
2477
+ FUNCTION_NAMES_FINANCIAL["DDB"] = "DDB";
2478
+ FUNCTION_NAMES_FINANCIAL["DISC"] = "DISC";
2479
+ FUNCTION_NAMES_FINANCIAL["DOLLARDE"] = "DOLLARDE";
2480
+ FUNCTION_NAMES_FINANCIAL["DOLLARFR"] = "DOLLARFR";
2481
+ FUNCTION_NAMES_FINANCIAL["DURATION"] = "DURATION";
2482
+ FUNCTION_NAMES_FINANCIAL["EFFECT"] = "EFFECT";
2483
+ FUNCTION_NAMES_FINANCIAL["FV"] = "FV";
2484
+ FUNCTION_NAMES_FINANCIAL["FVSCHEDULE"] = "FVSCHEDULE";
2485
+ FUNCTION_NAMES_FINANCIAL["INTRATE"] = "INTRATE";
2486
+ FUNCTION_NAMES_FINANCIAL["IPMT"] = "IPMT";
2487
+ FUNCTION_NAMES_FINANCIAL["IRR"] = "IRR";
2488
+ FUNCTION_NAMES_FINANCIAL["ISPMT"] = "ISPMT";
2489
+ FUNCTION_NAMES_FINANCIAL["MDURATION"] = "MDURATION";
2490
+ FUNCTION_NAMES_FINANCIAL["MIRR"] = "MIRR";
2491
+ FUNCTION_NAMES_FINANCIAL["NOMINAL"] = "NOMINAL";
2492
+ FUNCTION_NAMES_FINANCIAL["NPER"] = "NPER";
2493
+ FUNCTION_NAMES_FINANCIAL["NPV"] = "NPV";
2494
+ FUNCTION_NAMES_FINANCIAL["ODDFPRICE"] = "ODDFPRICE";
2495
+ FUNCTION_NAMES_FINANCIAL["ODDFYIELD"] = "ODDFYIELD";
2496
+ FUNCTION_NAMES_FINANCIAL["ODDLPRICE"] = "ODDLPRICE";
2497
+ FUNCTION_NAMES_FINANCIAL["ODDLYIELD"] = "ODDLYIELD";
2498
+ FUNCTION_NAMES_FINANCIAL["PDURATION"] = "PDURATION";
2499
+ FUNCTION_NAMES_FINANCIAL["PMT"] = "PMT";
2500
+ FUNCTION_NAMES_FINANCIAL["PPMT"] = "PPMT";
2501
+ FUNCTION_NAMES_FINANCIAL["PRICE"] = "PRICE";
2502
+ FUNCTION_NAMES_FINANCIAL["PRICEDISC"] = "PRICEDISC";
2503
+ FUNCTION_NAMES_FINANCIAL["PRICEMAT"] = "PRICEMAT";
2504
+ FUNCTION_NAMES_FINANCIAL["PV"] = "PV";
2505
+ FUNCTION_NAMES_FINANCIAL["RATE"] = "RATE";
2506
+ FUNCTION_NAMES_FINANCIAL["RECEIVED"] = "RECEIVED";
2507
+ FUNCTION_NAMES_FINANCIAL["RRI"] = "RRI";
2508
+ FUNCTION_NAMES_FINANCIAL["SLN"] = "SLN";
2509
+ FUNCTION_NAMES_FINANCIAL["SYD"] = "SYD";
2510
+ FUNCTION_NAMES_FINANCIAL["TBILLEQ"] = "TBILLEQ";
2511
+ FUNCTION_NAMES_FINANCIAL["TBILLPRICE"] = "TBILLPRICE";
2512
+ FUNCTION_NAMES_FINANCIAL["TBILLYIELD"] = "TBILLYIELD";
2513
+ FUNCTION_NAMES_FINANCIAL["VDB"] = "VDB";
2514
+ FUNCTION_NAMES_FINANCIAL["XIRR"] = "XIRR";
2515
+ FUNCTION_NAMES_FINANCIAL["XNPV"] = "XNPV";
2516
+ FUNCTION_NAMES_FINANCIAL["YIELD"] = "YIELD";
2517
+ FUNCTION_NAMES_FINANCIAL["YIELDDISC"] = "YIELDDISC";
2518
+ FUNCTION_NAMES_FINANCIAL["YIELDMAT"] = "YIELDMAT";
2519
+ return FUNCTION_NAMES_FINANCIAL;
2520
+ }({});
2182
2521
 
2183
2522
  //#endregion
2184
- //#region src/engine/analysis/lexer-node.ts
2185
- var LexerNode = class LexerNode {
2186
- constructor() {
2187
- _defineProperty(this, "_parent", void 0);
2188
- _defineProperty(this, "_token", "R_1");
2189
- _defineProperty(this, "_children", []);
2190
- _defineProperty(this, "_lambdaId", void 0);
2191
- _defineProperty(this, "_functionDefinitionPrivacyVar", void 0);
2192
- _defineProperty(this, "_lambdaParameter", "");
2193
- _defineProperty(this, "_startIndex", -1);
2194
- _defineProperty(this, "_endIndex", -1);
2195
- _defineProperty(this, "_definedNames", []);
2196
- }
2197
- dispose() {
2198
- var _this$_functionDefini;
2199
- this._children.forEach((node) => {
2200
- if (!(typeof node === "string")) node.dispose();
2201
- });
2202
- (_this$_functionDefini = this._functionDefinitionPrivacyVar) === null || _this$_functionDefini === void 0 || _this$_functionDefini.clear();
2203
- this._functionDefinitionPrivacyVar = null;
2204
- this._children = [];
2205
- this._parent = null;
2206
- this._definedNames = [];
2207
- }
2208
- getDefinedNames() {
2209
- return this._definedNames;
2210
- }
2211
- getStartIndex() {
2212
- return this._startIndex;
2213
- }
2214
- getLambdaId() {
2215
- return this._lambdaId;
2216
- }
2217
- setLambdaId(lambdaId) {
2218
- this._lambdaId = lambdaId;
2219
- }
2220
- getFunctionDefinitionPrivacyVar() {
2221
- return this._functionDefinitionPrivacyVar;
2222
- }
2223
- setLambdaPrivacyVar(lambdaPrivacyVar) {
2224
- this._functionDefinitionPrivacyVar = lambdaPrivacyVar;
2225
- }
2226
- getLambdaParameter() {
2227
- return this._lambdaParameter;
2228
- }
2229
- setLambdaParameter(lambdaParameter) {
2230
- this._lambdaParameter = lambdaParameter;
2231
- }
2232
- getParent() {
2233
- return this._parent;
2234
- }
2235
- setParent(lexerNode) {
2236
- this._parent = lexerNode;
2237
- }
2238
- getChildren() {
2239
- return this._children;
2240
- }
2241
- setChildren(children) {
2242
- this._children = children;
2243
- }
2244
- addChildren(children) {
2245
- this._children.push(children);
2246
- }
2247
- addChildrenFirst(children) {
2248
- this._children.unshift(children);
2249
- }
2250
- getToken() {
2251
- return this._token;
2252
- }
2253
- setToken(token) {
2254
- this._token = token;
2255
- }
2256
- setIndex(st, ed) {
2257
- this._startIndex = st;
2258
- this._endIndex = ed;
2259
- }
2260
- setDefinedNames(definedNames) {
2261
- this._definedNames = definedNames;
2262
- }
2263
- hasDefinedNames() {
2264
- return this._definedNames.length > 0;
2265
- }
2266
- replaceChild(lexerNode, newLexerNode) {
2267
- const i = this._getIndexInParent(lexerNode);
2268
- if (i == null) return;
2269
- this.getChildren().splice(i, 1, newLexerNode);
2270
- newLexerNode.setParent(this);
2271
- }
2272
- changeToParent(newParentLexerNode) {
2273
- const parentNode = this.getParent();
2274
- if (parentNode) parentNode.removeChild(this);
2275
- this.setParent(newParentLexerNode);
2276
- newParentLexerNode.getChildren().push(this);
2277
- }
2278
- removeChild(lexerNode) {
2279
- const i = this._getIndexInParent(lexerNode);
2280
- if (i == null) return;
2281
- this.getChildren().splice(i, 1);
2282
- }
2283
- serialize() {
2284
- const token = this.getToken();
2285
- const children = this.getChildren();
2286
- const childrenSerialization = [];
2287
- const childrenCount = children.length;
2288
- for (let i = 0; i < childrenCount; i++) {
2289
- const item = children[i];
2290
- if (item instanceof LexerNode) childrenSerialization.push(item.serialize());
2291
- else childrenSerialization.push(item);
2523
+ //#region src/functions/information/function-names.ts
2524
+ /**
2525
+ * Copyright 2023-present DreamNum Co., Ltd.
2526
+ *
2527
+ * Licensed under the Apache License, Version 2.0 (the "License");
2528
+ * you may not use this file except in compliance with the License.
2529
+ * You may obtain a copy of the License at
2530
+ *
2531
+ * http://www.apache.org/licenses/LICENSE-2.0
2532
+ *
2533
+ * Unless required by applicable law or agreed to in writing, software
2534
+ * distributed under the License is distributed on an "AS IS" BASIS,
2535
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2536
+ * See the License for the specific language governing permissions and
2537
+ * limitations under the License.
2538
+ */
2539
+ let FUNCTION_NAMES_INFORMATION = /* @__PURE__ */ function(FUNCTION_NAMES_INFORMATION) {
2540
+ FUNCTION_NAMES_INFORMATION["CELL"] = "CELL";
2541
+ FUNCTION_NAMES_INFORMATION["ERROR_TYPE"] = "ERROR.TYPE";
2542
+ FUNCTION_NAMES_INFORMATION["INFO"] = "INFO";
2543
+ FUNCTION_NAMES_INFORMATION["ISBETWEEN"] = "ISBETWEEN";
2544
+ FUNCTION_NAMES_INFORMATION["ISBLANK"] = "ISBLANK";
2545
+ FUNCTION_NAMES_INFORMATION["ISDATE"] = "ISDATE";
2546
+ FUNCTION_NAMES_INFORMATION["ISEMAIL"] = "ISEMAIL";
2547
+ FUNCTION_NAMES_INFORMATION["ISERR"] = "ISERR";
2548
+ FUNCTION_NAMES_INFORMATION["ISERROR"] = "ISERROR";
2549
+ FUNCTION_NAMES_INFORMATION["ISEVEN"] = "ISEVEN";
2550
+ FUNCTION_NAMES_INFORMATION["ISFORMULA"] = "ISFORMULA";
2551
+ FUNCTION_NAMES_INFORMATION["ISLOGICAL"] = "ISLOGICAL";
2552
+ FUNCTION_NAMES_INFORMATION["ISNA"] = "ISNA";
2553
+ FUNCTION_NAMES_INFORMATION["ISNONTEXT"] = "ISNONTEXT";
2554
+ FUNCTION_NAMES_INFORMATION["ISNUMBER"] = "ISNUMBER";
2555
+ FUNCTION_NAMES_INFORMATION["ISODD"] = "ISODD";
2556
+ FUNCTION_NAMES_INFORMATION["ISOMITTED"] = "ISOMITTED";
2557
+ FUNCTION_NAMES_INFORMATION["ISREF"] = "ISREF";
2558
+ FUNCTION_NAMES_INFORMATION["ISTEXT"] = "ISTEXT";
2559
+ FUNCTION_NAMES_INFORMATION["ISURL"] = "ISURL";
2560
+ FUNCTION_NAMES_INFORMATION["N"] = "N";
2561
+ FUNCTION_NAMES_INFORMATION["NA"] = "NA";
2562
+ FUNCTION_NAMES_INFORMATION["SHEET"] = "SHEET";
2563
+ FUNCTION_NAMES_INFORMATION["SHEETS"] = "SHEETS";
2564
+ FUNCTION_NAMES_INFORMATION["TYPE"] = "TYPE";
2565
+ return FUNCTION_NAMES_INFORMATION;
2566
+ }({});
2567
+
2568
+ //#endregion
2569
+ //#region src/functions/logical/function-names.ts
2570
+ /**
2571
+ * Copyright 2023-present DreamNum Co., Ltd.
2572
+ *
2573
+ * Licensed under the Apache License, Version 2.0 (the "License");
2574
+ * you may not use this file except in compliance with the License.
2575
+ * You may obtain a copy of the License at
2576
+ *
2577
+ * http://www.apache.org/licenses/LICENSE-2.0
2578
+ *
2579
+ * Unless required by applicable law or agreed to in writing, software
2580
+ * distributed under the License is distributed on an "AS IS" BASIS,
2581
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2582
+ * See the License for the specific language governing permissions and
2583
+ * limitations under the License.
2584
+ */
2585
+ let FUNCTION_NAMES_LOGICAL = /* @__PURE__ */ function(FUNCTION_NAMES_LOGICAL) {
2586
+ FUNCTION_NAMES_LOGICAL["AND"] = "AND";
2587
+ FUNCTION_NAMES_LOGICAL["BYCOL"] = "BYCOL";
2588
+ FUNCTION_NAMES_LOGICAL["BYROW"] = "BYROW";
2589
+ FUNCTION_NAMES_LOGICAL["FALSE"] = "FALSE";
2590
+ FUNCTION_NAMES_LOGICAL["IF"] = "IF";
2591
+ FUNCTION_NAMES_LOGICAL["IFERROR"] = "IFERROR";
2592
+ FUNCTION_NAMES_LOGICAL["IFNA"] = "IFNA";
2593
+ FUNCTION_NAMES_LOGICAL["IFS"] = "IFS";
2594
+ FUNCTION_NAMES_LOGICAL["LAMBDA"] = "LAMBDA";
2595
+ FUNCTION_NAMES_LOGICAL["LET"] = "LET";
2596
+ FUNCTION_NAMES_LOGICAL["MAKEARRAY"] = "MAKEARRAY";
2597
+ FUNCTION_NAMES_LOGICAL["MAP"] = "MAP";
2598
+ FUNCTION_NAMES_LOGICAL["NOT"] = "NOT";
2599
+ FUNCTION_NAMES_LOGICAL["OR"] = "OR";
2600
+ FUNCTION_NAMES_LOGICAL["REDUCE"] = "REDUCE";
2601
+ FUNCTION_NAMES_LOGICAL["SCAN"] = "SCAN";
2602
+ FUNCTION_NAMES_LOGICAL["SWITCH"] = "SWITCH";
2603
+ FUNCTION_NAMES_LOGICAL["TRUE"] = "TRUE";
2604
+ FUNCTION_NAMES_LOGICAL["XOR"] = "XOR";
2605
+ return FUNCTION_NAMES_LOGICAL;
2606
+ }({});
2607
+
2608
+ //#endregion
2609
+ //#region src/functions/lookup/function-names.ts
2610
+ /**
2611
+ * Copyright 2023-present DreamNum Co., Ltd.
2612
+ *
2613
+ * Licensed under the Apache License, Version 2.0 (the "License");
2614
+ * you may not use this file except in compliance with the License.
2615
+ * You may obtain a copy of the License at
2616
+ *
2617
+ * http://www.apache.org/licenses/LICENSE-2.0
2618
+ *
2619
+ * Unless required by applicable law or agreed to in writing, software
2620
+ * distributed under the License is distributed on an "AS IS" BASIS,
2621
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2622
+ * See the License for the specific language governing permissions and
2623
+ * limitations under the License.
2624
+ */
2625
+ let FUNCTION_NAMES_LOOKUP = /* @__PURE__ */ function(FUNCTION_NAMES_LOOKUP) {
2626
+ FUNCTION_NAMES_LOOKUP["ADDRESS"] = "ADDRESS";
2627
+ FUNCTION_NAMES_LOOKUP["AREAS"] = "AREAS";
2628
+ FUNCTION_NAMES_LOOKUP["CHOOSE"] = "CHOOSE";
2629
+ FUNCTION_NAMES_LOOKUP["CHOOSECOLS"] = "CHOOSECOLS";
2630
+ FUNCTION_NAMES_LOOKUP["CHOOSEROWS"] = "CHOOSEROWS";
2631
+ FUNCTION_NAMES_LOOKUP["COLUMN"] = "COLUMN";
2632
+ FUNCTION_NAMES_LOOKUP["COLUMNS"] = "COLUMNS";
2633
+ FUNCTION_NAMES_LOOKUP["DROP"] = "DROP";
2634
+ FUNCTION_NAMES_LOOKUP["EXPAND"] = "EXPAND";
2635
+ FUNCTION_NAMES_LOOKUP["FILTER"] = "FILTER";
2636
+ FUNCTION_NAMES_LOOKUP["FORMULATEXT"] = "FORMULATEXT";
2637
+ FUNCTION_NAMES_LOOKUP["GETPIVOTDATA"] = "GETPIVOTDATA";
2638
+ FUNCTION_NAMES_LOOKUP["HLOOKUP"] = "HLOOKUP";
2639
+ FUNCTION_NAMES_LOOKUP["HSTACK"] = "HSTACK";
2640
+ FUNCTION_NAMES_LOOKUP["HYPERLINK"] = "HYPERLINK";
2641
+ FUNCTION_NAMES_LOOKUP["IMAGE"] = "IMAGE";
2642
+ FUNCTION_NAMES_LOOKUP["INDEX"] = "INDEX";
2643
+ FUNCTION_NAMES_LOOKUP["INDIRECT"] = "INDIRECT";
2644
+ FUNCTION_NAMES_LOOKUP["LOOKUP"] = "LOOKUP";
2645
+ FUNCTION_NAMES_LOOKUP["MATCH"] = "MATCH";
2646
+ FUNCTION_NAMES_LOOKUP["OFFSET"] = "OFFSET";
2647
+ FUNCTION_NAMES_LOOKUP["ROW"] = "ROW";
2648
+ FUNCTION_NAMES_LOOKUP["ROWS"] = "ROWS";
2649
+ FUNCTION_NAMES_LOOKUP["RTD"] = "RTD";
2650
+ FUNCTION_NAMES_LOOKUP["SORT"] = "SORT";
2651
+ FUNCTION_NAMES_LOOKUP["SORTBY"] = "SORTBY";
2652
+ FUNCTION_NAMES_LOOKUP["TAKE"] = "TAKE";
2653
+ FUNCTION_NAMES_LOOKUP["TOCOL"] = "TOCOL";
2654
+ FUNCTION_NAMES_LOOKUP["TOROW"] = "TOROW";
2655
+ FUNCTION_NAMES_LOOKUP["TRANSPOSE"] = "TRANSPOSE";
2656
+ FUNCTION_NAMES_LOOKUP["UNIQUE"] = "UNIQUE";
2657
+ FUNCTION_NAMES_LOOKUP["VLOOKUP"] = "VLOOKUP";
2658
+ FUNCTION_NAMES_LOOKUP["VSTACK"] = "VSTACK";
2659
+ FUNCTION_NAMES_LOOKUP["WRAPCOLS"] = "WRAPCOLS";
2660
+ FUNCTION_NAMES_LOOKUP["WRAPROWS"] = "WRAPROWS";
2661
+ FUNCTION_NAMES_LOOKUP["XLOOKUP"] = "XLOOKUP";
2662
+ FUNCTION_NAMES_LOOKUP["XMATCH"] = "XMATCH";
2663
+ return FUNCTION_NAMES_LOOKUP;
2664
+ }({});
2665
+
2666
+ //#endregion
2667
+ //#region src/functions/math/function-names.ts
2668
+ /**
2669
+ * Copyright 2023-present DreamNum Co., Ltd.
2670
+ *
2671
+ * Licensed under the Apache License, Version 2.0 (the "License");
2672
+ * you may not use this file except in compliance with the License.
2673
+ * You may obtain a copy of the License at
2674
+ *
2675
+ * http://www.apache.org/licenses/LICENSE-2.0
2676
+ *
2677
+ * Unless required by applicable law or agreed to in writing, software
2678
+ * distributed under the License is distributed on an "AS IS" BASIS,
2679
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2680
+ * See the License for the specific language governing permissions and
2681
+ * limitations under the License.
2682
+ */
2683
+ let FUNCTION_NAMES_MATH = /* @__PURE__ */ function(FUNCTION_NAMES_MATH) {
2684
+ FUNCTION_NAMES_MATH["ABS"] = "ABS";
2685
+ FUNCTION_NAMES_MATH["ACOS"] = "ACOS";
2686
+ FUNCTION_NAMES_MATH["ACOSH"] = "ACOSH";
2687
+ FUNCTION_NAMES_MATH["ACOT"] = "ACOT";
2688
+ FUNCTION_NAMES_MATH["ACOTH"] = "ACOTH";
2689
+ FUNCTION_NAMES_MATH["AGGREGATE"] = "AGGREGATE";
2690
+ FUNCTION_NAMES_MATH["ARABIC"] = "ARABIC";
2691
+ FUNCTION_NAMES_MATH["ASIN"] = "ASIN";
2692
+ FUNCTION_NAMES_MATH["ASINH"] = "ASINH";
2693
+ FUNCTION_NAMES_MATH["ATAN"] = "ATAN";
2694
+ FUNCTION_NAMES_MATH["ATAN2"] = "ATAN2";
2695
+ FUNCTION_NAMES_MATH["ATANH"] = "ATANH";
2696
+ FUNCTION_NAMES_MATH["BASE"] = "BASE";
2697
+ FUNCTION_NAMES_MATH["CEILING"] = "CEILING";
2698
+ FUNCTION_NAMES_MATH["CEILING_MATH"] = "CEILING.MATH";
2699
+ FUNCTION_NAMES_MATH["CEILING_PRECISE"] = "CEILING.PRECISE";
2700
+ FUNCTION_NAMES_MATH["COMBIN"] = "COMBIN";
2701
+ FUNCTION_NAMES_MATH["COMBINA"] = "COMBINA";
2702
+ FUNCTION_NAMES_MATH["COS"] = "COS";
2703
+ FUNCTION_NAMES_MATH["COSH"] = "COSH";
2704
+ FUNCTION_NAMES_MATH["COT"] = "COT";
2705
+ FUNCTION_NAMES_MATH["COTH"] = "COTH";
2706
+ FUNCTION_NAMES_MATH["CSC"] = "CSC";
2707
+ FUNCTION_NAMES_MATH["CSCH"] = "CSCH";
2708
+ FUNCTION_NAMES_MATH["DECIMAL"] = "DECIMAL";
2709
+ FUNCTION_NAMES_MATH["DEGREES"] = "DEGREES";
2710
+ FUNCTION_NAMES_MATH["EVEN"] = "EVEN";
2711
+ FUNCTION_NAMES_MATH["EXP"] = "EXP";
2712
+ FUNCTION_NAMES_MATH["FACT"] = "FACT";
2713
+ FUNCTION_NAMES_MATH["FACTDOUBLE"] = "FACTDOUBLE";
2714
+ FUNCTION_NAMES_MATH["FLOOR"] = "FLOOR";
2715
+ FUNCTION_NAMES_MATH["FLOOR_MATH"] = "FLOOR.MATH";
2716
+ FUNCTION_NAMES_MATH["FLOOR_PRECISE"] = "FLOOR.PRECISE";
2717
+ FUNCTION_NAMES_MATH["GCD"] = "GCD";
2718
+ FUNCTION_NAMES_MATH["INT"] = "INT";
2719
+ FUNCTION_NAMES_MATH["ISO_CEILING"] = "ISO.CEILING";
2720
+ FUNCTION_NAMES_MATH["LCM"] = "LCM";
2721
+ FUNCTION_NAMES_MATH["LET"] = "LET";
2722
+ FUNCTION_NAMES_MATH["LN"] = "LN";
2723
+ FUNCTION_NAMES_MATH["LOG"] = "LOG";
2724
+ FUNCTION_NAMES_MATH["LOG10"] = "LOG10";
2725
+ FUNCTION_NAMES_MATH["MDETERM"] = "MDETERM";
2726
+ FUNCTION_NAMES_MATH["MINVERSE"] = "MINVERSE";
2727
+ FUNCTION_NAMES_MATH["MMULT"] = "MMULT";
2728
+ FUNCTION_NAMES_MATH["MOD"] = "MOD";
2729
+ FUNCTION_NAMES_MATH["MROUND"] = "MROUND";
2730
+ FUNCTION_NAMES_MATH["MULTINOMIAL"] = "MULTINOMIAL";
2731
+ FUNCTION_NAMES_MATH["MUNIT"] = "MUNIT";
2732
+ FUNCTION_NAMES_MATH["ODD"] = "ODD";
2733
+ FUNCTION_NAMES_MATH["PI"] = "PI";
2734
+ FUNCTION_NAMES_MATH["POWER"] = "POWER";
2735
+ FUNCTION_NAMES_MATH["PRODUCT"] = "PRODUCT";
2736
+ FUNCTION_NAMES_MATH["QUOTIENT"] = "QUOTIENT";
2737
+ FUNCTION_NAMES_MATH["RADIANS"] = "RADIANS";
2738
+ FUNCTION_NAMES_MATH["RAND"] = "RAND";
2739
+ FUNCTION_NAMES_MATH["RANDARRAY"] = "RANDARRAY";
2740
+ FUNCTION_NAMES_MATH["RANDBETWEEN"] = "RANDBETWEEN";
2741
+ FUNCTION_NAMES_MATH["ROMAN"] = "ROMAN";
2742
+ FUNCTION_NAMES_MATH["ROUND"] = "ROUND";
2743
+ FUNCTION_NAMES_MATH["ROUNDBANK"] = "ROUNDBANK";
2744
+ FUNCTION_NAMES_MATH["ROUNDDOWN"] = "ROUNDDOWN";
2745
+ FUNCTION_NAMES_MATH["ROUNDUP"] = "ROUNDUP";
2746
+ FUNCTION_NAMES_MATH["SEC"] = "SEC";
2747
+ FUNCTION_NAMES_MATH["SECH"] = "SECH";
2748
+ FUNCTION_NAMES_MATH["SERIESSUM"] = "SERIESSUM";
2749
+ FUNCTION_NAMES_MATH["SEQUENCE"] = "SEQUENCE";
2750
+ FUNCTION_NAMES_MATH["SIGN"] = "SIGN";
2751
+ FUNCTION_NAMES_MATH["SIN"] = "SIN";
2752
+ FUNCTION_NAMES_MATH["SINH"] = "SINH";
2753
+ FUNCTION_NAMES_MATH["SQRT"] = "SQRT";
2754
+ FUNCTION_NAMES_MATH["SQRTPI"] = "SQRTPI";
2755
+ FUNCTION_NAMES_MATH["SUBTOTAL"] = "SUBTOTAL";
2756
+ FUNCTION_NAMES_MATH["SUM"] = "SUM";
2757
+ FUNCTION_NAMES_MATH["SUMIF"] = "SUMIF";
2758
+ FUNCTION_NAMES_MATH["SUMIFS"] = "SUMIFS";
2759
+ FUNCTION_NAMES_MATH["SUMPRODUCT"] = "SUMPRODUCT";
2760
+ FUNCTION_NAMES_MATH["SUMSQ"] = "SUMSQ";
2761
+ FUNCTION_NAMES_MATH["SUMX2MY2"] = "SUMX2MY2";
2762
+ FUNCTION_NAMES_MATH["SUMX2PY2"] = "SUMX2PY2";
2763
+ FUNCTION_NAMES_MATH["SUMXMY2"] = "SUMXMY2";
2764
+ FUNCTION_NAMES_MATH["TAN"] = "TAN";
2765
+ FUNCTION_NAMES_MATH["TANH"] = "TANH";
2766
+ FUNCTION_NAMES_MATH["TRUNC"] = "TRUNC";
2767
+ return FUNCTION_NAMES_MATH;
2768
+ }({});
2769
+
2770
+ //#endregion
2771
+ //#region src/functions/statistical/function-names.ts
2772
+ /**
2773
+ * Copyright 2023-present DreamNum Co., Ltd.
2774
+ *
2775
+ * Licensed under the Apache License, Version 2.0 (the "License");
2776
+ * you may not use this file except in compliance with the License.
2777
+ * You may obtain a copy of the License at
2778
+ *
2779
+ * http://www.apache.org/licenses/LICENSE-2.0
2780
+ *
2781
+ * Unless required by applicable law or agreed to in writing, software
2782
+ * distributed under the License is distributed on an "AS IS" BASIS,
2783
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2784
+ * See the License for the specific language governing permissions and
2785
+ * limitations under the License.
2786
+ */
2787
+ let FUNCTION_NAMES_STATISTICAL = /* @__PURE__ */ function(FUNCTION_NAMES_STATISTICAL) {
2788
+ FUNCTION_NAMES_STATISTICAL["AVEDEV"] = "AVEDEV";
2789
+ FUNCTION_NAMES_STATISTICAL["AVERAGE"] = "AVERAGE";
2790
+ FUNCTION_NAMES_STATISTICAL["AVERAGE_WEIGHTED"] = "AVERAGE.WEIGHTED";
2791
+ FUNCTION_NAMES_STATISTICAL["AVERAGEA"] = "AVERAGEA";
2792
+ FUNCTION_NAMES_STATISTICAL["AVERAGEIF"] = "AVERAGEIF";
2793
+ FUNCTION_NAMES_STATISTICAL["AVERAGEIFS"] = "AVERAGEIFS";
2794
+ FUNCTION_NAMES_STATISTICAL["BETA_DIST"] = "BETA.DIST";
2795
+ FUNCTION_NAMES_STATISTICAL["BETA_INV"] = "BETA.INV";
2796
+ FUNCTION_NAMES_STATISTICAL["BINOM_DIST"] = "BINOM.DIST";
2797
+ FUNCTION_NAMES_STATISTICAL["BINOM_DIST_RANGE"] = "BINOM.DIST.RANGE";
2798
+ FUNCTION_NAMES_STATISTICAL["BINOM_INV"] = "BINOM.INV";
2799
+ FUNCTION_NAMES_STATISTICAL["CHISQ_DIST"] = "CHISQ.DIST";
2800
+ FUNCTION_NAMES_STATISTICAL["CHISQ_DIST_RT"] = "CHISQ.DIST.RT";
2801
+ FUNCTION_NAMES_STATISTICAL["CHISQ_INV"] = "CHISQ.INV";
2802
+ FUNCTION_NAMES_STATISTICAL["CHISQ_INV_RT"] = "CHISQ.INV.RT";
2803
+ FUNCTION_NAMES_STATISTICAL["CHISQ_TEST"] = "CHISQ.TEST";
2804
+ FUNCTION_NAMES_STATISTICAL["CONFIDENCE_NORM"] = "CONFIDENCE.NORM";
2805
+ FUNCTION_NAMES_STATISTICAL["CONFIDENCE_T"] = "CONFIDENCE.T";
2806
+ FUNCTION_NAMES_STATISTICAL["CORREL"] = "CORREL";
2807
+ FUNCTION_NAMES_STATISTICAL["COUNT"] = "COUNT";
2808
+ FUNCTION_NAMES_STATISTICAL["COUNTA"] = "COUNTA";
2809
+ FUNCTION_NAMES_STATISTICAL["COUNTBLANK"] = "COUNTBLANK";
2810
+ FUNCTION_NAMES_STATISTICAL["COUNTIF"] = "COUNTIF";
2811
+ FUNCTION_NAMES_STATISTICAL["COUNTIFS"] = "COUNTIFS";
2812
+ FUNCTION_NAMES_STATISTICAL["COVARIANCE_P"] = "COVARIANCE.P";
2813
+ FUNCTION_NAMES_STATISTICAL["COVARIANCE_S"] = "COVARIANCE.S";
2814
+ FUNCTION_NAMES_STATISTICAL["DEVSQ"] = "DEVSQ";
2815
+ FUNCTION_NAMES_STATISTICAL["EXPON_DIST"] = "EXPON.DIST";
2816
+ FUNCTION_NAMES_STATISTICAL["F_DIST"] = "F.DIST";
2817
+ FUNCTION_NAMES_STATISTICAL["F_DIST_RT"] = "F.DIST.RT";
2818
+ FUNCTION_NAMES_STATISTICAL["F_INV"] = "F.INV";
2819
+ FUNCTION_NAMES_STATISTICAL["F_INV_RT"] = "F.INV.RT";
2820
+ FUNCTION_NAMES_STATISTICAL["F_TEST"] = "F.TEST";
2821
+ FUNCTION_NAMES_STATISTICAL["FISHER"] = "FISHER";
2822
+ FUNCTION_NAMES_STATISTICAL["FISHERINV"] = "FISHERINV";
2823
+ FUNCTION_NAMES_STATISTICAL["FORECAST"] = "FORECAST";
2824
+ FUNCTION_NAMES_STATISTICAL["FORECAST_ETS"] = "FORECAST.ETS";
2825
+ FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_CONFINT"] = "FORECAST.ETS.CONFINT";
2826
+ FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_SEASONALITY"] = "FORECAST.ETS.SEASONALITY";
2827
+ FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_STAT"] = "FORECAST.ETS.STAT";
2828
+ FUNCTION_NAMES_STATISTICAL["FORECAST_LINEAR"] = "FORECAST.LINEAR";
2829
+ FUNCTION_NAMES_STATISTICAL["FREQUENCY"] = "FREQUENCY";
2830
+ FUNCTION_NAMES_STATISTICAL["GAMMA"] = "GAMMA";
2831
+ FUNCTION_NAMES_STATISTICAL["GAMMA_DIST"] = "GAMMA.DIST";
2832
+ FUNCTION_NAMES_STATISTICAL["GAMMA_INV"] = "GAMMA.INV";
2833
+ FUNCTION_NAMES_STATISTICAL["GAMMALN"] = "GAMMALN";
2834
+ FUNCTION_NAMES_STATISTICAL["GAMMALN_PRECISE"] = "GAMMALN.PRECISE";
2835
+ FUNCTION_NAMES_STATISTICAL["GAUSS"] = "GAUSS";
2836
+ FUNCTION_NAMES_STATISTICAL["GEOMEAN"] = "GEOMEAN";
2837
+ FUNCTION_NAMES_STATISTICAL["GROWTH"] = "GROWTH";
2838
+ FUNCTION_NAMES_STATISTICAL["HARMEAN"] = "HARMEAN";
2839
+ FUNCTION_NAMES_STATISTICAL["HYPGEOM_DIST"] = "HYPGEOM.DIST";
2840
+ FUNCTION_NAMES_STATISTICAL["INTERCEPT"] = "INTERCEPT";
2841
+ FUNCTION_NAMES_STATISTICAL["KURT"] = "KURT";
2842
+ FUNCTION_NAMES_STATISTICAL["LARGE"] = "LARGE";
2843
+ FUNCTION_NAMES_STATISTICAL["LINEST"] = "LINEST";
2844
+ FUNCTION_NAMES_STATISTICAL["LOGEST"] = "LOGEST";
2845
+ FUNCTION_NAMES_STATISTICAL["LOGNORM_DIST"] = "LOGNORM.DIST";
2846
+ FUNCTION_NAMES_STATISTICAL["LOGNORM_INV"] = "LOGNORM.INV";
2847
+ FUNCTION_NAMES_STATISTICAL["MARGINOFERROR"] = "MARGINOFERROR";
2848
+ FUNCTION_NAMES_STATISTICAL["MAX"] = "MAX";
2849
+ FUNCTION_NAMES_STATISTICAL["MAXA"] = "MAXA";
2850
+ FUNCTION_NAMES_STATISTICAL["MAXIFS"] = "MAXIFS";
2851
+ FUNCTION_NAMES_STATISTICAL["MEDIAN"] = "MEDIAN";
2852
+ FUNCTION_NAMES_STATISTICAL["MIN"] = "MIN";
2853
+ FUNCTION_NAMES_STATISTICAL["MINA"] = "MINA";
2854
+ FUNCTION_NAMES_STATISTICAL["MINIFS"] = "MINIFS";
2855
+ FUNCTION_NAMES_STATISTICAL["MODE_MULT"] = "MODE.MULT";
2856
+ FUNCTION_NAMES_STATISTICAL["MODE_SNGL"] = "MODE.SNGL";
2857
+ FUNCTION_NAMES_STATISTICAL["NEGBINOM_DIST"] = "NEGBINOM.DIST";
2858
+ FUNCTION_NAMES_STATISTICAL["NORM_DIST"] = "NORM.DIST";
2859
+ FUNCTION_NAMES_STATISTICAL["NORM_INV"] = "NORM.INV";
2860
+ FUNCTION_NAMES_STATISTICAL["NORM_S_DIST"] = "NORM.S.DIST";
2861
+ FUNCTION_NAMES_STATISTICAL["NORM_S_INV"] = "NORM.S.INV";
2862
+ FUNCTION_NAMES_STATISTICAL["PEARSON"] = "PEARSON";
2863
+ FUNCTION_NAMES_STATISTICAL["PERCENTILE_EXC"] = "PERCENTILE.EXC";
2864
+ FUNCTION_NAMES_STATISTICAL["PERCENTILE_INC"] = "PERCENTILE.INC";
2865
+ FUNCTION_NAMES_STATISTICAL["PERCENTRANK_EXC"] = "PERCENTRANK.EXC";
2866
+ FUNCTION_NAMES_STATISTICAL["PERCENTRANK_INC"] = "PERCENTRANK.INC";
2867
+ FUNCTION_NAMES_STATISTICAL["PERMUT"] = "PERMUT";
2868
+ FUNCTION_NAMES_STATISTICAL["PERMUTATIONA"] = "PERMUTATIONA";
2869
+ FUNCTION_NAMES_STATISTICAL["PHI"] = "PHI";
2870
+ FUNCTION_NAMES_STATISTICAL["POISSON_DIST"] = "POISSON.DIST";
2871
+ FUNCTION_NAMES_STATISTICAL["PROB"] = "PROB";
2872
+ FUNCTION_NAMES_STATISTICAL["QUARTILE_EXC"] = "QUARTILE.EXC";
2873
+ FUNCTION_NAMES_STATISTICAL["QUARTILE_INC"] = "QUARTILE.INC";
2874
+ FUNCTION_NAMES_STATISTICAL["RANK_AVG"] = "RANK.AVG";
2875
+ FUNCTION_NAMES_STATISTICAL["RANK_EQ"] = "RANK.EQ";
2876
+ FUNCTION_NAMES_STATISTICAL["RSQ"] = "RSQ";
2877
+ FUNCTION_NAMES_STATISTICAL["SKEW"] = "SKEW";
2878
+ FUNCTION_NAMES_STATISTICAL["SKEW_P"] = "SKEW.P";
2879
+ FUNCTION_NAMES_STATISTICAL["SLOPE"] = "SLOPE";
2880
+ FUNCTION_NAMES_STATISTICAL["SMALL"] = "SMALL";
2881
+ FUNCTION_NAMES_STATISTICAL["STANDARDIZE"] = "STANDARDIZE";
2882
+ FUNCTION_NAMES_STATISTICAL["STDEV_P"] = "STDEV.P";
2883
+ FUNCTION_NAMES_STATISTICAL["STDEV_S"] = "STDEV.S";
2884
+ FUNCTION_NAMES_STATISTICAL["STDEVA"] = "STDEVA";
2885
+ FUNCTION_NAMES_STATISTICAL["STDEVPA"] = "STDEVPA";
2886
+ FUNCTION_NAMES_STATISTICAL["STEYX"] = "STEYX";
2887
+ FUNCTION_NAMES_STATISTICAL["T_DIST"] = "T.DIST";
2888
+ FUNCTION_NAMES_STATISTICAL["T_DIST_2T"] = "T.DIST.2T";
2889
+ FUNCTION_NAMES_STATISTICAL["T_DIST_RT"] = "T.DIST.RT";
2890
+ FUNCTION_NAMES_STATISTICAL["T_INV"] = "T.INV";
2891
+ FUNCTION_NAMES_STATISTICAL["T_INV_2T"] = "T.INV.2T";
2892
+ FUNCTION_NAMES_STATISTICAL["T_TEST"] = "T.TEST";
2893
+ FUNCTION_NAMES_STATISTICAL["TREND"] = "TREND";
2894
+ FUNCTION_NAMES_STATISTICAL["TRIMMEAN"] = "TRIMMEAN";
2895
+ FUNCTION_NAMES_STATISTICAL["VAR_P"] = "VAR.P";
2896
+ FUNCTION_NAMES_STATISTICAL["VAR_S"] = "VAR.S";
2897
+ FUNCTION_NAMES_STATISTICAL["VARA"] = "VARA";
2898
+ FUNCTION_NAMES_STATISTICAL["VARPA"] = "VARPA";
2899
+ FUNCTION_NAMES_STATISTICAL["WEIBULL_DIST"] = "WEIBULL.DIST";
2900
+ FUNCTION_NAMES_STATISTICAL["Z_TEST"] = "Z.TEST";
2901
+ return FUNCTION_NAMES_STATISTICAL;
2902
+ }({});
2903
+
2904
+ //#endregion
2905
+ //#region src/functions/text/function-names.ts
2906
+ /**
2907
+ * Copyright 2023-present DreamNum Co., Ltd.
2908
+ *
2909
+ * Licensed under the Apache License, Version 2.0 (the "License");
2910
+ * you may not use this file except in compliance with the License.
2911
+ * You may obtain a copy of the License at
2912
+ *
2913
+ * http://www.apache.org/licenses/LICENSE-2.0
2914
+ *
2915
+ * Unless required by applicable law or agreed to in writing, software
2916
+ * distributed under the License is distributed on an "AS IS" BASIS,
2917
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2918
+ * See the License for the specific language governing permissions and
2919
+ * limitations under the License.
2920
+ */
2921
+ let FUNCTION_NAMES_TEXT = /* @__PURE__ */ function(FUNCTION_NAMES_TEXT) {
2922
+ FUNCTION_NAMES_TEXT["ASC"] = "ASC";
2923
+ FUNCTION_NAMES_TEXT["ARRAYTOTEXT"] = "ARRAYTOTEXT";
2924
+ FUNCTION_NAMES_TEXT["BAHTTEXT"] = "BAHTTEXT";
2925
+ FUNCTION_NAMES_TEXT["CHAR"] = "CHAR";
2926
+ FUNCTION_NAMES_TEXT["CLEAN"] = "CLEAN";
2927
+ FUNCTION_NAMES_TEXT["CODE"] = "CODE";
2928
+ FUNCTION_NAMES_TEXT["CONCAT"] = "CONCAT";
2929
+ FUNCTION_NAMES_TEXT["CONCATENATE"] = "CONCATENATE";
2930
+ FUNCTION_NAMES_TEXT["DBCS"] = "DBCS";
2931
+ FUNCTION_NAMES_TEXT["DOLLAR"] = "DOLLAR";
2932
+ FUNCTION_NAMES_TEXT["EXACT"] = "EXACT";
2933
+ FUNCTION_NAMES_TEXT["FIND"] = "FIND";
2934
+ FUNCTION_NAMES_TEXT["FINDB"] = "FINDB";
2935
+ FUNCTION_NAMES_TEXT["FIXED"] = "FIXED";
2936
+ FUNCTION_NAMES_TEXT["LEFT"] = "LEFT";
2937
+ FUNCTION_NAMES_TEXT["LEFTB"] = "LEFTB";
2938
+ FUNCTION_NAMES_TEXT["LEN"] = "LEN";
2939
+ FUNCTION_NAMES_TEXT["LENB"] = "LENB";
2940
+ FUNCTION_NAMES_TEXT["LOWER"] = "LOWER";
2941
+ FUNCTION_NAMES_TEXT["MID"] = "MID";
2942
+ FUNCTION_NAMES_TEXT["MIDB"] = "MIDB";
2943
+ FUNCTION_NAMES_TEXT["NUMBERSTRING"] = "NUMBERSTRING";
2944
+ FUNCTION_NAMES_TEXT["NUMBERVALUE"] = "NUMBERVALUE";
2945
+ FUNCTION_NAMES_TEXT["PHONETIC"] = "PHONETIC";
2946
+ FUNCTION_NAMES_TEXT["PROPER"] = "PROPER";
2947
+ FUNCTION_NAMES_TEXT["REGEXEXTRACT"] = "REGEXEXTRACT";
2948
+ FUNCTION_NAMES_TEXT["REGEXMATCH"] = "REGEXMATCH";
2949
+ FUNCTION_NAMES_TEXT["REGEXREPLACE"] = "REGEXREPLACE";
2950
+ FUNCTION_NAMES_TEXT["REPLACE"] = "REPLACE";
2951
+ FUNCTION_NAMES_TEXT["REPLACEB"] = "REPLACEB";
2952
+ FUNCTION_NAMES_TEXT["REPT"] = "REPT";
2953
+ FUNCTION_NAMES_TEXT["RIGHT"] = "RIGHT";
2954
+ FUNCTION_NAMES_TEXT["RIGHTB"] = "RIGHTB";
2955
+ FUNCTION_NAMES_TEXT["SEARCH"] = "SEARCH";
2956
+ FUNCTION_NAMES_TEXT["SEARCHB"] = "SEARCHB";
2957
+ FUNCTION_NAMES_TEXT["SUBSTITUTE"] = "SUBSTITUTE";
2958
+ FUNCTION_NAMES_TEXT["T"] = "T";
2959
+ FUNCTION_NAMES_TEXT["TEXT"] = "TEXT";
2960
+ FUNCTION_NAMES_TEXT["TEXTAFTER"] = "TEXTAFTER";
2961
+ FUNCTION_NAMES_TEXT["TEXTBEFORE"] = "TEXTBEFORE";
2962
+ FUNCTION_NAMES_TEXT["TEXTJOIN"] = "TEXTJOIN";
2963
+ FUNCTION_NAMES_TEXT["TEXTSPLIT"] = "TEXTSPLIT";
2964
+ FUNCTION_NAMES_TEXT["TRIM"] = "TRIM";
2965
+ FUNCTION_NAMES_TEXT["UNICHAR"] = "UNICHAR";
2966
+ FUNCTION_NAMES_TEXT["UNICODE"] = "UNICODE";
2967
+ FUNCTION_NAMES_TEXT["UPPER"] = "UPPER";
2968
+ FUNCTION_NAMES_TEXT["VALUE"] = "VALUE";
2969
+ FUNCTION_NAMES_TEXT["VALUETOTEXT"] = "VALUETOTEXT";
2970
+ FUNCTION_NAMES_TEXT["CALL"] = "CALL";
2971
+ FUNCTION_NAMES_TEXT["EUROCONVERT"] = "EUROCONVERT";
2972
+ FUNCTION_NAMES_TEXT["REGISTER_ID"] = "REGISTER.ID";
2973
+ return FUNCTION_NAMES_TEXT;
2974
+ }({});
2975
+
2976
+ //#endregion
2977
+ //#region src/functions/web/function-names.ts
2978
+ /**
2979
+ * Copyright 2023-present DreamNum Co., Ltd.
2980
+ *
2981
+ * Licensed under the Apache License, Version 2.0 (the "License");
2982
+ * you may not use this file except in compliance with the License.
2983
+ * You may obtain a copy of the License at
2984
+ *
2985
+ * http://www.apache.org/licenses/LICENSE-2.0
2986
+ *
2987
+ * Unless required by applicable law or agreed to in writing, software
2988
+ * distributed under the License is distributed on an "AS IS" BASIS,
2989
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2990
+ * See the License for the specific language governing permissions and
2991
+ * limitations under the License.
2992
+ */
2993
+ let FUNCTION_NAMES_WEB = /* @__PURE__ */ function(FUNCTION_NAMES_WEB) {
2994
+ FUNCTION_NAMES_WEB["ENCODEURL"] = "ENCODEURL";
2995
+ FUNCTION_NAMES_WEB["FILTERXML"] = "FILTERXML";
2996
+ FUNCTION_NAMES_WEB["WEBSERVICE"] = "WEBSERVICE";
2997
+ return FUNCTION_NAMES_WEB;
2998
+ }({});
2999
+
3000
+ //#endregion
3001
+ //#region src/functions/new-excel-functions.ts
3002
+ const NEW_EXCEL_FUNCTIONS = new Set([
3003
+ "ACOT",
3004
+ "ACOTH",
3005
+ "ARABIC",
3006
+ "BASE",
3007
+ "CEILING.MATH",
3008
+ "CEILING.PRECISE",
3009
+ "COMBINA",
3010
+ "COT",
3011
+ "COTH",
3012
+ "CSC",
3013
+ "CSCH",
3014
+ "DECIMAL",
3015
+ "FLOOR.MATH",
3016
+ "FLOOR.PRECISE",
3017
+ "MUNIT",
3018
+ "RANDARRAY",
3019
+ "SEC",
3020
+ "SECH",
3021
+ "SEQUENCE",
3022
+ "CHOOSECOLS",
3023
+ "CHOOSEROWS",
3024
+ "DROP",
3025
+ "EXPAND",
3026
+ "FILTER",
3027
+ "FORMULATEXT",
3028
+ "HSTACK",
3029
+ "SORT",
3030
+ "SORTBY",
3031
+ "TAKE",
3032
+ "TOCOL",
3033
+ "TOROW",
3034
+ "UNIQUE",
3035
+ "VSTACK",
3036
+ "WRAPCOLS",
3037
+ "WRAPROWS",
3038
+ "XLOOKUP",
3039
+ "XMATCH",
3040
+ "BITAND",
3041
+ "BITLSHIFT",
3042
+ "BITOR",
3043
+ "BITRSHIFT",
3044
+ "BITXOR",
3045
+ "ERF.PRECISE",
3046
+ "ERFC.PRECISE",
3047
+ "IMCOSH",
3048
+ "IMCOT",
3049
+ "IMCSC",
3050
+ "IMCSCH",
3051
+ "IMSEC",
3052
+ "IMSECH",
3053
+ "IMSINH",
3054
+ "IMTAN",
3055
+ "ISFORMULA",
3056
+ "SHEET",
3057
+ "SHEETS",
3058
+ "IFNA",
3059
+ "IFS",
3060
+ "SWITCH",
3061
+ "XOR",
3062
+ "BETA.DIST",
3063
+ "BETA.INV",
3064
+ "BINOM.DIST",
3065
+ "BINOM.DIST.RANGE",
3066
+ "BINOM.INV",
3067
+ "CHISQ.DIST",
3068
+ "CHISQ.DIST.RT",
3069
+ "CHISQ.INV",
3070
+ "CHISQ.INV.RT",
3071
+ "CHISQ.TEST",
3072
+ "CONFIDENCE.NORM",
3073
+ "CONFIDENCE.T",
3074
+ "COVARIANCE.P",
3075
+ "COVARIANCE.S",
3076
+ "EXPON.DIST",
3077
+ "F.DIST",
3078
+ "F.DIST.RT",
3079
+ "F.INV",
3080
+ "F.INV.RT",
3081
+ "F.TEST",
3082
+ "FORECAST.LINEAR",
3083
+ "GAMMA",
3084
+ "GAMMA.DIST",
3085
+ "GAMMA.INV",
3086
+ "GAMMALN.PRECISE",
3087
+ "GAUSS",
3088
+ "HYPGEOM.DIST",
3089
+ "LOGNORM.DIST",
3090
+ "LOGNORM.INV",
3091
+ "MAXIFS",
3092
+ "MINIFS",
3093
+ "MODE.MULT",
3094
+ "MODE.SNGL",
3095
+ "NEGBINOM.DIST",
3096
+ "NORM.DIST",
3097
+ "NORM.INV",
3098
+ "NORM.S.DIST",
3099
+ "NORM.S.INV",
3100
+ "PERCENTILE.EXC",
3101
+ "PERCENTILE.INC",
3102
+ "PERCENTRANK.EXC",
3103
+ "PERCENTRANK.INC",
3104
+ "PERMUTATIONA",
3105
+ "PHI",
3106
+ "POISSON.DIST",
3107
+ "QUARTILE.EXC",
3108
+ "QUARTILE.INC",
3109
+ "RANK.AVG",
3110
+ "RANK.EQ",
3111
+ "SKEW.P",
3112
+ "STDEV.P",
3113
+ "STDEV.S",
3114
+ "T.DIST",
3115
+ "T.DIST.2T",
3116
+ "T.DIST.RT",
3117
+ "T.INV",
3118
+ "T.INV.2T",
3119
+ "T.TEST",
3120
+ "VAR.P",
3121
+ "VAR.S",
3122
+ "WEIBULL.DIST",
3123
+ "Z.TEST",
3124
+ "ARRAYTOTEXT",
3125
+ "ENCODEURL",
3126
+ "NUMBERVALUE",
3127
+ "TEXTAFTER",
3128
+ "TEXTBEFORE",
3129
+ "TEXTJOIN",
3130
+ "TEXTSPLIT",
3131
+ "UNICHAR",
3132
+ "UNICODE",
3133
+ "VALUETOTEXT",
3134
+ "DAYS",
3135
+ "ISOWEEKNUM",
3136
+ "PDURATION",
3137
+ "RRI",
3138
+ "BYCOL",
3139
+ "BYROW",
3140
+ "MAKEARRAY",
3141
+ "MAP",
3142
+ "REDUCE",
3143
+ "SCAN"
3144
+ ]);
3145
+
3146
+ //#endregion
3147
+ //#region src/engine/utils/reference-cache.ts
3148
+ const referenceToRangeCache = new FormulaAstLRU(1e5);
3149
+ function deserializeRangeWithSheetWithCache(refString) {
3150
+ const refCache = referenceToRangeCache.get(refString);
3151
+ if (refCache) return refCache;
3152
+ const result = deserializeRangeWithSheet(refString);
3153
+ referenceToRangeCache.set(refString, result);
3154
+ return deserializeRangeWithSheet(refString);
3155
+ }
3156
+ function clearReferenceToRangeCache() {
3157
+ referenceToRangeCache.clear();
3158
+ }
3159
+
3160
+ //#endregion
3161
+ //#region src/engine/utils/sequence.ts
3162
+ let sequenceNodeType = /* @__PURE__ */ function(sequenceNodeType) {
3163
+ sequenceNodeType[sequenceNodeType["NORMAL"] = 0] = "NORMAL";
3164
+ sequenceNodeType[sequenceNodeType["NUMBER"] = 1] = "NUMBER";
3165
+ sequenceNodeType[sequenceNodeType["STRING"] = 2] = "STRING";
3166
+ sequenceNodeType[sequenceNodeType["FUNCTION"] = 3] = "FUNCTION";
3167
+ sequenceNodeType[sequenceNodeType["REFERENCE"] = 4] = "REFERENCE";
3168
+ sequenceNodeType[sequenceNodeType["ARRAY"] = 5] = "ARRAY";
3169
+ sequenceNodeType[sequenceNodeType["DEFINED_NAME"] = 6] = "DEFINED_NAME";
3170
+ sequenceNodeType[sequenceNodeType["TABLE"] = 7] = "TABLE";
3171
+ return sequenceNodeType;
3172
+ }({});
3173
+ /**
3174
+ * Deserialize Sequence to text.
3175
+ * @param newSequenceNodes
3176
+ * @returns
3177
+ */
3178
+ function generateStringWithSequence(newSequenceNodes) {
3179
+ let sequenceString = "";
3180
+ for (const node of newSequenceNodes) if (typeof node === "string") sequenceString += node;
3181
+ else sequenceString += node.token;
3182
+ return sequenceString;
3183
+ }
3184
+
3185
+ //#endregion
3186
+ //#region src/engine/analysis/lexer-node.ts
3187
+ var LexerNode = class LexerNode {
3188
+ constructor() {
3189
+ _defineProperty(this, "_parent", void 0);
3190
+ _defineProperty(this, "_token", "R_1");
3191
+ _defineProperty(this, "_children", []);
3192
+ _defineProperty(this, "_lambdaId", void 0);
3193
+ _defineProperty(this, "_functionDefinitionPrivacyVar", void 0);
3194
+ _defineProperty(this, "_lambdaParameter", "");
3195
+ _defineProperty(this, "_startIndex", -1);
3196
+ _defineProperty(this, "_endIndex", -1);
3197
+ _defineProperty(this, "_definedNames", []);
3198
+ }
3199
+ dispose() {
3200
+ var _this$_functionDefini;
3201
+ this._children.forEach((node) => {
3202
+ if (!(typeof node === "string")) node.dispose();
3203
+ });
3204
+ (_this$_functionDefini = this._functionDefinitionPrivacyVar) === null || _this$_functionDefini === void 0 || _this$_functionDefini.clear();
3205
+ this._functionDefinitionPrivacyVar = null;
3206
+ this._children = [];
3207
+ this._parent = null;
3208
+ this._definedNames = [];
3209
+ }
3210
+ getDefinedNames() {
3211
+ return this._definedNames;
3212
+ }
3213
+ getStartIndex() {
3214
+ return this._startIndex;
3215
+ }
3216
+ getLambdaId() {
3217
+ return this._lambdaId;
3218
+ }
3219
+ setLambdaId(lambdaId) {
3220
+ this._lambdaId = lambdaId;
3221
+ }
3222
+ getFunctionDefinitionPrivacyVar() {
3223
+ return this._functionDefinitionPrivacyVar;
3224
+ }
3225
+ setLambdaPrivacyVar(lambdaPrivacyVar) {
3226
+ this._functionDefinitionPrivacyVar = lambdaPrivacyVar;
3227
+ }
3228
+ getLambdaParameter() {
3229
+ return this._lambdaParameter;
3230
+ }
3231
+ setLambdaParameter(lambdaParameter) {
3232
+ this._lambdaParameter = lambdaParameter;
3233
+ }
3234
+ getParent() {
3235
+ return this._parent;
3236
+ }
3237
+ setParent(lexerNode) {
3238
+ this._parent = lexerNode;
3239
+ }
3240
+ getChildren() {
3241
+ return this._children;
3242
+ }
3243
+ setChildren(children) {
3244
+ this._children = children;
3245
+ }
3246
+ addChildren(children) {
3247
+ this._children.push(children);
3248
+ }
3249
+ addChildrenFirst(children) {
3250
+ this._children.unshift(children);
3251
+ }
3252
+ getToken() {
3253
+ return this._token;
3254
+ }
3255
+ setToken(token) {
3256
+ this._token = token;
3257
+ }
3258
+ setIndex(st, ed) {
3259
+ this._startIndex = st;
3260
+ this._endIndex = ed;
3261
+ }
3262
+ setDefinedNames(definedNames) {
3263
+ this._definedNames = definedNames;
3264
+ }
3265
+ hasDefinedNames() {
3266
+ return this._definedNames.length > 0;
3267
+ }
3268
+ replaceChild(lexerNode, newLexerNode) {
3269
+ const i = this._getIndexInParent(lexerNode);
3270
+ if (i == null) return;
3271
+ this.getChildren().splice(i, 1, newLexerNode);
3272
+ newLexerNode.setParent(this);
3273
+ }
3274
+ changeToParent(newParentLexerNode) {
3275
+ const parentNode = this.getParent();
3276
+ if (parentNode) parentNode.removeChild(this);
3277
+ this.setParent(newParentLexerNode);
3278
+ newParentLexerNode.getChildren().push(this);
3279
+ }
3280
+ removeChild(lexerNode) {
3281
+ const i = this._getIndexInParent(lexerNode);
3282
+ if (i == null) return;
3283
+ this.getChildren().splice(i, 1);
3284
+ }
3285
+ serialize() {
3286
+ const token = this.getToken();
3287
+ const children = this.getChildren();
3288
+ const childrenSerialization = [];
3289
+ const childrenCount = children.length;
3290
+ for (let i = 0; i < childrenCount; i++) {
3291
+ const item = children[i];
3292
+ if (item instanceof LexerNode) childrenSerialization.push(item.serialize());
3293
+ else childrenSerialization.push(item);
2292
3294
  }
2293
3295
  return {
2294
3296
  token,
@@ -2325,6 +3327,19 @@ var LexerTreeBuilder = class extends Disposable {
2325
3327
  _defineProperty(this, "_colonState", false);
2326
3328
  _defineProperty(this, "_formulaErrorCount", 0);
2327
3329
  _defineProperty(this, "_tableBracketState", false);
3330
+ _defineProperty(this, "_hasNewExcelFunction", false);
3331
+ _defineProperty(this, "_lambdaFunctionParameterSet", /* @__PURE__ */ new Set());
3332
+ _defineProperty(this, "_xlpmPrefix", "_xlpm.");
3333
+ _defineProperty(this, "_xlfnPrefix", "_xlfn.");
3334
+ _defineProperty(this, "_currentUnitId", "");
3335
+ }
3336
+ _resetPrefix() {
3337
+ this._xlpmPrefix = "_xlpm.";
3338
+ this._xlfnPrefix = "_xlfn.";
3339
+ }
3340
+ _clearPrefix() {
3341
+ this._xlpmPrefix = "";
3342
+ this._xlfnPrefix = "";
2328
3343
  }
2329
3344
  dispose() {
2330
3345
  this._resetTemp();
@@ -3449,11 +4464,289 @@ var LexerTreeBuilder = class extends Disposable {
3449
4464
  });
3450
4465
  }
3451
4466
  getNewFormulaWithPrefix(formulaString, hasFunction) {
4467
+ const lexerNode = this.treeBuilder(formulaString, false);
4468
+ if (!lexerNode || lexerNode === "#VALUE!" || Array.isArray(lexerNode)) return null;
4469
+ const formulaStrings = [];
4470
+ this._hasNewExcelFunction = false;
4471
+ this._generateNewFunctionString(lexerNode, formulaStrings, hasFunction);
4472
+ if (this._hasNewExcelFunction) return `=${formulaStrings.join("")}`;
3452
4473
  return null;
3453
4474
  }
4475
+ _generateNewFunctionString(lexerNode, formulaStrings, hasFunction) {
4476
+ const token = lexerNode.getToken();
4477
+ const tokenTrim = token.trim();
4478
+ const tokenTrimUpper = tokenTrim.toUpperCase();
4479
+ const tokenForFunction = this._clearFunctionString(tokenTrimUpper);
4480
+ const isFunctionNode = hasFunction(tokenForFunction);
4481
+ let curNodeType = 0;
4482
+ if (token === "R_1") curNodeType = 3;
4483
+ else if (token === "P_1") curNodeType = 4;
4484
+ else if (token === "L_1") curNodeType = 5;
4485
+ else if (NEW_EXCEL_FUNCTIONS.has(tokenForFunction)) {
4486
+ formulaStrings.push(`${this._xlfnPrefix}${tokenTrim}`);
4487
+ this._hasNewExcelFunction = true;
4488
+ } else if (tokenTrimUpper === "LAMBDA") {
4489
+ formulaStrings.push(`${this._xlfnPrefix}${tokenTrim}`);
4490
+ this._hasNewExcelFunction = true;
4491
+ curNodeType = 2;
4492
+ } else if (tokenTrimUpper === "LET") {
4493
+ formulaStrings.push(`${this._xlfnPrefix}${tokenTrim}`);
4494
+ this._hasNewExcelFunction = true;
4495
+ curNodeType = 1;
4496
+ } else if (tokenTrimUpper === ":") curNodeType = 8;
4497
+ else if (SUFFIX_TOKEN_SET.has(tokenTrimUpper)) curNodeType = 7;
4498
+ else if (tokenTrimUpper === "-") {
4499
+ if (this._checkAddBracketForMinus(lexerNode)) curNodeType = 9;
4500
+ formulaStrings.push(token);
4501
+ } else {
4502
+ formulaStrings.push(token);
4503
+ curNodeType = 10;
4504
+ }
4505
+ if (isFunctionNode) {
4506
+ if (curNodeType !== 2 && curNodeType !== 1) curNodeType = 6;
4507
+ formulaStrings.push("(");
4508
+ } else if (curNodeType === 9) formulaStrings.push("(");
4509
+ const children = lexerNode.getChildren();
4510
+ const childrenCount = children.length;
4511
+ if (curNodeType === 2) {
4512
+ const firstChild = children[0];
4513
+ let firstIsInputIndex = 0;
4514
+ if (firstChild instanceof LexerNode) {
4515
+ if (firstChild.getToken() === "L_1") firstIsInputIndex = 1;
4516
+ }
4517
+ for (let i = firstIsInputIndex; i < childrenCount - 1; i++) {
4518
+ const item = children[i];
4519
+ if (item instanceof LexerNode) {
4520
+ const varName = item.getChildren()[0];
4521
+ if (typeof varName === "string") {
4522
+ if (this._lambdaFunctionParameterSet.has(varName)) console.error(`Lambda parameter name "${varName}" is duplicated.`);
4523
+ this._lambdaFunctionParameterSet.add(varName);
4524
+ formulaStrings.push(`${this._xlpmPrefix}${varName}`);
4525
+ this._hasNewExcelFunction = true;
4526
+ }
4527
+ }
4528
+ formulaStrings.push(",");
4529
+ }
4530
+ this._handleNewFunctionChild(children[childrenCount - 1], formulaStrings, hasFunction);
4531
+ if (firstIsInputIndex === 1) {
4532
+ formulaStrings.push(")");
4533
+ formulaStrings.push("(");
4534
+ this._generateNewFunctionString(firstChild, formulaStrings, hasFunction);
4535
+ formulaStrings.push(")");
4536
+ } else formulaStrings.push(")");
4537
+ return;
4538
+ } else if (curNodeType === 1) {
4539
+ for (let i = 0; i < childrenCount - 1; i++) {
4540
+ const item = children[i];
4541
+ if (item instanceof LexerNode && i % 2 === 0) {
4542
+ const varName = item.getChildren()[0];
4543
+ if (typeof varName === "string") {
4544
+ if (this._lambdaFunctionParameterSet.has(varName)) console.error(`Let variable name "${varName}" is duplicated.`);
4545
+ this._lambdaFunctionParameterSet.add(varName);
4546
+ formulaStrings.push(`${this._xlpmPrefix}${varName}`);
4547
+ this._hasNewExcelFunction = true;
4548
+ formulaStrings.push(",");
4549
+ continue;
4550
+ }
4551
+ }
4552
+ this._handleNewFunctionChild(item, formulaStrings, hasFunction);
4553
+ if (item instanceof LexerNode) {
4554
+ const nextItem = children[i + 1];
4555
+ if (nextItem && nextItem instanceof LexerNode) formulaStrings.push(",");
4556
+ }
4557
+ }
4558
+ this._handleNewFunctionChild(children[childrenCount - 1], formulaStrings, hasFunction);
4559
+ formulaStrings.push(")");
4560
+ return;
4561
+ } else if (curNodeType === 8) {
4562
+ const firstNode = children[0];
4563
+ const secondNode = children[1];
4564
+ this._handleNewFunctionChild(firstNode, formulaStrings, hasFunction);
4565
+ formulaStrings.push(token);
4566
+ this._handleNewFunctionChild(secondNode, formulaStrings, hasFunction);
4567
+ return;
4568
+ }
4569
+ for (let i = 0; i < childrenCount; i++) {
4570
+ const item = children[i];
4571
+ this._handleNewFunctionChild(item, formulaStrings, hasFunction);
4572
+ if (item instanceof LexerNode) {
4573
+ const nextItem = children[i + 1];
4574
+ if (nextItem && nextItem instanceof LexerNode) formulaStrings.push(",");
4575
+ }
4576
+ }
4577
+ if (curNodeType === 7) formulaStrings.push(token);
4578
+ if (isFunctionNode) formulaStrings.push(")");
4579
+ else if (curNodeType === 9) formulaStrings.push(")");
4580
+ }
4581
+ _handleNewFunctionChild(item, formulaStrings, hasFunction) {
4582
+ if (item instanceof LexerNode) this._generateNewFunctionString(item, formulaStrings, hasFunction);
4583
+ else if (this._lambdaFunctionParameterSet.has(item)) {
4584
+ formulaStrings.push(`${this._xlpmPrefix}${item}`);
4585
+ this._hasNewExcelFunction = true;
4586
+ } else formulaStrings.push(item);
4587
+ }
4588
+ _clearFunctionString(token) {
4589
+ let t = token.trim();
4590
+ if (!t) return t;
4591
+ const firstChar = t[0];
4592
+ if (firstChar === "@" || firstChar === "-" || firstChar === "+") t = t.slice(1);
4593
+ if (!t) return t;
4594
+ const lastChar = t[t.length - 1];
4595
+ if (SUFFIX_TOKEN_SET.has(lastChar)) t = t.slice(0, -1);
4596
+ return t;
4597
+ }
4598
+ _checkAddBracketForMinus(node) {
4599
+ const childrenFirst = node.getChildren()[0];
4600
+ if (!childrenFirst || !(childrenFirst instanceof LexerNode) || node.getChildren().length > 1) return false;
4601
+ const children = childrenFirst.getChildren();
4602
+ const childrenCount = children.length;
4603
+ if (childrenCount === 1) return false;
4604
+ for (let i = 0; i < childrenCount; i++) {
4605
+ const item = children[i];
4606
+ if (!(item instanceof LexerNode) && OPERATOR_TOKEN_SET.has(item)) return true;
4607
+ }
4608
+ return false;
4609
+ }
3454
4610
  getFormulaExprTree(formulaString, unitId, hasFunction, getDefinedNameName, getTable) {
4611
+ const lexerNode = this.treeBuilder(formulaString, false);
4612
+ if (!lexerNode || lexerNode === "#VALUE!" || Array.isArray(lexerNode)) return null;
4613
+ this._clearPrefix();
4614
+ this._currentUnitId = unitId;
4615
+ const newNode = this._generateExprTree(lexerNode, hasFunction, getDefinedNameName, getTable);
4616
+ this._currentUnitId = "";
4617
+ this._resetPrefix();
4618
+ return newNode;
4619
+ }
4620
+ _generateExprTree(lexerNodeRoot, hasFunction, getDefinedNameName, getTable) {
4621
+ const newNode = {
4622
+ value: "",
4623
+ children: [],
4624
+ startIndex: 0
4625
+ };
4626
+ let lexerNode = lexerNodeRoot;
4627
+ if (lexerNode instanceof LexerNode && (lexerNode.getToken() === "R_1" || lexerNode.getToken() === "P_1") && lexerNode.getChildren().length === 1) lexerNode = lexerNode.getChildren()[0];
4628
+ if (!(lexerNode instanceof LexerNode)) return this._handleTextNodeForExprTree(lexerNode, getDefinedNameName, getTable);
4629
+ const children = lexerNode.getChildren();
4630
+ const childrenCount = children.length;
4631
+ const formulaStrings = [];
4632
+ this._generateNewFunctionString(lexerNode, formulaStrings, hasFunction);
4633
+ newNode.value = formulaStrings.join("");
4634
+ newNode.startIndex = lexerNode.getStartIndex();
4635
+ const curNodeType = this._getCurNodeTypeForExprTree(lexerNode);
4636
+ if (curNodeType === 2) {
4637
+ const firstChild = children[0];
4638
+ if (firstChild instanceof LexerNode) {
4639
+ if (firstChild.getToken().trim() !== "L_1") return newNode;
4640
+ this._handleLambdaForExprTree(firstChild, newNode, hasFunction, getDefinedNameName, getTable);
4641
+ }
4642
+ return newNode;
4643
+ } else if (curNodeType === 1) {
4644
+ for (let i = 0; i < childrenCount - 1; i++) {
4645
+ const item = children[i];
4646
+ if (item instanceof LexerNode && i % 2 === 1) {
4647
+ const itemChildren = item.getChildren();
4648
+ if (itemChildren.length === 1 && !(itemChildren[0] instanceof LexerNode)) continue;
4649
+ const childNode = this._generateExprTree(item, hasFunction, getDefinedNameName, getTable);
4650
+ childNode && newNode.children.push(childNode);
4651
+ }
4652
+ }
4653
+ return newNode;
4654
+ } else if (curNodeType === 8) {
4655
+ const firstNode = children[0];
4656
+ if (firstNode instanceof LexerNode) {
4657
+ const firstChildNode = firstNode.getChildren()[0];
4658
+ if (firstChildNode instanceof LexerNode) newNode.startIndex = firstChildNode.getStartIndex();
4659
+ }
4660
+ if (this._checkColonNodeForExprTree(lexerNode)) return newNode;
4661
+ } else if (curNodeType === 7) {
4662
+ const firstNode = children[0];
4663
+ if (firstNode instanceof LexerNode) {
4664
+ const firstChildNode = firstNode.getChildren()[0];
4665
+ if (firstChildNode instanceof LexerNode) newNode.startIndex = firstChildNode.getStartIndex();
4666
+ }
4667
+ }
4668
+ this._handleChildrenForExprTree(children, curNodeType, newNode, hasFunction, getDefinedNameName, getTable);
4669
+ return newNode;
4670
+ }
4671
+ _handleChildrenForExprTree(children, curNodeType, newNode, hasFunction, getDefinedNameName, getTable) {
4672
+ for (let i = 0; i < children.length; i++) {
4673
+ let item = children[i];
4674
+ if (!(item instanceof LexerNode)) {
4675
+ const childNode = this._handleTextNodeForExprTree(item, getDefinedNameName, getTable);
4676
+ childNode && newNode.children.push(childNode);
4677
+ continue;
4678
+ }
4679
+ const itemChildren = item.getChildren();
4680
+ if (itemChildren.length === 1 && !(itemChildren[0] instanceof LexerNode)) {
4681
+ const itemChild = itemChildren[0];
4682
+ if (!getDefinedNameName(this._currentUnitId, itemChild) && !this._getTableNameFromStructuredRef(itemChild, getTable) && !isReferenceString(itemChild)) continue;
4683
+ }
4684
+ if (curNodeType === 8) {
4685
+ const refNode = itemChildren[0];
4686
+ if (refNode instanceof LexerNode) {
4687
+ if (isReferenceString(refNode.getToken().trim())) continue;
4688
+ item = refNode;
4689
+ }
4690
+ }
4691
+ const childNode = this._generateExprTree(item, hasFunction, getDefinedNameName, getTable);
4692
+ childNode && newNode.children.push(childNode);
4693
+ }
4694
+ }
4695
+ _checkColonNodeForExprTree(item) {
4696
+ const itemChildren = item.getChildren();
4697
+ if (itemChildren.length < 2) return false;
4698
+ const firstChild = itemChildren[0];
4699
+ const secondChild = itemChildren[1];
4700
+ if (!(firstChild instanceof LexerNode) || !(secondChild instanceof LexerNode)) return false;
4701
+ const firstGrandChild = firstChild.getChildren()[0];
4702
+ const secondGrandChild = secondChild.getChildren()[0];
4703
+ if (!(firstGrandChild instanceof LexerNode) || !(secondGrandChild instanceof LexerNode)) return false;
4704
+ const firstChildToken = firstGrandChild.getToken().trim();
4705
+ const secondChildToken = secondGrandChild.getToken().trim();
4706
+ if (isReferenceString(`${firstChildToken}${":"}${secondChildToken}`)) return true;
4707
+ return false;
4708
+ }
4709
+ _handleTextNodeForExprTree(item, getDefinedNameName, getTable) {
4710
+ const itemTrim = item.trim();
4711
+ if (itemTrim.startsWith("{") && itemTrim.endsWith("}") || getDefinedNameName(this._currentUnitId, itemTrim) || this._getTableNameFromStructuredRef(itemTrim, getTable) || isReferenceString(itemTrim)) return {
4712
+ value: itemTrim,
4713
+ children: [],
4714
+ startIndex: -1
4715
+ };
3455
4716
  return null;
3456
4717
  }
4718
+ _getTableNameFromStructuredRef(token, getTable) {
4719
+ const { tableName } = splitTableStructuredRef(token);
4720
+ if (getTable(this._currentUnitId, tableName)) return tableName;
4721
+ return null;
4722
+ }
4723
+ _handleLambdaForExprTree(firstChild, newNode, hasFunction, getDefinedNameName, getTable) {
4724
+ const firstGrandchildren = firstChild.getChildren();
4725
+ for (let i = 0; i < firstGrandchildren.length; i++) {
4726
+ const item = firstGrandchildren[i];
4727
+ if (!(item instanceof LexerNode)) continue;
4728
+ const itemChildren = item.getChildren();
4729
+ if (itemChildren.length === 1 && !(itemChildren[0] instanceof LexerNode)) continue;
4730
+ const childNode = this._generateExprTree(item, hasFunction, getDefinedNameName, getTable);
4731
+ childNode && newNode.children.push(childNode);
4732
+ }
4733
+ }
4734
+ _getCurNodeTypeForExprTree(lexerNode) {
4735
+ const token = lexerNode.getToken();
4736
+ const tokenTrimUpper = token.trim().toUpperCase();
4737
+ let curNodeType = 0;
4738
+ if (token === "R_1") curNodeType = 3;
4739
+ else if (token === "P_1") curNodeType = 4;
4740
+ else if (token === "L_1") curNodeType = 5;
4741
+ else if (tokenTrimUpper === "LAMBDA") curNodeType = 2;
4742
+ else if (tokenTrimUpper === "LET") curNodeType = 1;
4743
+ else if (tokenTrimUpper === ":") curNodeType = 8;
4744
+ else if (SUFFIX_TOKEN_SET.has(tokenTrimUpper)) curNodeType = 7;
4745
+ else if (tokenTrimUpper === "-") {
4746
+ if (this._checkAddBracketForMinus(lexerNode)) curNodeType = 9;
4747
+ } else curNodeType = 10;
4748
+ return curNodeType;
4749
+ }
3457
4750
  };
3458
4751
 
3459
4752
  //#endregion
@@ -3509,13 +4802,24 @@ function updateFormulaDataByCellValue(sheetFormulaDataMatrix, newSheetFormulaDat
3509
4802
  }
3510
4803
  function clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix, arrayFormulaCellDataMatrix, r, c) {
3511
4804
  const arrayFormulaRangeValue = arrayFormulaRangeMatrix === null || arrayFormulaRangeMatrix === void 0 ? void 0 : arrayFormulaRangeMatrix.getValue(r, c);
3512
- if (arrayFormulaRangeValue == null) return true;
4805
+ if (arrayFormulaRangeValue == null) {
4806
+ let changed = false;
4807
+ arrayFormulaRangeMatrix.forValue((_, __, range) => {
4808
+ if (Rectangle.contains(range, cellToRange(r, c))) {
4809
+ arrayFormulaCellDataMatrix.realDeleteValue(r, c);
4810
+ changed = true;
4811
+ return false;
4812
+ }
4813
+ });
4814
+ return changed;
4815
+ }
4816
+ const targetArrayFormulaRange = arrayFormulaRangeValue;
3513
4817
  const intersection = [];
3514
4818
  arrayFormulaRangeMatrix.forValue((rangeRow, rangeCol, range) => {
3515
4819
  if (rangeRow === r && rangeCol === c) return;
3516
- if (Rectangle.intersects(range, arrayFormulaRangeValue)) intersection.push(range);
4820
+ if (Rectangle.intersects(range, targetArrayFormulaRange)) intersection.push(range);
3517
4821
  });
3518
- const { startRow, startColumn, endRow, endColumn } = arrayFormulaRangeValue;
4822
+ const { startRow, startColumn, endRow, endColumn } = targetArrayFormulaRange;
3519
4823
  for (let row = startRow; row <= endRow; row++) for (let col = startColumn; col <= endColumn; col++) {
3520
4824
  let isOverlapping = false;
3521
4825
  const currentCell = cellToRange(row, col);
@@ -3528,6 +4832,7 @@ function clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix, arrayFormulaCe
3528
4832
  });
3529
4833
  if (!isOverlapping) arrayFormulaCellDataMatrix.realDeleteValue(row, col);
3530
4834
  }
4835
+ return true;
3531
4836
  }
3532
4837
 
3533
4838
  //#endregion
@@ -3566,7 +4871,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
3566
4871
  const range = rangeMatrix.getValue(row, column);
3567
4872
  if (range == null) return true;
3568
4873
  const { startRow, startColumn, endRow, endColumn } = range;
3569
- for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) arrayFormulaCellMatrixData.setValue(r, c, null);
4874
+ for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) arrayFormulaCellMatrixData.realDeleteValue(r, c);
3570
4875
  rangeMatrix.realDeleteValue(row, column);
3571
4876
  });
3572
4877
  if (this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId][sheetId] = arrayFormulaCellMatrixData.getData();
@@ -3591,10 +4896,11 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
3591
4896
  const arrayFormulaRange = arrayFormulaRangeMatrix === null || arrayFormulaRangeMatrix === void 0 ? void 0 : arrayFormulaRangeMatrix.getValue(row, column);
3592
4897
  if (arrayFormulaRange == null) return true;
3593
4898
  const { startRow, startColumn, endRow, endColumn } = arrayFormulaRange;
3594
- for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) arrayFormulaCellMatrixData.setValue(r, c, null);
4899
+ for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) arrayFormulaCellMatrixData.realDeleteValue(r, c);
3595
4900
  });
3596
4901
  cellMatrixData.forValue((row, column, cellData) => {
3597
- arrayFormulaCellMatrixData.setValue(row, column, cellData);
4902
+ if (cellData == null) arrayFormulaCellMatrixData.realDeleteValue(row, column);
4903
+ else arrayFormulaCellMatrixData.setValue(row, column, cellData);
3598
4904
  });
3599
4905
  if (this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId][sheetId] = arrayFormulaCellMatrixData.getData();
3600
4906
  });
@@ -3820,23 +5126,34 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
3820
5126
  updateArrayFormulaRange(unitId, sheetId, cellValue) {
3821
5127
  var _this$_arrayFormulaRa5;
3822
5128
  const arrayFormulaRange = (_this$_arrayFormulaRa5 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa5 === void 0 ? void 0 : _this$_arrayFormulaRa5[sheetId];
3823
- if (!arrayFormulaRange) return;
5129
+ if (!arrayFormulaRange) return false;
3824
5130
  const arrayFormulaRangeMatrix = new ObjectMatrix(arrayFormulaRange);
3825
- new ObjectMatrix(cellValue).forValue((r, c, cell) => {
3826
- arrayFormulaRangeMatrix.realDeleteValue(r, c);
5131
+ const cellMatrix = new ObjectMatrix(cellValue);
5132
+ let changed = false;
5133
+ cellMatrix.forValue((r, c) => {
5134
+ if (arrayFormulaRangeMatrix.getValue(r, c) != null) {
5135
+ arrayFormulaRangeMatrix.realDeleteValue(r, c);
5136
+ changed = true;
5137
+ }
3827
5138
  });
5139
+ if (changed && this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId][sheetId] = arrayFormulaRangeMatrix.getData();
5140
+ return changed;
3828
5141
  }
3829
5142
  updateArrayFormulaCellData(unitId, sheetId, cellValue) {
3830
5143
  var _this$_arrayFormulaRa6, _this$_arrayFormulaCe4;
3831
5144
  const arrayFormulaRange = (_this$_arrayFormulaRa6 = this._arrayFormulaRange[unitId]) === null || _this$_arrayFormulaRa6 === void 0 ? void 0 : _this$_arrayFormulaRa6[sheetId];
3832
- if (!arrayFormulaRange) return;
5145
+ if (!arrayFormulaRange) return false;
3833
5146
  const arrayFormulaRangeMatrix = new ObjectMatrix(arrayFormulaRange);
3834
5147
  const arrayFormulaCellData = (_this$_arrayFormulaCe4 = this._arrayFormulaCellData[unitId]) === null || _this$_arrayFormulaCe4 === void 0 ? void 0 : _this$_arrayFormulaCe4[sheetId];
3835
- if (!arrayFormulaCellData) return;
5148
+ if (!arrayFormulaCellData) return false;
3836
5149
  const arrayFormulaCellDataMatrix = new ObjectMatrix(arrayFormulaCellData);
3837
- new ObjectMatrix(cellValue).forValue((r, c, cell) => {
3838
- clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix, arrayFormulaCellDataMatrix, r, c);
5150
+ const cellMatrix = new ObjectMatrix(cellValue);
5151
+ let changed = false;
5152
+ cellMatrix.forValue((r, c) => {
5153
+ changed = clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix, arrayFormulaCellDataMatrix, r, c) || changed;
3839
5154
  });
5155
+ if (changed && this._arrayFormulaCellData[unitId]) this._arrayFormulaCellData[unitId][sheetId] = arrayFormulaCellDataMatrix.getData();
5156
+ return changed;
3840
5157
  }
3841
5158
  updateImageFormulaData(unitId, sheetId, cellValue) {
3842
5159
  var _this$_unitImageFormu;
@@ -3894,7 +5211,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
3894
5211
  const column = Number(columnStr);
3895
5212
  const currentCell = sheetInstance.getCellRaw(row, column);
3896
5213
  const isFormula = isFormulaString(currentCell === null || currentCell === void 0 ? void 0 : currentCell.f) || isFormulaId(currentCell === null || currentCell === void 0 ? void 0 : currentCell.si);
3897
- const noValue = (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === void 0 || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === null || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === "";
5214
+ const noValue = (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === void 0 || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === null || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === "" || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === 0 || (currentCell === null || currentCell === void 0 ? void 0 : currentCell.v) === "0";
3898
5215
  if (!(isFormula && noValue)) continue;
3899
5216
  if (!columnRanges[column]) columnRanges[column] = [];
3900
5217
  const lastRange = columnRanges[column].slice(-1)[0];
@@ -3993,181 +5310,6 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
3993
5310
  return { [unitId]: { [sheetId]: newSheetFormulaData } };
3994
5311
  }
3995
5312
 
3996
- //#endregion
3997
- //#region src/basics/inverted-index-cache.ts
3998
- const DEFAULT_EMPTY_CELL_KEY = Symbol("EMPTY_CELL");
3999
- const normalizedValueMap = /* @__PURE__ */ new Map();
4000
- function normalizeValue(value) {
4001
- if (normalizedValueMap.has(value)) return normalizedValueMap.get(value);
4002
- let _value;
4003
- if (value === null || value === void 0 || value === "") _value = DEFAULT_EMPTY_CELL_KEY;
4004
- else if (isRealNum(value) && Number(value).toString() === value.toString()) _value = Number(value) === 0 ? 0 : Number(value);
4005
- else if (typeof value === "string") _value = value.toLowerCase();
4006
- else _value = value;
4007
- normalizedValueMap.set(value, _value);
4008
- return _value;
4009
- }
4010
- var InvertedIndexCache = class {
4011
- constructor() {
4012
- _defineProperty(this, "_cache", /* @__PURE__ */ new Map());
4013
- _defineProperty(this, "_continueBuildingCache", /* @__PURE__ */ new Map());
4014
- }
4015
- set(unitId, sheetId, column, value, row, isForceUpdate = false) {
4016
- if (!this.shouldContinueBuildingCache(unitId, sheetId, column, row) && !isForceUpdate) return;
4017
- let unitMap = this._cache.get(unitId);
4018
- if (unitMap == null) {
4019
- unitMap = /* @__PURE__ */ new Map();
4020
- this._cache.set(unitId, unitMap);
4021
- }
4022
- let sheetMap = unitMap.get(sheetId);
4023
- if (sheetMap == null) {
4024
- sheetMap = /* @__PURE__ */ new Map();
4025
- unitMap.set(sheetId, sheetMap);
4026
- }
4027
- let columnMap = sheetMap.get(column);
4028
- if (columnMap == null) {
4029
- columnMap = /* @__PURE__ */ new Map();
4030
- sheetMap.set(column, columnMap);
4031
- }
4032
- if (isForceUpdate) {
4033
- for (const [_, _cellList] of columnMap) if (_cellList.has(row)) {
4034
- _cellList.delete(row);
4035
- break;
4036
- }
4037
- }
4038
- const _value = normalizeValue(value);
4039
- let cellList = columnMap.get(_value);
4040
- if (cellList == null) {
4041
- cellList = /* @__PURE__ */ new Set();
4042
- columnMap.set(_value, cellList);
4043
- }
4044
- cellList.add(row);
4045
- }
4046
- getCellValuePositions(unitId, sheetId, column) {
4047
- var _this$_cache$get;
4048
- return (_this$_cache$get = this._cache.get(unitId)) === null || _this$_cache$get === void 0 || (_this$_cache$get = _this$_cache$get.get(sheetId)) === null || _this$_cache$get === void 0 ? void 0 : _this$_cache$get.get(column);
4049
- }
4050
- getCellPositions(unitId, sheetId, column, value, rowsInCache) {
4051
- var _this$_cache$get2;
4052
- const columnMap = (_this$_cache$get2 = this._cache.get(unitId)) === null || _this$_cache$get2 === void 0 || (_this$_cache$get2 = _this$_cache$get2.get(sheetId)) === null || _this$_cache$get2 === void 0 ? void 0 : _this$_cache$get2.get(column);
4053
- if (!columnMap) return;
4054
- const result = {
4055
- errorType: null,
4056
- matchingRows: []
4057
- };
4058
- const _value = normalizeValue(value);
4059
- if (ERROR_TYPE_SET.has(_value)) result.errorType = _value;
4060
- else if (_value === 0 || _value === DEFAULT_EMPTY_CELL_KEY) {
4061
- const rows = [];
4062
- const rowsForZero = columnMap.get(0);
4063
- if (rowsForZero) rows.push(...rowsForZero);
4064
- const rowsForEmpty = columnMap.get(DEFAULT_EMPTY_CELL_KEY);
4065
- if (rowsForEmpty) rows.push(...rowsForEmpty);
4066
- result.matchingRows = rows.filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
4067
- } else {
4068
- var _columnMap$get;
4069
- result.matchingRows = Array.from((_columnMap$get = columnMap.get(_value)) !== null && _columnMap$get !== void 0 ? _columnMap$get : []).filter((row) => rowsInCache.some(([start, end]) => row >= start && row <= end));
4070
- }
4071
- return result;
4072
- }
4073
- setContinueBuildingCache(unitId, sheetId, column, startRow, endRow) {
4074
- if (column === -1 || startRow === -1 || endRow === -1) return;
4075
- let unitMap = this._continueBuildingCache.get(unitId);
4076
- if (unitMap == null) {
4077
- unitMap = /* @__PURE__ */ new Map();
4078
- this._continueBuildingCache.set(unitId, unitMap);
4079
- }
4080
- let sheetMap = unitMap.get(sheetId);
4081
- if (sheetMap == null) {
4082
- sheetMap = /* @__PURE__ */ new Map();
4083
- unitMap.set(sheetId, sheetMap);
4084
- }
4085
- let columnMap = sheetMap.get(column);
4086
- if (columnMap == null) {
4087
- columnMap = new IntervalTree();
4088
- columnMap.insert([startRow, endRow]);
4089
- sheetMap.set(column, columnMap);
4090
- return;
4091
- }
4092
- this._handleNewInterval(columnMap, startRow, endRow);
4093
- }
4094
- shouldContinueBuildingCache(unitId, sheetId, column, row) {
4095
- var _this$_continueBuildi;
4096
- if (column === -1 || row === -1) return false;
4097
- const columnMap = (_this$_continueBuildi = this._continueBuildingCache.get(unitId)) === null || _this$_continueBuildi === void 0 || (_this$_continueBuildi = _this$_continueBuildi.get(sheetId)) === null || _this$_continueBuildi === void 0 ? void 0 : _this$_continueBuildi.get(column);
4098
- if (!columnMap) return true;
4099
- return columnMap.search([row, row]).length === 0;
4100
- }
4101
- canUseCache(unitId, sheetId, column, rangeStartRow, rangeEndRow) {
4102
- var _this$_continueBuildi2;
4103
- const columnMap = (_this$_continueBuildi2 = this._continueBuildingCache.get(unitId)) === null || _this$_continueBuildi2 === void 0 || (_this$_continueBuildi2 = _this$_continueBuildi2.get(sheetId)) === null || _this$_continueBuildi2 === void 0 ? void 0 : _this$_continueBuildi2.get(column);
4104
- if (column === -1 || rangeStartRow === -1 || rangeEndRow === -1 || !columnMap) return {
4105
- rowsInCache: [],
4106
- rowsNotInCache: []
4107
- };
4108
- const result = columnMap.search([rangeStartRow, rangeEndRow]);
4109
- if (result.length === 0) return {
4110
- rowsInCache: [],
4111
- rowsNotInCache: []
4112
- };
4113
- result.sort((a, b) => a[0] - b[0]);
4114
- const rowsInCache = [];
4115
- const rowsNotInCache = [];
4116
- let _rangeStartRow = rangeStartRow;
4117
- for (let i = 0; i < result.length; i++) {
4118
- const [start, end] = result[i];
4119
- if (_rangeStartRow >= start) {
4120
- if (rangeEndRow <= end) {
4121
- rowsInCache.push([_rangeStartRow, rangeEndRow]);
4122
- break;
4123
- }
4124
- rowsInCache.push([_rangeStartRow, end]);
4125
- _rangeStartRow = end + 1;
4126
- if (i === result.length - 1 && _rangeStartRow <= rangeEndRow) rowsNotInCache.push([_rangeStartRow, rangeEndRow]);
4127
- } else {
4128
- if (rangeEndRow > end) {
4129
- rowsInCache.push([start, end]);
4130
- rowsNotInCache.push([_rangeStartRow, start - 1]);
4131
- _rangeStartRow = end + 1;
4132
- if (i === result.length - 1 && _rangeStartRow <= rangeEndRow) rowsNotInCache.push([_rangeStartRow, rangeEndRow]);
4133
- continue;
4134
- }
4135
- rowsInCache.push([start, rangeEndRow]);
4136
- rowsNotInCache.push([_rangeStartRow, start - 1]);
4137
- }
4138
- }
4139
- return {
4140
- rowsInCache,
4141
- rowsNotInCache
4142
- };
4143
- }
4144
- clear() {
4145
- this._cache.clear();
4146
- this._continueBuildingCache.clear();
4147
- normalizedValueMap.clear();
4148
- }
4149
- _handleNewInterval(columnMap, startRow, endRow) {
4150
- let result = columnMap.search([startRow, endRow]);
4151
- if (result.length === 0) {
4152
- const adjacentRange = [startRow - 1 < 0 ? 0 : startRow - 1, endRow + 1];
4153
- result = columnMap.search(adjacentRange);
4154
- if (result.length === 0) {
4155
- columnMap.insert([startRow, endRow]);
4156
- return;
4157
- }
4158
- }
4159
- let min = startRow;
4160
- let max = endRow;
4161
- for (const interval of result) {
4162
- min = Math.min(min, interval[0]);
4163
- max = Math.max(max, interval[1]);
4164
- columnMap.remove(interval);
4165
- }
4166
- columnMap.insert([min, max]);
4167
- }
4168
- };
4169
- const CELL_INVERTED_INDEX_CACHE = new InvertedIndexCache();
4170
-
4171
5313
  //#endregion
4172
5314
  //#region src/services/sheet-row-filtered.service.ts
4173
5315
  /**
@@ -8356,7 +9498,10 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
8356
9498
  endColumn: endColumn - startColumn + column
8357
9499
  };
8358
9500
  arrayData.setValue(row, column, arrayRange);
8359
- if (this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange) || this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange)) {
9501
+ const hasDataInArrayFormulaRange = this._checkIfArrayFormulaRangeHasData(unitId, sheetId, row, column, arrayRange);
9502
+ const isArrayFormulaExceeded = this._checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange);
9503
+ if (hasDataInArrayFormulaRange || isArrayFormulaExceeded) {
9504
+ var _this$_currentConfigS;
8360
9505
  const errorObject = this._getValueObjectOfRuntimeData(ErrorValueObject.create("#SPILL!"));
8361
9506
  sheetData.setValue(row, column, errorObject);
8362
9507
  clearArrayUnitData.setValue(row, column, errorObject);
@@ -8366,17 +9511,21 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
8366
9511
  * In this case, you need to clear the previous range data to prevent other formulas from referencing the old values.
8367
9512
  */
8368
9513
  const unitData = this._currentConfigService.getUnitData();
9514
+ const arrayData = this._currentConfigService.getArrayFormulaCellData();
9515
+ const previousArrayFormulaRange = (_this$_currentConfigS = this._currentConfigService.getArrayFormulaRange()[unitId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[sheetId]) === null || _this$_currentConfigS === void 0 || (_this$_currentConfigS = _this$_currentConfigS[row]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS[column];
8369
9516
  objectValueRefOrArray.iterator((_, rowIndex, columnIndex) => {
8370
- var _unitData$unitId;
9517
+ var _unitData$unitId, _arrayData$unitId;
8371
9518
  const currentRow = rowIndex - startRow + row;
8372
9519
  const currentColumn = columnIndex - startColumn + column;
8373
9520
  const cell = (_unitData$unitId = unitData[unitId]) === null || _unitData$unitId === void 0 || (_unitData$unitId = _unitData$unitId[sheetId]) === null || _unitData$unitId === void 0 ? void 0 : _unitData$unitId.cellData.getValue(currentRow, currentColumn);
9521
+ const arrayDataCell = arrayData === null || arrayData === void 0 || (_arrayData$unitId = arrayData[unitId]) === null || _arrayData$unitId === void 0 || (_arrayData$unitId = _arrayData$unitId[sheetId]) === null || _arrayData$unitId === void 0 ? void 0 : _arrayData$unitId.getValue(currentRow, currentColumn);
9522
+ const shouldClearPreviousCellOfCurrentArrayFormula = this._arrayCellHasData(arrayDataCell) && this._isInArrayFormulaRange(previousArrayFormulaRange, currentRow, currentColumn) && (cell == null || this._isSameCellValue(cell, arrayDataCell));
8374
9523
  if (rowIndex === startRow && columnIndex === startColumn) runtimeArrayUnitData.setValue(row, column, errorObject);
9524
+ else if (shouldClearPreviousCellOfCurrentArrayFormula) sheetData.setValue(currentRow, currentColumn, null);
8375
9525
  else if (cell != null) {
8376
9526
  if (cell.v == null) cell.v = "";
8377
- runtimeArrayUnitData.setValue(currentRow, currentColumn, cell);
9527
+ sheetData.setValue(currentRow, currentColumn, { ...cell });
8378
9528
  } else if (this._isInOtherArrayFormulaRange(unitId, sheetId, row, column, currentRow, currentColumn)) return true;
8379
- else runtimeArrayUnitData.setValue(currentRow, currentColumn, { v: "" });
8380
9529
  });
8381
9530
  } else {
8382
9531
  const spillError = ErrorValueObject.create("#SPILL!");
@@ -8489,954 +9638,282 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
8489
9638
  getRuntimeState() {
8490
9639
  return {
8491
9640
  totalFormulasToCalculate: this.getTotalFormulasToCalculate(),
8492
- completedFormulasCount: this.getCompletedFormulasCount(),
8493
- totalArrayFormulasToCalculate: this.getTotalArrayFormulasToCalculate(),
8494
- completedArrayFormulasCount: this.getCompletedArrayFormulasCount(),
8495
- stage: this.getFormulaExecuteStage(),
8496
- formulaCycleIndex: this.getFormulaCycleIndex()
8497
- };
8498
- }
8499
- clearArrayObjectCache() {
8500
- FORMULA_REF_TO_ARRAY_CACHE.clear();
8501
- }
8502
- _checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
8503
- var _this$_unitArrayFormu;
8504
- const { startRow, startColumn, endRow, endColumn } = arrayRange;
8505
- const unitData = this._currentConfigService.getUnitData();
8506
- const arrayData = this._currentConfigService.getArrayFormulaCellData();
8507
- (_this$_unitArrayFormu = this._unitArrayFormulaRange[formulaUnitId]) === null || _this$_unitArrayFormu === void 0 || (_this$_unitArrayFormu = _this$_unitArrayFormu[formulaSheetId]) === null || _this$_unitArrayFormu === void 0 || (_this$_unitArrayFormu = _this$_unitArrayFormu[formulaRow]) === null || _this$_unitArrayFormu === void 0 || _this$_unitArrayFormu[formulaColumn];
8508
- for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
8509
- var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
8510
- if (r === formulaRow && formulaColumn === c) continue;
8511
- const cell = (_this$_runtimeData = this._runtimeData) === null || _this$_runtimeData === void 0 || (_this$_runtimeData = _this$_runtimeData[formulaUnitId]) === null || _this$_runtimeData === void 0 || (_this$_runtimeData = _this$_runtimeData[formulaSheetId]) === null || _this$_runtimeData === void 0 ? void 0 : _this$_runtimeData.getValue(r, c);
8512
- arrayData === null || arrayData === void 0 || (_arrayData$formulaUni = arrayData[formulaUnitId]) === null || _arrayData$formulaUni === void 0 || (_arrayData$formulaUni = _arrayData$formulaUni[formulaSheetId]) === null || _arrayData$formulaUni === void 0 || _arrayData$formulaUni.getValue(r, c);
8513
- const currentCell = unitData === null || unitData === void 0 || (_unitData$formulaUnit = unitData[formulaUnitId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit[formulaSheetId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit.cellData) === null || _unitData$formulaUnit === void 0 ? void 0 : _unitData$formulaUnit.getValue(r, c);
8514
- const featureCell = this._getRuntimeFeatureCellValue(r, c, formulaSheetId, formulaUnitId);
8515
- if (!isNullCellForFormula(cell) || this._isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) || !isNullCellForFormula(currentCell) || !isNullCellForFormula(featureCell)) return true;
8516
- }
8517
- return false;
8518
- }
8519
- _getRuntimeFeatureCellValue(row, column, sheetId, unitId) {
8520
- return getRuntimeFeatureCell(row, column, sheetId, unitId, this._runtimeFeatureCellData);
8521
- }
8522
- _arrayCellHasData(cell) {
8523
- if (cell === null || cell === void 0) return false;
8524
- if (cell.v !== void 0) return true;
8525
- return false;
8526
- }
8527
- /**
8528
- * If the current array formula in the extended area intersects with the existing array formula, a #SPILL! error will be reported. Note that if other array formulas are already #SPILL!, they will not conflict with the current array formula
8529
- * @param formulaUnitId
8530
- * @param formulaSheetId
8531
- * @param formulaRow
8532
- * @param formulaColumn
8533
- * @param r
8534
- * @param c
8535
- * @returns
8536
- */
8537
- _isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
8538
- var _this$_currentConfigS;
8539
- const arrayFormulaRange = (_this$_currentConfigS = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS === void 0 ? void 0 : _this$_currentConfigS[formulaSheetId];
8540
- if (arrayFormulaRange == null) return false;
8541
- let isCellOverlapping = false;
8542
- new ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
8543
- var _this$_runtimeData$fo;
8544
- if (rangeRow === formulaRow && rangeCol === formulaColumn) return;
8545
- const isOverlapping = this._isInArrayFormulaRange(range, r, c);
8546
- const cell = (_this$_runtimeData$fo = this._runtimeData[formulaUnitId]) === null || _this$_runtimeData$fo === void 0 || (_this$_runtimeData$fo = _this$_runtimeData$fo[formulaSheetId]) === null || _this$_runtimeData$fo === void 0 ? void 0 : _this$_runtimeData$fo.getValue(rangeRow, rangeCol);
8547
- if (isOverlapping && (cell === null || cell === void 0 ? void 0 : cell.v) !== "#SPILL!") isCellOverlapping = true;
8548
- });
8549
- return isCellOverlapping;
8550
- }
8551
- _isInArrayFormulaRange(range, r, c) {
8552
- if (range == null) return false;
8553
- const { startRow, startColumn, endRow, endColumn } = range;
8554
- if (r >= startRow && r <= endRow && c >= startColumn && c <= endColumn) return true;
8555
- return false;
8556
- }
8557
- _checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange) {
8558
- if (arrayRange.endRow >= rowCount || arrayRange.endColumn >= columnCount) return true;
8559
- return false;
8560
- }
8561
- _isInDirtyRange(unitId, sheetId, row, column) {
8562
- const dirtyRanges = this._currentConfigService.getDirtyRanges();
8563
- if (dirtyRanges.length === 0) return true;
8564
- return isInDirtyRange(dirtyRanges, unitId, sheetId, row, column);
8565
- }
8566
- };
8567
- FormulaRuntimeService = __decorate([__decorateParam(0, IFormulaCurrentConfigService), __decorateParam(1, IHyperlinkEngineFormulaService)], FormulaRuntimeService);
8568
- const IFormulaRuntimeService = createIdentifier("univer.formula.runtime.service");
8569
-
8570
- //#endregion
8571
- //#region src/engine/ast-node/node-type.ts
8572
- const NODE_ORDER_MAP = new Map([
8573
- [1, 7],
8574
- [2, 9],
8575
- [3, 8],
8576
- [4, 6],
8577
- [5, 1],
8578
- [6, 2],
8579
- [9, 10],
8580
- [10, 3],
8581
- [11, 4],
8582
- [12, 5]
8583
- ]);
8584
-
8585
- //#endregion
8586
- //#region src/engine/ast-node/base-ast-node.ts
8587
- var BaseAstNode = class {
8588
- constructor(_token) {
8589
- this._token = _token;
8590
- _defineProperty(this, "_children", []);
8591
- _defineProperty(this, "_definedNames", void 0);
8592
- _defineProperty(this, "_parent", void 0);
8593
- _defineProperty(this, "_valueObject", void 0);
8594
- _defineProperty(this, "_calculateState", false);
8595
- _defineProperty(this, "_async", false);
8596
- _defineProperty(this, "_address", false);
8597
- _defineProperty(this, "_isForcedCalculateFunction", false);
8598
- }
8599
- dispose() {
8600
- var _this$_valueObject;
8601
- this._children.forEach((node) => {
8602
- node.dispose();
8603
- });
8604
- (_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
8605
- this._valueObject = null;
8606
- this._children = [];
8607
- this._definedNames = null;
8608
- this._parent = null;
8609
- }
8610
- get nodeType() {
8611
- return 8;
8612
- }
8613
- resetCalculationState() {
8614
- this._children.forEach((node) => {
8615
- node.resetCalculationState();
8616
- });
8617
- this._valueObject = null;
8618
- this._calculateState = false;
8619
- }
8620
- isAsync() {
8621
- return this._async;
8622
- }
8623
- isAddress() {
8624
- return this._address;
8625
- }
8626
- isForcedCalculateFunction() {
8627
- return this._isForcedCalculateFunction;
8628
- }
8629
- setAsync() {
8630
- this._async = true;
8631
- }
8632
- setAddress() {
8633
- this._address = true;
8634
- }
8635
- getParent() {
8636
- return this._parent;
8637
- }
8638
- setParent(node) {
8639
- this._parent = node;
8640
- node.addChildren(this);
8641
- }
8642
- setForcedCalculateFunction() {
8643
- this._isForcedCalculateFunction = true;
8644
- }
8645
- getChildren() {
8646
- return this._children;
8647
- }
8648
- addChildren(...astNode) {
8649
- this._children.push(...astNode);
8650
- }
8651
- getToken() {
8652
- return this._token;
8653
- }
8654
- setValue(value) {
8655
- this._valueObject = value;
8656
- }
8657
- getValue() {
8658
- return this._valueObject;
8659
- }
8660
- isCalculated() {
8661
- return this._calculateState;
8662
- }
8663
- setCalculated() {
8664
- this._calculateState = true;
8665
- }
8666
- execute() {}
8667
- setNotEmpty(state = true) {}
8668
- async executeAsync() {
8669
- return Promise.resolve(0);
8670
- }
8671
- serialize() {
8672
- const token = this.getToken();
8673
- const children = this.getChildren();
8674
- const childrenSerialization = [];
8675
- const childrenCount = children.length;
8676
- for (let i = 0; i < childrenCount; i++) {
8677
- const item = children[i];
8678
- childrenSerialization.push(item.serialize());
8679
- }
8680
- const result = {
8681
- token,
8682
- nodeType: this.nodeType
8683
- };
8684
- if (childrenCount > 0) result.children = childrenSerialization;
8685
- return result;
8686
- }
8687
- hasDefinedName(definedName) {
8688
- var _this$_definedNames;
8689
- return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
8690
- }
8691
- setDefinedNames(definedNames) {
8692
- this._definedNames = definedNames;
8693
- }
8694
- getDefinedNames() {
8695
- return this._definedNames;
8696
- }
8697
- };
8698
- var ErrorNode = class ErrorNode extends BaseAstNode {
8699
- constructor(errorType) {
8700
- super(errorType);
8701
- _defineProperty(this, "_errorValueObject", void 0);
8702
- this._errorValueObject = ErrorValueObject.create(errorType);
8703
- }
8704
- get nodeType() {
8705
- return 7;
8706
- }
8707
- static create(errorType) {
8708
- return new ErrorNode(errorType);
8709
- }
8710
- getValue() {
8711
- return this._errorValueObject;
8712
- }
8713
- };
8714
-
8715
- //#endregion
8716
- //#region src/engine/ast-node/base-ast-node-factory.ts
8717
- var BaseAstNodeFactory = class {
8718
- get zIndex() {
8719
- return 0;
8720
- }
8721
- dispose() {}
8722
- create(param, currentRow, currentColumn) {
8723
- let token;
8724
- if (param instanceof LexerNode) token = param.getToken();
8725
- else token = param;
8726
- return new BaseAstNode(token);
9641
+ completedFormulasCount: this.getCompletedFormulasCount(),
9642
+ totalArrayFormulasToCalculate: this.getTotalArrayFormulasToCalculate(),
9643
+ completedArrayFormulasCount: this.getCompletedArrayFormulasCount(),
9644
+ stage: this.getFormulaExecuteStage(),
9645
+ formulaCycleIndex: this.getFormulaCycleIndex()
9646
+ };
8727
9647
  }
8728
- };
8729
-
8730
- //#endregion
8731
- //#region src/engine/ast-node/ast-root-node.ts
8732
- var AstRootNode = class extends BaseAstNode {
8733
- get nodeType() {
8734
- return 9;
9648
+ clearArrayObjectCache() {
9649
+ FORMULA_REF_TO_ARRAY_CACHE.clear();
8735
9650
  }
8736
- execute() {
8737
- const children = this.getChildren();
8738
- if (children.length > 1) {
8739
- this.setValue(ErrorValueObject.create("#VALUE!"));
8740
- return;
9651
+ _checkIfArrayFormulaRangeHasData(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, arrayRange) {
9652
+ var _this$_currentConfigS2;
9653
+ const { startRow, startColumn, endRow, endColumn } = arrayRange;
9654
+ const unitData = this._currentConfigService.getUnitData();
9655
+ const arrayData = this._currentConfigService.getArrayFormulaCellData();
9656
+ const previousArrayFormulaRange = (_this$_currentConfigS2 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[formulaSheetId]) === null || _this$_currentConfigS2 === void 0 || (_this$_currentConfigS2 = _this$_currentConfigS2[formulaRow]) === null || _this$_currentConfigS2 === void 0 ? void 0 : _this$_currentConfigS2[formulaColumn];
9657
+ for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
9658
+ var _this$_runtimeData, _arrayData$formulaUni, _unitData$formulaUnit;
9659
+ if (r === formulaRow && formulaColumn === c) continue;
9660
+ const cell = (_this$_runtimeData = this._runtimeData) === null || _this$_runtimeData === void 0 || (_this$_runtimeData = _this$_runtimeData[formulaUnitId]) === null || _this$_runtimeData === void 0 || (_this$_runtimeData = _this$_runtimeData[formulaSheetId]) === null || _this$_runtimeData === void 0 ? void 0 : _this$_runtimeData.getValue(r, c);
9661
+ const arrayDataCell = arrayData === null || arrayData === void 0 || (_arrayData$formulaUni = arrayData[formulaUnitId]) === null || _arrayData$formulaUni === void 0 || (_arrayData$formulaUni = _arrayData$formulaUni[formulaSheetId]) === null || _arrayData$formulaUni === void 0 ? void 0 : _arrayData$formulaUni.getValue(r, c);
9662
+ const currentCell = unitData === null || unitData === void 0 || (_unitData$formulaUnit = unitData[formulaUnitId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit[formulaSheetId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit.cellData) === null || _unitData$formulaUnit === void 0 ? void 0 : _unitData$formulaUnit.getValue(r, c);
9663
+ const featureCell = this._getRuntimeFeatureCellValue(r, c, formulaSheetId, formulaUnitId);
9664
+ const isPreviousCellOfCurrentArrayFormula = this._arrayCellHasData(arrayDataCell) && this._isInArrayFormulaRange(previousArrayFormulaRange, r, c) && (currentCell == null || this._isSameCellValue(currentCell, arrayDataCell));
9665
+ const hasRuntimeCell = !isNullCellForFormula(cell);
9666
+ const isInOtherArrayFormulaRange = this._isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c);
9667
+ const currentCellBlocks = !isNullCellForFormula(currentCell) && !isPreviousCellOfCurrentArrayFormula;
9668
+ const featureCellBlocks = !isNullCellForFormula(featureCell);
9669
+ if (hasRuntimeCell || isInOtherArrayFormulaRange || currentCellBlocks || featureCellBlocks) return true;
8741
9670
  }
8742
- const node = children[0];
8743
- if (node == null)
8744
- /**
8745
- * fix: https://github.com/dream-num/univer/issues/1415
8746
- */
8747
- this.setValue(ErrorValueObject.create("#VALUE!"));
8748
- else this.setValue(node.getValue());
9671
+ return false;
8749
9672
  }
8750
- };
8751
- var AstRootNodeFactory = class extends BaseAstNodeFactory {
8752
- get zIndex() {
8753
- return NODE_ORDER_MAP.get(9) || 100;
9673
+ _getRuntimeFeatureCellValue(row, column, sheetId, unitId) {
9674
+ return getRuntimeFeatureCell(row, column, sheetId, unitId, this._runtimeFeatureCellData);
8754
9675
  }
8755
- checkAndCreateNodeType(param) {
8756
- if (!(param instanceof LexerNode)) return;
8757
- if (param.getToken() === "R_1") return new AstRootNode("R_1");
9676
+ _arrayCellHasData(cell) {
9677
+ if (cell === null || cell === void 0) return false;
9678
+ if (cell.v !== void 0) return true;
9679
+ return false;
8758
9680
  }
8759
- };
8760
-
8761
- //#endregion
8762
- //#region src/functions/date/function-names.ts
8763
- /**
8764
- * Copyright 2023-present DreamNum Co., Ltd.
8765
- *
8766
- * Licensed under the Apache License, Version 2.0 (the "License");
8767
- * you may not use this file except in compliance with the License.
8768
- * You may obtain a copy of the License at
8769
- *
8770
- * http://www.apache.org/licenses/LICENSE-2.0
8771
- *
8772
- * Unless required by applicable law or agreed to in writing, software
8773
- * distributed under the License is distributed on an "AS IS" BASIS,
8774
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8775
- * See the License for the specific language governing permissions and
8776
- * limitations under the License.
8777
- */
8778
- let FUNCTION_NAMES_DATE = /* @__PURE__ */ function(FUNCTION_NAMES_DATE) {
8779
- FUNCTION_NAMES_DATE["DATE"] = "DATE";
8780
- FUNCTION_NAMES_DATE["DATEDIF"] = "DATEDIF";
8781
- FUNCTION_NAMES_DATE["DATEVALUE"] = "DATEVALUE";
8782
- FUNCTION_NAMES_DATE["DAY"] = "DAY";
8783
- FUNCTION_NAMES_DATE["DAYS"] = "DAYS";
8784
- FUNCTION_NAMES_DATE["DAYS360"] = "DAYS360";
8785
- FUNCTION_NAMES_DATE["EDATE"] = "EDATE";
8786
- FUNCTION_NAMES_DATE["EOMONTH"] = "EOMONTH";
8787
- FUNCTION_NAMES_DATE["EPOCHTODATE"] = "EPOCHTODATE";
8788
- FUNCTION_NAMES_DATE["HOUR"] = "HOUR";
8789
- FUNCTION_NAMES_DATE["ISOWEEKNUM"] = "ISOWEEKNUM";
8790
- FUNCTION_NAMES_DATE["MINUTE"] = "MINUTE";
8791
- FUNCTION_NAMES_DATE["MONTH"] = "MONTH";
8792
- FUNCTION_NAMES_DATE["NETWORKDAYS"] = "NETWORKDAYS";
8793
- FUNCTION_NAMES_DATE["NETWORKDAYS_INTL"] = "NETWORKDAYS.INTL";
8794
- FUNCTION_NAMES_DATE["NOW"] = "NOW";
8795
- FUNCTION_NAMES_DATE["SECOND"] = "SECOND";
8796
- FUNCTION_NAMES_DATE["TIME"] = "TIME";
8797
- FUNCTION_NAMES_DATE["TIMEVALUE"] = "TIMEVALUE";
8798
- FUNCTION_NAMES_DATE["TO_DATE"] = "TO_DATE";
8799
- FUNCTION_NAMES_DATE["TODAY"] = "TODAY";
8800
- FUNCTION_NAMES_DATE["WEEKDAY"] = "WEEKDAY";
8801
- FUNCTION_NAMES_DATE["WEEKNUM"] = "WEEKNUM";
8802
- FUNCTION_NAMES_DATE["WORKDAY"] = "WORKDAY";
8803
- FUNCTION_NAMES_DATE["WORKDAY_INTL"] = "WORKDAY.INTL";
8804
- FUNCTION_NAMES_DATE["YEAR"] = "YEAR";
8805
- FUNCTION_NAMES_DATE["YEARFRAC"] = "YEARFRAC";
8806
- return FUNCTION_NAMES_DATE;
8807
- }({});
8808
-
8809
- //#endregion
8810
- //#region src/functions/engineering/function-names.ts
8811
- /**
8812
- * Copyright 2023-present DreamNum Co., Ltd.
8813
- *
8814
- * Licensed under the Apache License, Version 2.0 (the "License");
8815
- * you may not use this file except in compliance with the License.
8816
- * You may obtain a copy of the License at
8817
- *
8818
- * http://www.apache.org/licenses/LICENSE-2.0
8819
- *
8820
- * Unless required by applicable law or agreed to in writing, software
8821
- * distributed under the License is distributed on an "AS IS" BASIS,
8822
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8823
- * See the License for the specific language governing permissions and
8824
- * limitations under the License.
8825
- */
8826
- let FUNCTION_NAMES_ENGINEERING = /* @__PURE__ */ function(FUNCTION_NAMES_ENGINEERING) {
8827
- FUNCTION_NAMES_ENGINEERING["BESSELI"] = "BESSELI";
8828
- FUNCTION_NAMES_ENGINEERING["BESSELJ"] = "BESSELJ";
8829
- FUNCTION_NAMES_ENGINEERING["BESSELK"] = "BESSELK";
8830
- FUNCTION_NAMES_ENGINEERING["BESSELY"] = "BESSELY";
8831
- FUNCTION_NAMES_ENGINEERING["BIN2DEC"] = "BIN2DEC";
8832
- FUNCTION_NAMES_ENGINEERING["BIN2HEX"] = "BIN2HEX";
8833
- FUNCTION_NAMES_ENGINEERING["BIN2OCT"] = "BIN2OCT";
8834
- FUNCTION_NAMES_ENGINEERING["BITAND"] = "BITAND";
8835
- FUNCTION_NAMES_ENGINEERING["BITLSHIFT"] = "BITLSHIFT";
8836
- FUNCTION_NAMES_ENGINEERING["BITOR"] = "BITOR";
8837
- FUNCTION_NAMES_ENGINEERING["BITRSHIFT"] = "BITRSHIFT";
8838
- FUNCTION_NAMES_ENGINEERING["BITXOR"] = "BITXOR";
8839
- FUNCTION_NAMES_ENGINEERING["COMPLEX"] = "COMPLEX";
8840
- FUNCTION_NAMES_ENGINEERING["CONVERT"] = "CONVERT";
8841
- FUNCTION_NAMES_ENGINEERING["DEC2BIN"] = "DEC2BIN";
8842
- FUNCTION_NAMES_ENGINEERING["DEC2HEX"] = "DEC2HEX";
8843
- FUNCTION_NAMES_ENGINEERING["DEC2OCT"] = "DEC2OCT";
8844
- FUNCTION_NAMES_ENGINEERING["DELTA"] = "DELTA";
8845
- FUNCTION_NAMES_ENGINEERING["ERF"] = "ERF";
8846
- FUNCTION_NAMES_ENGINEERING["ERF_PRECISE"] = "ERF.PRECISE";
8847
- FUNCTION_NAMES_ENGINEERING["ERFC"] = "ERFC";
8848
- FUNCTION_NAMES_ENGINEERING["ERFC_PRECISE"] = "ERFC.PRECISE";
8849
- FUNCTION_NAMES_ENGINEERING["GESTEP"] = "GESTEP";
8850
- FUNCTION_NAMES_ENGINEERING["HEX2BIN"] = "HEX2BIN";
8851
- FUNCTION_NAMES_ENGINEERING["HEX2DEC"] = "HEX2DEC";
8852
- FUNCTION_NAMES_ENGINEERING["HEX2OCT"] = "HEX2OCT";
8853
- FUNCTION_NAMES_ENGINEERING["IMABS"] = "IMABS";
8854
- FUNCTION_NAMES_ENGINEERING["IMAGINARY"] = "IMAGINARY";
8855
- FUNCTION_NAMES_ENGINEERING["IMARGUMENT"] = "IMARGUMENT";
8856
- FUNCTION_NAMES_ENGINEERING["IMCONJUGATE"] = "IMCONJUGATE";
8857
- FUNCTION_NAMES_ENGINEERING["IMCOS"] = "IMCOS";
8858
- FUNCTION_NAMES_ENGINEERING["IMCOSH"] = "IMCOSH";
8859
- FUNCTION_NAMES_ENGINEERING["IMCOT"] = "IMCOT";
8860
- FUNCTION_NAMES_ENGINEERING["IMCOTH"] = "IMCOTH";
8861
- FUNCTION_NAMES_ENGINEERING["IMCSC"] = "IMCSC";
8862
- FUNCTION_NAMES_ENGINEERING["IMCSCH"] = "IMCSCH";
8863
- FUNCTION_NAMES_ENGINEERING["IMDIV"] = "IMDIV";
8864
- FUNCTION_NAMES_ENGINEERING["IMEXP"] = "IMEXP";
8865
- FUNCTION_NAMES_ENGINEERING["IMLN"] = "IMLN";
8866
- FUNCTION_NAMES_ENGINEERING["IMLOG"] = "IMLOG";
8867
- FUNCTION_NAMES_ENGINEERING["IMLOG10"] = "IMLOG10";
8868
- FUNCTION_NAMES_ENGINEERING["IMLOG2"] = "IMLOG2";
8869
- FUNCTION_NAMES_ENGINEERING["IMPOWER"] = "IMPOWER";
8870
- FUNCTION_NAMES_ENGINEERING["IMPRODUCT"] = "IMPRODUCT";
8871
- FUNCTION_NAMES_ENGINEERING["IMREAL"] = "IMREAL";
8872
- FUNCTION_NAMES_ENGINEERING["IMSEC"] = "IMSEC";
8873
- FUNCTION_NAMES_ENGINEERING["IMSECH"] = "IMSECH";
8874
- FUNCTION_NAMES_ENGINEERING["IMSIN"] = "IMSIN";
8875
- FUNCTION_NAMES_ENGINEERING["IMSINH"] = "IMSINH";
8876
- FUNCTION_NAMES_ENGINEERING["IMSQRT"] = "IMSQRT";
8877
- FUNCTION_NAMES_ENGINEERING["IMSUB"] = "IMSUB";
8878
- FUNCTION_NAMES_ENGINEERING["IMSUM"] = "IMSUM";
8879
- FUNCTION_NAMES_ENGINEERING["IMTAN"] = "IMTAN";
8880
- FUNCTION_NAMES_ENGINEERING["IMTANH"] = "IMTANH";
8881
- FUNCTION_NAMES_ENGINEERING["OCT2BIN"] = "OCT2BIN";
8882
- FUNCTION_NAMES_ENGINEERING["OCT2DEC"] = "OCT2DEC";
8883
- FUNCTION_NAMES_ENGINEERING["OCT2HEX"] = "OCT2HEX";
8884
- return FUNCTION_NAMES_ENGINEERING;
8885
- }({});
8886
-
8887
- //#endregion
8888
- //#region src/functions/financial/function-names.ts
8889
- /**
8890
- * Copyright 2023-present DreamNum Co., Ltd.
8891
- *
8892
- * Licensed under the Apache License, Version 2.0 (the "License");
8893
- * you may not use this file except in compliance with the License.
8894
- * You may obtain a copy of the License at
8895
- *
8896
- * http://www.apache.org/licenses/LICENSE-2.0
8897
- *
8898
- * Unless required by applicable law or agreed to in writing, software
8899
- * distributed under the License is distributed on an "AS IS" BASIS,
8900
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8901
- * See the License for the specific language governing permissions and
8902
- * limitations under the License.
8903
- */
8904
- let FUNCTION_NAMES_FINANCIAL = /* @__PURE__ */ function(FUNCTION_NAMES_FINANCIAL) {
8905
- FUNCTION_NAMES_FINANCIAL["ACCRINT"] = "ACCRINT";
8906
- FUNCTION_NAMES_FINANCIAL["ACCRINTM"] = "ACCRINTM";
8907
- FUNCTION_NAMES_FINANCIAL["AMORDEGRC"] = "AMORDEGRC";
8908
- FUNCTION_NAMES_FINANCIAL["AMORLINC"] = "AMORLINC";
8909
- FUNCTION_NAMES_FINANCIAL["COUPDAYBS"] = "COUPDAYBS";
8910
- FUNCTION_NAMES_FINANCIAL["COUPDAYS"] = "COUPDAYS";
8911
- FUNCTION_NAMES_FINANCIAL["COUPDAYSNC"] = "COUPDAYSNC";
8912
- FUNCTION_NAMES_FINANCIAL["COUPNCD"] = "COUPNCD";
8913
- FUNCTION_NAMES_FINANCIAL["COUPNUM"] = "COUPNUM";
8914
- FUNCTION_NAMES_FINANCIAL["COUPPCD"] = "COUPPCD";
8915
- FUNCTION_NAMES_FINANCIAL["CUMIPMT"] = "CUMIPMT";
8916
- FUNCTION_NAMES_FINANCIAL["CUMPRINC"] = "CUMPRINC";
8917
- FUNCTION_NAMES_FINANCIAL["DB"] = "DB";
8918
- FUNCTION_NAMES_FINANCIAL["DDB"] = "DDB";
8919
- FUNCTION_NAMES_FINANCIAL["DISC"] = "DISC";
8920
- FUNCTION_NAMES_FINANCIAL["DOLLARDE"] = "DOLLARDE";
8921
- FUNCTION_NAMES_FINANCIAL["DOLLARFR"] = "DOLLARFR";
8922
- FUNCTION_NAMES_FINANCIAL["DURATION"] = "DURATION";
8923
- FUNCTION_NAMES_FINANCIAL["EFFECT"] = "EFFECT";
8924
- FUNCTION_NAMES_FINANCIAL["FV"] = "FV";
8925
- FUNCTION_NAMES_FINANCIAL["FVSCHEDULE"] = "FVSCHEDULE";
8926
- FUNCTION_NAMES_FINANCIAL["INTRATE"] = "INTRATE";
8927
- FUNCTION_NAMES_FINANCIAL["IPMT"] = "IPMT";
8928
- FUNCTION_NAMES_FINANCIAL["IRR"] = "IRR";
8929
- FUNCTION_NAMES_FINANCIAL["ISPMT"] = "ISPMT";
8930
- FUNCTION_NAMES_FINANCIAL["MDURATION"] = "MDURATION";
8931
- FUNCTION_NAMES_FINANCIAL["MIRR"] = "MIRR";
8932
- FUNCTION_NAMES_FINANCIAL["NOMINAL"] = "NOMINAL";
8933
- FUNCTION_NAMES_FINANCIAL["NPER"] = "NPER";
8934
- FUNCTION_NAMES_FINANCIAL["NPV"] = "NPV";
8935
- FUNCTION_NAMES_FINANCIAL["ODDFPRICE"] = "ODDFPRICE";
8936
- FUNCTION_NAMES_FINANCIAL["ODDFYIELD"] = "ODDFYIELD";
8937
- FUNCTION_NAMES_FINANCIAL["ODDLPRICE"] = "ODDLPRICE";
8938
- FUNCTION_NAMES_FINANCIAL["ODDLYIELD"] = "ODDLYIELD";
8939
- FUNCTION_NAMES_FINANCIAL["PDURATION"] = "PDURATION";
8940
- FUNCTION_NAMES_FINANCIAL["PMT"] = "PMT";
8941
- FUNCTION_NAMES_FINANCIAL["PPMT"] = "PPMT";
8942
- FUNCTION_NAMES_FINANCIAL["PRICE"] = "PRICE";
8943
- FUNCTION_NAMES_FINANCIAL["PRICEDISC"] = "PRICEDISC";
8944
- FUNCTION_NAMES_FINANCIAL["PRICEMAT"] = "PRICEMAT";
8945
- FUNCTION_NAMES_FINANCIAL["PV"] = "PV";
8946
- FUNCTION_NAMES_FINANCIAL["RATE"] = "RATE";
8947
- FUNCTION_NAMES_FINANCIAL["RECEIVED"] = "RECEIVED";
8948
- FUNCTION_NAMES_FINANCIAL["RRI"] = "RRI";
8949
- FUNCTION_NAMES_FINANCIAL["SLN"] = "SLN";
8950
- FUNCTION_NAMES_FINANCIAL["SYD"] = "SYD";
8951
- FUNCTION_NAMES_FINANCIAL["TBILLEQ"] = "TBILLEQ";
8952
- FUNCTION_NAMES_FINANCIAL["TBILLPRICE"] = "TBILLPRICE";
8953
- FUNCTION_NAMES_FINANCIAL["TBILLYIELD"] = "TBILLYIELD";
8954
- FUNCTION_NAMES_FINANCIAL["VDB"] = "VDB";
8955
- FUNCTION_NAMES_FINANCIAL["XIRR"] = "XIRR";
8956
- FUNCTION_NAMES_FINANCIAL["XNPV"] = "XNPV";
8957
- FUNCTION_NAMES_FINANCIAL["YIELD"] = "YIELD";
8958
- FUNCTION_NAMES_FINANCIAL["YIELDDISC"] = "YIELDDISC";
8959
- FUNCTION_NAMES_FINANCIAL["YIELDMAT"] = "YIELDMAT";
8960
- return FUNCTION_NAMES_FINANCIAL;
8961
- }({});
8962
-
8963
- //#endregion
8964
- //#region src/functions/information/function-names.ts
8965
- /**
8966
- * Copyright 2023-present DreamNum Co., Ltd.
8967
- *
8968
- * Licensed under the Apache License, Version 2.0 (the "License");
8969
- * you may not use this file except in compliance with the License.
8970
- * You may obtain a copy of the License at
8971
- *
8972
- * http://www.apache.org/licenses/LICENSE-2.0
8973
- *
8974
- * Unless required by applicable law or agreed to in writing, software
8975
- * distributed under the License is distributed on an "AS IS" BASIS,
8976
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8977
- * See the License for the specific language governing permissions and
8978
- * limitations under the License.
8979
- */
8980
- let FUNCTION_NAMES_INFORMATION = /* @__PURE__ */ function(FUNCTION_NAMES_INFORMATION) {
8981
- FUNCTION_NAMES_INFORMATION["CELL"] = "CELL";
8982
- FUNCTION_NAMES_INFORMATION["ERROR_TYPE"] = "ERROR.TYPE";
8983
- FUNCTION_NAMES_INFORMATION["INFO"] = "INFO";
8984
- FUNCTION_NAMES_INFORMATION["ISBETWEEN"] = "ISBETWEEN";
8985
- FUNCTION_NAMES_INFORMATION["ISBLANK"] = "ISBLANK";
8986
- FUNCTION_NAMES_INFORMATION["ISDATE"] = "ISDATE";
8987
- FUNCTION_NAMES_INFORMATION["ISEMAIL"] = "ISEMAIL";
8988
- FUNCTION_NAMES_INFORMATION["ISERR"] = "ISERR";
8989
- FUNCTION_NAMES_INFORMATION["ISERROR"] = "ISERROR";
8990
- FUNCTION_NAMES_INFORMATION["ISEVEN"] = "ISEVEN";
8991
- FUNCTION_NAMES_INFORMATION["ISFORMULA"] = "ISFORMULA";
8992
- FUNCTION_NAMES_INFORMATION["ISLOGICAL"] = "ISLOGICAL";
8993
- FUNCTION_NAMES_INFORMATION["ISNA"] = "ISNA";
8994
- FUNCTION_NAMES_INFORMATION["ISNONTEXT"] = "ISNONTEXT";
8995
- FUNCTION_NAMES_INFORMATION["ISNUMBER"] = "ISNUMBER";
8996
- FUNCTION_NAMES_INFORMATION["ISODD"] = "ISODD";
8997
- FUNCTION_NAMES_INFORMATION["ISOMITTED"] = "ISOMITTED";
8998
- FUNCTION_NAMES_INFORMATION["ISREF"] = "ISREF";
8999
- FUNCTION_NAMES_INFORMATION["ISTEXT"] = "ISTEXT";
9000
- FUNCTION_NAMES_INFORMATION["ISURL"] = "ISURL";
9001
- FUNCTION_NAMES_INFORMATION["N"] = "N";
9002
- FUNCTION_NAMES_INFORMATION["NA"] = "NA";
9003
- FUNCTION_NAMES_INFORMATION["SHEET"] = "SHEET";
9004
- FUNCTION_NAMES_INFORMATION["SHEETS"] = "SHEETS";
9005
- FUNCTION_NAMES_INFORMATION["TYPE"] = "TYPE";
9006
- return FUNCTION_NAMES_INFORMATION;
9007
- }({});
9008
-
9009
- //#endregion
9010
- //#region src/functions/logical/function-names.ts
9011
- /**
9012
- * Copyright 2023-present DreamNum Co., Ltd.
9013
- *
9014
- * Licensed under the Apache License, Version 2.0 (the "License");
9015
- * you may not use this file except in compliance with the License.
9016
- * You may obtain a copy of the License at
9017
- *
9018
- * http://www.apache.org/licenses/LICENSE-2.0
9019
- *
9020
- * Unless required by applicable law or agreed to in writing, software
9021
- * distributed under the License is distributed on an "AS IS" BASIS,
9022
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9023
- * See the License for the specific language governing permissions and
9024
- * limitations under the License.
9025
- */
9026
- let FUNCTION_NAMES_LOGICAL = /* @__PURE__ */ function(FUNCTION_NAMES_LOGICAL) {
9027
- FUNCTION_NAMES_LOGICAL["AND"] = "AND";
9028
- FUNCTION_NAMES_LOGICAL["BYCOL"] = "BYCOL";
9029
- FUNCTION_NAMES_LOGICAL["BYROW"] = "BYROW";
9030
- FUNCTION_NAMES_LOGICAL["FALSE"] = "FALSE";
9031
- FUNCTION_NAMES_LOGICAL["IF"] = "IF";
9032
- FUNCTION_NAMES_LOGICAL["IFERROR"] = "IFERROR";
9033
- FUNCTION_NAMES_LOGICAL["IFNA"] = "IFNA";
9034
- FUNCTION_NAMES_LOGICAL["IFS"] = "IFS";
9035
- FUNCTION_NAMES_LOGICAL["LAMBDA"] = "LAMBDA";
9036
- FUNCTION_NAMES_LOGICAL["LET"] = "LET";
9037
- FUNCTION_NAMES_LOGICAL["MAKEARRAY"] = "MAKEARRAY";
9038
- FUNCTION_NAMES_LOGICAL["MAP"] = "MAP";
9039
- FUNCTION_NAMES_LOGICAL["NOT"] = "NOT";
9040
- FUNCTION_NAMES_LOGICAL["OR"] = "OR";
9041
- FUNCTION_NAMES_LOGICAL["REDUCE"] = "REDUCE";
9042
- FUNCTION_NAMES_LOGICAL["SCAN"] = "SCAN";
9043
- FUNCTION_NAMES_LOGICAL["SWITCH"] = "SWITCH";
9044
- FUNCTION_NAMES_LOGICAL["TRUE"] = "TRUE";
9045
- FUNCTION_NAMES_LOGICAL["XOR"] = "XOR";
9046
- return FUNCTION_NAMES_LOGICAL;
9047
- }({});
9048
-
9049
- //#endregion
9050
- //#region src/functions/lookup/function-names.ts
9051
- /**
9052
- * Copyright 2023-present DreamNum Co., Ltd.
9053
- *
9054
- * Licensed under the Apache License, Version 2.0 (the "License");
9055
- * you may not use this file except in compliance with the License.
9056
- * You may obtain a copy of the License at
9057
- *
9058
- * http://www.apache.org/licenses/LICENSE-2.0
9059
- *
9060
- * Unless required by applicable law or agreed to in writing, software
9061
- * distributed under the License is distributed on an "AS IS" BASIS,
9062
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9063
- * See the License for the specific language governing permissions and
9064
- * limitations under the License.
9065
- */
9066
- let FUNCTION_NAMES_LOOKUP = /* @__PURE__ */ function(FUNCTION_NAMES_LOOKUP) {
9067
- FUNCTION_NAMES_LOOKUP["ADDRESS"] = "ADDRESS";
9068
- FUNCTION_NAMES_LOOKUP["AREAS"] = "AREAS";
9069
- FUNCTION_NAMES_LOOKUP["CHOOSE"] = "CHOOSE";
9070
- FUNCTION_NAMES_LOOKUP["CHOOSECOLS"] = "CHOOSECOLS";
9071
- FUNCTION_NAMES_LOOKUP["CHOOSEROWS"] = "CHOOSEROWS";
9072
- FUNCTION_NAMES_LOOKUP["COLUMN"] = "COLUMN";
9073
- FUNCTION_NAMES_LOOKUP["COLUMNS"] = "COLUMNS";
9074
- FUNCTION_NAMES_LOOKUP["DROP"] = "DROP";
9075
- FUNCTION_NAMES_LOOKUP["EXPAND"] = "EXPAND";
9076
- FUNCTION_NAMES_LOOKUP["FILTER"] = "FILTER";
9077
- FUNCTION_NAMES_LOOKUP["FORMULATEXT"] = "FORMULATEXT";
9078
- FUNCTION_NAMES_LOOKUP["GETPIVOTDATA"] = "GETPIVOTDATA";
9079
- FUNCTION_NAMES_LOOKUP["HLOOKUP"] = "HLOOKUP";
9080
- FUNCTION_NAMES_LOOKUP["HSTACK"] = "HSTACK";
9081
- FUNCTION_NAMES_LOOKUP["HYPERLINK"] = "HYPERLINK";
9082
- FUNCTION_NAMES_LOOKUP["IMAGE"] = "IMAGE";
9083
- FUNCTION_NAMES_LOOKUP["INDEX"] = "INDEX";
9084
- FUNCTION_NAMES_LOOKUP["INDIRECT"] = "INDIRECT";
9085
- FUNCTION_NAMES_LOOKUP["LOOKUP"] = "LOOKUP";
9086
- FUNCTION_NAMES_LOOKUP["MATCH"] = "MATCH";
9087
- FUNCTION_NAMES_LOOKUP["OFFSET"] = "OFFSET";
9088
- FUNCTION_NAMES_LOOKUP["ROW"] = "ROW";
9089
- FUNCTION_NAMES_LOOKUP["ROWS"] = "ROWS";
9090
- FUNCTION_NAMES_LOOKUP["RTD"] = "RTD";
9091
- FUNCTION_NAMES_LOOKUP["SORT"] = "SORT";
9092
- FUNCTION_NAMES_LOOKUP["SORTBY"] = "SORTBY";
9093
- FUNCTION_NAMES_LOOKUP["TAKE"] = "TAKE";
9094
- FUNCTION_NAMES_LOOKUP["TOCOL"] = "TOCOL";
9095
- FUNCTION_NAMES_LOOKUP["TOROW"] = "TOROW";
9096
- FUNCTION_NAMES_LOOKUP["TRANSPOSE"] = "TRANSPOSE";
9097
- FUNCTION_NAMES_LOOKUP["UNIQUE"] = "UNIQUE";
9098
- FUNCTION_NAMES_LOOKUP["VLOOKUP"] = "VLOOKUP";
9099
- FUNCTION_NAMES_LOOKUP["VSTACK"] = "VSTACK";
9100
- FUNCTION_NAMES_LOOKUP["WRAPCOLS"] = "WRAPCOLS";
9101
- FUNCTION_NAMES_LOOKUP["WRAPROWS"] = "WRAPROWS";
9102
- FUNCTION_NAMES_LOOKUP["XLOOKUP"] = "XLOOKUP";
9103
- FUNCTION_NAMES_LOOKUP["XMATCH"] = "XMATCH";
9104
- return FUNCTION_NAMES_LOOKUP;
9105
- }({});
9106
-
9107
- //#endregion
9108
- //#region src/functions/math/function-names.ts
9109
- /**
9110
- * Copyright 2023-present DreamNum Co., Ltd.
9111
- *
9112
- * Licensed under the Apache License, Version 2.0 (the "License");
9113
- * you may not use this file except in compliance with the License.
9114
- * You may obtain a copy of the License at
9115
- *
9116
- * http://www.apache.org/licenses/LICENSE-2.0
9117
- *
9118
- * Unless required by applicable law or agreed to in writing, software
9119
- * distributed under the License is distributed on an "AS IS" BASIS,
9120
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9121
- * See the License for the specific language governing permissions and
9122
- * limitations under the License.
9123
- */
9124
- let FUNCTION_NAMES_MATH = /* @__PURE__ */ function(FUNCTION_NAMES_MATH) {
9125
- FUNCTION_NAMES_MATH["ABS"] = "ABS";
9126
- FUNCTION_NAMES_MATH["ACOS"] = "ACOS";
9127
- FUNCTION_NAMES_MATH["ACOSH"] = "ACOSH";
9128
- FUNCTION_NAMES_MATH["ACOT"] = "ACOT";
9129
- FUNCTION_NAMES_MATH["ACOTH"] = "ACOTH";
9130
- FUNCTION_NAMES_MATH["AGGREGATE"] = "AGGREGATE";
9131
- FUNCTION_NAMES_MATH["ARABIC"] = "ARABIC";
9132
- FUNCTION_NAMES_MATH["ASIN"] = "ASIN";
9133
- FUNCTION_NAMES_MATH["ASINH"] = "ASINH";
9134
- FUNCTION_NAMES_MATH["ATAN"] = "ATAN";
9135
- FUNCTION_NAMES_MATH["ATAN2"] = "ATAN2";
9136
- FUNCTION_NAMES_MATH["ATANH"] = "ATANH";
9137
- FUNCTION_NAMES_MATH["BASE"] = "BASE";
9138
- FUNCTION_NAMES_MATH["CEILING"] = "CEILING";
9139
- FUNCTION_NAMES_MATH["CEILING_MATH"] = "CEILING.MATH";
9140
- FUNCTION_NAMES_MATH["CEILING_PRECISE"] = "CEILING.PRECISE";
9141
- FUNCTION_NAMES_MATH["COMBIN"] = "COMBIN";
9142
- FUNCTION_NAMES_MATH["COMBINA"] = "COMBINA";
9143
- FUNCTION_NAMES_MATH["COS"] = "COS";
9144
- FUNCTION_NAMES_MATH["COSH"] = "COSH";
9145
- FUNCTION_NAMES_MATH["COT"] = "COT";
9146
- FUNCTION_NAMES_MATH["COTH"] = "COTH";
9147
- FUNCTION_NAMES_MATH["CSC"] = "CSC";
9148
- FUNCTION_NAMES_MATH["CSCH"] = "CSCH";
9149
- FUNCTION_NAMES_MATH["DECIMAL"] = "DECIMAL";
9150
- FUNCTION_NAMES_MATH["DEGREES"] = "DEGREES";
9151
- FUNCTION_NAMES_MATH["EVEN"] = "EVEN";
9152
- FUNCTION_NAMES_MATH["EXP"] = "EXP";
9153
- FUNCTION_NAMES_MATH["FACT"] = "FACT";
9154
- FUNCTION_NAMES_MATH["FACTDOUBLE"] = "FACTDOUBLE";
9155
- FUNCTION_NAMES_MATH["FLOOR"] = "FLOOR";
9156
- FUNCTION_NAMES_MATH["FLOOR_MATH"] = "FLOOR.MATH";
9157
- FUNCTION_NAMES_MATH["FLOOR_PRECISE"] = "FLOOR.PRECISE";
9158
- FUNCTION_NAMES_MATH["GCD"] = "GCD";
9159
- FUNCTION_NAMES_MATH["INT"] = "INT";
9160
- FUNCTION_NAMES_MATH["ISO_CEILING"] = "ISO.CEILING";
9161
- FUNCTION_NAMES_MATH["LCM"] = "LCM";
9162
- FUNCTION_NAMES_MATH["LET"] = "LET";
9163
- FUNCTION_NAMES_MATH["LN"] = "LN";
9164
- FUNCTION_NAMES_MATH["LOG"] = "LOG";
9165
- FUNCTION_NAMES_MATH["LOG10"] = "LOG10";
9166
- FUNCTION_NAMES_MATH["MDETERM"] = "MDETERM";
9167
- FUNCTION_NAMES_MATH["MINVERSE"] = "MINVERSE";
9168
- FUNCTION_NAMES_MATH["MMULT"] = "MMULT";
9169
- FUNCTION_NAMES_MATH["MOD"] = "MOD";
9170
- FUNCTION_NAMES_MATH["MROUND"] = "MROUND";
9171
- FUNCTION_NAMES_MATH["MULTINOMIAL"] = "MULTINOMIAL";
9172
- FUNCTION_NAMES_MATH["MUNIT"] = "MUNIT";
9173
- FUNCTION_NAMES_MATH["ODD"] = "ODD";
9174
- FUNCTION_NAMES_MATH["PI"] = "PI";
9175
- FUNCTION_NAMES_MATH["POWER"] = "POWER";
9176
- FUNCTION_NAMES_MATH["PRODUCT"] = "PRODUCT";
9177
- FUNCTION_NAMES_MATH["QUOTIENT"] = "QUOTIENT";
9178
- FUNCTION_NAMES_MATH["RADIANS"] = "RADIANS";
9179
- FUNCTION_NAMES_MATH["RAND"] = "RAND";
9180
- FUNCTION_NAMES_MATH["RANDARRAY"] = "RANDARRAY";
9181
- FUNCTION_NAMES_MATH["RANDBETWEEN"] = "RANDBETWEEN";
9182
- FUNCTION_NAMES_MATH["ROMAN"] = "ROMAN";
9183
- FUNCTION_NAMES_MATH["ROUND"] = "ROUND";
9184
- FUNCTION_NAMES_MATH["ROUNDBANK"] = "ROUNDBANK";
9185
- FUNCTION_NAMES_MATH["ROUNDDOWN"] = "ROUNDDOWN";
9186
- FUNCTION_NAMES_MATH["ROUNDUP"] = "ROUNDUP";
9187
- FUNCTION_NAMES_MATH["SEC"] = "SEC";
9188
- FUNCTION_NAMES_MATH["SECH"] = "SECH";
9189
- FUNCTION_NAMES_MATH["SERIESSUM"] = "SERIESSUM";
9190
- FUNCTION_NAMES_MATH["SEQUENCE"] = "SEQUENCE";
9191
- FUNCTION_NAMES_MATH["SIGN"] = "SIGN";
9192
- FUNCTION_NAMES_MATH["SIN"] = "SIN";
9193
- FUNCTION_NAMES_MATH["SINH"] = "SINH";
9194
- FUNCTION_NAMES_MATH["SQRT"] = "SQRT";
9195
- FUNCTION_NAMES_MATH["SQRTPI"] = "SQRTPI";
9196
- FUNCTION_NAMES_MATH["SUBTOTAL"] = "SUBTOTAL";
9197
- FUNCTION_NAMES_MATH["SUM"] = "SUM";
9198
- FUNCTION_NAMES_MATH["SUMIF"] = "SUMIF";
9199
- FUNCTION_NAMES_MATH["SUMIFS"] = "SUMIFS";
9200
- FUNCTION_NAMES_MATH["SUMPRODUCT"] = "SUMPRODUCT";
9201
- FUNCTION_NAMES_MATH["SUMSQ"] = "SUMSQ";
9202
- FUNCTION_NAMES_MATH["SUMX2MY2"] = "SUMX2MY2";
9203
- FUNCTION_NAMES_MATH["SUMX2PY2"] = "SUMX2PY2";
9204
- FUNCTION_NAMES_MATH["SUMXMY2"] = "SUMXMY2";
9205
- FUNCTION_NAMES_MATH["TAN"] = "TAN";
9206
- FUNCTION_NAMES_MATH["TANH"] = "TANH";
9207
- FUNCTION_NAMES_MATH["TRUNC"] = "TRUNC";
9208
- return FUNCTION_NAMES_MATH;
9209
- }({});
9681
+ /**
9682
+ * If the current array formula in the extended area intersects with the existing array formula, a #SPILL! error will be reported. Note that if other array formulas are already #SPILL!, they will not conflict with the current array formula
9683
+ * @param formulaUnitId
9684
+ * @param formulaSheetId
9685
+ * @param formulaRow
9686
+ * @param formulaColumn
9687
+ * @param r
9688
+ * @param c
9689
+ * @returns
9690
+ */
9691
+ _isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c) {
9692
+ var _this$_currentConfigS3;
9693
+ const arrayFormulaRange = (_this$_currentConfigS3 = this._currentConfigService.getArrayFormulaRange()[formulaUnitId]) === null || _this$_currentConfigS3 === void 0 ? void 0 : _this$_currentConfigS3[formulaSheetId];
9694
+ if (arrayFormulaRange == null) return false;
9695
+ let isCellOverlapping = false;
9696
+ new ObjectMatrix(arrayFormulaRange).forValue((rangeRow, rangeCol, range) => {
9697
+ var _this$_runtimeData$fo;
9698
+ if (rangeRow === formulaRow && rangeCol === formulaColumn) return;
9699
+ const isOverlapping = this._isInArrayFormulaRange(range, r, c);
9700
+ const cell = (_this$_runtimeData$fo = this._runtimeData[formulaUnitId]) === null || _this$_runtimeData$fo === void 0 || (_this$_runtimeData$fo = _this$_runtimeData$fo[formulaSheetId]) === null || _this$_runtimeData$fo === void 0 ? void 0 : _this$_runtimeData$fo.getValue(rangeRow, rangeCol);
9701
+ if (isOverlapping && (cell === null || cell === void 0 ? void 0 : cell.v) !== "#SPILL!") isCellOverlapping = true;
9702
+ });
9703
+ return isCellOverlapping;
9704
+ }
9705
+ _isInArrayFormulaRange(range, r, c) {
9706
+ if (range == null) return false;
9707
+ const { startRow, startColumn, endRow, endColumn } = range;
9708
+ if (r >= startRow && r <= endRow && c >= startColumn && c <= endColumn) return true;
9709
+ return false;
9710
+ }
9711
+ _isSameCellValue(cell, arrayDataCell) {
9712
+ return (cell === null || cell === void 0 ? void 0 : cell.v) === (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.v) && (cell === null || cell === void 0 ? void 0 : cell.t) === (arrayDataCell === null || arrayDataCell === void 0 ? void 0 : arrayDataCell.t);
9713
+ }
9714
+ _checkIfArrayFormulaExceeded(rowCount, columnCount, arrayRange) {
9715
+ if (arrayRange.endRow >= rowCount || arrayRange.endColumn >= columnCount) return true;
9716
+ return false;
9717
+ }
9718
+ _isInDirtyRange(unitId, sheetId, row, column) {
9719
+ const dirtyRanges = this._currentConfigService.getDirtyRanges();
9720
+ if (dirtyRanges.length === 0) return true;
9721
+ return isInDirtyRange(dirtyRanges, unitId, sheetId, row, column);
9722
+ }
9723
+ };
9724
+ FormulaRuntimeService = __decorate([__decorateParam(0, IFormulaCurrentConfigService), __decorateParam(1, IHyperlinkEngineFormulaService)], FormulaRuntimeService);
9725
+ const IFormulaRuntimeService = createIdentifier("univer.formula.runtime.service");
9210
9726
 
9211
9727
  //#endregion
9212
- //#region src/functions/statistical/function-names.ts
9213
- /**
9214
- * Copyright 2023-present DreamNum Co., Ltd.
9215
- *
9216
- * Licensed under the Apache License, Version 2.0 (the "License");
9217
- * you may not use this file except in compliance with the License.
9218
- * You may obtain a copy of the License at
9219
- *
9220
- * http://www.apache.org/licenses/LICENSE-2.0
9221
- *
9222
- * Unless required by applicable law or agreed to in writing, software
9223
- * distributed under the License is distributed on an "AS IS" BASIS,
9224
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9225
- * See the License for the specific language governing permissions and
9226
- * limitations under the License.
9227
- */
9228
- let FUNCTION_NAMES_STATISTICAL = /* @__PURE__ */ function(FUNCTION_NAMES_STATISTICAL) {
9229
- FUNCTION_NAMES_STATISTICAL["AVEDEV"] = "AVEDEV";
9230
- FUNCTION_NAMES_STATISTICAL["AVERAGE"] = "AVERAGE";
9231
- FUNCTION_NAMES_STATISTICAL["AVERAGE_WEIGHTED"] = "AVERAGE.WEIGHTED";
9232
- FUNCTION_NAMES_STATISTICAL["AVERAGEA"] = "AVERAGEA";
9233
- FUNCTION_NAMES_STATISTICAL["AVERAGEIF"] = "AVERAGEIF";
9234
- FUNCTION_NAMES_STATISTICAL["AVERAGEIFS"] = "AVERAGEIFS";
9235
- FUNCTION_NAMES_STATISTICAL["BETA_DIST"] = "BETA.DIST";
9236
- FUNCTION_NAMES_STATISTICAL["BETA_INV"] = "BETA.INV";
9237
- FUNCTION_NAMES_STATISTICAL["BINOM_DIST"] = "BINOM.DIST";
9238
- FUNCTION_NAMES_STATISTICAL["BINOM_DIST_RANGE"] = "BINOM.DIST.RANGE";
9239
- FUNCTION_NAMES_STATISTICAL["BINOM_INV"] = "BINOM.INV";
9240
- FUNCTION_NAMES_STATISTICAL["CHISQ_DIST"] = "CHISQ.DIST";
9241
- FUNCTION_NAMES_STATISTICAL["CHISQ_DIST_RT"] = "CHISQ.DIST.RT";
9242
- FUNCTION_NAMES_STATISTICAL["CHISQ_INV"] = "CHISQ.INV";
9243
- FUNCTION_NAMES_STATISTICAL["CHISQ_INV_RT"] = "CHISQ.INV.RT";
9244
- FUNCTION_NAMES_STATISTICAL["CHISQ_TEST"] = "CHISQ.TEST";
9245
- FUNCTION_NAMES_STATISTICAL["CONFIDENCE_NORM"] = "CONFIDENCE.NORM";
9246
- FUNCTION_NAMES_STATISTICAL["CONFIDENCE_T"] = "CONFIDENCE.T";
9247
- FUNCTION_NAMES_STATISTICAL["CORREL"] = "CORREL";
9248
- FUNCTION_NAMES_STATISTICAL["COUNT"] = "COUNT";
9249
- FUNCTION_NAMES_STATISTICAL["COUNTA"] = "COUNTA";
9250
- FUNCTION_NAMES_STATISTICAL["COUNTBLANK"] = "COUNTBLANK";
9251
- FUNCTION_NAMES_STATISTICAL["COUNTIF"] = "COUNTIF";
9252
- FUNCTION_NAMES_STATISTICAL["COUNTIFS"] = "COUNTIFS";
9253
- FUNCTION_NAMES_STATISTICAL["COVARIANCE_P"] = "COVARIANCE.P";
9254
- FUNCTION_NAMES_STATISTICAL["COVARIANCE_S"] = "COVARIANCE.S";
9255
- FUNCTION_NAMES_STATISTICAL["DEVSQ"] = "DEVSQ";
9256
- FUNCTION_NAMES_STATISTICAL["EXPON_DIST"] = "EXPON.DIST";
9257
- FUNCTION_NAMES_STATISTICAL["F_DIST"] = "F.DIST";
9258
- FUNCTION_NAMES_STATISTICAL["F_DIST_RT"] = "F.DIST.RT";
9259
- FUNCTION_NAMES_STATISTICAL["F_INV"] = "F.INV";
9260
- FUNCTION_NAMES_STATISTICAL["F_INV_RT"] = "F.INV.RT";
9261
- FUNCTION_NAMES_STATISTICAL["F_TEST"] = "F.TEST";
9262
- FUNCTION_NAMES_STATISTICAL["FISHER"] = "FISHER";
9263
- FUNCTION_NAMES_STATISTICAL["FISHERINV"] = "FISHERINV";
9264
- FUNCTION_NAMES_STATISTICAL["FORECAST"] = "FORECAST";
9265
- FUNCTION_NAMES_STATISTICAL["FORECAST_ETS"] = "FORECAST.ETS";
9266
- FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_CONFINT"] = "FORECAST.ETS.CONFINT";
9267
- FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_SEASONALITY"] = "FORECAST.ETS.SEASONALITY";
9268
- FUNCTION_NAMES_STATISTICAL["FORECAST_ETS_STAT"] = "FORECAST.ETS.STAT";
9269
- FUNCTION_NAMES_STATISTICAL["FORECAST_LINEAR"] = "FORECAST.LINEAR";
9270
- FUNCTION_NAMES_STATISTICAL["FREQUENCY"] = "FREQUENCY";
9271
- FUNCTION_NAMES_STATISTICAL["GAMMA"] = "GAMMA";
9272
- FUNCTION_NAMES_STATISTICAL["GAMMA_DIST"] = "GAMMA.DIST";
9273
- FUNCTION_NAMES_STATISTICAL["GAMMA_INV"] = "GAMMA.INV";
9274
- FUNCTION_NAMES_STATISTICAL["GAMMALN"] = "GAMMALN";
9275
- FUNCTION_NAMES_STATISTICAL["GAMMALN_PRECISE"] = "GAMMALN.PRECISE";
9276
- FUNCTION_NAMES_STATISTICAL["GAUSS"] = "GAUSS";
9277
- FUNCTION_NAMES_STATISTICAL["GEOMEAN"] = "GEOMEAN";
9278
- FUNCTION_NAMES_STATISTICAL["GROWTH"] = "GROWTH";
9279
- FUNCTION_NAMES_STATISTICAL["HARMEAN"] = "HARMEAN";
9280
- FUNCTION_NAMES_STATISTICAL["HYPGEOM_DIST"] = "HYPGEOM.DIST";
9281
- FUNCTION_NAMES_STATISTICAL["INTERCEPT"] = "INTERCEPT";
9282
- FUNCTION_NAMES_STATISTICAL["KURT"] = "KURT";
9283
- FUNCTION_NAMES_STATISTICAL["LARGE"] = "LARGE";
9284
- FUNCTION_NAMES_STATISTICAL["LINEST"] = "LINEST";
9285
- FUNCTION_NAMES_STATISTICAL["LOGEST"] = "LOGEST";
9286
- FUNCTION_NAMES_STATISTICAL["LOGNORM_DIST"] = "LOGNORM.DIST";
9287
- FUNCTION_NAMES_STATISTICAL["LOGNORM_INV"] = "LOGNORM.INV";
9288
- FUNCTION_NAMES_STATISTICAL["MARGINOFERROR"] = "MARGINOFERROR";
9289
- FUNCTION_NAMES_STATISTICAL["MAX"] = "MAX";
9290
- FUNCTION_NAMES_STATISTICAL["MAXA"] = "MAXA";
9291
- FUNCTION_NAMES_STATISTICAL["MAXIFS"] = "MAXIFS";
9292
- FUNCTION_NAMES_STATISTICAL["MEDIAN"] = "MEDIAN";
9293
- FUNCTION_NAMES_STATISTICAL["MIN"] = "MIN";
9294
- FUNCTION_NAMES_STATISTICAL["MINA"] = "MINA";
9295
- FUNCTION_NAMES_STATISTICAL["MINIFS"] = "MINIFS";
9296
- FUNCTION_NAMES_STATISTICAL["MODE_MULT"] = "MODE.MULT";
9297
- FUNCTION_NAMES_STATISTICAL["MODE_SNGL"] = "MODE.SNGL";
9298
- FUNCTION_NAMES_STATISTICAL["NEGBINOM_DIST"] = "NEGBINOM.DIST";
9299
- FUNCTION_NAMES_STATISTICAL["NORM_DIST"] = "NORM.DIST";
9300
- FUNCTION_NAMES_STATISTICAL["NORM_INV"] = "NORM.INV";
9301
- FUNCTION_NAMES_STATISTICAL["NORM_S_DIST"] = "NORM.S.DIST";
9302
- FUNCTION_NAMES_STATISTICAL["NORM_S_INV"] = "NORM.S.INV";
9303
- FUNCTION_NAMES_STATISTICAL["PEARSON"] = "PEARSON";
9304
- FUNCTION_NAMES_STATISTICAL["PERCENTILE_EXC"] = "PERCENTILE.EXC";
9305
- FUNCTION_NAMES_STATISTICAL["PERCENTILE_INC"] = "PERCENTILE.INC";
9306
- FUNCTION_NAMES_STATISTICAL["PERCENTRANK_EXC"] = "PERCENTRANK.EXC";
9307
- FUNCTION_NAMES_STATISTICAL["PERCENTRANK_INC"] = "PERCENTRANK.INC";
9308
- FUNCTION_NAMES_STATISTICAL["PERMUT"] = "PERMUT";
9309
- FUNCTION_NAMES_STATISTICAL["PERMUTATIONA"] = "PERMUTATIONA";
9310
- FUNCTION_NAMES_STATISTICAL["PHI"] = "PHI";
9311
- FUNCTION_NAMES_STATISTICAL["POISSON_DIST"] = "POISSON.DIST";
9312
- FUNCTION_NAMES_STATISTICAL["PROB"] = "PROB";
9313
- FUNCTION_NAMES_STATISTICAL["QUARTILE_EXC"] = "QUARTILE.EXC";
9314
- FUNCTION_NAMES_STATISTICAL["QUARTILE_INC"] = "QUARTILE.INC";
9315
- FUNCTION_NAMES_STATISTICAL["RANK_AVG"] = "RANK.AVG";
9316
- FUNCTION_NAMES_STATISTICAL["RANK_EQ"] = "RANK.EQ";
9317
- FUNCTION_NAMES_STATISTICAL["RSQ"] = "RSQ";
9318
- FUNCTION_NAMES_STATISTICAL["SKEW"] = "SKEW";
9319
- FUNCTION_NAMES_STATISTICAL["SKEW_P"] = "SKEW.P";
9320
- FUNCTION_NAMES_STATISTICAL["SLOPE"] = "SLOPE";
9321
- FUNCTION_NAMES_STATISTICAL["SMALL"] = "SMALL";
9322
- FUNCTION_NAMES_STATISTICAL["STANDARDIZE"] = "STANDARDIZE";
9323
- FUNCTION_NAMES_STATISTICAL["STDEV_P"] = "STDEV.P";
9324
- FUNCTION_NAMES_STATISTICAL["STDEV_S"] = "STDEV.S";
9325
- FUNCTION_NAMES_STATISTICAL["STDEVA"] = "STDEVA";
9326
- FUNCTION_NAMES_STATISTICAL["STDEVPA"] = "STDEVPA";
9327
- FUNCTION_NAMES_STATISTICAL["STEYX"] = "STEYX";
9328
- FUNCTION_NAMES_STATISTICAL["T_DIST"] = "T.DIST";
9329
- FUNCTION_NAMES_STATISTICAL["T_DIST_2T"] = "T.DIST.2T";
9330
- FUNCTION_NAMES_STATISTICAL["T_DIST_RT"] = "T.DIST.RT";
9331
- FUNCTION_NAMES_STATISTICAL["T_INV"] = "T.INV";
9332
- FUNCTION_NAMES_STATISTICAL["T_INV_2T"] = "T.INV.2T";
9333
- FUNCTION_NAMES_STATISTICAL["T_TEST"] = "T.TEST";
9334
- FUNCTION_NAMES_STATISTICAL["TREND"] = "TREND";
9335
- FUNCTION_NAMES_STATISTICAL["TRIMMEAN"] = "TRIMMEAN";
9336
- FUNCTION_NAMES_STATISTICAL["VAR_P"] = "VAR.P";
9337
- FUNCTION_NAMES_STATISTICAL["VAR_S"] = "VAR.S";
9338
- FUNCTION_NAMES_STATISTICAL["VARA"] = "VARA";
9339
- FUNCTION_NAMES_STATISTICAL["VARPA"] = "VARPA";
9340
- FUNCTION_NAMES_STATISTICAL["WEIBULL_DIST"] = "WEIBULL.DIST";
9341
- FUNCTION_NAMES_STATISTICAL["Z_TEST"] = "Z.TEST";
9342
- return FUNCTION_NAMES_STATISTICAL;
9343
- }({});
9728
+ //#region src/engine/ast-node/node-type.ts
9729
+ const NODE_ORDER_MAP = new Map([
9730
+ [1, 7],
9731
+ [2, 9],
9732
+ [3, 8],
9733
+ [4, 6],
9734
+ [5, 1],
9735
+ [6, 2],
9736
+ [9, 10],
9737
+ [10, 3],
9738
+ [11, 4],
9739
+ [12, 5]
9740
+ ]);
9344
9741
 
9345
9742
  //#endregion
9346
- //#region src/functions/text/function-names.ts
9347
- /**
9348
- * Copyright 2023-present DreamNum Co., Ltd.
9349
- *
9350
- * Licensed under the Apache License, Version 2.0 (the "License");
9351
- * you may not use this file except in compliance with the License.
9352
- * You may obtain a copy of the License at
9353
- *
9354
- * http://www.apache.org/licenses/LICENSE-2.0
9355
- *
9356
- * Unless required by applicable law or agreed to in writing, software
9357
- * distributed under the License is distributed on an "AS IS" BASIS,
9358
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9359
- * See the License for the specific language governing permissions and
9360
- * limitations under the License.
9361
- */
9362
- let FUNCTION_NAMES_TEXT = /* @__PURE__ */ function(FUNCTION_NAMES_TEXT) {
9363
- FUNCTION_NAMES_TEXT["ASC"] = "ASC";
9364
- FUNCTION_NAMES_TEXT["ARRAYTOTEXT"] = "ARRAYTOTEXT";
9365
- FUNCTION_NAMES_TEXT["BAHTTEXT"] = "BAHTTEXT";
9366
- FUNCTION_NAMES_TEXT["CHAR"] = "CHAR";
9367
- FUNCTION_NAMES_TEXT["CLEAN"] = "CLEAN";
9368
- FUNCTION_NAMES_TEXT["CODE"] = "CODE";
9369
- FUNCTION_NAMES_TEXT["CONCAT"] = "CONCAT";
9370
- FUNCTION_NAMES_TEXT["CONCATENATE"] = "CONCATENATE";
9371
- FUNCTION_NAMES_TEXT["DBCS"] = "DBCS";
9372
- FUNCTION_NAMES_TEXT["DOLLAR"] = "DOLLAR";
9373
- FUNCTION_NAMES_TEXT["EXACT"] = "EXACT";
9374
- FUNCTION_NAMES_TEXT["FIND"] = "FIND";
9375
- FUNCTION_NAMES_TEXT["FINDB"] = "FINDB";
9376
- FUNCTION_NAMES_TEXT["FIXED"] = "FIXED";
9377
- FUNCTION_NAMES_TEXT["LEFT"] = "LEFT";
9378
- FUNCTION_NAMES_TEXT["LEFTB"] = "LEFTB";
9379
- FUNCTION_NAMES_TEXT["LEN"] = "LEN";
9380
- FUNCTION_NAMES_TEXT["LENB"] = "LENB";
9381
- FUNCTION_NAMES_TEXT["LOWER"] = "LOWER";
9382
- FUNCTION_NAMES_TEXT["MID"] = "MID";
9383
- FUNCTION_NAMES_TEXT["MIDB"] = "MIDB";
9384
- FUNCTION_NAMES_TEXT["NUMBERSTRING"] = "NUMBERSTRING";
9385
- FUNCTION_NAMES_TEXT["NUMBERVALUE"] = "NUMBERVALUE";
9386
- FUNCTION_NAMES_TEXT["PHONETIC"] = "PHONETIC";
9387
- FUNCTION_NAMES_TEXT["PROPER"] = "PROPER";
9388
- FUNCTION_NAMES_TEXT["REGEXEXTRACT"] = "REGEXEXTRACT";
9389
- FUNCTION_NAMES_TEXT["REGEXMATCH"] = "REGEXMATCH";
9390
- FUNCTION_NAMES_TEXT["REGEXREPLACE"] = "REGEXREPLACE";
9391
- FUNCTION_NAMES_TEXT["REPLACE"] = "REPLACE";
9392
- FUNCTION_NAMES_TEXT["REPLACEB"] = "REPLACEB";
9393
- FUNCTION_NAMES_TEXT["REPT"] = "REPT";
9394
- FUNCTION_NAMES_TEXT["RIGHT"] = "RIGHT";
9395
- FUNCTION_NAMES_TEXT["RIGHTB"] = "RIGHTB";
9396
- FUNCTION_NAMES_TEXT["SEARCH"] = "SEARCH";
9397
- FUNCTION_NAMES_TEXT["SEARCHB"] = "SEARCHB";
9398
- FUNCTION_NAMES_TEXT["SUBSTITUTE"] = "SUBSTITUTE";
9399
- FUNCTION_NAMES_TEXT["T"] = "T";
9400
- FUNCTION_NAMES_TEXT["TEXT"] = "TEXT";
9401
- FUNCTION_NAMES_TEXT["TEXTAFTER"] = "TEXTAFTER";
9402
- FUNCTION_NAMES_TEXT["TEXTBEFORE"] = "TEXTBEFORE";
9403
- FUNCTION_NAMES_TEXT["TEXTJOIN"] = "TEXTJOIN";
9404
- FUNCTION_NAMES_TEXT["TEXTSPLIT"] = "TEXTSPLIT";
9405
- FUNCTION_NAMES_TEXT["TRIM"] = "TRIM";
9406
- FUNCTION_NAMES_TEXT["UNICHAR"] = "UNICHAR";
9407
- FUNCTION_NAMES_TEXT["UNICODE"] = "UNICODE";
9408
- FUNCTION_NAMES_TEXT["UPPER"] = "UPPER";
9409
- FUNCTION_NAMES_TEXT["VALUE"] = "VALUE";
9410
- FUNCTION_NAMES_TEXT["VALUETOTEXT"] = "VALUETOTEXT";
9411
- FUNCTION_NAMES_TEXT["CALL"] = "CALL";
9412
- FUNCTION_NAMES_TEXT["EUROCONVERT"] = "EUROCONVERT";
9413
- FUNCTION_NAMES_TEXT["REGISTER_ID"] = "REGISTER.ID";
9414
- return FUNCTION_NAMES_TEXT;
9415
- }({});
9743
+ //#region src/engine/ast-node/base-ast-node.ts
9744
+ var BaseAstNode = class {
9745
+ constructor(_token) {
9746
+ this._token = _token;
9747
+ _defineProperty(this, "_children", []);
9748
+ _defineProperty(this, "_definedNames", void 0);
9749
+ _defineProperty(this, "_parent", void 0);
9750
+ _defineProperty(this, "_valueObject", void 0);
9751
+ _defineProperty(this, "_calculateState", false);
9752
+ _defineProperty(this, "_async", false);
9753
+ _defineProperty(this, "_address", false);
9754
+ _defineProperty(this, "_isForcedCalculateFunction", false);
9755
+ }
9756
+ dispose() {
9757
+ var _this$_valueObject;
9758
+ this._children.forEach((node) => {
9759
+ node.dispose();
9760
+ });
9761
+ (_this$_valueObject = this._valueObject) === null || _this$_valueObject === void 0 || _this$_valueObject.dispose();
9762
+ this._valueObject = null;
9763
+ this._children = [];
9764
+ this._definedNames = null;
9765
+ this._parent = null;
9766
+ }
9767
+ get nodeType() {
9768
+ return 8;
9769
+ }
9770
+ resetCalculationState() {
9771
+ this._children.forEach((node) => {
9772
+ node.resetCalculationState();
9773
+ });
9774
+ this._valueObject = null;
9775
+ this._calculateState = false;
9776
+ }
9777
+ isAsync() {
9778
+ return this._async;
9779
+ }
9780
+ isAddress() {
9781
+ return this._address;
9782
+ }
9783
+ isForcedCalculateFunction() {
9784
+ return this._isForcedCalculateFunction;
9785
+ }
9786
+ setAsync() {
9787
+ this._async = true;
9788
+ }
9789
+ setAddress() {
9790
+ this._address = true;
9791
+ }
9792
+ getParent() {
9793
+ return this._parent;
9794
+ }
9795
+ setParent(node) {
9796
+ this._parent = node;
9797
+ node.addChildren(this);
9798
+ }
9799
+ setForcedCalculateFunction() {
9800
+ this._isForcedCalculateFunction = true;
9801
+ }
9802
+ getChildren() {
9803
+ return this._children;
9804
+ }
9805
+ addChildren(...astNode) {
9806
+ this._children.push(...astNode);
9807
+ }
9808
+ getToken() {
9809
+ return this._token;
9810
+ }
9811
+ setValue(value) {
9812
+ this._valueObject = value;
9813
+ }
9814
+ getValue() {
9815
+ return this._valueObject;
9816
+ }
9817
+ isCalculated() {
9818
+ return this._calculateState;
9819
+ }
9820
+ setCalculated() {
9821
+ this._calculateState = true;
9822
+ }
9823
+ execute() {}
9824
+ setNotEmpty(state = true) {}
9825
+ async executeAsync() {
9826
+ return Promise.resolve(0);
9827
+ }
9828
+ serialize() {
9829
+ const token = this.getToken();
9830
+ const children = this.getChildren();
9831
+ const childrenSerialization = [];
9832
+ const childrenCount = children.length;
9833
+ for (let i = 0; i < childrenCount; i++) {
9834
+ const item = children[i];
9835
+ childrenSerialization.push(item.serialize());
9836
+ }
9837
+ const result = {
9838
+ token,
9839
+ nodeType: this.nodeType
9840
+ };
9841
+ if (childrenCount > 0) result.children = childrenSerialization;
9842
+ return result;
9843
+ }
9844
+ hasDefinedName(definedName) {
9845
+ var _this$_definedNames;
9846
+ return ((_this$_definedNames = this._definedNames) === null || _this$_definedNames === void 0 ? void 0 : _this$_definedNames.includes(definedName)) || false;
9847
+ }
9848
+ setDefinedNames(definedNames) {
9849
+ this._definedNames = definedNames;
9850
+ }
9851
+ getDefinedNames() {
9852
+ return this._definedNames;
9853
+ }
9854
+ };
9855
+ var ErrorNode = class ErrorNode extends BaseAstNode {
9856
+ constructor(errorType) {
9857
+ super(errorType);
9858
+ _defineProperty(this, "_errorValueObject", void 0);
9859
+ this._errorValueObject = ErrorValueObject.create(errorType);
9860
+ }
9861
+ get nodeType() {
9862
+ return 7;
9863
+ }
9864
+ static create(errorType) {
9865
+ return new ErrorNode(errorType);
9866
+ }
9867
+ getValue() {
9868
+ return this._errorValueObject;
9869
+ }
9870
+ };
9416
9871
 
9417
9872
  //#endregion
9418
- //#region src/functions/web/function-names.ts
9419
- /**
9420
- * Copyright 2023-present DreamNum Co., Ltd.
9421
- *
9422
- * Licensed under the Apache License, Version 2.0 (the "License");
9423
- * you may not use this file except in compliance with the License.
9424
- * You may obtain a copy of the License at
9425
- *
9426
- * http://www.apache.org/licenses/LICENSE-2.0
9427
- *
9428
- * Unless required by applicable law or agreed to in writing, software
9429
- * distributed under the License is distributed on an "AS IS" BASIS,
9430
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9431
- * See the License for the specific language governing permissions and
9432
- * limitations under the License.
9433
- */
9434
- let FUNCTION_NAMES_WEB = /* @__PURE__ */ function(FUNCTION_NAMES_WEB) {
9435
- FUNCTION_NAMES_WEB["ENCODEURL"] = "ENCODEURL";
9436
- FUNCTION_NAMES_WEB["FILTERXML"] = "FILTERXML";
9437
- FUNCTION_NAMES_WEB["WEBSERVICE"] = "WEBSERVICE";
9438
- return FUNCTION_NAMES_WEB;
9439
- }({});
9873
+ //#region src/engine/ast-node/base-ast-node-factory.ts
9874
+ var BaseAstNodeFactory = class {
9875
+ get zIndex() {
9876
+ return 0;
9877
+ }
9878
+ dispose() {}
9879
+ create(param, currentRow, currentColumn) {
9880
+ let token;
9881
+ if (param instanceof LexerNode) token = param.getToken();
9882
+ else token = param;
9883
+ return new BaseAstNode(token);
9884
+ }
9885
+ };
9886
+
9887
+ //#endregion
9888
+ //#region src/engine/ast-node/ast-root-node.ts
9889
+ var AstRootNode = class extends BaseAstNode {
9890
+ get nodeType() {
9891
+ return 9;
9892
+ }
9893
+ execute() {
9894
+ const children = this.getChildren();
9895
+ if (children.length > 1) {
9896
+ this.setValue(ErrorValueObject.create("#VALUE!"));
9897
+ return;
9898
+ }
9899
+ const node = children[0];
9900
+ if (node == null)
9901
+ /**
9902
+ * fix: https://github.com/dream-num/univer/issues/1415
9903
+ */
9904
+ this.setValue(ErrorValueObject.create("#VALUE!"));
9905
+ else this.setValue(node.getValue());
9906
+ }
9907
+ };
9908
+ var AstRootNodeFactory = class extends BaseAstNodeFactory {
9909
+ get zIndex() {
9910
+ return NODE_ORDER_MAP.get(9) || 100;
9911
+ }
9912
+ checkAndCreateNodeType(param) {
9913
+ if (!(param instanceof LexerNode)) return;
9914
+ if (param.getToken() === "R_1") return new AstRootNode("R_1");
9915
+ }
9916
+ };
9440
9917
 
9441
9918
  //#endregion
9442
9919
  //#region src/functions/column-like-functions.ts
@@ -9463,7 +9940,8 @@ const FORMULA_CACHE_LRU_COUNT = 5e3;
9463
9940
  const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
9464
9941
  function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService) {
9465
9942
  let astNode = FORMULA_AST_CACHE.get(`${unitId}${formulaString}`);
9466
- if (astNode && !isDirtyDefinedForNode(astNode, currentConfigService)) return astNode;
9943
+ const noCache = checkIsChangedByDefinedName(unitId, formulaString, currentConfigService);
9944
+ if (!noCache && astNode && !isDirtyDefinedForNode(astNode, currentConfigService)) return astNode;
9467
9945
  const lexerNode = lexer.treeBuilder(formulaString);
9468
9946
  if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
9469
9947
  astNode = astTreeBuilder.parse(lexerNode);
@@ -9471,9 +9949,20 @@ function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentCo
9471
9949
  console.error("generateAstNode astNode is null");
9472
9950
  return ErrorNode.create(lexerNode);
9473
9951
  }
9474
- FORMULA_AST_CACHE.set(`${unitId}${formulaString}`, astNode);
9952
+ if (!noCache) FORMULA_AST_CACHE.set(`${unitId}${formulaString}`, astNode);
9475
9953
  return astNode;
9476
9954
  }
9955
+ function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
9956
+ const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
9957
+ if (unitDefinedNameMap == null) return false;
9958
+ const formulaText = normalizeFormulaText(formula);
9959
+ const names = Object.keys(unitDefinedNameMap);
9960
+ for (let i = 0, len = names.length; i < len; i++) if (normalizeFormulaText(names[i]) === formulaText) return true;
9961
+ return false;
9962
+ }
9963
+ function normalizeFormulaText(formula) {
9964
+ return formula.startsWith("=") ? formula.slice(1) : formula;
9965
+ }
9477
9966
  function isDirtyDefinedForNode(node, currentConfigService) {
9478
9967
  const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
9479
9968
  const executeUnitId = currentConfigService.getExecuteUnitId();
@@ -11337,6 +11826,8 @@ var DependencyManagerBaseService = class extends Disposable {
11337
11826
  updateDependencyTreeDirtyState(treeId, isDirty) {
11338
11827
  throw new Error("Method not implemented.");
11339
11828
  }
11829
+ openKdTree() {}
11830
+ closeKdTree() {}
11340
11831
  };
11341
11832
  /**
11342
11833
  * Passively marked as dirty, register the reference and execution actions of the feature plugin.
@@ -11348,89 +11839,16 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11348
11839
  constructor(..._args2) {
11349
11840
  super(..._args2);
11350
11841
  _defineProperty(this, "_allTreeMap", /* @__PURE__ */ new Map());
11351
- }
11352
- dispose() {
11353
- super.dispose();
11354
- this.reset();
11355
- }
11356
- buildDependencyTree(shouldBeBuildTrees, dependencyTrees = []) {
11357
- const allTrees = this.getAllTree();
11358
- if (shouldBeBuildTrees.length === 0) {
11359
- this._buildReverseDependency(allTrees, dependencyTrees);
11360
- return allTrees;
11361
- }
11362
- this._buildDependencyTree(allTrees, shouldBeBuildTrees);
11363
- this._buildReverseDependency(allTrees, shouldBeBuildTrees);
11364
- return allTrees;
11365
- }
11366
- /**
11367
- * Build the dependency relationship between the trees.
11368
- * @param allTrees all FormulaDependencyTree
11369
- * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
11370
- */
11371
- _buildDependencyTree(allTrees, shouldBeBuildTrees) {
11372
- const shouldBeBuildTreeMap = /* @__PURE__ */ new Map();
11373
- for (let i = 0; i < shouldBeBuildTrees.length; i++) {
11374
- const tree = shouldBeBuildTrees[i];
11375
- shouldBeBuildTreeMap.set(tree.treeId, tree);
11376
- }
11377
- for (let i = 0; i < allTrees.length; i++) {
11378
- const tree = allTrees[i];
11379
- const RTreeItem = tree.toRTreeItem();
11380
- const searchResults = this._dependencyRTreeCache.bulkSearch(RTreeItem);
11381
- for (const id of searchResults) {
11382
- const shouldBeBuildTree = shouldBeBuildTreeMap.get(id);
11383
- if (shouldBeBuildTree && tree !== shouldBeBuildTree && !shouldBeBuildTree.hasChildren(tree.treeId)) shouldBeBuildTree.pushChildren(tree);
11384
- }
11385
- }
11386
- shouldBeBuildTreeMap.clear();
11387
- }
11388
- /**
11389
- * Build the reverse dependency relationship between the trees.
11390
- * @param allTrees
11391
- * @param dependencyTrees
11392
- */
11393
- _buildReverseDependency(allTrees, dependencyTrees) {
11394
- const allTreeMap = /* @__PURE__ */ new Map();
11395
- for (let i = 0; i < allTrees.length; i++) {
11396
- const tree = allTrees[i];
11397
- allTreeMap.set(tree.treeId, tree);
11398
- }
11399
- for (let i = 0; i < dependencyTrees.length; i++) {
11400
- const tree = dependencyTrees[i];
11401
- const RTreeItem = tree.toRTreeItem();
11402
- const searchResults = this._dependencyRTreeCache.bulkSearch(RTreeItem);
11403
- for (const id of searchResults) {
11404
- const allTree = allTreeMap.get(id);
11405
- if (allTree && tree !== allTree && !allTree.hasChildren(tree.treeId)) allTree.pushChildren(tree);
11406
- }
11407
- }
11408
- allTreeMap.clear();
11409
- }
11410
- /**
11411
- * Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
11412
- * return FormulaDependencyTree[]
11413
- */
11414
- getAllTree() {
11415
- const trees = [];
11416
- this._allTreeMap.forEach((tree) => {
11417
- tree.resetState();
11418
- trees.push(tree);
11419
- });
11420
- return trees;
11421
- }
11422
- getTreeById(treeId) {
11423
- return this._allTreeMap.get(treeId);
11842
+ _defineProperty(this, "_dependencyRTreeCache", new RTree(true));
11424
11843
  }
11425
11844
  reset() {
11426
11845
  this._otherFormulaData.clear();
11427
11846
  this._featureFormulaData.clear();
11428
11847
  this._formulaData.clear();
11429
- this._definedNameMap.clear();
11430
- this._otherFormulaDataMainData.clear();
11431
11848
  this._dependencyRTreeCache.clear();
11432
11849
  this._allTreeMap.clear();
11433
11850
  this._restDependencyTreeId();
11851
+ this._otherFormulaDataMainData.clear();
11434
11852
  }
11435
11853
  addOtherFormulaDependency(unitId, sheetId, formulaId, dependencyTree) {
11436
11854
  if (!this._otherFormulaData.has(unitId)) this._otherFormulaData.set(unitId, /* @__PURE__ */ new Map());
@@ -11439,7 +11857,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11439
11857
  const sheetMap = unitMap.get(sheetId);
11440
11858
  if (!sheetMap.has(formulaId)) sheetMap.set(formulaId, new ObjectMatrix());
11441
11859
  sheetMap.get(formulaId).setValue(dependencyTree.refOffsetX, dependencyTree.refOffsetY, dependencyTree.treeId);
11442
- this._addAllTreeMap(dependencyTree);
11443
11860
  }
11444
11861
  removeOtherFormulaDependency(unitId, sheetId, formulaIds) {
11445
11862
  const unitMap = this._otherFormulaData.get(unitId);
@@ -11450,7 +11867,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11450
11867
  if (treeSet == null) return;
11451
11868
  treeSet.forValue((row, column, treeId) => {
11452
11869
  this._removeDependencyRTreeCache(treeId);
11453
- this.clearDependencyForTree(this._allTreeMap.get(treeId));
11454
11870
  this._removeAllTreeMap(treeId);
11455
11871
  });
11456
11872
  sheetMap.delete(formulaId);
@@ -11469,11 +11885,7 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11469
11885
  const formulaTreeSet = sheetMap.get(formulaId);
11470
11886
  if (formulaTreeSet == null) continue;
11471
11887
  formulaTreeSet.forValue((row, column, treeId) => {
11472
- const tree = this._allTreeMap.get(treeId);
11473
- if (tree) {
11474
- this.clearDependencyForTree(tree);
11475
- this._removeAllTreeMap(treeId);
11476
- }
11888
+ if (this._allTreeMap.get(treeId)) this._removeAllTreeMap(treeId);
11477
11889
  });
11478
11890
  this._otherFormulaDataMainData.delete(formulaId);
11479
11891
  }
@@ -11486,11 +11898,7 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11486
11898
  const formulaTreeSet = sheetMap.get(formulaId);
11487
11899
  if (formulaTreeSet == null) continue;
11488
11900
  formulaTreeSet.forValue((row, column, treeId) => {
11489
- const tree = this._allTreeMap.get(treeId);
11490
- if (tree) {
11491
- this.clearDependencyForTree(tree);
11492
- this._removeAllTreeMap(treeId);
11493
- }
11901
+ if (this._allTreeMap.get(treeId)) this._removeAllTreeMap(treeId);
11494
11902
  });
11495
11903
  this._otherFormulaDataMainData.delete(formulaId);
11496
11904
  }
@@ -11503,7 +11911,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11503
11911
  const unitMap = this._featureFormulaData.get(unitId);
11504
11912
  if (!unitMap.has(sheetId)) unitMap.set(sheetId, /* @__PURE__ */ new Map());
11505
11913
  unitMap.get(sheetId).set(featureId, dependencyTree.treeId);
11506
- this._addAllTreeMap(dependencyTree);
11507
11914
  }
11508
11915
  removeFeatureFormulaDependency(unitId, sheetId, featureIds) {
11509
11916
  const unitMap = this._featureFormulaData.get(unitId);
@@ -11514,7 +11921,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11514
11921
  if (deleteTreeId == null) return;
11515
11922
  this._removeDependencyRTreeCache(deleteTreeId);
11516
11923
  sheetMap.delete(featureId);
11517
- this.clearDependencyForTree(this._allTreeMap.get(deleteTreeId));
11518
11924
  this._removeAllTreeMap(deleteTreeId);
11519
11925
  });
11520
11926
  }
@@ -11526,7 +11932,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11526
11932
  this._removeDependencyRTreeCacheById(unitId, sheetId);
11527
11933
  sheetMap.forEach((featureTreeId) => {
11528
11934
  if (featureTreeId == null) return;
11529
- this.clearDependencyForTree(this._allTreeMap.get(featureTreeId));
11530
11935
  this._removeAllTreeMap(featureTreeId);
11531
11936
  });
11532
11937
  sheetMap.clear();
@@ -11535,7 +11940,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11535
11940
  this._removeDependencyRTreeCacheById(unitId, sheetId);
11536
11941
  sheetMap.forEach((featureTreeId) => {
11537
11942
  if (featureTreeId == null) return;
11538
- this.clearDependencyForTree(this._allTreeMap.get(featureTreeId));
11539
11943
  this._removeAllTreeMap(featureTreeId);
11540
11944
  });
11541
11945
  });
@@ -11547,7 +11951,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11547
11951
  const unitMap = this._formulaData.get(unitId);
11548
11952
  if (!unitMap.has(sheetId)) unitMap.set(sheetId, new ObjectMatrix());
11549
11953
  unitMap.get(sheetId).setValue(row, column, dependencyTree.treeId);
11550
- this._addAllTreeMap(dependencyTree);
11551
11954
  }
11552
11955
  removeFormulaDependency(unitId, sheetId, row, column) {
11553
11956
  const unitMap = this._formulaData.get(unitId);
@@ -11557,7 +11960,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11557
11960
  if (deleteTreeId == null) return;
11558
11961
  this._removeDependencyRTreeCache(deleteTreeId);
11559
11962
  sheetMatrix.realDeleteValue(row, column);
11560
- this.clearDependencyForTree(this._allTreeMap.get(deleteTreeId));
11561
11963
  this._removeAllTreeMap(deleteTreeId);
11562
11964
  }
11563
11965
  }
@@ -11568,7 +11970,6 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11568
11970
  this._removeDependencyRTreeCacheById(unitId, sheetId);
11569
11971
  sheetMatrix.forValue((row, column, treeId) => {
11570
11972
  if (treeId == null) return true;
11571
- this.clearDependencyForTree(this._allTreeMap.get(treeId));
11572
11973
  this._removeAllTreeMap(treeId);
11573
11974
  });
11574
11975
  sheetMatrix.reset();
@@ -11577,47 +11978,23 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11577
11978
  this._removeDependencyRTreeCacheById(unitId, sheetId);
11578
11979
  sheetMatrix.forValue((row, column, treeId) => {
11579
11980
  if (treeId == null) return true;
11580
- this.clearDependencyForTree(this._allTreeMap.get(treeId));
11581
11981
  this._removeAllTreeMap(treeId);
11582
11982
  });
11583
11983
  });
11584
11984
  this._formulaData.delete(unitId);
11585
11985
  }
11586
11986
  }
11587
- /**
11588
- * Clear the dependency relationship of the tree.
11589
- * establish the relationship between the parent and the child.
11590
- * @param shouldBeClearTree
11591
- */
11592
- clearDependencyForTree(shouldBeClearTree) {
11593
- if (shouldBeClearTree == null) return;
11594
- const parents = shouldBeClearTree.parents;
11595
- const children = shouldBeClearTree.children;
11596
- const allTreeMap = this._allTreeMap;
11597
- for (const parentTreeId of parents) {
11598
- const parent = allTreeMap.get(parentTreeId);
11599
- parent === null || parent === void 0 || parent.children.delete(shouldBeClearTree.treeId);
11600
- }
11601
- for (const childTreeId of children) {
11602
- const child = allTreeMap.get(childTreeId);
11603
- child === null || child === void 0 || child.parents.delete(shouldBeClearTree.treeId);
11604
- }
11605
- shouldBeClearTree.dispose();
11606
- }
11607
11987
  _removeDependencyRTreeCache(treeId) {
11608
11988
  if (treeId == null) return;
11609
11989
  const treeRangeMap = this._allTreeMap.get(treeId);
11610
11990
  if (treeRangeMap) {
11611
11991
  const searchRanges = [];
11612
- for (let i = 0; i < treeRangeMap.rangeList.length; i++) {
11613
- const { unitId, sheetId, range } = treeRangeMap.rangeList[i];
11614
- searchRanges.push({
11615
- unitId,
11616
- sheetId,
11617
- range,
11618
- id: treeId
11619
- });
11620
- }
11992
+ for (const [unitId, sheetMap] of treeRangeMap) for (const [sheetId, range] of sheetMap) searchRanges.push({
11993
+ unitId,
11994
+ sheetId,
11995
+ range,
11996
+ id: treeId
11997
+ });
11621
11998
  this._dependencyRTreeCache.bulkRemove(searchRanges);
11622
11999
  }
11623
12000
  }
@@ -11628,23 +12005,100 @@ var DependencyManagerService = class extends DependencyManagerBaseService {
11628
12005
  if (treeSet) {
11629
12006
  for (const treeId of treeSet) {
11630
12007
  this._removeDependencyRTreeCache(treeId);
11631
- this.clearDependencyForTree(this._allTreeMap.get(treeId));
11632
12008
  this._removeAllTreeMap(treeId);
11633
12009
  }
11634
12010
  treeSet.clear();
11635
12011
  }
11636
12012
  }
11637
12013
  }
12014
+ openKdTree() {
12015
+ this._dependencyRTreeCache.openKdTree();
12016
+ }
12017
+ closeKdTree() {
12018
+ this._dependencyRTreeCache.closeKdTree();
12019
+ }
11638
12020
  _removeAllTreeMap(treeId) {
11639
12021
  if (treeId == null) return;
11640
12022
  this._allTreeMap.delete(treeId);
11641
12023
  }
11642
12024
  _addAllTreeMap(tree) {
11643
- this._allTreeMap.set(tree.treeId, tree);
12025
+ const rangeList = tree.rangeList;
12026
+ let oldTreeMap = this._allTreeMap.get(tree.treeId);
12027
+ for (let i = 0; i < rangeList.length; i++) {
12028
+ var _oldTreeMap$get, _oldTreeMap$get2;
12029
+ let { unitId, sheetId, range } = rangeList[i];
12030
+ if (!oldTreeMap) {
12031
+ oldTreeMap = /* @__PURE__ */ new Map();
12032
+ this._allTreeMap.set(tree.treeId, oldTreeMap);
12033
+ }
12034
+ if (!oldTreeMap.has(unitId)) oldTreeMap.set(unitId, /* @__PURE__ */ new Map());
12035
+ const oldRange = oldTreeMap === null || oldTreeMap === void 0 || (_oldTreeMap$get = oldTreeMap.get(unitId)) === null || _oldTreeMap$get === void 0 ? void 0 : _oldTreeMap$get.get(sheetId);
12036
+ if (oldRange) range = {
12037
+ startRow: Math.min(range.startRow, oldRange.startRow),
12038
+ startColumn: Math.min(range.startColumn, oldRange.startColumn),
12039
+ endRow: Math.max(range.endRow, oldRange.endRow),
12040
+ endColumn: Math.max(range.endColumn, oldRange.endColumn)
12041
+ };
12042
+ (_oldTreeMap$get2 = oldTreeMap.get(unitId)) === null || _oldTreeMap$get2 === void 0 || _oldTreeMap$get2.set(sheetId, range);
12043
+ }
11644
12044
  }
11645
- updateDependencyTreeDirtyState(treeId, isDirty) {
11646
- const tree = this._allTreeMap.get(treeId);
11647
- if (tree) tree.isDirty = isDirty;
12045
+ dispose() {
12046
+ super.dispose();
12047
+ this.reset();
12048
+ }
12049
+ buildDependencyTree(shouldBeBuildTrees, dependencyTrees = []) {
12050
+ const allTrees = this.getAllTree();
12051
+ if (shouldBeBuildTrees.length === 0) {
12052
+ this._buildReverseDependency(allTrees, dependencyTrees);
12053
+ return allTrees;
12054
+ }
12055
+ this._buildDependencyTree(allTrees, shouldBeBuildTrees);
12056
+ this._buildReverseDependency(allTrees, shouldBeBuildTrees);
12057
+ return allTrees;
12058
+ }
12059
+ /**
12060
+ * Build the dependency relationship between the trees.
12061
+ * @param allTrees all FormulaDependencyTree
12062
+ * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
12063
+ */
12064
+ _buildDependencyTree(allTrees, shouldBeBuildTrees) {
12065
+ const shouldBeBuildTreeMap = /* @__PURE__ */ new Map();
12066
+ for (let i = 0; i < shouldBeBuildTrees.length; i++) {
12067
+ const tree = shouldBeBuildTrees[i];
12068
+ shouldBeBuildTreeMap.set(tree.treeId, tree);
12069
+ }
12070
+ for (let i = 0; i < allTrees.length; i++) {
12071
+ const tree = allTrees[i];
12072
+ const RTreeItem = tree.toRTreeItem();
12073
+ const searchResults = this._dependencyRTreeCache.bulkSearch(RTreeItem);
12074
+ for (const id of searchResults) {
12075
+ const shouldBeBuildTree = shouldBeBuildTreeMap.get(id);
12076
+ if (shouldBeBuildTree && tree !== shouldBeBuildTree && !shouldBeBuildTree.hasChildren(tree.treeId)) shouldBeBuildTree.pushChildren(tree);
12077
+ }
12078
+ }
12079
+ shouldBeBuildTreeMap.clear();
12080
+ }
12081
+ /**
12082
+ * Build the reverse dependency relationship between the trees.
12083
+ * @param allTrees
12084
+ * @param dependencyTrees
12085
+ */
12086
+ _buildReverseDependency(allTrees, dependencyTrees) {
12087
+ const allTreeMap = /* @__PURE__ */ new Map();
12088
+ for (let i = 0; i < allTrees.length; i++) {
12089
+ const tree = allTrees[i];
12090
+ allTreeMap.set(tree.treeId, tree);
12091
+ }
12092
+ for (let i = 0; i < dependencyTrees.length; i++) {
12093
+ const tree = dependencyTrees[i];
12094
+ const RTreeItem = tree.toRTreeItem();
12095
+ const searchResults = this._dependencyRTreeCache.bulkSearch(RTreeItem);
12096
+ for (const id of searchResults) {
12097
+ const allTree = allTreeMap.get(id);
12098
+ if (allTree && tree !== allTree && !allTree.hasChildren(tree.treeId)) allTree.pushChildren(tree);
12099
+ }
12100
+ }
12101
+ allTreeMap.clear();
11648
12102
  }
11649
12103
  };
11650
12104
  const IDependencyManagerService = createIdentifier("univer.formula.dependency-manager.service");
@@ -12187,12 +12641,14 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12187
12641
  this._lexerTreeBuilder = _lexerTreeBuilder;
12188
12642
  _defineProperty(this, "_updateRangeFlattenCache", /* @__PURE__ */ new Map());
12189
12643
  _defineProperty(this, "_dependencyRTreeCacheForAddressFunction", new RTree());
12644
+ _defineProperty(this, "_dependencyTreeCache", /* @__PURE__ */ new Map());
12190
12645
  _defineProperty(this, "_executedAddressFunctionNodeIds", /* @__PURE__ */ new Set());
12191
12646
  _defineProperty(this, "_formulaDependencyTreeModel", /* @__PURE__ */ new Map());
12192
12647
  this._initUnitDispose();
12193
12648
  }
12194
12649
  dispose() {
12195
12650
  super.dispose();
12651
+ this._dependencyTreeCache.clear();
12196
12652
  this._updateRangeFlattenCache.clear();
12197
12653
  this._dependencyRTreeCacheForAddressFunction.clear();
12198
12654
  FORMULA_AST_CACHE.clear();
@@ -12222,87 +12678,301 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12222
12678
  });
12223
12679
  });
12224
12680
  const unitData = this._currentConfigService.getUnitData();
12225
- const treeList = await this._generateTreeList(formulaData, otherFormulaData, unitData);
12226
- if (isCalculateTreeModel) this._runtimeService.setDependencyTreeModelData(this._getAllDependencyJson(treeList));
12227
- const updateTreeList = this._getUpdateTreeListAndMakeDependency(treeList);
12228
- let finalTreeList = this._calculateRunList(updateTreeList);
12229
- if (this._dependencyFeatureCalculation(finalTreeList)) {
12230
- finalTreeList.forEach((tree) => {
12231
- tree.resetState();
12232
- });
12233
- finalTreeList = this._calculateRunList(finalTreeList);
12234
- }
12681
+ await this._generateTreeList(formulaData, otherFormulaData, unitData);
12682
+ this._dependencyManagerService.openKdTree();
12683
+ const updateTreeList = this._getUpdateTreeListAndMakeDependency();
12684
+ const finalTreeList = this._calculateRunList(updateTreeList);
12235
12685
  if (this._checkIsCycleDependency(finalTreeList)) this._runtimeService.enableCycleDependency();
12686
+ if (isCalculateTreeModel) this._runtimeService.setDependencyTreeModelData(this._getAllDependencyJson(Array.from(this._dependencyTreeCache.values())));
12687
+ this._dependencyTreeCache.clear();
12236
12688
  this._dependencyRTreeCacheForAddressFunction.clear();
12689
+ this._dependencyManagerService.closeKdTree();
12237
12690
  this._runtimeService.clearArrayObjectCache();
12238
12691
  return Promise.resolve(finalTreeList);
12239
12692
  }
12240
- _dependencyFeatureCalculation(newTreeList) {
12241
- const featureMap = this._featureCalculationManagerService.getReferenceExecutorMap();
12242
- if (featureMap.size === 0) return;
12693
+ _isCyclicUtilMap(treeId, colorMap) {
12694
+ const WHITE = 0;
12695
+ const GRAY = 1;
12696
+ const BLACK = 2;
12697
+ const stack = [treeId];
12698
+ while (stack.length > 0) {
12699
+ const currentTreeId = stack[stack.length - 1];
12700
+ if ((colorMap.get(currentTreeId) || WHITE) === WHITE) {
12701
+ colorMap.set(currentTreeId, GRAY);
12702
+ const node = this._dependencyTreeCache.get(currentTreeId);
12703
+ if (node == null) {
12704
+ colorMap.set(currentTreeId, BLACK);
12705
+ stack.pop();
12706
+ continue;
12707
+ }
12708
+ const parents = this._dependencyManagerService.searchDependency(node.toRTreeItem());
12709
+ for (const parentTreeId of parents) {
12710
+ const parentColor = colorMap.get(parentTreeId) || WHITE;
12711
+ if (parentColor === GRAY) return true;
12712
+ else if (parentColor === WHITE) stack.push(parentTreeId);
12713
+ }
12714
+ } else {
12715
+ colorMap.set(currentTreeId, BLACK);
12716
+ stack.pop();
12717
+ }
12718
+ }
12719
+ return false;
12720
+ }
12721
+ _checkIsCycleDependency(treeList) {
12722
+ const colorMap = /* @__PURE__ */ new Map();
12723
+ for (const tree of treeList) if (!colorMap.has(tree.treeId)) {
12724
+ if (this._isCyclicUtilMap(tree.treeId, colorMap)) return true;
12725
+ }
12726
+ colorMap.clear();
12727
+ return false;
12728
+ }
12729
+ _getFeatureFormulaTree(featureId, treeId, params) {
12730
+ const { unitId, subUnitId, dependencyRanges, getDirtyData } = params;
12731
+ const FDtree = new FormulaDependencyTree(treeId || generateRandomDependencyTreeId(this._dependencyManagerService));
12732
+ FDtree.unitId = unitId;
12733
+ FDtree.subUnitId = subUnitId;
12734
+ FDtree.rangeList = dependencyRanges;
12735
+ FDtree.getDirtyData = getDirtyData;
12736
+ const allDependency = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
12737
+ FDtree.featureDirtyRanges = this._convertDirtyRangesToUnitRange(allDependency.dirtyRanges);
12738
+ FDtree.featureId = featureId;
12739
+ FDtree.type = 2;
12740
+ this._dependencyManagerService.addFeatureFormulaDependency(unitId, subUnitId, featureId, FDtree);
12741
+ this._dependencyTreeCache.set(FDtree.treeId, FDtree);
12742
+ if (this._dependencyManagerService.getFeatureFormulaDependency(params.unitId, params.subUnitId, featureId)) FDtree.isCache = true;
12743
+ return FDtree;
12744
+ }
12745
+ _registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
12243
12746
  /**
12244
- * Clear the dependency relationships of all featureCalculation nodes in the tree.
12245
- * Because each execution requires rebuilding the reverse dependencies,
12246
- * the previous dependencies may become outdated due to data changes in applications such as pivot tables,
12247
- * which can result in an outdated dirty mark range.
12747
+ * Register formulas in doc, slide, and other types of applications.
12248
12748
  */
12249
- this._clearFeatureCalculationNode(newTreeList);
12250
- let hasFeatureCalculation = false;
12251
- featureMap.forEach((subUnitMap, _) => {
12252
- subUnitMap.forEach((featureMap, _) => {
12253
- featureMap.forEach((params, featureId) => {
12254
- const { unitId, subUnitId, getDirtyData } = params;
12255
- const allDependency = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
12256
- const dirtyRanges = this._convertDirtyRangesToUnitRange(allDependency.dirtyRanges);
12257
- const intersectTrees = this._intersectFeatureCalculation(dirtyRanges, newTreeList, {
12258
- unitId,
12259
- subUnitId,
12260
- featureId
12261
- });
12262
- if (intersectTrees.length > 0) {
12263
- let featureTree = this._getExistTreeList({
12264
- unitId,
12265
- subUnitId,
12266
- featureId
12267
- }, newTreeList);
12268
- if (featureTree == null) {
12269
- featureTree = this._getFeatureFormulaTree(featureId, generateRandomDependencyTreeId(this._dependencyManagerService), params);
12270
- newTreeList.push(featureTree);
12749
+ for (const unitId of otherFormulaDataKeys) {
12750
+ const subComponentData = otherFormulaData[unitId];
12751
+ if (subComponentData == null) continue;
12752
+ const subComponentKeys = Object.keys(subComponentData);
12753
+ for (const subUnitId of subComponentKeys) {
12754
+ const subFormulaData = subComponentData[subUnitId];
12755
+ if (subFormulaData == null) continue;
12756
+ const { rowCount = Infinity, columnCount = Infinity } = this._currentConfigService.getSheetRowColumnCount(unitId, subUnitId) || {};
12757
+ const subFormulaDataKeys = Object.keys(subFormulaData);
12758
+ for (const subFormulaDataId of subFormulaDataKeys) {
12759
+ var _treeMatrix$getValue;
12760
+ const hasOtherFormula = this._dependencyManagerService.hasOtherFormulaDataMainData(subFormulaDataId);
12761
+ const { f: formulaString, ranges } = subFormulaData[subFormulaDataId];
12762
+ let isCache = false;
12763
+ if (hasOtherFormula) isCache = true;
12764
+ const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
12765
+ const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
12766
+ const firstFDtree = new FormulaDependencyTree((_treeMatrix$getValue = treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) !== null && _treeMatrix$getValue !== void 0 ? _treeMatrix$getValue : generateRandomDependencyTreeId(this._dependencyManagerService));
12767
+ for (let i = 0; i < ranges.length; i++) {
12768
+ const range = ranges[i];
12769
+ const { startRow, startColumn } = range;
12770
+ let { endRow, endColumn } = range;
12771
+ endRow = Math.min(endRow, rowCount - 1);
12772
+ endColumn = Math.min(endColumn, columnCount - 1);
12773
+ for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
12774
+ const x = c - firstColumn;
12775
+ const y = r - firstRow;
12776
+ if (x === 0 && y === 0) {
12777
+ firstFDtree.formula = formulaString;
12778
+ firstFDtree.unitId = unitId;
12779
+ firstFDtree.subUnitId = subUnitId;
12780
+ firstFDtree.formulaId = subFormulaDataId;
12781
+ firstFDtree.type = 1;
12782
+ firstFDtree.isCache = isCache;
12783
+ treeList.push(firstFDtree);
12784
+ this._dependencyTreeCache.set(firstFDtree.treeId, firstFDtree);
12785
+ this._dependencyManagerService.addOtherFormulaDependency(unitId, subUnitId, subFormulaDataId, firstFDtree);
12786
+ this._dependencyManagerService.addFormulaDependencyByDefinedName(firstFDtree);
12787
+ continue;
12788
+ }
12789
+ const virtual = new FormulaDependencyTreeVirtual();
12790
+ virtual.treeId = (treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(x, y)) || generateRandomDependencyTreeId(this._dependencyManagerService);
12791
+ virtual.refTree = firstFDtree;
12792
+ virtual.refOffsetX = x;
12793
+ virtual.refOffsetY = y;
12794
+ virtual.isCache = isCache;
12795
+ virtual.type = 1;
12796
+ this._dependencyManagerService.addOtherFormulaDependency(unitId, subUnitId, subFormulaDataId, virtual);
12797
+ this._dependencyManagerService.addFormulaDependencyByDefinedName(virtual);
12798
+ treeList.push(virtual);
12799
+ this._dependencyTreeCache.set(virtual.treeId, virtual);
12271
12800
  }
12272
- featureTree.parents = /* @__PURE__ */ new Set();
12273
- intersectTrees.forEach((tree) => {
12274
- if (tree.hasChildren(featureTree.treeId)) return;
12275
- tree.pushChildren(featureTree);
12276
- });
12277
- hasFeatureCalculation = true;
12278
12801
  }
12802
+ this._dependencyManagerService.addOtherFormulaDependencyMainData(subFormulaDataId);
12803
+ }
12804
+ }
12805
+ }
12806
+ }
12807
+ _registerFormulas(formulaDataKeys, formulaData, unitData, treeList) {
12808
+ /**
12809
+ * Register formulas in the sheet.
12810
+ */
12811
+ for (const unitId of formulaDataKeys) {
12812
+ const sheetData = formulaData[unitId];
12813
+ if (sheetData == null) continue;
12814
+ const sheetDataKeys = Object.keys(sheetData);
12815
+ for (const sheetId of sheetDataKeys) {
12816
+ const matrixData = new ObjectMatrix(sheetData[sheetId] || {});
12817
+ const sIdCache = /* @__PURE__ */ new Map();
12818
+ matrixData.forValue((row, column, formulaDataItem) => {
12819
+ if (formulaDataItem == null) return true;
12820
+ const { x = 0, y = 0, si } = formulaDataItem;
12821
+ if (!(x === 0 && y === 0 && si != null)) return true;
12822
+ const FDtree = this._createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem);
12823
+ const treeId = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
12824
+ if (treeId != null) FDtree.treeId = treeId;
12825
+ else {
12826
+ this._dependencyManagerService.addFormulaDependency(unitId, sheetId, row, column, FDtree);
12827
+ this._dependencyManagerService.addFormulaDependencyByDefinedName(FDtree);
12828
+ }
12829
+ sIdCache.set(si, FDtree);
12830
+ treeList.push(FDtree);
12831
+ this._dependencyTreeCache.set(FDtree.treeId, FDtree);
12279
12832
  });
12280
- });
12281
- });
12282
- return hasFeatureCalculation;
12833
+ matrixData.forValue((row, column, formulaDataItem) => {
12834
+ if (formulaDataItem == null) return true;
12835
+ const { x = 0, y = 0, si } = formulaDataItem;
12836
+ if (x === 0 && y === 0 && si != null) return true;
12837
+ let FDtree;
12838
+ if (si && sIdCache.has(si)) {
12839
+ const cache = sIdCache.get(si);
12840
+ FDtree = this._createVirtualFDtree(cache, formulaDataItem);
12841
+ } else FDtree = this._createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem);
12842
+ const treeId = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
12843
+ if (treeId != null) FDtree.treeId = treeId;
12844
+ else {
12845
+ this._dependencyManagerService.addFormulaDependency(unitId, sheetId, row, column, FDtree);
12846
+ this._dependencyManagerService.addFormulaDependencyByDefinedName(FDtree);
12847
+ }
12848
+ treeList.push(FDtree);
12849
+ this._dependencyTreeCache.set(FDtree.treeId, FDtree);
12850
+ });
12851
+ sIdCache.clear();
12852
+ }
12853
+ }
12854
+ }
12855
+ _createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem) {
12856
+ const { f: formulaString, x = 0, y = 0 } = formulaDataItem;
12857
+ const FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
12858
+ const sheetItem = unitData[unitId][sheetId];
12859
+ FDtree.formula = formulaString;
12860
+ FDtree.unitId = unitId;
12861
+ FDtree.subUnitId = sheetId;
12862
+ FDtree.row = row;
12863
+ FDtree.column = column;
12864
+ FDtree.rowCount = sheetItem.rowCount;
12865
+ FDtree.columnCount = sheetItem.columnCount;
12866
+ return FDtree;
12283
12867
  }
12284
- _clearFeatureCalculationNode(newTreeList) {
12285
- const featureMap = this._featureCalculationManagerService.getReferenceExecutorMap();
12286
- newTreeList.forEach((tree) => {
12287
- const newChildren = /* @__PURE__ */ new Set();
12288
- for (const childTreeId of tree.children) {
12289
- var _featureMap$get;
12290
- const child = this._dependencyManagerService.getTreeById(childTreeId);
12291
- if (!child) continue;
12292
- if (!child.featureId) newChildren.add(childTreeId);
12293
- else if (!((_featureMap$get = featureMap.get(tree.unitId)) === null || _featureMap$get === void 0 || (_featureMap$get = _featureMap$get.get(tree.subUnitId)) === null || _featureMap$get === void 0 ? void 0 : _featureMap$get.has(child.featureId))) newChildren.add(childTreeId);
12868
+ /**
12869
+ * Build a formula dependency tree based on the dependency relationships.
12870
+ * @param treeList
12871
+ */
12872
+ _getUpdateTreeListAndMakeDependency() {
12873
+ const newTreeList = [];
12874
+ const existTree = /* @__PURE__ */ new Set();
12875
+ const forceCalculate = this._currentConfigService.isForceCalculate();
12876
+ const dirtyRanges = this._currentConfigService.getDirtyRanges();
12877
+ const treeIds = this._dependencyManagerService.searchDependency(dirtyRanges);
12878
+ const addressSearchResults = this._dependencyRTreeCacheForAddressFunction.bulkSearch(dirtyRanges);
12879
+ for (const addressSearchResult of addressSearchResults) treeIds.add(addressSearchResult);
12880
+ for (const [treeId, tree] of this._dependencyTreeCache)
12881
+ /**
12882
+ * forceCalculate: Mandatory calculation, adding all formulas to dependencies
12883
+ * tree.dependencyRange: Formula dependent modification range
12884
+ * includeTree: modification range contains formula
12885
+ */
12886
+ if ((forceCalculate || tree.isDirty || tree.dependencySheetName(this._currentConfigService.getDirtyNameMap()) || treeIds.has(treeId) && !tree.isExcludeRange(this._currentConfigService.getExcludedRange())) && !existTree.has(treeId)) {
12887
+ newTreeList.push(tree);
12888
+ existTree.add(treeId);
12889
+ }
12890
+ for (const [treeId, tree] of this._dependencyTreeCache) {
12891
+ if (tree.isVirtual) continue;
12892
+ tree.rangeList.length = 0;
12893
+ }
12894
+ return newTreeList;
12895
+ }
12896
+ _getTreeById(treeId) {
12897
+ return this._dependencyTreeCache.get(treeId);
12898
+ }
12899
+ _getTreeNode(tree) {
12900
+ return generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService);
12901
+ }
12902
+ *_traverse(treeList, skippedTreeIds) {
12903
+ const stack = treeList;
12904
+ const cacheStack = /* @__PURE__ */ new Set();
12905
+ while (stack.length > 0) {
12906
+ const tree = stack.pop();
12907
+ cacheStack.clear();
12908
+ if (tree === void 0 || tree.isSkip()) continue;
12909
+ if (tree.isAdded()) {
12910
+ yield tree;
12911
+ tree.setSkip();
12912
+ skippedTreeIds.add(tree.treeId);
12913
+ continue;
12294
12914
  }
12295
- tree.children = newChildren;
12296
- const newParents = /* @__PURE__ */ new Set();
12297
- for (const parentTreeId of tree.parents) {
12298
- var _featureMap$get2;
12299
- const parent = this._dependencyManagerService.getTreeById(parentTreeId);
12300
- if (!parent) continue;
12301
- if (!parent.featureId) newParents.add(parentTreeId);
12302
- else if (!((_featureMap$get2 = featureMap.get(tree.unitId)) === null || _featureMap$get2 === void 0 || (_featureMap$get2 = _featureMap$get2.get(tree.subUnitId)) === null || _featureMap$get2 === void 0 ? void 0 : _featureMap$get2.has(parent.featureId))) newParents.add(parentTreeId);
12915
+ const searchResults = this._dependencyManagerService.searchDependency(tree.toRTreeItem(), skippedTreeIds);
12916
+ const addressSearchResults = this._dependencyRTreeCacheForAddressFunction.bulkSearch(tree.toRTreeItem(), skippedTreeIds);
12917
+ for (const addressSearchResult of addressSearchResults) searchResults.add(addressSearchResult);
12918
+ for (const parentTreeId of searchResults) {
12919
+ const parentTree = this._dependencyTreeCache.get(parentTreeId);
12920
+ if (!parentTree) {
12921
+ console.error("Dependency tree not found for treeId:", parentTreeId);
12922
+ continue;
12923
+ }
12924
+ if (parentTree.isAdded() || tree.isSkip()) continue;
12925
+ cacheStack.add(parentTree);
12303
12926
  }
12304
- tree.parents = newParents;
12305
- });
12927
+ searchResults.clear();
12928
+ if (cacheStack.size === 0) {
12929
+ yield tree;
12930
+ tree.setSkip();
12931
+ skippedTreeIds.add(tree.treeId);
12932
+ } else {
12933
+ tree.setAdded();
12934
+ stack.push(tree);
12935
+ for (const cacheTree of cacheStack) stack.push(cacheTree);
12936
+ }
12937
+ }
12938
+ stack.length = 0;
12939
+ cacheStack.clear();
12940
+ }
12941
+ _calculateRunList(treeList) {
12942
+ const formulaRunList = [];
12943
+ const skippedTreeIds = /* @__PURE__ */ new Set();
12944
+ for (const tree of this._traverse(treeList, skippedTreeIds)) formulaRunList.push(tree);
12945
+ return formulaRunList;
12946
+ }
12947
+ async _getAllTreeList() {
12948
+ await this._initializeGenerateTreeList();
12949
+ return Array.from(this._dependencyTreeCache.values());
12950
+ }
12951
+ _getDependencyTreeParenIds(tree) {
12952
+ return this._dependencyManagerService.searchDependency(tree.toRTreeItem());
12953
+ }
12954
+ _getDependencyTreeChildrenIds(tree) {
12955
+ const childrenIds = /* @__PURE__ */ new Set();
12956
+ const rangeList = tree.rangeList;
12957
+ for (const [treeId, dependencyTree] of this._dependencyTreeCache) for (const unitRange of rangeList) {
12958
+ const unitId = unitRange.unitId;
12959
+ const sheetId = unitRange.sheetId;
12960
+ if (dependencyTree.unitId !== unitId || dependencyTree.subUnitId !== sheetId) continue;
12961
+ const range = unitRange.range;
12962
+ if (dependencyTree.inRangeData(range)) {
12963
+ childrenIds.add(treeId);
12964
+ break;
12965
+ }
12966
+ }
12967
+ return childrenIds;
12968
+ }
12969
+ _startFormulaDependencyTreeModel() {
12970
+ this._dependencyManagerService.openKdTree();
12971
+ }
12972
+ _endFormulaDependencyTreeModel() {
12973
+ this._formulaDependencyTreeModel.clear();
12974
+ this._dependencyTreeCache.clear();
12975
+ this._dependencyManagerService.closeKdTree();
12306
12976
  }
12307
12977
  /**
12308
12978
  * TODO @DR-Univer: The next step will be to try changing the incoming dirtyRanges to an array, thus avoiding conversion.
@@ -12324,23 +12994,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12324
12994
  }
12325
12995
  return unitRange;
12326
12996
  }
12327
- _intersectFeatureCalculation(dirtyRanges, newTreeList, param) {
12328
- const dependencyTree = [];
12329
- const treeIds = this._dependencyManagerService.searchDependency(dirtyRanges);
12330
- for (let i = 0, len = newTreeList.length; i < len; i++) {
12331
- const tree = newTreeList[i];
12332
- if (tree.unitId === param.unitId && tree.subUnitId === param.subUnitId && tree.featureId === param.featureId) continue;
12333
- if (treeIds.has(tree.treeId)) dependencyTree.push(tree);
12334
- }
12335
- return dependencyTree;
12336
- }
12337
- _getExistTreeList(param, treeList) {
12338
- const { unitId, subUnitId, featureId } = param;
12339
- for (let i = 0, len = treeList.length; i < len; i++) {
12340
- const tree = treeList[i];
12341
- if (tree.unitId === unitId && tree.subUnitId === subUnitId && tree.featureId === featureId) return tree;
12342
- }
12343
- }
12344
12997
  _isCyclicUtil(treeId, visited, recursionStack) {
12345
12998
  const node = this._dependencyManagerService.getTreeById(treeId);
12346
12999
  if (node == null) return false;
@@ -12355,15 +13008,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12355
13008
  recursionStack.delete(node.treeId);
12356
13009
  return false;
12357
13010
  }
12358
- _checkIsCycleDependency(treeList) {
12359
- const visited = /* @__PURE__ */ new Set();
12360
- const recursionStack = /* @__PURE__ */ new Set();
12361
- for (let i = 0, len = treeList.length; i < len; i++) {
12362
- const tree = treeList[i];
12363
- if (this._isCyclicUtil(tree.treeId, visited, recursionStack) === true) return true;
12364
- }
12365
- return false;
12366
- }
12367
13011
  /**
12368
13012
  * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
12369
13013
  * @param formulaData
@@ -12410,82 +13054,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12410
13054
  });
12411
13055
  });
12412
13056
  }
12413
- _getFeatureFormulaTree(featureId, treeId, params) {
12414
- const { unitId, subUnitId, dependencyRanges, getDirtyData } = params;
12415
- const FDtree = new FormulaDependencyTree(treeId || generateRandomDependencyTreeId(this._dependencyManagerService));
12416
- FDtree.unitId = unitId;
12417
- FDtree.subUnitId = subUnitId;
12418
- FDtree.rangeList = dependencyRanges;
12419
- FDtree.getDirtyData = getDirtyData;
12420
- const allDependency = getDirtyData(this._currentConfigService.getDirtyData(), this._runtimeService.getAllRuntimeData());
12421
- FDtree.featureDirtyRanges = this._convertDirtyRangesToUnitRange(allDependency.dirtyRanges);
12422
- FDtree.featureId = featureId;
12423
- FDtree.type = 2;
12424
- this._dependencyManagerService.addFeatureFormulaDependency(unitId, subUnitId, featureId, FDtree);
12425
- if (this._dependencyManagerService.getFeatureFormulaDependency(params.unitId, params.subUnitId, featureId)) FDtree.isCache = true;
12426
- return FDtree;
12427
- }
12428
- _registerOtherFormulas(otherFormulaData, otherFormulaDataKeys, treeList) {
12429
- /**
12430
- * Register formulas in doc, slide, and other types of applications.
12431
- */
12432
- for (const unitId of otherFormulaDataKeys) {
12433
- const subComponentData = otherFormulaData[unitId];
12434
- if (subComponentData == null) continue;
12435
- const subComponentKeys = Object.keys(subComponentData);
12436
- for (const subUnitId of subComponentKeys) {
12437
- const subFormulaData = subComponentData[subUnitId];
12438
- if (subFormulaData == null) continue;
12439
- const { rowCount = Infinity, columnCount = Infinity } = this._currentConfigService.getSheetRowColumnCount(unitId, subUnitId) || {};
12440
- const subFormulaDataKeys = Object.keys(subFormulaData);
12441
- for (const subFormulaDataId of subFormulaDataKeys) {
12442
- const hasOtherFormula = this._dependencyManagerService.hasOtherFormulaDataMainData(subFormulaDataId);
12443
- const { f: formulaString, ranges } = subFormulaData[subFormulaDataId];
12444
- let isCache = false;
12445
- if (hasOtherFormula) isCache = true;
12446
- const node = generateAstNode(unitId, formulaString, this._lexer, this._astTreeBuilder, this._currentConfigService);
12447
- const { firstRow, firstColumn } = this._getFirstCellOfRange(ranges);
12448
- const treeMatrix = this._dependencyManagerService.getOtherFormulaDependency(unitId, subUnitId, subFormulaDataId);
12449
- const firstFDtree = new FormulaDependencyTree((treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(0, 0)) || generateRandomDependencyTreeId(this._dependencyManagerService));
12450
- for (let i = 0; i < ranges.length; i++) {
12451
- const range = ranges[i];
12452
- const { startRow, startColumn } = range;
12453
- let { endRow, endColumn } = range;
12454
- endRow = Math.min(endRow, rowCount - 1);
12455
- endColumn = Math.min(endColumn, columnCount - 1);
12456
- for (let r = startRow; r <= endRow; r++) for (let c = startColumn; c <= endColumn; c++) {
12457
- const x = c - firstColumn;
12458
- const y = r - firstRow;
12459
- if (x === 0 && y === 0) {
12460
- firstFDtree.node = node;
12461
- firstFDtree.formula = formulaString;
12462
- firstFDtree.unitId = unitId;
12463
- firstFDtree.subUnitId = subUnitId;
12464
- firstFDtree.formulaId = subFormulaDataId;
12465
- firstFDtree.type = 1;
12466
- firstFDtree.isCache = isCache;
12467
- treeList.push(firstFDtree);
12468
- this._dependencyManagerService.addOtherFormulaDependency(unitId, subUnitId, subFormulaDataId, firstFDtree);
12469
- this._dependencyManagerService.addFormulaDependencyByDefinedName(firstFDtree);
12470
- continue;
12471
- }
12472
- const virtual = new FormulaDependencyTreeVirtual();
12473
- virtual.treeId = (treeMatrix === null || treeMatrix === void 0 ? void 0 : treeMatrix.getValue(x, y)) || generateRandomDependencyTreeId(this._dependencyManagerService);
12474
- virtual.refTree = firstFDtree;
12475
- virtual.refOffsetX = x;
12476
- virtual.refOffsetY = y;
12477
- virtual.isCache = isCache;
12478
- virtual.type = 1;
12479
- this._dependencyManagerService.addOtherFormulaDependency(unitId, subUnitId, subFormulaDataId, virtual);
12480
- this._dependencyManagerService.addFormulaDependencyByDefinedName(virtual);
12481
- treeList.push(virtual);
12482
- }
12483
- }
12484
- this._dependencyManagerService.addOtherFormulaDependencyMainData(subFormulaDataId);
12485
- }
12486
- }
12487
- }
12488
- }
12489
13057
  _getFirstCellOfRange(ranges) {
12490
13058
  const range = ranges[0];
12491
13059
  return {
@@ -12493,72 +13061,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12493
13061
  firstColumn: range.startColumn
12494
13062
  };
12495
13063
  }
12496
- _registerFormulas(formulaDataKeys, formulaData, unitData, treeList) {
12497
- /**
12498
- * Register formulas in the sheet.
12499
- */
12500
- for (const unitId of formulaDataKeys) {
12501
- const sheetData = formulaData[unitId];
12502
- if (sheetData == null) continue;
12503
- const sheetDataKeys = Object.keys(sheetData);
12504
- for (const sheetId of sheetDataKeys) {
12505
- const matrixData = new ObjectMatrix(sheetData[sheetId] || {});
12506
- const sIdCache = /* @__PURE__ */ new Map();
12507
- matrixData.forValue((row, column, formulaDataItem) => {
12508
- if (formulaDataItem == null) return true;
12509
- const { x = 0, y = 0, si } = formulaDataItem;
12510
- if (!(x === 0 && y === 0 && si != null)) return true;
12511
- const FDtree = this._createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem);
12512
- const treeId = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
12513
- if (treeId != null) {
12514
- FDtree.treeId = treeId;
12515
- FDtree.isCache = true;
12516
- this._dependencyManagerService.updateDependencyTreeDirtyState(treeId, false);
12517
- } else {
12518
- this._dependencyManagerService.addFormulaDependency(unitId, sheetId, row, column, FDtree);
12519
- this._dependencyManagerService.addFormulaDependencyByDefinedName(FDtree);
12520
- }
12521
- sIdCache.set(si, FDtree);
12522
- treeList.push(FDtree);
12523
- });
12524
- matrixData.forValue((row, column, formulaDataItem) => {
12525
- if (formulaDataItem == null) return true;
12526
- const { x = 0, y = 0, si } = formulaDataItem;
12527
- if (x === 0 && y === 0 && si != null) return true;
12528
- let FDtree;
12529
- if (si && sIdCache.has(si)) {
12530
- const cache = sIdCache.get(si);
12531
- FDtree = this._createVirtualFDtree(cache, formulaDataItem);
12532
- } else FDtree = this._createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem);
12533
- const treeId = this._dependencyManagerService.getFormulaDependency(unitId, sheetId, row, column);
12534
- if (treeId != null) {
12535
- FDtree.treeId = treeId;
12536
- FDtree.isCache = true;
12537
- this._dependencyManagerService.updateDependencyTreeDirtyState(treeId, false);
12538
- } else {
12539
- this._dependencyManagerService.addFormulaDependency(unitId, sheetId, row, column, FDtree);
12540
- this._dependencyManagerService.addFormulaDependencyByDefinedName(FDtree);
12541
- }
12542
- treeList.push(FDtree);
12543
- });
12544
- sIdCache.clear();
12545
- }
12546
- }
12547
- }
12548
- _createFDtree(unitId, sheetId, row, column, unitData, formulaDataItem) {
12549
- const { f: formulaString, x = 0, y = 0 } = formulaDataItem;
12550
- const FDtree = new FormulaDependencyTree(generateRandomDependencyTreeId(this._dependencyManagerService));
12551
- const sheetItem = unitData[unitId][sheetId];
12552
- FDtree.node = generateAstNode(unitId, formulaString, this._lexer, this._astTreeBuilder, this._currentConfigService);
12553
- FDtree.formula = formulaString;
12554
- FDtree.unitId = unitId;
12555
- FDtree.subUnitId = sheetId;
12556
- FDtree.row = row;
12557
- FDtree.column = column;
12558
- FDtree.rowCount = sheetItem.rowCount;
12559
- FDtree.columnCount = sheetItem.columnCount;
12560
- return FDtree;
12561
- }
12562
13064
  _createVirtualFDtree(tree, formulaDataItem) {
12563
13065
  const { x = 0, y = 0 } = formulaDataItem;
12564
13066
  const virtual = new FormulaDependencyTreeVirtual();
@@ -12668,9 +13170,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12668
13170
  this._nodeTraversalReferenceFunction(node, referenceFunctionList);
12669
13171
  return referenceFunctionList;
12670
13172
  }
12671
- _getTreeNode(tree) {
12672
- return tree.node;
12673
- }
12674
13173
  async _buildDirtyRangesByAddressFunction(treeDependencyCache, tree) {
12675
13174
  const addressFunctionNodes = tree.addressFunctionNodes;
12676
13175
  if (addressFunctionNodes.length === 0) return;
@@ -12773,9 +13272,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12773
13272
  if (newDirtyRanges.length > 0) this._searchDependencyByAddressFunction(treeDependencyCache, newDirtyRanges, searchResults);
12774
13273
  return searchResults;
12775
13274
  }
12776
- _getTreeById(treeId) {
12777
- return this._dependencyManagerService.getTreeById(treeId);
12778
- }
12779
13275
  _addDependencyTreeByAddressFunction(tree, addressFunctionRangeList) {
12780
13276
  const searchRanges = [];
12781
13277
  for (let i = 0; i < addressFunctionRangeList.length; i++) {
@@ -12804,33 +13300,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12804
13300
  }
12805
13301
  return rangeList;
12806
13302
  }
12807
- /**
12808
- * Build a formula dependency tree based on the dependency relationships.
12809
- * @param treeList
12810
- */
12811
- _getUpdateTreeListAndMakeDependency(treeList) {
12812
- const newTreeList = [];
12813
- const existTree = /* @__PURE__ */ new Set();
12814
- const forceCalculate = this._currentConfigService.isForceCalculate();
12815
- const dirtyRanges = this._currentConfigService.getDirtyRanges();
12816
- const treeIds = this._dependencyManagerService.searchDependency(dirtyRanges);
12817
- const addressSearchResults = this._dependencyRTreeCacheForAddressFunction.bulkSearch(dirtyRanges);
12818
- for (const addressSearchResult of addressSearchResults) treeIds.add(addressSearchResult);
12819
- const allTree = this._dependencyManagerService.buildDependencyTree(treeList);
12820
- for (const tree of allTree) {
12821
- const treeId = tree.treeId;
12822
- /**
12823
- * forceCalculate: Mandatory calculation, adding all formulas to dependencies
12824
- * tree.dependencyRange: Formula dependent modification range
12825
- * includeTree: modification range contains formula
12826
- */
12827
- if ((forceCalculate || tree.isDirty || tree.dependencySheetName(this._currentConfigService.getDirtyNameMap()) || treeIds.has(treeId) && !tree.isExcludeRange(this._currentConfigService.getExcludedRange())) && !existTree.has(treeId)) {
12828
- newTreeList.push(tree);
12829
- existTree.add(treeId);
12830
- }
12831
- }
12832
- return newTreeList;
12833
- }
12834
13303
  _includeTreeFeature(tree) {
12835
13304
  const unitId = tree.unitId;
12836
13305
  const subUnitId = tree.subUnitId;
@@ -12902,63 +13371,12 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12902
13371
  for (const range of ranges) if (tree.inRangeData(range)) return true;
12903
13372
  return false;
12904
13373
  }
12905
- /**
12906
- * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
12907
- * @param treeList
12908
- */
12909
- _calculateRunList(treeList) {
12910
- treeList.length;
12911
- const stack = treeList;
12912
- const formulaRunList = [];
12913
- const cacheStack = [];
12914
- while (stack.length > 0) {
12915
- const tree = stack.pop();
12916
- if (tree === void 0 || tree.isSkip()) continue;
12917
- if (tree.isAdded()) {
12918
- formulaRunList.push(tree);
12919
- tree.setSkip();
12920
- continue;
12921
- }
12922
- cacheStack.length = 0;
12923
- for (const parentTreeId of tree.parents) {
12924
- const parentTree = this._dependencyManagerService.getTreeById(parentTreeId);
12925
- if (!parentTree) {
12926
- console.error("Dependency tree not found for treeId:", parentTreeId);
12927
- continue;
12928
- }
12929
- if (parentTree.isAdded() || tree.isSkip()) continue;
12930
- cacheStack.push(parentTree);
12931
- }
12932
- const addressSearchResults = this._dependencyRTreeCacheForAddressFunction.bulkSearch(tree.toRTreeItem());
12933
- for (const parentTreeId of addressSearchResults) {
12934
- const parentTree = this._dependencyManagerService.getTreeById(parentTreeId);
12935
- if (!parentTree) {
12936
- console.error("Dependency tree not found for treeId:", parentTreeId);
12937
- continue;
12938
- }
12939
- if (parentTree.isAdded() || tree.isSkip()) continue;
12940
- cacheStack.push(parentTree);
12941
- }
12942
- if (cacheStack.length === 0) {
12943
- formulaRunList.push(tree);
12944
- tree.setSkip();
12945
- } else {
12946
- tree.setAdded();
12947
- stack.push(tree, ...cacheStack);
12948
- }
12949
- }
12950
- return formulaRunList;
12951
- }
12952
13374
  async _initializeGenerateTreeList() {
12953
13375
  const formulaData = this._currentConfigService.getFormulaData();
12954
13376
  const otherFormulaData = this._otherFormulaManagerService.getOtherFormulaData();
12955
13377
  const unitData = this._currentConfigService.getUnitData();
12956
13378
  return await this._generateTreeList(formulaData, otherFormulaData, unitData);
12957
13379
  }
12958
- async _getAllTreeList() {
12959
- const treeList = await this._initializeGenerateTreeList();
12960
- return this._dependencyManagerService.buildDependencyTree(treeList);
12961
- }
12962
13380
  _getTreeModel(treeId) {
12963
13381
  let treeModel = this._formulaDependencyTreeModel.get(treeId);
12964
13382
  if (!treeModel) {
@@ -12972,12 +13390,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12972
13390
  }
12973
13391
  return treeModel;
12974
13392
  }
12975
- _getDependencyTreeParenIds(tree) {
12976
- return tree.parents;
12977
- }
12978
- _getDependencyTreeChildrenIds(tree) {
12979
- return tree.children;
12980
- }
12981
13393
  _getFormulaDependencyTreeModel(tree) {
12982
13394
  const treeModel = this._getTreeModel(tree.treeId);
12983
13395
  const parentIds = this._getDependencyTreeParenIds(tree);
@@ -12990,10 +13402,6 @@ let FormulaDependencyGenerator = class FormulaDependencyGenerator extends Dispos
12990
13402
  }
12991
13403
  return treeModel;
12992
13404
  }
12993
- _endFormulaDependencyTreeModel() {
12994
- this._formulaDependencyTreeModel.clear();
12995
- }
12996
- _startFormulaDependencyTreeModel() {}
12997
13405
  _getAllDependencyJson(treeList) {
12998
13406
  this._startFormulaDependencyTreeModel();
12999
13407
  const results = [];
@@ -13241,7 +13649,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13241
13649
  if (isArrayFormulaState) this._runtimeService.setFormulaExecuteStage(5);
13242
13650
  else this._runtimeService.setFormulaExecuteStage(2);
13243
13651
  this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());
13244
- const treeList = (await this._formulaDependencyGenerator.generate(this._isCalculateTreeModel)).reverse();
13652
+ const treeList = await this._formulaDependencyGenerator.generate(this._isCalculateTreeModel);
13245
13653
  const interpreter = this._interpreter;
13246
13654
  if (isArrayFormulaState) {
13247
13655
  this._runtimeService.setFormulaExecuteStage(6);
@@ -13254,11 +13662,16 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13254
13662
  let pendingTasks = [];
13255
13663
  const config = this._configService.getConfig(ENGINE_FORMULA_PLUGIN_CONFIG_KEY);
13256
13664
  const intervalCount = (config === null || config === void 0 ? void 0 : config.intervalCount) || 500;
13665
+ let i = 0;
13257
13666
  const treeCount = treeList.length;
13258
- for (let i = 0; i < treeCount; i++) {
13259
- var _nodeData$node;
13260
- const tree = treeList[i];
13261
- const nodeData = tree.nodeData;
13667
+ while (treeList.length > 0) {
13668
+ const tree = treeList.pop();
13669
+ const node = generateAstNode(tree.unitId, tree.formula, this._lexer, this._astTreeBuilder, this._currentConfigService);
13670
+ const nodeData = {
13671
+ node,
13672
+ refOffsetX: tree.refOffsetX,
13673
+ refOffsetY: tree.refOffsetY
13674
+ };
13262
13675
  const getDirtyData = tree.getDirtyData;
13263
13676
  if (i % intervalCount === 0) {
13264
13677
  /**
@@ -13300,7 +13713,8 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13300
13713
  if (tree.formulaId != null) this._runtimeService.setRuntimeOtherData(tree.formulaId, tree.refOffsetX, tree.refOffsetY, value);
13301
13714
  else this._runtimeService.setRuntimeData(value);
13302
13715
  }
13303
- (_nodeData$node = nodeData.node) === null || _nodeData$node === void 0 || _nodeData$node.resetCalculationState();
13716
+ node.resetCalculationState();
13717
+ i++;
13304
13718
  }
13305
13719
  pendingTasks.forEach((cancel) => cancel());
13306
13720
  pendingTasks = [];
@@ -15813,13 +16227,26 @@ function isRowHidden(rowData, rowIndex) {
15813
16227
  if (!row) return false;
15814
16228
  return row.hd === BooleanNumber.TRUE;
15815
16229
  }
16230
+ const NESTED_AGGREGATE_FORMULA_CACHE = /* @__PURE__ */ new WeakMap();
15816
16231
  function isNestedAggregateOrSubtotal(cellData, rowIndex, columnIndex, sheetId, unitId, formulaDataModel) {
15817
16232
  const cellValue = cellData.getValue(rowIndex, columnIndex);
15818
- if ((cellValue === null || cellValue === void 0 ? void 0 : cellValue.f) || (cellValue === null || cellValue === void 0 ? void 0 : cellValue.si)) {
15819
- const formulaString = formulaDataModel.getFormulaStringByCell(rowIndex, columnIndex, sheetId, unitId);
15820
- if (formulaString && (formulaString.indexOf(`${"SUBTOTAL"}(`) > -1 || formulaString.indexOf(`${"AGGREGATE"}(`) > -1)) return true;
15821
- }
15822
- return false;
16233
+ if (!(cellValue === null || cellValue === void 0 ? void 0 : cellValue.f) && !(cellValue === null || cellValue === void 0 ? void 0 : cellValue.si)) return false;
16234
+ if (typeof cellValue.f === "string") return hasNestedAggregateFormula(cellValue.f);
16235
+ if (cellValue.si == null) return false;
16236
+ let cache = NESTED_AGGREGATE_FORMULA_CACHE.get(formulaDataModel);
16237
+ if (cache == null) {
16238
+ cache = /* @__PURE__ */ new Map();
16239
+ NESTED_AGGREGATE_FORMULA_CACHE.set(formulaDataModel, cache);
16240
+ }
16241
+ const cacheKey = `${unitId}\0${sheetId}\0${cellValue.si}`;
16242
+ const cached = cache.get(cacheKey);
16243
+ if (cached != null) return cached;
16244
+ const result = hasNestedAggregateFormula(formulaDataModel.getFormulaStringByCell(rowIndex, columnIndex, sheetId, unitId));
16245
+ cache.set(cacheKey, result);
16246
+ return result;
16247
+ }
16248
+ function hasNestedAggregateFormula(formulaString) {
16249
+ return !!formulaString && (formulaString.indexOf(`${"SUBTOTAL"}(`) > -1 || formulaString.indexOf(`${"AGGREGATE"}(`) > -1);
15823
16250
  }
15824
16251
  function getModeSnglResult(valueCountMap, valueMaxCount) {
15825
16252
  const result = Object.entries(valueCountMap).filter(([_, { count }]) => count === valueMaxCount).sort((a, b) => a[1].order - b[1].order).map(([value]) => +value);
@@ -15894,40 +16321,54 @@ function getAggregateResult(options, refs) {
15894
16321
  });
15895
16322
  if (errorValueObject === null || errorValueObject === void 0 ? void 0 : errorValueObject.isError()) return errorValueObject;
15896
16323
  }
16324
+ let result;
15897
16325
  switch (type) {
15898
16326
  case "AVERAGE":
15899
- if (n === 0) return ErrorValueObject.create("#DIV/0!");
15900
- return NumberValueObject.create(sum / n);
15901
- case "COUNT": return NumberValueObject.create(count);
15902
- case "COUNTA": return NumberValueObject.create(counta);
15903
- case "MAX": return NumberValueObject.create(max);
15904
- case "MIN": return NumberValueObject.create(min);
15905
- case "PRODUCT": return NumberValueObject.create(n === 0 ? 0 : product);
16327
+ result = n === 0 ? ErrorValueObject.create("#DIV/0!") : NumberValueObject.create(sum / n);
16328
+ break;
16329
+ case "COUNT":
16330
+ result = NumberValueObject.create(count);
16331
+ break;
16332
+ case "COUNTA":
16333
+ result = NumberValueObject.create(counta);
16334
+ break;
16335
+ case "MAX":
16336
+ result = NumberValueObject.create(max);
16337
+ break;
16338
+ case "MIN":
16339
+ result = NumberValueObject.create(min);
16340
+ break;
16341
+ case "PRODUCT":
16342
+ result = NumberValueObject.create(n === 0 ? 0 : product);
16343
+ break;
15906
16344
  case "STDEV":
15907
16345
  case "STDEV.S":
15908
- if (n < 2) return ErrorValueObject.create("#DIV/0!");
15909
- return createNewArray([valueObjects], 1, n).std(1);
16346
+ result = n < 2 ? ErrorValueObject.create("#DIV/0!") : createNewArray([valueObjects], 1, n).std(1);
16347
+ break;
15910
16348
  case "STDEVP":
15911
16349
  case "STDEV.P":
15912
- if (n === 0) return ErrorValueObject.create("#DIV/0!");
15913
- return createNewArray([valueObjects], 1, n).std();
15914
- case "SUM": return NumberValueObject.create(sum);
16350
+ result = n === 0 ? ErrorValueObject.create("#DIV/0!") : createNewArray([valueObjects], 1, n).std();
16351
+ break;
16352
+ case "SUM":
16353
+ result = NumberValueObject.create(sum);
16354
+ break;
15915
16355
  case "VAR":
15916
16356
  case "VAR.S":
15917
- if (n < 2) return ErrorValueObject.create("#DIV/0!");
15918
- return createNewArray([valueObjects], 1, n).var(1);
16357
+ result = n < 2 ? ErrorValueObject.create("#DIV/0!") : createNewArray([valueObjects], 1, n).var(1);
16358
+ break;
15919
16359
  case "VARP":
15920
16360
  case "VAR.P":
15921
- if (n === 0) return ErrorValueObject.create("#DIV/0!");
15922
- return createNewArray([valueObjects], 1, n).var();
16361
+ result = n === 0 ? ErrorValueObject.create("#DIV/0!") : createNewArray([valueObjects], 1, n).var();
16362
+ break;
15923
16363
  case "MEDIAN":
15924
- if (n === 0) return ErrorValueObject.create("#NUM!");
15925
- return getMedianResult(valueObjects.map((vo) => +vo.getValue()));
16364
+ result = n === 0 ? ErrorValueObject.create("#NUM!") : getMedianResult(valueObjects.map((vo) => +vo.getValue()));
16365
+ break;
15926
16366
  case "MODE.SNGL":
15927
- if (valueCountOrder === 0 || valueMaxCount === 1) return ErrorValueObject.create("#N/A");
15928
- return getModeSnglResult(valueCountMap, valueMaxCount);
15929
- default: return ErrorValueObject.create("#VALUE!");
16367
+ result = valueCountOrder === 0 || valueMaxCount === 1 ? ErrorValueObject.create("#N/A") : getModeSnglResult(valueCountMap, valueMaxCount);
16368
+ break;
16369
+ default: result = ErrorValueObject.create("#VALUE!");
15930
16370
  }
16371
+ return result;
15931
16372
  }
15932
16373
  function getArrayValuesByAggregateIgnoreOptions(array, options, formulaDataModel) {
15933
16374
  const { ignoreRowHidden = false, ignoreErrorValues = false, ignoreNested = false } = options !== null && options !== void 0 ? options : {};
@@ -39930,152 +40371,6 @@ const ALL_IMPLEMENTED_FUNCTIONS = [
39930
40371
  ];
39931
40372
  const ALL_IMPLEMENTED_FUNCTIONS_SET = new Set(ALL_IMPLEMENTED_FUNCTIONS.map(([_, name]) => name));
39932
40373
 
39933
- //#endregion
39934
- //#region src/functions/new-excel-functions.ts
39935
- const NEW_EXCEL_FUNCTIONS = new Set([
39936
- "ACOT",
39937
- "ACOTH",
39938
- "ARABIC",
39939
- "BASE",
39940
- "CEILING.MATH",
39941
- "CEILING.PRECISE",
39942
- "COMBINA",
39943
- "COT",
39944
- "COTH",
39945
- "CSC",
39946
- "CSCH",
39947
- "DECIMAL",
39948
- "FLOOR.MATH",
39949
- "FLOOR.PRECISE",
39950
- "MUNIT",
39951
- "RANDARRAY",
39952
- "SEC",
39953
- "SECH",
39954
- "SEQUENCE",
39955
- "CHOOSECOLS",
39956
- "CHOOSEROWS",
39957
- "DROP",
39958
- "EXPAND",
39959
- "FILTER",
39960
- "FORMULATEXT",
39961
- "HSTACK",
39962
- "SORT",
39963
- "SORTBY",
39964
- "TAKE",
39965
- "TOCOL",
39966
- "TOROW",
39967
- "UNIQUE",
39968
- "VSTACK",
39969
- "WRAPCOLS",
39970
- "WRAPROWS",
39971
- "XLOOKUP",
39972
- "XMATCH",
39973
- "BITAND",
39974
- "BITLSHIFT",
39975
- "BITOR",
39976
- "BITRSHIFT",
39977
- "BITXOR",
39978
- "ERF.PRECISE",
39979
- "ERFC.PRECISE",
39980
- "IMCOSH",
39981
- "IMCOT",
39982
- "IMCSC",
39983
- "IMCSCH",
39984
- "IMSEC",
39985
- "IMSECH",
39986
- "IMSINH",
39987
- "IMTAN",
39988
- "ISFORMULA",
39989
- "SHEET",
39990
- "SHEETS",
39991
- "IFNA",
39992
- "IFS",
39993
- "SWITCH",
39994
- "XOR",
39995
- "BETA.DIST",
39996
- "BETA.INV",
39997
- "BINOM.DIST",
39998
- "BINOM.DIST.RANGE",
39999
- "BINOM.INV",
40000
- "CHISQ.DIST",
40001
- "CHISQ.DIST.RT",
40002
- "CHISQ.INV",
40003
- "CHISQ.INV.RT",
40004
- "CHISQ.TEST",
40005
- "CONFIDENCE.NORM",
40006
- "CONFIDENCE.T",
40007
- "COVARIANCE.P",
40008
- "COVARIANCE.S",
40009
- "EXPON.DIST",
40010
- "F.DIST",
40011
- "F.DIST.RT",
40012
- "F.INV",
40013
- "F.INV.RT",
40014
- "F.TEST",
40015
- "FORECAST.LINEAR",
40016
- "GAMMA",
40017
- "GAMMA.DIST",
40018
- "GAMMA.INV",
40019
- "GAMMALN.PRECISE",
40020
- "GAUSS",
40021
- "HYPGEOM.DIST",
40022
- "LOGNORM.DIST",
40023
- "LOGNORM.INV",
40024
- "MAXIFS",
40025
- "MINIFS",
40026
- "MODE.MULT",
40027
- "MODE.SNGL",
40028
- "NEGBINOM.DIST",
40029
- "NORM.DIST",
40030
- "NORM.INV",
40031
- "NORM.S.DIST",
40032
- "NORM.S.INV",
40033
- "PERCENTILE.EXC",
40034
- "PERCENTILE.INC",
40035
- "PERCENTRANK.EXC",
40036
- "PERCENTRANK.INC",
40037
- "PERMUTATIONA",
40038
- "PHI",
40039
- "POISSON.DIST",
40040
- "QUARTILE.EXC",
40041
- "QUARTILE.INC",
40042
- "RANK.AVG",
40043
- "RANK.EQ",
40044
- "SKEW.P",
40045
- "STDEV.P",
40046
- "STDEV.S",
40047
- "T.DIST",
40048
- "T.DIST.2T",
40049
- "T.DIST.RT",
40050
- "T.INV",
40051
- "T.INV.2T",
40052
- "T.TEST",
40053
- "VAR.P",
40054
- "VAR.S",
40055
- "WEIBULL.DIST",
40056
- "Z.TEST",
40057
- "ARRAYTOTEXT",
40058
- "ENCODEURL",
40059
- "NUMBERVALUE",
40060
- "TEXTAFTER",
40061
- "TEXTBEFORE",
40062
- "TEXTJOIN",
40063
- "TEXTSPLIT",
40064
- "UNICHAR",
40065
- "UNICODE",
40066
- "VALUETOTEXT",
40067
- "DAYS",
40068
- "ISOWEEKNUM",
40069
- "PDURATION",
40070
- "RRI",
40071
- "BYCOL",
40072
- "BYROW",
40073
- "MAKEARRAY",
40074
- "MAP",
40075
- "REDUCE",
40076
- "SCAN"
40077
- ]);
40078
-
40079
40374
  //#endregion
40080
40375
  //#region src/functions/univer/function-names.ts
40081
40376
  /**
@@ -40122,7 +40417,7 @@ function getObjectValue(result, isUseStrip = false) {
40122
40417
  //#endregion
40123
40418
  //#region package.json
40124
40419
  var name = "@univerjs/engine-formula";
40125
- var version = "0.22.1";
40420
+ var version = "0.23.0";
40126
40421
 
40127
40422
  //#endregion
40128
40423
  //#region src/services/global-computing-status.service.ts
@@ -40521,6 +40816,7 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
40521
40816
  } }
40522
40817
  };
40523
40818
  this._commandService.executeCommand(SetOtherFormulaMutation.id, params, { onlyLocal: true }).then(() => {
40819
+ if (this._disposed) return;
40524
40820
  this._commandService.executeCommand(OtherFormulaMarkDirty.id, { [unitId]: { [subUnitId]: { [formulaId]: true } } }, { onlyLocal: true });
40525
40821
  });
40526
40822
  };
@@ -40689,4 +40985,4 @@ _defineProperty(UniverFormulaEnginePlugin, "version", version);
40689
40985
  UniverFormulaEnginePlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverFormulaEnginePlugin);
40690
40986
 
40691
40987
  //#endregion
40692
- export { ALL_IMPLEMENTED_FUNCTIONS, ALL_IMPLEMENTED_FUNCTIONS_SET, ActiveDirtyManagerService, ArrayValueObject, AstRootNodeFactory, AstTreeBuilder, AsyncArrayObject, AsyncCustomFunction, AsyncObject, BaseFunction, BaseReferenceObject, BaseValueObject, BooleanValue, BooleanValueObject, CalculateController, CalculateFormulaService, CustomFunction, DEFAULT_INTERVAL_COUNT, DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT, DefinedNamesService, DependencyManagerBaseService, DependencyManagerService, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, ERROR_TYPE_SET, ErrorType, ErrorValueObject, FUNCTION_NAMES_ARRAY, FUNCTION_NAMES_COMPATIBILITY, FUNCTION_NAMES_CUBE, FUNCTION_NAMES_DATABASE, FUNCTION_NAMES_DATE, FUNCTION_NAMES_ENGINEERING, FUNCTION_NAMES_FINANCIAL, FUNCTION_NAMES_INFORMATION, FUNCTION_NAMES_LOGICAL, FUNCTION_NAMES_LOOKUP, FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FUNCTION_NAMES_UNIVER, FUNCTION_NAMES_WEB, FeatureCalculationManagerService, FormulaCurrentConfigService, FormulaDataModel, FormulaDependencyGenerator, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeType, FormulaDependencyTreeVirtual, FormulaExecuteStageType, FormulaExecutedStateType, FormulaResultStatus, FormulaRuntimeService, FunctionNodeFactory, FunctionService, FunctionType, GlobalComputingStatusService, HyperlinkEngineFormulaService, IActiveDirtyManagerService, ICalculateFormulaService, IDefinedNamesService, IDependencyManagerService, IFeatureCalculationManagerService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaRuntimeService, IFunctionService, IHyperlinkEngineFormulaService, IOtherFormulaManagerService, ISheetRowFilteredService, ISuperTableService, Interpreter, LambdaNodeFactory, LambdaParameterNodeFactory, LambdaValueObjectObject, Lexer, LexerNode, LexerTreeBuilder, NEW_EXCEL_FUNCTIONS, NullValueObject, NumberValueObject, OPERATOR_TOKEN_SET, OperatorNodeFactory, OtherFormulaBizType, OtherFormulaManagerService, OtherFormulaMarkDirty, PrefixNodeFactory, RangeReferenceObject, ReferenceNodeFactory, RegisterFunctionMutation, RegisterOtherFormulaService, RemoveDefinedNameMutation, RemoveFeatureCalculationMutation, RemoveOtherFormulaMutation, RemoveSuperTableMutation, SUFFIX_TOKEN_SET, SetArrayFormulaDataMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFeatureCalculationMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDataMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetImageFormulaDataMutation, SetOtherFormulaMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetSuperTableMutation, SetSuperTableOptionMutation, SetTriggerFormulaCalculationStartMutation, SheetRowFilteredService, StringValueObject, SuffixNodeFactory, SuperTableService, UnionNodeFactory, UniverFormulaEnginePlugin, ValueNodeFactory, ValueObjectFactory, compareToken, convertUnitDataToRuntime, deserializeRangeForR1C1, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, excelDateSerial, extractFormulaError, functionArray, functionCompatibility, functionCube, functionDatabase, functionDate, functionEngineering, functionFinancial, functionInformation, functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, functionText, functionUniver, functionWeb, generateAstNode, generateExecuteAstNodeData, generateRandomDependencyTreeId, generateStringWithSequence, getAbsoluteRefTypeWitString, getAbsoluteRefTypeWithSingleString, getObjectValue, getRangeWithRefsString, handleNumfmtInCell, handleRefStringInfo, includeFormulaLexerToken, initSheetFormulaData, isFormulaLexerToken, isInDirtyRange, isReferenceString, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchRefDrawToken, matchToken, needsQuoting, normalizeSheetName, operatorToken, prefixToken, quoteSheetName, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, splitTableStructuredRef, strip, stripErrorMargin, unquoteSheetName };
40988
+ export { ALL_IMPLEMENTED_FUNCTIONS, ALL_IMPLEMENTED_FUNCTIONS_SET, ActiveDirtyManagerService, ArrayValueObject, AstRootNodeFactory, AstTreeBuilder, AsyncArrayObject, AsyncCustomFunction, AsyncObject, BaseFunction, BaseReferenceObject, BaseValueObject, BooleanValue, BooleanValueObject, CELL_INVERTED_INDEX_CACHE, CalculateController, CalculateFormulaService, CustomFunction, DEFAULT_CYCLE_REFERENCE_COUNT, DEFAULT_INTERVAL_COUNT, DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT, DefinedNamesService, DependencyManagerBaseService, DependencyManagerService, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, ERROR_TYPE_SET, ErrorType, ErrorValueObject, FORMULA_REF_TO_ARRAY_CACHE, FUNCTION_NAMES_ARRAY, FUNCTION_NAMES_COMPATIBILITY, FUNCTION_NAMES_CUBE, FUNCTION_NAMES_DATABASE, FUNCTION_NAMES_DATE, FUNCTION_NAMES_ENGINEERING, FUNCTION_NAMES_FINANCIAL, FUNCTION_NAMES_INFORMATION, FUNCTION_NAMES_LOGICAL, FUNCTION_NAMES_LOOKUP, FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FUNCTION_NAMES_UNIVER, FUNCTION_NAMES_WEB, FeatureCalculationManagerService, FormulaCurrentConfigService, FormulaDataModel, FormulaDependencyGenerator, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeType, FormulaDependencyTreeVirtual, FormulaExecuteStageType, FormulaExecutedStateType, FormulaResultStatus, FormulaRuntimeService, FunctionNodeFactory, FunctionService, FunctionType, GlobalComputingStatusService, HyperlinkEngineFormulaService, IActiveDirtyManagerService, ICalculateFormulaService, IDefinedNamesService, IDependencyManagerService, IFeatureCalculationManagerService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaRuntimeService, IFunctionService, IHyperlinkEngineFormulaService, IOtherFormulaManagerService, ISheetRowFilteredService, ISuperTableService, Interpreter, LambdaNodeFactory, LambdaParameterNodeFactory, LambdaValueObjectObject, Lexer, LexerNode, LexerTreeBuilder, NEW_EXCEL_FUNCTIONS, NullValueObject, NumberValueObject, OPERATOR_TOKEN_SET, OperatorNodeFactory, OtherFormulaBizType, OtherFormulaManagerService, OtherFormulaMarkDirty, PrefixNodeFactory, RangeReferenceObject, ReferenceNodeFactory, RegisterFunctionMutation, RegisterOtherFormulaService, RemoveDefinedNameMutation, RemoveFeatureCalculationMutation, RemoveOtherFormulaMutation, RemoveSuperTableMutation, SUFFIX_TOKEN_SET, SetArrayFormulaDataMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFeatureCalculationMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDataMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetImageFormulaDataMutation, SetOtherFormulaMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetSuperTableMutation, SetSuperTableOptionMutation, SetTriggerFormulaCalculationStartMutation, SheetRowFilteredService, StringValueObject, SuffixNodeFactory, SuperTableService, UnionNodeFactory, UniverFormulaEnginePlugin, ValueNodeFactory, ValueObjectFactory, compareToken, convertUnitDataToRuntime, deserializeRangeForR1C1, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, excelDateSerial, extractFormulaError, functionArray, functionCompatibility, functionCube, functionDatabase, functionDate, functionEngineering, functionFinancial, functionInformation, functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, functionText, functionUniver, functionWeb, generateAstNode, generateExecuteAstNodeData, generateRandomDependencyTreeId, generateStringWithSequence, getAbsoluteRefTypeWitString, getAbsoluteRefTypeWithSingleString, getObjectValue, getRangeWithRefsString, handleNumfmtInCell, handleRefStringInfo, includeFormulaLexerToken, initSheetFormulaData, isFormulaLexerToken, isInDirtyRange, isReferenceString, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchRefDrawToken, matchToken, needsQuoting, normalizeSheetName, operatorToken, prefixToken, quoteSheetName, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, splitTableStructuredRef, strip, stripErrorMargin, unquoteSheetName };