@syncfusion/ej2-calculate 35.1.37

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.
Files changed (173) hide show
  1. package/.eslintrc.json +263 -0
  2. package/README.md +132 -0
  3. package/base.d.ts +4 -0
  4. package/base.js +4 -0
  5. package/common.d.ts +4 -0
  6. package/common.js +4 -0
  7. package/dist/ej2-calculate.umd.min.js +11 -0
  8. package/dist/ej2-calculate.umd.min.js.map +1 -0
  9. package/dist/es6/ej2-calculate.es2015.js +24801 -0
  10. package/dist/es6/ej2-calculate.es2015.js.map +1 -0
  11. package/dist/es6/ej2-calculate.es5.js +27229 -0
  12. package/dist/es6/ej2-calculate.es5.js.map +1 -0
  13. package/dist/global/ej2-calculate.min.js +11 -0
  14. package/dist/global/ej2-calculate.min.js.map +1 -0
  15. package/dist/global/index.d.ts +14 -0
  16. package/formulas.d.ts +4 -0
  17. package/formulas.js +4 -0
  18. package/index.d.ts +4 -0
  19. package/index.js +4 -0
  20. package/license +10 -0
  21. package/package.json +30 -0
  22. package/src/base/calculate-model.d.ts +4 -0
  23. package/src/base/calculate-model.js +0 -0
  24. package/src/base/calculate.d.ts +1105 -0
  25. package/src/base/calculate.js +4720 -0
  26. package/src/base/index.d.ts +8 -0
  27. package/src/base/index.js +7 -0
  28. package/src/base/parser.d.ts +208 -0
  29. package/src/base/parser.js +1512 -0
  30. package/src/common/address.d.ts +59 -0
  31. package/src/common/address.js +96 -0
  32. package/src/common/cell-ref.d.ts +32 -0
  33. package/src/common/cell-ref.js +112 -0
  34. package/src/common/common.d.ts +44 -0
  35. package/src/common/common.js +134 -0
  36. package/src/common/enum.d.ts +94 -0
  37. package/src/common/enum.js +97 -0
  38. package/src/common/index.d.ts +9 -0
  39. package/src/common/index.js +8 -0
  40. package/src/common/interface.d.ts +122 -0
  41. package/src/common/interface.js +0 -0
  42. package/src/common/l10n.d.ts +24 -0
  43. package/src/common/l10n.js +54 -0
  44. package/src/common/number-date.d.ts +26 -0
  45. package/src/common/number-date.js +38 -0
  46. package/src/common/sheet-info.d.ts +10 -0
  47. package/src/common/sheet-info.js +17 -0
  48. package/src/common/sort.d.ts +17 -0
  49. package/src/common/sort.js +44 -0
  50. package/src/formulas/array.d.ts +47 -0
  51. package/src/formulas/array.js +718 -0
  52. package/src/formulas/basic.d.ts +47 -0
  53. package/src/formulas/basic.js +181 -0
  54. package/src/formulas/complex-numbers.d.ts +207 -0
  55. package/src/formulas/complex-numbers.js +549 -0
  56. package/src/formulas/database.d.ts +152 -0
  57. package/src/formulas/database.js +579 -0
  58. package/src/formulas/date-time-extra.d.ts +97 -0
  59. package/src/formulas/date-time-extra.js +415 -0
  60. package/src/formulas/date-time-intl.d.ts +57 -0
  61. package/src/formulas/date-time-intl.js +309 -0
  62. package/src/formulas/date-time.d.ts +164 -0
  63. package/src/formulas/date-time.js +1021 -0
  64. package/src/formulas/engineering-base.d.ts +150 -0
  65. package/src/formulas/engineering-base.js +404 -0
  66. package/src/formulas/engineering-bessel.d.ts +65 -0
  67. package/src/formulas/engineering-bessel.js +167 -0
  68. package/src/formulas/engineering-convert.d.ts +35 -0
  69. package/src/formulas/engineering-convert.js +120 -0
  70. package/src/formulas/engineering-misc.d.ts +64 -0
  71. package/src/formulas/engineering-misc.js +168 -0
  72. package/src/formulas/financial-amortization-ecma.d.ts +87 -0
  73. package/src/formulas/financial-amortization-ecma.js +288 -0
  74. package/src/formulas/financial-annuity.d.ts +104 -0
  75. package/src/formulas/financial-annuity.js +419 -0
  76. package/src/formulas/financial-bond-helpers.d.ts +106 -0
  77. package/src/formulas/financial-bond-helpers.js +190 -0
  78. package/src/formulas/financial-cashflow.d.ts +47 -0
  79. package/src/formulas/financial-cashflow.js +203 -0
  80. package/src/formulas/financial-coupons.d.ts +227 -0
  81. package/src/formulas/financial-coupons.js +810 -0
  82. package/src/formulas/financial-depreciation.d.ts +64 -0
  83. package/src/formulas/financial-depreciation.js +247 -0
  84. package/src/formulas/financial-rates.d.ts +54 -0
  85. package/src/formulas/financial-rates.js +140 -0
  86. package/src/formulas/financial-securities.d.ts +126 -0
  87. package/src/formulas/financial-securities.js +488 -0
  88. package/src/formulas/formula-math-helpers.d.ts +212 -0
  89. package/src/formulas/formula-math-helpers.js +599 -0
  90. package/src/formulas/formula-module-base.d.ts +54 -0
  91. package/src/formulas/formula-module-base.js +125 -0
  92. package/src/formulas/formula-owner.d.ts +17 -0
  93. package/src/formulas/formula-owner.js +0 -0
  94. package/src/formulas/index.d.ts +68 -0
  95. package/src/formulas/index.js +67 -0
  96. package/src/formulas/information-advanced.d.ts +44 -0
  97. package/src/formulas/information-advanced.js +157 -0
  98. package/src/formulas/information-ecma.d.ts +33 -0
  99. package/src/formulas/information-ecma.js +88 -0
  100. package/src/formulas/information-extra.d.ts +146 -0
  101. package/src/formulas/information-extra.js +351 -0
  102. package/src/formulas/information.d.ts +34 -0
  103. package/src/formulas/information.js +78 -0
  104. package/src/formulas/logical-extra.d.ts +75 -0
  105. package/src/formulas/logical-extra.js +217 -0
  106. package/src/formulas/logical.d.ts +83 -0
  107. package/src/formulas/logical.js +296 -0
  108. package/src/formulas/lookup-array.d.ts +98 -0
  109. package/src/formulas/lookup-array.js +364 -0
  110. package/src/formulas/lookup-ref-extra.d.ts +64 -0
  111. package/src/formulas/lookup-ref-extra.js +180 -0
  112. package/src/formulas/lookup-ref.d.ts +84 -0
  113. package/src/formulas/lookup-ref.js +263 -0
  114. package/src/formulas/lookup.d.ts +114 -0
  115. package/src/formulas/lookup.js +881 -0
  116. package/src/formulas/math-aggregate.d.ts +74 -0
  117. package/src/formulas/math-aggregate.js +376 -0
  118. package/src/formulas/math-ceiling-ecma.d.ts +42 -0
  119. package/src/formulas/math-ceiling-ecma.js +123 -0
  120. package/src/formulas/math-combinatorics.d.ts +75 -0
  121. package/src/formulas/math-combinatorics.js +290 -0
  122. package/src/formulas/math-misc.d.ts +164 -0
  123. package/src/formulas/math-misc.js +889 -0
  124. package/src/formulas/math-number.d.ts +76 -0
  125. package/src/formulas/math-number.js +261 -0
  126. package/src/formulas/math-rounding.d.ts +115 -0
  127. package/src/formulas/math-rounding.js +728 -0
  128. package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
  129. package/src/formulas/math-trig-hyperbolic.js +113 -0
  130. package/src/formulas/math-trig.d.ts +165 -0
  131. package/src/formulas/math-trig.js +334 -0
  132. package/src/formulas/matrix-base.d.ts +13 -0
  133. package/src/formulas/matrix-base.js +169 -0
  134. package/src/formulas/matrix.d.ts +64 -0
  135. package/src/formulas/matrix.js +161 -0
  136. package/src/formulas/regression-ecma.d.ts +66 -0
  137. package/src/formulas/regression-ecma.js +234 -0
  138. package/src/formulas/statistical-advanced.d.ts +125 -0
  139. package/src/formulas/statistical-advanced.js +756 -0
  140. package/src/formulas/statistical-correlation.d.ts +75 -0
  141. package/src/formulas/statistical-correlation.js +198 -0
  142. package/src/formulas/statistical-dispersion.d.ts +108 -0
  143. package/src/formulas/statistical-dispersion.js +337 -0
  144. package/src/formulas/statistical-distribution-extended.d.ts +176 -0
  145. package/src/formulas/statistical-distribution-extended.js +668 -0
  146. package/src/formulas/statistical-distribution.d.ts +104 -0
  147. package/src/formulas/statistical-distribution.js +368 -0
  148. package/src/formulas/statistical-ecma.d.ts +95 -0
  149. package/src/formulas/statistical-ecma.js +392 -0
  150. package/src/formulas/statistical-extended.d.ts +136 -0
  151. package/src/formulas/statistical-extended.js +340 -0
  152. package/src/formulas/statistical-ifs.d.ts +46 -0
  153. package/src/formulas/statistical-ifs.js +180 -0
  154. package/src/formulas/statistical-moments.d.ts +84 -0
  155. package/src/formulas/statistical-moments.js +269 -0
  156. package/src/formulas/statistical-percentile.d.ts +56 -0
  157. package/src/formulas/statistical-percentile.js +195 -0
  158. package/src/formulas/statistical-sample-base.d.ts +14 -0
  159. package/src/formulas/statistical-sample-base.js +124 -0
  160. package/src/formulas/statistical.d.ts +135 -0
  161. package/src/formulas/statistical.js +542 -0
  162. package/src/formulas/text-advanced.d.ts +64 -0
  163. package/src/formulas/text-advanced.js +222 -0
  164. package/src/formulas/text-ecma.d.ts +54 -0
  165. package/src/formulas/text-ecma.js +106 -0
  166. package/src/formulas/text-extra.d.ts +216 -0
  167. package/src/formulas/text-extra.js +657 -0
  168. package/src/formulas/text.d.ts +125 -0
  169. package/src/formulas/text.js +628 -0
  170. package/src/global.js +1 -0
  171. package/src/index.d.ts +14 -0
  172. package/src/index.js +14 -0
  173. package/tslint.json +111 -0
@@ -0,0 +1,881 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings, CommonErrors, getSkeletonVal } from '../common/index';
15
+ import { getAlphalabel } from '../base/index';
16
+ import { isNullOrUndefined, Internationalization } from '@syncfusion/ej2-base';
17
+ import { dateToInt, isNumber } from '../common/number-date';
18
+ import { getCellAddress, getRangeIndexes } from '../common/address';
19
+ import { FormulaModuleBase } from './formula-module-base';
20
+ /**
21
+ * Vertical and horizontal table lookups (VLOOKUP, HLOOKUP) and reference indexing.
22
+ *
23
+ * Registers 9 functions including CHOOSE, INDEX, MATCH, LOOKUP, VLOOKUP, and others.
24
+ *
25
+ * @hidden
26
+ */
27
+ var LookupFormulas = /** @class */ (function (_super) {
28
+ __extends(LookupFormulas, _super);
29
+ /**
30
+ * @hidden
31
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
32
+ */
33
+ function LookupFormulas(owner) {
34
+ var _this = _super.call(this, owner) || this;
35
+ /** Formula definitions registered with {@link BasicFormulas}. */
36
+ _this.formulas = [
37
+ { formulaName: 'CHOOSE', category: 'Lookup & Reference', description: 'Returns a value from a list, given an index number.' },
38
+ { formulaName: 'INDEX', category: 'Lookup & Reference', description: 'Returns a value from a table, given a row and column number.' },
39
+ { formulaName: 'MATCH', category: 'Lookup & Reference', description: 'Returns the relative position of an checked item in range that matches a specified value in a specified order' },
40
+ { formulaName: 'LOOKUP', category: 'Lookup & Reference', description: 'Looks for a value in a one-row or one-column range, then returns a value from the same position in a second one-row or one-column range.' },
41
+ { formulaName: 'VLOOKUP', category: 'Lookup & Reference', description: 'Looks for a specific value in the first column of a lookup range and returns a corresponding value from a different column within the same row.' },
42
+ { formulaName: 'HLOOKUP', category: 'Lookup & Reference', description: 'Looks for a value in the top row of the array of values and then returns a value in the same column from a row in the array that you specify.' },
43
+ { formulaName: 'ADDRESS', category: 'Lookup & Reference', description: 'Returns a cell reference as text, given specified row and column numbers.' },
44
+ { formulaName: 'SUBTOTAL', category: 'Lookup & Reference', description: 'Returns a subtotal in a list or database.' },
45
+ { formulaName: 'TEXT', category: 'Lookup & Reference', description: 'Converts a value to text in specified number format.' }
46
+ ];
47
+ return _this;
48
+ }
49
+ /**
50
+ * Returns a value from a list, given an index number.
51
+ *
52
+ * Excel: `CHOOSE(...)`.
53
+ *
54
+ * @hidden
55
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
56
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * engine.computeFormula('=CHOOSE(1)');
61
+ * ```
62
+ */
63
+ LookupFormulas.prototype.ComputeCHOOSE = function () {
64
+ var _this = this;
65
+ var args = [];
66
+ for (var _i = 0; _i < arguments.length; _i++) {
67
+ args[_i] = arguments[_i];
68
+ }
69
+ if (isNullOrUndefined(args) || (args[0] === '' && args.length === 1)) {
70
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
71
+ }
72
+ else if (args.length < 2) {
73
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
74
+ }
75
+ var errCollection = this.parent.getErrorStrings();
76
+ var processArgs = function (actuaValue) {
77
+ actuaValue = _this.parent.getValueFromArg(actuaValue);
78
+ if (actuaValue.toUpperCase() === _this.parent.trueValue) {
79
+ actuaValue = '1';
80
+ }
81
+ else if (actuaValue.toUpperCase() === _this.parent.falseValue) {
82
+ actuaValue = '0';
83
+ }
84
+ return actuaValue;
85
+ };
86
+ var getIndexValue;
87
+ getIndexValue = processArgs(args[0]);
88
+ if (errCollection.indexOf(getIndexValue) > -1) {
89
+ return getIndexValue;
90
+ }
91
+ if (this.parent.isCellReference(args[0])) {
92
+ if (args[0].indexOf(':') > -1) {
93
+ return errCollection[CommonErrors.Value];
94
+ }
95
+ }
96
+ else {
97
+ getIndexValue = this.parent.removeTics(getIndexValue);
98
+ if (getIndexValue.split('%').length === 2 && this.parent.isNumber(getIndexValue.split('%')[0])) {
99
+ getIndexValue = (Number(getIndexValue.split('%')[0]) * 0.01).toString();
100
+ }
101
+ }
102
+ getIndexValue = Math.floor(this.parent.parseFloat(getIndexValue));
103
+ if (getIndexValue < 1 || isNaN(getIndexValue) || isNullOrUndefined(args[getIndexValue])) {
104
+ return errCollection[CommonErrors.Value];
105
+ }
106
+ getIndexValue = args[getIndexValue];
107
+ if (getIndexValue === '') {
108
+ getIndexValue = '0';
109
+ }
110
+ if (this.parent.isCellReference(getIndexValue)) {
111
+ if (getIndexValue.indexOf(':') > -1) {
112
+ return errCollection[CommonErrors.Value];
113
+ }
114
+ return this.parent.getValueFromArg(getIndexValue);
115
+ }
116
+ else {
117
+ if (getIndexValue.indexOf(this.parent.tic) > -1 && (errCollection.indexOf(getIndexValue.split(this.parent.tic).join('')) > -1 ||
118
+ (this.parent.removeTics(getIndexValue).match(/^(\d*\.\d+|\d+)\s*[-*/]\s*(\d*\.\d+|\d+)$/)))) {
119
+ getIndexValue = this.parent.removeTics(getIndexValue);
120
+ }
121
+ getIndexValue = this.parent.removeTics(this.parent.getValueFromArg(getIndexValue));
122
+ if (getIndexValue.indexOf(this.parent.tic + this.parent.tic) > -1) {
123
+ return getIndexValue.replace(/""/g, this.parent.tic);
124
+ }
125
+ if (getIndexValue.split('%').length === 2 && this.parent.isNumber(getIndexValue.split('%')[0])) {
126
+ getIndexValue = (Number(getIndexValue.split('%')[0]) * 0.01).toString();
127
+ }
128
+ return getIndexValue;
129
+ }
130
+ };
131
+ /**
132
+ * Returns a value from a table, given a row and column number.
133
+ *
134
+ * Excel: `INDEX(...)`.
135
+ *
136
+ * @hidden
137
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
138
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
139
+ */
140
+ LookupFormulas.prototype.ComputeINDEX = function () {
141
+ var _this = this;
142
+ var args = [];
143
+ for (var _i = 0; _i < arguments.length; _i++) {
144
+ args[_i] = arguments[_i];
145
+ }
146
+ var nestedFormula;
147
+ var value;
148
+ var errCollection = this.parent.getErrorStrings();
149
+ if (args.length && args[args.length - 1] === 'nestedFormulaTrue') {
150
+ nestedFormula = true;
151
+ args.pop();
152
+ }
153
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
154
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
155
+ }
156
+ else if (args.length < 2 || args.length > 4) {
157
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
158
+ }
159
+ else if (args[0] === '' || args[3] === '' || (args[3] && (args[3] === '0' || args[3] === 'FALSE'))) {
160
+ return errCollection[CommonErrors.Value];
161
+ }
162
+ var row;
163
+ var col;
164
+ var area;
165
+ var processArgs = function (actualValue) {
166
+ if (isNullOrUndefined(actualValue) || actualValue === '') {
167
+ return 1;
168
+ }
169
+ var value = _this.parent.getValueFromArg(actualValue);
170
+ if (errCollection.indexOf(value) > -1) {
171
+ return value;
172
+ }
173
+ if (value.toUpperCase() === _this.parent.trueValue) {
174
+ value = '1';
175
+ }
176
+ else if (value.toUpperCase() === _this.parent.falseValue) {
177
+ value = '0';
178
+ }
179
+ if (value.indexOf(_this.parent.tic) > -1) {
180
+ value = _this.parent.removeTics(value);
181
+ if (actualValue.indexOf(_this.parent.tic) === -1 || value.trim() === '') {
182
+ return errCollection[CommonErrors.Value];
183
+ }
184
+ }
185
+ if (value.split('%').length === 2 && _this.parent.isNumber(value.split('%')[0])) {
186
+ value = (Number(value.split('%')[0]) / 100).toString();
187
+ }
188
+ value = parseInt(Number(value).toString(), 10);
189
+ if (isNaN(value) || value < 0) {
190
+ return errCollection[CommonErrors.Value];
191
+ }
192
+ else if (value === 0) {
193
+ value = 1;
194
+ }
195
+ return value;
196
+ };
197
+ if (args[3]) {
198
+ area = processArgs(args[3]);
199
+ if (errCollection.indexOf(area.toString()) > -1) {
200
+ return area.toString();
201
+ }
202
+ }
203
+ if (args[0].startsWith(this.parent.tic) && args[0].endsWith(this.parent.tic)) {
204
+ args[0] = args[0].substring(1, args[0].length - 1);
205
+ }
206
+ var rangeArr = args[0].split(this.parent.getParseArgumentSeparator());
207
+ args[0] = rangeArr[area ? area - 1 : 0];
208
+ if (!args[0]) {
209
+ return errCollection[CommonErrors.Ref];
210
+ }
211
+ value = args[0];
212
+ row = processArgs(args[1]);
213
+ if (errCollection.indexOf(row.toString()) > -1) {
214
+ return row.toString();
215
+ }
216
+ col = processArgs(args[2]);
217
+ if (errCollection.indexOf(col.toString()) > -1) {
218
+ return col.toString();
219
+ }
220
+ var i = value.indexOf(':');
221
+ if (i === -1) {
222
+ if (row > 1 || col > 1) {
223
+ return errCollection[CommonErrors.Ref];
224
+ }
225
+ value = this.parent.isCellReference(value) ? this.parent.getValueFromArg(value) : value;
226
+ }
227
+ else {
228
+ var startRow = this.parent.rowIndex(value.substring(0, i));
229
+ var endRow = this.parent.rowIndex(value.substring(i + 1));
230
+ var startCol = this.parent.colIndex(value.substring(0, i));
231
+ var endCol = this.parent.colIndex(value.substring(i + 1));
232
+ if (row > endRow - startRow + 1 || col > endCol - startCol + 1) {
233
+ return errCollection[CommonErrors.Ref];
234
+ }
235
+ row = startRow + row - 1;
236
+ col = startCol + col - 1;
237
+ value = this.parent.getValueFromArg(this.getSheetReference(value) + this.parent.convertAlpha(col) + row);
238
+ }
239
+ if (value === '') {
240
+ return 0;
241
+ }
242
+ if (nestedFormula && errCollection.indexOf(value) === -1 &&
243
+ !this.parent.isNumber(value) && value !== this.parent.trueValue && value !== this.parent.falseValue) {
244
+ return this.parent.tic + value + this.parent.tic;
245
+ }
246
+ return value;
247
+ };
248
+ /**
249
+ * Returns the relative position of an checked item in range that matches a specified value in a specified order.
250
+ *
251
+ * Excel: `MATCH(...)`.
252
+ *
253
+ * @hidden
254
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
255
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
256
+ */
257
+ LookupFormulas.prototype.ComputeMATCH = function () {
258
+ var _this = this;
259
+ var args = [];
260
+ for (var _i = 0; _i < arguments.length; _i++) {
261
+ args[_i] = arguments[_i];
262
+ }
263
+ var argArr = args.slice();
264
+ var errCollection = this.parent.getErrorStrings();
265
+ if (isNullOrUndefined(argArr) || (argArr.length === 1 && argArr[0] === '')) {
266
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
267
+ }
268
+ else if (argArr.length < 2 || argArr.length > 3) {
269
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
270
+ }
271
+ // args[0] codes
272
+ argArr[0] = this.parent.getValueFromArg(args[0]);
273
+ var isStringValue = argArr[0].indexOf(this.parent.tic) > -1;
274
+ argArr[0] = argArr[0].split(this.parent.tic).join('');
275
+ if (errCollection.indexOf(argArr[0]) > -1) {
276
+ return argArr[0];
277
+ }
278
+ if (argArr[0] === '') {
279
+ return errCollection[CommonErrors.NA];
280
+ }
281
+ if (isNaN(Number(argArr[0]))) {
282
+ isStringValue = true;
283
+ }
284
+ // args[2] codes
285
+ var matchType;
286
+ if (isNullOrUndefined(args[2])) {
287
+ argArr[2] = '1';
288
+ }
289
+ else {
290
+ argArr[2] = this.parent.getValueFromArg(argArr[2]);
291
+ if ((argArr[2].indexOf(this.parent.tic) > -1) && isNaN(Number(argArr[2].split(this.parent.tic).join('')))) {
292
+ return errCollection[CommonErrors.Value];
293
+ }
294
+ if (argArr[2].toUpperCase() === this.parent.trueValue) {
295
+ argArr[2] = '1';
296
+ }
297
+ else if (argArr[2].toUpperCase() === this.parent.falseValue) {
298
+ argArr[2] = '0';
299
+ }
300
+ }
301
+ matchType = parseFloat(argArr[2]);
302
+ if ([-1, 0, 1].indexOf(matchType) === -1) {
303
+ matchType = 0;
304
+ }
305
+ // args[1] codes
306
+ var valueCollection = [];
307
+ var isStringCollection = false;
308
+ var grid = this.parent.grid;
309
+ var curGrid = this.parent.grid;
310
+ var isWildCardVal;
311
+ if (argArr[1].indexOf(':') > -1 || this.parent.isCellReference(argArr[1])) {
312
+ var cellIdxs = getRangeIndexes(argArr[1]);
313
+ var startRow = cellIdxs[0];
314
+ var startCol = cellIdxs[1];
315
+ var endRow_1 = cellIdxs[2];
316
+ var endCol_1 = cellIdxs[3];
317
+ if (startRow >= 1048576 || endRow_1 >= 1048576 || startCol >= 16384 || endCol_1 >= 16384) {
318
+ return errCollection[CommonErrors.Name];
319
+ }
320
+ if (startRow !== endRow_1 && startCol !== endCol_1) {
321
+ return errCollection[CommonErrors.NA];
322
+ }
323
+ var sheetToken = '';
324
+ var family = this.parent.getSheetFamilyItem(grid);
325
+ if (argArr[1].startsWith('!')) {
326
+ sheetToken = argArr[1].substring(0, argArr[1].replace('!', '').indexOf('!') + 2);
327
+ if (family.tokenToParentObject !== null) {
328
+ grid = family.tokenToParentObject.get(sheetToken);
329
+ }
330
+ }
331
+ else if (family.parentObjectToToken !== null) {
332
+ sheetToken = family.parentObjectToToken.get(grid);
333
+ }
334
+ var sheetId = this.parent.getSheetId(grid);
335
+ var getCellValue = this.parent.getCellValueFn(grid, this.parent.cell, sheetId, true);
336
+ var j_1 = 0;
337
+ var cellValue_1;
338
+ var performAction = void 0;
339
+ var result_1;
340
+ if (matchType === 0) {
341
+ isWildCardVal = argArr[0].indexOf('*') > -1 || argArr[0].indexOf('?') > -1;
342
+ performAction = function () {
343
+ if (isWildCardVal) {
344
+ cellValue_1 = _this.parent.findWildCardValue(argArr[0], cellValue_1);
345
+ }
346
+ if (argArr[0] === cellValue_1) {
347
+ endCol_1 = -2;
348
+ endRow_1 = -2;
349
+ result_1 = j_1 + 1;
350
+ return;
351
+ }
352
+ j_1++;
353
+ };
354
+ }
355
+ else {
356
+ performAction = function () {
357
+ valueCollection[j_1] = cellValue_1;
358
+ j_1++;
359
+ };
360
+ }
361
+ for (var r = startRow; r <= endRow_1; r++) {
362
+ for (var c = startCol; c <= endCol_1; c++) {
363
+ cellValue_1 = getCellValue(r + 1, c + 1, getCellAddress(r, c));
364
+ if (!isStringCollection && isNaN(Number(cellValue_1))) {
365
+ isStringCollection = true;
366
+ }
367
+ performAction();
368
+ }
369
+ }
370
+ if (result_1) {
371
+ this.parent.grid = curGrid;
372
+ return result_1;
373
+ }
374
+ if (isStringValue !== isStringCollection) {
375
+ this.parent.grid = curGrid;
376
+ return errCollection[CommonErrors.NA];
377
+ }
378
+ }
379
+ else if (!isNullOrUndefined(argArr[1]) && argArr[1].includes(this.parent.tic + this.parent.tic)) {
380
+ var criterias = argArr[1].split(this.parent.tic + this.parent.tic);
381
+ criterias.forEach(function (criteria) {
382
+ criteria = criteria.trim().split(_this.parent.tic).join('');
383
+ if (criteria) {
384
+ valueCollection.push(criteria);
385
+ }
386
+ });
387
+ }
388
+ var index = 0;
389
+ var indexVal = '';
390
+ var isIndexFound = false;
391
+ var matchValue = !isNaN(Number(argArr[0])) ? Number(argArr[0]) : argArr[0];
392
+ for (var i = 0; i < valueCollection.length; i++) {
393
+ if (valueCollection[i] === '') {
394
+ if (i === (valueCollection.length - 1)) {
395
+ valueCollection.pop();
396
+ }
397
+ continue;
398
+ }
399
+ else if (matchType === -1 && (isStringValue || isStringCollection)) {
400
+ break;
401
+ }
402
+ var matchCollectionValue = !isNaN(Number(valueCollection[i])) ?
403
+ Number(valueCollection[i]) : valueCollection[i];
404
+ if (matchType === 1) {
405
+ if (matchValue === matchCollectionValue) {
406
+ index = i + 1;
407
+ isIndexFound = true;
408
+ if (isNaN(Number(argArr[0]))) {
409
+ isStringValue = false;
410
+ }
411
+ }
412
+ else if ((matchValue > matchCollectionValue) && !isStringValue && !isIndexFound) {
413
+ if (!indexVal || (matchCollectionValue > (!isNaN(Number(indexVal)) ? Number(indexVal) : indexVal))) {
414
+ index = i + 1;
415
+ indexVal = valueCollection[i];
416
+ }
417
+ }
418
+ }
419
+ else if (matchType === 0) {
420
+ if (isWildCardVal) {
421
+ valueCollection[i] = this.parent.findWildCardValue(argArr[0], valueCollection[i]);
422
+ }
423
+ if (argArr[0] === valueCollection[i]) {
424
+ return i + 1;
425
+ }
426
+ }
427
+ else if (matchType === -1) {
428
+ if ((Number(valueCollection[i]) > Number(valueCollection[i + 1]))
429
+ || i === valueCollection.length - 1) {
430
+ if (matchValue === matchCollectionValue) {
431
+ index = i + 1;
432
+ matchValue = undefined;
433
+ }
434
+ else if (matchValue < matchCollectionValue) {
435
+ if (!indexVal || (matchCollectionValue < (!isNaN(Number(indexVal)) ? Number(indexVal) : indexVal))) {
436
+ index = i + 1;
437
+ indexVal = valueCollection[i];
438
+ }
439
+ }
440
+ }
441
+ else {
442
+ this.parent.grid = curGrid;
443
+ return errCollection[CommonErrors.NA];
444
+ }
445
+ }
446
+ }
447
+ if (isStringValue && isStringCollection && matchType === 1) {
448
+ index = valueCollection.length;
449
+ }
450
+ this.parent.grid = curGrid;
451
+ return index ? index : errCollection[CommonErrors.NA];
452
+ };
453
+ /**
454
+ * Looks for a value in a one-row or one-column range, then returns a value from the same position in a second one-row or one-column range.
455
+ *
456
+ * Excel: `LOOKUP(...)`.
457
+ *
458
+ * @hidden
459
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
460
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
461
+ */
462
+ LookupFormulas.prototype.ComputeLOOKUP = function () {
463
+ var args = [];
464
+ for (var _i = 0; _i < arguments.length; _i++) {
465
+ args[_i] = arguments[_i];
466
+ }
467
+ var argArr = args;
468
+ if (isNullOrUndefined(argArr) || (argArr.length === 1 && argArr[0] === '')) {
469
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
470
+ }
471
+ return this.parent.computeLookup(argArr);
472
+ };
473
+ /**
474
+ * Looks for a specific value in the first column of a lookup range and returns a corresponding value from a different column within the same row.
475
+ *
476
+ * Excel: `VLOOKUP(...)`.
477
+ *
478
+ * @hidden
479
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
480
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
481
+ */
482
+ LookupFormulas.prototype.ComputeVLOOKUP = function () {
483
+ var args = [];
484
+ for (var _i = 0; _i < arguments.length; _i++) {
485
+ args[_i] = arguments[_i];
486
+ }
487
+ var argArr = args;
488
+ return this.parent.computeVHLookup(argArr, true);
489
+ };
490
+ /**
491
+ * Looks for a value in the top row of the array of values and then returns a value in the same column from a row in the array that you specify.
492
+ *
493
+ * Excel: `HLOOKUP(...)`.
494
+ *
495
+ * @hidden
496
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
497
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
498
+ */
499
+ LookupFormulas.prototype.ComputeHLOOKUP = function () {
500
+ var args = [];
501
+ for (var _i = 0; _i < arguments.length; _i++) {
502
+ args[_i] = arguments[_i];
503
+ }
504
+ var argArr = args;
505
+ return this.parent.computeVHLookup(argArr);
506
+ };
507
+ /**
508
+ * Returns a cell reference as text, given specified row and column numbers.
509
+ *
510
+ * Excel: `ADDRESS(...)`.
511
+ *
512
+ * @hidden
513
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
514
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
515
+ */
516
+ LookupFormulas.prototype.ComputeADDRESS = function () {
517
+ var _this = this;
518
+ var args = [];
519
+ for (var _i = 0; _i < arguments.length; _i++) {
520
+ args[_i] = arguments[_i];
521
+ }
522
+ var value;
523
+ var errCollection = this.parent.getErrorStrings();
524
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0].trim() === '')) {
525
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
526
+ }
527
+ else if (args.length < 2 || args.length > 5) {
528
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
529
+ }
530
+ else if (args[0].split(this.parent.tic).join('').trim() === '' || args[1].split(this.parent.tic).join('').trim() === '') {
531
+ return errCollection[CommonErrors.Value];
532
+ }
533
+ var processArgs = function (actualValue) {
534
+ var value = _this.parent.getValueFromArg(actualValue).trim();
535
+ if (errCollection.indexOf(value) > -1) {
536
+ return value;
537
+ }
538
+ if (value.toUpperCase() === _this.parent.trueValue) {
539
+ value = '1';
540
+ }
541
+ else if (value.toUpperCase() === _this.parent.falseValue) {
542
+ value = '0';
543
+ }
544
+ if (_this.parent.isCellReference(actualValue) && value.indexOf(_this.parent.tic) > -1) {
545
+ return errCollection[CommonErrors.Value];
546
+ }
547
+ value = _this.parent.removeTics(value);
548
+ if (value.split('%').length === 2 && _this.parent.isNumber(value.split('%')[0])) {
549
+ value = (Number(value.split('%')[0]) / 100).toString();
550
+ }
551
+ return value;
552
+ };
553
+ /* For argArr[0] */
554
+ var rowIndex = processArgs(args[0], 0);
555
+ if (errCollection.indexOf(rowIndex) > -1) {
556
+ return rowIndex;
557
+ }
558
+ rowIndex = Number(rowIndex);
559
+ if (isNaN(rowIndex) || rowIndex < 1) {
560
+ return errCollection[CommonErrors.Value];
561
+ }
562
+ else {
563
+ rowIndex = rowIndex.toString();
564
+ }
565
+ /* For argArr[1] */
566
+ var colIndex = processArgs(args[1], 1);
567
+ if (errCollection.indexOf(colIndex) > -1) {
568
+ return colIndex;
569
+ }
570
+ colIndex = Number(colIndex);
571
+ if (isNaN(colIndex) || colIndex < 1) {
572
+ return errCollection[CommonErrors.Value];
573
+ }
574
+ else {
575
+ colIndex = colIndex.toString();
576
+ }
577
+ /* For argArr[2] */
578
+ var absIndex;
579
+ var refStyle;
580
+ if (isNullOrUndefined(args[2]) || args[2].trim() === '') {
581
+ absIndex = '1';
582
+ }
583
+ else {
584
+ absIndex = processArgs(args[2], 2);
585
+ if (errCollection.indexOf(absIndex) > -1) {
586
+ return absIndex;
587
+ }
588
+ absIndex = Number(absIndex);
589
+ if (isNaN(absIndex) || absIndex < 1 || absIndex > 4) {
590
+ return errCollection[CommonErrors.Value];
591
+ }
592
+ else {
593
+ absIndex = absIndex.toString();
594
+ }
595
+ }
596
+ if (isNullOrUndefined(args[3]) || args[3].trim() === '') {
597
+ refStyle = '1';
598
+ }
599
+ else {
600
+ refStyle = processArgs(args[3], 3);
601
+ if (errCollection.indexOf(refStyle) > -1) {
602
+ return refStyle;
603
+ }
604
+ if (refStyle.toUpperCase() === this.parent.trueValue || Number(refStyle) > 1) {
605
+ refStyle = '1';
606
+ }
607
+ else if (refStyle === '' || refStyle.toUpperCase() === this.parent.falseValue) {
608
+ refStyle = '0';
609
+ }
610
+ }
611
+ if (refStyle === '1') {
612
+ if (absIndex === '1') {
613
+ value = '$' + getAlphalabel(parseInt(colIndex, 10)) + '$' + parseInt(rowIndex, 10);
614
+ }
615
+ else if (absIndex === '2') {
616
+ value = getAlphalabel(parseInt(colIndex, 10)) + '$' + parseInt(rowIndex, 10);
617
+ }
618
+ else if (absIndex === '3') {
619
+ value = '$' + getAlphalabel(parseInt(colIndex, 10)) + parseInt(rowIndex, 10);
620
+ }
621
+ else if (absIndex === '4') {
622
+ value = getAlphalabel(parseInt(colIndex, 10)) + parseInt(rowIndex, 10);
623
+ }
624
+ }
625
+ else if (refStyle === '0') {
626
+ if (absIndex === '1') {
627
+ value = 'R' + parseInt(rowIndex, 10) + 'C' + parseInt(colIndex, 10);
628
+ }
629
+ else if (absIndex === '2') {
630
+ value = 'R' + parseInt(rowIndex, 10) + 'C[' + parseInt(colIndex, 10) + ']';
631
+ }
632
+ else if (absIndex === '3') {
633
+ value = 'R[' + parseInt(rowIndex, 10) + ']C' + parseInt(colIndex, 10);
634
+ }
635
+ else if (absIndex === '4') {
636
+ value = 'R[' + parseInt(rowIndex, 10) + ']C[' + parseInt(colIndex, 10) + ']';
637
+ }
638
+ }
639
+ else {
640
+ return errCollection[CommonErrors.Name];
641
+ }
642
+ var val;
643
+ if (!isNullOrUndefined(args[4]) && args[4] !== '') {
644
+ val = this.parent.getValueFromArg(args[4]).split(this.parent.tic).join('');
645
+ if (errCollection.indexOf(val) > -1) {
646
+ return val;
647
+ }
648
+ }
649
+ if (!isNullOrUndefined(val)) {
650
+ value = val + '!' + value;
651
+ }
652
+ return value;
653
+ };
654
+ /**
655
+ * Returns a subtotal in a list or database.
656
+ *
657
+ * Excel: `SUBTOTAL(...)`.
658
+ *
659
+ * @hidden
660
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
661
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
662
+ */
663
+ LookupFormulas.prototype.ComputeSUBTOTAL = function () {
664
+ var args = [];
665
+ for (var _i = 0; _i < arguments.length; _i++) {
666
+ args[_i] = arguments[_i];
667
+ }
668
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
669
+ var value;
670
+ var errCollection = this.parent.getErrorStrings();
671
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
672
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
673
+ }
674
+ else if (args.length < 2) {
675
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
676
+ }
677
+ value = this.parent.getValueFromArg(args[0]).trim();
678
+ if (errCollection.indexOf(value) > -1) {
679
+ return value;
680
+ }
681
+ if (value.split(this.parent.tic).join('').trim() === '') {
682
+ return errCollection[CommonErrors.Value];
683
+ }
684
+ if (!this.parent.isCellReference(args[0])) {
685
+ value = this.parent.removeTics(value);
686
+ }
687
+ if (value.toUpperCase() === this.parent.trueValue) {
688
+ value = '1';
689
+ }
690
+ else if (value.toUpperCase() === this.parent.falseValue) {
691
+ value = '0';
692
+ }
693
+ else if (value.split('%').length === 2 && this.parent.isNumber(value.split('%')[0])) {
694
+ value = (Number(value.split('%')[0]) / 100).toString();
695
+ }
696
+ value = this.parent.parseFloat(value);
697
+ if (isNaN(value) || ((1 > value || value > 11) && (101 > value || value > 111))) {
698
+ return errCollection[CommonErrors.Value];
699
+ }
700
+ var cellRef = args.slice(1, args.length);
701
+ switch (value) {
702
+ case 1:
703
+ case 101:
704
+ value = (_a = this.owner).ComputeAVERAGE.apply(_a, cellRef.concat(['isSubtotal']));
705
+ break;
706
+ case 2:
707
+ case 102:
708
+ value = (_b = this.owner).ComputeCOUNT.apply(_b, cellRef.concat(['isSubtotal']));
709
+ break;
710
+ case 3:
711
+ case 103:
712
+ value = (_c = this.owner).ComputeCOUNTA.apply(_c, cellRef.concat(['isSubtotal']));
713
+ break;
714
+ case 4:
715
+ case 104:
716
+ value = (_d = this.owner).ComputeMAX.apply(_d, cellRef.concat(['isSubtotal']));
717
+ break;
718
+ case 5:
719
+ case 105:
720
+ value = (_e = this.owner).ComputeMIN.apply(_e, cellRef.concat(['isSubtotal']));
721
+ break;
722
+ case 6:
723
+ case 106:
724
+ value = (_f = this.owner).ComputePRODUCT.apply(_f, cellRef.concat(['isSubtotal']));
725
+ break;
726
+ case 7:
727
+ case 107:
728
+ value = (_g = this.owner).ComputeDAY.apply(_g, cellRef);
729
+ break;
730
+ case 8:
731
+ case 108:
732
+ value = (_h = this.owner).ComputeCONCAT.apply(_h, cellRef);
733
+ break;
734
+ case 9:
735
+ case 109:
736
+ value = (_j = this.owner).ComputeSUM.apply(_j, cellRef.concat(['isSubtotal']));
737
+ break;
738
+ case 10:
739
+ case 110:
740
+ value = (_k = this.owner).ComputeAVERAGEA.apply(_k, cellRef);
741
+ break;
742
+ case 11:
743
+ case 111:
744
+ value = (_l = this.owner).ComputeABS.apply(_l, cellRef);
745
+ break;
746
+ default:
747
+ value = errCollection[CommonErrors.Value];
748
+ break;
749
+ }
750
+ return value;
751
+ };
752
+ /**
753
+ * Converts a value to text in specified number format.
754
+ *
755
+ * Excel: `TEXT(...)`.
756
+ *
757
+ * @hidden
758
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
759
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
760
+ */
761
+ LookupFormulas.prototype.ComputeTEXT = function () {
762
+ var args = [];
763
+ for (var _i = 0; _i < arguments.length; _i++) {
764
+ args[_i] = arguments[_i];
765
+ }
766
+ var nestedFormula;
767
+ if (args.length && args[args.length - 1] === 'nestedFormulaTrue') {
768
+ nestedFormula = true;
769
+ args.pop();
770
+ }
771
+ var argsLength = args.length;
772
+ var firstArg = args[0];
773
+ var secondArg = args[1];
774
+ if (argsLength !== 2) {
775
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
776
+ }
777
+ var s1 = firstArg;
778
+ var s2 = secondArg;
779
+ if (secondArg === '') {
780
+ return this.parent.getValueFromArg(s1);
781
+ }
782
+ var dTime = new Date(1900, 0, 1, 0, 0, 0);
783
+ var checkString = s1 + ',' + s2;
784
+ var intl = new Internationalization();
785
+ if (this.parent.getErrorStrings().indexOf(checkString) > -1) {
786
+ return checkString;
787
+ }
788
+ s1 = this.parent.getValueFromArg(s1);
789
+ if (isNumber(s1.split(this.parent.tic).join(''))) {
790
+ s1 = s1.split(this.parent.tic).join('');
791
+ }
792
+ if (secondArg.startsWith('"') && secondArg.endsWith('"')) {
793
+ s2 = s2.split(this.parent.tic).join('');
794
+ }
795
+ else {
796
+ s2 = this.parent.getValueFromArg(s2);
797
+ }
798
+ if (s2 === '') {
799
+ return '';
800
+ }
801
+ if (s1 === '' && (s2.length > 0 && (s2.toUpperCase().indexOf('M') > -1 || s2.toUpperCase().indexOf('D') > -1
802
+ || s2.toUpperCase().indexOf('Y') > -1 || s2.toUpperCase().indexOf('S') > -1 || s2.toUpperCase().indexOf('T') > -1)
803
+ || s2.toUpperCase().indexOf('H') > -1)) {
804
+ s1 = dTime.toString();
805
+ }
806
+ var d = this.parseDouble(s1);
807
+ if (isNaN(d) && this.parent.isDate(new Date(s1)) !== null) {
808
+ d = this.parent.toOADate(new Date(s1));
809
+ }
810
+ dTime = Date.parse(s1.split(this.parent.tic).join(''));
811
+ if (!isNaN(d) || !isNaN(dTime)) {
812
+ if (s2.length > 0 && s2.indexOf('#') === -1 && (s2.toUpperCase().indexOf('M') > -1 || s2.toUpperCase().indexOf('D') > -1
813
+ || s2.toUpperCase().indexOf('Y') > -1 || s2.toUpperCase().indexOf('S') > -1 || s2.toUpperCase().indexOf('T') > -1)
814
+ || s2.toUpperCase().indexOf('H') > -1) {
815
+ s2 = s2.split('Y').join('y').split('D').join('d').split('H').join('h');
816
+ s2 = s2.split('S').join('s').split('m').join('M').split('AM/PM').join('tt');
817
+ var formatChar = s2.split('');
818
+ var isH = false;
819
+ var isMFound = false;
820
+ var i = 0;
821
+ // let mcount: number = 0;
822
+ var lastCharIndex = 0;
823
+ var totalCharforM = 0;
824
+ for (i = 0; i < formatChar.length;) {
825
+ var c = formatChar[i];
826
+ if (c === 's' && formatChar[lastCharIndex] === 'M') {
827
+ formatChar[lastCharIndex] = 'm';
828
+ if (formatChar[lastCharIndex - 1] === 'M') {
829
+ formatChar[lastCharIndex - 1] = 'm';
830
+ }
831
+ }
832
+ if (this.parent.isChar(c)) {
833
+ lastCharIndex = i;
834
+ if (c === 'M') {
835
+ // mcount++;
836
+ totalCharforM++;
837
+ }
838
+ }
839
+ else if (totalCharforM > 1) {
840
+ totalCharforM++;
841
+ }
842
+ if (c === 'M' && isH) {
843
+ formatChar[i] = 'm';
844
+ isMFound = true;
845
+ }
846
+ if (c === 'h') {
847
+ isH = true;
848
+ }
849
+ else if (this.parent.isChar(c) && c !== 'M' && c !== 'h' && !isMFound) {
850
+ isH = false;
851
+ isMFound = false;
852
+ }
853
+ i++;
854
+ }
855
+ s2 = String(formatChar);
856
+ s2 = s2.split(',').join('').split('\n').join(' ');
857
+ var dt = this.parent.fromOADate(d);
858
+ if (d === 0) {
859
+ dt = dTime;
860
+ }
861
+ var getSkeleton = getSkeletonVal(s2);
862
+ if (getSkeleton === '') {
863
+ var date = dateToInt(dt);
864
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
865
+ var dateString = this.parent.parentObject.getDisplayText({ format: s2, value: date });
866
+ return dateString;
867
+ }
868
+ var dFormatter = intl.getDateFormat({ skeleton: getSkeleton, type: 'date' });
869
+ var formattedString = dFormatter(dt);
870
+ s1 = formattedString;
871
+ }
872
+ else {
873
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
874
+ s1 = this.parent.parentObject.getDisplayText({ format: s2, value: d });
875
+ }
876
+ }
877
+ return nestedFormula ? this.parent.tic + s1 + this.parent.tic : s1;
878
+ };
879
+ return LookupFormulas;
880
+ }(FormulaModuleBase));
881
+ export { LookupFormulas };