ooxml-core 1.31.0 → 1.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/{PptxHandler-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
  2. package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
  3. package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
  4. package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
  5. package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
  6. package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
  7. package/dist/automation/index.cjs +862 -389
  8. package/dist/automation/index.mjs +862 -389
  9. package/dist/{chunk-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
  10. package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
  11. package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
  12. package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
  13. package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
  14. package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
  15. package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
  16. package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
  17. package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
  18. package/dist/diagram/index.cjs +8 -4
  19. package/dist/diagram/index.mjs +8 -4
  20. package/dist/docx/embedded.cjs +8 -4
  21. package/dist/docx/embedded.mjs +8 -4
  22. package/dist/docx/index.cjs +8 -4
  23. package/dist/docx/index.mjs +8 -4
  24. package/dist/docx/layout/index.cjs +8 -4
  25. package/dist/docx/layout/index.mjs +8 -4
  26. package/dist/docx/load/index.cjs +8 -4
  27. package/dist/docx/load/index.mjs +8 -4
  28. package/dist/docx/ui/index.cjs +8 -4
  29. package/dist/docx/ui/index.mjs +8 -4
  30. package/dist/geometry/index.cjs +16 -12
  31. package/dist/geometry/index.mjs +16 -12
  32. package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
  33. package/dist/index.cjs +16 -12
  34. package/dist/index.mjs +16 -12
  35. package/dist/pptx/automation/index.cjs +294 -157
  36. package/dist/pptx/automation/index.d.ts +3 -3
  37. package/dist/pptx/automation/index.mjs +5 -5
  38. package/dist/pptx/chunks/{index-PdM5zpmu.d.ts → index-D-FdgqrP.d.ts} +102 -3
  39. package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
  40. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
  41. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
  42. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
  43. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
  44. package/dist/pptx/cli/index.cjs +294 -157
  45. package/dist/pptx/cli/index.mjs +4 -4
  46. package/dist/pptx/converter/index.cjs +8 -4
  47. package/dist/pptx/converter/index.d.ts +1 -1
  48. package/dist/pptx/converter/index.mjs +2 -2
  49. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  50. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  51. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  52. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  53. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  54. package/dist/pptx/index.cjs +380 -171
  55. package/dist/pptx/index.d.ts +4 -4
  56. package/dist/pptx/index.mjs +5 -5
  57. package/dist/pptx/node/index.d.ts +1 -1
  58. package/dist/teams/chat-view.d.ts +10 -1
  59. package/dist/teams/chat-view.d.ts.map +1 -1
  60. package/dist/teams/index.cjs +805 -144
  61. package/dist/teams/index.d.ts +1 -0
  62. package/dist/teams/index.d.ts.map +1 -1
  63. package/dist/teams/index.mjs +795 -145
  64. package/dist/teams/presence-controller.d.ts +18 -3
  65. package/dist/teams/presence-controller.d.ts.map +1 -1
  66. package/dist/teams/presence-meetings.d.ts +21 -0
  67. package/dist/teams/presence-meetings.d.ts.map +1 -0
  68. package/dist/teams/presence.d.ts +40 -2
  69. package/dist/teams/presence.d.ts.map +1 -1
  70. package/dist/teams/store.d.ts +5 -0
  71. package/dist/teams/store.d.ts.map +1 -1
  72. package/dist/teams/view.d.ts +5 -0
  73. package/dist/teams/view.d.ts.map +1 -1
  74. package/dist/teams/workspace.d.ts +5 -2
  75. package/dist/teams/workspace.d.ts.map +1 -1
  76. package/dist/visio/index.cjs +6 -1
  77. package/dist/visio/index.mjs +6 -1
  78. package/dist/visio/ui/index.cjs +6 -1
  79. package/dist/visio/ui/index.mjs +6 -1
  80. package/dist/xlsx/formula/ets-drift-compare.d.ts +19 -0
  81. package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
  82. package/dist/xlsx/formula/ets-excel-compare.d.ts +12 -0
  83. package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -1
  84. package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
  85. package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
  86. package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
  87. package/dist/xlsx/formula/ets-init-maps.d.ts.map +1 -0
  88. package/dist/xlsx/formula/functions/ets-core.d.ts +1 -1
  89. package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -1
  90. package/dist/xlsx/formula/functions/ets-init-chain.d.ts +11 -0
  91. package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
  92. package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
  93. package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
  94. package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
  95. package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
  96. package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
  97. package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
  98. package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
  99. package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
  100. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
  101. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
  102. package/dist/xlsx/formula/functions/ets-init.d.ts +18 -0
  103. package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -1
  104. package/dist/xlsx/formula/functions/ets-search-map.d.ts +24 -0
  105. package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
  106. package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
  107. package/dist/xlsx/formula/functions/ets-search.d.ts.map +1 -0
  108. package/dist/xlsx/formula/functions/ets-season.d.ts +2 -2
  109. package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -1
  110. package/dist/xlsx/formula/functions/ets-validate.d.ts +16 -0
  111. package/dist/xlsx/formula/functions/ets-validate.d.ts.map +1 -0
  112. package/dist/xlsx/index.cjs +762 -289
  113. package/dist/xlsx/index.mjs +762 -289
  114. package/dist/xlsx/layout/form-control-view.d.ts.map +1 -1
  115. package/dist/xlsx/layout/shape-view.d.ts.map +1 -1
  116. package/dist/xlsx/load/index.cjs +599 -126
  117. package/dist/xlsx/load/index.mjs +599 -126
  118. package/dist/xlsx/read/form-control.d.ts.map +1 -1
  119. package/dist/xlsx/ui/index.cjs +756 -283
  120. package/dist/xlsx/ui/index.mjs +756 -283
  121. package/package.json +1 -1
  122. package/dist/PptxHandler-E4DDV3FQ.mjs +0 -4
  123. package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
@@ -6541,14 +6541,14 @@ function linearFit(xs, ys) {
6541
6541
  return { slope, intercept: my - slope * mx };
6542
6542
  }
6543
6543
  function rank(values2, x, ascending, average) {
6544
- let better = 0;
6544
+ let better2 = 0;
6545
6545
  let ties = 0;
6546
6546
  for (const v of values2) {
6547
6547
  if (v === x) ties++;
6548
- else if (ascending ? v < x : v > x) better++;
6548
+ else if (ascending ? v < x : v > x) better2++;
6549
6549
  }
6550
6550
  if (ties === 0) fail(ERR.NA);
6551
- return average ? better + (ties + 1) / 2 : better + 1;
6551
+ return average ? better2 + (ties + 1) / 2 : better2 + 1;
6552
6552
  }
6553
6553
  var LANCZOS = [
6554
6554
  676.5203681218851,
@@ -11594,11 +11594,11 @@ function binomDist(k, n2, p, cumulative2) {
11594
11594
  for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
11595
11595
  return Math.min(1, total2);
11596
11596
  }
11597
- function poisson(k, mean4, cumulative2) {
11597
+ function poisson(k, mean9, cumulative2) {
11598
11598
  const kk = Math.trunc(k);
11599
- if (kk < 0 || mean4 < 0) fail(ERR.NUM);
11600
- if (cumulative2) return 1 - gammaP(kk + 1, mean4);
11601
- return Math.exp(kk * Math.log(mean4) - mean4 - gammaLn(kk + 1));
11599
+ if (kk < 0 || mean9 < 0) fail(ERR.NUM);
11600
+ if (cumulative2) return 1 - gammaP(kk + 1, mean9);
11601
+ return Math.exp(kk * Math.log(mean9) - mean9 - gammaLn(kk + 1));
11602
11602
  }
11603
11603
  var normDist = (x, m, s, cumulative2) => {
11604
11604
  positive2(s);
@@ -11606,13 +11606,272 @@ var normDist = (x, m, s, cumulative2) => {
11606
11606
  return cumulative2 ? normCdf(z) : normPdf(z) / s;
11607
11607
  };
11608
11608
 
11609
+ // xlsx/formula/functions/ets-init-three.ts
11610
+ var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11611
+ function slopeOf(v) {
11612
+ const k = v.length;
11613
+ const mx = (k - 1) / 2;
11614
+ const my = mean2(v);
11615
+ let sxy = 0;
11616
+ let sxx = 0;
11617
+ for (let i2 = 0; i2 < k; i2++) {
11618
+ sxy += (i2 - mx) * (v[i2] - my);
11619
+ sxx += (i2 - mx) * (i2 - mx);
11620
+ }
11621
+ return sxx === 0 ? 0 : sxy / sxx;
11622
+ }
11623
+ function positionSlopes(y, m) {
11624
+ return Array.from({ length: m }, (_v, c2) => {
11625
+ const vals = [];
11626
+ for (let t = c2; t < y.length; t += m) vals.push(y[t]);
11627
+ return slopeOf(vals) / m;
11628
+ });
11629
+ }
11630
+ function isThreeSeasonLength(n2, m) {
11631
+ return m >= 4 && n2 >= 3 * m && n2 <= 3 * m + Math.ceil(m / 2) + 1;
11632
+ }
11633
+ function threeSeasonSeasonals(y, m, slopeSumOverride) {
11634
+ const n2 = y.length;
11635
+ const extra = n2 - 3 * m;
11636
+ const j0 = Math.floor(m / 2);
11637
+ const at2 = (t) => y[t];
11638
+ const slope = (j) => (at2(j + 2 * m) - at2(j)) / (2 * m);
11639
+ const B = (j) => j + 2 * m < n2 ? slope(j) : slope(j % m);
11640
+ const e = (t) => at2(t) - at2(t - 1) - B(t - j0);
11641
+ const slopeSum = slopeSumOverride ?? positionSlopes(y, m).reduce((a2, b) => a2 + b, 0);
11642
+ const out = [0];
11643
+ for (let k = 1; k < m; k++) {
11644
+ let back = 0;
11645
+ for (let t = k + 1; t <= m; t++) back -= e(t);
11646
+ let fwd = 0;
11647
+ for (let t = m + 1; t <= m + k; t++) fwd += e(t);
11648
+ if (k < j0 - 1) {
11649
+ out.push(fwd);
11650
+ continue;
11651
+ }
11652
+ if (k === m - 1 && extra <= Math.ceil(m / 2)) {
11653
+ out.push(back);
11654
+ continue;
11655
+ }
11656
+ const wrapped = Math.max(0, k - j0 + 1 - extra);
11657
+ let corner4 = 0;
11658
+ for (let i2 = extra; i2 <= k - j0; i2++)
11659
+ corner4 += (at2(i2 + m) + at2(i2 + 2 * m) - 2 * at2(i2)) / (4 * m);
11660
+ const level4 = (at2(k) + at2(m + k)) / 2 - at2(m);
11661
+ const bb = back - (at2(k) - at2(m));
11662
+ const ff = fwd - (at2(m + k) - at2(m));
11663
+ out.push(level4 + (bb + ff) / 2 - 3 * wrapped / (4 * m) * slopeSum + corner4);
11664
+ }
11665
+ return out;
11666
+ }
11667
+ function padThreeSeasons(y, m, slopeMean = mean2(positionSlopes(y, m))) {
11668
+ const n2 = y.length;
11669
+ const total2 = Math.max(3 * m + Math.ceil(m / 2), n2);
11670
+ const ext = [...y];
11671
+ for (let t = n2; t < total2; t++) ext.push(y[t - 3 * m] + 3 * m * slopeMean);
11672
+ return ext;
11673
+ }
11674
+ function threeSeasonTrend(y, m, rel, slopeMean) {
11675
+ const ext = padThreeSeasons(y, m, slopeMean);
11676
+ const total2 = ext.length;
11677
+ const mx = (total2 - 1) / 2;
11678
+ let sxx = 0;
11679
+ let sxy = 0;
11680
+ for (let t = 0; t < total2; t++) {
11681
+ sxx += (t - mx) * (t - mx);
11682
+ sxy += (t - mx) * (ext[t] - rel[t % m]);
11683
+ }
11684
+ return sxy / sxx;
11685
+ }
11686
+ function isTwoSeasonLength(n2, m) {
11687
+ return m >= 4 && n2 === 2 * m;
11688
+ }
11689
+ function isTwoPlusLength(n2, m) {
11690
+ return m >= 4 && n2 > 2 * m && n2 < 3 * m;
11691
+ }
11692
+ function slopeSumOf(y, m) {
11693
+ return positionSlopes(y, m).reduce((a2, c2) => a2 + c2, 0);
11694
+ }
11695
+ function extendTwoSeasons(y, m) {
11696
+ const b = mean2(positionSlopes(y, m));
11697
+ const out = [...y];
11698
+ for (let t = y.length; t < 3 * m; t++) out.push(y[t - 2 * m] + 2 * m * b);
11699
+ return out;
11700
+ }
11701
+ function paddedSearchSeries(y, m) {
11702
+ if (isTwoSeasonLength(y.length, m) || isTwoPlusLength(y.length, m))
11703
+ return padThreeSeasons(extendTwoSeasons(y, m), m, slopeSumOf(y, m) / m);
11704
+ if (isThreeSeasonLength(y.length, m)) return padThreeSeasons(y, m);
11705
+ return void 0;
11706
+ }
11707
+
11708
+ // xlsx/formula/functions/ets-init-states.ts
11709
+ var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11710
+ function chainStates(y, m, seasons) {
11711
+ const h2 = Math.floor(seasons / 2);
11712
+ const first2 = seasons - h2;
11713
+ const at2 = (t) => y[t];
11714
+ const meanFirst = (t) => mean3(Array.from({ length: first2 }, (_v, c2) => at2(t + c2 * m)));
11715
+ const slope = (j) => {
11716
+ const early = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + c2 * m)));
11717
+ const late = mean3(Array.from({ length: h2 }, (_v, c2) => at2(j + (seasons - h2 + c2) * m)));
11718
+ return (late - early) / ((seasons - h2) * m);
11719
+ };
11720
+ const j0 = Math.floor(m / 2);
11721
+ const state = /* @__PURE__ */ new Map([[j0 - 1, 0]]);
11722
+ for (let t = j0; t <= j0 + m - 2; t++)
11723
+ state.set(t, state.get(t - 1) + meanFirst(t) - meanFirst(t - 1) - slope(t - j0));
11724
+ const byPosition = new Array(m).fill(0);
11725
+ for (const [t, s] of state) byPosition[t % m] = s;
11726
+ return byPosition;
11727
+ }
11728
+ function chainSeasonals(y, m, seasons) {
11729
+ const byPosition = chainStates(y, m, seasons);
11730
+ const origin = byPosition[0];
11731
+ return byPosition.map((s) => s - origin);
11732
+ }
11733
+
11734
+ // xlsx/formula/functions/ets-init-four.ts
11735
+ var mean4 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11736
+ function template(w, m, a2) {
11737
+ const block = (c2) => mean4(w.slice(c2 * m, (c2 + 1) * m));
11738
+ const at2 = (i2) => w[i2];
11739
+ return (block(0) - block(2)) / 12 + (block(1) - block(3)) / 6 - (at2(a2) + at2(a2 + m) - 2 * at2(a2 + 2 * m)) / 6;
11740
+ }
11741
+ function fourSeasonPlusSeasonals(y, m) {
11742
+ const r = y.length - 4 * m;
11743
+ const a2 = Math.floor(m / 2) - 1;
11744
+ const states2 = chainStates(y.slice(0, 4 * m), m, 4);
11745
+ for (let q = 0; q < r; q++) {
11746
+ const pos = (a2 + q) % m;
11747
+ states2[pos] = states2[pos] + template(y.slice(q, q + 4 * m), m, a2);
11748
+ }
11749
+ const origin = states2[0];
11750
+ return states2.map((s) => s - origin);
11751
+ }
11752
+
11753
+ // xlsx/formula/functions/ets-init-threeplus.ts
11754
+ var mean5 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11755
+ function isThreePlusLength(n2, m) {
11756
+ return m >= 4 && n2 >= 3 * m + Math.ceil(m / 2) + 2 && n2 < 4 * m;
11757
+ }
11758
+ function shift2(y, m, k) {
11759
+ const a2 = Math.ceil(m / 2) + 1;
11760
+ const at2 = (i2) => y[i2];
11761
+ return (at2(m + k) - at2(2 * m + k)) / 2 - (mean5(y.slice(a2 + k, a2 + k + m)) - mean5(y.slice(a2 + 2 * m + k, a2 + 3 * m + k))) / 4;
11762
+ }
11763
+ function isLowThreeLength(n2, m) {
11764
+ return m === 2 && n2 >= 5 && n2 < 8 || m === 3 && n2 >= 6 && n2 < 12;
11765
+ }
11766
+ function lowSeasonSeasonals(y, m, slopeSum) {
11767
+ const base = threeSeasonSeasonals(y, m, slopeSum);
11768
+ const d = -shift2(y, m, -m);
11769
+ return base.map((s, k) => k === 0 ? 0 : s + d);
11770
+ }
11771
+ function threePlusSeasonals(y, m) {
11772
+ const base = threeSeasonSeasonals(y, m);
11773
+ const moved = y.length - 3 * m - Math.ceil(m / 2) - 1;
11774
+ const z = base.map((s, k) => k < moved ? s - shift2(y, m, k) : s);
11775
+ const origin = z[0];
11776
+ return z.map((s) => s - origin);
11777
+ }
11778
+
11779
+ // xlsx/formula/functions/ets-init-short.ts
11780
+ function seasonStart(m) {
11781
+ return Math.ceil(10 * (m + 1) / 7);
11782
+ }
11783
+ function isShortSeasonLength(n2, m) {
11784
+ return m >= 5 && n2 >= seasonStart(m) && n2 < 2 * m;
11785
+ }
11786
+ function padTwoSeasons(y, m) {
11787
+ const p = [...y];
11788
+ for (let t = y.length; t < 2 * m; t++) p.push(p[t - m]);
11789
+ return p;
11790
+ }
11791
+ function trendShift(m, n2) {
11792
+ const j0 = Math.floor(m / 2);
11793
+ const u = 2 * m - 1 - n2;
11794
+ return (u * u - (j0 - 2) * u + 2 * (j0 - 1)) / 4;
11795
+ }
11796
+ function shortSeasonStart(y, m) {
11797
+ const n2 = y.length;
11798
+ const p = padTwoSeasons(y, m);
11799
+ const ss = slopeSumOf(p, m);
11800
+ const ext = extendTwoSeasons(p, m);
11801
+ const base = threeSeasonSeasonals(ext, m, ss);
11802
+ const total2 = 3 * m + Math.ceil(m / 2);
11803
+ const sxx = total2 * (total2 * total2 - 1) / 12;
11804
+ const trend = threeSeasonTrend(ext, m, base, ss / m) + trendShift(m, n2) * ss / sxx;
11805
+ const rel = base.map((s, k) => k >= n2 - m && k <= m - 2 ? s + ss / 2 : s);
11806
+ return { rel, trend };
11807
+ }
11808
+ function shortSearchSeries(y, m) {
11809
+ const p = padTwoSeasons(y, m);
11810
+ return padThreeSeasons(extendTwoSeasons(p, m), m, slopeSumOf(p, m) / m);
11811
+ }
11812
+
11813
+ // xlsx/formula/functions/ets-init-chain.ts
11814
+ var MAX_SEASONS = 5;
11815
+ var mean6 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11816
+ function isExactLength(n2, m) {
11817
+ const whole = Math.floor(n2 / m);
11818
+ return whole >= MAX_SEASONS || whole === 4 || isThreeSeasonLength(n2, m) || isThreePlusLength(n2, m) || isLowThreeLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m) || isShortSeasonLength(n2, m);
11819
+ }
11820
+ function fromRelative(y0, rel, trend) {
11821
+ const combined = rel.map((s) => y0 + s - trend);
11822
+ const level4 = mean6(combined);
11823
+ return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11824
+ }
11825
+ function chainStart(y, m) {
11826
+ const n2 = y.length;
11827
+ const whole = Math.floor(n2 / m);
11828
+ if (isShortSeasonLength(n2, m)) {
11829
+ const { rel: rel2, trend } = shortSeasonStart(y, m);
11830
+ return fromRelative(y[0], rel2, trend);
11831
+ }
11832
+ if (isThreeSeasonLength(n2, m) || isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m)) {
11833
+ const short = isTwoSeasonLength(n2, m) || isTwoPlusLength(n2, m);
11834
+ const series = short ? extendTwoSeasons(y, m) : y;
11835
+ const rel2 = threeSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11836
+ return fromRelative(
11837
+ y[0],
11838
+ rel2,
11839
+ threeSeasonTrend(series, m, rel2, short ? slopeSumOf(y, m) / m : void 0)
11840
+ );
11841
+ }
11842
+ if (isLowThreeLength(n2, m)) {
11843
+ const short = n2 < 3 * m;
11844
+ const series = short ? extendTwoSeasons(y, m) : y;
11845
+ const rel2 = lowSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
11846
+ const pad8 = short ? slopeSumOf(y, m) / m : void 0;
11847
+ return fromRelative(y[0], rel2, threeSeasonTrend(series, m, rel2, pad8));
11848
+ }
11849
+ if (isThreePlusLength(n2, m)) {
11850
+ const rel2 = threePlusSeasonals(y, m);
11851
+ return fromRelative(y[0], rel2, threeSeasonTrend(y, m, rel2));
11852
+ }
11853
+ if (m < 2 || whole < 4) return void 0;
11854
+ const partial = whole < MAX_SEASONS && n2 % m !== 0;
11855
+ const rel = partial ? fourSeasonPlusSeasonals(y, m) : chainSeasonals(y, m, Math.min(whole, MAX_SEASONS));
11856
+ const mx = (n2 - 1) / 2;
11857
+ let sxy = 0;
11858
+ let sxx = 0;
11859
+ const my = mean6(y.map((v, t) => v - rel[t % m]));
11860
+ for (let t = 0; t < n2; t++) {
11861
+ const d = y[t] - rel[t % m] - my;
11862
+ sxy += (t - mx) * d;
11863
+ sxx += (t - mx) * (t - mx);
11864
+ }
11865
+ return fromRelative(y[0], rel, sxy / sxx);
11866
+ }
11867
+
11609
11868
  // xlsx/formula/functions/ets-init.ts
11610
11869
  var MAX_EXACT_SEASON = 24;
11611
- var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11870
+ var mean7 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11612
11871
  function olsSlope(y) {
11613
11872
  const n2 = y.length;
11614
11873
  const mx = (n2 - 1) / 2;
11615
- const my = mean2(y);
11874
+ const my = mean7(y);
11616
11875
  let sxy = 0;
11617
11876
  let sxx = 0;
11618
11877
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11621,12 +11880,30 @@ function olsSlope(y) {
11621
11880
  }
11622
11881
  return sxx === 0 ? 0 : sxy / sxx;
11623
11882
  }
11883
+ var PADS = {
11884
+ 6: [[0, 6]],
11885
+ 5: [
11886
+ [1, 4],
11887
+ [0, 6]
11888
+ ],
11889
+ 4: [
11890
+ [0, 4],
11891
+ [1, 4],
11892
+ [0, 6]
11893
+ ]
11894
+ };
11895
+ function shortSeriesTrend(y) {
11896
+ const pads = PADS[y.length];
11897
+ if (!pads) return olsSlope(y);
11898
+ const slope = olsSlope(y);
11899
+ return olsSlope([...y, ...pads.map(([src, lag]) => y[src] + lag * slope)]);
11900
+ }
11624
11901
  function split(trend, combined) {
11625
- const level4 = mean2(combined);
11902
+ const level4 = mean7(combined);
11626
11903
  return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
11627
11904
  }
11628
11905
  function heuristicStates(y, m) {
11629
- const trend = (mean2(y.slice(m, 2 * m)) - mean2(y.slice(0, m))) / m;
11906
+ const trend = (mean7(y.slice(m, 2 * m)) - mean7(y.slice(0, m))) / m;
11630
11907
  return split(
11631
11908
  trend,
11632
11909
  Array.from({ length: m }, (_v, k) => y[k] - trend * (k + 1))
@@ -11663,9 +11940,11 @@ function solveSystem(a2, b) {
11663
11940
  function initialStates(y, m, p, run2) {
11664
11941
  const y0 = y[0];
11665
11942
  if (m < 2) {
11666
- const trend2 = olsSlope(y);
11943
+ const trend2 = shortSeriesTrend(y);
11667
11944
  return { level: y0 - trend2, trend: trend2, season: [] };
11668
11945
  }
11946
+ const exact = chainStart(y, m);
11947
+ if (exact) return exact;
11669
11948
  if (m > MAX_EXACT_SEASON) return heuristicStates(y, m);
11670
11949
  const zeros = new Array(y.length).fill(0);
11671
11950
  const unit = (trend2, season) => run2(zeros, m, { level: 0, trend: trend2, season }, p).fitted;
@@ -11685,6 +11964,202 @@ function initialStates(y, m, p, run2) {
11685
11964
  return split(trend, [y0 - trend, ...u.slice(1)]);
11686
11965
  }
11687
11966
 
11967
+ // xlsx/formula/functions/ets-search-map.ts
11968
+ var LOW = 1e-3;
11969
+ var DRIFT_SHIFT = 1.5;
11970
+ var DRIFT_T = 9.3;
11971
+ var CANDIDATES = [
11972
+ ...[2e-3, 0.1, 0.126, 0.25, 0.5, 0.75, 0.9].map((a2) => [a2, LOW]),
11973
+ [0.1, 0.099],
11974
+ [0.126, 0.125],
11975
+ [0.25, 0.249],
11976
+ [0.333333, 0.166667],
11977
+ [0.5, 0.25],
11978
+ [0.5, 0.499],
11979
+ [0.666667, 0.166667],
11980
+ [0.666667, 0.5],
11981
+ [0.75, 0.749],
11982
+ [0.833333, 0.75],
11983
+ [0.9, 0.899],
11984
+ [0.998, 0.099],
11985
+ [0.998, 0.249],
11986
+ [0.998, 0.499],
11987
+ [0.998, 0.749],
11988
+ [0.998, 0.899],
11989
+ [0.166667, 0.0833333],
11990
+ [0.833333, 0.0833333]
11991
+ ];
11992
+ var ALWAYS_DRIFT = /* @__PURE__ */ new Set([
11993
+ "0.1/0.099",
11994
+ "0.998/0.899",
11995
+ "0.998/0.749",
11996
+ "0.166667/0.0833333",
11997
+ "0.25/0.249",
11998
+ "0.9/0.899",
11999
+ "0.666667/0.5",
12000
+ "0.75/0.749"
12001
+ ]);
12002
+ var NEVER_DRIFT = /* @__PURE__ */ new Set(["0.333333/0.166667"]);
12003
+ function trendShape(y, h2) {
12004
+ const n2 = y.length;
12005
+ const hold = h2 > 0 ? h2 : Math.max(1, Math.round(0.3 * n2));
12006
+ const mx = (n2 - 1) / 2;
12007
+ let my = 0;
12008
+ for (const v of y) my += v;
12009
+ my /= n2;
12010
+ let sxy = 0;
12011
+ let sxx = 0;
12012
+ let syy = 0;
12013
+ for (let i2 = 0; i2 < n2; i2++) {
12014
+ const dy = y[i2] - my;
12015
+ sxy += (i2 - mx) * dy;
12016
+ sxx += (i2 - mx) * (i2 - mx);
12017
+ syy += dy * dy;
12018
+ }
12019
+ if (syy === 0 || sxx === 0 || n2 < 3) return { shift: 0, t: 0 };
12020
+ const slope = sxy / sxx;
12021
+ const resid = syy - slope * sxy;
12022
+ const se = Math.sqrt(Math.max(resid, 0) / (n2 - 2) / sxx);
12023
+ let tail = 0;
12024
+ for (let i2 = n2 - hold; i2 < n2; i2++) tail += y[i2];
12025
+ let head = 0;
12026
+ for (let i2 = 0; i2 < n2 - hold; i2++) head += y[i2];
12027
+ const shift3 = Math.abs(tail / hold - head / (n2 - hold)) / Math.sqrt(syy / n2);
12028
+ return { shift: shift3, t: se === 0 ? Number.POSITIVE_INFINITY : Math.abs(slope / se) };
12029
+ }
12030
+ function reportedFor(alpha, beta, shape2) {
12031
+ const key = `${alpha}/${beta}`;
12032
+ let drift;
12033
+ if (beta === LOW) drift = false;
12034
+ else if (ALWAYS_DRIFT.has(key)) drift = true;
12035
+ else if (NEVER_DRIFT.has(key)) drift = false;
12036
+ else drift = shape2.shift <= DRIFT_SHIFT && shape2.t <= DRIFT_T;
12037
+ return { alpha, beta: drift ? LOW : beta, fit: [alpha, beta], drift };
12038
+ }
12039
+
12040
+ // xlsx/formula/functions/ets-search.ts
12041
+ var LOW2 = 1e-3;
12042
+ var MIN_SEARCH_POINTS = 4;
12043
+ var THREE_POINTS = { alpha: 0.1, beta: 0.099, gamma: LOW2, drift: false };
12044
+ var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
12045
+ var SEASON_STEPS = [LOW2, 0.125, 0.25, 0.5, 0.75, 0.9];
12046
+ var SHORT_SERIES = 16;
12047
+ function better(c2, best) {
12048
+ return c2 < best * (1 - 1e-6) && c2 < best - 1e-12;
12049
+ }
12050
+ var SEASONAL_TRIPLES = [
12051
+ [0.126, LOW2, LOW2],
12052
+ [0.251, LOW2, LOW2],
12053
+ [0.501, LOW2, LOW2],
12054
+ [0.751, LOW2, LOW2],
12055
+ [2e-3, LOW2, 0.125],
12056
+ [2e-3, LOW2, 0.25],
12057
+ [2e-3, LOW2, 0.5],
12058
+ [2e-3, LOW2, 0.75],
12059
+ [0.251, LOW2, 0.25],
12060
+ [0.75, LOW2, 0.249],
12061
+ [0.9, LOW2, 0.099],
12062
+ [0.251, 0.25, LOW2],
12063
+ [0.1, LOW2, 0.899],
12064
+ [0.126, 0.125, LOW2],
12065
+ [0.998, 0.099, LOW2],
12066
+ [0.25, LOW2, 0.749],
12067
+ [0.5, LOW2, 0.499],
12068
+ [0.5, 0.25, LOW2],
12069
+ [0.251, 0.25, 0.25],
12070
+ [0.501, 0.5, LOW2]
12071
+ ];
12072
+ var SHORT_EXTRA_TRIPLES = [
12073
+ [1 / 6, 1 / 12, 1 / 12],
12074
+ [1 / 3, 1 / 6, 1 / 6],
12075
+ [1 / 6, 1 / 12, 0.75],
12076
+ [1 / 3, 1 / 6, 0.5],
12077
+ [5 / 6, 1 / 12, 1 / 12]
12078
+ ];
12079
+ function searchSeasonalLattice(cost, extra = []) {
12080
+ let best = { alpha: 0.126, beta: LOW2, gamma: LOW2 };
12081
+ let bestCost = cost(best);
12082
+ for (const [alpha, beta, gamma2] of [...SEASONAL_TRIPLES, ...extra]) {
12083
+ const c2 = cost({ alpha, beta, gamma: gamma2 });
12084
+ if (better(c2, bestCost)) {
12085
+ bestCost = c2;
12086
+ best = { alpha, beta, gamma: gamma2 };
12087
+ }
12088
+ }
12089
+ return { ...best, drift: false };
12090
+ }
12091
+ function searchSeasonal(n2, cost) {
12092
+ let best = { alpha: 0.9, beta: LOW2, gamma: LOW2 };
12093
+ let bestCost = cost(best);
12094
+ for (const a2 of SEASON_ALPHAS)
12095
+ for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW2, a2 - LOW2] : [LOW2])
12096
+ for (const g2 of [...SEASON_STEPS, 1 - a2 - LOW2]) {
12097
+ if (b < LOW2 || g2 > 1 - a2 - LOW2 + 1e-9) continue;
12098
+ const c2 = cost({ alpha: a2, beta: b, gamma: g2 });
12099
+ if (better(c2, bestCost)) {
12100
+ bestCost = c2;
12101
+ best = { alpha: a2, beta: b, gamma: g2 };
12102
+ }
12103
+ }
12104
+ return { ...best, drift: false };
12105
+ }
12106
+ function searchLattice(shape2, cost) {
12107
+ let best = [0.9, LOW2];
12108
+ let bestCost = cost({ alpha: 0.9, beta: LOW2, gamma: LOW2 });
12109
+ for (const [alpha, beta] of CANDIDATES) {
12110
+ const c2 = cost({ alpha, beta, gamma: LOW2 });
12111
+ if (better(c2, bestCost)) {
12112
+ bestCost = c2;
12113
+ best = [alpha, beta];
12114
+ }
12115
+ }
12116
+ const out = reportedFor(best[0], best[1], shape2);
12117
+ const [fa, fb] = out.fit;
12118
+ const same12 = fa === out.alpha && fb === out.beta;
12119
+ return {
12120
+ alpha: out.alpha,
12121
+ beta: out.beta,
12122
+ gamma: LOW2,
12123
+ drift: out.drift,
12124
+ ...same12 ? {} : { fit: { alpha: fa, beta: fb, gamma: LOW2 } }
12125
+ };
12126
+ }
12127
+ function chooseSmoothing(n2, m, cost, shape2 = { shift: 9, t: 99 }) {
12128
+ if (m >= 2 && isShortSeasonLength(n2, m)) return searchSeasonalLattice(cost, SHORT_EXTRA_TRIPLES);
12129
+ if (m >= 2) return isExactLength(n2, m) ? searchSeasonalLattice(cost) : searchSeasonal(n2, cost);
12130
+ if (n2 < MIN_SEARCH_POINTS) return THREE_POINTS;
12131
+ return searchLattice(shape2, cost);
12132
+ }
12133
+
12134
+ // xlsx/formula/functions/ets-validate.ts
12135
+ function etsSearchSeries(y) {
12136
+ const pads = PADS[y.length];
12137
+ if (!pads) return y;
12138
+ const slope = olsSlope(y);
12139
+ return [...y, ...pads.map(([src, lag]) => y[src] + lag * slope)];
12140
+ }
12141
+ function etsValidationCost(y, m, init, p, holdout) {
12142
+ const n2 = y.length;
12143
+ const train = n2 - holdout;
12144
+ let { level: level4, trend } = init;
12145
+ const season = [...init.season];
12146
+ let sse = 0;
12147
+ for (let t = 0; t < train; t++) {
12148
+ const k = m >= 2 ? t % m : 0;
12149
+ const e = y[t] - (level4 + trend + (m >= 2 ? season[k] ?? 0 : 0));
12150
+ sse += e * e;
12151
+ level4 += trend + p.alpha * e;
12152
+ trend += p.beta * e;
12153
+ if (m >= 2) season[k] = (season[k] ?? 0) + p.gamma * e;
12154
+ }
12155
+ for (let j = 1; j <= holdout; j++) {
12156
+ const t = train + j - 1;
12157
+ const e = y[t] - (level4 + j * trend + (m >= 2 ? season[t % m] ?? 0 : 0));
12158
+ sse += e * e;
12159
+ }
12160
+ return sse;
12161
+ }
12162
+
11688
12163
  // xlsx/formula/functions/ets-core.ts
11689
12164
  function etsRun(y, m, init, p) {
11690
12165
  let { level: level4, trend } = init;
@@ -11703,36 +12178,36 @@ function etsRun(y, m, init, p) {
11703
12178
  }
11704
12179
  return { fitted, level: level4, trend, season, sse };
11705
12180
  }
11706
- var LOW = 1e-3;
11707
- var SHORT_SERIES = 16;
11708
12181
  var NO_SEASON_GAMMA = Number.EPSILON;
11709
- var ALPHAS = [2e-3, 0.1, 0.126, 0.25, 0.5, 2 / 3, 0.75, 0.9];
11710
- var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
11711
- var SEASON_STEPS = [LOW, 0.125, 0.25, 0.5, 0.75, 0.9];
11712
12182
  function fitEts(y, seasonLength) {
11713
12183
  const n2 = y.length;
11714
12184
  if (n2 < 2) fail(ERR.NUM);
11715
- const m = seasonLength >= 2 && n2 >= 2 * seasonLength ? seasonLength : 0;
12185
+ const m = seasonLength >= 2 && n2 >= seasonStart(seasonLength) ? seasonLength : 0;
11716
12186
  const solve2 = (p) => {
11717
12187
  const init = initialStates(y, m, p, etsRun);
11718
12188
  return { init, run: etsRun(y, m, init, p) };
11719
12189
  };
11720
- const cost = (v) => solve2({ alpha: v[0], beta: v[1], gamma: v[2] }).run.sse;
11721
- let best = [0.9, LOW, LOW];
11722
- let bestCost = cost(best);
11723
- for (const a2 of m >= 2 ? SEASON_ALPHAS : ALPHAS)
11724
- for (const b of n2 >= 7 && n2 <= SHORT_SERIES ? [LOW, a2 - LOW] : [LOW])
11725
- for (const g2 of m >= 2 ? [...SEASON_STEPS, 1 - a2 - LOW] : [LOW]) {
11726
- if (b < LOW || g2 > 1 - a2 - LOW + 1e-9) continue;
11727
- const c2 = cost([a2, b, g2]);
11728
- if (c2 < bestCost * (1 - 1e-6) && c2 < bestCost - 1e-12) {
11729
- bestCost = c2;
11730
- best = [a2, b, g2];
11731
- }
11732
- }
11733
- const [alpha, beta, gamma2] = best;
11734
- const { run: run2 } = solve2({ alpha, beta, gamma: gamma2 });
11735
- return { alpha, beta, gamma: m >= 2 ? gamma2 : NO_SEASON_GAMMA, m, n: n2, ...run2 };
12190
+ const exact = m < 2 || isExactLength(n2, m);
12191
+ const padded = m >= 2 && exact ? isShortSeasonLength(n2, m) ? shortSearchSeries(y, m) : paddedSearchSeries(y, m) : void 0;
12192
+ const searched = padded ?? (m >= 2 ? y : etsSearchSeries(y));
12193
+ const holdout = m >= 2 && !exact ? 0 : etsHoldout(padded && !(m >= 2 && isShortSeasonLength(n2, m)) ? padded.length : n2, m);
12194
+ const { drift, fit: fit2, ...chosen } = chooseSmoothing(
12195
+ n2,
12196
+ m,
12197
+ (p) => etsValidationCost(searched, m, solve2(p).init, p, holdout),
12198
+ trendShape(y, holdout)
12199
+ );
12200
+ const { run: run2 } = solve2(fit2 ?? chosen);
12201
+ const state = drift ? solve2({ alpha: 1, beta: 0, gamma: chosen.gamma }).run : run2;
12202
+ return {
12203
+ ...chosen,
12204
+ gamma: m >= 2 ? chosen.gamma : NO_SEASON_GAMMA,
12205
+ m,
12206
+ n: n2,
12207
+ ...run2,
12208
+ level: state.level,
12209
+ trend: state.trend
12210
+ };
11736
12211
  }
11737
12212
  function etsHoldout(n2, m) {
11738
12213
  if (n2 < 11) return 0;
@@ -11757,12 +12232,12 @@ function etsErrorSd(fit2, h2) {
11757
12232
  // xlsx/formula/functions/ets-season.ts
11758
12233
  var MAX_POINTS = 8192;
11759
12234
  var MIN_CYCLES = 3;
11760
- var MIN_SHARE = 0.3;
11761
- var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
12235
+ var MIN_ACF = 0.3;
12236
+ var mean8 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
11762
12237
  function detrend(y) {
11763
12238
  const n2 = y.length;
11764
12239
  const mx = (n2 - 1) / 2;
11765
- const my = mean3(y);
12240
+ const my = mean8(y);
11766
12241
  let sxy = 0;
11767
12242
  let sxx = 0;
11768
12243
  for (let i2 = 0; i2 < n2; i2++) {
@@ -11779,34 +12254,23 @@ function detectSeasonality(series) {
11779
12254
  const r = detrend(y);
11780
12255
  const scale2 = Math.max(...y.map(Math.abs), 1);
11781
12256
  if (r.every((v) => Math.abs(v) <= 1e-12 * scale2)) return 0;
11782
- const cos2 = new Float64Array(n2);
11783
- const sin2 = new Float64Array(n2);
11784
- for (let j = 0; j < n2; j++) {
11785
- cos2[j] = Math.cos(2 * Math.PI * j / n2);
11786
- sin2[j] = Math.sin(2 * Math.PI * j / n2);
11787
- }
11788
- let total2 = 0;
11789
- let best = 0;
11790
- let bestK = 0;
11791
- for (let k = 1; k <= Math.floor(n2 / 2); k++) {
11792
- let re = 0;
11793
- let im = 0;
11794
- for (let t = 0; t < n2; t++) {
11795
- const j = k * t % n2;
11796
- const v = r[t];
11797
- re += v * cos2[j];
11798
- im -= v * sin2[j];
11799
- }
11800
- const power2 = re * re + im * im;
11801
- total2 += power2;
11802
- if (k >= MIN_CYCLES && power2 > best) {
11803
- best = power2;
11804
- bestK = k;
11805
- }
12257
+ const maxLag = Math.floor(n2 / MIN_CYCLES);
12258
+ let energy = 0;
12259
+ for (const v of r) energy += v * v;
12260
+ const acf = (lag) => {
12261
+ let s = 0;
12262
+ for (let t = 0; t + lag < n2; t++) s += r[t] * r[t + lag];
12263
+ return s / energy;
12264
+ };
12265
+ let prev = acf(1);
12266
+ let cur = acf(2);
12267
+ for (let lag = 2; lag <= maxLag; lag++) {
12268
+ const next = acf(lag + 1);
12269
+ if (cur >= prev && cur >= next && cur >= MIN_ACF) return lag;
12270
+ prev = cur;
12271
+ cur = next;
11806
12272
  }
11807
- if (bestK === 0 || !(best / total2 >= MIN_SHARE)) return 0;
11808
- const period = Math.round(n2 / bestK);
11809
- return period >= 2 ? period : 0;
12273
+ return 0;
11810
12274
  }
11811
12275
 
11812
12276
  // xlsx/formula/functions/ets-grid.ts
@@ -11878,9 +12342,9 @@ function aggregate2(code, xs) {
11878
12342
  case 4:
11879
12343
  return Math.max(...xs);
11880
12344
  case 5:
11881
- return Math.min(...xs);
11882
- case 6:
11883
12345
  return median2(xs);
12346
+ case 6:
12347
+ return Math.min(...xs);
11884
12348
  default:
11885
12349
  return xs.reduce((a2, b) => a2 + b, 0);
11886
12350
  }
@@ -14422,10 +14886,10 @@ function mergeMessageModules(modules) {
14422
14886
  // i18n/translator.ts
14423
14887
  var SINGLE2 = /\{(\w+)\}/g;
14424
14888
  var DOUBLE = /\{\{\s*(\w+)\s*\}\}/g;
14425
- function interpolate(template, params, placeholder2 = "single") {
14426
- if (!params) return template;
14889
+ function interpolate(template2, params, placeholder2 = "single") {
14890
+ if (!params) return template2;
14427
14891
  const pattern = placeholder2 === "double" ? DOUBLE : SINGLE2;
14428
- return template.replace(
14892
+ return template2.replace(
14429
14893
  pattern,
14430
14894
  (match2, name) => Object.prototype.hasOwnProperty.call(params, name) && params[name] !== void 0 ? String(params[name]) : match2
14431
14895
  );
@@ -14858,7 +15322,7 @@ var ENGLISH_PIVOT_CAPTIONS = {
14858
15322
  functions: FUNCTIONS,
14859
15323
  aggregates: aggregateNames()
14860
15324
  };
14861
- var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
15325
+ var fillCaption = (template2, ...args) => template2.replace(/\{(\d)\}/g, (_match, at2) => args[Number(at2)] ?? "");
14862
15326
  function pivotCaptions(pivot) {
14863
15327
  const own = pivot.captions;
14864
15328
  if (!own) return ENGLISH_PIVOT_CAPTIONS;
@@ -15569,8 +16033,8 @@ var DIV0 = { error: "#DIV/0!" };
15569
16033
  function variance2(numbers3, sample) {
15570
16034
  const n2 = numbers3.length;
15571
16035
  if (n2 < (sample ? 2 : 1)) return DIV0;
15572
- const mean4 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n2;
15573
- const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean4) ** 2, 0);
16036
+ const mean9 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n2;
16037
+ const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean9) ** 2, 0);
15574
16038
  return squares / (sample ? n2 - 1 : n2);
15575
16039
  }
15576
16040
  function aggregateValues(records, field, type) {
@@ -17235,11 +17699,11 @@ var ParseCache = class {
17235
17699
  parseNew(formula2) {
17236
17700
  if (formula2.length > MAX_TEMPLATE_LENGTH) return treeOf(makeTemplate(formula2, NO_RUNS));
17237
17701
  const shape2 = formulaShape(formula2);
17238
- const template = this.templates.get(shape2.hash);
17239
- const reused = template && fromTemplate(template, formula2, shape2);
17702
+ const template2 = this.templates.get(shape2.hash);
17703
+ const reused = template2 && fromTemplate(template2, formula2, shape2);
17240
17704
  if (reused) return reused;
17241
17705
  const made = makeTemplate(formula2, shape2);
17242
- if (!template && "ast" in made) {
17706
+ if (!template2 && "ast" in made) {
17243
17707
  if (this.templates.size > MAX_TEMPLATES) this.templates.clear();
17244
17708
  this.templates.set(shape2.hash, made);
17245
17709
  }
@@ -17957,22 +18421,22 @@ function astTraits(ast) {
17957
18421
  traitsCache.set(ast, traits);
17958
18422
  return traits;
17959
18423
  }
17960
- function intervalDelta(a2, b, shift2) {
17961
- const { at: at2, count: count2 } = shift2;
18424
+ function intervalDelta(a2, b, shift3) {
18425
+ const { at: at2, count: count2 } = shift3;
17962
18426
  if (count2 > 0) {
17963
18427
  if (b < at2) return 0;
17964
18428
  if (a2 < at2) return void 0;
17965
- return b + count2 > (shift2.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
18429
+ return b + count2 > (shift3.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count2;
17966
18430
  }
17967
18431
  const last = at2 - count2 - 1;
17968
18432
  if (b < at2) return 0;
17969
18433
  if (a2 > last) return count2;
17970
18434
  return void 0;
17971
18435
  }
17972
- function areaDelta(area, sheet, shift2) {
18436
+ function areaDelta(area, sheet, shift3) {
17973
18437
  if (area.sheet !== sheet) return 0;
17974
18438
  const { start, end } = area.range;
17975
- return shift2.axis === "row" ? intervalDelta(start.row, end.row, shift2) : intervalDelta(start.col, end.col, shift2);
18439
+ return shift3.axis === "row" ? intervalDelta(start.row, end.row, shift3) : intervalDelta(start.col, end.col, shift3);
17976
18440
  }
17977
18441
  function movedRange(range2, axis, delta) {
17978
18442
  if (delta === 0) return range2;
@@ -17984,10 +18448,10 @@ function movedRange(range2, axis, delta) {
17984
18448
  end: { row: range2.end.row, col: range2.end.col + delta }
17985
18449
  };
17986
18450
  }
17987
- function reachesEdit(areas, sheet, shift2) {
18451
+ function reachesEdit(areas, sheet, shift3) {
17988
18452
  for (const area of areas) {
17989
18453
  if (area.sheet !== sheet) continue;
17990
- if ((shift2.axis === "row" ? area.range.end.row : area.range.end.col) >= shift2.at) return true;
18454
+ if ((shift3.axis === "row" ? area.range.end.row : area.range.end.col) >= shift3.at) return true;
17991
18455
  }
17992
18456
  return false;
17993
18457
  }
@@ -18036,8 +18500,8 @@ var EngineStructure = class extends EngineCore {
18036
18500
  * changed (cells moved, formulas rewritten). Spills on the sheet, array formulas the edit cuts
18037
18501
  * and anything unexpected fall back to a rebuild on the next recalculation.
18038
18502
  */
18039
- shiftCells(sheet, shift2) {
18040
- if (!this.graphReady() || !this.shiftable(sheet, shift2)) {
18503
+ shiftCells(sheet, shift3) {
18504
+ if (!this.graphReady() || !this.shiftable(sheet, shift3)) {
18041
18505
  this.invalidate();
18042
18506
  return;
18043
18507
  }
@@ -18048,15 +18512,15 @@ var EngineStructure = class extends EngineCore {
18048
18512
  if (own) {
18049
18513
  const next = /* @__PURE__ */ new Map();
18050
18514
  for (const node2 of own.values()) {
18051
- const pos = shift2.axis === "row" ? node2.row : node2.col;
18052
- const delta = intervalDelta(pos, pos, shift2);
18515
+ const pos = shift3.axis === "row" ? node2.row : node2.col;
18516
+ const delta = intervalDelta(pos, pos, shift3);
18053
18517
  if (delta === void 0) {
18054
18518
  this.dropNode(node2);
18055
18519
  continue;
18056
18520
  }
18057
18521
  if (delta !== 0) {
18058
18522
  moved.set(node2, delta);
18059
- if (shift2.axis === "row") node2.row += delta;
18523
+ if (shift3.axis === "row") node2.row += delta;
18060
18524
  else node2.col += delta;
18061
18525
  }
18062
18526
  next.set(cellKey(node2.row, node2.col), node2);
@@ -18065,7 +18529,7 @@ var EngineStructure = class extends EngineCore {
18065
18529
  }
18066
18530
  for (const map of this.nodes.values())
18067
18531
  for (const node2 of map.values()) {
18068
- if (!this.shiftNode(node2, sheet, shift2, moved.get(node2) ?? 0)) {
18532
+ if (!this.shiftNode(node2, sheet, shift3, moved.get(node2) ?? 0)) {
18069
18533
  this.invalidate();
18070
18534
  return;
18071
18535
  }
@@ -18074,11 +18538,11 @@ var EngineStructure = class extends EngineCore {
18074
18538
  this.graphChanged();
18075
18539
  }
18076
18540
  /** No spill or stale spilled value on the sheet, and no array formula the edit cuts. */
18077
- shiftable(sheet, shift2) {
18541
+ shiftable(sheet, shift3) {
18078
18542
  for (const node2 of this.footprints) {
18079
18543
  if (node2.sheet !== sheet) continue;
18080
18544
  if (node2.spill || node2.blockedSpill) return false;
18081
- if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift2) === void 0)
18545
+ if (node2.arrayRange && areaDelta({ sheet, range: node2.arrayRange }, sheet, shift3) === void 0)
18082
18546
  return false;
18083
18547
  }
18084
18548
  const ws = this.workbook.sheets[sheet];
@@ -18094,19 +18558,19 @@ var EngineStructure = class extends EngineCore {
18094
18558
  this.footprints.delete(node2);
18095
18559
  }
18096
18560
  /** Updates one formula for the edit; false when the graph cannot follow it. */
18097
- shiftNode(node2, sheet, shift2, nodeDelta) {
18561
+ shiftNode(node2, sheet, shift3, nodeDelta) {
18098
18562
  const cell = this.workbook.sheets[node2.sheet]?.rows.get(node2.row)?.get(node2.col);
18099
18563
  if (cell?.formula === void 0) return false;
18100
18564
  if (node2.arrayRange) {
18101
- const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift2);
18565
+ const delta = areaDelta({ sheet: node2.sheet, range: node2.arrayRange }, sheet, shift3);
18102
18566
  if (delta === void 0) return false;
18103
- node2.arrayRange = movedRange(node2.arrayRange, shift2.axis, delta);
18567
+ node2.arrayRange = movedRange(node2.arrayRange, shift3.axis, delta);
18104
18568
  if (!cell.arrayRange || !sameRange(node2.arrayRange, normalizeRange(cell.arrayRange)))
18105
18569
  return false;
18106
18570
  }
18107
18571
  const changed = cell.formula !== node2.formula;
18108
18572
  const traits = node2.ast && astTraits(node2.ast);
18109
- const reached = reachesEdit(node2.deps, sheet, shift2) || reachesEdit(node2.dynamicDeps, sheet, shift2);
18573
+ const reached = reachesEdit(node2.deps, sheet, shift3) || reachesEdit(node2.dynamicDeps, sheet, shift3);
18110
18574
  if (!changed && !reached && nodeDelta === 0 && !traits?.descriptive && !traits?.opaque)
18111
18575
  return true;
18112
18576
  if (traits?.complex) {
@@ -18115,10 +18579,10 @@ var EngineStructure = class extends EngineCore {
18115
18579
  this.structuralSeeds.add(node2);
18116
18580
  return true;
18117
18581
  }
18118
- const pos = shift2.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
18582
+ const pos = shift3.axis === "row" ? node2.row - nodeDelta : node2.col - nodeDelta;
18119
18583
  const moves = { seed: !!traits?.descriptive, moved: false, cut: false };
18120
- const deps = this.moveAreas(node2.deps, sheet, shift2, pos, nodeDelta, moves);
18121
- const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift2, pos, nodeDelta, moves);
18584
+ const deps = this.moveAreas(node2.deps, sheet, shift3, pos, nodeDelta, moves);
18585
+ const dynamicDeps = this.moveAreas(node2.dynamicDeps, sheet, shift3, pos, nodeDelta, moves);
18122
18586
  const { cut, moved: anyMoved } = moves;
18123
18587
  let seed = moves.seed;
18124
18588
  if (cut || changed !== anyMoved) {
@@ -18142,20 +18606,20 @@ var EngineStructure = class extends EngineCore {
18142
18606
  * moved, one was cut (deleted, widened, pushed off the grid) and whether implicit intersection
18143
18607
  * with one can now pick another cell.
18144
18608
  */
18145
- moveAreas(list2, sheet, shift2, pos, nodeDelta, moves) {
18609
+ moveAreas(list2, sheet, shift3, pos, nodeDelta, moves) {
18146
18610
  let out;
18147
18611
  for (let i2 = 0; i2 < list2.length; i2++) {
18148
18612
  const area = list2[i2];
18149
- const delta = areaDelta(area, sheet, shift2);
18613
+ const delta = areaDelta(area, sheet, shift3);
18150
18614
  if (delta === void 0) {
18151
18615
  moves.cut = true;
18152
18616
  continue;
18153
18617
  }
18154
- if (intersectionMoves(area, delta, pos, nodeDelta, shift2.axis)) moves.seed = true;
18618
+ if (intersectionMoves(area, delta, pos, nodeDelta, shift3.axis)) moves.seed = true;
18155
18619
  if (delta === 0) continue;
18156
18620
  moves.moved = true;
18157
18621
  out ??= list2.slice();
18158
- out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift2.axis, delta) };
18622
+ out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift3.axis, delta) };
18159
18623
  }
18160
18624
  return out ?? list2;
18161
18625
  }
@@ -18467,9 +18931,9 @@ function prefixText(prefix) {
18467
18931
  // xlsx/formula/shift-formula.ts
18468
18932
  var templates = /* @__PURE__ */ new Map();
18469
18933
  var MAX_TEMPLATES2 = 2e5;
18470
- function remember(text3, template) {
18934
+ function remember(text3, template2) {
18471
18935
  if (templates.size >= MAX_TEMPLATES2) templates.clear();
18472
- templates.set(text3, template);
18936
+ templates.set(text3, template2);
18473
18937
  }
18474
18938
  function mergeSpacedAreas(tokens2) {
18475
18939
  const out = [];
@@ -18500,16 +18964,16 @@ function templateOf(formula2) {
18500
18964
  const cached = templates.get(formula2);
18501
18965
  if (cached !== void 0) return cached;
18502
18966
  const raw2 = safeTokens(formula2);
18503
- let template = null;
18967
+ let template2 = null;
18504
18968
  if (raw2) {
18505
- template = [];
18969
+ template2 = [];
18506
18970
  let literal3 = "";
18507
18971
  for (const token2 of mergeSpacedAreas(raw2)) {
18508
18972
  if (token2.kind !== "ref" && !(token2.kind === "name" && token2.prefix)) {
18509
18973
  literal3 += token2.text;
18510
18974
  continue;
18511
18975
  }
18512
- if (literal3) template.push(literal3);
18976
+ if (literal3) template2.push(literal3);
18513
18977
  literal3 = "";
18514
18978
  const part = { kind: token2.kind, text: token2.text };
18515
18979
  if (token2.prefix) {
@@ -18518,23 +18982,23 @@ function templateOf(formula2) {
18518
18982
  }
18519
18983
  if (token2.ref) part.ref = token2.ref;
18520
18984
  if (token2.spill) part.spill = true;
18521
- template.push(part);
18985
+ template2.push(part);
18522
18986
  }
18523
- if (literal3) template.push(literal3);
18987
+ if (literal3) template2.push(literal3);
18524
18988
  }
18525
- remember(formula2, template);
18526
- return template;
18989
+ remember(formula2, template2);
18990
+ return template2;
18527
18991
  }
18528
18992
  function rewriteTemplate(formula2, rewrite2) {
18529
- const template = templateOf(formula2);
18530
- if (!template) return formula2;
18993
+ const template2 = templateOf(formula2);
18994
+ if (!template2) return formula2;
18531
18995
  let next;
18532
- for (let i2 = 0; i2 < template.length; i2++) {
18533
- const part = template[i2];
18996
+ for (let i2 = 0; i2 < template2.length; i2++) {
18997
+ const part = template2[i2];
18534
18998
  if (typeof part === "string") continue;
18535
18999
  const changed = rewrite2(part);
18536
19000
  if (!changed) continue;
18537
- next ??= template.slice();
19001
+ next ??= template2.slice();
18538
19002
  next[i2] = changed;
18539
19003
  }
18540
19004
  if (!next) return formula2;
@@ -19972,9 +20436,9 @@ function aggregateCaptionsOf(pivot) {
19972
20436
  ]) {
19973
20437
  const at2 = measure5.caption.indexOf(measure5.field);
19974
20438
  if (at2 < 0 || measure5.caption === measure5.field) continue;
19975
- const template = `${measure5.caption.slice(0, at2)}{0}${measure5.caption.slice(at2 + measure5.field.length)}`;
19976
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure5.aggregate])
19977
- out[measure5.aggregate] = template;
20439
+ const template2 = `${measure5.caption.slice(0, at2)}{0}${measure5.caption.slice(at2 + measure5.field.length)}`;
20440
+ if (template2 !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure5.aggregate])
20441
+ out[measure5.aggregate] = template2;
19978
20442
  }
19979
20443
  return Object.keys(out).length ? out : void 0;
19980
20444
  }
@@ -30481,7 +30945,8 @@ var pie = {
30481
30945
  gd16("stAng", "pin 0 adj1 21599999"),
30482
30946
  gd16("endAng", "pin 0 adj2 21599999"),
30483
30947
  gd16("swAng", "+- endAng 0 stAng"),
30484
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30948
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30949
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30485
30950
  gd16("stx", "cos wd2 stAng"),
30486
30951
  gd16("sty", "sin hd2 stAng"),
30487
30952
  gd16("x1", "+- hc stx 0"),
@@ -30526,7 +30991,8 @@ var chord = {
30526
30991
  gd16("stAng", "pin 0 adj1 21599999"),
30527
30992
  gd16("endAng", "pin 0 adj2 21599999"),
30528
30993
  gd16("swAng", "+- endAng 0 stAng"),
30529
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
30994
+ gd16("swAngWrap", "+- swAng 21600000 0"),
30995
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30530
30996
  gd16("stx", "cos wd2 stAng"),
30531
30997
  gd16("sty", "sin hd2 stAng"),
30532
30998
  gd16("x1", "+- hc stx 0"),
@@ -30550,7 +31016,8 @@ var arc = {
30550
31016
  gd16("stAng", "pin 0 adj1 21599999"),
30551
31017
  gd16("endAng", "pin 0 adj2 21599999"),
30552
31018
  gd16("swAng", "+- endAng 0 stAng"),
30553
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31019
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31020
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30554
31021
  gd16("stx", "cos wd2 stAng"),
30555
31022
  gd16("sty", "sin hd2 stAng"),
30556
31023
  gd16("x1", "+- hc stx 0"),
@@ -30645,7 +31112,8 @@ var blockArc = {
30645
31112
  gd16("iwd2", "+- wd2 0 thw"),
30646
31113
  gd16("ihd2", "+- hd2 0 thh2"),
30647
31114
  gd16("swAng", "+- endAng 0 stAng"),
30648
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
31115
+ gd16("swAngWrap", "+- swAng 21600000 0"),
31116
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
30649
31117
  gd16("mswAng", "+- 0 0 swAng2"),
30650
31118
  gd16("stx", "cos wd2 stAng"),
30651
31119
  gd16("sty", "sin hd2 stAng"),
@@ -38770,8 +39238,8 @@ function writeDiagramFormatDefinition(source3, change) {
38770
39238
  (entry3) => entry3.id === change.value
38771
39239
  ))
38772
39240
  throw new RangeError("Unknown SmartArt format preset.");
38773
- const template = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
38774
- const fresh = parseXml(template).documentElement;
39241
+ const template2 = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
39242
+ const fresh = parseXml(template2).documentElement;
38775
39243
  if (!source3) {
38776
39244
  fresh.setAttribute("uniqueId", `urn:ooxml-core/${change.kind}/${change.value}`);
38777
39245
  return buildXml(fresh);
@@ -40653,8 +41121,8 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40653
41121
  );
40654
41122
  const direct = model2.nodes.find((node2) => node2.modelId === shape2.sourceNodeId);
40655
41123
  const fillIndex = shape2.style?.fill?.index;
40656
- const template = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
40657
- if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template || template.kind === "solid" && template.color.kind === "scheme" && template.color.value === "phClr")) {
41124
+ const template2 = fillIndex ? input.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
41125
+ if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template2 || template2.kind === "solid" && template2.color.kind === "scheme" && template2.color.value === "phClr")) {
40658
41126
  const original = themed.get(`#${shape2.fill.color.value}`.toUpperCase());
40659
41127
  if (original)
40660
41128
  shape2.fill.color = {
@@ -40662,9 +41130,9 @@ function buildGeneratedDiagramCache(dataXml2, input) {
40662
41130
  transforms: [...original.transforms, ...shape2.fill.color.transforms]
40663
41131
  };
40664
41132
  }
40665
- if (!direct?.fill && shape2.fill?.kind === "gradient" && template?.kind === "gradient") {
41133
+ if (!direct?.fill && shape2.fill?.kind === "gradient" && template2?.kind === "gradient") {
40666
41134
  shape2.fill.stops.forEach((stop, index3) => {
40667
- const authored = template.stops[index3]?.color;
41135
+ const authored = template2.stops[index3]?.color;
40668
41136
  if (authored?.kind === "scheme" && authored.value === "phClr" && stop.color.kind === "srgb") {
40669
41137
  const original = themed.get(`#${stop.color.value}`.toUpperCase());
40670
41138
  if (original)
@@ -45864,7 +46332,12 @@ function vmlCaption(vml, shapeId) {
45864
46332
  const shape2 = vml.slice(start, end < 0 ? void 0 : end);
45865
46333
  const box2 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape2)?.[1];
45866
46334
  if (!box2) return void 0;
45867
- const text3 = box2.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
46335
+ let stripped = box2.replace(/<br\s*\/?>/gi, "\n");
46336
+ for (let prev = ""; prev !== stripped; ) {
46337
+ prev = stripped;
46338
+ stripped = stripped.replace(/<[^>]*>/g, "");
46339
+ }
46340
+ const text3 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
45868
46341
  if (code.startsWith("#")) {
45869
46342
  const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
45870
46343
  return Number.isFinite(value3) ? String.fromCodePoint(value3) : match2;
@@ -49101,12 +49574,12 @@ function reanchor(xml, anchor) {
49101
49574
  ).documentElement;
49102
49575
  for (const candidate of Array.from(holder.childNodes)) {
49103
49576
  if (candidate.nodeType !== 1) continue;
49104
- const template = candidate;
49105
- const original = first(old, template.localName, NS.xdr);
49106
- const position = original ? original.cloneNode(true) : doc.importNode(template, true);
49107
- for (const attribute2 of Array.from(template.attributes))
49577
+ const template2 = candidate;
49578
+ const original = first(old, template2.localName, NS.xdr);
49579
+ const position = original ? original.cloneNode(true) : doc.importNode(template2, true);
49580
+ for (const attribute2 of Array.from(template2.attributes))
49108
49581
  position.setAttribute(attribute2.name, attribute2.value);
49109
- for (const value3 of Array.from(template.childNodes)) {
49582
+ for (const value3 of Array.from(template2.childNodes)) {
49110
49583
  if (value3.nodeType !== 1) continue;
49111
49584
  const item2 = value3;
49112
49585
  const existing = first(position, item2.localName, NS.xdr);
@@ -49309,9 +49782,9 @@ function writeDrawing(writer, partName, objects, sourceDrawing, context) {
49309
49782
 
49310
49783
  // xlsx/edit/range-math.ts
49311
49784
  var axisMax = (axis) => axis === "row" ? MAX_ROW : MAX_COL;
49312
- function shiftSpan(start, end, shift2) {
49313
- const { at: at2, count: count2 } = shift2;
49314
- const max = axisMax(shift2.axis);
49785
+ function shiftSpan(start, end, shift3) {
49786
+ const { at: at2, count: count2 } = shift3;
49787
+ const max = axisMax(shift3.axis);
49315
49788
  if (count2 > 0) {
49316
49789
  if (start >= at2) {
49317
49790
  if (start + count2 > max) return void 0;
@@ -49327,35 +49800,35 @@ function shiftSpan(start, end, shift2) {
49327
49800
  const e = end >= max ? max : end < at2 ? end : end > last ? end - n2 : at2 - 1;
49328
49801
  return s > e ? void 0 : { start: s, end: e };
49329
49802
  }
49330
- function shiftIndex(index3, shift2) {
49331
- const { at: at2, count: count2 } = shift2;
49803
+ function shiftIndex(index3, shift3) {
49804
+ const { at: at2, count: count2 } = shift3;
49332
49805
  if (index3 < at2) return index3;
49333
- if (count2 > 0) return index3 + count2 > axisMax(shift2.axis) ? void 0 : index3 + count2;
49806
+ if (count2 > 0) return index3 + count2 > axisMax(shift3.axis) ? void 0 : index3 + count2;
49334
49807
  return index3 < at2 - count2 ? void 0 : index3 + count2;
49335
49808
  }
49336
- function shiftIndexClamped(index3, shift2) {
49337
- const moved = shiftIndex(index3, shift2);
49809
+ function shiftIndexClamped(index3, shift3) {
49810
+ const moved = shiftIndex(index3, shift3);
49338
49811
  if (moved !== void 0) return moved;
49339
- return shift2.count > 0 ? axisMax(shift2.axis) : shift2.at;
49812
+ return shift3.count > 0 ? axisMax(shift3.axis) : shift3.at;
49340
49813
  }
49341
- function shiftRange(range2, shift2) {
49342
- if (shift2.axis === "row") {
49343
- const span6 = shiftSpan(range2.start.row, range2.end.row, shift2);
49814
+ function shiftRange(range2, shift3) {
49815
+ if (shift3.axis === "row") {
49816
+ const span6 = shiftSpan(range2.start.row, range2.end.row, shift3);
49344
49817
  return span6 && {
49345
49818
  start: { row: span6.start, col: range2.start.col },
49346
49819
  end: { row: span6.end, col: range2.end.col }
49347
49820
  };
49348
49821
  }
49349
- const span5 = shiftSpan(range2.start.col, range2.end.col, shift2);
49822
+ const span5 = shiftSpan(range2.start.col, range2.end.col, shift3);
49350
49823
  return span5 && {
49351
49824
  start: { row: range2.start.row, col: span5.start },
49352
49825
  end: { row: range2.end.row, col: span5.end }
49353
49826
  };
49354
49827
  }
49355
- function shiftRangeInBand(range2, shift2, lo, hi) {
49356
- const other = shift2.axis === "row" ? "col" : "row";
49828
+ function shiftRangeInBand(range2, shift3, lo, hi) {
49829
+ const other = shift3.axis === "row" ? "col" : "row";
49357
49830
  if (range2.end[other] < lo || range2.start[other] > hi) return range2;
49358
- if (range2.start[other] >= lo && range2.end[other] <= hi) return shiftRange(range2, shift2);
49831
+ if (range2.start[other] >= lo && range2.end[other] <= hi) return shiftRange(range2, shift3);
49359
49832
  return range2;
49360
49833
  }
49361
49834
  function subtractRange(a2, b) {
@@ -49386,7 +49859,7 @@ function pointsAt(token2, formulaSheet, sheet) {
49386
49859
  if (!prefix) return formulaSheet.toLowerCase() === sheet.toLowerCase();
49387
49860
  return prefix.book === void 0 && prefix.sheet2 === void 0 && prefix.sheet.toLowerCase() === sheet.toLowerCase();
49388
49861
  }
49389
- function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
49862
+ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, band) {
49390
49863
  let tokens2;
49391
49864
  try {
49392
49865
  tokens2 = tokenize(formula2);
@@ -49407,7 +49880,7 @@ function shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, band) {
49407
49880
  },
49408
49881
  end: { row: Math.max(ref.start.row, ref.end.row), col: Math.max(ref.start.col, ref.end.col) }
49409
49882
  };
49410
- const moved = shiftRangeInBand(range2, shift2, band.lo, band.hi);
49883
+ const moved = shiftRangeInBand(range2, shift3, band.lo, band.hi);
49411
49884
  if (moved && sameRange2(moved, range2)) continue;
49412
49885
  const prefix = token2.prefix?.text ?? "";
49413
49886
  if (!moved) {
@@ -49445,15 +49918,15 @@ function carriedRefEdits(sourceSheets, currentSheets, shiftsOf = () => []) {
49445
49918
  edits.deleted.push(source3.name);
49446
49919
  continue;
49447
49920
  }
49448
- for (const shift2 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift2 });
49921
+ for (const shift3 of shiftsOf(current)) edits.shifts.push({ sheet: source3.name, shift: shift3 });
49449
49922
  if (current.name !== source3.name) edits.renamed.push([source3.name, current.name]);
49450
49923
  }
49451
49924
  return edits;
49452
49925
  }
49453
49926
  var hasCarriedRefEdits = (edits) => edits.shifts.length > 0 || edits.deleted.length > 0 || edits.renamed.length > 0;
49454
- function shiftOne(formula2, formulaSheet, sheet, shift2) {
49455
- if (shift2.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift2, shift2.band);
49456
- const spec2 = { sheet, axis: shift2.axis, at: shift2.at, count: shift2.count };
49927
+ function shiftOne(formula2, formulaSheet, sheet, shift3) {
49928
+ if (shift3.band) return shiftFormulaInBand(formula2, formulaSheet, sheet, shift3, shift3.band);
49929
+ const spec2 = { sheet, axis: shift3.axis, at: shift3.at, count: shift3.count };
49457
49930
  return shiftFormula(formula2, formulaSheet, spec2);
49458
49931
  }
49459
49932
  function renameAll(formula2, renamed, taken) {
@@ -49476,7 +49949,7 @@ var takenNames = (edits) => new Set(
49476
49949
  );
49477
49950
  function patchCarriedFormula(formula2, formulaSheet, edits) {
49478
49951
  let out = formula2;
49479
- for (const { sheet, shift: shift2 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift2);
49952
+ for (const { sheet, shift: shift3 } of edits.shifts) out = shiftOne(out, formulaSheet, sheet, shift3);
49480
49953
  for (const sheet of edits.deleted) out = deleteSheetInFormula(out, sheet);
49481
49954
  return renameAll(out, edits.renamed, takenNames(edits));
49482
49955
  }
@@ -51251,7 +51724,7 @@ function addChartSeries(space, input) {
51251
51724
  const group2 = groups.find((_, i2) => i2 === (input.groupIndex ?? groups.length - 1));
51252
51725
  if (!group2) throw new RangeError("The chart has no chart group to add a series to");
51253
51726
  const all2 = chartSpaceSeries(draft);
51254
- const template = all2[0];
51727
+ const template2 = all2[0];
51255
51728
  const series = {
51256
51729
  index: nextNumber(all2.map((item2) => item2.index)),
51257
51730
  order: nextNumber(all2.map((item2) => item2.order)),
@@ -51268,7 +51741,7 @@ function addChartSeries(space, input) {
51268
51741
  };
51269
51742
  else if (input.name !== void 0) series.tx = { value: input.name, text: input.name };
51270
51743
  if (input.spPr) series.spPr = structuredClone(input.spPr);
51271
- const templateCategories = template?.categories ?? template?.xValues;
51744
+ const templateCategories = template2?.categories ?? template2?.xValues;
51272
51745
  if (input.categories !== void 0)
51273
51746
  series[categoryKey(group2)] = categorySource(
51274
51747
  input.categories,
@@ -53314,8 +53787,8 @@ async function saveXlsx(workbook) {
53314
53787
 
53315
53788
  // xlsx/edit/shift-preserved.ts
53316
53789
  var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
53317
- function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53318
- const keys = banded ? ["extLst"] : [shift2.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
53790
+ function hasPreservedOverflow(sheet, shift3, clipped, banded) {
53791
+ const keys = banded ? ["extLst"] : [shift3.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
53319
53792
  for (const key of keys)
53320
53793
  for (const xml of sheet.preserved.get(key) ?? []) {
53321
53794
  if (!xml.includes(key === "extLst" ? "sqref" : "brk")) continue;
@@ -53331,7 +53804,7 @@ function hasPreservedOverflow(sheet, shift2, clipped, banded) {
53331
53804
  ))
53332
53805
  return true;
53333
53806
  } else if (elements(root).some(
53334
- (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift2) === void 0
53807
+ (node2) => node2.localName === "brk" && shiftIndex(Number(node2.getAttribute("id") ?? "0"), shift3) === void 0
53335
53808
  ))
53336
53809
  return true;
53337
53810
  }
@@ -53363,11 +53836,11 @@ function editEntries(sheet, key, edit, quick) {
53363
53836
  if (next.length) sheet.preserved.set(key, next);
53364
53837
  else sheet.preserved.delete(key);
53365
53838
  }
53366
- function shiftBreaks(root, shift2) {
53839
+ function shiftBreaks(root, shift3) {
53367
53840
  let changed = false;
53368
53841
  for (const brk of elements(root).filter((e) => e.localName === "brk")) {
53369
53842
  const id = Number(brk.getAttribute("id") ?? "0");
53370
- const moved = shiftIndex(id, shift2);
53843
+ const moved = shiftIndex(id, shift3);
53371
53844
  if (moved === id) continue;
53372
53845
  changed = true;
53373
53846
  if (moved === void 0 || moved === 0) root.removeChild(brk);
@@ -53412,12 +53885,12 @@ function shiftSqrefs(root, moveRange) {
53412
53885
  list2.setAttribute("count", String(elements(list2).length));
53413
53886
  return elements(root).length > 0 ? "changed" : "drop";
53414
53887
  }
53415
- function shiftPreservedXml(sheet, shift2, moveRange, banded) {
53888
+ function shiftPreservedXml(sheet, shift3, moveRange, banded) {
53416
53889
  if (!banded)
53417
53890
  editEntries(
53418
53891
  sheet,
53419
- shift2.axis === "row" ? "rowBreaks" : "colBreaks",
53420
- (root) => shiftBreaks(root, shift2),
53892
+ shift3.axis === "row" ? "rowBreaks" : "colBreaks",
53893
+ (root) => shiftBreaks(root, shift3),
53421
53894
  (xml) => xml.includes("brk")
53422
53895
  );
53423
53896
  editEntries(
@@ -54572,25 +55045,25 @@ function setBorders(ctx, s, range2, preset, edge2 = { style: "thin" }) {
54572
55045
  }
54573
55046
 
54574
55047
  // xlsx/edit/insert-guard.ts
54575
- function assertInsertFits(sheet, shift2, band) {
55048
+ function assertInsertFits(sheet, shift3, band) {
54576
55049
  for (const pivot of sheet.pivotTables ?? []) {
54577
- const start = pivot.location.start[shift2.axis];
54578
- const end = pivot.location.end[shift2.axis];
54579
- const other2 = shift2.axis === "row" ? "col" : "row";
55050
+ const start = pivot.location.start[shift3.axis];
55051
+ const end = pivot.location.end[shift3.axis];
55052
+ const other2 = shift3.axis === "row" ? "col" : "row";
54580
55053
  if (band && (band.hi < pivot.location.start[other2] || band.lo > pivot.location.end[other2]))
54581
55054
  continue;
54582
55055
  const partial = band && (band.lo > pivot.location.start[other2] || band.hi < pivot.location.end[other2]);
54583
- const overlap = shift2.count > 0 ? shift2.at > start && shift2.at <= end : shift2.at <= end && shift2.at - shift2.count > start;
54584
- if (overlap || partial && shift2.at <= end)
55056
+ const overlap = shift3.count > 0 ? shift3.at > start && shift3.at <= end : shift3.at <= end && shift3.at - shift3.count > start;
55057
+ if (overlap || partial && shift3.at <= end)
54585
55058
  throw new Error("Cannot move or remove part of a PivotTable. Delete the PivotTable first.");
54586
55059
  }
54587
- if (shift2.count <= 0) return;
54588
- const max = shift2.axis === "row" ? MAX_ROW : MAX_COL;
54589
- if (shift2.at + shift2.count > max + 1)
55060
+ if (shift3.count <= 0) return;
55061
+ const max = shift3.axis === "row" ? MAX_ROW : MAX_COL;
55062
+ if (shift3.at + shift3.count > max + 1)
54590
55063
  throw new RangeError("The insert area extends beyond the sheet.");
54591
- const first2 = max - shift2.count + 1;
54592
- const lost = shift2.axis === "row" ? cellRange(first2, band?.lo ?? 0, MAX_ROW, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, first2, band?.hi ?? MAX_ROW, MAX_COL);
54593
- const other = shift2.axis === "row" ? "col" : "row";
55064
+ const first2 = max - shift3.count + 1;
55065
+ const lost = shift3.axis === "row" ? cellRange(first2, band?.lo ?? 0, MAX_ROW, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, first2, band?.hi ?? MAX_ROW, MAX_COL);
55066
+ const other = shift3.axis === "row" ? "col" : "row";
54594
55067
  const clipped = (range2) => (!band || range2.start[other] >= band.lo && range2.end[other] <= band.hi) && rangesIntersect(range2, lost);
54595
55068
  const fail2 = () => {
54596
55069
  throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
@@ -54601,14 +55074,14 @@ function assertInsertFits(sheet, shift2, band) {
54601
55074
  if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell) || cell.cellMetadata !== void 0 || cell.valueMetadata !== void 0))
54602
55075
  fail2();
54603
55076
  }
54604
- if (sheet.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet.merges.some((m) => rangesIntersect(m, lost)) || sheet.tables.some((t) => rangesIntersect(t.range, lost)) || sheet.dataValidations.some((rule) => rule.ranges.some(clipped)) || sheet.conditionalFormats.some((format) => format.ranges.some(clipped)) || sheet.autoFilter !== void 0 && clipped(sheet.autoFilter.range) || sheet.pageSetup?.printArea !== void 0 && clipped(sheet.pageSetup.printArea) || hasPreservedOverflow(sheet, shift2, clipped, !!band))
55077
+ if (sheet.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet.merges.some((m) => rangesIntersect(m, lost)) || sheet.tables.some((t) => rangesIntersect(t.range, lost)) || sheet.dataValidations.some((rule) => rule.ranges.some(clipped)) || sheet.conditionalFormats.some((format) => format.ranges.some(clipped)) || sheet.autoFilter !== void 0 && clipped(sheet.autoFilter.range) || sheet.pageSetup?.printArea !== void 0 && clipped(sheet.pageSetup.printArea) || hasPreservedOverflow(sheet, shift3, clipped, !!band))
54605
55078
  fail2();
54606
55079
  for (const { anchor } of sheet.drawings) {
54607
55080
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) continue;
54608
- if (anchor.from[shift2.axis] >= first2 || anchor.to && anchor.to[shift2.axis] >= first2) fail2();
55081
+ if (anchor.from[shift3.axis] >= first2 || anchor.to && anchor.to[shift3.axis] >= first2) fail2();
54609
55082
  }
54610
55083
  if (band) return;
54611
- if (shift2.axis === "row") {
55084
+ if (shift3.axis === "row") {
54612
55085
  for (const [row2, info] of sheet.rowInfo) if (row2 >= first2 && Object.keys(info).length) fail2();
54613
55086
  } else {
54614
55087
  if (normalizeColumns(sheet.columns).some((c2) => c2.min >= first2)) fail2();
@@ -54616,11 +55089,11 @@ function assertInsertFits(sheet, shift2, band) {
54616
55089
  }
54617
55090
 
54618
55091
  // xlsx/edit/shift-rule-anchors.ts
54619
- function rebaseRulesForDeletion(sheet, shift2, band) {
54620
- if (shift2.count >= 0) return;
54621
- const last = shift2.at - shift2.count - 1;
54622
- const removed = shift2.axis === "row" ? cellRange(shift2.at, band?.lo ?? 0, last, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, shift2.at, band?.hi ?? MAX_ROW, last);
54623
- const other = shift2.axis === "row" ? "col" : "row";
55092
+ function rebaseRulesForDeletion(sheet, shift3, band) {
55093
+ if (shift3.count >= 0) return;
55094
+ const last = shift3.at - shift3.count - 1;
55095
+ const removed = shift3.axis === "row" ? cellRange(shift3.at, band?.lo ?? 0, last, band?.hi ?? MAX_COL) : cellRange(band?.lo ?? 0, shift3.at, band?.hi ?? MAX_ROW, last);
55096
+ const other = shift3.axis === "row" ? "col" : "row";
54624
55097
  const surviving = (ranges) => ranges.flatMap(
54625
55098
  (range2) => band && (range2.start[other] < band.lo || range2.end[other] > band.hi) ? [range2] : subtractRange(range2, removed)
54626
55099
  );
@@ -54868,10 +55341,10 @@ function shiftScenarios(sheet, move) {
54868
55341
  }
54869
55342
 
54870
55343
  // xlsx/edit/shift-sheet.ts
54871
- function shiftSheetContent(sheet, shift2, band) {
54872
- assertInsertFits(sheet, shift2, band);
54873
- const moveRange = (range2) => band ? shiftRangeInBand(range2, shift2, band.lo, band.hi) : shiftRange(range2, shift2);
54874
- shiftCells(sheet, shift2, band, moveRange);
55344
+ function shiftSheetContent(sheet, shift3, band) {
55345
+ assertInsertFits(sheet, shift3, band);
55346
+ const moveRange = (range2) => band ? shiftRangeInBand(range2, shift3, band.lo, band.hi) : shiftRange(range2, shift3);
55347
+ shiftCells(sheet, shift3, band, moveRange);
54875
55348
  sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
54876
55349
  sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
54877
55350
  sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
@@ -54883,7 +55356,7 @@ function shiftSheetContent(sheet, shift2, band) {
54883
55356
  const range2 = moveRange({ start: c2.address, end: c2.address });
54884
55357
  return range2 ? [{ ...c2, address: range2.start }] : [];
54885
55358
  });
54886
- sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift2, moveRange));
55359
+ sheet.tables = sheet.tables.flatMap((t) => shiftTable2(sheet, t, shift3, moveRange));
54887
55360
  shiftDataTables(sheet, moveRange);
54888
55361
  shiftScenarios(sheet, moveRange);
54889
55362
  for (const pivot of sheet.pivotTables ?? []) {
@@ -54893,8 +55366,8 @@ function shiftSheetContent(sheet, shift2, band) {
54893
55366
  pivot.dirty = true;
54894
55367
  }
54895
55368
  }
54896
- for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift2, band);
54897
- if (!band) shiftAxisFormats(sheet, shift2);
55369
+ for (const drawing of sheet.drawings) shiftAnchor(drawing.anchor, shift3, band);
55370
+ if (!band) shiftAxisFormats(sheet, shift3);
54898
55371
  if (sheet.autoFilter) {
54899
55372
  const old = sheet.autoFilter.range;
54900
55373
  const range2 = moveRange(old);
@@ -54903,39 +55376,39 @@ function shiftSheetContent(sheet, shift2, band) {
54903
55376
  clearFilteredRows(sheet);
54904
55377
  } else {
54905
55378
  const filter2 = { ...sheet.autoFilter, range: range2 };
54906
- if (shift2.axis === "col" && filter2.columns)
55379
+ if (shift3.axis === "col" && filter2.columns)
54907
55380
  filter2.columns = filter2.columns.flatMap((fc) => {
54908
- const abs3 = shiftIndex(old.start.col + fc.offset, shift2);
55381
+ const abs3 = shiftIndex(old.start.col + fc.offset, shift3);
54909
55382
  return abs3 === void 0 ? [] : [{ ...fc, offset: abs3 - range2.start.col }];
54910
55383
  });
54911
55384
  sheet.autoFilter = filter2;
54912
55385
  }
54913
55386
  }
54914
- if (!band) shiftFreeze(sheet, shift2);
55387
+ if (!band) shiftFreeze(sheet, shift3);
54915
55388
  const printArea = sheet.pageSetup?.printArea;
54916
55389
  if (sheet.pageSetup && printArea) {
54917
55390
  const moved = moveRange(printArea);
54918
55391
  if (moved) sheet.pageSetup.printArea = moved;
54919
55392
  else delete sheet.pageSetup.printArea;
54920
55393
  }
54921
- shiftPreservedXml(sheet, shift2, moveRange, !!band);
55394
+ shiftPreservedXml(sheet, shift3, moveRange, !!band);
54922
55395
  }
54923
- function shiftCells(sheet, shift2, band, moveRange) {
55396
+ function shiftCells(sheet, shift3, band, moveRange) {
54924
55397
  const old = sheet.rows;
54925
55398
  sheet.rows = /* @__PURE__ */ new Map();
54926
55399
  for (const [row2, cells] of old)
54927
55400
  for (const [col, cell] of cells) {
54928
- const along = shift2.axis === "row" ? row2 : col;
54929
- const across = shift2.axis === "row" ? col : row2;
55401
+ const along = shift3.axis === "row" ? row2 : col;
55402
+ const across = shift3.axis === "row" ? col : row2;
54930
55403
  const inBand = !band || across >= band.lo && across <= band.hi;
54931
- const moved = inBand ? shiftIndex(along, shift2) : along;
55404
+ const moved = inBand ? shiftIndex(along, shift3) : along;
54932
55405
  if (moved === void 0) continue;
54933
55406
  if (cell.arrayRange) {
54934
55407
  const range2 = moveRange(cell.arrayRange);
54935
55408
  if (range2) cell.arrayRange = range2;
54936
55409
  else delete cell.arrayRange;
54937
55410
  }
54938
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
55411
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
54939
55412
  else putCell(sheet, row2, moved, cell);
54940
55413
  }
54941
55414
  }
@@ -54943,73 +55416,73 @@ function uniqueColumnName(columns) {
54943
55416
  const taken = new Set(columns.map((c2) => c2.name.toLowerCase()));
54944
55417
  for (let n2 = 1; ; n2++) if (!taken.has(`column${n2}`)) return `Column${n2}`;
54945
55418
  }
54946
- function shiftTable2(sheet, table3, shift2, moveRange) {
55419
+ function shiftTable2(sheet, table3, shift3, moveRange) {
54947
55420
  const old = table3.range;
54948
55421
  const range2 = moveRange(old);
54949
55422
  if (!range2) return [];
54950
55423
  const next = { ...table3, range: range2, columns: [...table3.columns] };
54951
55424
  const widened = range2.end.col - range2.start.col !== old.end.col - old.start.col;
54952
- if (shift2.axis === "col" && widened) {
54953
- if (shift2.count > 0) {
54954
- const offset2 = shift2.at - old.start.col;
54955
- for (let i2 = 0; i2 < shift2.count; i2++) {
55425
+ if (shift3.axis === "col" && widened) {
55426
+ if (shift3.count > 0) {
55427
+ const offset2 = shift3.at - old.start.col;
55428
+ for (let i2 = 0; i2 < shift3.count; i2++) {
54956
55429
  const column2 = { name: uniqueColumnName(next.columns) };
54957
55430
  next.columns.splice(offset2 + i2, 0, column2);
54958
55431
  if (next.headerRow) {
54959
55432
  const cell = { value: column2.name };
54960
- putCell(sheet, range2.start.row, shift2.at + i2, cell);
55433
+ putCell(sheet, range2.start.row, shift3.at + i2, cell);
54961
55434
  }
54962
55435
  }
54963
55436
  } else {
54964
55437
  next.columns = next.columns.filter(
54965
- (_c, i2) => shiftIndex(old.start.col + i2, shift2) !== void 0
55438
+ (_c, i2) => shiftIndex(old.start.col + i2, shift3) !== void 0
54966
55439
  );
54967
55440
  }
54968
55441
  }
54969
55442
  return [next];
54970
55443
  }
54971
- function shiftAnchor(anchor, shift2, band) {
54972
- const key = shift2.axis === "row" ? "row" : "col";
54973
- const other = shift2.axis === "row" ? "col" : "row";
55444
+ function shiftAnchor(anchor, shift3, band) {
55445
+ const key = shift3.axis === "row" ? "row" : "col";
55446
+ const other = shift3.axis === "row" ? "col" : "row";
54974
55447
  if (band && (anchor.from[other] < band.lo || anchor.from[other] > band.hi)) return;
54975
55448
  const from = anchor.from[key];
54976
- const movedFrom = shiftIndexClamped(from, shift2);
54977
- if (shiftIndex(from, shift2) === void 0)
55449
+ const movedFrom = shiftIndexClamped(from, shift3);
55450
+ if (shiftIndex(from, shift3) === void 0)
54978
55451
  anchor.from[key === "row" ? "rowOffset" : "colOffset"] = 0;
54979
55452
  anchor.from[key] = movedFrom;
54980
55453
  if (anchor.to) {
54981
55454
  const to = anchor.to[key];
54982
- const moved = shiftIndex(to, shift2);
55455
+ const moved = shiftIndex(to, shift3);
54983
55456
  if (moved === void 0) {
54984
- anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift2));
55457
+ anchor.to[key] = Math.max(movedFrom, shiftIndexClamped(to, shift3));
54985
55458
  anchor.to[key === "row" ? "rowOffset" : "colOffset"] = 0;
54986
55459
  } else anchor.to[key] = moved;
54987
55460
  }
54988
55461
  }
54989
- function shiftAxisFormats(sheet, shift2) {
54990
- if (shift2.axis === "row") {
55462
+ function shiftAxisFormats(sheet, shift3) {
55463
+ if (shift3.axis === "row") {
54991
55464
  const old = sheet.rowInfo;
54992
55465
  sheet.rowInfo = /* @__PURE__ */ new Map();
54993
55466
  for (const [row2, info] of old) {
54994
- const moved = shiftIndex(row2, shift2);
55467
+ const moved = shiftIndex(row2, shift3);
54995
55468
  if (moved !== void 0) sheet.rowInfo.set(moved, info);
54996
55469
  }
54997
55470
  return;
54998
55471
  }
54999
55472
  sheet.columns = normalizeColumns(
55000
55473
  sheet.columns.flatMap((info) => {
55001
- const span5 = shiftSpan(info.min, info.max, shift2);
55474
+ const span5 = shiftSpan(info.min, info.max, shift3);
55002
55475
  return span5 ? [{ ...info, min: span5.start, max: span5.end }] : [];
55003
55476
  })
55004
55477
  );
55005
55478
  }
55006
- function shiftFreeze(sheet, shift2) {
55479
+ function shiftFreeze(sheet, shift3) {
55007
55480
  const freeze = sheet.view.freeze;
55008
55481
  if (!freeze) return;
55009
- const key = shift2.axis === "row" ? "rows" : "cols";
55482
+ const key = shift3.axis === "row" ? "rows" : "cols";
55010
55483
  const frozen = freeze[key];
55011
- if (shift2.at >= frozen) return;
55012
- const next = shift2.count > 0 ? frozen + shift2.count : frozen - Math.min(-shift2.count, frozen - shift2.at);
55484
+ if (shift3.at >= frozen) return;
55485
+ const next = shift3.count > 0 ? frozen + shift3.count : frozen - Math.min(-shift3.count, frozen - shift3.at);
55013
55486
  sheet.view.freeze = { ...freeze, [key]: next };
55014
55487
  }
55015
55488
 
@@ -55019,15 +55492,15 @@ function checkSpan(axis, at2, count2) {
55019
55492
  if (!Number.isInteger(at2) || !Number.isInteger(count2) || at2 < 0 || at2 > max || count2 < 1 || at2 + count2 > max + 1)
55020
55493
  throw new RangeError(`Invalid ${axis} span ${at2} + ${count2}`);
55021
55494
  }
55022
- function applyAxisShift(ctx, sheet, shift2) {
55023
- assertInsertFits(sheet, shift2);
55024
- rebaseRulesForDeletion(sheet, shift2);
55025
- const spec2 = { sheet: sheet.name, axis: shift2.axis, at: shift2.at, count: shift2.count };
55495
+ function applyAxisShift(ctx, sheet, shift3) {
55496
+ assertInsertFits(sheet, shift3);
55497
+ rebaseRulesForDeletion(sheet, shift3);
55498
+ const spec2 = { sheet: sheet.name, axis: shift3.axis, at: shift3.at, count: shift3.count };
55026
55499
  rewriteFormulas(
55027
55500
  ctx.workbook,
55028
55501
  (formula2, formulaSheet) => shiftFormula(formula2, formulaSheet, spec2)
55029
55502
  );
55030
- shiftSheetContent(sheet, shift2);
55503
+ shiftSheetContent(sheet, shift3);
55031
55504
  }
55032
55505
  function inheritFormats(sheet, axis, at2, count2) {
55033
55506
  if (at2 === 0) return;
@@ -55053,17 +55526,17 @@ function shiftAxis(ctx, s, axis, at2, count2, insert2) {
55053
55526
  checkSpan(axis, at2, count2);
55054
55527
  const sheet = sheetAt(ctx.workbook, s);
55055
55528
  const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
55056
- const shift2 = { axis, at: at2, count: insert2 ? count2 : -count2 };
55057
- assertInsertFits(sheet, shift2);
55529
+ const shift3 = { axis, at: at2, count: insert2 ? count2 : -count2 };
55530
+ assertInsertFits(sheet, shift3);
55058
55531
  const info = { sheet: s, structural: true };
55059
- if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift2))
55060
- info.calc = { kind: "shift", sheet: s, shift: shift2 };
55532
+ if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift3))
55533
+ info.calc = { kind: "shift", sheet: s, shift: shift3 };
55061
55534
  ctx.run(
55062
55535
  `${insert2 ? "Insert" : "Delete"} ${noun}`,
55063
55536
  "structure",
55064
- [{ kind: "shift", sheet: s, shift: shift2 }],
55537
+ [{ kind: "shift", sheet: s, shift: shift3 }],
55065
55538
  () => {
55066
- applyAxisShift(ctx, sheet, shift2);
55539
+ applyAxisShift(ctx, sheet, shift3);
55067
55540
  if (insert2) inheritFormats(sheet, axis, at2, count2);
55068
55541
  },
55069
55542
  info
@@ -55075,9 +55548,9 @@ var insertColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count
55075
55548
  var deleteColumns = (ctx, s, at2, count2) => shiftAxis(ctx, s, "col", at2, count2, false);
55076
55549
 
55077
55550
  // xlsx/edit/cell-shift.ts
55078
- function assertBandIntact(sheet, shift2, band) {
55079
- const zone = shift2.axis === "row" ? cellRange(shift2.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift2.at, band.hi, MAX_COL);
55080
- const other = shift2.axis === "row" ? "col" : "row";
55551
+ function assertBandIntact(sheet, shift3, band) {
55552
+ const zone = shift3.axis === "row" ? cellRange(shift3.at, band.lo, MAX_ROW, band.hi) : cellRange(band.lo, shift3.at, band.hi, MAX_COL);
55553
+ const other = shift3.axis === "row" ? "col" : "row";
55081
55554
  const torn = (r) => rangesIntersect(r, zone) && (r.start[other] < band.lo || r.end[other] > band.hi);
55082
55555
  if (sheet.merges.some(torn))
55083
55556
  throw new Error("Cannot shift cells: a merged range would be split.");
@@ -55090,25 +55563,25 @@ function shiftBand(ctx, s, range2, direction) {
55090
55563
  const vertical2 = direction === "down" || direction === "up";
55091
55564
  const insert2 = direction === "down" || direction === "right";
55092
55565
  const size = vertical2 ? r.end.row - r.start.row + 1 : r.end.col - r.start.col + 1;
55093
- const shift2 = {
55566
+ const shift3 = {
55094
55567
  axis: vertical2 ? "row" : "col",
55095
55568
  at: vertical2 ? r.start.row : r.start.col,
55096
55569
  count: insert2 ? size : -size
55097
55570
  };
55098
55571
  const band = vertical2 ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
55099
- assertBandIntact(sheet, shift2, band);
55100
- assertInsertFits(sheet, shift2, band);
55572
+ assertBandIntact(sheet, shift3, band);
55573
+ assertInsertFits(sheet, shift3, band);
55101
55574
  ctx.run(
55102
55575
  `${insert2 ? "Insert" : "Delete"} cells`,
55103
55576
  "structure",
55104
- [{ kind: "shift", sheet: s, shift: shift2, band }],
55577
+ [{ kind: "shift", sheet: s, shift: shift3, band }],
55105
55578
  () => {
55106
- rebaseRulesForDeletion(sheet, shift2, band);
55579
+ rebaseRulesForDeletion(sheet, shift3, band);
55107
55580
  rewriteFormulas(
55108
55581
  ctx.workbook,
55109
- (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift2, band)
55582
+ (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet.name, shift3, band)
55110
55583
  );
55111
- shiftSheetContent(sheet, shift2, band);
55584
+ shiftSheetContent(sheet, shift3, band);
55112
55585
  },
55113
55586
  { sheet: s, ranges: [r], structural: true }
55114
55587
  );
@@ -56636,14 +57109,14 @@ function restoreRefs(workbook, data) {
56636
57109
  }
56637
57110
  var sameRange3 = (a2, b) => a2 === b || !!a2 && !!b && a2.start.row === b.start.row && a2.start.col === b.start.col && a2.end.row === b.end.row && a2.end.col === b.end.col;
56638
57111
  var sameEntry = (a2, b) => a2.formula === b.formula && sameRange3(a2.arrayRange, b.arrayRange);
56639
- function movePosition(spec2, shift2, s, row2, col) {
56640
- if (!spec2 || !shift2 || s !== spec2.sheet) return [row2, col];
56641
- const along = shift2.axis === "row" ? row2 : col;
56642
- const across = shift2.axis === "row" ? col : row2;
57112
+ function movePosition(spec2, shift3, s, row2, col) {
57113
+ if (!spec2 || !shift3 || s !== spec2.sheet) return [row2, col];
57114
+ const along = shift3.axis === "row" ? row2 : col;
57115
+ const across = shift3.axis === "row" ? col : row2;
56643
57116
  if (spec2.band && (across < spec2.band.lo || across > spec2.band.hi)) return [row2, col];
56644
- const moved = shiftIndex(along, shift2);
57117
+ const moved = shiftIndex(along, shift3);
56645
57118
  if (moved === void 0) return void 0;
56646
- return shift2.axis === "row" ? [moved, col] : [row2, moved];
57119
+ return shift3.axis === "row" ? [moved, col] : [row2, moved];
56647
57120
  }
56648
57121
  function diffRefs(workbook, before, spec2) {
56649
57122
  const keptBefore = [];
@@ -56664,37 +57137,37 @@ function diffRefs(workbook, before, spec2) {
56664
57137
  before.formulas = keptBefore;
56665
57138
  return keptAfter;
56666
57139
  }
56667
- function moveCellsRaw(sheet, shift2, band) {
57140
+ function moveCellsRaw(sheet, shift3, band) {
56668
57141
  const old = sheet.rows;
56669
57142
  sheet.rows = /* @__PURE__ */ new Map();
56670
- if (shift2.axis === "row" && !band) {
57143
+ if (shift3.axis === "row" && !band) {
56671
57144
  for (const [row2, cells] of old) {
56672
- const moved = shiftIndex(row2, shift2);
57145
+ const moved = shiftIndex(row2, shift3);
56673
57146
  if (moved !== void 0) sheet.rows.set(moved, cells);
56674
57147
  }
56675
57148
  return;
56676
57149
  }
56677
57150
  for (const [row2, cells] of old)
56678
57151
  for (const [col, cell] of cells) {
56679
- const along = shift2.axis === "row" ? row2 : col;
56680
- const across = shift2.axis === "row" ? col : row2;
57152
+ const along = shift3.axis === "row" ? row2 : col;
57153
+ const across = shift3.axis === "row" ? col : row2;
56681
57154
  const inBand = !band || across >= band.lo && across <= band.hi;
56682
- const moved = inBand ? shiftIndex(along, shift2) : along;
57155
+ const moved = inBand ? shiftIndex(along, shift3) : along;
56683
57156
  if (moved === void 0) continue;
56684
- if (shift2.axis === "row") putCell(sheet, moved, col, cell);
57157
+ if (shift3.axis === "row") putCell(sheet, moved, col, cell);
56685
57158
  else putCell(sheet, row2, moved, cell);
56686
57159
  }
56687
57160
  }
56688
57161
  function shiftEdgeCells(sheet, spec2, phase) {
56689
- const { shift: shift2, band } = spec2;
57162
+ const { shift: shift3, band } = spec2;
56690
57163
  const out = [];
56691
- if (phase === "after" && shift2.count < 0) return out;
56692
- const hit = (along) => phase === "before" ? shiftIndex(along, shift2) === void 0 : along >= shift2.at && along < shift2.at + shift2.count;
57164
+ if (phase === "after" && shift3.count < 0) return out;
57165
+ const hit = (along) => phase === "before" ? shiftIndex(along, shift3) === void 0 : along >= shift3.at && along < shift3.at + shift3.count;
56693
57166
  for (const [row2, cells] of sheet.rows) {
56694
- if (shift2.axis === "row" && !hit(row2)) continue;
57167
+ if (shift3.axis === "row" && !hit(row2)) continue;
56695
57168
  for (const [col, cell] of cells) {
56696
- const along = shift2.axis === "row" ? row2 : col;
56697
- const across = shift2.axis === "row" ? col : row2;
57169
+ const along = shift3.axis === "row" ? row2 : col;
57170
+ const across = shift3.axis === "row" ? col : row2;
56698
57171
  if (band && (across < band.lo || across > band.hi)) continue;
56699
57172
  if (hit(along)) out.push([row2, col, structuredClone(cell)]);
56700
57173
  }
@@ -56837,8 +57310,8 @@ function restoreShift(workbook, snapshot2) {
56837
57310
  const { spec: spec2 } = snapshot2;
56838
57311
  const sheet = workbook.sheets[spec2.sheet];
56839
57312
  if (!sheet) return;
56840
- const shift2 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
56841
- moveCellsRaw(sheet, shift2, spec2.band);
57313
+ const shift3 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
57314
+ moveCellsRaw(sheet, shift3, spec2.band);
56842
57315
  for (const [row2, col, cell] of snapshot2.cells) putCell(sheet, row2, col, cloneCell(cell));
56843
57316
  restoreRefs(workbook, snapshot2.data);
56844
57317
  workbook.activeSheet = snapshot2.activeSheet;
@@ -61262,8 +61735,8 @@ function scottBinCount(values2, min, max) {
61262
61735
  if (values2.length < 2 || max <= min) {
61263
61736
  return 1;
61264
61737
  }
61265
- const mean4 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
61266
- const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean4) ** 2, 0) / (values2.length - 1);
61738
+ const mean9 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
61739
+ const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean9) ** 2, 0) / (values2.length - 1);
61267
61740
  const sd = Math.sqrt(variance3);
61268
61741
  if (!(sd > 0)) {
61269
61742
  return 1;
@@ -61515,8 +61988,8 @@ function fitChartTrendline(options7, xVals, yVals) {
61515
61988
  function chartSampleVariance(values2) {
61516
61989
  const count2 = values2.length;
61517
61990
  if (count2 === 0) return 0;
61518
- const mean4 = values2.reduce((sum3, value3) => sum3 + value3, 0) / count2;
61519
- return values2.reduce((sum3, value3) => sum3 + (value3 - mean4) ** 2, 0) / Math.max(count2 - 1, 1);
61991
+ const mean9 = values2.reduce((sum3, value3) => sum3 + value3, 0) / count2;
61992
+ return values2.reduce((sum3, value3) => sum3 + (value3 - mean9) ** 2, 0) / Math.max(count2 - 1, 1);
61520
61993
  }
61521
61994
  function chartErrorBarAmount(options7, values2, displayIndex, sourceIndex, side) {
61522
61995
  switch (options7.valueType) {
@@ -62384,7 +62857,7 @@ function boxWhiskerSvg(model2, frame2, out) {
62384
62857
  trim2
62385
62858
  );
62386
62859
  if (!distribution) return;
62387
- const { stats, whiskerMin, whiskerMax, mean: mean4 } = distribution;
62860
+ const { stats, whiskerMin, whiskerMax, mean: mean9 } = distribution;
62388
62861
  const x = frame2.band(ci) - frame2.bandSize / 2 + si * slot2 + (slot2 - width) / 2;
62389
62862
  const mid = x + width / 2;
62390
62863
  const y = frame2.value;
@@ -62409,10 +62882,10 @@ function boxWhiskerSvg(model2, frame2, out) {
62409
62882
  )
62410
62883
  );
62411
62884
  out.push(line3(x, y(stats.median), x + width, y(stats.median), "#1e293b", 2));
62412
- if (visibility?.meanLine) out.push(line3(x, y(mean4), x + width, y(mean4), "#0f766e", 1.5));
62885
+ if (visibility?.meanLine) out.push(line3(x, y(mean9), x + width, y(mean9), "#0f766e", 1.5));
62413
62886
  if (visibility?.meanMarker !== false)
62414
62887
  out.push(
62415
- `<path d="${boxMeanMarkerPath(mid, y(mean4))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
62888
+ `<path d="${boxMeanMarkerPath(mid, y(mean9))}" fill="none" stroke="#0f766e" stroke-width="1.5" data-chart-part="mean"/>`
62416
62889
  );
62417
62890
  observations.forEach((point2, index3) => {
62418
62891
  const outlier = point2.value < whiskerMin || point2.value > whiskerMax;
@@ -62658,10 +63131,10 @@ function categoryAnalysis(model2, frame2, out) {
62658
63131
  const layout2 = barred ? barLayout(model2, frame2) : void 0;
62659
63132
  model2.series.forEach((series, si) => {
62660
63133
  if (!series.trendlines && !series.errorBars) return;
62661
- const shift2 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
63134
+ const shift3 = layout2 ? layout2.offset(si) + layout2.barSize / 2 : 0;
62662
63135
  const barPlane = (x, y) => {
62663
63136
  const [px, py] = plane(x, y);
62664
- return model2.horizontal ? [px, py + shift2] : [px + shift2, py];
63137
+ return model2.horizontal ? [px, py + shift3] : [px + shift3, py];
62665
63138
  };
62666
63139
  seriesAnalysis(series, si, (i2) => i2 + 1, plane, barPlane, true, out);
62667
63140
  });
@@ -65545,11 +66018,11 @@ var byId = (sheet, id) => {
65545
66018
  return table3;
65546
66019
  };
65547
66020
  function insertBandRow(workbook, sheet, table3, row2) {
65548
- const shift2 = { axis: "row", at: row2, count: 1 };
66021
+ const shift3 = { axis: "row", at: row2, count: 1 };
65549
66022
  const band = { lo: table3.range.start.col, hi: table3.range.end.col };
65550
- assertInsertFits(sheet, shift2, band);
65551
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
65552
- shiftSheetContent(sheet, shift2, band);
66023
+ assertInsertFits(sheet, shift3, band);
66024
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
66025
+ shiftSheetContent(sheet, shift3, band);
65553
66026
  }
65554
66027
  function setHeaderRow(workbook, sheet, id, on) {
65555
66028
  let table3 = byId(sheet, id);
@@ -68586,10 +69059,10 @@ function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2")
68586
69059
  [hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
68587
69060
  () => {
68588
69061
  if (!hasHeader) {
68589
- const shift2 = { axis: "row", at: r.start.row, count: 1 };
69062
+ const shift3 = { axis: "row", at: r.start.row, count: 1 };
68590
69063
  const band = { lo: r.start.col, hi: r.end.col };
68591
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
68592
- shiftSheetContent(sheet, shift2, band);
69064
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift3, band));
69065
+ shiftSheetContent(sheet, shift3, band);
68593
69066
  r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
68594
69067
  }
68595
69068
  const width = r.end.col - r.start.col + 1;