@gridsheet/functions 3.0.1 → 3.0.2
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/dist/functions/src/math/sumif.d.ts.map +1 -1
- package/dist/functions/src/math/sumifs.d.ts.map +1 -1
- package/dist/functions/src/statistics/averageif.d.ts.map +1 -1
- package/dist/functions/src/statistics/averageifs.d.ts.map +1 -1
- package/dist/math/index.js +186 -186
- package/dist/math/index.js.map +1 -1
- package/dist/statistics/index.js +179 -179
- package/dist/statistics/index.js.map +1 -1
- package/package.json +8 -4
package/dist/math/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/math/mod.ts","../../src/math/sqrt.ts","../../src/math/product.ts","../../src/math/round.ts","../../src/math/rounddown.ts","../../src/math/roundup.ts","../../src/math/log.ts","../../src/math/log10.ts","../../src/math/ln.ts","../../src/math/exp.ts","../../src/math/pi.ts","../../src/math/radians.ts","../../src/math/sin.ts","../../src/math/cos.ts","../../src/math/tan.ts","../../src/math/asin.ts","../../src/math/acos.ts","../../src/math/atan.ts","../../src/math/atan2.ts","../../src/math/rand.ts","../../src/math/unaryPercent.ts","../../src/math/uplus.ts","../../src/math/sumif.ts","../../src/math/sumifs.ts","../../src/math/countif.ts","../../src/math/countifs.ts","../../src/math/fact.ts","../../src/math/int.ts","../../src/math/iseven.ts","../../src/math/isodd.ts","../../src/math/lcm.ts","../../src/math/odd.ts","../../src/math/even.ts","../../src/math/sign.ts","../../src/math/sumsq.ts","../../src/math/trunc.ts","../../src/math/base.ts","../../src/math/sequence.ts","../../src/math/__matrix_base.ts","../../src/math/mmult.ts","../../src/math/transpose.ts","../../src/math/minverse.ts","../../src/math/mdeterm.ts","../../src/math/sumproduct.ts","../../src/math/index.ts"],"sourcesContent":["import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the result of the modulo operation.`;\n\nexport class ModFunction extends BaseFunction {\n example = 'MOD(10, 4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'dividend',\n description: 'A number that will be divided by divisor.',\n acceptedTypes: ['number'],\n },\n { name: 'divisor', description: 'A number that will divide a dividend.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length !== 2) {\n throw new FormulaError('#N/A', 'Number of arguments for MOD is incorrect.');\n }\n const validated = args.map((arg) => ensureNumber(arg));\n if (validated[1] === 0) {\n throw new FormulaError('#DIV/0!', 'The second argument must be non-zero.');\n }\n return validated;\n }\n\n protected main(v1: number, v2: number) {\n // https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers\n return ((v1 % v2) + v2) % v2;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the positive square root of a positive number.`;\n\nexport class SqrtFunction extends BaseFunction {\n example = 'SQRT(9)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number for which the positive square root is to be found.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value < 0) {\n throw new FormulaError('NUM!', 'First argument must be positive.');\n }\n return Math.sqrt(value);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition, eachMatrix } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the product of a series of numbers.`;\n\nexport class ProductFunction extends BaseFunction {\n example = 'PRODUCT(2,3,4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'Numbers or ranges to multiply.',\n takesMatrix: true,\n acceptedTypes: ['number', 'matrix'],\n variadic: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(...values: any[]) {\n let product = 1;\n for (const val of values) {\n eachMatrix(\n val,\n (v: any) => {\n if (v == null || typeof v === 'string') {\n return;\n }\n product *= ensureNumber(v);\n },\n this.at,\n );\n }\n return product;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round a number to the specified number of decimal places according to standard rules.`;\n\nexport class RoundFunction extends BaseFunction {\n example = 'ROUND(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.round(value * multiplier) / multiplier;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round down a number to the specified number of decimal places according to standard rules.`;\n\nexport class RounddownFunction extends BaseFunction {\n example = 'ROUNDDOWN(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded down.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.floor(value * multiplier) / multiplier;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round up a number to the specified number of decimal places according to standard rules.`;\n\nexport class RoundupFunction extends BaseFunction {\n example = 'ROUNDUP(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded up.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.ceil(value * multiplier) / multiplier;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of a number whose base is the specified number.`;\n\nexport class LogFunction extends BaseFunction {\n example = 'LOG(128, 2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of the specified number as base.',\n acceptedTypes: ['number'],\n },\n { name: 'base', description: 'An exponent to power the base.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n validate(args: any[]) {\n const [value, base] = super.validate(args);\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n if (base <= 1) {\n throw new FormulaError('NUM!', 'base must be greater than 1');\n }\n return [value, base];\n }\n\n protected main(value: number, base: number) {\n return Math.log2(value) / Math.log2(base);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of 10`;\n\nexport class Log10Function extends BaseFunction {\n example = 'LOG10(100)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of 10',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n return Math.log10(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of e`;\n\nexport class LnFunction extends BaseFunction {\n example = 'LN(100)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of e',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n return Math.log(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the power of a number whose base is the Euler number e.`;\n\nexport class ExpFunction extends BaseFunction {\n example = 'EXP(2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'exponent',\n description: 'It is an exponent of power with e as the base.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'Number of arguments for EXP is incorrect.');\n }\n return [ensureNumber(args[0])];\n }\n\n protected main(exponent: number) {\n return Math.exp(exponent);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the value of Pi.`;\n\nexport class PiFunction extends BaseFunction {\n example = 'PI()';\n description = description;\n defs: FunctionArgumentDefinition[] = [];\n category: FunctionCategory = 'math';\n\n protected main() {\n return Math.PI;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Converts an angle value in degrees to radians.`;\n\nexport class RadiansFunction extends BaseFunction {\n example = 'RADIANS(180)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in degrees that you want to convert to radians.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return (angle / 180) * Math.PI;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sin of the angle specified in radians.`;\n\nexport class SinFunction extends BaseFunction {\n example = 'SIN(PI()/2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the sin.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.sin(angle);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the cos of the angle specified in radians.`;\n\nexport class CosFunction extends BaseFunction {\n example = 'COS(PI())';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the cos.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.cos(angle);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the tan of the angle specified in radians.`;\n\nexport class TanFunction extends BaseFunction {\n example = 'TAN(PI()/4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the tan.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.tan(angle);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse sin of the value in radians.`;\n\nexport class AsinFunction extends BaseFunction {\n example = 'ASIN(1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse sin between -1 and 1.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (-1 > value || value > 1) {\n throw new FormulaError('#NUM!', 'value must be between -1 and 1');\n }\n return Math.asin(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse cos of the value in radians.`;\n\nexport class AcosFunction extends BaseFunction {\n example = 'ACOS(0)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse cos between -1 and 1.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (-1 > value || value > 1) {\n throw new FormulaError('#NUM!', 'value must be between -1 and 1');\n }\n return Math.acos(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse tan of the value in radians.`;\n\nexport class AtanFunction extends BaseFunction {\n example = 'ATAN(1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse tan.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.atan(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the angle in radians between the x-axis and a line passing from the origin through a given coordinate point (x, y).`;\n\nexport class Atan2Function extends BaseFunction {\n example = 'ATAN2(4,3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'x',\n description: 'x of the point.',\n acceptedTypes: ['number'],\n },\n {\n name: 'y',\n description: 'y of the point.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(x: number, y: number) {\n return Math.atan2(x, y);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns a random number between 0 and 1.`;\n\nexport class RandFunction extends BaseFunction {\n example = 'RAND()';\n description = description;\n defs: FunctionArgumentDefinition[] = [];\n category: FunctionCategory = 'math';\n\n protected main() {\n return Math.random();\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns a value interpreted as a percentage, i.e. divides the number by 100.`;\n\nexport class UnaryPercentFunction extends BaseFunction {\n example = 'UNARY_PERCENT(50)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be divided by 100.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return value / 100;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the number with its sign unchanged (unary plus).`;\n\nexport class UplusFunction extends BaseFunction {\n example = 'UPLUS(4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to return as-is.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return value;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { Sheet, eachMatrix, stripMatrix, check, conditionArg, ensureString } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of a series of cells.`;\n\nexport class SumifFunction extends BaseFunction {\n example = 'SUMIF(A1:A10,\">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range', description: 'A condition range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n conditionArg,\n {\n name: 'sum_range',\n description: 'A range to be summarized.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(range: Sheet, condition: any, sumRange?: Sheet) {\n const conditionStr = ensureString(condition);\n const condArr: any[] = [];\n const sumArr: any[] = [];\n\n eachMatrix(\n range,\n (v) => {\n condArr.push(v);\n },\n this.at,\n );\n if (sumRange) {\n eachMatrix(\n sumRange,\n (v) => {\n sumArr.push(v);\n },\n this.at,\n );\n }\n\n let total = 0;\n condArr.forEach((c, i) => {\n const s = stripMatrix((sumRange ? sumArr[i] : c) ?? 0, this.at);\n if (typeof s === 'number' && check(c, conditionStr)) {\n total += s;\n }\n });\n return total;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition, conditionArg } from '@gridsheet/core';\nimport { Sheet, eachMatrix, stripMatrix, createBooleanMask, ensureString } from '@gridsheet/core';\nimport type { PointType } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of a range depending on multiple criteria.`;\n\nexport class SumifsFunction extends BaseFunction {\n example = 'SUMIFS(A1:A10, B1:B10, \">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'sum_range', description: 'The range to be summed.', takesMatrix: true, acceptedTypes: ['matrix'] },\n {\n name: 'range',\n description: 'First condition range.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n variadic: true,\n },\n { ...conditionArg, name: 'condition', variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n const validatedArgs = super.validate(args);\n if ((validatedArgs.length - 1) % 2 !== 0) {\n throw new FormulaError('#N/A', 'SUMIFS requires sum_range and at least one range/condition pair.');\n }\n if (!(validatedArgs[0] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', 'First argument of SUMIFS must be a range.');\n }\n const expectedRows = validatedArgs[0].numRows;\n const expectedCols = validatedArgs[0].numCols;\n\n const tables: Sheet[] = [];\n const conditions: string[] = [];\n for (let i = 1; i < validatedArgs.length; i += 2) {\n if (!(validatedArgs[i] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', `Argument ${i + 1} of SUMIFS must be a range.`);\n }\n if (validatedArgs[i].numRows !== expectedRows || validatedArgs[i].numCols !== expectedCols) {\n throw new FormulaError('#VALUE!', 'Array arguments to SUMIFS are of different size.');\n }\n tables.push(validatedArgs[i] as Sheet);\n conditions.push(ensureString(validatedArgs[i + 1]));\n }\n const sumRange = validatedArgs[0];\n const mask = createBooleanMask(tables, conditions, this.at);\n return [sumRange, mask];\n }\n\n protected main(sumRange: Sheet, mask: boolean[][]) {\n let total = 0;\n eachMatrix(\n sumRange,\n (v: any, pt: PointType) => {\n if (pt && mask[pt.y][pt.x]) {\n const num = stripMatrix(v ?? 0, this.at);\n if (typeof num === 'number') {\n total += num;\n }\n }\n },\n this.at,\n );\n\n return total;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { Sheet, eachMatrix, ensureString, check, conditionArg } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the count of a series of cells.`;\n\nexport class CountifFunction extends BaseFunction {\n example = 'COUNTIF(A1:A10,\">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range', description: 'Target range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { ...conditionArg },\n ];\n category: FunctionCategory = 'math';\n\n protected main(sheet: Sheet, condition: any) {\n const conditionStr = ensureString(condition);\n let count = 0;\n eachMatrix(\n sheet,\n (v: any) => {\n if (check(v, conditionStr)) {\n count++;\n }\n },\n this.at,\n );\n return count;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition, conditionArg } from '@gridsheet/core';\nimport { Sheet, createBooleanMask, ensureString } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the count of a range depending on multiple criteria.`;\n\nexport class CountifsFunction extends BaseFunction {\n example = 'COUNTIFS(A1:A10, \">20\", B1:B10, \"<5\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range1', description: 'First condition range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { ...conditionArg, name: 'condition1' },\n {\n name: 'range2',\n description: 'Additional condition range.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n optional: true,\n variadic: true,\n },\n { ...conditionArg, name: 'condition2', optional: true, variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n const validatedArgs = super.validate(args);\n if (validatedArgs.length % 2 !== 0) {\n throw new FormulaError('#N/A', 'COUNTIFS requires at least one range/condition pair.');\n }\n const refRange = validatedArgs[0] instanceof Sheet ? validatedArgs[0] : null;\n let expectedRows = 0;\n let expectedCols = 0;\n if (refRange) {\n expectedRows = refRange.numRows;\n expectedCols = refRange.numCols;\n }\n\n const tables: Sheet[] = [];\n const conditions: string[] = [];\n for (let i = 0; i < validatedArgs.length; i += 2) {\n if (!(validatedArgs[i] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', `Argument ${i + 1} of COUNTIFS must be a range.`);\n }\n if (validatedArgs[i].numRows !== expectedRows || validatedArgs[i].numCols !== expectedCols) {\n throw new FormulaError('#VALUE!', 'Array arguments to COUNTIFS are of different size.');\n }\n tables.push(validatedArgs[i] as Sheet);\n conditions.push(ensureString(validatedArgs[i + 1]));\n }\n const mask = createBooleanMask(tables, conditions, this.at);\n return [mask];\n }\n\n protected main(mask: boolean[][]) {\n let count = 0;\n for (const row of mask) {\n for (const val of row) {\n if (val) {\n count++;\n }\n }\n }\n return count;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the factorial of a number.`;\n\nexport class FactFunction extends BaseFunction {\n example = 'FACT(5)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A non-negative integer whose factorial will be returned.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(n: number) {\n if (n < 0) {\n throw new FormulaError('#NUM!', 'FACT requires a non-negative integer.');\n }\n let result = 1;\n for (let i = 2; i <= Math.floor(n); i++) {\n result *= i;\n }\n return result;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number down to the nearest integer that is less than or equal to it.`;\n\nexport class IntFunction extends BaseFunction {\n example = 'INT(8.9)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round down to the nearest integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(value);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns TRUE if the value is even.`;\n\nexport class IsevenFunction extends BaseFunction {\n example = 'ISEVEN(4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to check for being even.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(Math.abs(value)) % 2 === 0;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns TRUE if the value is odd.`;\n\nexport class IsoddFunction extends BaseFunction {\n example = 'ISODD(3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to check for being odd.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(Math.abs(value)) % 2 !== 0;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nfunction gcd(a: number, b: number): number {\n a = Math.abs(Math.floor(a));\n b = Math.abs(Math.floor(b));\n while (b) {\n [a, b] = [b, a % b];\n }\n return a;\n}\n\nconst description = `Returns the least common multiple of one or more integers.`;\n\nexport class LcmFunction extends BaseFunction {\n example = 'LCM(4, 6)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'Integers (must be >= 1).', acceptedTypes: ['number'], variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length === 0) {\n throw new FormulaError('#N/A', 'LCM requires at least one argument.');\n }\n return args.map((arg) => {\n const n = Math.floor(ensureNumber(arg));\n if (n < 1) {\n throw new FormulaError('#NUM!', 'LCM arguments must be >= 1.');\n }\n return n;\n });\n }\n\n protected main(...values: number[]) {\n return values.reduce((acc, v) => (acc * v) / gcd(acc, v), 1);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number up to the nearest odd integer.`;\n\nexport class OddFunction extends BaseFunction {\n example = 'ODD(2.3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round up to the nearest odd integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value === 0) {\n return 1;\n }\n const sign = value > 0 ? 1 : -1;\n let n = Math.ceil(Math.abs(value));\n if (n % 2 === 0) {\n n++;\n }\n return sign * n;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number up to the nearest even integer.`;\n\nexport class EvenFunction extends BaseFunction {\n example = 'EVEN(3.1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round up to the nearest even integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value === 0) {\n return 0;\n }\n const sign = value > 0 ? 1 : -1;\n let n = Math.ceil(Math.abs(value));\n if (n % 2 !== 0) {\n n++;\n }\n return sign * n;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns -1 if the value is negative, 1 if positive, and 0 if zero.`;\n\nexport class SignFunction extends BaseFunction {\n example = 'SIGN(-3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The number to check the sign of.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value > 0) {\n return 1;\n }\n if (value < 0) {\n return -1;\n }\n return 0;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition, eachMatrix } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of the squares of a series of numbers or cells.`;\n\nexport class SumsqFunction extends BaseFunction {\n example = 'SUMSQ(A1:A10, 3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'Numbers or ranges to square and sum.',\n takesMatrix: true,\n acceptedTypes: ['number', 'matrix'],\n variadic: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(...values: any[]) {\n let sum = 0;\n for (const val of values) {\n eachMatrix(\n val,\n (v: any) => {\n const n = ensureNumber(v, { ignore: true });\n sum += n * n;\n },\n this.at,\n );\n }\n return sum;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Truncates a number to a certain number of significant digits by omitting less significant digits.`;\n\nexport class TruncFunction extends BaseFunction {\n example = 'TRUNC(3.14159, 2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The number to truncate.', acceptedTypes: ['number'] },\n {\n name: 'places',\n description: 'The number of significant digits to keep. Defaults to 0.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, places = 0) {\n const p = Math.floor(places);\n const factor = Math.pow(10, p);\n return (value >= 0 ? Math.floor : Math.ceil)(value * factor) / factor;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Converts a number into a text representation in another base, e.g. base 2 for binary.`;\n\nexport class BaseConvFunction extends BaseFunction {\n example = 'BASE(255, 16)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'A non-negative integer to convert.', acceptedTypes: ['number'] },\n { name: 'base', description: 'The base (radix) to convert into, between 2 and 36.', acceptedTypes: ['number'] },\n {\n name: 'min_length',\n description: 'Minimum length of the result string (zero-padded).',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length < 2 || args.length > 3) {\n throw new FormulaError('#N/A', 'Number of arguments for BASE is incorrect.');\n }\n args[0] = Math.floor(ensureNumber(args[0]));\n args[1] = Math.floor(ensureNumber(args[1]));\n if (args[0] < 0) {\n throw new FormulaError('#NUM!', 'BASE requires a non-negative integer as value.');\n }\n if (args[1] < 2 || args[1] > 36) {\n throw new FormulaError('#NUM!', 'BASE requires a base between 2 and 36.');\n }\n if (args[2] != null) {\n args[2] = Math.floor(ensureNumber(args[2]));\n if (args[2] < 0) {\n throw new FormulaError('#NUM!', 'BASE min_length must be non-negative.');\n }\n }\n return args;\n }\n\n protected main(value: number, base: number, minLength?: number) {\n const result = value.toString(base).toUpperCase();\n if (minLength != null && result.length < minLength) {\n return result.padStart(minLength, '0');\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Generates a sequence of numbers in a 2D array.\nReturns a rows × cols array starting at start, incrementing by step.`;\n\nexport class SequenceFunction extends BaseFunction {\n autoSpilling = true;\n example = 'SEQUENCE(4, 3, 1, 1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'rows',\n description: 'The number of rows to return.',\n acceptedTypes: ['number'],\n },\n {\n name: 'columns',\n description: 'The number of columns to return. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n {\n name: 'start',\n description: 'The starting value of the sequence. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n {\n name: 'step',\n description: 'The increment between each value. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length < 1 || args.length > 4) {\n throw new FormulaError('#N/A', 'Number of arguments for SEQUENCE is incorrect.');\n }\n args[0] = Math.floor(ensureNumber(args[0]));\n if (args[0] < 1) {\n throw new FormulaError('#VALUE!', 'rows must be at least 1.');\n }\n if (args.length >= 2) {\n args[1] = Math.floor(ensureNumber(args[1]));\n if (args[1] < 1) {\n throw new FormulaError('#VALUE!', 'columns must be at least 1.');\n }\n }\n if (args.length >= 3) {\n args[2] = ensureNumber(args[2]);\n }\n if (args.length >= 4) {\n args[3] = ensureNumber(args[3]);\n }\n return args;\n }\n\n protected main(rows: number, cols: number = 1, start: number = 1, step: number = 1) {\n const matrix: number[][] = [];\n let current = start;\n for (let y = 0; y < rows; y++) {\n const row: number[] = [];\n for (let x = 0; x < cols; x++) {\n row.push(current);\n current += step;\n }\n matrix.push(row);\n }\n return matrix;\n }\n}\n","import { BaseFunction } from '@gridsheet/core';\nimport { FormulaError, eachMatrix, ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\n/**\n * Common base class for matrix functions (MMULT, TRANSPOSE, MINVERSE, MDETERM).\n *\n * Provides:\n * - `extractNumberMatrix()` to convert a Sheet/Spilling/2D-array arg into number[][]\n */\nexport abstract class MatrixFunction extends BaseFunction {\n category: FunctionCategory = 'math';\n\n /** Convert a matrix argument to a 2D number array using eachMatrix. */\n protected extractNumberMatrix(value: any, argName: string): number[][] {\n const matrix: number[][] = [];\n eachMatrix(\n value,\n (v: any, { y, x }) => {\n if (!matrix[y]) {\n matrix[y] = [];\n }\n matrix[y][x] = ensureNumber(v);\n },\n this.at,\n );\n if (matrix.length === 0) {\n throw new FormulaError('#VALUE!', `${argName} must be a non-empty matrix.`);\n }\n return matrix;\n }\n\n /** Require the matrix to be square. Throws if not. */\n protected requireSquare(matrix: number[][], funcName: string): void {\n const n = matrix.length;\n if (matrix.some((row) => row.length !== n)) {\n throw new FormulaError('#VALUE!', `${funcName} requires a square matrix.`);\n }\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the matrix product of two matrices.\nThe number of columns in matrix1 must equal the number of rows in matrix2.`;\n\nexport class MmultFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'MMULT(A1:B2, C1:D2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix1', description: 'First matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { name: 'matrix2', description: 'Second matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 2) {\n throw new FormulaError('#N/A', 'MMULT requires exactly 2 arguments.');\n }\n const matA = this.extractNumberMatrix(args[0], 'matrix1');\n const matB = this.extractNumberMatrix(args[1], 'matrix2');\n\n const colsA = matA[0].length;\n const rowsB = matB.length;\n if (colsA !== rowsB) {\n throw new FormulaError(\n '#VALUE!',\n `MMULT: number of columns in matrix1 (${colsA}) must equal number of rows in matrix2 (${rowsB}).`,\n );\n }\n return [matA, matB];\n }\n\n protected main(matA: number[][], matB: number[][]): number[][] {\n const rowsA = matA.length;\n const colsA = matA[0].length;\n const colsB = matB[0].length;\n const result: number[][] = [];\n for (let i = 0; i < rowsA; i++) {\n result[i] = [];\n for (let j = 0; j < colsB; j++) {\n let sum = 0;\n for (let k = 0; k < colsA; k++) {\n sum += matA[i][k] * matB[k][j];\n }\n result[i][j] = sum;\n }\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the transpose of a matrix.\nRows and columns of the input array are swapped.`;\n\nexport class TransposeFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'TRANSPOSE(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'The matrix to transpose.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'TRANSPOSE requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n return [matrix];\n }\n\n protected main(matrix: number[][]): number[][] {\n const rows = matrix.length;\n const cols = matrix[0].length;\n const result: number[][] = [];\n for (let j = 0; j < cols; j++) {\n result[j] = [];\n for (let i = 0; i < rows; i++) {\n result[j][i] = matrix[i][j];\n }\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the inverse of a square matrix.\nThe matrix must be square and non-singular (determinant ≠ 0).`;\n\nexport class MinverseFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'MINVERSE(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'A square numeric matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'MINVERSE requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n this.requireSquare(matrix, 'MINVERSE');\n const inv = this.invertMatrix(matrix);\n if (inv === null) {\n throw new FormulaError('#NUM!', 'MINVERSE: matrix is singular and cannot be inverted.');\n }\n return [inv];\n }\n\n protected main(inv: number[][]): number[][] {\n return inv;\n }\n\n private invertMatrix(mat: number[][]): number[][] | null {\n const n = mat.length;\n // Build augmented matrix [mat | I]\n const aug: number[][] = mat.map((row, i) => [...row, ...Array.from({ length: n }, (_, j) => (i === j ? 1 : 0))]);\n\n for (let col = 0; col < n; col++) {\n // Find pivot row\n let pivotRow = -1;\n let maxVal = 0;\n for (let row = col; row < n; row++) {\n if (Math.abs(aug[row][col]) > maxVal) {\n maxVal = Math.abs(aug[row][col]);\n pivotRow = row;\n }\n }\n if (pivotRow === -1 || Math.abs(aug[pivotRow][col]) < 1e-10) {\n return null; // singular\n }\n [aug[col], aug[pivotRow]] = [aug[pivotRow], aug[col]];\n\n const pivot = aug[col][col];\n for (let j = 0; j < 2 * n; j++) {\n aug[col][j] /= pivot;\n }\n for (let row = 0; row < n; row++) {\n if (row === col) {\n continue;\n }\n const factor = aug[row][col];\n for (let j = 0; j < 2 * n; j++) {\n aug[row][j] -= factor * aug[col][j];\n }\n }\n }\n\n return aug.map((row) => row.slice(n));\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the determinant of a square matrix.`;\n\nexport class MdetermFunction extends MatrixFunction {\n example = 'MDETERM(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'A square numeric matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'MDETERM requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n this.requireSquare(matrix, 'MDETERM');\n return [matrix];\n }\n\n protected main(matrix: number[][]): number {\n return this.determinant(matrix);\n }\n\n private determinant(mat: number[][]): number {\n const n = mat.length;\n const a: number[][] = mat.map((row) => [...row]);\n let det = 1;\n\n for (let col = 0; col < n; col++) {\n let pivotRow = col;\n for (let row = col + 1; row < n; row++) {\n if (Math.abs(a[row][col]) > Math.abs(a[pivotRow][col])) {\n pivotRow = row;\n }\n }\n if (pivotRow !== col) {\n [a[col], a[pivotRow]] = [a[pivotRow], a[col]];\n det *= -1;\n }\n if (Math.abs(a[col][col]) < 1e-10) {\n return 0;\n }\n det *= a[col][col];\n for (let row = col + 1; row < n; row++) {\n const factor = a[row][col] / a[col][col];\n for (let j = col; j < n; j++) {\n a[row][j] -= factor * a[col][j];\n }\n }\n }\n return det;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the sum of the products of corresponding array elements.\nAll arrays must have the same dimensions.`;\n\nexport class SumproductFunction extends MatrixFunction {\n example = 'SUMPRODUCT(A1:A3, B1:B3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'array1', description: 'First array.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { name: 'array2', description: 'Additional arrays.', takesMatrix: true, acceptedTypes: ['matrix'], variadic: true },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length < 1) {\n throw new FormulaError('#N/A', 'SUMPRODUCT requires at least 1 argument.');\n }\n const matrices = args.map((arg, i) => this.extractNumberMatrix(arg, `array${i + 1}`));\n const rows = matrices[0].length;\n const cols = matrices[0][0].length;\n for (let i = 1; i < matrices.length; i++) {\n if (matrices[i].length !== rows || matrices[i][0].length !== cols) {\n throw new FormulaError('#VALUE!', 'SUMPRODUCT: all arrays must have the same dimensions.');\n }\n }\n return [matrices];\n }\n\n protected main(matrices: number[][][]): number {\n const rows = matrices[0].length;\n const cols = matrices[0][0].length;\n let sum = 0;\n for (let r = 0; r < rows; r++) {\n for (let c = 0; c < cols; c++) {\n let product = 1;\n for (const mat of matrices) {\n product *= mat[r][c];\n }\n sum += product;\n }\n }\n return sum;\n }\n}\n","import type { FunctionMapping } from '@gridsheet/core';\nimport { ModFunction } from './mod';\nimport { SqrtFunction } from './sqrt';\nimport { ProductFunction } from './product';\nimport { RoundFunction } from './round';\nimport { RounddownFunction } from './rounddown';\nimport { RoundupFunction } from './roundup';\nimport { LogFunction } from './log';\nimport { Log10Function } from './log10';\nimport { LnFunction } from './ln';\nimport { ExpFunction } from './exp';\nimport { PiFunction } from './pi';\nimport { RadiansFunction } from './radians';\nimport { SinFunction } from './sin';\nimport { CosFunction } from './cos';\nimport { TanFunction } from './tan';\nimport { AsinFunction } from './asin';\nimport { AcosFunction } from './acos';\nimport { AtanFunction } from './atan';\nimport { Atan2Function } from './atan2';\nimport { RandFunction } from './rand';\nimport { UnaryPercentFunction } from './unaryPercent';\nimport { UplusFunction } from './uplus';\nimport { SumifFunction } from './sumif';\nimport { SumifsFunction } from './sumifs';\nimport { CountifFunction } from './countif';\nimport { CountifsFunction } from './countifs';\nimport { FactFunction } from './fact';\nimport { IntFunction } from './int';\nimport { IsevenFunction } from './iseven';\nimport { IsoddFunction } from './isodd';\nimport { LcmFunction } from './lcm';\nimport { OddFunction } from './odd';\nimport { EvenFunction } from './even';\nimport { SignFunction } from './sign';\nimport { SumsqFunction } from './sumsq';\nimport { TruncFunction } from './trunc';\nimport { BaseConvFunction } from './base';\nimport { SequenceFunction } from './sequence';\nimport { MmultFunction } from './mmult';\nimport { TransposeFunction } from './transpose';\nimport { MinverseFunction } from './minverse';\nimport { MdetermFunction } from './mdeterm';\nimport { SumproductFunction } from './sumproduct';\n\nexport const mathFunctions: FunctionMapping = {\n mod: ModFunction,\n sqrt: SqrtFunction,\n product: ProductFunction,\n round: RoundFunction,\n rounddown: RounddownFunction,\n roundup: RoundupFunction,\n log: LogFunction,\n log10: Log10Function,\n ln: LnFunction,\n exp: ExpFunction,\n pi: PiFunction,\n radians: RadiansFunction,\n sin: SinFunction,\n cos: CosFunction,\n tan: TanFunction,\n asin: AsinFunction,\n acos: AcosFunction,\n atan: AtanFunction,\n atan2: Atan2Function,\n rand: RandFunction,\n unary_percent: UnaryPercentFunction,\n uplus: UplusFunction,\n sumif: SumifFunction,\n sumifs: SumifsFunction,\n countif: CountifFunction,\n countifs: CountifsFunction,\n fact: FactFunction,\n int: IntFunction,\n iseven: IsevenFunction,\n isodd: IsoddFunction,\n lcm: LcmFunction,\n odd: OddFunction,\n even: EvenFunction,\n sign: SignFunction,\n sumsq: SumsqFunction,\n trunc: TruncFunction,\n base: BaseConvFunction,\n sequence: SequenceFunction,\n mmult: MmultFunction,\n transpose: TransposeFunction,\n minverse: MinverseFunction,\n mdeterm: MdetermFunction,\n sumproduct: SumproductFunction,\n};\n\nexport default mathFunctions;\n"],"names":["description","ModFunction","BaseFunction","args","FormulaError","validated","arg","ensureNumber","v1","v2","SqrtFunction","value","ProductFunction","values","product","val","eachMatrix","v","RoundFunction","digit","multiplier","RounddownFunction","RoundupFunction","LogFunction","base","Log10Function","LnFunction","ExpFunction","exponent","PiFunction","RadiansFunction","angle","SinFunction","CosFunction","TanFunction","AsinFunction","AcosFunction","AtanFunction","Atan2Function","x","y","RandFunction","UnaryPercentFunction","UplusFunction","SumifFunction","conditionArg","range","condition","sumRange","conditionStr","ensureString","condArr","sumArr","total","i","s","stripMatrix","check","SumifsFunction","validatedArgs","Sheet","expectedRows","expectedCols","tables","conditions","mask","createBooleanMask","pt","num","CountifFunction","sheet","count","CountifsFunction","refRange","row","FactFunction","n","result","IntFunction","IsevenFunction","IsoddFunction","gcd","a","b","LcmFunction","acc","OddFunction","sign","EvenFunction","SignFunction","SumsqFunction","sum","TruncFunction","places","p","factor","BaseConvFunction","minLength","SequenceFunction","rows","cols","start","step","matrix","current","MatrixFunction","argName","funcName","MmultFunction","matA","matB","colsA","rowsB","rowsA","colsB","j","k","TransposeFunction","MinverseFunction","inv","mat","aug","_","col","pivotRow","maxVal","pivot","MdetermFunction","det","SumproductFunction","matrices","r","c","mathFunctions"],"mappings":";AAKA,MAAMA,IAAc;AAEb,MAAMC,UAAoBC,EAAa;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA,GACK,KAAA,UAAA,cACI,KAAA,cAAAF,GACuB,KAAA,OAAA;AAAA,MACnC;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QACb,eAAe,CAAC,QAAQ;AAAA,MAC1B;AAAA,MACA,EAAE,MAAM,WAAW,aAAa,yCAAyC,eAAe,CAAC,QAAQ,EAAE;AAAA,IACrG,GAC6B,KAAA,WAAA;AAAA,EAAA;AAAA,EAEnB,SAASG,GAAoB;AACjC,QAAAA,EAAK,WAAW;AACZ,YAAA,IAAIC,EAAa,QAAQ,2CAA2C;AAE5E,UAAMC,IAAYF,EAAK,IAAI,CAACG,MAAQC,EAAaD,CAAG,CAAC;AACjD,QAAAD,EAAU,CAAC,MAAM;AACb,YAAA,IAAID,EAAa,WAAW,uCAAuC;AAEpE,WAAAC;AAAA,EAAA;AAAA,EAGC,KAAKG,GAAYC,GAAY;AAE5B,YAAAD,IAAKC,IAAMA,KAAMA;AAAA,EAAA;AAE9B;AC/BA,MAAMT,IAAc;AAEb,MAAMU,UAAqBR,EAAa;AAAA,EAAxC,cAAA;AAAA,UAAA,GAAA,SAAA,GACK,KAAA,UAAA,WACI,KAAA,cAAAF,GACuB,KAAA,OAAA;AAAA,MACnC;AAAA,QACE,MAAM;AAAA,QACN,aAAa;AAAA,QACb,eAAe,CAAC,QAAQ;AAAA,MAAA;AAAA,IAE5B,GAC6B,KAAA,WAAA;AAAA,EAAA;AAAA,EAEnB,KAAKW,GAAe;AAC5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/mod.ts","../../src/math/sqrt.ts","../../src/math/product.ts","../../src/math/round.ts","../../src/math/rounddown.ts","../../src/math/roundup.ts","../../src/math/log.ts","../../src/math/log10.ts","../../src/math/ln.ts","../../src/math/exp.ts","../../src/math/pi.ts","../../src/math/radians.ts","../../src/math/sin.ts","../../src/math/cos.ts","../../src/math/tan.ts","../../src/math/asin.ts","../../src/math/acos.ts","../../src/math/atan.ts","../../src/math/atan2.ts","../../src/math/rand.ts","../../src/math/unaryPercent.ts","../../src/math/uplus.ts","../../src/math/sumif.ts","../../src/math/sumifs.ts","../../src/math/countif.ts","../../src/math/countifs.ts","../../src/math/fact.ts","../../src/math/int.ts","../../src/math/iseven.ts","../../src/math/isodd.ts","../../src/math/lcm.ts","../../src/math/odd.ts","../../src/math/even.ts","../../src/math/sign.ts","../../src/math/sumsq.ts","../../src/math/trunc.ts","../../src/math/base.ts","../../src/math/sequence.ts","../../src/math/__matrix_base.ts","../../src/math/mmult.ts","../../src/math/transpose.ts","../../src/math/minverse.ts","../../src/math/mdeterm.ts","../../src/math/sumproduct.ts","../../src/math/index.ts"],"sourcesContent":["import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the result of the modulo operation.`;\n\nexport class ModFunction extends BaseFunction {\n example = 'MOD(10, 4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'dividend',\n description: 'A number that will be divided by divisor.',\n acceptedTypes: ['number'],\n },\n { name: 'divisor', description: 'A number that will divide a dividend.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length !== 2) {\n throw new FormulaError('#N/A', 'Number of arguments for MOD is incorrect.');\n }\n const validated = args.map((arg) => ensureNumber(arg));\n if (validated[1] === 0) {\n throw new FormulaError('#DIV/0!', 'The second argument must be non-zero.');\n }\n return validated;\n }\n\n protected main(v1: number, v2: number) {\n // https://stackoverflow.com/questions/4467539/javascript-modulo-gives-a-negative-result-for-negative-numbers\n return ((v1 % v2) + v2) % v2;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the positive square root of a positive number.`;\n\nexport class SqrtFunction extends BaseFunction {\n example = 'SQRT(9)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number for which the positive square root is to be found.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value < 0) {\n throw new FormulaError('NUM!', 'First argument must be positive.');\n }\n return Math.sqrt(value);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition, eachMatrix } from '@gridsheet/core';\nimport { ensureNumber, isNumeric } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the product of a series of numbers.`;\n\nexport class ProductFunction extends BaseFunction {\n example = 'PRODUCT(2,3,4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'Numbers or ranges to multiply.',\n takesMatrix: true,\n acceptedTypes: ['number', 'matrix'],\n variadic: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(...values: any[]) {\n let product = 1;\n for (const val of values) {\n eachMatrix(\n val,\n (v: any) => {\n if (!isNumeric(v)) {\n return;\n }\n product *= ensureNumber(v);\n },\n this.at,\n );\n }\n return product;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round a number to the specified number of decimal places according to standard rules.`;\n\nexport class RoundFunction extends BaseFunction {\n example = 'ROUND(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.round(value * multiplier) / multiplier;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round down a number to the specified number of decimal places according to standard rules.`;\n\nexport class RounddownFunction extends BaseFunction {\n example = 'ROUNDDOWN(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded down.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.floor(value * multiplier) / multiplier;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Round up a number to the specified number of decimal places according to standard rules.`;\n\nexport class RoundupFunction extends BaseFunction {\n example = 'ROUNDUP(99.44,1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be rounded up.',\n acceptedTypes: ['number'],\n },\n {\n name: 'digit',\n description: 'The number of decimal places after rounding.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, digit = 0) {\n const multiplier = Math.pow(10, digit);\n return Math.ceil(value * multiplier) / multiplier;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of a number whose base is the specified number.`;\n\nexport class LogFunction extends BaseFunction {\n example = 'LOG(128, 2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of the specified number as base.',\n acceptedTypes: ['number'],\n },\n { name: 'base', description: 'An exponent to power the base.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n validate(args: any[]) {\n const [value, base] = super.validate(args);\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n if (base <= 1) {\n throw new FormulaError('NUM!', 'base must be greater than 1');\n }\n return [value, base];\n }\n\n protected main(value: number, base: number) {\n return Math.log2(value) / Math.log2(base);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of 10`;\n\nexport class Log10Function extends BaseFunction {\n example = 'LOG10(100)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of 10',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n return Math.log10(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the logarithm of e`;\n\nexport class LnFunction extends BaseFunction {\n example = 'LN(100)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'The value for the logarithm of e',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value <= 0) {\n throw new FormulaError('NUM!', 'value must be greater than 0');\n }\n return Math.log(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the power of a number whose base is the Euler number e.`;\n\nexport class ExpFunction extends BaseFunction {\n example = 'EXP(2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'exponent',\n description: 'It is an exponent of power with e as the base.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'Number of arguments for EXP is incorrect.');\n }\n return [ensureNumber(args[0])];\n }\n\n protected main(exponent: number) {\n return Math.exp(exponent);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the value of Pi.`;\n\nexport class PiFunction extends BaseFunction {\n example = 'PI()';\n description = description;\n defs: FunctionArgumentDefinition[] = [];\n category: FunctionCategory = 'math';\n\n protected main() {\n return Math.PI;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Converts an angle value in degrees to radians.`;\n\nexport class RadiansFunction extends BaseFunction {\n example = 'RADIANS(180)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in degrees that you want to convert to radians.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return (angle / 180) * Math.PI;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sin of the angle specified in radians.`;\n\nexport class SinFunction extends BaseFunction {\n example = 'SIN(PI()/2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the sin.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.sin(angle);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the cos of the angle specified in radians.`;\n\nexport class CosFunction extends BaseFunction {\n example = 'COS(PI())';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the cos.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.cos(angle);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the tan of the angle specified in radians.`;\n\nexport class TanFunction extends BaseFunction {\n example = 'TAN(PI()/4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'angle',\n description: 'An angle in radians, at which you want the tan.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(angle: number) {\n return Math.tan(angle);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse sin of the value in radians.`;\n\nexport class AsinFunction extends BaseFunction {\n example = 'ASIN(1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse sin between -1 and 1.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (-1 > value || value > 1) {\n throw new FormulaError('#NUM!', 'value must be between -1 and 1');\n }\n return Math.asin(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse cos of the value in radians.`;\n\nexport class AcosFunction extends BaseFunction {\n example = 'ACOS(0)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse cos between -1 and 1.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (-1 > value || value > 1) {\n throw new FormulaError('#NUM!', 'value must be between -1 and 1');\n }\n return Math.acos(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the inverse tan of the value in radians.`;\n\nexport class AtanFunction extends BaseFunction {\n example = 'ATAN(1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A value for the inverse tan.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.atan(value);\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the angle in radians between the x-axis and a line passing from the origin through a given coordinate point (x, y).`;\n\nexport class Atan2Function extends BaseFunction {\n example = 'ATAN2(4,3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'x',\n description: 'x of the point.',\n acceptedTypes: ['number'],\n },\n {\n name: 'y',\n description: 'y of the point.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(x: number, y: number) {\n return Math.atan2(x, y);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns a random number between 0 and 1.`;\n\nexport class RandFunction extends BaseFunction {\n example = 'RAND()';\n description = description;\n defs: FunctionArgumentDefinition[] = [];\n category: FunctionCategory = 'math';\n\n protected main() {\n return Math.random();\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns a value interpreted as a percentage, i.e. divides the number by 100.`;\n\nexport class UnaryPercentFunction extends BaseFunction {\n example = 'UNARY_PERCENT(50)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to be divided by 100.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return value / 100;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the number with its sign unchanged (unary plus).`;\n\nexport class UplusFunction extends BaseFunction {\n example = 'UPLUS(4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A number to return as-is.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return value;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport {\n Sheet,\n eachMatrix,\n stripMatrix,\n check,\n conditionArg,\n ensureString,\n ensureNumber,\n isNumeric,\n} from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of a series of cells.`;\n\nexport class SumifFunction extends BaseFunction {\n example = 'SUMIF(A1:A10,\">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range', description: 'A condition range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n conditionArg,\n {\n name: 'sum_range',\n description: 'A range to be summarized.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(range: Sheet, condition: any, sumRange?: Sheet) {\n const conditionStr = ensureString(condition);\n const condArr: any[] = [];\n const sumArr: any[] = [];\n\n eachMatrix(\n range,\n (v) => {\n condArr.push(v);\n },\n this.at,\n );\n if (sumRange) {\n eachMatrix(\n sumRange,\n (v) => {\n sumArr.push(v);\n },\n this.at,\n );\n }\n\n let total = 0;\n condArr.forEach((c, i) => {\n const s = stripMatrix((sumRange ? sumArr[i] : c) ?? 0, this.at);\n if (isNumeric(s) && check(c, conditionStr)) {\n total += ensureNumber(s);\n }\n });\n return total;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition, conditionArg } from '@gridsheet/core';\nimport {\n Sheet,\n eachMatrix,\n stripMatrix,\n createBooleanMask,\n ensureString,\n ensureNumber,\n isNumeric,\n} from '@gridsheet/core';\nimport type { PointType } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of a range depending on multiple criteria.`;\n\nexport class SumifsFunction extends BaseFunction {\n example = 'SUMIFS(A1:A10, B1:B10, \">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'sum_range', description: 'The range to be summed.', takesMatrix: true, acceptedTypes: ['matrix'] },\n {\n name: 'range',\n description: 'First condition range.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n variadic: true,\n },\n { ...conditionArg, name: 'condition', variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n const validatedArgs = super.validate(args);\n if ((validatedArgs.length - 1) % 2 !== 0) {\n throw new FormulaError('#N/A', 'SUMIFS requires sum_range and at least one range/condition pair.');\n }\n if (!(validatedArgs[0] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', 'First argument of SUMIFS must be a range.');\n }\n const expectedRows = validatedArgs[0].numRows;\n const expectedCols = validatedArgs[0].numCols;\n\n const tables: Sheet[] = [];\n const conditions: string[] = [];\n for (let i = 1; i < validatedArgs.length; i += 2) {\n if (!(validatedArgs[i] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', `Argument ${i + 1} of SUMIFS must be a range.`);\n }\n if (validatedArgs[i].numRows !== expectedRows || validatedArgs[i].numCols !== expectedCols) {\n throw new FormulaError('#VALUE!', 'Array arguments to SUMIFS are of different size.');\n }\n tables.push(validatedArgs[i] as Sheet);\n conditions.push(ensureString(validatedArgs[i + 1]));\n }\n const sumRange = validatedArgs[0];\n const mask = createBooleanMask(tables, conditions, this.at);\n return [sumRange, mask];\n }\n\n protected main(sumRange: Sheet, mask: boolean[][]) {\n let total = 0;\n eachMatrix(\n sumRange,\n (v: any, pt: PointType) => {\n if (pt && mask[pt.y][pt.x]) {\n const num = stripMatrix(v ?? 0, this.at);\n if (isNumeric(num)) {\n total += ensureNumber(num);\n }\n }\n },\n this.at,\n );\n\n return total;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { Sheet, eachMatrix, ensureString, check, conditionArg } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the count of a series of cells.`;\n\nexport class CountifFunction extends BaseFunction {\n example = 'COUNTIF(A1:A10,\">20\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range', description: 'Target range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { ...conditionArg },\n ];\n category: FunctionCategory = 'math';\n\n protected main(sheet: Sheet, condition: any) {\n const conditionStr = ensureString(condition);\n let count = 0;\n eachMatrix(\n sheet,\n (v: any) => {\n if (check(v, conditionStr)) {\n count++;\n }\n },\n this.at,\n );\n return count;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition, conditionArg } from '@gridsheet/core';\nimport { Sheet, createBooleanMask, ensureString } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the count of a range depending on multiple criteria.`;\n\nexport class CountifsFunction extends BaseFunction {\n example = 'COUNTIFS(A1:A10, \">20\", B1:B10, \"<5\")';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'range1', description: 'First condition range.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { ...conditionArg, name: 'condition1' },\n {\n name: 'range2',\n description: 'Additional condition range.',\n takesMatrix: true,\n acceptedTypes: ['matrix'],\n optional: true,\n variadic: true,\n },\n { ...conditionArg, name: 'condition2', optional: true, variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n const validatedArgs = super.validate(args);\n if (validatedArgs.length % 2 !== 0) {\n throw new FormulaError('#N/A', 'COUNTIFS requires at least one range/condition pair.');\n }\n const refRange = validatedArgs[0] instanceof Sheet ? validatedArgs[0] : null;\n let expectedRows = 0;\n let expectedCols = 0;\n if (refRange) {\n expectedRows = refRange.numRows;\n expectedCols = refRange.numCols;\n }\n\n const tables: Sheet[] = [];\n const conditions: string[] = [];\n for (let i = 0; i < validatedArgs.length; i += 2) {\n if (!(validatedArgs[i] instanceof Sheet)) {\n throw new FormulaError('#VALUE!', `Argument ${i + 1} of COUNTIFS must be a range.`);\n }\n if (validatedArgs[i].numRows !== expectedRows || validatedArgs[i].numCols !== expectedCols) {\n throw new FormulaError('#VALUE!', 'Array arguments to COUNTIFS are of different size.');\n }\n tables.push(validatedArgs[i] as Sheet);\n conditions.push(ensureString(validatedArgs[i + 1]));\n }\n const mask = createBooleanMask(tables, conditions, this.at);\n return [mask];\n }\n\n protected main(mask: boolean[][]) {\n let count = 0;\n for (const row of mask) {\n for (const val of row) {\n if (val) {\n count++;\n }\n }\n }\n return count;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the factorial of a number.`;\n\nexport class FactFunction extends BaseFunction {\n example = 'FACT(5)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'A non-negative integer whose factorial will be returned.',\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(n: number) {\n if (n < 0) {\n throw new FormulaError('#NUM!', 'FACT requires a non-negative integer.');\n }\n let result = 1;\n for (let i = 2; i <= Math.floor(n); i++) {\n result *= i;\n }\n return result;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number down to the nearest integer that is less than or equal to it.`;\n\nexport class IntFunction extends BaseFunction {\n example = 'INT(8.9)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round down to the nearest integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(value);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns TRUE if the value is even.`;\n\nexport class IsevenFunction extends BaseFunction {\n example = 'ISEVEN(4)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to check for being even.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(Math.abs(value)) % 2 === 0;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns TRUE if the value is odd.`;\n\nexport class IsoddFunction extends BaseFunction {\n example = 'ISODD(3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to check for being odd.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n return Math.floor(Math.abs(value)) % 2 !== 0;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nfunction gcd(a: number, b: number): number {\n a = Math.abs(Math.floor(a));\n b = Math.abs(Math.floor(b));\n while (b) {\n [a, b] = [b, a % b];\n }\n return a;\n}\n\nconst description = `Returns the least common multiple of one or more integers.`;\n\nexport class LcmFunction extends BaseFunction {\n example = 'LCM(4, 6)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'Integers (must be >= 1).', acceptedTypes: ['number'], variadic: true },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length === 0) {\n throw new FormulaError('#N/A', 'LCM requires at least one argument.');\n }\n return args.map((arg) => {\n const n = Math.floor(ensureNumber(arg));\n if (n < 1) {\n throw new FormulaError('#NUM!', 'LCM arguments must be >= 1.');\n }\n return n;\n });\n }\n\n protected main(...values: number[]) {\n return values.reduce((acc, v) => (acc * v) / gcd(acc, v), 1);\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number up to the nearest odd integer.`;\n\nexport class OddFunction extends BaseFunction {\n example = 'ODD(2.3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round up to the nearest odd integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value === 0) {\n return 1;\n }\n const sign = value > 0 ? 1 : -1;\n let n = Math.ceil(Math.abs(value));\n if (n % 2 === 0) {\n n++;\n }\n return sign * n;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Rounds a number up to the nearest even integer.`;\n\nexport class EvenFunction extends BaseFunction {\n example = 'EVEN(3.1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The value to round up to the nearest even integer.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value === 0) {\n return 0;\n }\n const sign = value > 0 ? 1 : -1;\n let n = Math.ceil(Math.abs(value));\n if (n % 2 !== 0) {\n n++;\n }\n return sign * n;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns -1 if the value is negative, 1 if positive, and 0 if zero.`;\n\nexport class SignFunction extends BaseFunction {\n example = 'SIGN(-3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The number to check the sign of.', acceptedTypes: ['number'] },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number) {\n if (value > 0) {\n return 1;\n }\n if (value < 0) {\n return -1;\n }\n return 0;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition, eachMatrix } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Returns the sum of the squares of a series of numbers or cells.`;\n\nexport class SumsqFunction extends BaseFunction {\n example = 'SUMSQ(A1:A10, 3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'value',\n description: 'Numbers or ranges to square and sum.',\n takesMatrix: true,\n acceptedTypes: ['number', 'matrix'],\n variadic: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(...values: any[]) {\n let sum = 0;\n for (const val of values) {\n eachMatrix(\n val,\n (v: any) => {\n const n = ensureNumber(v, { ignore: true });\n sum += n * n;\n },\n this.at,\n );\n }\n return sum;\n }\n}\n","import { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Truncates a number to a certain number of significant digits by omitting less significant digits.`;\n\nexport class TruncFunction extends BaseFunction {\n example = 'TRUNC(3.14159, 2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'The number to truncate.', acceptedTypes: ['number'] },\n {\n name: 'places',\n description: 'The number of significant digits to keep. Defaults to 0.',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected main(value: number, places = 0) {\n const p = Math.floor(places);\n const factor = Math.pow(10, p);\n return (value >= 0 ? Math.floor : Math.ceil)(value * factor) / factor;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Converts a number into a text representation in another base, e.g. base 2 for binary.`;\n\nexport class BaseConvFunction extends BaseFunction {\n example = 'BASE(255, 16)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'value', description: 'A non-negative integer to convert.', acceptedTypes: ['number'] },\n { name: 'base', description: 'The base (radix) to convert into, between 2 and 36.', acceptedTypes: ['number'] },\n {\n name: 'min_length',\n description: 'Minimum length of the result string (zero-padded).',\n acceptedTypes: ['number'],\n optional: true,\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length < 2 || args.length > 3) {\n throw new FormulaError('#N/A', 'Number of arguments for BASE is incorrect.');\n }\n args[0] = Math.floor(ensureNumber(args[0]));\n args[1] = Math.floor(ensureNumber(args[1]));\n if (args[0] < 0) {\n throw new FormulaError('#NUM!', 'BASE requires a non-negative integer as value.');\n }\n if (args[1] < 2 || args[1] > 36) {\n throw new FormulaError('#NUM!', 'BASE requires a base between 2 and 36.');\n }\n if (args[2] != null) {\n args[2] = Math.floor(ensureNumber(args[2]));\n if (args[2] < 0) {\n throw new FormulaError('#NUM!', 'BASE min_length must be non-negative.');\n }\n }\n return args;\n }\n\n protected main(value: number, base: number, minLength?: number) {\n const result = value.toString(base).toUpperCase();\n if (minLength != null && result.length < minLength) {\n return result.padStart(minLength, '0');\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport { BaseFunction, type FunctionArgumentDefinition } from '@gridsheet/core';\nimport { ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\nconst description = `Generates a sequence of numbers in a 2D array.\nReturns a rows × cols array starting at start, incrementing by step.`;\n\nexport class SequenceFunction extends BaseFunction {\n autoSpilling = true;\n example = 'SEQUENCE(4, 3, 1, 1)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n {\n name: 'rows',\n description: 'The number of rows to return.',\n acceptedTypes: ['number'],\n },\n {\n name: 'columns',\n description: 'The number of columns to return. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n {\n name: 'start',\n description: 'The starting value of the sequence. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n {\n name: 'step',\n description: 'The increment between each value. Defaults to 1.',\n optional: true,\n acceptedTypes: ['number'],\n },\n ];\n category: FunctionCategory = 'math';\n\n protected validate(args: any[]): any[] {\n if (args.length < 1 || args.length > 4) {\n throw new FormulaError('#N/A', 'Number of arguments for SEQUENCE is incorrect.');\n }\n args[0] = Math.floor(ensureNumber(args[0]));\n if (args[0] < 1) {\n throw new FormulaError('#VALUE!', 'rows must be at least 1.');\n }\n if (args.length >= 2) {\n args[1] = Math.floor(ensureNumber(args[1]));\n if (args[1] < 1) {\n throw new FormulaError('#VALUE!', 'columns must be at least 1.');\n }\n }\n if (args.length >= 3) {\n args[2] = ensureNumber(args[2]);\n }\n if (args.length >= 4) {\n args[3] = ensureNumber(args[3]);\n }\n return args;\n }\n\n protected main(rows: number, cols: number = 1, start: number = 1, step: number = 1) {\n const matrix: number[][] = [];\n let current = start;\n for (let y = 0; y < rows; y++) {\n const row: number[] = [];\n for (let x = 0; x < cols; x++) {\n row.push(current);\n current += step;\n }\n matrix.push(row);\n }\n return matrix;\n }\n}\n","import { BaseFunction } from '@gridsheet/core';\nimport { FormulaError, eachMatrix, ensureNumber } from '@gridsheet/core';\nimport type { FunctionCategory } from '@gridsheet/core';\n\n/**\n * Common base class for matrix functions (MMULT, TRANSPOSE, MINVERSE, MDETERM).\n *\n * Provides:\n * - `extractNumberMatrix()` to convert a Sheet/Spilling/2D-array arg into number[][]\n */\nexport abstract class MatrixFunction extends BaseFunction {\n category: FunctionCategory = 'math';\n\n /** Convert a matrix argument to a 2D number array using eachMatrix. */\n protected extractNumberMatrix(value: any, argName: string): number[][] {\n const matrix: number[][] = [];\n eachMatrix(\n value,\n (v: any, { y, x }) => {\n if (!matrix[y]) {\n matrix[y] = [];\n }\n matrix[y][x] = ensureNumber(v);\n },\n this.at,\n );\n if (matrix.length === 0) {\n throw new FormulaError('#VALUE!', `${argName} must be a non-empty matrix.`);\n }\n return matrix;\n }\n\n /** Require the matrix to be square. Throws if not. */\n protected requireSquare(matrix: number[][], funcName: string): void {\n const n = matrix.length;\n if (matrix.some((row) => row.length !== n)) {\n throw new FormulaError('#VALUE!', `${funcName} requires a square matrix.`);\n }\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the matrix product of two matrices.\nThe number of columns in matrix1 must equal the number of rows in matrix2.`;\n\nexport class MmultFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'MMULT(A1:B2, C1:D2)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix1', description: 'First matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { name: 'matrix2', description: 'Second matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 2) {\n throw new FormulaError('#N/A', 'MMULT requires exactly 2 arguments.');\n }\n const matA = this.extractNumberMatrix(args[0], 'matrix1');\n const matB = this.extractNumberMatrix(args[1], 'matrix2');\n\n const colsA = matA[0].length;\n const rowsB = matB.length;\n if (colsA !== rowsB) {\n throw new FormulaError(\n '#VALUE!',\n `MMULT: number of columns in matrix1 (${colsA}) must equal number of rows in matrix2 (${rowsB}).`,\n );\n }\n return [matA, matB];\n }\n\n protected main(matA: number[][], matB: number[][]): number[][] {\n const rowsA = matA.length;\n const colsA = matA[0].length;\n const colsB = matB[0].length;\n const result: number[][] = [];\n for (let i = 0; i < rowsA; i++) {\n result[i] = [];\n for (let j = 0; j < colsB; j++) {\n let sum = 0;\n for (let k = 0; k < colsA; k++) {\n sum += matA[i][k] * matB[k][j];\n }\n result[i][j] = sum;\n }\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the transpose of a matrix.\nRows and columns of the input array are swapped.`;\n\nexport class TransposeFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'TRANSPOSE(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'The matrix to transpose.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'TRANSPOSE requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n return [matrix];\n }\n\n protected main(matrix: number[][]): number[][] {\n const rows = matrix.length;\n const cols = matrix[0].length;\n const result: number[][] = [];\n for (let j = 0; j < cols; j++) {\n result[j] = [];\n for (let i = 0; i < rows; i++) {\n result[j][i] = matrix[i][j];\n }\n }\n return result;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the inverse of a square matrix.\nThe matrix must be square and non-singular (determinant ≠ 0).`;\n\nexport class MinverseFunction extends MatrixFunction {\n autoSpilling = true;\n example = 'MINVERSE(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'A square numeric matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'MINVERSE requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n this.requireSquare(matrix, 'MINVERSE');\n const inv = this.invertMatrix(matrix);\n if (inv === null) {\n throw new FormulaError('#NUM!', 'MINVERSE: matrix is singular and cannot be inverted.');\n }\n return [inv];\n }\n\n protected main(inv: number[][]): number[][] {\n return inv;\n }\n\n private invertMatrix(mat: number[][]): number[][] | null {\n const n = mat.length;\n // Build augmented matrix [mat | I]\n const aug: number[][] = mat.map((row, i) => [...row, ...Array.from({ length: n }, (_, j) => (i === j ? 1 : 0))]);\n\n for (let col = 0; col < n; col++) {\n // Find pivot row\n let pivotRow = -1;\n let maxVal = 0;\n for (let row = col; row < n; row++) {\n if (Math.abs(aug[row][col]) > maxVal) {\n maxVal = Math.abs(aug[row][col]);\n pivotRow = row;\n }\n }\n if (pivotRow === -1 || Math.abs(aug[pivotRow][col]) < 1e-10) {\n return null; // singular\n }\n [aug[col], aug[pivotRow]] = [aug[pivotRow], aug[col]];\n\n const pivot = aug[col][col];\n for (let j = 0; j < 2 * n; j++) {\n aug[col][j] /= pivot;\n }\n for (let row = 0; row < n; row++) {\n if (row === col) {\n continue;\n }\n const factor = aug[row][col];\n for (let j = 0; j < 2 * n; j++) {\n aug[row][j] -= factor * aug[col][j];\n }\n }\n }\n\n return aug.map((row) => row.slice(n));\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the determinant of a square matrix.`;\n\nexport class MdetermFunction extends MatrixFunction {\n example = 'MDETERM(A1:C3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'matrix', description: 'A square numeric matrix.', takesMatrix: true, acceptedTypes: ['matrix'] },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length !== 1) {\n throw new FormulaError('#N/A', 'MDETERM requires exactly 1 argument.');\n }\n const matrix = this.extractNumberMatrix(args[0], 'matrix');\n this.requireSquare(matrix, 'MDETERM');\n return [matrix];\n }\n\n protected main(matrix: number[][]): number {\n return this.determinant(matrix);\n }\n\n private determinant(mat: number[][]): number {\n const n = mat.length;\n const a: number[][] = mat.map((row) => [...row]);\n let det = 1;\n\n for (let col = 0; col < n; col++) {\n let pivotRow = col;\n for (let row = col + 1; row < n; row++) {\n if (Math.abs(a[row][col]) > Math.abs(a[pivotRow][col])) {\n pivotRow = row;\n }\n }\n if (pivotRow !== col) {\n [a[col], a[pivotRow]] = [a[pivotRow], a[col]];\n det *= -1;\n }\n if (Math.abs(a[col][col]) < 1e-10) {\n return 0;\n }\n det *= a[col][col];\n for (let row = col + 1; row < n; row++) {\n const factor = a[row][col] / a[col][col];\n for (let j = col; j < n; j++) {\n a[row][j] -= factor * a[col][j];\n }\n }\n }\n return det;\n }\n}\n","import { FormulaError } from '@gridsheet/core';\nimport type { FunctionArgumentDefinition } from '@gridsheet/core';\nimport { MatrixFunction } from './__matrix_base';\n\nconst description = `Returns the sum of the products of corresponding array elements.\nAll arrays must have the same dimensions.`;\n\nexport class SumproductFunction extends MatrixFunction {\n example = 'SUMPRODUCT(A1:A3, B1:B3)';\n description = description;\n defs: FunctionArgumentDefinition[] = [\n { name: 'array1', description: 'First array.', takesMatrix: true, acceptedTypes: ['matrix'] },\n { name: 'array2', description: 'Additional arrays.', takesMatrix: true, acceptedTypes: ['matrix'], variadic: true },\n ];\n\n protected validate(args: any[]): any[] {\n if (args.length < 1) {\n throw new FormulaError('#N/A', 'SUMPRODUCT requires at least 1 argument.');\n }\n const matrices = args.map((arg, i) => this.extractNumberMatrix(arg, `array${i + 1}`));\n const rows = matrices[0].length;\n const cols = matrices[0][0].length;\n for (let i = 1; i < matrices.length; i++) {\n if (matrices[i].length !== rows || matrices[i][0].length !== cols) {\n throw new FormulaError('#VALUE!', 'SUMPRODUCT: all arrays must have the same dimensions.');\n }\n }\n return [matrices];\n }\n\n protected main(matrices: number[][][]): number {\n const rows = matrices[0].length;\n const cols = matrices[0][0].length;\n let sum = 0;\n for (let r = 0; r < rows; r++) {\n for (let c = 0; c < cols; c++) {\n let product = 1;\n for (const mat of matrices) {\n product *= mat[r][c];\n }\n sum += product;\n }\n }\n return sum;\n }\n}\n","import type { FunctionMapping } from '@gridsheet/core';\nimport { ModFunction } from './mod';\nimport { SqrtFunction } from './sqrt';\nimport { ProductFunction } from './product';\nimport { RoundFunction } from './round';\nimport { RounddownFunction } from './rounddown';\nimport { RoundupFunction } from './roundup';\nimport { LogFunction } from './log';\nimport { Log10Function } from './log10';\nimport { LnFunction } from './ln';\nimport { ExpFunction } from './exp';\nimport { PiFunction } from './pi';\nimport { RadiansFunction } from './radians';\nimport { SinFunction } from './sin';\nimport { CosFunction } from './cos';\nimport { TanFunction } from './tan';\nimport { AsinFunction } from './asin';\nimport { AcosFunction } from './acos';\nimport { AtanFunction } from './atan';\nimport { Atan2Function } from './atan2';\nimport { RandFunction } from './rand';\nimport { UnaryPercentFunction } from './unaryPercent';\nimport { UplusFunction } from './uplus';\nimport { SumifFunction } from './sumif';\nimport { SumifsFunction } from './sumifs';\nimport { CountifFunction } from './countif';\nimport { CountifsFunction } from './countifs';\nimport { FactFunction } from './fact';\nimport { IntFunction } from './int';\nimport { IsevenFunction } from './iseven';\nimport { IsoddFunction } from './isodd';\nimport { LcmFunction } from './lcm';\nimport { OddFunction } from './odd';\nimport { EvenFunction } from './even';\nimport { SignFunction } from './sign';\nimport { SumsqFunction } from './sumsq';\nimport { TruncFunction } from './trunc';\nimport { BaseConvFunction } from './base';\nimport { SequenceFunction } from './sequence';\nimport { MmultFunction } from './mmult';\nimport { TransposeFunction } from './transpose';\nimport { MinverseFunction } from './minverse';\nimport { MdetermFunction } from './mdeterm';\nimport { SumproductFunction } from './sumproduct';\n\nexport const mathFunctions: FunctionMapping = {\n mod: ModFunction,\n sqrt: SqrtFunction,\n product: ProductFunction,\n round: RoundFunction,\n rounddown: RounddownFunction,\n roundup: RoundupFunction,\n log: LogFunction,\n log10: Log10Function,\n ln: LnFunction,\n exp: ExpFunction,\n pi: PiFunction,\n radians: RadiansFunction,\n sin: SinFunction,\n cos: CosFunction,\n tan: TanFunction,\n asin: AsinFunction,\n acos: AcosFunction,\n atan: AtanFunction,\n atan2: Atan2Function,\n rand: RandFunction,\n unary_percent: UnaryPercentFunction,\n uplus: UplusFunction,\n sumif: SumifFunction,\n sumifs: SumifsFunction,\n countif: CountifFunction,\n countifs: CountifsFunction,\n fact: FactFunction,\n int: IntFunction,\n iseven: IsevenFunction,\n isodd: IsoddFunction,\n lcm: LcmFunction,\n odd: OddFunction,\n even: EvenFunction,\n sign: SignFunction,\n sumsq: SumsqFunction,\n trunc: TruncFunction,\n base: BaseConvFunction,\n sequence: SequenceFunction,\n mmult: MmultFunction,\n transpose: TransposeFunction,\n minverse: MinverseFunction,\n mdeterm: MdetermFunction,\n sumproduct: SumproductFunction,\n};\n\nexport default mathFunctions;\n"],"names":["description","ModFunction","BaseFunction","args","FormulaError","validated","arg","ensureNumber","v1","v2","SqrtFunction","value","ProductFunction","values","product","val","eachMatrix","v","isNumeric","RoundFunction","digit","multiplier","RounddownFunction","RoundupFunction","LogFunction","base","Log10Function","LnFunction","ExpFunction","exponent","PiFunction","RadiansFunction","angle","SinFunction","CosFunction","TanFunction","AsinFunction","AcosFunction","AtanFunction","Atan2Function","x","y","RandFunction","UnaryPercentFunction","UplusFunction","SumifFunction","conditionArg","range","condition","sumRange","conditionStr","ensureString","condArr","sumArr","total","i","s","stripMatrix","check","SumifsFunction","validatedArgs","Sheet","expectedRows","expectedCols","tables","conditions","mask","createBooleanMask","pt","num","CountifFunction","sheet","count","CountifsFunction","refRange","row","FactFunction","n","result","IntFunction","IsevenFunction","IsoddFunction","gcd","a","b","LcmFunction","acc","OddFunction","sign","EvenFunction","SignFunction","SumsqFunction","sum","TruncFunction","places","p","factor","BaseConvFunction","minLength","SequenceFunction","rows","cols","start","step","matrix","current","MatrixFunction","argName","funcName","MmultFunction","matA","matB","colsA","rowsB","rowsA","colsB","j","k","TransposeFunction","MinverseFunction","inv","mat","aug","_","col","pivotRow","maxVal","pivot","MdetermFunction","det","SumproductFunction","matrices","r","c","mathFunctions"],"mappings":";AAKA,MAAMA,IAAc;AAEb,MAAMC,UAAoBC,EAAa;AAAA,EAAvC,cAAA;AAAA,UAAA,GAAA,SAAA,GACK,KAAA,UAAA,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