ooxml-core 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9872,8 +9872,14 @@ function parseWorkbookPart(xml) {
9872
9872
  const protection2 = xFirst(root, "workbookProtection");
9873
9873
  const password = att(protection2, "workbookPassword");
9874
9874
  const modernHash = readModernHash(protection2, "workbook");
9875
- const calcMode = att(xFirst(root, "calcPr"), "calcMode");
9875
+ const calcPr = xFirst(root, "calcPr");
9876
+ const calcMode = att(calcPr, "calcMode");
9877
+ const iterate = boolAttr(calcPr, "iterate", false) ? {
9878
+ count: numAttr(calcPr, "iterateCount") ?? 100,
9879
+ delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
9880
+ } : void 0;
9876
9881
  return {
9882
+ ...iterate ? { iterate } : {},
9877
9883
  ...password ? { workbookPasswordHash: password } : {},
9878
9884
  ...modernHash ? { workbookModernHash: modernHash } : {},
9879
9885
  ...calcMode === "manual" ? { calcMode: "manual" } : {},
@@ -11248,6 +11254,7 @@ async function loadXlsx(input) {
11248
11254
  if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
11249
11255
  if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
11250
11256
  if (book.calcMode) workbook.calcMode = book.calcMode;
11257
+ if (book.iterate) workbook.iterate = book.iterate;
11251
11258
  if (signatures.hasSignatures)
11252
11259
  workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
11253
11260
  if (!sheets.length) throw new Error("XLSX workbook has no sheets");
@@ -15665,6 +15672,67 @@ var ENGINEERING_FUNCTIONS = [
15665
15672
  )
15666
15673
  ];
15667
15674
 
15675
+ // src/xlsx/formula/functions/coupons.ts
15676
+ var C8 = "Financial";
15677
+ function checkSecurity(settlement, maturity, frequency2, basis) {
15678
+ if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
15679
+ fail(ERR.NUM);
15680
+ }
15681
+ function couponFacts(settlement, maturity, frequency2, basis, ctx) {
15682
+ const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
15683
+ checkSecurity(s, m, frequency2, basis);
15684
+ const months = 12 / frequency2;
15685
+ const { year, month, day } = serialToYmd(m, ctx.date1904);
15686
+ const monthEnd = day === daysInMonth(year, month);
15687
+ let count2 = 0;
15688
+ let next = m;
15689
+ let previous = addMonths(m, -months, ctx, monthEnd);
15690
+ while (previous > s) {
15691
+ count2 += 1;
15692
+ next = previous;
15693
+ previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
15694
+ }
15695
+ count2 += 1;
15696
+ const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
15697
+ const daysSincePrevious = dayCount(previous, s, false);
15698
+ const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
15699
+ const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
15700
+ return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
15701
+ }
15702
+ var security = (name, description, pick3) => spec(
15703
+ name,
15704
+ C8,
15705
+ `${name}(settlement, maturity, frequency, [basis])`,
15706
+ description,
15707
+ 3,
15708
+ 4,
15709
+ (args, ctx) => pick3(
15710
+ couponFacts(
15711
+ serialArg(args[0]),
15712
+ serialArg(args[1]),
15713
+ int3(args[2]),
15714
+ args.length > 3 && args[3] !== null ? int3(args[3]) : 0,
15715
+ ctx
15716
+ )
15717
+ )
15718
+ );
15719
+ var COUPON_FUNCTIONS = [
15720
+ security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
15721
+ security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
15722
+ security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
15723
+ security(
15724
+ "COUPDAYBS",
15725
+ "The days from the start of the coupon period to settlement.",
15726
+ (f) => f.daysSincePrevious
15727
+ ),
15728
+ security(
15729
+ "COUPDAYS",
15730
+ "The days in the coupon period that contains the settlement date.",
15731
+ (f) => f.daysInPeriod
15732
+ ),
15733
+ security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
15734
+ ];
15735
+
15668
15736
  // src/xlsx/formula/functions/financial-core.ts
15669
15737
  function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
15670
15738
  if (nper === 0) fail(ERR.NUM);
@@ -15734,12 +15802,185 @@ function cumulative(args, principal) {
15734
15802
  return total2;
15735
15803
  }
15736
15804
 
15805
+ // src/xlsx/formula/functions/bonds.ts
15806
+ var C9 = "Financial";
15807
+ var basisOf = (args, index2) => {
15808
+ const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
15809
+ if (basis < 0 || basis > 4) fail(ERR.NUM);
15810
+ return basis;
15811
+ };
15812
+ function pricePerHundred(facts, rate, yld, redemption, frequency2) {
15813
+ const { count: n, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
15814
+ const coupon = 100 * rate / frequency2;
15815
+ const accrued = coupon * (a / e);
15816
+ if (n === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
15817
+ let price = redemption / (1 + yld / frequency2) ** (n - 1 + dsc / e);
15818
+ for (let k = 1; k <= n; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
15819
+ return price - accrued;
15820
+ }
15821
+ function bondOf(args, ctx, redemptionAt, basisAt) {
15822
+ const frequency2 = int3(args[5]);
15823
+ const facts = couponFacts(
15824
+ serialArg(args[0]),
15825
+ serialArg(args[1]),
15826
+ frequency2,
15827
+ basisOf(args, basisAt),
15828
+ ctx
15829
+ );
15830
+ return { facts, rate: num2(args[2]), redemption: num2(args[redemptionAt]), frequency: frequency2 };
15831
+ }
15832
+ function duration(bond, yld) {
15833
+ const { facts, rate, frequency: frequency2 } = bond;
15834
+ const { count: n, daysInPeriod: e, daysToNext: dsc } = facts;
15835
+ const coupon = 100 * rate / frequency2;
15836
+ let weighted = 0;
15837
+ let total2 = 0;
15838
+ for (let k = 1; k <= n; k++) {
15839
+ const periods = k - 1 + dsc / e;
15840
+ const flow = k === n ? coupon + 100 : coupon;
15841
+ const value = flow / (1 + yld / frequency2) ** periods;
15842
+ weighted += periods / frequency2 * value;
15843
+ total2 += value;
15844
+ }
15845
+ return weighted / total2;
15846
+ }
15847
+ function quasiPeriods(anchor, from, to, frequency2, ctx) {
15848
+ const months = 12 / frequency2;
15849
+ const { year, month, day } = serialToYmd(anchor, ctx.date1904);
15850
+ const monthEnd = day === daysInMonth(year, month);
15851
+ const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
15852
+ let back = 0;
15853
+ while (at(back) > from) back -= 1;
15854
+ const dates = [];
15855
+ for (let k = back; ; k++) {
15856
+ dates.push(at(k));
15857
+ if (at(k) >= to) break;
15858
+ }
15859
+ return dates;
15860
+ }
15861
+ function accruedInterest(args, ctx) {
15862
+ const issue = serialArg(args[0]);
15863
+ const first4 = serialArg(args[1]);
15864
+ const settlement = serialArg(args[2]);
15865
+ const [rate, par] = [num2(args[3]), optNum(args, 4, 1e3)];
15866
+ const frequency2 = int3(args[5]);
15867
+ const basis = basisOf(args, 6);
15868
+ const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
15869
+ if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
15870
+ const start = fromIssue ? issue : Math.max(issue, first4);
15871
+ if (start >= settlement) return 0;
15872
+ const dates = quasiPeriods(first4, start, settlement, frequency2, ctx);
15873
+ const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
15874
+ let sum2 = 0;
15875
+ for (let i = 0; i + 1 < dates.length; i++) {
15876
+ const [p, q] = [dates[i], dates[i + 1]];
15877
+ const a = count2(Math.max(start, p), Math.min(settlement, q));
15878
+ if (a <= 0) continue;
15879
+ const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
15880
+ sum2 += a / length;
15881
+ }
15882
+ return par * rate / frequency2 * sum2;
15883
+ }
15884
+ var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
15885
+ var BOND_FUNCTIONS = [
15886
+ spec(
15887
+ "PRICE",
15888
+ C9,
15889
+ BOND_ARGS("PRICE", "rate", "yld", "redemption"),
15890
+ "The price per 100 face value of a security that pays periodic interest.",
15891
+ 6,
15892
+ 7,
15893
+ (args, ctx) => {
15894
+ const bond = bondOf(args, ctx, 4, 6);
15895
+ const yld = num2(args[3]);
15896
+ if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
15897
+ return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
15898
+ }
15899
+ ),
15900
+ spec(
15901
+ "YIELD",
15902
+ C9,
15903
+ BOND_ARGS("YIELD", "rate", "pr", "redemption"),
15904
+ "The yield of a security that pays periodic interest.",
15905
+ 6,
15906
+ 7,
15907
+ (args, ctx) => {
15908
+ const bond = bondOf(args, ctx, 4, 6);
15909
+ const price = num2(args[3]);
15910
+ if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
15911
+ const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
15912
+ return solve(f, bond.rate || 0.05);
15913
+ }
15914
+ ),
15915
+ ...["DURATION", "MDURATION"].map(
15916
+ (name) => spec(
15917
+ name,
15918
+ C9,
15919
+ `${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
15920
+ name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
15921
+ 5,
15922
+ 6,
15923
+ (args, ctx) => {
15924
+ const frequency2 = int3(args[4]);
15925
+ const facts = couponFacts(
15926
+ serialArg(args[0]),
15927
+ serialArg(args[1]),
15928
+ frequency2,
15929
+ basisOf(args, 5),
15930
+ ctx
15931
+ );
15932
+ const [rate, yld] = [num2(args[2]), num2(args[3])];
15933
+ if (rate < 0 || yld < 0) fail(ERR.NUM);
15934
+ const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
15935
+ return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
15936
+ }
15937
+ )
15938
+ ),
15939
+ spec(
15940
+ "ACCRINT",
15941
+ C9,
15942
+ "ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
15943
+ "The accrued interest of a security that pays periodic interest.",
15944
+ 6,
15945
+ 8,
15946
+ (args, ctx) => accruedInterest(args, ctx)
15947
+ ),
15948
+ spec(
15949
+ "ACCRINTM",
15950
+ C9,
15951
+ "ACCRINTM(issue, settlement, rate, [par], [basis])",
15952
+ "The accrued interest of a security that pays interest at maturity.",
15953
+ 3,
15954
+ 5,
15955
+ (args, ctx) => {
15956
+ const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
15957
+ const [rate, par] = [num2(args[2]), optNum(args, 3, 1e3)];
15958
+ if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
15959
+ return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
15960
+ }
15961
+ )
15962
+ ];
15963
+
15737
15964
  // src/xlsx/formula/functions/depreciation.ts
15738
- var C8 = "Financial";
15965
+ var C10 = "Financial";
15966
+ function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
15967
+ let book = cost;
15968
+ let total2 = 0;
15969
+ for (let period = 1; period - 1 < end; period++) {
15970
+ const declining = book * factor / life;
15971
+ const straight = (book - salvage) / Math.max(life - (period - 1), 1);
15972
+ const wanted = noSwitch ? declining : Math.max(declining, straight);
15973
+ const dep = Math.max(0, Math.min(wanted, book - salvage));
15974
+ const covered = Math.min(end, period) - Math.max(start, period - 1);
15975
+ if (covered > 0) total2 += dep * Math.min(covered, 1);
15976
+ book -= dep;
15977
+ }
15978
+ return total2;
15979
+ }
15739
15980
  var DEPRECIATION_FUNCTIONS = [
15740
15981
  numeric(
15741
15982
  "SLN",
15742
- C8,
15983
+ C10,
15743
15984
  "SLN(cost, salvage, life)",
15744
15985
  "Straight-line depreciation.",
15745
15986
  3,
@@ -15748,7 +15989,7 @@ var DEPRECIATION_FUNCTIONS = [
15748
15989
  ),
15749
15990
  numeric(
15750
15991
  "SYD",
15751
- C8,
15992
+ C10,
15752
15993
  "SYD(cost, salvage, life, per)",
15753
15994
  "Sum-of-years' digits depreciation.",
15754
15995
  4,
@@ -15760,7 +16001,7 @@ var DEPRECIATION_FUNCTIONS = [
15760
16001
  ),
15761
16002
  numeric(
15762
16003
  "DDB",
15763
- C8,
16004
+ C10,
15764
16005
  "DDB(cost, salvage, life, period, [factor])",
15765
16006
  "Double-declining balance depreciation.",
15766
16007
  4,
@@ -15776,9 +16017,33 @@ var DEPRECIATION_FUNCTIONS = [
15776
16017
  return dep;
15777
16018
  }
15778
16019
  ),
16020
+ spec(
16021
+ "VDB",
16022
+ C10,
16023
+ "VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
16024
+ "Depreciation over any span of periods, switching to straight-line when that is larger.",
16025
+ 5,
16026
+ 7,
16027
+ (args) => {
16028
+ const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num2(args[i]));
16029
+ const factor = args.length > 5 && args[5] !== null ? num2(args[5]) : 2;
16030
+ const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
16031
+ if ([cost, salvage, life, start, end, factor].some((v) => v === void 0 || Number.isNaN(v)) || cost < 0 || salvage < 0 || life <= 0 || start < 0 || end < start || end > life || factor <= 0)
16032
+ fail(ERR.NUM);
16033
+ return variableDeclining(
16034
+ cost,
16035
+ salvage,
16036
+ life,
16037
+ start,
16038
+ end,
16039
+ factor,
16040
+ noSwitch
16041
+ );
16042
+ }
16043
+ ),
15779
16044
  numeric(
15780
16045
  "DB",
15781
- C8,
16046
+ C10,
15782
16047
  "DB(cost, salvage, life, period, [month])",
15783
16048
  "Fixed-declining balance depreciation.",
15784
16049
  4,
@@ -15801,7 +16066,7 @@ var DEPRECIATION_FUNCTIONS = [
15801
16066
  ),
15802
16067
  numeric(
15803
16068
  "EFFECT",
15804
- C8,
16069
+ C10,
15805
16070
  "EFFECT(nominal_rate, npery)",
15806
16071
  "The effective annual interest rate.",
15807
16072
  2,
@@ -15814,7 +16079,7 @@ var DEPRECIATION_FUNCTIONS = [
15814
16079
  ),
15815
16080
  numeric(
15816
16081
  "NOMINAL",
15817
- C8,
16082
+ C10,
15818
16083
  "NOMINAL(effect_rate, npery)",
15819
16084
  "The nominal annual interest rate.",
15820
16085
  2,
@@ -15827,7 +16092,7 @@ var DEPRECIATION_FUNCTIONS = [
15827
16092
  ),
15828
16093
  numeric(
15829
16094
  "CUMIPMT",
15830
- C8,
16095
+ C10,
15831
16096
  "CUMIPMT(rate, nper, pv, start_period, end_period, type)",
15832
16097
  "Cumulative interest paid between periods.",
15833
16098
  6,
@@ -15836,7 +16101,7 @@ var DEPRECIATION_FUNCTIONS = [
15836
16101
  ),
15837
16102
  numeric(
15838
16103
  "CUMPRINC",
15839
- C8,
16104
+ C10,
15840
16105
  "CUMPRINC(rate, nper, pv, start_period, end_period, type)",
15841
16106
  "Cumulative principal paid between periods.",
15842
16107
  6,
@@ -15845,7 +16110,7 @@ var DEPRECIATION_FUNCTIONS = [
15845
16110
  ),
15846
16111
  numeric(
15847
16112
  "ISPMT",
15848
- C8,
16113
+ C10,
15849
16114
  "ISPMT(rate, per, nper, pv)",
15850
16115
  "Interest paid in a period of a straight-line loan.",
15851
16116
  4,
@@ -15857,7 +16122,7 @@ var DEPRECIATION_FUNCTIONS = [
15857
16122
  ),
15858
16123
  numeric(
15859
16124
  "PDURATION",
15860
- C8,
16125
+ C10,
15861
16126
  "PDURATION(rate, pv, fv)",
15862
16127
  "Periods required to reach a value.",
15863
16128
  3,
@@ -15869,7 +16134,7 @@ var DEPRECIATION_FUNCTIONS = [
15869
16134
  ),
15870
16135
  numeric(
15871
16136
  "RRI",
15872
- C8,
16137
+ C10,
15873
16138
  "RRI(nper, pv, fv)",
15874
16139
  "An equivalent interest rate for growth.",
15875
16140
  3,
@@ -15881,7 +16146,7 @@ var DEPRECIATION_FUNCTIONS = [
15881
16146
  ),
15882
16147
  spec(
15883
16148
  "FVSCHEDULE",
15884
- C8,
16149
+ C10,
15885
16150
  "FVSCHEDULE(principal, schedule)",
15886
16151
  "Future value with a schedule of rates.",
15887
16152
  2,
@@ -15891,7 +16156,7 @@ var DEPRECIATION_FUNCTIONS = [
15891
16156
  ),
15892
16157
  numeric(
15893
16158
  "DOLLARDE",
15894
- C8,
16159
+ C10,
15895
16160
  "DOLLARDE(fractional_dollar, fraction)",
15896
16161
  "Converts a fractional price to a decimal.",
15897
16162
  2,
@@ -15907,7 +16172,7 @@ var DEPRECIATION_FUNCTIONS = [
15907
16172
  ),
15908
16173
  numeric(
15909
16174
  "DOLLARFR",
15910
- C8,
16175
+ C10,
15911
16176
  "DOLLARFR(decimal_dollar, fraction)",
15912
16177
  "Converts a decimal price to a fraction.",
15913
16178
  2,
@@ -15923,8 +16188,141 @@ var DEPRECIATION_FUNCTIONS = [
15923
16188
  )
15924
16189
  ];
15925
16190
 
16191
+ // src/xlsx/formula/functions/securities.ts
16192
+ var C11 = "Financial";
16193
+ var basisOf2 = (args, index2) => {
16194
+ const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
16195
+ if (basis < 0 || basis > 4) fail(ERR.NUM);
16196
+ return basis;
16197
+ };
16198
+ function span(args) {
16199
+ const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
16200
+ if (s >= m) fail(ERR.NUM);
16201
+ return { s, m };
16202
+ }
16203
+ var positive = (...values2) => {
16204
+ for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
16205
+ };
16206
+ var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
16207
+ const { s, m } = span(args);
16208
+ const [a, b] = [num2(args[2]), num2(args[3])];
16209
+ positive(a, b);
16210
+ return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
16211
+ });
16212
+ var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
16213
+ const { s, m } = span(args);
16214
+ const issue = Math.floor(serialArg(args[2]));
16215
+ const [rate, other] = [num2(args[3]), num2(args[4])];
16216
+ const basis = basisOf2(args, 5);
16217
+ if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
16218
+ return fn(
16219
+ rate,
16220
+ other,
16221
+ yearFrac(issue, m, basis, ctx),
16222
+ yearFrac(issue, s, basis, ctx),
16223
+ yearFrac(s, m, basis, ctx)
16224
+ );
16225
+ });
16226
+ function billDays(args) {
16227
+ const { s, m } = span(args);
16228
+ const days = m - s;
16229
+ if (days > 365) fail(ERR.NUM);
16230
+ return days;
16231
+ }
16232
+ var SECURITY_FUNCTIONS = [
16233
+ discount(
16234
+ "DISC",
16235
+ "The discount rate of a security.",
16236
+ "DISC(settlement, maturity, pr, redemption, [basis])",
16237
+ (pr, redemption, f) => (redemption - pr) / redemption / f
16238
+ ),
16239
+ discount(
16240
+ "PRICEDISC",
16241
+ "The price per 100 face value of a discounted security.",
16242
+ "PRICEDISC(settlement, maturity, discount, redemption, [basis])",
16243
+ (rate, redemption, f) => redemption - rate * redemption * f
16244
+ ),
16245
+ discount(
16246
+ "YIELDDISC",
16247
+ "The annual yield of a discounted security.",
16248
+ "YIELDDISC(settlement, maturity, pr, redemption, [basis])",
16249
+ (pr, redemption, f) => (redemption - pr) / pr / f
16250
+ ),
16251
+ discount(
16252
+ "INTRATE",
16253
+ "The interest rate of a fully invested security.",
16254
+ "INTRATE(settlement, maturity, investment, redemption, [basis])",
16255
+ (investment, redemption, f) => (redemption - investment) / investment / f
16256
+ ),
16257
+ discount(
16258
+ "RECEIVED",
16259
+ "The amount received at maturity for a fully invested security.",
16260
+ "RECEIVED(settlement, maturity, investment, discount, [basis])",
16261
+ (investment, rate, f) => investment / (1 - rate * f)
16262
+ ),
16263
+ atMaturity(
16264
+ "PRICEMAT",
16265
+ "The price per 100 face value of a security that pays interest at maturity.",
16266
+ "PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
16267
+ (rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
16268
+ ),
16269
+ atMaturity(
16270
+ "YIELDMAT",
16271
+ "The annual yield of a security that pays interest at maturity.",
16272
+ "YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
16273
+ (rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
16274
+ ),
16275
+ spec(
16276
+ "TBILLPRICE",
16277
+ C11,
16278
+ "TBILLPRICE(settlement, maturity, discount)",
16279
+ "The price per 100 face value of a Treasury bill.",
16280
+ 3,
16281
+ 3,
16282
+ (args) => {
16283
+ const days = billDays(args);
16284
+ const rate = num2(args[2]);
16285
+ positive(rate);
16286
+ const price = 100 * (1 - rate * days / 360);
16287
+ return price > 0 ? price : fail(ERR.NUM);
16288
+ }
16289
+ ),
16290
+ spec(
16291
+ "TBILLYIELD",
16292
+ C11,
16293
+ "TBILLYIELD(settlement, maturity, pr)",
16294
+ "The yield of a Treasury bill.",
16295
+ 3,
16296
+ 3,
16297
+ (args) => {
16298
+ const days = billDays(args);
16299
+ const price = num2(args[2]);
16300
+ positive(price);
16301
+ return (100 - price) / price * (360 / days);
16302
+ }
16303
+ ),
16304
+ spec(
16305
+ "TBILLEQ",
16306
+ C11,
16307
+ "TBILLEQ(settlement, maturity, discount)",
16308
+ "The bond-equivalent yield of a Treasury bill.",
16309
+ 3,
16310
+ 3,
16311
+ (args) => {
16312
+ const days = billDays(args);
16313
+ const rate = num2(args[2]);
16314
+ positive(rate);
16315
+ if (days <= 182) return 365 * rate / (360 - rate * days);
16316
+ const price = 100 - rate * 100 * (days / 360);
16317
+ const t = days / 365;
16318
+ const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
16319
+ return (-t + root) / (t - 0.5);
16320
+ }
16321
+ )
16322
+ ];
16323
+
15926
16324
  // src/xlsx/formula/functions/financial.ts
15927
- var C9 = "Financial";
16325
+ var C12 = "Financial";
15928
16326
  var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
15929
16327
  function datedFlows(ctx, args) {
15930
16328
  const values2 = collectNumbers(ctx, [args[0] ?? null]);
@@ -15940,9 +16338,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
15940
16338
  );
15941
16339
  var FINANCIAL_FUNCTIONS = [
15942
16340
  ...DEPRECIATION_FUNCTIONS,
16341
+ ...COUPON_FUNCTIONS,
16342
+ ...BOND_FUNCTIONS,
16343
+ ...SECURITY_FUNCTIONS,
15943
16344
  numeric(
15944
16345
  "PMT",
15945
- C9,
16346
+ C12,
15946
16347
  "PMT(rate, nper, pv, [fv], [type])",
15947
16348
  "The payment for a loan.",
15948
16349
  3,
@@ -15951,7 +16352,7 @@ var FINANCIAL_FUNCTIONS = [
15951
16352
  ),
15952
16353
  numeric(
15953
16354
  "FV",
15954
- C9,
16355
+ C12,
15955
16356
  "FV(rate, nper, pmt, [pv], [type])",
15956
16357
  "The future value of an investment.",
15957
16358
  3,
@@ -15960,7 +16361,7 @@ var FINANCIAL_FUNCTIONS = [
15960
16361
  ),
15961
16362
  numeric(
15962
16363
  "PV",
15963
- C9,
16364
+ C12,
15964
16365
  "PV(rate, nper, pmt, [fv], [type])",
15965
16366
  "The present value of an investment.",
15966
16367
  3,
@@ -15969,7 +16370,7 @@ var FINANCIAL_FUNCTIONS = [
15969
16370
  ),
15970
16371
  numeric(
15971
16372
  "NPER",
15972
- C9,
16373
+ C12,
15973
16374
  "NPER(rate, pmt, pv, [fv], [type])",
15974
16375
  "The number of periods for an investment.",
15975
16376
  3,
@@ -15986,7 +16387,7 @@ var FINANCIAL_FUNCTIONS = [
15986
16387
  ),
15987
16388
  numeric(
15988
16389
  "IPMT",
15989
- C9,
16390
+ C12,
15990
16391
  "IPMT(rate, per, nper, pv, [fv], [type])",
15991
16392
  "The interest part of a payment.",
15992
16393
  4,
@@ -15995,7 +16396,7 @@ var FINANCIAL_FUNCTIONS = [
15995
16396
  ),
15996
16397
  numeric(
15997
16398
  "PPMT",
15998
- C9,
16399
+ C12,
15999
16400
  "PPMT(rate, per, nper, pv, [fv], [type])",
16000
16401
  "The principal part of a payment.",
16001
16402
  4,
@@ -16004,7 +16405,7 @@ var FINANCIAL_FUNCTIONS = [
16004
16405
  ),
16005
16406
  numeric(
16006
16407
  "RATE",
16007
- C9,
16408
+ C12,
16008
16409
  "RATE(nper, pmt, pv, [fv], [type], [guess])",
16009
16410
  "The interest rate per period.",
16010
16411
  3,
@@ -16017,7 +16418,7 @@ var FINANCIAL_FUNCTIONS = [
16017
16418
  ),
16018
16419
  spec(
16019
16420
  "NPV",
16020
- C9,
16421
+ C12,
16021
16422
  "NPV(rate, value1, [value2], ...)",
16022
16423
  "The net present value of cash flows.",
16023
16424
  2,
@@ -16027,7 +16428,7 @@ var FINANCIAL_FUNCTIONS = [
16027
16428
  ),
16028
16429
  spec(
16029
16430
  "IRR",
16030
- C9,
16431
+ C12,
16031
16432
  "IRR(values, [guess])",
16032
16433
  "The internal rate of return.",
16033
16434
  1,
@@ -16044,7 +16445,7 @@ var FINANCIAL_FUNCTIONS = [
16044
16445
  ),
16045
16446
  spec(
16046
16447
  "XNPV",
16047
- C9,
16448
+ C12,
16048
16449
  "XNPV(rate, values, dates)",
16049
16450
  "The net present value of dated cash flows.",
16050
16451
  3,
@@ -16057,7 +16458,7 @@ var FINANCIAL_FUNCTIONS = [
16057
16458
  ),
16058
16459
  spec(
16059
16460
  "XIRR",
16060
- C9,
16461
+ C12,
16061
16462
  "XIRR(values, dates, [guess])",
16062
16463
  "The internal rate of return of dated cash flows.",
16063
16464
  2,
@@ -16071,7 +16472,7 @@ var FINANCIAL_FUNCTIONS = [
16071
16472
  ),
16072
16473
  spec(
16073
16474
  "MIRR",
16074
- C9,
16475
+ C12,
16075
16476
  "MIRR(values, finance_rate, reinvest_rate)",
16076
16477
  "The modified internal rate of return.",
16077
16478
  3,
@@ -16081,9 +16482,9 @@ var FINANCIAL_FUNCTIONS = [
16081
16482
  const finance = num2(args[1]);
16082
16483
  const reinvest = num2(args[2]);
16083
16484
  const n = values2.length;
16084
- const positive3 = values2.map((v) => v > 0 ? v : 0);
16485
+ const positive4 = values2.map((v) => v > 0 ? v : 0);
16085
16486
  const negative = values2.map((v) => v < 0 ? v : 0);
16086
- const fvPos = positive3.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
16487
+ const fvPos = positive4.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
16087
16488
  const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
16088
16489
  if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
16089
16490
  return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
@@ -16288,7 +16689,7 @@ function implicitIntersection(value, frame) {
16288
16689
  }
16289
16690
 
16290
16691
  // src/xlsx/formula/functions/info.ts
16291
- var C10 = "Information";
16692
+ var C13 = "Information";
16292
16693
  var ERROR_NUMBERS = {
16293
16694
  "#NULL!": 1,
16294
16695
  "#DIV/0!": 2,
@@ -16301,7 +16702,7 @@ var ERROR_NUMBERS = {
16301
16702
  "#SPILL!": 9,
16302
16703
  "#CALC!": 14
16303
16704
  };
16304
- var is = (name, syntax, description, test) => spec(name, C10, syntax, description, 1, 1, (args) => test(scalar(args[0])));
16705
+ var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
16305
16706
  var parity = (v, odd) => {
16306
16707
  if (isError(v)) fail(v);
16307
16708
  if (typeof v === "boolean") fail(ERR.VALUE);
@@ -16338,7 +16739,7 @@ var INFO_FUNCTIONS = [
16338
16739
  is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
16339
16740
  spec(
16340
16741
  "ISREF",
16341
- C10,
16742
+ C13,
16342
16743
  "ISREF(value)",
16343
16744
  "TRUE for references.",
16344
16745
  1,
@@ -16348,7 +16749,7 @@ var INFO_FUNCTIONS = [
16348
16749
  ),
16349
16750
  spec(
16350
16751
  "ISFORMULA",
16351
- C10,
16752
+ C13,
16352
16753
  "ISFORMULA(reference)",
16353
16754
  "TRUE when a cell holds a formula.",
16354
16755
  1,
@@ -16362,17 +16763,17 @@ var INFO_FUNCTIONS = [
16362
16763
  },
16363
16764
  ["any"]
16364
16765
  ),
16365
- spec("N", C10, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
16766
+ spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
16366
16767
  const v = scalar(args[0]);
16367
16768
  if (isError(v)) return v;
16368
16769
  if (typeof v === "number") return v;
16369
16770
  if (typeof v === "boolean") return v ? 1 : 0;
16370
16771
  return 0;
16371
16772
  }),
16372
- spec("NA", C10, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
16773
+ spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
16373
16774
  spec(
16374
16775
  "TYPE",
16375
- C10,
16776
+ C13,
16376
16777
  "TYPE(value)",
16377
16778
  "The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
16378
16779
  1,
@@ -16384,13 +16785,13 @@ var INFO_FUNCTIONS = [
16384
16785
  },
16385
16786
  ["any"]
16386
16787
  ),
16387
- spec("ERROR.TYPE", C10, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
16788
+ spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
16388
16789
  const v = scalar(args[0]);
16389
16790
  return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
16390
16791
  }),
16391
16792
  spec(
16392
16793
  "SHEET",
16393
- C10,
16794
+ C13,
16394
16795
  "SHEET([value])",
16395
16796
  "The sheet number of a reference or sheet name.",
16396
16797
  0,
@@ -16406,7 +16807,7 @@ var INFO_FUNCTIONS = [
16406
16807
  ),
16407
16808
  spec(
16408
16809
  "SHEETS",
16409
- C10,
16810
+ C13,
16410
16811
  "SHEETS([reference])",
16411
16812
  "The number of sheets in a reference (or the workbook).",
16412
16813
  0,
@@ -16421,7 +16822,7 @@ var INFO_FUNCTIONS = [
16421
16822
  ),
16422
16823
  spec(
16423
16824
  "CELL",
16424
- C10,
16825
+ C13,
16425
16826
  "CELL(info_type, [reference])",
16426
16827
  "Information about a cell (address, row, col, contents, type, filename, sheet).",
16427
16828
  1,
@@ -16596,7 +16997,7 @@ function broadcast1(a, fn) {
16596
16997
  }
16597
16998
 
16598
16999
  // src/xlsx/formula/functions/lambda.ts
16599
- var C11 = "Logical";
17000
+ var C14 = "Logical";
16600
17001
  function lambdaArg(value) {
16601
17002
  if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
16602
17003
  return value;
@@ -16613,7 +17014,7 @@ function element(ctx, value) {
16613
17014
  var LAMBDA_HELPERS = [
16614
17015
  spec(
16615
17016
  "MAP",
16616
- C11,
17017
+ C14,
16617
17018
  "MAP(array1, ..., lambda)",
16618
17019
  "Applies a LAMBDA to each value of arrays.",
16619
17020
  2,
@@ -16639,7 +17040,7 @@ var LAMBDA_HELPERS = [
16639
17040
  ),
16640
17041
  spec(
16641
17042
  "REDUCE",
16642
- C11,
17043
+ C14,
16643
17044
  "REDUCE([initial_value], array, lambda)",
16644
17045
  "Reduces an array to an accumulated value.",
16645
17046
  2,
@@ -16655,7 +17056,7 @@ var LAMBDA_HELPERS = [
16655
17056
  ),
16656
17057
  spec(
16657
17058
  "SCAN",
16658
- C11,
17059
+ C14,
16659
17060
  "SCAN([initial_value], array, lambda)",
16660
17061
  "The intermediate values of a reduction, as an array.",
16661
17062
  2,
@@ -16673,7 +17074,7 @@ var LAMBDA_HELPERS = [
16673
17074
  ),
16674
17075
  spec(
16675
17076
  "BYROW",
16676
- C11,
17077
+ C14,
16677
17078
  "BYROW(array, lambda)",
16678
17079
  "Applies a LAMBDA to each row, returning a column.",
16679
17080
  2,
@@ -16689,7 +17090,7 @@ var LAMBDA_HELPERS = [
16689
17090
  ),
16690
17091
  spec(
16691
17092
  "BYCOL",
16692
- C11,
17093
+ C14,
16693
17094
  "BYCOL(array, lambda)",
16694
17095
  "Applies a LAMBDA to each column, returning a row.",
16695
17096
  2,
@@ -16708,7 +17109,7 @@ var LAMBDA_HELPERS = [
16708
17109
  ),
16709
17110
  spec(
16710
17111
  "MAKEARRAY",
16711
- C11,
17112
+ C14,
16712
17113
  "MAKEARRAY(rows, columns, lambda)",
16713
17114
  "An array built by calling a LAMBDA for each position.",
16714
17115
  3,
@@ -16725,7 +17126,7 @@ var LAMBDA_HELPERS = [
16725
17126
  ];
16726
17127
 
16727
17128
  // src/xlsx/formula/functions/logical.ts
16728
- var C12 = "Logical";
17129
+ var C15 = "Logical";
16729
17130
  function deref(ctx, value) {
16730
17131
  if (value instanceof RefValue) {
16731
17132
  if (value.isCell()) {
@@ -16795,7 +17196,7 @@ function logicalValues(ctx, args) {
16795
17196
  if (out.length === 0) fail(ERR.VALUE);
16796
17197
  return out;
16797
17198
  }
16798
- var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C12) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
17199
+ var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
16799
17200
  function localName(arg) {
16800
17201
  const node = arg?.node;
16801
17202
  if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
@@ -16889,7 +17290,7 @@ var LOGICAL_FUNCTIONS = [
16889
17290
  ),
16890
17291
  {
16891
17292
  name: "NOT",
16892
- category: C12,
17293
+ category: C15,
16893
17294
  syntax: "NOT(logical)",
16894
17295
  description: "Reverses a logical value.",
16895
17296
  minArgs: 1,
@@ -16898,7 +17299,7 @@ var LOGICAL_FUNCTIONS = [
16898
17299
  },
16899
17300
  {
16900
17301
  name: "TRUE",
16901
- category: C12,
17302
+ category: C15,
16902
17303
  syntax: "TRUE()",
16903
17304
  description: "The logical value TRUE.",
16904
17305
  minArgs: 0,
@@ -16907,7 +17308,7 @@ var LOGICAL_FUNCTIONS = [
16907
17308
  },
16908
17309
  {
16909
17310
  name: "FALSE",
16910
- category: C12,
17311
+ category: C15,
16911
17312
  syntax: "FALSE()",
16912
17313
  description: "The logical value FALSE.",
16913
17314
  minArgs: 0,
@@ -17105,7 +17506,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
17105
17506
  }
17106
17507
 
17107
17508
  // src/xlsx/formula/functions/reference.ts
17108
- var C13 = "Lookup & Reference";
17509
+ var C16 = "Lookup & Reference";
17109
17510
  function refArg(value) {
17110
17511
  if (value instanceof RefValue) return value;
17111
17512
  if (isError(value)) fail(value);
@@ -17194,7 +17595,7 @@ function rowsOrCols(value, ctx, axis) {
17194
17595
  var REFERENCE_FUNCTIONS = [
17195
17596
  spec(
17196
17597
  "OFFSET",
17197
- C13,
17598
+ C16,
17198
17599
  "OFFSET(reference, rows, cols, [height], [width])",
17199
17600
  "A reference offset from a starting reference.",
17200
17601
  3,
@@ -17205,7 +17606,7 @@ var REFERENCE_FUNCTIONS = [
17205
17606
  ),
17206
17607
  spec(
17207
17608
  "INDIRECT",
17208
- C13,
17609
+ C16,
17209
17610
  "INDIRECT(ref_text, [a1])",
17210
17611
  "The reference named by a text.",
17211
17612
  1,
@@ -17221,7 +17622,7 @@ var REFERENCE_FUNCTIONS = [
17221
17622
  ),
17222
17623
  spec(
17223
17624
  "ROW",
17224
- C13,
17625
+ C16,
17225
17626
  "ROW([reference])",
17226
17627
  "The row number of a reference.",
17227
17628
  0,
@@ -17231,7 +17632,7 @@ var REFERENCE_FUNCTIONS = [
17231
17632
  ),
17232
17633
  spec(
17233
17634
  "COLUMN",
17234
- C13,
17635
+ C16,
17235
17636
  "COLUMN([reference])",
17236
17637
  "The column number of a reference.",
17237
17638
  0,
@@ -17241,7 +17642,7 @@ var REFERENCE_FUNCTIONS = [
17241
17642
  ),
17242
17643
  spec(
17243
17644
  "ROWS",
17244
- C13,
17645
+ C16,
17245
17646
  "ROWS(array)",
17246
17647
  "The number of rows in a reference or array.",
17247
17648
  1,
@@ -17254,7 +17655,7 @@ var REFERENCE_FUNCTIONS = [
17254
17655
  ),
17255
17656
  spec(
17256
17657
  "COLUMNS",
17257
- C13,
17658
+ C16,
17258
17659
  "COLUMNS(array)",
17259
17660
  "The number of columns in a reference or array.",
17260
17661
  1,
@@ -17267,7 +17668,7 @@ var REFERENCE_FUNCTIONS = [
17267
17668
  ),
17268
17669
  spec(
17269
17670
  "AREAS",
17270
- C13,
17671
+ C16,
17271
17672
  "AREAS(reference)",
17272
17673
  "The number of areas in a reference.",
17273
17674
  1,
@@ -17277,7 +17678,7 @@ var REFERENCE_FUNCTIONS = [
17277
17678
  ),
17278
17679
  spec(
17279
17680
  "ADDRESS",
17280
- C13,
17681
+ C16,
17281
17682
  "ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
17282
17683
  "A cell address as text.",
17283
17684
  2,
@@ -17286,7 +17687,7 @@ var REFERENCE_FUNCTIONS = [
17286
17687
  ),
17287
17688
  spec(
17288
17689
  "HYPERLINK",
17289
- C13,
17690
+ C16,
17290
17691
  "HYPERLINK(link_location, [friendly_name])",
17291
17692
  "A link; the cell shows the friendly name.",
17292
17693
  1,
@@ -17295,7 +17696,7 @@ var REFERENCE_FUNCTIONS = [
17295
17696
  ),
17296
17697
  spec(
17297
17698
  "ANCHORARRAY",
17298
- C13,
17699
+ C16,
17299
17700
  "ANCHORARRAY(reference)",
17300
17701
  "The spill range of a dynamic array formula (A1#).",
17301
17702
  1,
@@ -17315,7 +17716,7 @@ var REFERENCE_FUNCTIONS = [
17315
17716
  ),
17316
17717
  spec(
17317
17718
  "SINGLE",
17318
- C13,
17719
+ C16,
17319
17720
  "SINGLE(value)",
17320
17721
  "Implicit intersection (the @ operator).",
17321
17722
  1,
@@ -17325,7 +17726,7 @@ var REFERENCE_FUNCTIONS = [
17325
17726
  ),
17326
17727
  spec(
17327
17728
  "FORMULATEXT",
17328
- C13,
17729
+ C16,
17329
17730
  "FORMULATEXT(reference)",
17330
17731
  "The formula of a cell as text.",
17331
17732
  1,
@@ -17345,7 +17746,7 @@ var REFERENCE_FUNCTIONS = [
17345
17746
  ];
17346
17747
 
17347
17748
  // src/xlsx/formula/functions/lookup.ts
17348
- var C14 = "Lookup & Reference";
17749
+ var C17 = "Lookup & Reference";
17349
17750
  function cellOf(value, row2, col) {
17350
17751
  if (value instanceof RefValue) {
17351
17752
  const area = value.areas[0];
@@ -17472,7 +17873,7 @@ var LOOKUP_FUNCTIONS = [
17472
17873
  ...REFERENCE_FUNCTIONS,
17473
17874
  spec(
17474
17875
  "VLOOKUP",
17475
- C14,
17876
+ C17,
17476
17877
  "VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
17477
17878
  "Looks up a value in the first column of a table.",
17478
17879
  3,
@@ -17482,7 +17883,7 @@ var LOOKUP_FUNCTIONS = [
17482
17883
  ),
17483
17884
  spec(
17484
17885
  "HLOOKUP",
17485
- C14,
17886
+ C17,
17486
17887
  "HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
17487
17888
  "Looks up a value in the first row of a table.",
17488
17889
  3,
@@ -17492,7 +17893,7 @@ var LOOKUP_FUNCTIONS = [
17492
17893
  ),
17493
17894
  spec(
17494
17895
  "LOOKUP",
17495
- C14,
17896
+ C17,
17496
17897
  "LOOKUP(lookup_value, lookup_vector, [result_vector])",
17497
17898
  "Looks up a value in a sorted vector or array.",
17498
17899
  2,
@@ -17502,7 +17903,7 @@ var LOOKUP_FUNCTIONS = [
17502
17903
  ),
17503
17904
  spec(
17504
17905
  "MATCH",
17505
- C14,
17906
+ C17,
17506
17907
  "MATCH(lookup_value, lookup_array, [match_type])",
17507
17908
  "The position of a value in a range.",
17508
17909
  2,
@@ -17512,7 +17913,7 @@ var LOOKUP_FUNCTIONS = [
17512
17913
  ),
17513
17914
  spec(
17514
17915
  "XMATCH",
17515
- C14,
17916
+ C17,
17516
17917
  "XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
17517
17918
  "The position of a value with flexible matching.",
17518
17919
  2,
@@ -17532,7 +17933,7 @@ var LOOKUP_FUNCTIONS = [
17532
17933
  ),
17533
17934
  spec(
17534
17935
  "XLOOKUP",
17535
- C14,
17936
+ C17,
17536
17937
  "XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
17537
17938
  "Searches a range and returns the matching item from another.",
17538
17939
  3,
@@ -17542,7 +17943,7 @@ var LOOKUP_FUNCTIONS = [
17542
17943
  ),
17543
17944
  spec(
17544
17945
  "INDEX",
17545
- C14,
17946
+ C17,
17546
17947
  "INDEX(array, row_num, [column_num], [area_num])",
17547
17948
  "The value or reference at a position.",
17548
17949
  1,
@@ -17552,7 +17953,7 @@ var LOOKUP_FUNCTIONS = [
17552
17953
  ),
17553
17954
  spec(
17554
17955
  "CHOOSE",
17555
- C14,
17956
+ C17,
17556
17957
  "CHOOSE(index_num, value1, [value2], ...)",
17557
17958
  "Chooses a value from a list by index.",
17558
17959
  2,
@@ -17756,7 +18157,7 @@ function liftCriteria(ctx, pairs, fn) {
17756
18157
  }
17757
18158
 
17758
18159
  // src/xlsx/formula/functions/math-sum.ts
17759
- var C15 = "Math & Trig";
18160
+ var C18 = "Math & Trig";
17760
18161
  var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
17761
18162
  function sumProduct(ctx, args) {
17762
18163
  const matrices = args.map((a) => ctx.toMatrix(a));
@@ -17861,7 +18262,7 @@ function aggregate(code, values2, k) {
17861
18262
  var SUM_FUNCTIONS = [
17862
18263
  spec(
17863
18264
  "SUM",
17864
- C15,
18265
+ C18,
17865
18266
  "SUM(number1, [number2], ...)",
17866
18267
  "Adds its arguments.",
17867
18268
  0,
@@ -17871,7 +18272,7 @@ var SUM_FUNCTIONS = [
17871
18272
  ),
17872
18273
  spec(
17873
18274
  "PRODUCT",
17874
- C15,
18275
+ C18,
17875
18276
  "PRODUCT(number1, [number2], ...)",
17876
18277
  "Multiplies its arguments.",
17877
18278
  1,
@@ -17884,7 +18285,7 @@ var SUM_FUNCTIONS = [
17884
18285
  ),
17885
18286
  spec(
17886
18287
  "SUMSQ",
17887
- C15,
18288
+ C18,
17888
18289
  "SUMSQ(number1, [number2], ...)",
17889
18290
  "The sum of the squares of the arguments.",
17890
18291
  1,
@@ -17894,7 +18295,7 @@ var SUM_FUNCTIONS = [
17894
18295
  ),
17895
18296
  spec(
17896
18297
  "SUMPRODUCT",
17897
- C15,
18298
+ C18,
17898
18299
  "SUMPRODUCT(array1, [array2], ...)",
17899
18300
  "The sum of the products of corresponding array elements.",
17900
18301
  1,
@@ -17904,7 +18305,7 @@ var SUM_FUNCTIONS = [
17904
18305
  ),
17905
18306
  spec(
17906
18307
  "SUMX2MY2",
17907
- C15,
18308
+ C18,
17908
18309
  "SUMX2MY2(array_x, array_y)",
17909
18310
  "Sum of the differences of squares.",
17910
18311
  2,
@@ -17914,7 +18315,7 @@ var SUM_FUNCTIONS = [
17914
18315
  ),
17915
18316
  spec(
17916
18317
  "SUMX2PY2",
17917
- C15,
18318
+ C18,
17918
18319
  "SUMX2PY2(array_x, array_y)",
17919
18320
  "Sum of the sums of squares.",
17920
18321
  2,
@@ -17924,7 +18325,7 @@ var SUM_FUNCTIONS = [
17924
18325
  ),
17925
18326
  spec(
17926
18327
  "SUMXMY2",
17927
- C15,
18328
+ C18,
17928
18329
  "SUMXMY2(array_x, array_y)",
17929
18330
  "Sum of the squares of differences.",
17930
18331
  2,
@@ -17934,7 +18335,7 @@ var SUM_FUNCTIONS = [
17934
18335
  ),
17935
18336
  spec(
17936
18337
  "SUMIF",
17937
- C15,
18338
+ C18,
17938
18339
  "SUMIF(range, criteria, [sum_range])",
17939
18340
  "Adds the cells that meet a criterion.",
17940
18341
  2,
@@ -17947,7 +18348,7 @@ var SUM_FUNCTIONS = [
17947
18348
  ),
17948
18349
  spec(
17949
18350
  "SUMIFS",
17950
- C15,
18351
+ C18,
17951
18352
  "SUMIFS(sum_range, criteria_range1, criteria1, ...)",
17952
18353
  "Adds the cells that meet several criteria.",
17953
18354
  3,
@@ -17961,7 +18362,7 @@ var SUM_FUNCTIONS = [
17961
18362
  ),
17962
18363
  spec(
17963
18364
  "SUBTOTAL",
17964
- C15,
18365
+ C18,
17965
18366
  "SUBTOTAL(function_num, ref1, ...)",
17966
18367
  "A subtotal (1-11 include hidden rows, 101-111 ignore them).",
17967
18368
  2,
@@ -17976,7 +18377,7 @@ var SUM_FUNCTIONS = [
17976
18377
  ),
17977
18378
  spec(
17978
18379
  "AGGREGATE",
17979
- C15,
18380
+ C18,
17980
18381
  "AGGREGATE(function_num, options, ref1, ...)",
17981
18382
  "An aggregate that can ignore hidden rows and errors.",
17982
18383
  3,
@@ -18016,14 +18417,14 @@ var SUM_FUNCTIONS = [
18016
18417
  ];
18017
18418
 
18018
18419
  // src/xlsx/formula/functions/math-more.ts
18019
- var C16 = "Math & Trig";
18420
+ var C19 = "Math & Trig";
18020
18421
  var MATH_MORE = [
18021
- numeric("SIN", C16, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
18022
- numeric("COS", C16, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
18023
- numeric("TAN", C16, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
18422
+ numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
18423
+ numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
18424
+ numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
18024
18425
  numeric(
18025
18426
  "ASIN",
18026
- C16,
18427
+ C19,
18027
18428
  "ASIN(number)",
18028
18429
  "The arcsine in radians.",
18029
18430
  1,
@@ -18032,17 +18433,17 @@ var MATH_MORE = [
18032
18433
  ),
18033
18434
  numeric(
18034
18435
  "ACOS",
18035
- C16,
18436
+ C19,
18036
18437
  "ACOS(number)",
18037
18438
  "The arccosine in radians.",
18038
18439
  1,
18039
18440
  1,
18040
18441
  (x) => domain(Math.abs(x) <= 1, Math.acos(x))
18041
18442
  ),
18042
- numeric("ATAN", C16, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
18443
+ numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
18043
18444
  numeric(
18044
18445
  "ATAN2",
18045
- C16,
18446
+ C19,
18046
18447
  "ATAN2(x_num, y_num)",
18047
18448
  "The arctangent of x and y coordinates.",
18048
18449
  2,
@@ -18052,13 +18453,13 @@ var MATH_MORE = [
18052
18453
  return Math.atan2(y ?? 0, x);
18053
18454
  }
18054
18455
  ),
18055
- numeric("SINH", C16, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
18056
- numeric("COSH", C16, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
18057
- numeric("TANH", C16, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
18058
- numeric("ASINH", C16, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
18456
+ numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
18457
+ numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
18458
+ numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
18459
+ numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
18059
18460
  numeric(
18060
18461
  "ACOSH",
18061
- C16,
18462
+ C19,
18062
18463
  "ACOSH(number)",
18063
18464
  "The inverse hyperbolic cosine.",
18064
18465
  1,
@@ -18067,7 +18468,7 @@ var MATH_MORE = [
18067
18468
  ),
18068
18469
  numeric(
18069
18470
  "ATANH",
18070
- C16,
18471
+ C19,
18071
18472
  "ATANH(number)",
18072
18473
  "The inverse hyperbolic tangent.",
18073
18474
  1,
@@ -18076,7 +18477,7 @@ var MATH_MORE = [
18076
18477
  ),
18077
18478
  numeric(
18078
18479
  "COT",
18079
- C16,
18480
+ C19,
18080
18481
  "COT(number)",
18081
18482
  "The cotangent of an angle.",
18082
18483
  1,
@@ -18085,7 +18486,7 @@ var MATH_MORE = [
18085
18486
  ),
18086
18487
  numeric(
18087
18488
  "COTH",
18088
- C16,
18489
+ C19,
18089
18490
  "COTH(number)",
18090
18491
  "The hyperbolic cotangent.",
18091
18492
  1,
@@ -18094,7 +18495,7 @@ var MATH_MORE = [
18094
18495
  ),
18095
18496
  numeric(
18096
18497
  "CSC",
18097
- C16,
18498
+ C19,
18098
18499
  "CSC(number)",
18099
18500
  "The cosecant of an angle.",
18100
18501
  1,
@@ -18103,19 +18504,19 @@ var MATH_MORE = [
18103
18504
  ),
18104
18505
  numeric(
18105
18506
  "CSCH",
18106
- C16,
18507
+ C19,
18107
18508
  "CSCH(number)",
18108
18509
  "The hyperbolic cosecant.",
18109
18510
  1,
18110
18511
  1,
18111
18512
  (x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
18112
18513
  ),
18113
- numeric("SEC", C16, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
18114
- numeric("SECH", C16, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
18115
- numeric("ACOT", C16, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
18514
+ numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
18515
+ numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
18516
+ numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
18116
18517
  numeric(
18117
18518
  "ACOTH",
18118
- C16,
18519
+ C19,
18119
18520
  "ACOTH(number)",
18120
18521
  "The inverse hyperbolic cotangent.",
18121
18522
  1,
@@ -18124,7 +18525,7 @@ var MATH_MORE = [
18124
18525
  ),
18125
18526
  numeric(
18126
18527
  "DEGREES",
18127
- C16,
18528
+ C19,
18128
18529
  "DEGREES(angle)",
18129
18530
  "Converts radians to degrees.",
18130
18531
  1,
@@ -18133,7 +18534,7 @@ var MATH_MORE = [
18133
18534
  ),
18134
18535
  numeric(
18135
18536
  "RADIANS",
18136
- C16,
18537
+ C19,
18137
18538
  "RADIANS(angle)",
18138
18539
  "Converts degrees to radians.",
18139
18540
  1,
@@ -18142,7 +18543,7 @@ var MATH_MORE = [
18142
18543
  ),
18143
18544
  spec(
18144
18545
  "RAND",
18145
- C16,
18546
+ C19,
18146
18547
  "RAND()",
18147
18548
  "A random number between 0 and 1.",
18148
18549
  0,
@@ -18153,7 +18554,7 @@ var MATH_MORE = [
18153
18554
  ),
18154
18555
  spec(
18155
18556
  "RANDBETWEEN",
18156
- C16,
18557
+ C19,
18157
18558
  "RANDBETWEEN(bottom, top)",
18158
18559
  "A random integer between two numbers.",
18159
18560
  2,
@@ -18169,7 +18570,7 @@ var MATH_MORE = [
18169
18570
  ),
18170
18571
  spec(
18171
18572
  "SERIESSUM",
18172
- C16,
18573
+ C19,
18173
18574
  "SERIESSUM(x, n, m, coefficients)",
18174
18575
  "The sum of a power series.",
18175
18576
  4,
@@ -18188,7 +18589,7 @@ var MATH_MORE = [
18188
18589
  ];
18189
18590
 
18190
18591
  // src/xlsx/formula/functions/math-combin.ts
18191
- var C17 = "Math & Trig";
18592
+ var C20 = "Math & Trig";
18192
18593
  var fact = (n) => {
18193
18594
  if (n < 0) fail(ERR.NUM);
18194
18595
  let out = 1;
@@ -18212,8 +18613,8 @@ function integers(args, ctx) {
18212
18613
  });
18213
18614
  }
18214
18615
  var COMBINATORIC_FUNCTIONS = [
18215
- numeric("FACT", C17, "FACT(number)", "The factorial of a number.", 1, 1, fact),
18216
- numeric("FACTDOUBLE", C17, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
18616
+ numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
18617
+ numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
18217
18618
  if (n < -1) fail(ERR.NUM);
18218
18619
  let out = 1;
18219
18620
  for (let i = Math.trunc(n); i > 1; i -= 2) out *= i;
@@ -18221,7 +18622,7 @@ var COMBINATORIC_FUNCTIONS = [
18221
18622
  }),
18222
18623
  numeric(
18223
18624
  "COMBIN",
18224
- C17,
18625
+ C20,
18225
18626
  "COMBIN(number, number_chosen)",
18226
18627
  "The number of combinations.",
18227
18628
  2,
@@ -18230,7 +18631,7 @@ var COMBINATORIC_FUNCTIONS = [
18230
18631
  ),
18231
18632
  numeric(
18232
18633
  "COMBINA",
18233
- C17,
18634
+ C20,
18234
18635
  "COMBINA(number, number_chosen)",
18235
18636
  "Combinations with repetitions.",
18236
18637
  2,
@@ -18242,7 +18643,7 @@ var COMBINATORIC_FUNCTIONS = [
18242
18643
  ),
18243
18644
  spec(
18244
18645
  "MULTINOMIAL",
18245
- C17,
18646
+ C20,
18246
18647
  "MULTINOMIAL(number1, ...)",
18247
18648
  "The multinomial of a set of numbers.",
18248
18649
  1,
@@ -18256,7 +18657,7 @@ var COMBINATORIC_FUNCTIONS = [
18256
18657
  ),
18257
18658
  spec(
18258
18659
  "GCD",
18259
- C17,
18660
+ C20,
18260
18661
  "GCD(number1, ...)",
18261
18662
  "The greatest common divisor.",
18262
18663
  1,
@@ -18266,7 +18667,7 @@ var COMBINATORIC_FUNCTIONS = [
18266
18667
  ),
18267
18668
  spec(
18268
18669
  "LCM",
18269
- C17,
18670
+ C20,
18270
18671
  "LCM(number1, ...)",
18271
18672
  "The least common multiple.",
18272
18673
  1,
@@ -18314,7 +18715,7 @@ function mround(x, m) {
18314
18715
  }
18315
18716
 
18316
18717
  // src/xlsx/formula/functions/math.ts
18317
- var C18 = "Math & Trig";
18718
+ var C21 = "Math & Trig";
18318
18719
  function roundTo(x, digits2, mode) {
18319
18720
  if (!Number.isFinite(x)) return x;
18320
18721
  const d = Math.trunc(digits2);
@@ -18333,10 +18734,10 @@ var quotientMultiple = (x, sig, op) => {
18333
18734
  var MATH_FUNCTIONS = [
18334
18735
  ...MATH_MORE,
18335
18736
  ...SUM_FUNCTIONS,
18336
- numeric("ABS", C18, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
18737
+ numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
18337
18738
  numeric(
18338
18739
  "SIGN",
18339
- C18,
18740
+ C21,
18340
18741
  "SIGN(number)",
18341
18742
  "The sign of a number: 1, 0 or -1.",
18342
18743
  1,
@@ -18345,7 +18746,7 @@ var MATH_FUNCTIONS = [
18345
18746
  ),
18346
18747
  numeric(
18347
18748
  "INT",
18348
- C18,
18749
+ C21,
18349
18750
  "INT(number)",
18350
18751
  "Rounds a number down to the nearest integer.",
18351
18752
  1,
@@ -18354,7 +18755,7 @@ var MATH_FUNCTIONS = [
18354
18755
  ),
18355
18756
  numeric(
18356
18757
  "TRUNC",
18357
- C18,
18758
+ C21,
18358
18759
  "TRUNC(number, [num_digits])",
18359
18760
  "Truncates a number toward zero.",
18360
18761
  1,
@@ -18363,7 +18764,7 @@ var MATH_FUNCTIONS = [
18363
18764
  ),
18364
18765
  numeric(
18365
18766
  "ROUND",
18366
- C18,
18767
+ C21,
18367
18768
  "ROUND(number, num_digits)",
18368
18769
  "Rounds a number to a number of digits.",
18369
18770
  2,
@@ -18372,7 +18773,7 @@ var MATH_FUNCTIONS = [
18372
18773
  ),
18373
18774
  numeric(
18374
18775
  "ROUNDUP",
18375
- C18,
18776
+ C21,
18376
18777
  "ROUNDUP(number, num_digits)",
18377
18778
  "Rounds a number away from zero.",
18378
18779
  2,
@@ -18381,7 +18782,7 @@ var MATH_FUNCTIONS = [
18381
18782
  ),
18382
18783
  numeric(
18383
18784
  "ROUNDDOWN",
18384
- C18,
18785
+ C21,
18385
18786
  "ROUNDDOWN(number, num_digits)",
18386
18787
  "Rounds a number toward zero.",
18387
18788
  2,
@@ -18390,7 +18791,7 @@ var MATH_FUNCTIONS = [
18390
18791
  ),
18391
18792
  numeric(
18392
18793
  "MROUND",
18393
- C18,
18794
+ C21,
18394
18795
  "MROUND(number, multiple)",
18395
18796
  "Rounds a number to the nearest multiple.",
18396
18797
  2,
@@ -18399,7 +18800,7 @@ var MATH_FUNCTIONS = [
18399
18800
  ),
18400
18801
  numeric(
18401
18802
  "CEILING",
18402
- C18,
18803
+ C21,
18403
18804
  "CEILING(number, significance)",
18404
18805
  "Rounds a number up to a multiple of significance.",
18405
18806
  2,
@@ -18411,7 +18812,7 @@ var MATH_FUNCTIONS = [
18411
18812
  ),
18412
18813
  numeric(
18413
18814
  "FLOOR",
18414
- C18,
18815
+ C21,
18415
18816
  "FLOOR(number, significance)",
18416
18817
  "Rounds a number down to a multiple of significance.",
18417
18818
  2,
@@ -18424,7 +18825,7 @@ var MATH_FUNCTIONS = [
18424
18825
  ),
18425
18826
  numeric(
18426
18827
  "CEILING.MATH",
18427
- C18,
18828
+ C21,
18428
18829
  "CEILING.MATH(number, [significance], [mode])",
18429
18830
  "Rounds a number up to an integer or multiple.",
18430
18831
  1,
@@ -18437,7 +18838,7 @@ var MATH_FUNCTIONS = [
18437
18838
  ),
18438
18839
  numeric(
18439
18840
  "FLOOR.MATH",
18440
- C18,
18841
+ C21,
18441
18842
  "FLOOR.MATH(number, [significance], [mode])",
18442
18843
  "Rounds a number down to an integer or multiple.",
18443
18844
  1,
@@ -18450,7 +18851,7 @@ var MATH_FUNCTIONS = [
18450
18851
  ),
18451
18852
  numeric(
18452
18853
  "CEILING.PRECISE",
18453
- C18,
18854
+ C21,
18454
18855
  "CEILING.PRECISE(number, [significance])",
18455
18856
  "Rounds a number up regardless of sign.",
18456
18857
  1,
@@ -18459,7 +18860,7 @@ var MATH_FUNCTIONS = [
18459
18860
  ),
18460
18861
  numeric(
18461
18862
  "ISO.CEILING",
18462
- C18,
18863
+ C21,
18463
18864
  "ISO.CEILING(number, [significance])",
18464
18865
  "Rounds a number up regardless of sign.",
18465
18866
  1,
@@ -18468,7 +18869,7 @@ var MATH_FUNCTIONS = [
18468
18869
  ),
18469
18870
  numeric(
18470
18871
  "FLOOR.PRECISE",
18471
- C18,
18872
+ C21,
18472
18873
  "FLOOR.PRECISE(number, [significance])",
18473
18874
  "Rounds a number down regardless of sign.",
18474
18875
  1,
@@ -18477,7 +18878,7 @@ var MATH_FUNCTIONS = [
18477
18878
  ),
18478
18879
  numeric(
18479
18880
  "EVEN",
18480
- C18,
18881
+ C21,
18481
18882
  "EVEN(number)",
18482
18883
  "Rounds a number away from zero to an even integer.",
18483
18884
  1,
@@ -18486,7 +18887,7 @@ var MATH_FUNCTIONS = [
18486
18887
  ),
18487
18888
  numeric(
18488
18889
  "ODD",
18489
- C18,
18890
+ C21,
18490
18891
  "ODD(number)",
18491
18892
  "Rounds a number away from zero to an odd integer.",
18492
18893
  1,
@@ -18498,7 +18899,7 @@ var MATH_FUNCTIONS = [
18498
18899
  ),
18499
18900
  numeric(
18500
18901
  "MOD",
18501
- C18,
18902
+ C21,
18502
18903
  "MOD(number, divisor)",
18503
18904
  "The remainder after division (sign of the divisor).",
18504
18905
  2,
@@ -18507,7 +18908,7 @@ var MATH_FUNCTIONS = [
18507
18908
  ),
18508
18909
  numeric(
18509
18910
  "QUOTIENT",
18510
- C18,
18911
+ C21,
18511
18912
  "QUOTIENT(numerator, denominator)",
18512
18913
  "The integer part of a division.",
18513
18914
  2,
@@ -18519,7 +18920,7 @@ var MATH_FUNCTIONS = [
18519
18920
  ),
18520
18921
  numeric(
18521
18922
  "SQRT",
18522
- C18,
18923
+ C21,
18523
18924
  "SQRT(number)",
18524
18925
  "The positive square root.",
18525
18926
  1,
@@ -18528,7 +18929,7 @@ var MATH_FUNCTIONS = [
18528
18929
  ),
18529
18930
  numeric(
18530
18931
  "SQRTPI",
18531
- C18,
18932
+ C21,
18532
18933
  "SQRTPI(number)",
18533
18934
  "The square root of number * pi.",
18534
18935
  1,
@@ -18537,18 +18938,18 @@ var MATH_FUNCTIONS = [
18537
18938
  ),
18538
18939
  numeric(
18539
18940
  "POWER",
18540
- C18,
18941
+ C21,
18541
18942
  "POWER(number, power)",
18542
18943
  "A number raised to a power.",
18543
18944
  2,
18544
18945
  2,
18545
18946
  (b, e) => power(b, e ?? 1)
18546
18947
  ),
18547
- numeric("EXP", C18, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
18548
- numeric("LN", C18, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
18948
+ numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
18949
+ numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
18549
18950
  numeric(
18550
18951
  "LOG10",
18551
- C18,
18952
+ C21,
18552
18953
  "LOG10(number)",
18553
18954
  "The base-10 logarithm.",
18554
18955
  1,
@@ -18557,7 +18958,7 @@ var MATH_FUNCTIONS = [
18557
18958
  ),
18558
18959
  numeric(
18559
18960
  "LOG",
18560
- C18,
18961
+ C21,
18561
18962
  "LOG(number, [base])",
18562
18963
  "The logarithm to a base (10 by default).",
18563
18964
  1,
@@ -18569,12 +18970,12 @@ var MATH_FUNCTIONS = [
18569
18970
  return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
18570
18971
  }
18571
18972
  ),
18572
- numeric("PI", C18, "PI()", "The value of pi.", 0, 0, () => Math.PI),
18973
+ numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
18573
18974
  ...COMBINATORIC_FUNCTIONS
18574
18975
  ];
18575
18976
 
18576
18977
  // src/xlsx/formula/functions/matrix.ts
18577
- var C19 = "Math & Trig";
18978
+ var C22 = "Math & Trig";
18578
18979
  function numbers2(ctx, value) {
18579
18980
  return ctx.toMatrix(value ?? null).data.map(
18580
18981
  (row2) => row2.map((v) => {
@@ -18633,7 +19034,7 @@ function eliminate(input, invert2) {
18633
19034
  var MATRIX_FUNCTIONS = [
18634
19035
  spec(
18635
19036
  "MMULT",
18636
- C19,
19037
+ C22,
18637
19038
  "MMULT(array1, array2)",
18638
19039
  "The matrix product of two arrays.",
18639
19040
  2,
@@ -18654,7 +19055,7 @@ var MATRIX_FUNCTIONS = [
18654
19055
  ),
18655
19056
  spec(
18656
19057
  "MDETERM",
18657
- C19,
19058
+ C22,
18658
19059
  "MDETERM(array)",
18659
19060
  "The determinant of a square matrix.",
18660
19061
  1,
@@ -18664,7 +19065,7 @@ var MATRIX_FUNCTIONS = [
18664
19065
  ),
18665
19066
  spec(
18666
19067
  "MINVERSE",
18667
- C19,
19068
+ C22,
18668
19069
  "MINVERSE(array)",
18669
19070
  "The inverse of a square matrix.",
18670
19071
  1,
@@ -18676,7 +19077,7 @@ var MATRIX_FUNCTIONS = [
18676
19077
  },
18677
19078
  ["any"]
18678
19079
  ),
18679
- spec("MUNIT", C19, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
19080
+ spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
18680
19081
  const n = int3(args[0]);
18681
19082
  if (n < 1) fail(ERR.VALUE);
18682
19083
  return Matrix.build(n, n, (r, c2) => r === c2 ? 1 : 0);
@@ -18743,7 +19144,7 @@ function fitStatistics(fit) {
18743
19144
  }
18744
19145
 
18745
19146
  // src/xlsx/formula/functions/regression.ts
18746
- var C20 = "Statistical";
19147
+ var C23 = "Statistical";
18747
19148
  function numbersOf2(ctx, value) {
18748
19149
  return ctx.toMatrix(value ?? null).data.map(
18749
19150
  (row2) => row2.map((v) => {
@@ -18812,7 +19213,7 @@ var ARGS = ["any"];
18812
19213
  var REGRESSION_FUNCTIONS = [
18813
19214
  spec(
18814
19215
  "LINEST",
18815
- C20,
19216
+ C23,
18816
19217
  "LINEST(known_y, [known_x], [const], [stats])",
18817
19218
  "The statistics of a straight-line (or multiple linear) least-squares fit.",
18818
19219
  1,
@@ -18826,7 +19227,7 @@ var REGRESSION_FUNCTIONS = [
18826
19227
  ),
18827
19228
  spec(
18828
19229
  "LOGEST",
18829
- C20,
19230
+ C23,
18830
19231
  "LOGEST(known_y, [known_x], [const], [stats])",
18831
19232
  "The statistics of an exponential-curve fit.",
18832
19233
  1,
@@ -18844,7 +19245,7 @@ var REGRESSION_FUNCTIONS = [
18844
19245
  ),
18845
19246
  spec(
18846
19247
  "TREND",
18847
- C20,
19248
+ C23,
18848
19249
  "TREND(known_y, [known_x], [new_x], [const])",
18849
19250
  "Values along a linear trend.",
18850
19251
  1,
@@ -18858,7 +19259,7 @@ var REGRESSION_FUNCTIONS = [
18858
19259
  ),
18859
19260
  spec(
18860
19261
  "GROWTH",
18861
- C20,
19262
+ C23,
18862
19263
  "GROWTH(known_y, [known_x], [new_x], [const])",
18863
19264
  "Values along an exponential trend.",
18864
19265
  1,
@@ -19012,7 +19413,7 @@ var tPdf = (t, df) => Math.exp(
19012
19413
  gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
19013
19414
  );
19014
19415
  var chiCdf = (x, df) => gammaP(df / 2, x / 2);
19015
- var positive = (...values2) => {
19416
+ var positive2 = (...values2) => {
19016
19417
  for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
19017
19418
  };
19018
19419
  var probability = (p) => {
@@ -19037,13 +19438,13 @@ function poisson(k, mean2, cumulative2) {
19037
19438
  return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
19038
19439
  }
19039
19440
  var normDist = (x, m, s, cumulative2) => {
19040
- positive(s);
19441
+ positive2(s);
19041
19442
  const z = (x - m) / s;
19042
19443
  return cumulative2 ? normCdf(z) : normPdf(z) / s;
19043
19444
  };
19044
19445
 
19045
19446
  // src/xlsx/formula/functions/distributions-f.ts
19046
- var C21 = "Statistical";
19447
+ var C24 = "Statistical";
19047
19448
  var degrees = (...values2) => {
19048
19449
  for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
19049
19450
  };
@@ -19064,13 +19465,13 @@ var betaScaled = (x, a, b, lo, hi) => {
19064
19465
  return betaI((x - lo) / (hi - lo), a, b);
19065
19466
  };
19066
19467
  var betaInverse = (p, a, b, lo, hi) => {
19067
- positive(a, b);
19468
+ positive2(a, b);
19068
19469
  if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
19069
19470
  return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
19070
19471
  };
19071
19472
  var gammaInverse = (p, a, b) => {
19072
19473
  prob(p);
19073
- positive(a, b);
19474
+ positive2(a, b);
19074
19475
  return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
19075
19476
  };
19076
19477
  function binomInverse(trials, p, alpha) {
@@ -19102,7 +19503,7 @@ var negbinomPmf = (f, s, p) => {
19102
19503
  var DISTRIBUTION_F = [
19103
19504
  numeric(
19104
19505
  "F.DIST",
19105
- C21,
19506
+ C24,
19106
19507
  "F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
19107
19508
  "The left-tailed F probability distribution.",
19108
19509
  4,
@@ -19118,7 +19519,7 @@ var DISTRIBUTION_F = [
19118
19519
  ...["F.DIST.RT", "FDIST"].map(
19119
19520
  (name) => numeric(
19120
19521
  name,
19121
- C21,
19522
+ C24,
19122
19523
  `${name}(x, deg_freedom1, deg_freedom2)`,
19123
19524
  "The right-tailed F probability distribution.",
19124
19525
  3,
@@ -19132,7 +19533,7 @@ var DISTRIBUTION_F = [
19132
19533
  ),
19133
19534
  numeric(
19134
19535
  "F.INV",
19135
- C21,
19536
+ C24,
19136
19537
  "F.INV(probability, deg_freedom1, deg_freedom2)",
19137
19538
  "The inverse of the left-tailed F distribution.",
19138
19539
  3,
@@ -19146,7 +19547,7 @@ var DISTRIBUTION_F = [
19146
19547
  ...["F.INV.RT", "FINV"].map(
19147
19548
  (name) => numeric(
19148
19549
  name,
19149
- C21,
19550
+ C24,
19150
19551
  `${name}(probability, deg_freedom1, deg_freedom2)`,
19151
19552
  "The inverse of the right-tailed F distribution.",
19152
19553
  3,
@@ -19161,7 +19562,7 @@ var DISTRIBUTION_F = [
19161
19562
  ...["BETA.INV", "BETAINV"].map(
19162
19563
  (name) => numeric(
19163
19564
  name,
19164
- C21,
19565
+ C24,
19165
19566
  `${name}(probability, alpha, beta, [A], [B])`,
19166
19567
  "The inverse of the cumulative beta distribution.",
19167
19568
  3,
@@ -19172,13 +19573,13 @@ var DISTRIBUTION_F = [
19172
19573
  ),
19173
19574
  numeric(
19174
19575
  "BETADIST",
19175
- C21,
19576
+ C24,
19176
19577
  "BETADIST(x, alpha, beta, [A], [B])",
19177
19578
  "The cumulative beta distribution.",
19178
19579
  3,
19179
19580
  5,
19180
19581
  (x, a, b, lo, hi) => {
19181
- positive(a, b);
19582
+ positive2(a, b);
19182
19583
  return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
19183
19584
  },
19184
19585
  [0, 0, 0, 0, 1]
@@ -19186,7 +19587,7 @@ var DISTRIBUTION_F = [
19186
19587
  ...["GAMMA.INV", "GAMMAINV"].map(
19187
19588
  (name) => numeric(
19188
19589
  name,
19189
- C21,
19590
+ C24,
19190
19591
  `${name}(probability, alpha, beta)`,
19191
19592
  "The inverse of the gamma cumulative distribution.",
19192
19593
  3,
@@ -19196,14 +19597,14 @@ var DISTRIBUTION_F = [
19196
19597
  ),
19197
19598
  numeric(
19198
19599
  "GAMMADIST",
19199
- C21,
19600
+ C24,
19200
19601
  "GAMMADIST(x, alpha, beta, cumulative)",
19201
19602
  "The gamma distribution.",
19202
19603
  4,
19203
19604
  4,
19204
19605
  (x, a, b, c2) => {
19205
19606
  if (x < 0) fail(ERR.NUM);
19206
- positive(a, b);
19607
+ positive2(a, b);
19207
19608
  const al = a ?? 1;
19208
19609
  const be = b ?? 1;
19209
19610
  return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
@@ -19211,33 +19612,33 @@ var DISTRIBUTION_F = [
19211
19612
  ),
19212
19613
  numeric(
19213
19614
  "LOGINV",
19214
- C21,
19615
+ C24,
19215
19616
  "LOGINV(probability, mean, standard_dev)",
19216
19617
  "The inverse of the lognormal cumulative distribution.",
19217
19618
  3,
19218
19619
  3,
19219
19620
  (p, m, s) => {
19220
- positive(s);
19621
+ positive2(s);
19221
19622
  if (p <= 0 || p >= 1) fail(ERR.NUM);
19222
19623
  return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
19223
19624
  }
19224
19625
  ),
19225
19626
  numeric(
19226
19627
  "LOGNORMDIST",
19227
- C21,
19628
+ C24,
19228
19629
  "LOGNORMDIST(x, mean, standard_dev)",
19229
19630
  "The cumulative lognormal distribution.",
19230
19631
  3,
19231
19632
  3,
19232
19633
  (x, m, s) => {
19233
- positive(x, s);
19634
+ positive2(x, s);
19234
19635
  return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
19235
19636
  }
19236
19637
  ),
19237
19638
  ...["BINOM.INV", "CRITBINOM"].map(
19238
19639
  (name) => numeric(
19239
19640
  name,
19240
- C21,
19641
+ C24,
19241
19642
  `${name}(trials, probability_s, alpha)`,
19242
19643
  "The smallest value whose cumulative binomial distribution reaches the criterion.",
19243
19644
  3,
@@ -19247,7 +19648,7 @@ var DISTRIBUTION_F = [
19247
19648
  ),
19248
19649
  numeric(
19249
19650
  "BINOM.DIST.RANGE",
19250
- C21,
19651
+ C24,
19251
19652
  "BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
19252
19653
  "The probability of a trial result within a range, from the binomial distribution.",
19253
19654
  3,
@@ -19265,7 +19666,7 @@ var DISTRIBUTION_F = [
19265
19666
  ),
19266
19667
  numeric(
19267
19668
  "HYPGEOMDIST",
19268
- C21,
19669
+ C24,
19269
19670
  "HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
19270
19671
  "The hypergeometric distribution.",
19271
19672
  4,
@@ -19274,7 +19675,7 @@ var DISTRIBUTION_F = [
19274
19675
  ),
19275
19676
  numeric(
19276
19677
  "NEGBINOMDIST",
19277
- C21,
19678
+ C24,
19278
19679
  "NEGBINOMDIST(number_f, number_s, probability_s)",
19279
19680
  "The negative binomial distribution.",
19280
19681
  3,
@@ -19284,7 +19685,7 @@ var DISTRIBUTION_F = [
19284
19685
  ];
19285
19686
 
19286
19687
  // src/xlsx/formula/functions/statistical-shape.ts
19287
- var C22 = "Statistical";
19688
+ var C25 = "Statistical";
19288
19689
  function moments(values2) {
19289
19690
  const n = values2.length;
19290
19691
  return { n, m: mean(values2), s: stdev(values2, true) };
@@ -19301,7 +19702,7 @@ function frequency(data, bins) {
19301
19702
  var STATISTICAL_SHAPE = [
19302
19703
  spec(
19303
19704
  "GEOMEAN",
19304
- C22,
19705
+ C25,
19305
19706
  "GEOMEAN(number1, ...)",
19306
19707
  "The geometric mean.",
19307
19708
  1,
@@ -19315,7 +19716,7 @@ var STATISTICAL_SHAPE = [
19315
19716
  ),
19316
19717
  spec(
19317
19718
  "HARMEAN",
19318
- C22,
19719
+ C25,
19319
19720
  "HARMEAN(number1, ...)",
19320
19721
  "The harmonic mean.",
19321
19722
  1,
@@ -19329,7 +19730,7 @@ var STATISTICAL_SHAPE = [
19329
19730
  ),
19330
19731
  spec(
19331
19732
  "AVEDEV",
19332
- C22,
19733
+ C25,
19333
19734
  "AVEDEV(number1, ...)",
19334
19735
  "The mean absolute deviation from the mean.",
19335
19736
  1,
@@ -19344,7 +19745,7 @@ var STATISTICAL_SHAPE = [
19344
19745
  ),
19345
19746
  spec(
19346
19747
  "DEVSQ",
19347
- C22,
19748
+ C25,
19348
19749
  "DEVSQ(number1, ...)",
19349
19750
  "The sum of squared deviations from the mean.",
19350
19751
  1,
@@ -19357,7 +19758,7 @@ var STATISTICAL_SHAPE = [
19357
19758
  ),
19358
19759
  spec(
19359
19760
  "KURT",
19360
- C22,
19761
+ C25,
19361
19762
  "KURT(number1, ...)",
19362
19763
  "The kurtosis of a data set.",
19363
19764
  1,
@@ -19373,7 +19774,7 @@ var STATISTICAL_SHAPE = [
19373
19774
  ),
19374
19775
  spec(
19375
19776
  "SKEW",
19376
- C22,
19777
+ C25,
19377
19778
  "SKEW(number1, ...)",
19378
19779
  "The skewness of a distribution.",
19379
19780
  1,
@@ -19388,7 +19789,7 @@ var STATISTICAL_SHAPE = [
19388
19789
  ),
19389
19790
  spec(
19390
19791
  "SKEW.P",
19391
- C22,
19792
+ C25,
19392
19793
  "SKEW.P(number1, ...)",
19393
19794
  "The population skewness.",
19394
19795
  1,
@@ -19404,7 +19805,7 @@ var STATISTICAL_SHAPE = [
19404
19805
  ),
19405
19806
  numeric(
19406
19807
  "STANDARDIZE",
19407
- C22,
19808
+ C25,
19408
19809
  "STANDARDIZE(x, mean, standard_dev)",
19409
19810
  "A normalized value.",
19410
19811
  3,
@@ -19416,7 +19817,7 @@ var STATISTICAL_SHAPE = [
19416
19817
  ),
19417
19818
  spec(
19418
19819
  "TRIMMEAN",
19419
- C22,
19820
+ C25,
19420
19821
  "TRIMMEAN(array, percent)",
19421
19822
  "The mean of the interior of a data set.",
19422
19823
  2,
@@ -19432,7 +19833,7 @@ var STATISTICAL_SHAPE = [
19432
19833
  ),
19433
19834
  spec(
19434
19835
  "FREQUENCY",
19435
- C22,
19836
+ C25,
19436
19837
  "FREQUENCY(data_array, bins_array)",
19437
19838
  "How often values occur within ranges, as a vertical array.",
19438
19839
  2,
@@ -19442,7 +19843,7 @@ var STATISTICAL_SHAPE = [
19442
19843
  ),
19443
19844
  numeric(
19444
19845
  "PERMUT",
19445
- C22,
19846
+ C25,
19446
19847
  "PERMUT(number, number_chosen)",
19447
19848
  "The number of permutations.",
19448
19849
  2,
@@ -19458,7 +19859,7 @@ var STATISTICAL_SHAPE = [
19458
19859
  ),
19459
19860
  numeric(
19460
19861
  "PERMUTATIONA",
19461
- C22,
19862
+ C25,
19462
19863
  "PERMUTATIONA(number, number_chosen)",
19463
19864
  "Permutations with repetitions.",
19464
19865
  2,
@@ -19468,26 +19869,26 @@ var STATISTICAL_SHAPE = [
19468
19869
  return Math.pow(Math.trunc(n), Math.trunc(k ?? 0));
19469
19870
  }
19470
19871
  ),
19471
- numeric("FISHER", C22, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
19872
+ numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
19472
19873
  if (x <= -1 || x >= 1) fail(ERR.NUM);
19473
19874
  return 0.5 * Math.log((1 + x) / (1 - x));
19474
19875
  }),
19475
19876
  numeric(
19476
19877
  "FISHERINV",
19477
- C22,
19878
+ C25,
19478
19879
  "FISHERINV(y)",
19479
19880
  "The inverse of the Fisher transformation.",
19480
19881
  1,
19481
19882
  1,
19482
19883
  (y) => Math.tanh(y)
19483
19884
  ),
19484
- numeric("GAMMA", C22, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
19885
+ numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
19485
19886
  if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
19486
19887
  return gamma(x);
19487
19888
  }),
19488
19889
  numeric(
19489
19890
  "GAMMALN",
19490
- C22,
19891
+ C25,
19491
19892
  "GAMMALN(x)",
19492
19893
  "The natural logarithm of the gamma function.",
19493
19894
  1,
@@ -19496,7 +19897,7 @@ var STATISTICAL_SHAPE = [
19496
19897
  ),
19497
19898
  numeric(
19498
19899
  "GAMMALN.PRECISE",
19499
- C22,
19900
+ C25,
19500
19901
  "GAMMALN.PRECISE(x)",
19501
19902
  "The natural logarithm of the gamma function.",
19502
19903
  1,
@@ -19506,7 +19907,7 @@ var STATISTICAL_SHAPE = [
19506
19907
  ];
19507
19908
 
19508
19909
  // src/xlsx/formula/functions/statistical-more.ts
19509
- var C23 = "Statistical";
19910
+ var C26 = "Statistical";
19510
19911
  function pairedNumbers(ctx, a, b) {
19511
19912
  const ma = ctx.toMatrix(a).flat();
19512
19913
  const mb = ctx.toMatrix(b).flat();
@@ -19527,7 +19928,7 @@ function pairedNumbers(ctx, a, b) {
19527
19928
  }
19528
19929
  var pairFn = (name, description, syntax, fn) => spec(
19529
19930
  name,
19530
- C23,
19931
+ C26,
19531
19932
  syntax,
19532
19933
  description,
19533
19934
  2,
@@ -19542,7 +19943,7 @@ var STATISTICAL_MORE = [
19542
19943
  ...STATISTICAL_SHAPE,
19543
19944
  spec(
19544
19945
  "MODE.MULT",
19545
- C23,
19946
+ C26,
19546
19947
  "MODE.MULT(number1, [number2], ...)",
19547
19948
  "A vertical array of the most frequent values.",
19548
19949
  1,
@@ -19624,7 +20025,7 @@ var STATISTICAL_MORE = [
19624
20025
  ...["FORECAST", "FORECAST.LINEAR"].map(
19625
20026
  (name) => spec(
19626
20027
  name,
19627
- C23,
20028
+ C26,
19628
20029
  `${name}(x, known_ys, known_xs)`,
19629
20030
  "Predicts a value along a linear trend.",
19630
20031
  3,
@@ -19641,7 +20042,7 @@ var STATISTICAL_MORE = [
19641
20042
  ];
19642
20043
 
19643
20044
  // src/xlsx/formula/functions/hypothesis-tests.ts
19644
- var C24 = "Statistical";
20045
+ var C27 = "Statistical";
19645
20046
  var ARRAYS = ["any"];
19646
20047
  var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
19647
20048
  function tStatistic(a, b, type) {
@@ -19726,7 +20127,7 @@ var HYPOTHESIS_TESTS = [
19726
20127
  ["Z.TEST", "ZTEST"],
19727
20128
  (name) => spec(
19728
20129
  name,
19729
- C24,
20130
+ C27,
19730
20131
  `${name}(array, x, [sigma])`,
19731
20132
  "The one-tailed P-value of a z-test.",
19732
20133
  2,
@@ -19745,7 +20146,7 @@ var HYPOTHESIS_TESTS = [
19745
20146
  ["T.TEST", "TTEST"],
19746
20147
  (name) => spec(
19747
20148
  name,
19748
- C24,
20149
+ C27,
19749
20150
  `${name}(array1, array2, tails, type)`,
19750
20151
  "The probability associated with a Student's t-test.",
19751
20152
  4,
@@ -19766,7 +20167,7 @@ var HYPOTHESIS_TESTS = [
19766
20167
  ["F.TEST", "FTEST"],
19767
20168
  (name) => spec(
19768
20169
  name,
19769
- C24,
20170
+ C27,
19770
20171
  `${name}(array1, array2)`,
19771
20172
  "The two-tailed probability that the variances of two arrays are not different.",
19772
20173
  2,
@@ -19779,7 +20180,7 @@ var HYPOTHESIS_TESTS = [
19779
20180
  ["CHISQ.TEST", "CHITEST"],
19780
20181
  (name) => spec(
19781
20182
  name,
19782
- C24,
20183
+ C27,
19783
20184
  `${name}(actual_range, expected_range)`,
19784
20185
  "The chi-squared test of independence.",
19785
20186
  2,
@@ -19790,7 +20191,7 @@ var HYPOTHESIS_TESTS = [
19790
20191
  ),
19791
20192
  spec(
19792
20193
  "PROB",
19793
- C24,
20194
+ C27,
19794
20195
  "PROB(x_range, prob_range, lower_limit, [upper_limit])",
19795
20196
  "The probability that values in a range are between two limits.",
19796
20197
  3,
@@ -19801,7 +20202,7 @@ var HYPOTHESIS_TESTS = [
19801
20202
  ];
19802
20203
 
19803
20204
  // src/xlsx/formula/functions/statistical-spread.ts
19804
- var C25 = "Statistical";
20205
+ var C28 = "Statistical";
19805
20206
  var STATISTICAL_SPREAD = [
19806
20207
  ...[
19807
20208
  ["STDEV", true, false],
@@ -19813,7 +20214,7 @@ var STATISTICAL_SPREAD = [
19813
20214
  ].map(
19814
20215
  ([name, sample, a]) => spec(
19815
20216
  name,
19816
- C25,
20217
+ C28,
19817
20218
  `${name}(number1, [number2], ...)`,
19818
20219
  `The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
19819
20220
  1,
@@ -19832,7 +20233,7 @@ var STATISTICAL_SPREAD = [
19832
20233
  ].map(
19833
20234
  ([name, sample, a]) => spec(
19834
20235
  name,
19835
- C25,
20236
+ C28,
19836
20237
  `${name}(number1, [number2], ...)`,
19837
20238
  `The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
19838
20239
  1,
@@ -19844,7 +20245,7 @@ var STATISTICAL_SPREAD = [
19844
20245
  ...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
19845
20246
  (name) => spec(
19846
20247
  name,
19847
- C25,
20248
+ C28,
19848
20249
  `${name}(array, k)`,
19849
20250
  "The k-th percentile.",
19850
20251
  2,
@@ -19860,7 +20261,7 @@ var STATISTICAL_SPREAD = [
19860
20261
  ...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
19861
20262
  (name) => spec(
19862
20263
  name,
19863
- C25,
20264
+ C28,
19864
20265
  `${name}(array, quart)`,
19865
20266
  "A quartile of a data set.",
19866
20267
  2,
@@ -19872,7 +20273,7 @@ var STATISTICAL_SPREAD = [
19872
20273
  ...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
19873
20274
  (name) => spec(
19874
20275
  name,
19875
- C25,
20276
+ C28,
19876
20277
  `${name}(array, x, [significance])`,
19877
20278
  "The rank of a value as a percentage of the data set.",
19878
20279
  2,
@@ -19889,7 +20290,7 @@ var STATISTICAL_SPREAD = [
19889
20290
  ];
19890
20291
 
19891
20292
  // src/xlsx/formula/functions/statistical-count.ts
19892
- var C26 = "Statistical";
20293
+ var C29 = "Statistical";
19893
20294
  function count(ctx, args) {
19894
20295
  let n = 0;
19895
20296
  for (const arg of args) {
@@ -19955,7 +20356,7 @@ function countIf(ctx, range, criteria) {
19955
20356
  var COUNT_FUNCTIONS = [
19956
20357
  spec(
19957
20358
  "COUNT",
19958
- C26,
20359
+ C29,
19959
20360
  "COUNT(value1, [value2], ...)",
19960
20361
  "Counts the numbers in the arguments.",
19961
20362
  0,
@@ -19965,7 +20366,7 @@ var COUNT_FUNCTIONS = [
19965
20366
  ),
19966
20367
  spec(
19967
20368
  "COUNTA",
19968
- C26,
20369
+ C29,
19969
20370
  "COUNTA(value1, [value2], ...)",
19970
20371
  "Counts the non-empty values.",
19971
20372
  1,
@@ -19975,7 +20376,7 @@ var COUNT_FUNCTIONS = [
19975
20376
  ),
19976
20377
  spec(
19977
20378
  "COUNTBLANK",
19978
- C26,
20379
+ C29,
19979
20380
  "COUNTBLANK(range)",
19980
20381
  "Counts the empty cells in a range.",
19981
20382
  1,
@@ -19985,7 +20386,7 @@ var COUNT_FUNCTIONS = [
19985
20386
  ),
19986
20387
  spec(
19987
20388
  "COUNTIF",
19988
- C26,
20389
+ C29,
19989
20390
  "COUNTIF(range, criteria)",
19990
20391
  "Counts the cells that meet a criterion.",
19991
20392
  2,
@@ -19995,7 +20396,7 @@ var COUNT_FUNCTIONS = [
19995
20396
  ),
19996
20397
  spec(
19997
20398
  "COUNTIFS",
19998
- C26,
20399
+ C29,
19999
20400
  "COUNTIFS(criteria_range1, criteria1, ...)",
20000
20401
  "Counts the cells that meet several criteria.",
20001
20402
  2,
@@ -20008,7 +20409,7 @@ var COUNT_FUNCTIONS = [
20008
20409
  ),
20009
20410
  spec(
20010
20411
  "AVERAGE",
20011
- C26,
20412
+ C29,
20012
20413
  "AVERAGE(number1, [number2], ...)",
20013
20414
  "The arithmetic mean.",
20014
20415
  1,
@@ -20019,7 +20420,7 @@ var COUNT_FUNCTIONS = [
20019
20420
  ];
20020
20421
 
20021
20422
  // src/xlsx/formula/functions/statistical.ts
20022
- var C27 = "Statistical";
20423
+ var C30 = "Statistical";
20023
20424
  var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
20024
20425
  var extreme2 = extreme;
20025
20426
  var STATISTICAL_FUNCTIONS = [
@@ -20030,7 +20431,7 @@ var STATISTICAL_FUNCTIONS = [
20030
20431
  ...COUNT_FUNCTIONS,
20031
20432
  spec(
20032
20433
  "AVERAGEA",
20033
- C27,
20434
+ C30,
20034
20435
  "AVERAGEA(value1, [value2], ...)",
20035
20436
  "The mean counting text as 0 and logicals.",
20036
20437
  1,
@@ -20040,7 +20441,7 @@ var STATISTICAL_FUNCTIONS = [
20040
20441
  ),
20041
20442
  spec(
20042
20443
  "AVERAGEIF",
20043
- C27,
20444
+ C30,
20044
20445
  "AVERAGEIF(range, criteria, [average_range])",
20045
20446
  "The mean of the cells that meet a criterion.",
20046
20447
  2,
@@ -20059,7 +20460,7 @@ var STATISTICAL_FUNCTIONS = [
20059
20460
  ),
20060
20461
  spec(
20061
20462
  "AVERAGEIFS",
20062
- C27,
20463
+ C30,
20063
20464
  "AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
20064
20465
  "The mean of the cells that meet several criteria.",
20065
20466
  3,
@@ -20073,7 +20474,7 @@ var STATISTICAL_FUNCTIONS = [
20073
20474
  ),
20074
20475
  spec(
20075
20476
  "MAX",
20076
- C27,
20477
+ C30,
20077
20478
  "MAX(number1, [number2], ...)",
20078
20479
  "The largest value.",
20079
20480
  1,
@@ -20083,7 +20484,7 @@ var STATISTICAL_FUNCTIONS = [
20083
20484
  ),
20084
20485
  spec(
20085
20486
  "MIN",
20086
- C27,
20487
+ C30,
20087
20488
  "MIN(number1, [number2], ...)",
20088
20489
  "The smallest value.",
20089
20490
  1,
@@ -20093,7 +20494,7 @@ var STATISTICAL_FUNCTIONS = [
20093
20494
  ),
20094
20495
  spec(
20095
20496
  "MAXA",
20096
- C27,
20497
+ C30,
20097
20498
  "MAXA(value1, [value2], ...)",
20098
20499
  "The largest value counting logicals and text.",
20099
20500
  1,
@@ -20103,7 +20504,7 @@ var STATISTICAL_FUNCTIONS = [
20103
20504
  ),
20104
20505
  spec(
20105
20506
  "MINA",
20106
- C27,
20507
+ C30,
20107
20508
  "MINA(value1, [value2], ...)",
20108
20509
  "The smallest value counting logicals and text.",
20109
20510
  1,
@@ -20113,7 +20514,7 @@ var STATISTICAL_FUNCTIONS = [
20113
20514
  ),
20114
20515
  spec(
20115
20516
  "MAXIFS",
20116
- C27,
20517
+ C30,
20117
20518
  "MAXIFS(max_range, criteria_range1, criteria1, ...)",
20118
20519
  "The largest value meeting criteria.",
20119
20520
  3,
@@ -20127,7 +20528,7 @@ var STATISTICAL_FUNCTIONS = [
20127
20528
  ),
20128
20529
  spec(
20129
20530
  "MINIFS",
20130
- C27,
20531
+ C30,
20131
20532
  "MINIFS(min_range, criteria_range1, criteria1, ...)",
20132
20533
  "The smallest value meeting criteria.",
20133
20534
  3,
@@ -20141,7 +20542,7 @@ var STATISTICAL_FUNCTIONS = [
20141
20542
  ),
20142
20543
  spec(
20143
20544
  "MEDIAN",
20144
- C27,
20545
+ C30,
20145
20546
  "MEDIAN(number1, [number2], ...)",
20146
20547
  "The median.",
20147
20548
  1,
@@ -20151,7 +20552,7 @@ var STATISTICAL_FUNCTIONS = [
20151
20552
  ),
20152
20553
  spec(
20153
20554
  "MODE",
20154
- C27,
20555
+ C30,
20155
20556
  "MODE(number1, [number2], ...)",
20156
20557
  "The most frequent value.",
20157
20558
  1,
@@ -20161,7 +20562,7 @@ var STATISTICAL_FUNCTIONS = [
20161
20562
  ),
20162
20563
  spec(
20163
20564
  "MODE.SNGL",
20164
- C27,
20565
+ C30,
20165
20566
  "MODE.SNGL(number1, [number2], ...)",
20166
20567
  "The most frequent value.",
20167
20568
  1,
@@ -20171,7 +20572,7 @@ var STATISTICAL_FUNCTIONS = [
20171
20572
  ),
20172
20573
  spec(
20173
20574
  "LARGE",
20174
- C27,
20575
+ C30,
20175
20576
  "LARGE(array, k)",
20176
20577
  "The k-th largest value.",
20177
20578
  2,
@@ -20181,7 +20582,7 @@ var STATISTICAL_FUNCTIONS = [
20181
20582
  ),
20182
20583
  spec(
20183
20584
  "SMALL",
20184
- C27,
20585
+ C30,
20185
20586
  "SMALL(array, k)",
20186
20587
  "The k-th smallest value.",
20187
20588
  2,
@@ -20192,7 +20593,7 @@ var STATISTICAL_FUNCTIONS = [
20192
20593
  ...["RANK", "RANK.EQ", "RANK.AVG"].map(
20193
20594
  (name) => spec(
20194
20595
  name,
20195
- C27,
20596
+ C30,
20196
20597
  `${name}(number, ref, [order])`,
20197
20598
  "The rank of a number in a list.",
20198
20599
  2,
@@ -20209,11 +20610,11 @@ var STATISTICAL_FUNCTIONS = [
20209
20610
  ];
20210
20611
 
20211
20612
  // src/xlsx/formula/functions/distributions-more.ts
20212
- var C28 = "Statistical";
20613
+ var C31 = "Statistical";
20213
20614
  var DISTRIBUTION_MORE = [
20214
20615
  numeric(
20215
20616
  "T.DIST",
20216
- C28,
20617
+ C31,
20217
20618
  "T.DIST(x, deg_freedom, cumulative)",
20218
20619
  "Student's left-tailed t-distribution.",
20219
20620
  3,
@@ -20225,7 +20626,7 @@ var DISTRIBUTION_MORE = [
20225
20626
  ),
20226
20627
  numeric(
20227
20628
  "T.DIST.RT",
20228
- C28,
20629
+ C31,
20229
20630
  "T.DIST.RT(x, deg_freedom)",
20230
20631
  "Student's right-tailed t-distribution.",
20231
20632
  2,
@@ -20237,7 +20638,7 @@ var DISTRIBUTION_MORE = [
20237
20638
  ),
20238
20639
  numeric(
20239
20640
  "T.DIST.2T",
20240
- C28,
20641
+ C31,
20241
20642
  "T.DIST.2T(x, deg_freedom)",
20242
20643
  "Student's two-tailed t-distribution.",
20243
20644
  2,
@@ -20249,7 +20650,7 @@ var DISTRIBUTION_MORE = [
20249
20650
  ),
20250
20651
  numeric(
20251
20652
  "TDIST",
20252
- C28,
20653
+ C31,
20253
20654
  "TDIST(x, deg_freedom, tails)",
20254
20655
  "Student's t-distribution.",
20255
20656
  3,
@@ -20261,7 +20662,7 @@ var DISTRIBUTION_MORE = [
20261
20662
  ),
20262
20663
  numeric(
20263
20664
  "T.INV",
20264
- C28,
20665
+ C31,
20265
20666
  "T.INV(probability, deg_freedom)",
20266
20667
  "The left-tailed inverse of Student's t-distribution.",
20267
20668
  2,
@@ -20276,7 +20677,7 @@ var DISTRIBUTION_MORE = [
20276
20677
  ...["T.INV.2T", "TINV"].map(
20277
20678
  (name) => numeric(
20278
20679
  name,
20279
- C28,
20680
+ C31,
20280
20681
  `${name}(probability, deg_freedom)`,
20281
20682
  "The two-tailed inverse of Student's t-distribution.",
20282
20683
  2,
@@ -20289,7 +20690,7 @@ var DISTRIBUTION_MORE = [
20289
20690
  ),
20290
20691
  numeric(
20291
20692
  "CHISQ.DIST",
20292
- C28,
20693
+ C31,
20293
20694
  "CHISQ.DIST(x, deg_freedom, cumulative)",
20294
20695
  "The chi-squared distribution.",
20295
20696
  3,
@@ -20303,7 +20704,7 @@ var DISTRIBUTION_MORE = [
20303
20704
  ...["CHISQ.DIST.RT", "CHIDIST"].map(
20304
20705
  (name) => numeric(
20305
20706
  name,
20306
- C28,
20707
+ C31,
20307
20708
  `${name}(x, deg_freedom)`,
20308
20709
  "The right-tailed chi-squared probability.",
20309
20710
  2,
@@ -20316,7 +20717,7 @@ var DISTRIBUTION_MORE = [
20316
20717
  ),
20317
20718
  numeric(
20318
20719
  "CHISQ.INV",
20319
- C28,
20720
+ C31,
20320
20721
  "CHISQ.INV(probability, deg_freedom)",
20321
20722
  "The inverse of the left-tailed chi-squared distribution.",
20322
20723
  2,
@@ -20329,7 +20730,7 @@ var DISTRIBUTION_MORE = [
20329
20730
  ...["CHISQ.INV.RT", "CHIINV"].map(
20330
20731
  (name) => numeric(
20331
20732
  name,
20332
- C28,
20733
+ C31,
20333
20734
  `${name}(probability, deg_freedom)`,
20334
20735
  "The inverse of the right-tailed chi-squared distribution.",
20335
20736
  2,
@@ -20342,7 +20743,7 @@ var DISTRIBUTION_MORE = [
20342
20743
  ),
20343
20744
  numeric(
20344
20745
  "BETA.DIST",
20345
- C28,
20746
+ C31,
20346
20747
  "BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
20347
20748
  "The beta distribution.",
20348
20749
  4,
@@ -20350,7 +20751,7 @@ var DISTRIBUTION_MORE = [
20350
20751
  (x, a, b, c2, lo, hi) => {
20351
20752
  const A = lo ?? 0;
20352
20753
  const B = hi ?? 1;
20353
- positive(a, b);
20754
+ positive2(a, b);
20354
20755
  if (x < A || x > B || A === B) fail(ERR.NUM);
20355
20756
  const t = (x - A) / (B - A);
20356
20757
  const al = a ?? 1;
@@ -20362,7 +20763,7 @@ var DISTRIBUTION_MORE = [
20362
20763
  ),
20363
20764
  numeric(
20364
20765
  "NEGBINOM.DIST",
20365
- C28,
20766
+ C31,
20366
20767
  "NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
20367
20768
  "The negative binomial distribution.",
20368
20769
  4,
@@ -20381,7 +20782,7 @@ var DISTRIBUTION_MORE = [
20381
20782
  ),
20382
20783
  numeric(
20383
20784
  "HYPGEOM.DIST",
20384
- C28,
20785
+ C31,
20385
20786
  "HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
20386
20787
  "The hypergeometric distribution.",
20387
20788
  5,
@@ -20402,13 +20803,13 @@ var DISTRIBUTION_MORE = [
20402
20803
  ];
20403
20804
 
20404
20805
  // src/xlsx/formula/functions/distributions.ts
20405
- var C29 = "Statistical";
20806
+ var C32 = "Statistical";
20406
20807
  var DISTRIBUTION_FUNCTIONS = [
20407
20808
  ...DISTRIBUTION_MORE,
20408
20809
  ...DISTRIBUTION_F,
20409
20810
  numeric(
20410
20811
  "NORM.DIST",
20411
- C29,
20812
+ C32,
20412
20813
  "NORM.DIST(x, mean, standard_dev, cumulative)",
20413
20814
  "The normal distribution.",
20414
20815
  4,
@@ -20417,7 +20818,7 @@ var DISTRIBUTION_FUNCTIONS = [
20417
20818
  ),
20418
20819
  numeric(
20419
20820
  "NORMDIST",
20420
- C29,
20821
+ C32,
20421
20822
  "NORMDIST(x, mean, standard_dev, cumulative)",
20422
20823
  "The normal distribution.",
20423
20824
  4,
@@ -20426,7 +20827,7 @@ var DISTRIBUTION_FUNCTIONS = [
20426
20827
  ),
20427
20828
  numeric(
20428
20829
  "NORM.S.DIST",
20429
- C29,
20830
+ C32,
20430
20831
  "NORM.S.DIST(z, cumulative)",
20431
20832
  "The standard normal distribution.",
20432
20833
  2,
@@ -20435,7 +20836,7 @@ var DISTRIBUTION_FUNCTIONS = [
20435
20836
  ),
20436
20837
  numeric(
20437
20838
  "NORMSDIST",
20438
- C29,
20839
+ C32,
20439
20840
  "NORMSDIST(z)",
20440
20841
  "The standard normal cumulative distribution.",
20441
20842
  1,
@@ -20444,31 +20845,31 @@ var DISTRIBUTION_FUNCTIONS = [
20444
20845
  ),
20445
20846
  numeric(
20446
20847
  "NORM.INV",
20447
- C29,
20848
+ C32,
20448
20849
  "NORM.INV(probability, mean, standard_dev)",
20449
20850
  "The inverse of the normal cumulative distribution.",
20450
20851
  3,
20451
20852
  3,
20452
20853
  (p, m, s) => {
20453
- positive(s);
20854
+ positive2(s);
20454
20855
  return (m ?? 0) + (s ?? 1) * normInv(p);
20455
20856
  }
20456
20857
  ),
20457
20858
  numeric(
20458
20859
  "NORMINV",
20459
- C29,
20860
+ C32,
20460
20861
  "NORMINV(probability, mean, standard_dev)",
20461
20862
  "The inverse of the normal cumulative distribution.",
20462
20863
  3,
20463
20864
  3,
20464
20865
  (p, m, s) => {
20465
- positive(s);
20866
+ positive2(s);
20466
20867
  return (m ?? 0) + (s ?? 1) * normInv(p);
20467
20868
  }
20468
20869
  ),
20469
20870
  numeric(
20470
20871
  "NORM.S.INV",
20471
- C29,
20872
+ C32,
20472
20873
  "NORM.S.INV(probability)",
20473
20874
  "The inverse of the standard normal distribution.",
20474
20875
  1,
@@ -20477,17 +20878,17 @@ var DISTRIBUTION_FUNCTIONS = [
20477
20878
  ),
20478
20879
  numeric(
20479
20880
  "NORMSINV",
20480
- C29,
20881
+ C32,
20481
20882
  "NORMSINV(probability)",
20482
20883
  "The inverse of the standard normal distribution.",
20483
20884
  1,
20484
20885
  1,
20485
20886
  normInv
20486
20887
  ),
20487
- numeric("PHI", C29, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
20888
+ numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
20488
20889
  numeric(
20489
20890
  "GAUSS",
20490
- C29,
20891
+ C32,
20491
20892
  "GAUSS(z)",
20492
20893
  "The probability between the mean and z standard deviations.",
20493
20894
  1,
@@ -20525,14 +20926,14 @@ var DISTRIBUTION_FUNCTIONS = [
20525
20926
  ...["CONFIDENCE", "CONFIDENCE.NORM"].map(
20526
20927
  (name) => numeric(
20527
20928
  name,
20528
- C29,
20929
+ C32,
20529
20930
  `${name}(alpha, standard_dev, size)`,
20530
20931
  "The confidence interval for a population mean (normal).",
20531
20932
  3,
20532
20933
  3,
20533
20934
  (a, s, n) => {
20534
20935
  probability(a);
20535
- positive(s);
20936
+ positive2(s);
20536
20937
  if ((n ?? 0) < 1) fail(ERR.NUM);
20537
20938
  return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n ?? 1));
20538
20939
  }
@@ -20540,14 +20941,14 @@ var DISTRIBUTION_FUNCTIONS = [
20540
20941
  ),
20541
20942
  numeric(
20542
20943
  "CONFIDENCE.T",
20543
- C29,
20944
+ C32,
20544
20945
  "CONFIDENCE.T(alpha, standard_dev, size)",
20545
20946
  "The confidence interval for a population mean (Student's t).",
20546
20947
  3,
20547
20948
  3,
20548
20949
  (a, s, n) => {
20549
20950
  probability(a);
20550
- positive(s);
20951
+ positive2(s);
20551
20952
  const size = Math.trunc(n ?? 1);
20552
20953
  if (size < 2) fail(ERR.DIV0);
20553
20954
  return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
@@ -20556,7 +20957,7 @@ var DISTRIBUTION_FUNCTIONS = [
20556
20957
  ...["BINOM.DIST", "BINOMDIST"].map(
20557
20958
  (name) => numeric(
20558
20959
  name,
20559
- C29,
20960
+ C32,
20560
20961
  `${name}(number_s, trials, probability_s, cumulative)`,
20561
20962
  "The binomial distribution probability.",
20562
20963
  4,
@@ -20567,7 +20968,7 @@ var DISTRIBUTION_FUNCTIONS = [
20567
20968
  ...["POISSON.DIST", "POISSON"].map(
20568
20969
  (name) => numeric(
20569
20970
  name,
20570
- C29,
20971
+ C32,
20571
20972
  `${name}(x, mean, cumulative)`,
20572
20973
  "The Poisson distribution.",
20573
20974
  3,
@@ -20578,54 +20979,54 @@ var DISTRIBUTION_FUNCTIONS = [
20578
20979
  ...["EXPON.DIST", "EXPONDIST"].map(
20579
20980
  (name) => numeric(
20580
20981
  name,
20581
- C29,
20982
+ C32,
20582
20983
  `${name}(x, lambda, cumulative)`,
20583
20984
  "The exponential distribution.",
20584
20985
  3,
20585
20986
  3,
20586
20987
  (x, l, c2) => {
20587
20988
  if (x < 0) fail(ERR.NUM);
20588
- positive(l);
20989
+ positive2(l);
20589
20990
  return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
20590
20991
  }
20591
20992
  )
20592
20993
  ),
20593
20994
  numeric(
20594
20995
  "LOGNORM.DIST",
20595
- C29,
20996
+ C32,
20596
20997
  "LOGNORM.DIST(x, mean, standard_dev, cumulative)",
20597
20998
  "The lognormal distribution.",
20598
20999
  4,
20599
21000
  4,
20600
21001
  (x, m, s, c2) => {
20601
- positive(x, s);
21002
+ positive2(x, s);
20602
21003
  const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
20603
21004
  return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
20604
21005
  }
20605
21006
  ),
20606
21007
  numeric(
20607
21008
  "LOGNORM.INV",
20608
- C29,
21009
+ C32,
20609
21010
  "LOGNORM.INV(probability, mean, standard_dev)",
20610
21011
  "The inverse of the lognormal distribution.",
20611
21012
  3,
20612
21013
  3,
20613
21014
  (p, m, s) => {
20614
- positive(s);
21015
+ positive2(s);
20615
21016
  return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
20616
21017
  }
20617
21018
  ),
20618
21019
  ...["WEIBULL.DIST", "WEIBULL"].map(
20619
21020
  (name) => numeric(
20620
21021
  name,
20621
- C29,
21022
+ C32,
20622
21023
  `${name}(x, alpha, beta, cumulative)`,
20623
21024
  "The Weibull distribution.",
20624
21025
  4,
20625
21026
  4,
20626
21027
  (x, a, b, c2) => {
20627
21028
  if (x < 0) fail(ERR.NUM);
20628
- positive(a, b);
21029
+ positive2(a, b);
20629
21030
  const al = a ?? 1;
20630
21031
  const be = b ?? 1;
20631
21032
  return c2 ? 1 - Math.exp(-Math.pow(x / be, al)) : al / Math.pow(be, al) * Math.pow(x, al - 1) * Math.exp(-Math.pow(x / be, al));
@@ -20634,14 +21035,14 @@ var DISTRIBUTION_FUNCTIONS = [
20634
21035
  ),
20635
21036
  numeric(
20636
21037
  "GAMMA.DIST",
20637
- C29,
21038
+ C32,
20638
21039
  "GAMMA.DIST(x, alpha, beta, cumulative)",
20639
21040
  "The gamma distribution.",
20640
21041
  4,
20641
21042
  4,
20642
21043
  (x, a, b, c2) => {
20643
21044
  if (x < 0) fail(ERR.NUM);
20644
- positive(a, b);
21045
+ positive2(a, b);
20645
21046
  const al = a ?? 1;
20646
21047
  const be = b ?? 1;
20647
21048
  return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
@@ -20650,7 +21051,7 @@ var DISTRIBUTION_FUNCTIONS = [
20650
21051
  ];
20651
21052
 
20652
21053
  // src/xlsx/formula/functions/text-convert.ts
20653
- var C30 = "Text";
21054
+ var C33 = "Text";
20654
21055
  var CP1252 = {
20655
21056
  128: 8364,
20656
21057
  130: 8218,
@@ -20695,7 +21096,7 @@ function fixed(value, decimals, commas) {
20695
21096
  var TEXT_CONVERT = [
20696
21097
  spec(
20697
21098
  "TEXT",
20698
- C30,
21099
+ C33,
20699
21100
  "TEXT(value, format_text)",
20700
21101
  "Formats a value with a number format.",
20701
21102
  2,
@@ -20708,7 +21109,7 @@ var TEXT_CONVERT = [
20708
21109
  return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
20709
21110
  }
20710
21111
  ),
20711
- spec("VALUE", C30, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
21112
+ spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
20712
21113
  const v = scalar(args[0]);
20713
21114
  if (typeof v === "number") return v;
20714
21115
  if (v === null) return 0;
@@ -20718,7 +21119,7 @@ var TEXT_CONVERT = [
20718
21119
  }),
20719
21120
  spec(
20720
21121
  "NUMBERVALUE",
20721
- C30,
21122
+ C33,
20722
21123
  "NUMBERVALUE(text, [decimal_separator], [group_separator])",
20723
21124
  "Converts text to a number with given separators.",
20724
21125
  1,
@@ -20745,7 +21146,7 @@ var TEXT_CONVERT = [
20745
21146
  ),
20746
21147
  spec(
20747
21148
  "FIXED",
20748
- C30,
21149
+ C33,
20749
21150
  "FIXED(number, [decimals], [no_commas])",
20750
21151
  "Formats a number as text with fixed decimals.",
20751
21152
  1,
@@ -20754,7 +21155,7 @@ var TEXT_CONVERT = [
20754
21155
  ),
20755
21156
  spec(
20756
21157
  "DOLLAR",
20757
- C30,
21158
+ C33,
20758
21159
  "DOLLAR(number, [decimals])",
20759
21160
  "Formats a number as currency text.",
20760
21161
  1,
@@ -20765,28 +21166,28 @@ var TEXT_CONVERT = [
20765
21166
  return value < 0 && text.replace(/[0.,]/g, "") !== "" ? `($${text})` : `$${text}`;
20766
21167
  }
20767
21168
  ),
20768
- spec("CHAR", C30, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
21169
+ spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
20769
21170
  const n = int3(args[0]);
20770
21171
  if (n < 1 || n > 255) fail(ERR.VALUE);
20771
21172
  return String.fromCharCode(CP1252[n] ?? n);
20772
21173
  }),
20773
- spec("CODE", C30, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
21174
+ spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
20774
21175
  const text = str(args[0]);
20775
21176
  if (text === "") fail(ERR.VALUE);
20776
21177
  const code = text.charCodeAt(0);
20777
21178
  return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
20778
21179
  }),
20779
- spec("UNICHAR", C30, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
21180
+ spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
20780
21181
  const n = int3(args[0]);
20781
21182
  if (n < 1 || n > 1114111) fail(ERR.VALUE);
20782
21183
  return String.fromCodePoint(n);
20783
21184
  }),
20784
- spec("UNICODE", C30, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
21185
+ spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
20785
21186
  const text = str(args[0]);
20786
21187
  if (text === "") fail(ERR.VALUE);
20787
21188
  return text.codePointAt(0) ?? fail(ERR.VALUE);
20788
21189
  }),
20789
- spec("T", C30, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
21190
+ spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
20790
21191
  const v = scalar(args[0]);
20791
21192
  if (isError(v)) return v;
20792
21193
  return typeof v === "string" ? v : "";
@@ -20836,7 +21237,7 @@ function right(text, n) {
20836
21237
  }
20837
21238
 
20838
21239
  // src/xlsx/formula/functions/text.ts
20839
- var C31 = "Text";
21240
+ var C34 = "Text";
20840
21241
  var MAX_TEXT = 32767;
20841
21242
  var limit = (text) => text.length > MAX_TEXT ? fail(ERR.VALUE) : text;
20842
21243
  function find(args, insensitive) {
@@ -20869,7 +21270,7 @@ var TEXT_FUNCTIONS = [
20869
21270
  ...TEXT_CONVERT,
20870
21271
  spec(
20871
21272
  "CONCATENATE",
20872
- C31,
21273
+ C34,
20873
21274
  "CONCATENATE(text1, [text2], ...)",
20874
21275
  "Joins text items.",
20875
21276
  1,
@@ -20878,7 +21279,7 @@ var TEXT_FUNCTIONS = [
20878
21279
  ),
20879
21280
  spec(
20880
21281
  "CONCAT",
20881
- C31,
21282
+ C34,
20882
21283
  "CONCAT(text1, [text2], ...)",
20883
21284
  "Joins text from items and ranges.",
20884
21285
  1,
@@ -20888,7 +21289,7 @@ var TEXT_FUNCTIONS = [
20888
21289
  ),
20889
21290
  spec(
20890
21291
  "TEXTJOIN",
20891
- C31,
21292
+ C34,
20892
21293
  "TEXTJOIN(delimiter, ignore_empty, text1, ...)",
20893
21294
  "Joins text with a delimiter.",
20894
21295
  3,
@@ -20907,14 +21308,14 @@ var TEXT_FUNCTIONS = [
20907
21308
  ["any"]
20908
21309
  ),
20909
21310
  ...["LEFT", "LEFTB"].map(
20910
- (name) => spec(name, C31, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
21311
+ (name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
20911
21312
  const n = optNum(args, 1, 1);
20912
21313
  if (n < 0) fail(ERR.VALUE);
20913
21314
  return left(str(args[0]), Math.trunc(n));
20914
21315
  })
20915
21316
  ),
20916
21317
  ...["RIGHT", "RIGHTB"].map(
20917
- (name) => spec(name, C31, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
21318
+ (name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
20918
21319
  const n = Math.trunc(optNum(args, 1, 1));
20919
21320
  if (n < 0) fail(ERR.VALUE);
20920
21321
  return right(str(args[0]), n);
@@ -20923,7 +21324,7 @@ var TEXT_FUNCTIONS = [
20923
21324
  ...["MID", "MIDB"].map(
20924
21325
  (name) => spec(
20925
21326
  name,
20926
- C31,
21327
+ C34,
20927
21328
  `${name}(text, start_num, num_chars)`,
20928
21329
  "Characters from the middle of a text.",
20929
21330
  3,
@@ -20939,7 +21340,7 @@ var TEXT_FUNCTIONS = [
20939
21340
  ...["LEN", "LENB"].map(
20940
21341
  (name) => spec(
20941
21342
  name,
20942
- C31,
21343
+ C34,
20943
21344
  `${name}(text)`,
20944
21345
  "The number of characters in a text.",
20945
21346
  1,
@@ -20949,7 +21350,7 @@ var TEXT_FUNCTIONS = [
20949
21350
  ),
20950
21351
  spec(
20951
21352
  "LOWER",
20952
- C31,
21353
+ C34,
20953
21354
  "LOWER(text)",
20954
21355
  "Converts text to lower case.",
20955
21356
  1,
@@ -20958,7 +21359,7 @@ var TEXT_FUNCTIONS = [
20958
21359
  ),
20959
21360
  spec(
20960
21361
  "UPPER",
20961
- C31,
21362
+ C34,
20962
21363
  "UPPER(text)",
20963
21364
  "Converts text to upper case.",
20964
21365
  1,
@@ -20967,7 +21368,7 @@ var TEXT_FUNCTIONS = [
20967
21368
  ),
20968
21369
  spec(
20969
21370
  "PROPER",
20970
- C31,
21371
+ C34,
20971
21372
  "PROPER(text)",
20972
21373
  "Capitalizes the first letter of each word.",
20973
21374
  1,
@@ -20976,7 +21377,7 @@ var TEXT_FUNCTIONS = [
20976
21377
  ),
20977
21378
  spec(
20978
21379
  "TRIM",
20979
- C31,
21380
+ C34,
20980
21381
  "TRIM(text)",
20981
21382
  "Removes extra spaces.",
20982
21383
  1,
@@ -20985,7 +21386,7 @@ var TEXT_FUNCTIONS = [
20985
21386
  ),
20986
21387
  spec(
20987
21388
  "CLEAN",
20988
- C31,
21389
+ C34,
20989
21390
  "CLEAN(text)",
20990
21391
  "Removes non-printable characters.",
20991
21392
  1,
@@ -20997,7 +21398,7 @@ var TEXT_FUNCTIONS = [
20997
21398
  ),
20998
21399
  spec(
20999
21400
  "SUBSTITUTE",
21000
- C31,
21401
+ C34,
21001
21402
  "SUBSTITUTE(text, old_text, new_text, [instance_num])",
21002
21403
  "Replaces occurrences of a text.",
21003
21404
  3,
@@ -21021,7 +21422,7 @@ var TEXT_FUNCTIONS = [
21021
21422
  ...["REPLACE", "REPLACEB"].map(
21022
21423
  (name) => spec(
21023
21424
  name,
21024
- C31,
21425
+ C34,
21025
21426
  `${name}(old_text, start_num, num_chars, new_text)`,
21026
21427
  "Replaces part of a text.",
21027
21428
  4,
@@ -21038,7 +21439,7 @@ var TEXT_FUNCTIONS = [
21038
21439
  ...["FIND", "FINDB"].map(
21039
21440
  (name) => spec(
21040
21441
  name,
21041
- C31,
21442
+ C34,
21042
21443
  `${name}(find_text, within_text, [start_num])`,
21043
21444
  "The position of a text (case-sensitive).",
21044
21445
  2,
@@ -21049,7 +21450,7 @@ var TEXT_FUNCTIONS = [
21049
21450
  ...["SEARCH", "SEARCHB"].map(
21050
21451
  (name) => spec(
21051
21452
  name,
21052
- C31,
21453
+ C34,
21053
21454
  `${name}(find_text, within_text, [start_num])`,
21054
21455
  "The position of a text (wildcards, any case).",
21055
21456
  2,
@@ -21057,7 +21458,7 @@ var TEXT_FUNCTIONS = [
21057
21458
  (args) => find(args, true)
21058
21459
  )
21059
21460
  ),
21060
- spec("REPT", C31, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
21461
+ spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
21061
21462
  const n = Math.trunc(num2(args[1]));
21062
21463
  const text = str(args[0]);
21063
21464
  if (n < 0 || text.length * n > MAX_TEXT) fail(ERR.VALUE);
@@ -21065,7 +21466,7 @@ var TEXT_FUNCTIONS = [
21065
21466
  }),
21066
21467
  spec(
21067
21468
  "EXACT",
21068
- C31,
21469
+ C34,
21069
21470
  "EXACT(text1, text2)",
21070
21471
  "Whether two texts are identical (case-sensitive).",
21071
21472
  2,
@@ -21074,8 +21475,78 @@ var TEXT_FUNCTIONS = [
21074
21475
  )
21075
21476
  ];
21076
21477
 
21478
+ // src/xlsx/formula/functions/text-regex.ts
21479
+ var C35 = "Text";
21480
+ function compile(pattern, caseMode2, global) {
21481
+ if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
21482
+ try {
21483
+ return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
21484
+ } catch {
21485
+ return fail(ERR.VALUE);
21486
+ }
21487
+ }
21488
+ var caseMode = (args, index2) => optNum(args, index2, 0);
21489
+ function encodeUrl(text) {
21490
+ return encodeURIComponent(text).replace(
21491
+ /[!'()*]/g,
21492
+ (c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
21493
+ );
21494
+ }
21495
+ var TEXT_REGEX_FUNCTIONS = [
21496
+ spec(
21497
+ "ENCODEURL",
21498
+ C35,
21499
+ "ENCODEURL(text)",
21500
+ "Percent-encodes text for use in a URL.",
21501
+ 1,
21502
+ 1,
21503
+ (args) => encodeUrl(str(args[0]))
21504
+ ),
21505
+ spec(
21506
+ "REGEXTEST",
21507
+ C35,
21508
+ "REGEXTEST(text, pattern, [case_sensitivity])",
21509
+ "Whether any part of the text matches the pattern.",
21510
+ 2,
21511
+ 3,
21512
+ (args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
21513
+ ),
21514
+ spec(
21515
+ "REGEXEXTRACT",
21516
+ C35,
21517
+ "REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
21518
+ "The first part of the text that matches the pattern.",
21519
+ 2,
21520
+ 4,
21521
+ (args) => {
21522
+ if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
21523
+ const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
21524
+ return match2 ? match2[0] : fail(ERR.NA);
21525
+ }
21526
+ ),
21527
+ spec(
21528
+ "REGEXREPLACE",
21529
+ C35,
21530
+ "REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
21531
+ "Replaces the parts of the text that match the pattern.",
21532
+ 3,
21533
+ 5,
21534
+ (args) => {
21535
+ const text = str(args[0]);
21536
+ const regex = compile(str(args[1]), caseMode(args, 4), true);
21537
+ const replacement = str(args[2]);
21538
+ const occurrence = args.length > 3 && args[3] !== null ? int3(args[3]) : 0;
21539
+ if (occurrence === 0) return text.replace(regex, replacement);
21540
+ const matches2 = [...text.matchAll(regex)];
21541
+ const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
21542
+ if (!picked || picked.index === void 0) return text;
21543
+ return text.slice(0, picked.index) + picked[0].replace(new RegExp(regex.source, regex.flags.replace("g", "")), replacement) + text.slice(picked.index + picked[0].length);
21544
+ }
21545
+ )
21546
+ ];
21547
+
21077
21548
  // src/xlsx/formula/functions/text-extra.ts
21078
- var C32 = "Text";
21549
+ var C36 = "Text";
21079
21550
  function delimitersOf(ctx, value) {
21080
21551
  if (value === void 0 || value === null) return [];
21081
21552
  return ctx.toMatrix(value).flat().map((v) => {
@@ -21141,9 +21612,10 @@ function valueToText(value, strict) {
21141
21612
  return toText(value);
21142
21613
  }
21143
21614
  var TEXT_EXTRA_FUNCTIONS = [
21615
+ ...TEXT_REGEX_FUNCTIONS,
21144
21616
  spec(
21145
21617
  "TEXTBEFORE",
21146
- C32,
21618
+ C36,
21147
21619
  "TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
21148
21620
  "The text before a delimiter.",
21149
21621
  2,
@@ -21153,7 +21625,7 @@ var TEXT_EXTRA_FUNCTIONS = [
21153
21625
  ),
21154
21626
  spec(
21155
21627
  "TEXTAFTER",
21156
- C32,
21628
+ C36,
21157
21629
  "TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
21158
21630
  "The text after a delimiter.",
21159
21631
  2,
@@ -21163,7 +21635,7 @@ var TEXT_EXTRA_FUNCTIONS = [
21163
21635
  ),
21164
21636
  spec(
21165
21637
  "TEXTSPLIT",
21166
- C32,
21638
+ C36,
21167
21639
  "TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
21168
21640
  "Splits text into an array.",
21169
21641
  2,
@@ -21186,7 +21658,7 @@ var TEXT_EXTRA_FUNCTIONS = [
21186
21658
  ),
21187
21659
  spec(
21188
21660
  "VALUETOTEXT",
21189
- C32,
21661
+ C36,
21190
21662
  "VALUETOTEXT(value, [format])",
21191
21663
  "Text for any value.",
21192
21664
  1,
@@ -21195,7 +21667,7 @@ var TEXT_EXTRA_FUNCTIONS = [
21195
21667
  ),
21196
21668
  spec(
21197
21669
  "ARRAYTOTEXT",
21198
- C32,
21670
+ C36,
21199
21671
  "ARRAYTOTEXT(array, [format])",
21200
21672
  "Text for an array.",
21201
21673
  1,
@@ -21960,6 +22432,8 @@ var EngineHost = class {
21960
22432
  inProgress = /* @__PURE__ */ new Set();
21961
22433
  cycles = /* @__PURE__ */ new Set();
21962
22434
  dynamicCycleHits = /* @__PURE__ */ new Set();
22435
+ /** Set while a circular group is iterated: reads of a formula in progress see its stored value. */
22436
+ iterating = false;
21963
22437
  pending;
21964
22438
  columnIndex;
21965
22439
  reverseIndex;
@@ -21999,6 +22473,7 @@ var EngineHost = class {
21999
22473
  const node = this.nodes.get(sheet)?.get(cellKey(row2, col));
22000
22474
  if (!node) return;
22001
22475
  if (this.inProgress.has(node)) {
22476
+ if (this.iterating) return;
22002
22477
  this.dynamicCycleHits.add(node);
22003
22478
  this.dynamicCycleHit = true;
22004
22479
  this.cycleReads++;
@@ -22317,6 +22792,10 @@ function storeResult(sheet, node, cell, result2, claims) {
22317
22792
 
22318
22793
  // src/xlsx/formula/engine-core.ts
22319
22794
  var MAX_ROUNDS = 8;
22795
+ function valueChange(before, after) {
22796
+ if (typeof before === "number" && typeof after === "number") return Math.abs(after - before);
22797
+ return before === after ? 0 : Number.POSITIVE_INFINITY;
22798
+ }
22320
22799
  var EngineCore = class extends EngineHost {
22321
22800
  releaseAllSpills() {
22322
22801
  for (const sheet of this.workbook.sheets) {
@@ -22402,7 +22881,9 @@ var EngineCore = class extends EngineHost {
22402
22881
  for (const component of order.components) {
22403
22882
  const first4 = component.nodes[0];
22404
22883
  if (component.cyclic) {
22405
- for (const node of component.nodes) this.markCycle(node);
22884
+ const iterate = this.workbook.iterate;
22885
+ if (iterate) this.iterateGroup(component.nodes, iterate);
22886
+ else for (const node of component.nodes) this.markCycle(node);
22406
22887
  } else if (this.pending.has(first4)) {
22407
22888
  this.computeFrom(first4);
22408
22889
  }
@@ -22444,6 +22925,30 @@ var EngineCore = class extends EngineHost {
22444
22925
  }
22445
22926
  }
22446
22927
  }
22928
+ /**
22929
+ * Iterative calculation of a circular group (`calcPr iterate`): every member is recomputed in
22930
+ * turn, reading the others' values from the previous step, until the largest change is within
22931
+ * `delta` or `count` passes have run. The group starts from the values the cells hold.
22932
+ */
22933
+ iterateGroup(nodes, limits) {
22934
+ for (const node of nodes) this.pending?.delete(node);
22935
+ const cellOf2 = (node) => this.workbook.sheets[node.sheet]?.rows.get(node.row)?.get(node.col);
22936
+ this.iterating = true;
22937
+ try {
22938
+ for (let pass = 0; pass < limits.count; pass++) {
22939
+ let change = 0;
22940
+ for (const node of nodes) {
22941
+ const before = cellOf2(node)?.value ?? null;
22942
+ this.compute(node);
22943
+ const after = cellOf2(node)?.value ?? null;
22944
+ change = Math.max(change, valueChange(before, after));
22945
+ }
22946
+ if (change <= limits.delta) break;
22947
+ }
22948
+ } finally {
22949
+ this.iterating = false;
22950
+ }
22951
+ }
22447
22952
  markCycle(node) {
22448
22953
  this.pending?.delete(node);
22449
22954
  this.cycles.add(node);
@@ -22934,16 +23439,16 @@ function shiftIndexClamped(index2, shift2) {
22934
23439
  }
22935
23440
  function shiftRange(range, shift2) {
22936
23441
  if (shift2.axis === "row") {
22937
- const span3 = shiftSpan(range.start.row, range.end.row, shift2);
22938
- return span3 && {
22939
- start: { row: span3.start, col: range.start.col },
22940
- end: { row: span3.end, col: range.end.col }
23442
+ const span4 = shiftSpan(range.start.row, range.end.row, shift2);
23443
+ return span4 && {
23444
+ start: { row: span4.start, col: range.start.col },
23445
+ end: { row: span4.end, col: range.end.col }
22941
23446
  };
22942
23447
  }
22943
- const span2 = shiftSpan(range.start.col, range.end.col, shift2);
22944
- return span2 && {
22945
- start: { row: range.start.row, col: span2.start },
22946
- end: { row: range.end.row, col: span2.end }
23448
+ const span3 = shiftSpan(range.start.col, range.end.col, shift2);
23449
+ return span3 && {
23450
+ start: { row: range.start.row, col: span3.start },
23451
+ end: { row: range.end.row, col: span3.end }
22947
23452
  };
22948
23453
  }
22949
23454
  function shiftRangeInBand(range, shift2, lo, hi) {
@@ -23755,7 +24260,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
23755
24260
  ).join("")}</definedNames>`;
23756
24261
  const calc = kept.get("calcPr");
23757
24262
  const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
23758
- out += `<calcPr${copyAttrs(calc, ["fullCalcOnLoad", "calcId", "calcMode"])} calcId="191029"${mode} fullCalcOnLoad="1"/>`;
24263
+ const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
24264
+ const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
24265
+ out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
23759
24266
  out += raw(KEPT_TAIL);
23760
24267
  return `${out}</workbook>`;
23761
24268
  }
@@ -25974,8 +26481,8 @@ function shiftAxisFormats(sheet, shift2) {
25974
26481
  }
25975
26482
  sheet.columns = normalizeColumns(
25976
26483
  sheet.columns.flatMap((info) => {
25977
- const span2 = shiftSpan(info.min, info.max, shift2);
25978
- return span2 ? [{ ...info, min: span2.start, max: span2.end }] : [];
26484
+ const span3 = shiftSpan(info.min, info.max, shift2);
26485
+ return span3 ? [{ ...info, min: span3.start, max: span3.end }] : [];
25979
26486
  })
25980
26487
  );
25981
26488
  }
@@ -26152,11 +26659,11 @@ function toHtml(cells3, theme2) {
26152
26659
  if (covered.has(`${r},${c2}`)) continue;
26153
26660
  const cell = cells3.data[r]?.[c2] ?? null;
26154
26661
  const attrs2 = [];
26155
- const span2 = spans2.get(`${r},${c2}`);
26156
- if (span2 && span2.end.row > span2.start.row)
26157
- attrs2.push(`rowspan="${span2.end.row - span2.start.row + 1}"`);
26158
- if (span2 && span2.end.col > span2.start.col)
26159
- attrs2.push(`colspan="${span2.end.col - span2.start.col + 1}"`);
26662
+ const span3 = spans2.get(`${r},${c2}`);
26663
+ if (span3 && span3.end.row > span3.start.row)
26664
+ attrs2.push(`rowspan="${span3.end.row - span3.start.row + 1}"`);
26665
+ if (span3 && span3.end.col > span3.start.col)
26666
+ attrs2.push(`colspan="${span3.end.col - span3.start.col + 1}"`);
26160
26667
  if (cell && typeof cell.value === "number") attrs2.push(`x:num="${cell.value}"`);
26161
26668
  const css = cssFor(cell?.style, theme2);
26162
26669
  if (css) attrs2.push(`style="${escapeHtml(css)}"`);
@@ -28592,7 +29099,7 @@ var MAX_OUTLINE_LEVEL = 7;
28592
29099
  function nextLevel(level, delta) {
28593
29100
  return Math.max(0, Math.min(MAX_OUTLINE_LEVEL, (level ?? 0) + delta));
28594
29101
  }
28595
- function span(from, to) {
29102
+ function span2(from, to) {
28596
29103
  const lo = Math.max(0, Math.min(from, to));
28597
29104
  const hi = Math.max(from, to);
28598
29105
  return Array.from({ length: hi - lo + 1 }, (_v, i) => lo + i);
@@ -28604,7 +29111,7 @@ function outlineRows(ctx, s, from, to, delta) {
28604
29111
  "structure",
28605
29112
  [{ kind: "sheet", sheet: s }],
28606
29113
  () => {
28607
- for (const row2 of span(from, to)) {
29114
+ for (const row2 of span2(from, to)) {
28608
29115
  const info = { ...sheet.rowInfo.get(row2) };
28609
29116
  const level = nextLevel(info.outlineLevel, delta);
28610
29117
  if (level) info.outlineLevel = level;
@@ -28625,7 +29132,7 @@ function outlineColumns(ctx, s, from, to, delta) {
28625
29132
  delta > 0 ? "Group columns" : "Ungroup columns",
28626
29133
  "structure",
28627
29134
  [{ kind: "sheet", sheet: s }],
28628
- () => editColumns(sheet, span(from, to), (info) => {
29135
+ () => editColumns(sheet, span2(from, to), (info) => {
28629
29136
  const level = nextLevel(info.outlineLevel, delta);
28630
29137
  if (level) info.outlineLevel = level;
28631
29138
  else {
@@ -30937,10 +31444,10 @@ function inspectZip(bytes, limits, check3) {
30937
31444
  if (offset2 !== end) fail2("INVALID_ZIP", "Central directory length or count mismatch");
30938
31445
  spans2.sort((a, b) => a.start - b.start);
30939
31446
  let previousEnd = 0;
30940
- for (const span2 of spans2) {
30941
- if (span2.start !== previousEnd)
31447
+ for (const span3 of spans2) {
31448
+ if (span3.start !== previousEnd)
30942
31449
  fail2("ZIP_MISMATCH", "Overlapping, prefixed, or unindexed ZIP records");
30943
- previousEnd = span2.end;
31450
+ previousEnd = span3.end;
30944
31451
  }
30945
31452
  if (previousEnd !== centralStart) fail2("ZIP_MISMATCH", "Unindexed ZIP data");
30946
31453
  return entries;
@@ -33912,17 +34419,17 @@ function flattenNurbs(controls2, sourceKnots, degree, consume, consumeWork) {
33912
34419
  while (multiplicity < degree) {
33913
34420
  charge(points.length + knots.length + degree * 4);
33914
34421
  if (points.length >= MAX_REFINED_CONTROLS) throw failure2;
33915
- let span2 = degree;
33916
- while (span2 < points.length - 1 && knots[span2 + 1] <= u) span2++;
34422
+ let span3 = degree;
34423
+ while (span3 < points.length - 1 && knots[span3 + 1] <= u) span3++;
33917
34424
  const next = new Array(points.length + 1);
33918
- for (let i = 0; i <= span2 - degree; i++) next[i] = points[i];
33919
- for (let i = span2 - multiplicity; i < points.length; i++) next[i + 1] = points[i];
33920
- for (let i = span2 - degree + 1; i <= span2 - multiplicity; i++) {
34425
+ for (let i = 0; i <= span3 - degree; i++) next[i] = points[i];
34426
+ for (let i = span3 - multiplicity; i < points.length; i++) next[i + 1] = points[i];
34427
+ for (let i = span3 - degree + 1; i <= span3 - multiplicity; i++) {
33921
34428
  const alpha = (u - knots[i]) / (knots[i + degree] - knots[i]);
33922
34429
  if (!Number.isFinite(alpha) || alpha < 0 || alpha > 1) throw failure2;
33923
34430
  next[i] = blend(points[i - 1], points[i], alpha);
33924
34431
  }
33925
- knots = [...knots.slice(0, span2 + 1), u, ...knots.slice(span2 + 1)];
34432
+ knots = [...knots.slice(0, span3 + 1), u, ...knots.slice(span3 + 1)];
33926
34433
  points = next;
33927
34434
  multiplicity++;
33928
34435
  }
@@ -33953,9 +34460,9 @@ function flattenNurbs(controls2, sourceKnots, degree, consume, consumeWork) {
33953
34460
  subdivide(left2, depth + 1);
33954
34461
  subdivide(right2.reverse(), depth + 1);
33955
34462
  };
33956
- for (let span2 = degree; span2 < points.length; span2++) {
34463
+ for (let span3 = degree; span3 < points.length; span3++) {
33957
34464
  charge(1);
33958
- if (knots[span2 + 1] > knots[span2]) subdivide(points.slice(span2 - degree, span2 + 1), 0);
34465
+ if (knots[span3 + 1] > knots[span3]) subdivide(points.slice(span3 - degree, span3 + 1), 0);
33959
34466
  }
33960
34467
  if (output.length) {
33961
34468
  const last = controls2.at(-1);
@@ -34297,9 +34804,9 @@ function ellipticalArc(startX, startY, x, y, midX, midY, angle, ratio) {
34297
34804
  const radius = Math.hypot(ax - ux, ay - uy);
34298
34805
  const tau = Math.PI * 2;
34299
34806
  const start = Math.atan2(ay - uy, ax - ux), mid = Math.atan2(by - uy, bx - ux), end = Math.atan2(cy - uy, cx - ux);
34300
- const span2 = (end - start + tau) % tau, middle = (mid - start + tau) % tau;
34301
- const sweep = middle <= span2 ? 1 : 0;
34302
- const large = (sweep ? span2 : tau - span2) > Math.PI ? 1 : 0;
34807
+ const span3 = (end - start + tau) % tau, middle = (mid - start + tau) % tau;
34808
+ const sweep = middle <= span3 ? 1 : 0;
34809
+ const large = (sweep ? span3 : tau - span3) > Math.PI ? 1 : 0;
34303
34810
  if (!Number.isFinite(radius) || radius > 1e9) return void 0;
34304
34811
  return `A ${point(radius, radius / ratio)} ${clean2(angle * 180 / Math.PI)} ${large} ${sweep} ${point(x, y)}`;
34305
34812
  }
@@ -37928,17 +38435,17 @@ async function assertGeometryPackageScope(pkg, pagePaths, commands, check3, root
37928
38435
  }
37929
38436
 
37930
38437
  // src/visio/edit.ts
37931
- function positive2(value) {
38438
+ function positive3(value) {
37932
38439
  if (!Number.isSafeInteger(value) || value <= 0)
37933
38440
  fail2("INVALID_LIMITS", "Edit limits must be positive safe integers.");
37934
38441
  return value;
37935
38442
  }
37936
38443
  async function editVsdx(input, edits, options = {}) {
37937
38444
  const limits = { ...DEFAULTS, ...options.limits };
37938
- for (const value of Object.values(limits)) positive2(value);
37939
- const maxEdits = positive2(options.maxEdits ?? 1e3);
37940
- const maxText = positive2(options.maxTextCharacters ?? 1e6);
37941
- const maxOutput = positive2(options.maxOutputBytes ?? limits.maxInputBytes);
38445
+ for (const value of Object.values(limits)) positive3(value);
38446
+ const maxEdits = positive3(options.maxEdits ?? 1e3);
38447
+ const maxText = positive3(options.maxTextCharacters ?? 1e6);
38448
+ const maxOutput = positive3(options.maxOutputBytes ?? limits.maxInputBytes);
37942
38449
  const deadline = Date.now() + limits.maxRuntimeMs;
37943
38450
  const check3 = () => {
37944
38451
  if (Date.now() >= deadline) fail2("LIMIT_RUNTIME", "Visio edit deadline exceeded.");