ooxml-core 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PptxHandler-G63S6YZU.mjs → PptxHandler-75LOVF7I.mjs} +2 -2
- package/dist/automation/index.cjs +2559 -1169
- package/dist/automation/index.mjs +2559 -1169
- package/dist/chart/gradient-definition.d.ts +2 -2
- package/dist/chart/gradient-definition.d.ts.map +1 -1
- package/dist/chart/index.cjs +7 -7
- package/dist/chart/index.mjs +7 -7
- package/dist/{chunk-BICQYRPW.mjs → chunk-75LA7H3F.mjs} +1339 -1435
- package/dist/{chunk-CKJSWE7N.mjs → chunk-LA7D6ZYQ.mjs} +244 -115
- package/dist/{chunk-ROM5MZ7O.mjs → chunk-OMGH6IKY.mjs} +3 -3
- package/dist/{chunk-RWXFQJVF.mjs → chunk-Q27H4HFS.mjs} +1 -1
- package/dist/{chunk-DDG5HTGX.mjs → chunk-RFX7AJDZ.mjs} +1 -1
- package/dist/crypto/index.cjs +1406 -184
- package/dist/crypto/index.mjs +1406 -184
- package/dist/diagram/dom.d.ts +1 -14
- package/dist/diagram/dom.d.ts.map +1 -1
- package/dist/diagram/index.cjs +15 -15
- package/dist/diagram/index.d.ts +12 -12
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.mjs +15 -15
- package/dist/diagram/types.d.ts +12 -148
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/digest/algorithm-names.d.ts +2 -2
- package/dist/digest/algorithm-names.d.ts.map +1 -1
- package/dist/digest/bit-ops.d.ts +30 -0
- package/dist/digest/bit-ops.d.ts.map +1 -0
- package/dist/digest/digest.d.ts +2 -2
- package/dist/digest/digest.d.ts.map +1 -1
- package/dist/digest/index.cjs +1319 -90
- package/dist/digest/index.d.ts +7 -1
- package/dist/digest/index.d.ts.map +1 -1
- package/dist/digest/index.mjs +1313 -91
- package/dist/digest/md2.d.ts +22 -0
- package/dist/digest/md2.d.ts.map +1 -0
- package/dist/digest/md4.d.ts +3 -0
- package/dist/digest/md4.d.ts.map +1 -0
- package/dist/digest/md5.d.ts +3 -0
- package/dist/digest/md5.d.ts.map +1 -0
- package/dist/digest/password-hash.d.ts +7 -0
- package/dist/digest/password-hash.d.ts.map +1 -1
- package/dist/digest/ripemd-functions.d.ts +18 -0
- package/dist/digest/ripemd-functions.d.ts.map +1 -0
- package/dist/digest/ripemd128.d.ts +3 -0
- package/dist/digest/ripemd128.d.ts.map +1 -0
- package/dist/digest/ripemd160.d.ts +3 -0
- package/dist/digest/ripemd160.d.ts.map +1 -0
- package/dist/digest/whirlpool-sbox.d.ts +15 -0
- package/dist/digest/whirlpool-sbox.d.ts.map +1 -0
- package/dist/digest/whirlpool-table.d.ts +12 -0
- package/dist/digest/whirlpool-table.d.ts.map +1 -0
- package/dist/digest/whirlpool.d.ts +3 -0
- package/dist/digest/whirlpool.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/diagram-theme.d.ts +3 -3
- package/dist/docx/diagram-theme.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +470 -276
- package/dist/docx/embedded.mjs +470 -276
- package/dist/docx/field-flags.d.ts +8 -0
- package/dist/docx/field-flags.d.ts.map +1 -0
- package/dist/docx/field-lock.d.ts +6 -0
- package/dist/docx/field-lock.d.ts.map +1 -0
- package/dist/docx/field-runs.d.ts +4 -1
- package/dist/docx/field-runs.d.ts.map +1 -1
- package/dist/docx/index.cjs +1029 -850
- package/dist/docx/index.d.ts +2 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +1027 -850
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +61 -47
- package/dist/docx/layout/index.mjs +61 -47
- package/dist/docx/layout/page-fields.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1883 -467
- package/dist/docx/load/index.mjs +1883 -467
- package/dist/docx/model-run.d.ts +5 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/numbering-model.d.ts +1 -1
- package/dist/docx/numbering-model.d.ts.map +1 -1
- package/dist/docx/numbering-package.d.ts +4 -4
- package/dist/docx/numbering-package.d.ts.map +1 -1
- package/dist/docx/numbering-start-edit.d.ts +8 -0
- package/dist/docx/numbering-start-edit.d.ts.map +1 -0
- package/dist/docx/numbering-start-patch.d.ts +13 -0
- package/dist/docx/numbering-start-patch.d.ts.map +1 -0
- package/dist/docx/theme-color.d.ts.map +1 -1
- package/dist/docx/theme-model.d.ts +3 -2
- package/dist/docx/theme-model.d.ts.map +1 -1
- package/dist/docx/theme.d.ts +5 -1
- package/dist/docx/theme.d.ts.map +1 -1
- package/dist/docx/ui/field-guard.d.ts +2 -0
- package/dist/docx/ui/field-guard.d.ts.map +1 -1
- package/dist/docx/ui/field-results.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +547 -375
- package/dist/docx/ui/index.mjs +547 -376
- package/dist/docx/ui/review-commands.d.ts.map +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts.map +1 -1
- package/dist/docx/ui/simple-field-input.d.ts +3 -0
- package/dist/docx/ui/simple-field-input.d.ts.map +1 -1
- package/dist/docx/ui/track-changes-mode.d.ts.map +1 -1
- package/dist/docx/ui/track-paragraph-boundaries.d.ts +5 -0
- package/dist/docx/ui/track-paragraph-boundaries.d.ts.map +1 -0
- package/dist/docx/write-inline.d.ts.map +1 -1
- package/dist/docx/write-run.d.ts.map +1 -1
- package/dist/drawingml/dom.d.ts +15 -0
- package/dist/drawingml/dom.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-brightness.d.ts +6 -0
- package/dist/drawingml/drawing-color-brightness.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-css.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-color.d.ts +5 -5
- package/dist/drawingml/drawing-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-fill.d.ts +3 -3
- package/dist/drawingml/drawing-fill.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-geometry.d.ts +4 -4
- package/dist/drawingml/drawing-geometry.d.ts.map +1 -0
- package/dist/drawingml/drawing-shadow.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-text.d.ts +2 -2
- package/dist/drawingml/drawing-text.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-geometry.d.ts +2 -2
- package/dist/drawingml/gradient-geometry.d.ts.map +1 -0
- package/dist/drawingml/gradient-preset-data.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-presets.d.ts +3 -3
- package/dist/drawingml/gradient-presets.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +1545 -0
- package/dist/drawingml/index.d.ts +19 -0
- package/dist/drawingml/index.d.ts.map +1 -0
- package/dist/drawingml/index.mjs +1497 -0
- package/dist/{diagram → drawingml}/ordered-color-transforms.d.ts +2 -2
- package/dist/drawingml/ordered-color-transforms.d.ts.map +1 -0
- package/dist/drawingml/rect-path-gradient.d.ts.map +1 -0
- package/dist/drawingml/theme-color.d.ts +19 -0
- package/dist/drawingml/theme-color.d.ts.map +1 -0
- package/dist/drawingml/theme-model.d.ts +40 -0
- package/dist/drawingml/theme-model.d.ts.map +1 -0
- package/dist/drawingml/theme.d.ts +21 -0
- package/dist/drawingml/theme.d.ts.map +1 -0
- package/dist/drawingml/types.d.ts +152 -0
- package/dist/drawingml/types.d.ts.map +1 -0
- package/dist/drawingml/write-color.d.ts +4 -0
- package/dist/drawingml/write-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/write-fill.d.ts +2 -2
- package/dist/drawingml/write-fill.d.ts.map +1 -0
- package/dist/geometry/connector-elbow-geometry.d.ts +14 -0
- package/dist/geometry/connector-elbow-geometry.d.ts.map +1 -1
- package/dist/geometry/index.cjs +43 -0
- package/dist/geometry/index.mjs +42 -1
- package/dist/i18n/dictionary.d.ts +13 -0
- package/dist/i18n/dictionary.d.ts.map +1 -0
- package/dist/i18n/index.cjs +68 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.mjs +60 -0
- package/dist/i18n/locale.d.ts +17 -0
- package/dist/i18n/locale.d.ts.map +1 -0
- package/dist/i18n/translator.d.ts +18 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/index.cjs +3712 -2178
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3711 -2179
- package/dist/pptx/automation/index.cjs +2852 -1568
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts → index-BHqL5KXH.d.ts} +2 -2
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts.map → index-BHqL5KXH.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-lk7dyOPS.d.ts → index-BYkdcS8J.d.ts} +12 -16
- package/dist/pptx/chunks/index-BYkdcS8J.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-CO2jmJFf.d.ts.map +1 -1
- package/dist/pptx/chunks/{text-operations-CDLx4hD5.d.ts → text-operations-DEJ7alZR.d.ts} +2 -2
- package/dist/pptx/chunks/text-operations-DEJ7alZR.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +2680 -1396
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/index.cjs +1771 -1756
- package/dist/pptx/index.d.ts +3 -3
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +144 -74
- package/dist/teams/index.mjs +144 -74
- package/dist/visio/ui/index.cjs +14 -3
- package/dist/visio/ui/index.mjs +14 -3
- package/dist/visio/ui/shape-rotation.d.ts +1 -1
- package/dist/visio/ui/shape-rotation.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts.map +1 -1
- package/dist/xlsx/edit/protection.d.ts +1 -1
- package/dist/xlsx/index.cjs +3222 -1886
- package/dist/xlsx/index.mjs +3222 -1886
- package/dist/xlsx/layout/chart-appearance.d.ts +1 -1
- package/dist/xlsx/layout/chart-appearance.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-scale.d.ts +5 -1
- package/dist/xlsx/layout/chart-scale.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-svg-legend.d.ts +13 -0
- package/dist/xlsx/layout/chart-svg-legend.d.ts.map +1 -0
- package/dist/xlsx/layout/chart-svg.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-view.d.ts +3 -1
- package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +2110 -838
- package/dist/xlsx/load/index.mjs +2110 -838
- package/dist/xlsx/read/theme.d.ts +2 -4
- package/dist/xlsx/read/theme.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +2017 -771
- package/dist/xlsx/ui/index.mjs +2017 -771
- package/dist/xlsx/ui/locales/merge.d.ts +2 -1
- package/dist/xlsx/ui/locales/merge.d.ts.map +1 -1
- package/dist/xlsx/ui/localization.d.ts.map +1 -1
- package/dist/xlsx/write/theme.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/diagram/drawing-color-brightness.d.ts +0 -6
- package/dist/diagram/drawing-color-brightness.d.ts.map +0 -1
- package/dist/diagram/drawing-color-css.d.ts.map +0 -1
- package/dist/diagram/drawing-color.d.ts.map +0 -1
- package/dist/diagram/drawing-fill.d.ts.map +0 -1
- package/dist/diagram/drawing-geometry.d.ts.map +0 -1
- package/dist/diagram/drawing-shadow.d.ts.map +0 -1
- package/dist/diagram/drawing-text.d.ts.map +0 -1
- package/dist/diagram/gradient-geometry.d.ts.map +0 -1
- package/dist/diagram/gradient-preset-data.d.ts.map +0 -1
- package/dist/diagram/gradient-presets.d.ts.map +0 -1
- package/dist/diagram/ordered-color-transforms.d.ts.map +0 -1
- package/dist/diagram/rect-path-gradient.d.ts.map +0 -1
- package/dist/diagram/write-color.d.ts +0 -4
- package/dist/diagram/write-color.d.ts.map +0 -1
- package/dist/diagram/write-fill.d.ts.map +0 -1
- package/dist/pptx/chunks/index-lk7dyOPS.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-CDLx4hD5.d.ts.map +0 -1
- /package/dist/{diagram → drawingml}/drawing-color-css.d.ts +0 -0
- /package/dist/{diagram → drawingml}/drawing-shadow.d.ts +0 -0
- /package/dist/{diagram → drawingml}/gradient-preset-data.d.ts +0 -0
- /package/dist/{diagram → drawingml}/rect-path-gradient.d.ts +0 -0
package/dist/xlsx/ui/index.mjs
CHANGED
|
@@ -842,7 +842,7 @@ var FORMAT_PRESETS = [
|
|
|
842
842
|
var isDigit = (t) => t?.t === "digit";
|
|
843
843
|
function fractionSlash(tokens) {
|
|
844
844
|
return tokens.findIndex(
|
|
845
|
-
(t,
|
|
845
|
+
(t, i2) => t.t === "slash" && isDigit(tokens[i2 - 1]) && (isDigit(tokens[i2 + 1]) || tokens[i2 + 1]?.t === "num")
|
|
846
846
|
);
|
|
847
847
|
}
|
|
848
848
|
function compileFraction(tokens, slash) {
|
|
@@ -862,19 +862,19 @@ function compileFraction(tokens, slash) {
|
|
|
862
862
|
if (fixed2) {
|
|
863
863
|
plan.fixedDenominator = Number(denTokens.map((t) => t.t === "num" ? t.v : "0").join(""));
|
|
864
864
|
}
|
|
865
|
-
tokens.forEach((tok,
|
|
866
|
-
if (
|
|
867
|
-
else if (
|
|
865
|
+
tokens.forEach((tok, i2) => {
|
|
866
|
+
if (i2 === slash) plan.tokens.push({ r: "slash" });
|
|
867
|
+
else if (i2 > slash && i2 < denEnd) {
|
|
868
868
|
if (fixed2) {
|
|
869
|
-
if (
|
|
869
|
+
if (i2 === slash + 1) plan.tokens.push({ r: "den", index: 0 });
|
|
870
870
|
} else if (isDigit(tok)) {
|
|
871
871
|
plan.tokens.push({ r: "den", index: plan.denDigits.length });
|
|
872
872
|
plan.denDigits.push(tok.c);
|
|
873
873
|
}
|
|
874
|
-
} else if (isDigit(tok) &&
|
|
874
|
+
} else if (isDigit(tok) && i2 >= numStart && i2 < slash) {
|
|
875
875
|
plan.tokens.push({ r: "num", index: plan.numDigits.length });
|
|
876
876
|
plan.numDigits.push(tok.c);
|
|
877
|
-
} else if (isDigit(tok) &&
|
|
877
|
+
} else if (isDigit(tok) && i2 < numStart) {
|
|
878
878
|
plan.tokens.push({ r: "int", index: plan.intDigits.length });
|
|
879
879
|
plan.intDigits.push(tok.c);
|
|
880
880
|
} else if (tok.t === "lit") plan.tokens.push({ r: "lit", v: tok.v });
|
|
@@ -911,21 +911,21 @@ function approximate(x, maxDen) {
|
|
|
911
911
|
var pad = (c) => c === "0" ? "0" : c === "?" ? " " : "";
|
|
912
912
|
function padLeft(s, slots) {
|
|
913
913
|
let prefix = "";
|
|
914
|
-
for (let
|
|
914
|
+
for (let i2 = 0; i2 < slots.length - s.length; i2++) prefix += pad(slots[i2] ?? "#");
|
|
915
915
|
return prefix + s;
|
|
916
916
|
}
|
|
917
917
|
function padRight(s, slots) {
|
|
918
918
|
let suffix = "";
|
|
919
|
-
for (let
|
|
919
|
+
for (let i2 = s.length; i2 < slots.length; i2++) suffix += pad(slots[i2] ?? "#");
|
|
920
920
|
return s + suffix;
|
|
921
921
|
}
|
|
922
922
|
function renderFraction(value2, plan) {
|
|
923
923
|
const x = Math.abs(value2);
|
|
924
924
|
const hasInt = plan.intDigits.length > 0;
|
|
925
925
|
let ip = hasInt ? Math.floor(x) : 0;
|
|
926
|
-
const
|
|
926
|
+
const f6 = x - ip;
|
|
927
927
|
const maxDen = 10 ** Math.max(1, plan.denDigits.length) - 1;
|
|
928
|
-
let [n, d] = plan.fixedDenominator ? [Math.round(
|
|
928
|
+
let [n, d] = plan.fixedDenominator ? [Math.round(f6 * plan.fixedDenominator), plan.fixedDenominator] : approximate(f6, maxDen);
|
|
929
929
|
if (hasInt && n >= d) {
|
|
930
930
|
ip += 1;
|
|
931
931
|
n = 0;
|
|
@@ -937,13 +937,13 @@ function renderFraction(value2, plan) {
|
|
|
937
937
|
const numHash = allHash(plan.numDigits);
|
|
938
938
|
const hideFraction = blank && numHash && (plan.fixedDenominator !== void 0 || allHash(plan.denDigits));
|
|
939
939
|
const dropSeparator = hideFraction || hasInt && intText === "" && numHash;
|
|
940
|
-
const lastInt = plan.tokens.reduce((last, t,
|
|
940
|
+
const lastInt = plan.tokens.reduce((last, t, i2) => t.r === "int" ? i2 : last, -1);
|
|
941
941
|
const firstNum = plan.tokens.findIndex((t) => t.r === "num");
|
|
942
942
|
let text = "";
|
|
943
943
|
let intDone = false;
|
|
944
|
-
plan.tokens.forEach((tok,
|
|
944
|
+
plan.tokens.forEach((tok, i2) => {
|
|
945
945
|
if (tok.r === "lit") {
|
|
946
|
-
if (!(dropSeparator &&
|
|
946
|
+
if (!(dropSeparator && i2 > lastInt && i2 < firstNum)) text += tok.v;
|
|
947
947
|
} else if (tok.r === "int") {
|
|
948
948
|
if (!intDone) text += intText;
|
|
949
949
|
intDone = true;
|
|
@@ -986,16 +986,16 @@ function roundSignificant(v, keep) {
|
|
|
986
986
|
let point = v.point;
|
|
987
987
|
if (roundUp) {
|
|
988
988
|
const chars = head.split("");
|
|
989
|
-
let
|
|
990
|
-
while (
|
|
991
|
-
chars[
|
|
992
|
-
|
|
989
|
+
let i2 = chars.length - 1;
|
|
990
|
+
while (i2 >= 0 && chars[i2] === "9") {
|
|
991
|
+
chars[i2] = "0";
|
|
992
|
+
i2--;
|
|
993
993
|
}
|
|
994
|
-
if (
|
|
994
|
+
if (i2 < 0) {
|
|
995
995
|
chars.unshift("1");
|
|
996
996
|
point++;
|
|
997
997
|
} else {
|
|
998
|
-
chars[
|
|
998
|
+
chars[i2] = String(Number(chars[i2]) + 1);
|
|
999
999
|
}
|
|
1000
1000
|
head = chars.join("");
|
|
1001
1001
|
}
|
|
@@ -1032,7 +1032,7 @@ var isDigit2 = (t) => t?.t === "digit";
|
|
|
1032
1032
|
function compileNumber(tokens) {
|
|
1033
1033
|
const expAt = tokens.findIndex((t) => t.t === "exp");
|
|
1034
1034
|
const end = expAt < 0 ? tokens.length : expAt;
|
|
1035
|
-
let pointAt = tokens.findIndex((t,
|
|
1035
|
+
let pointAt = tokens.findIndex((t, i2) => t.t === "point" && i2 < end);
|
|
1036
1036
|
if (pointAt < 0) pointAt = end;
|
|
1037
1037
|
const intDigits = [];
|
|
1038
1038
|
const fracDigits = [];
|
|
@@ -1046,34 +1046,34 @@ function compileNumber(tokens) {
|
|
|
1046
1046
|
return false;
|
|
1047
1047
|
};
|
|
1048
1048
|
let seenDigit = false;
|
|
1049
|
-
for (let
|
|
1050
|
-
const tok = tokens[
|
|
1049
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
1050
|
+
const tok = tokens[i2];
|
|
1051
1051
|
if (!tok) continue;
|
|
1052
|
-
if (
|
|
1052
|
+
if (i2 === expAt && tok.t === "exp") {
|
|
1053
1053
|
let n = 0;
|
|
1054
|
-
while (isDigit2(tokens[
|
|
1054
|
+
while (isDigit2(tokens[i2 + 1 + n])) n++;
|
|
1055
1055
|
exponent = { plus: tok.plus, digits: n };
|
|
1056
1056
|
out.push({ r: "exp" });
|
|
1057
|
-
|
|
1057
|
+
i2 += n;
|
|
1058
1058
|
continue;
|
|
1059
1059
|
}
|
|
1060
1060
|
switch (tok.t) {
|
|
1061
1061
|
case "digit":
|
|
1062
1062
|
seenDigit = true;
|
|
1063
|
-
if (
|
|
1063
|
+
if (i2 < pointAt) {
|
|
1064
1064
|
out.push({ r: "int", c: tok.c, index: intDigits.length });
|
|
1065
1065
|
intDigits.push(tok.c);
|
|
1066
|
-
} else if (
|
|
1066
|
+
} else if (i2 < end) {
|
|
1067
1067
|
out.push({ r: "frac", c: tok.c, index: fracDigits.length });
|
|
1068
1068
|
fracDigits.push(tok.c);
|
|
1069
1069
|
} else out.push({ r: "lit", v: tok.c });
|
|
1070
1070
|
break;
|
|
1071
1071
|
case "point":
|
|
1072
|
-
out.push(
|
|
1072
|
+
out.push(i2 === pointAt ? { r: "point" } : { r: "lit", v: "." });
|
|
1073
1073
|
break;
|
|
1074
1074
|
case "comma":
|
|
1075
|
-
if (
|
|
1076
|
-
else if (seenDigit &&
|
|
1075
|
+
if (i2 < pointAt && seenDigit && hasIntAfter(i2)) grouping = true;
|
|
1076
|
+
else if (seenDigit && i2 < end) scaleCommas++;
|
|
1077
1077
|
else out.push({ r: "lit", v: "," });
|
|
1078
1078
|
break;
|
|
1079
1079
|
case "percent":
|
|
@@ -1129,11 +1129,11 @@ function placeIntegers(digits2, slots, grouping) {
|
|
|
1129
1129
|
});
|
|
1130
1130
|
}
|
|
1131
1131
|
function placeFraction(digits2, slots) {
|
|
1132
|
-
const out = slots.map((_,
|
|
1133
|
-
for (let
|
|
1134
|
-
const c = slots[
|
|
1135
|
-
if (digits2.charAt(
|
|
1136
|
-
out[
|
|
1132
|
+
const out = slots.map((_, i2) => digits2.charAt(i2));
|
|
1133
|
+
for (let i2 = slots.length - 1; i2 >= 0; i2--) {
|
|
1134
|
+
const c = slots[i2] ?? "0";
|
|
1135
|
+
if (digits2.charAt(i2) !== "0" || c === "0") break;
|
|
1136
|
+
out[i2] = pad2(c);
|
|
1137
1137
|
}
|
|
1138
1138
|
return out;
|
|
1139
1139
|
}
|
|
@@ -1248,21 +1248,21 @@ var PALETTE_56 = [
|
|
|
1248
1248
|
function splitSections(format) {
|
|
1249
1249
|
const sections = [];
|
|
1250
1250
|
let current = "";
|
|
1251
|
-
for (let
|
|
1252
|
-
const ch = format.charAt(
|
|
1251
|
+
for (let i2 = 0; i2 < format.length; i2++) {
|
|
1252
|
+
const ch = format.charAt(i2);
|
|
1253
1253
|
if (ch === '"') {
|
|
1254
|
-
const end = format.indexOf('"',
|
|
1254
|
+
const end = format.indexOf('"', i2 + 1);
|
|
1255
1255
|
const stop = end < 0 ? format.length : end + 1;
|
|
1256
|
-
current += format.slice(
|
|
1257
|
-
|
|
1256
|
+
current += format.slice(i2, stop);
|
|
1257
|
+
i2 = stop - 1;
|
|
1258
1258
|
} else if (ch === "\\" || ch === "_" || ch === "*") {
|
|
1259
|
-
current += format.slice(
|
|
1260
|
-
|
|
1259
|
+
current += format.slice(i2, i2 + 2);
|
|
1260
|
+
i2++;
|
|
1261
1261
|
} else if (ch === "[") {
|
|
1262
|
-
const end = format.indexOf("]",
|
|
1262
|
+
const end = format.indexOf("]", i2 + 1);
|
|
1263
1263
|
const stop = end < 0 ? format.length : end + 1;
|
|
1264
|
-
current += format.slice(
|
|
1265
|
-
|
|
1264
|
+
current += format.slice(i2, stop);
|
|
1265
|
+
i2 = stop - 1;
|
|
1266
1266
|
} else if (ch === ";") {
|
|
1267
1267
|
sections.push(current);
|
|
1268
1268
|
current = "";
|
|
@@ -1295,9 +1295,9 @@ function parseBracket(content) {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
return {};
|
|
1297
1297
|
}
|
|
1298
|
-
function runLength(s,
|
|
1298
|
+
function runLength(s, i2, lowerCh) {
|
|
1299
1299
|
let n = 0;
|
|
1300
|
-
while (
|
|
1300
|
+
while (i2 + n < s.length && s.charAt(i2 + n).toLowerCase() === lowerCh) n++;
|
|
1301
1301
|
return n;
|
|
1302
1302
|
}
|
|
1303
1303
|
function datePartFor(ch, n) {
|
|
@@ -1325,31 +1325,31 @@ function tokenizeSection(src) {
|
|
|
1325
1325
|
if (last?.t === "lit") last.v += v;
|
|
1326
1326
|
else tokens.push({ t: "lit", v });
|
|
1327
1327
|
};
|
|
1328
|
-
for (let
|
|
1329
|
-
const ch = src.charAt(
|
|
1328
|
+
for (let i2 = 0; i2 < src.length; i2++) {
|
|
1329
|
+
const ch = src.charAt(i2);
|
|
1330
1330
|
const lower2 = ch.toLowerCase();
|
|
1331
1331
|
if (ch === '"') {
|
|
1332
|
-
const end = src.indexOf('"',
|
|
1332
|
+
const end = src.indexOf('"', i2 + 1);
|
|
1333
1333
|
const stop = end < 0 ? src.length : end;
|
|
1334
|
-
lit(src.slice(
|
|
1335
|
-
|
|
1334
|
+
lit(src.slice(i2 + 1, stop));
|
|
1335
|
+
i2 = stop;
|
|
1336
1336
|
} else if (ch === "\\") {
|
|
1337
|
-
if (
|
|
1338
|
-
|
|
1337
|
+
if (i2 + 1 < src.length) lit(src.charAt(i2 + 1));
|
|
1338
|
+
i2++;
|
|
1339
1339
|
} else if (ch === "_") {
|
|
1340
1340
|
lit(" ");
|
|
1341
|
-
|
|
1341
|
+
i2++;
|
|
1342
1342
|
} else if (ch === "*") {
|
|
1343
|
-
|
|
1343
|
+
i2++;
|
|
1344
1344
|
} else if (ch === "[") {
|
|
1345
|
-
const end = src.indexOf("]",
|
|
1345
|
+
const end = src.indexOf("]", i2 + 1);
|
|
1346
1346
|
const stop = end < 0 ? src.length : end;
|
|
1347
|
-
const res = parseBracket(src.slice(
|
|
1347
|
+
const res = parseBracket(src.slice(i2 + 1, stop));
|
|
1348
1348
|
if (res.color) color = res.color;
|
|
1349
1349
|
if (res.condition) condition = res.condition;
|
|
1350
1350
|
if (res.token?.t === "lit") lit(res.token.v);
|
|
1351
1351
|
else if (res.token) tokens.push(res.token);
|
|
1352
|
-
|
|
1352
|
+
i2 = stop;
|
|
1353
1353
|
} else if (ch === "0" || ch === "#" || ch === "?") {
|
|
1354
1354
|
tokens.push({ t: "digit", c: ch });
|
|
1355
1355
|
} else if (ch >= "1" && ch <= "9") {
|
|
@@ -1364,26 +1364,26 @@ function tokenizeSection(src) {
|
|
|
1364
1364
|
tokens.push({ t: "slash" });
|
|
1365
1365
|
} else if (ch === "@") {
|
|
1366
1366
|
tokens.push({ t: "text" });
|
|
1367
|
-
} else if (lower2 === "e" && (src.charAt(
|
|
1368
|
-
tokens.push({ t: "exp", plus: src.charAt(
|
|
1369
|
-
|
|
1370
|
-
} else if (lower2 === "g" && src.slice(
|
|
1367
|
+
} else if (lower2 === "e" && (src.charAt(i2 + 1) === "+" || src.charAt(i2 + 1) === "-")) {
|
|
1368
|
+
tokens.push({ t: "exp", plus: src.charAt(i2 + 1) === "+" });
|
|
1369
|
+
i2++;
|
|
1370
|
+
} else if (lower2 === "g" && src.slice(i2, i2 + 7).toLowerCase() === "general") {
|
|
1371
1371
|
tokens.push({ t: "general" });
|
|
1372
|
-
|
|
1373
|
-
} else if (lower2 === "a" && src.slice(
|
|
1372
|
+
i2 += 6;
|
|
1373
|
+
} else if (lower2 === "a" && src.slice(i2, i2 + 5).toUpperCase() === "AM/PM") {
|
|
1374
1374
|
tokens.push({ t: "ampm", kind: "AM/PM" });
|
|
1375
|
-
|
|
1376
|
-
} else if (lower2 === "a" && src.slice(
|
|
1375
|
+
i2 += 4;
|
|
1376
|
+
} else if (lower2 === "a" && src.slice(i2, i2 + 3).toUpperCase() === "A/P") {
|
|
1377
1377
|
tokens.push({ t: "ampm", kind: ch === "A" ? "A/P" : "a/p" });
|
|
1378
|
-
|
|
1378
|
+
i2 += 2;
|
|
1379
1379
|
} else if (lower2 === "e" || lower2 === "g") {
|
|
1380
|
-
const n = runLength(src,
|
|
1380
|
+
const n = runLength(src, i2, lower2);
|
|
1381
1381
|
tokens.push({ t: "date", part: lower2 });
|
|
1382
|
-
|
|
1382
|
+
i2 += n - 1;
|
|
1383
1383
|
} else if ("ymdhsb".includes(lower2)) {
|
|
1384
|
-
const n = runLength(src,
|
|
1384
|
+
const n = runLength(src, i2, lower2);
|
|
1385
1385
|
tokens.push({ t: "date", part: datePartFor(lower2, n) });
|
|
1386
|
-
|
|
1386
|
+
i2 += n - 1;
|
|
1387
1387
|
} else {
|
|
1388
1388
|
lit(ch);
|
|
1389
1389
|
}
|
|
@@ -1409,16 +1409,16 @@ function normalizeDateTokens(tokens) {
|
|
|
1409
1409
|
if (last?.t === "lit") last.v += v;
|
|
1410
1410
|
else out.push({ t: "lit", v });
|
|
1411
1411
|
};
|
|
1412
|
-
for (let
|
|
1413
|
-
const tok = tokens[
|
|
1412
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
1413
|
+
const tok = tokens[i2];
|
|
1414
1414
|
if (!tok) continue;
|
|
1415
1415
|
if (tok.t === "point") {
|
|
1416
1416
|
let n = 0;
|
|
1417
|
-
while (tokens[
|
|
1417
|
+
while (tokens[i2 + 1 + n]?.t === "digit" && tokens[i2 + 1 + n].c === "0")
|
|
1418
1418
|
n++;
|
|
1419
1419
|
if (n > 0) {
|
|
1420
1420
|
out.push({ t: "subsec", digits: n });
|
|
1421
|
-
|
|
1421
|
+
i2 += n;
|
|
1422
1422
|
} else lit(".");
|
|
1423
1423
|
} else if (tok.t === "digit") lit(tok.c);
|
|
1424
1424
|
else if (tok.t === "num") lit(tok.v);
|
|
@@ -1901,8 +1901,8 @@ function scan(section) {
|
|
|
1901
1901
|
let bracket = false;
|
|
1902
1902
|
let lastDigit = -1;
|
|
1903
1903
|
let dot = -1;
|
|
1904
|
-
for (let
|
|
1905
|
-
const ch = section[
|
|
1904
|
+
for (let i2 = 0; i2 < section.length; i2++) {
|
|
1905
|
+
const ch = section[i2] ?? "";
|
|
1906
1906
|
if (quoted) {
|
|
1907
1907
|
if (ch === '"') quoted = false;
|
|
1908
1908
|
continue;
|
|
@@ -1911,11 +1911,11 @@ function scan(section) {
|
|
|
1911
1911
|
if (ch === "]") bracket = false;
|
|
1912
1912
|
continue;
|
|
1913
1913
|
}
|
|
1914
|
-
if (ch === "\\" || ch === "_" || ch === "*")
|
|
1914
|
+
if (ch === "\\" || ch === "_" || ch === "*") i2++;
|
|
1915
1915
|
else if (ch === '"') quoted = true;
|
|
1916
1916
|
else if (ch === "[") bracket = true;
|
|
1917
|
-
else if (ch === "0" || ch === "#" || ch === "?") lastDigit =
|
|
1918
|
-
else if (ch === "." && dot < 0) dot =
|
|
1917
|
+
else if (ch === "0" || ch === "#" || ch === "?") lastDigit = i2;
|
|
1918
|
+
else if (ch === "." && dot < 0) dot = i2;
|
|
1919
1919
|
else if ((ch === "e" || ch === "E") && lastDigit >= 0) break;
|
|
1920
1920
|
}
|
|
1921
1921
|
return { lastDigit, dot: dot >= 0 && dot < lastDigit ? dot : -1 };
|
|
@@ -1970,11 +1970,11 @@ function splitItems(text) {
|
|
|
1970
1970
|
const items = [];
|
|
1971
1971
|
let depth = 0;
|
|
1972
1972
|
let current = "";
|
|
1973
|
-
for (let
|
|
1974
|
-
const ch = text[
|
|
1973
|
+
for (let i2 = 0; i2 < text.length; i2++) {
|
|
1974
|
+
const ch = text[i2] ?? "";
|
|
1975
1975
|
if (ch === "'") {
|
|
1976
|
-
current += ch + (text[
|
|
1977
|
-
|
|
1976
|
+
current += ch + (text[i2 + 1] ?? "");
|
|
1977
|
+
i2++;
|
|
1978
1978
|
continue;
|
|
1979
1979
|
}
|
|
1980
1980
|
if (ch === "[") depth++;
|
|
@@ -2130,38 +2130,38 @@ function readReference(source, at) {
|
|
|
2130
2130
|
return void 0;
|
|
2131
2131
|
}
|
|
2132
2132
|
function readQuoted(source, at) {
|
|
2133
|
-
let
|
|
2133
|
+
let i2 = at + 1;
|
|
2134
2134
|
let name = "";
|
|
2135
|
-
while (
|
|
2136
|
-
const ch = source[
|
|
2135
|
+
while (i2 < source.length) {
|
|
2136
|
+
const ch = source[i2];
|
|
2137
2137
|
if (ch === "'") {
|
|
2138
|
-
if (source[
|
|
2138
|
+
if (source[i2 + 1] === "'") {
|
|
2139
2139
|
name += "'";
|
|
2140
|
-
|
|
2140
|
+
i2 += 2;
|
|
2141
2141
|
continue;
|
|
2142
2142
|
}
|
|
2143
|
-
return { name, length:
|
|
2143
|
+
return { name, length: i2 + 1 - at };
|
|
2144
2144
|
}
|
|
2145
2145
|
name += ch;
|
|
2146
|
-
|
|
2146
|
+
i2++;
|
|
2147
2147
|
}
|
|
2148
2148
|
throw new FormulaError("Unterminated quoted sheet name", at);
|
|
2149
2149
|
}
|
|
2150
2150
|
function readBrackets(source, at) {
|
|
2151
2151
|
let depth = 0;
|
|
2152
|
-
let
|
|
2153
|
-
while (
|
|
2154
|
-
const ch = source[
|
|
2152
|
+
let i2 = at;
|
|
2153
|
+
while (i2 < source.length) {
|
|
2154
|
+
const ch = source[i2];
|
|
2155
2155
|
if (ch === "'") {
|
|
2156
|
-
|
|
2156
|
+
i2 += 2;
|
|
2157
2157
|
continue;
|
|
2158
2158
|
}
|
|
2159
2159
|
if (ch === "[") depth++;
|
|
2160
2160
|
else if (ch === "]") {
|
|
2161
2161
|
depth--;
|
|
2162
|
-
if (depth === 0) return
|
|
2162
|
+
if (depth === 0) return i2 + 1 - at;
|
|
2163
2163
|
}
|
|
2164
|
-
|
|
2164
|
+
i2++;
|
|
2165
2165
|
}
|
|
2166
2166
|
throw new FormulaError("Unterminated structured reference", at);
|
|
2167
2167
|
}
|
|
@@ -2212,22 +2212,22 @@ function numberLiteral(text) {
|
|
|
2212
2212
|
function tokenize(formula) {
|
|
2213
2213
|
const source = formula;
|
|
2214
2214
|
const tokens = [];
|
|
2215
|
-
let
|
|
2216
|
-
if (
|
|
2215
|
+
let i2 = source.startsWith("=") ? 1 : 0;
|
|
2216
|
+
if (i2 === 1) tokens.push({ kind: "ws", text: "=", start: 0 });
|
|
2217
2217
|
const push3 = (token) => {
|
|
2218
2218
|
tokens.push(token);
|
|
2219
|
-
|
|
2219
|
+
i2 = token.start + token.text.length;
|
|
2220
2220
|
};
|
|
2221
|
-
while (
|
|
2222
|
-
const ch = source[
|
|
2223
|
-
const start =
|
|
2221
|
+
while (i2 < source.length) {
|
|
2222
|
+
const ch = source[i2] ?? "";
|
|
2223
|
+
const start = i2;
|
|
2224
2224
|
if (/[ \t\r\n]/.test(ch)) {
|
|
2225
|
-
const m = /^[ \t\r\n]+/.exec(source.slice(
|
|
2225
|
+
const m = /^[ \t\r\n]+/.exec(source.slice(i2));
|
|
2226
2226
|
push3({ kind: "ws", text: m?.[0] ?? ch, start });
|
|
2227
2227
|
continue;
|
|
2228
2228
|
}
|
|
2229
2229
|
if (ch === '"') {
|
|
2230
|
-
let j =
|
|
2230
|
+
let j = i2 + 1;
|
|
2231
2231
|
let value2 = "";
|
|
2232
2232
|
for (; ; ) {
|
|
2233
2233
|
if (j >= source.length) throw new FormulaError("Unterminated string", start);
|
|
@@ -2246,11 +2246,11 @@ function tokenize(formula) {
|
|
|
2246
2246
|
continue;
|
|
2247
2247
|
}
|
|
2248
2248
|
if (ch === "#") {
|
|
2249
|
-
const code = matchError(source,
|
|
2249
|
+
const code = matchError(source, i2);
|
|
2250
2250
|
if (!code) throw new FormulaError(`Unexpected '#'`, start);
|
|
2251
2251
|
push3({
|
|
2252
2252
|
kind: code === "#REF!" ? "ref" : "error",
|
|
2253
|
-
text: source.slice(
|
|
2253
|
+
text: source.slice(i2, i2 + code.length),
|
|
2254
2254
|
start,
|
|
2255
2255
|
value: code
|
|
2256
2256
|
});
|
|
@@ -2269,40 +2269,40 @@ function tokenize(formula) {
|
|
|
2269
2269
|
push3({ kind, text: ch, start });
|
|
2270
2270
|
continue;
|
|
2271
2271
|
}
|
|
2272
|
-
if (ch === "[" && !/^\[\d+\]/.test(source.slice(
|
|
2273
|
-
const length = readBrackets(source,
|
|
2274
|
-
push3({ kind: "structured", text: source.slice(
|
|
2272
|
+
if (ch === "[" && !/^\[\d+\]/.test(source.slice(i2))) {
|
|
2273
|
+
const length = readBrackets(source, i2);
|
|
2274
|
+
push3({ kind: "structured", text: source.slice(i2, i2 + length), start, value: "" });
|
|
2275
2275
|
continue;
|
|
2276
2276
|
}
|
|
2277
2277
|
const prefixed = ch === "'" || ch === "[" || NAME_START.test(ch) || /\d/.test(ch);
|
|
2278
2278
|
if (prefixed) {
|
|
2279
|
-
const prefix = readPrefix(source,
|
|
2279
|
+
const prefix = readPrefix(source, i2);
|
|
2280
2280
|
if (prefix) {
|
|
2281
|
-
push3(readAfterPrefix(source,
|
|
2281
|
+
push3(readAfterPrefix(source, i2 + prefix.length, start, prefix.prefix));
|
|
2282
2282
|
continue;
|
|
2283
2283
|
}
|
|
2284
2284
|
if (ch === "'" || ch === "[") throw new FormulaError("Malformed sheet reference", start);
|
|
2285
2285
|
}
|
|
2286
2286
|
if (/[\d.]/.test(ch) || ch === "$" || NAME_START.test(ch)) {
|
|
2287
|
-
const ref = readReference(source,
|
|
2287
|
+
const ref = readReference(source, i2);
|
|
2288
2288
|
if (ref) {
|
|
2289
|
-
push3(refToken(source, start,
|
|
2289
|
+
push3(refToken(source, start, i2 + ref.length, ref.ref, void 0));
|
|
2290
2290
|
continue;
|
|
2291
2291
|
}
|
|
2292
2292
|
if (/[\d.]/.test(ch)) {
|
|
2293
|
-
const m = NUMBER_RE2.exec(source.slice(
|
|
2293
|
+
const m = NUMBER_RE2.exec(source.slice(i2));
|
|
2294
2294
|
if (!m) throw new FormulaError(`Unexpected '${ch}'`, start);
|
|
2295
2295
|
push3({ kind: "number", text: m[0], start, value: numberLiteral(m[0]) });
|
|
2296
2296
|
continue;
|
|
2297
2297
|
}
|
|
2298
2298
|
if (ch !== "$") {
|
|
2299
|
-
push3(readName(source,
|
|
2299
|
+
push3(readName(source, i2, start, void 0));
|
|
2300
2300
|
continue;
|
|
2301
2301
|
}
|
|
2302
2302
|
}
|
|
2303
|
-
const
|
|
2304
|
-
if (
|
|
2305
|
-
push3({ kind: "op", text:
|
|
2303
|
+
const op2 = OPERATORS.find((o) => source.startsWith(o, i2));
|
|
2304
|
+
if (op2) {
|
|
2305
|
+
push3({ kind: "op", text: op2, start });
|
|
2306
2306
|
continue;
|
|
2307
2307
|
}
|
|
2308
2308
|
throw new FormulaError(`Unexpected character '${ch}'`, start);
|
|
@@ -2864,16 +2864,16 @@ var Matrix = class _Matrix {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
/** Every row, materialising a padded matrix (bounded by `MAX_ARRAY_CELLS`). */
|
|
2866
2866
|
get data() {
|
|
2867
|
-
const
|
|
2868
|
-
if (!
|
|
2867
|
+
const pad4 = this.padding;
|
|
2868
|
+
if (!pad4) return this.dense;
|
|
2869
2869
|
if (this.materialized) return this.materialized;
|
|
2870
|
-
checkArraySize(
|
|
2870
|
+
checkArraySize(pad4.rows, pad4.cols);
|
|
2871
2871
|
const out = [];
|
|
2872
|
-
for (let r = 0; r <
|
|
2872
|
+
for (let r = 0; r < pad4.rows; r++) {
|
|
2873
2873
|
const line2 = [];
|
|
2874
2874
|
const stored = this.dense[r];
|
|
2875
|
-
for (let c = 0; c <
|
|
2876
|
-
line2.push(stored && c < stored.length ? stored[c] :
|
|
2875
|
+
for (let c = 0; c < pad4.cols; c++)
|
|
2876
|
+
line2.push(stored && c < stored.length ? stored[c] : pad4.fill);
|
|
2877
2877
|
out.push(line2);
|
|
2878
2878
|
}
|
|
2879
2879
|
this.materialized = out;
|
|
@@ -2903,8 +2903,8 @@ var Matrix = class _Matrix {
|
|
|
2903
2903
|
get(row2, col) {
|
|
2904
2904
|
const stored = this.dense[row2];
|
|
2905
2905
|
if (stored && col < stored.length) return stored[col] ?? null;
|
|
2906
|
-
const
|
|
2907
|
-
return
|
|
2906
|
+
const pad4 = this.padding;
|
|
2907
|
+
return pad4 && row2 < pad4.rows && col < pad4.cols ? pad4.fill : null;
|
|
2908
2908
|
}
|
|
2909
2909
|
/** Only the stored block of a padded matrix (what a spilling formula shows). */
|
|
2910
2910
|
block() {
|
|
@@ -2926,21 +2926,21 @@ var Matrix = class _Matrix {
|
|
|
2926
2926
|
/** Maps every value; a padded matrix maps its block and its fill once. */
|
|
2927
2927
|
mapValues(fn) {
|
|
2928
2928
|
const block = this.dense.map((line2) => line2.map((value2) => fn(value2)));
|
|
2929
|
-
const
|
|
2930
|
-
return new _Matrix(block,
|
|
2929
|
+
const pad4 = this.padding;
|
|
2930
|
+
return new _Matrix(block, pad4 ? { ...pad4, fill: fn(pad4.fill) } : void 0);
|
|
2931
2931
|
}
|
|
2932
2932
|
/** Visits every value in row-major order without materialising a padded matrix. */
|
|
2933
2933
|
forEachValue(visit2) {
|
|
2934
|
-
const
|
|
2935
|
-
if (!
|
|
2934
|
+
const pad4 = this.padding;
|
|
2935
|
+
if (!pad4) {
|
|
2936
2936
|
for (const line2 of this.dense) for (const v of line2) visit2(v);
|
|
2937
2937
|
return;
|
|
2938
2938
|
}
|
|
2939
|
-
for (let r = 0; r <
|
|
2939
|
+
for (let r = 0; r < pad4.rows; r++) {
|
|
2940
2940
|
const stored = this.dense[r];
|
|
2941
2941
|
const n = stored ? stored.length : 0;
|
|
2942
2942
|
for (let c = 0; c < n; c++) visit2(stored[c] ?? null);
|
|
2943
|
-
for (let c = n; c <
|
|
2943
|
+
for (let c = n; c < pad4.cols; c++) visit2(pad4.fill);
|
|
2944
2944
|
}
|
|
2945
2945
|
}
|
|
2946
2946
|
/** Every element in row-major order. */
|
|
@@ -3066,9 +3066,9 @@ var num = (value2) => toNumber(scalar(value2));
|
|
|
3066
3066
|
var str = (value2) => toText(scalar(value2));
|
|
3067
3067
|
var bool = (value2) => toBool(scalar(value2));
|
|
3068
3068
|
var int = (value2) => Math.trunc(num(value2));
|
|
3069
|
-
var optNum = (args,
|
|
3070
|
-
var optBool = (args,
|
|
3071
|
-
var omitted = (args,
|
|
3069
|
+
var optNum = (args, i2, fallback) => i2 < args.length ? num(args[i2]) : fallback;
|
|
3070
|
+
var optBool = (args, i2, fallback) => i2 < args.length ? bool(args[i2]) : fallback;
|
|
3071
|
+
var omitted = (args, i2) => i2 >= args.length || args[i2] === null;
|
|
3072
3072
|
function collectNumbers(ctx, args, options = {}) {
|
|
3073
3073
|
const out = [];
|
|
3074
3074
|
for (const arg of args) {
|
|
@@ -3098,11 +3098,11 @@ var all = (ctx, args) => collectNumbers(ctx, args, { includeAll: true });
|
|
|
3098
3098
|
var domain = (ok, value2) => ok ? value2 : fail(ERR.NUM);
|
|
3099
3099
|
function wildcardRegex(pattern) {
|
|
3100
3100
|
let source = "";
|
|
3101
|
-
for (let
|
|
3102
|
-
const ch = pattern[
|
|
3103
|
-
if (ch === "~" &&
|
|
3104
|
-
source += escapeRegex(pattern[
|
|
3105
|
-
|
|
3101
|
+
for (let i2 = 0; i2 < pattern.length; i2++) {
|
|
3102
|
+
const ch = pattern[i2] ?? "";
|
|
3103
|
+
if (ch === "~" && i2 + 1 < pattern.length) {
|
|
3104
|
+
source += escapeRegex(pattern[i2 + 1] ?? "");
|
|
3105
|
+
i2++;
|
|
3106
3106
|
} else if (ch === "*") source += "[\\s\\S]*";
|
|
3107
3107
|
else if (ch === "?") source += "[\\s\\S]";
|
|
3108
3108
|
else source += escapeRegex(ch);
|
|
@@ -3119,20 +3119,20 @@ function makeCriteria(criteria) {
|
|
|
3119
3119
|
if (typeof criteria === "boolean") return (value2) => value2 === criteria;
|
|
3120
3120
|
if (criteria === null) return (value2) => value2 === null || value2 === "";
|
|
3121
3121
|
const match2 = /^(<=|>=|<>|<|>|=)?([\s\S]*)$/.exec(criteria);
|
|
3122
|
-
const
|
|
3122
|
+
const op2 = match2?.[1] ?? "";
|
|
3123
3123
|
const operandText = match2?.[2] ?? "";
|
|
3124
3124
|
const asNumber2 = parseNumberText(operandText);
|
|
3125
3125
|
const upper2 = operandText.toUpperCase();
|
|
3126
3126
|
const asBool = upper2 === "TRUE" ? true : upper2 === "FALSE" ? false : void 0;
|
|
3127
3127
|
const errorOperand = /^#/.test(operandText) ? operandText.toUpperCase() : void 0;
|
|
3128
|
-
if (
|
|
3128
|
+
if (op2 === "" || op2 === "=" || op2 === "<>") {
|
|
3129
3129
|
let test;
|
|
3130
3130
|
if (operandText === "") {
|
|
3131
|
-
if (
|
|
3132
|
-
if (
|
|
3131
|
+
if (op2 === "") return (value2) => value2 === null || value2 === "";
|
|
3132
|
+
if (op2 === "=") return (value2) => value2 === null;
|
|
3133
3133
|
return (value2) => value2 !== null;
|
|
3134
3134
|
} else if (asNumber2 !== void 0) {
|
|
3135
|
-
if (
|
|
3135
|
+
if (op2 === "<>")
|
|
3136
3136
|
return (value2) => !(typeof value2 === "number" && compareScalars(value2, asNumber2) === 0);
|
|
3137
3137
|
test = (value2) => typeof value2 === "number" && compareScalars(value2, asNumber2) === 0 || typeof value2 === "string" && parseNumberText(value2) === asNumber2;
|
|
3138
3138
|
} else if (asBool !== void 0) {
|
|
@@ -3146,9 +3146,9 @@ function makeCriteria(criteria) {
|
|
|
3146
3146
|
const lower2 = operandText.toLowerCase();
|
|
3147
3147
|
test = (value2) => typeof value2 === "string" && value2.toLowerCase() === lower2;
|
|
3148
3148
|
}
|
|
3149
|
-
return
|
|
3149
|
+
return op2 === "<>" ? (value2) => !test(value2) : test;
|
|
3150
3150
|
}
|
|
3151
|
-
const sign2 = (c) =>
|
|
3151
|
+
const sign2 = (c) => op2 === "<" ? c < 0 : op2 === ">" ? c > 0 : op2 === "<=" ? c <= 0 : c >= 0;
|
|
3152
3152
|
if (asNumber2 !== void 0) {
|
|
3153
3153
|
return (value2) => typeof value2 === "number" && sign2(compareScalars(value2, asNumber2));
|
|
3154
3154
|
}
|
|
@@ -3166,9 +3166,9 @@ function spec(name, category, syntax, description, minArgs, maxArgs, fn, params,
|
|
|
3166
3166
|
function numeric(name, category, syntax, description, minArgs, maxArgs, fn, defaults = []) {
|
|
3167
3167
|
return spec(name, category, syntax, description, minArgs, maxArgs, (args) => {
|
|
3168
3168
|
const values2 = [];
|
|
3169
|
-
for (let
|
|
3170
|
-
if (
|
|
3171
|
-
else if (defaults[
|
|
3169
|
+
for (let i2 = 0; i2 < maxArgs; i2++) {
|
|
3170
|
+
if (i2 < args.length) values2.push(num(args[i2]));
|
|
3171
|
+
else if (defaults[i2] !== void 0) values2.push(defaults[i2]);
|
|
3172
3172
|
}
|
|
3173
3173
|
const result2 = fn(...values2);
|
|
3174
3174
|
return typeof result2 === "number" ? finite(result2) : result2;
|
|
@@ -3177,7 +3177,7 @@ function numeric(name, category, syntax, description, minArgs, maxArgs, fn, defa
|
|
|
3177
3177
|
|
|
3178
3178
|
// xlsx/formula/functions/array-shape.ts
|
|
3179
3179
|
var C = "Lookup & Reference";
|
|
3180
|
-
var intAt = (ctx, args,
|
|
3180
|
+
var intAt = (ctx, args, i2) => i2 < args.length && args[i2] !== null ? Math.trunc(num(ctx.toScalar(args[i2] ?? null))) : void 0;
|
|
3181
3181
|
function take(m, rows2, cols, drop) {
|
|
3182
3182
|
const slice = (length, n) => {
|
|
3183
3183
|
if (n === void 0) return [0, length];
|
|
@@ -3191,9 +3191,9 @@ function take(m, rows2, cols, drop) {
|
|
|
3191
3191
|
return new Matrix(m.data.slice(r1, r2).map((row2) => row2.slice(c1, c2)));
|
|
3192
3192
|
}
|
|
3193
3193
|
function choose(indexes2, length) {
|
|
3194
|
-
return indexes2.map((
|
|
3195
|
-
const at =
|
|
3196
|
-
if (
|
|
3194
|
+
return indexes2.map((i2) => {
|
|
3195
|
+
const at = i2 < 0 ? length + i2 : i2 - 1;
|
|
3196
|
+
if (i2 === 0 || at < 0 || at >= length) fail(ERR.VALUE);
|
|
3197
3197
|
return at;
|
|
3198
3198
|
});
|
|
3199
3199
|
}
|
|
@@ -3214,7 +3214,7 @@ function stack(ctx, args, vertical2) {
|
|
|
3214
3214
|
)
|
|
3215
3215
|
);
|
|
3216
3216
|
}
|
|
3217
|
-
const height = parts.reduce((
|
|
3217
|
+
const height = parts.reduce((h2, p) => Math.max(h2, p.rows), 0);
|
|
3218
3218
|
return Matrix.build(
|
|
3219
3219
|
height,
|
|
3220
3220
|
parts.reduce((a, p) => a + p.cols, 0),
|
|
@@ -3251,9 +3251,9 @@ function wrap(ctx, args, byRows) {
|
|
|
3251
3251
|
const flat = values2.flat();
|
|
3252
3252
|
const count2 = intAt(ctx, args, 1) ?? 0;
|
|
3253
3253
|
if (count2 < 1) return ERR.NUM;
|
|
3254
|
-
const
|
|
3254
|
+
const pad4 = args.length > 2 ? ctx.toScalar(args[2] ?? null) : ERR.NA;
|
|
3255
3255
|
const other = Math.ceil(flat.length / count2);
|
|
3256
|
-
return byRows ? Matrix.build(other, count2, (r, c) => flat[r * count2 + c] ??
|
|
3256
|
+
return byRows ? Matrix.build(other, count2, (r, c) => flat[r * count2 + c] ?? pad4) : Matrix.build(count2, other, (r, c) => flat[c * count2 + r] ?? pad4);
|
|
3257
3257
|
}
|
|
3258
3258
|
var ARRAY_SHAPE_FUNCTIONS = [
|
|
3259
3259
|
spec(
|
|
@@ -3382,8 +3382,8 @@ var ARRAY_SHAPE_FUNCTIONS = [
|
|
|
3382
3382
|
const cols = intAt(ctx, args, 2) ?? m.cols;
|
|
3383
3383
|
if (rows2 < m.rows || cols < m.cols) return ERR.VALUE;
|
|
3384
3384
|
if (rows2 > MAX_ARRAY_SIDE || cols > MAX_ARRAY_SIDE) return ERR.NUM;
|
|
3385
|
-
const
|
|
3386
|
-
return Matrix.build(rows2, cols, (r, c) => r < m.rows && c < m.cols ? m.get(r, c) :
|
|
3385
|
+
const pad4 = args.length > 3 ? ctx.toScalar(args[3] ?? null) : ERR.NA;
|
|
3386
|
+
return Matrix.build(rows2, cols, (r, c) => r < m.rows && c < m.cols ? m.get(r, c) : pad4);
|
|
3387
3387
|
},
|
|
3388
3388
|
["any"]
|
|
3389
3389
|
)
|
|
@@ -3400,7 +3400,7 @@ function sortCompare(a, b, descending) {
|
|
|
3400
3400
|
else c = compareScalars(a, b);
|
|
3401
3401
|
return descending ? -c : c;
|
|
3402
3402
|
}
|
|
3403
|
-
var optInt = (ctx, args,
|
|
3403
|
+
var optInt = (ctx, args, i2, fallback) => i2 < args.length && args[i2] !== null ? Math.trunc(num(ctx.toScalar(args[i2] ?? null))) : fallback;
|
|
3404
3404
|
function transpose(m) {
|
|
3405
3405
|
return Matrix.build(m.cols, m.rows, (r, c) => m.get(c, r));
|
|
3406
3406
|
}
|
|
@@ -3435,7 +3435,7 @@ function filter(args, ctx) {
|
|
|
3435
3435
|
return out;
|
|
3436
3436
|
}
|
|
3437
3437
|
function sortRows(rows2, keys) {
|
|
3438
|
-
const order = rows2.map((_,
|
|
3438
|
+
const order = rows2.map((_, i2) => i2);
|
|
3439
3439
|
order.sort((x, y) => {
|
|
3440
3440
|
for (const key of keys) {
|
|
3441
3441
|
const c = sortCompare(key.values[x] ?? null, key.values[y] ?? null, key.descending);
|
|
@@ -3443,7 +3443,7 @@ function sortRows(rows2, keys) {
|
|
|
3443
3443
|
}
|
|
3444
3444
|
return x - y;
|
|
3445
3445
|
});
|
|
3446
|
-
return order.map((
|
|
3446
|
+
return order.map((i2) => rows2[i2] ?? []);
|
|
3447
3447
|
}
|
|
3448
3448
|
function sort(args, ctx) {
|
|
3449
3449
|
let m = ctx.toMatrix(args[0] ?? null);
|
|
@@ -3464,9 +3464,9 @@ function sortBy(args, ctx) {
|
|
|
3464
3464
|
const m = ctx.toMatrix(args[0] ?? null);
|
|
3465
3465
|
const keys = [];
|
|
3466
3466
|
let byCol;
|
|
3467
|
-
for (let
|
|
3468
|
-
const by = ctx.toMatrix(args[
|
|
3469
|
-
const order =
|
|
3467
|
+
for (let i2 = 1; i2 < args.length; i2 += 2) {
|
|
3468
|
+
const by = ctx.toMatrix(args[i2] ?? null);
|
|
3469
|
+
const order = i2 + 1 < args.length && args[i2 + 1] !== null ? num(ctx.toScalar(args[i2 + 1] ?? null)) : 1;
|
|
3470
3470
|
if (order !== 1 && order !== -1) fail(ERR.VALUE);
|
|
3471
3471
|
const column = by.cols === 1 && by.rows === m.rows;
|
|
3472
3472
|
const row2 = by.rows === 1 && by.cols === m.cols;
|
|
@@ -3657,22 +3657,22 @@ function extreme(values2, max) {
|
|
|
3657
3657
|
function percentileInc(values2, p) {
|
|
3658
3658
|
if (values2.length === 0 || p < 0 || p > 1) fail(ERR.NUM);
|
|
3659
3659
|
const s = sorted(values2);
|
|
3660
|
-
const
|
|
3661
|
-
const lo = Math.floor(
|
|
3660
|
+
const h2 = (s.length - 1) * p;
|
|
3661
|
+
const lo = Math.floor(h2);
|
|
3662
3662
|
const a = s[lo];
|
|
3663
3663
|
const b = s[Math.min(lo + 1, s.length - 1)];
|
|
3664
|
-
return a + (
|
|
3664
|
+
return a + (h2 - lo) * (b - a);
|
|
3665
3665
|
}
|
|
3666
3666
|
function percentileExc(values2, p) {
|
|
3667
3667
|
const n = values2.length;
|
|
3668
3668
|
if (n === 0 || p <= 0 || p >= 1) fail(ERR.NUM);
|
|
3669
|
-
const
|
|
3670
|
-
if (
|
|
3669
|
+
const h2 = (n + 1) * p;
|
|
3670
|
+
if (h2 < 1 || h2 > n) fail(ERR.NUM);
|
|
3671
3671
|
const s = sorted(values2);
|
|
3672
|
-
const lo = Math.floor(
|
|
3672
|
+
const lo = Math.floor(h2);
|
|
3673
3673
|
const a = s[lo - 1];
|
|
3674
3674
|
const b = s[Math.min(lo, n - 1)];
|
|
3675
|
-
return a + (
|
|
3675
|
+
return a + (h2 - lo) * (b - a);
|
|
3676
3676
|
}
|
|
3677
3677
|
function quartile(values2, q, exclusive) {
|
|
3678
3678
|
const quart = Math.trunc(q);
|
|
@@ -3711,7 +3711,7 @@ function covariance(xs, ys, sample) {
|
|
|
3711
3711
|
const mx = mean(xs);
|
|
3712
3712
|
const my = mean(ys);
|
|
3713
3713
|
let total2 = 0;
|
|
3714
|
-
for (let
|
|
3714
|
+
for (let i2 = 0; i2 < n; i2++) total2 += (xs[i2] - mx) * (ys[i2] - my);
|
|
3715
3715
|
return total2 / (sample ? n - 1 : n);
|
|
3716
3716
|
}
|
|
3717
3717
|
function correlation(xs, ys) {
|
|
@@ -3727,9 +3727,9 @@ function linearFit(xs, ys) {
|
|
|
3727
3727
|
const my = mean(ys);
|
|
3728
3728
|
let sxy = 0;
|
|
3729
3729
|
let sxx = 0;
|
|
3730
|
-
for (let
|
|
3731
|
-
const dx = xs[
|
|
3732
|
-
sxy += dx * (ys[
|
|
3730
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
3731
|
+
const dx = xs[i2] - mx;
|
|
3732
|
+
sxy += dx * (ys[i2] - my);
|
|
3733
3733
|
sxx += dx * dx;
|
|
3734
3734
|
}
|
|
3735
3735
|
if (sxx === 0) fail(ERR.DIV0);
|
|
@@ -3761,7 +3761,7 @@ function gamma(z) {
|
|
|
3761
3761
|
const x = z - 1;
|
|
3762
3762
|
let a = 0.9999999999998099;
|
|
3763
3763
|
const t = x + 7.5;
|
|
3764
|
-
for (let
|
|
3764
|
+
for (let i2 = 0; i2 < LANCZOS.length; i2++) a += LANCZOS[i2] / (x + i2 + 1);
|
|
3765
3765
|
return Math.sqrt(2 * Math.PI) * Math.pow(t, x + 0.5) * Math.exp(-t) * a;
|
|
3766
3766
|
}
|
|
3767
3767
|
function gammaLn(z) {
|
|
@@ -3770,7 +3770,7 @@ function gammaLn(z) {
|
|
|
3770
3770
|
const x = z - 1;
|
|
3771
3771
|
let a = 0.9999999999998099;
|
|
3772
3772
|
const t = x + 7.5;
|
|
3773
|
-
for (let
|
|
3773
|
+
for (let i2 = 0; i2 < LANCZOS.length; i2++) a += LANCZOS[i2] / (x + i2 + 1);
|
|
3774
3774
|
return 0.5 * Math.log(2 * Math.PI) + (x + 0.5) * Math.log(t) - t + Math.log(a);
|
|
3775
3775
|
}
|
|
3776
3776
|
|
|
@@ -3884,7 +3884,7 @@ function weekendDays(value2) {
|
|
|
3884
3884
|
if (typeof v === "string") {
|
|
3885
3885
|
if (!/^[01]{7}$/.test(v)) fail(ERR.VALUE);
|
|
3886
3886
|
const days = /* @__PURE__ */ new Set();
|
|
3887
|
-
for (let
|
|
3887
|
+
for (let i2 = 0; i2 < 7; i2++) if (v[i2] === "1") days.add((i2 + 1) % 7);
|
|
3888
3888
|
return days;
|
|
3889
3889
|
}
|
|
3890
3890
|
const code = Math.trunc(num(v));
|
|
@@ -4237,11 +4237,11 @@ var DATETIME_FUNCTIONS = [
|
|
|
4237
4237
|
3,
|
|
4238
4238
|
3,
|
|
4239
4239
|
(args) => {
|
|
4240
|
-
const
|
|
4240
|
+
const h2 = Math.trunc(num(args[0]));
|
|
4241
4241
|
const m = Math.trunc(num(args[1]));
|
|
4242
4242
|
const s = Math.trunc(num(args[2]));
|
|
4243
|
-
if (
|
|
4244
|
-
const total2 =
|
|
4243
|
+
if (h2 > 32767 || m > 32767 || s > 32767) fail(ERR.NUM);
|
|
4244
|
+
const total2 = h2 * 3600 + m * 60 + s;
|
|
4245
4245
|
if (total2 < 0) fail(ERR.NUM);
|
|
4246
4246
|
return total2 % 86400 / 86400;
|
|
4247
4247
|
}
|
|
@@ -4393,11 +4393,11 @@ function digits(n) {
|
|
|
4393
4393
|
}
|
|
4394
4394
|
function formatComplex({ re, im, suffix }) {
|
|
4395
4395
|
const r = Math.abs(re) < 1e-15 * Math.max(1, Math.abs(im)) ? 0 : re;
|
|
4396
|
-
const
|
|
4397
|
-
if (
|
|
4398
|
-
const imaginary =
|
|
4396
|
+
const i2 = Math.abs(im) < 1e-15 * Math.max(1, Math.abs(re)) ? 0 : im;
|
|
4397
|
+
if (i2 === 0) return digits(r);
|
|
4398
|
+
const imaginary = i2 === 1 ? suffix : i2 === -1 ? `-${suffix}` : `${digits(i2)}${suffix}`;
|
|
4399
4399
|
if (r === 0) return imaginary;
|
|
4400
|
-
return `${digits(r)}${
|
|
4400
|
+
return `${digits(r)}${i2 > 0 ? "+" : ""}${imaginary}`;
|
|
4401
4401
|
}
|
|
4402
4402
|
var make = (re, im, suffix) => ({ re, im, suffix });
|
|
4403
4403
|
var modulus = (z) => Math.hypot(z.re, z.im);
|
|
@@ -4410,7 +4410,7 @@ function divide(a, b) {
|
|
|
4410
4410
|
}
|
|
4411
4411
|
function integerPower(z, n) {
|
|
4412
4412
|
let result2 = one(z);
|
|
4413
|
-
for (let
|
|
4413
|
+
for (let i2 = 0; i2 < Math.abs(n); i2++)
|
|
4414
4414
|
result2 = make(
|
|
4415
4415
|
result2.re * z.re - result2.im * z.im,
|
|
4416
4416
|
result2.re * z.im + result2.im * z.re,
|
|
@@ -4806,9 +4806,9 @@ var bitArg = (value2) => {
|
|
|
4806
4806
|
if (n < 0 || n >= 2 ** 48 || !Number.isInteger(n)) fail(ERR.NUM);
|
|
4807
4807
|
return n;
|
|
4808
4808
|
};
|
|
4809
|
-
var bitwise = (a, b,
|
|
4810
|
-
const hi =
|
|
4811
|
-
const lo =
|
|
4809
|
+
var bitwise = (a, b, op2) => {
|
|
4810
|
+
const hi = op2(Math.floor(a / 2 ** 24), Math.floor(b / 2 ** 24));
|
|
4811
|
+
const lo = op2(a % 2 ** 24, b % 2 ** 24);
|
|
4812
4812
|
return hi * 2 ** 24 + lo;
|
|
4813
4813
|
};
|
|
4814
4814
|
var ENGINEERING_FUNCTIONS = [
|
|
@@ -4902,9 +4902,9 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
4902
4902
|
if (!/^[MDCLXVI]*$/.test(body2)) fail(ERR.VALUE);
|
|
4903
4903
|
const value2 = { M: 1e3, D: 500, C: 100, L: 50, X: 10, V: 5, I: 1 };
|
|
4904
4904
|
let total2 = 0;
|
|
4905
|
-
for (let
|
|
4906
|
-
const cur = value2[body2[
|
|
4907
|
-
const next = value2[body2[
|
|
4905
|
+
for (let i2 = 0; i2 < body2.length; i2++) {
|
|
4906
|
+
const cur = value2[body2[i2] ?? ""] ?? 0;
|
|
4907
|
+
const next = value2[body2[i2 + 1] ?? ""] ?? 0;
|
|
4908
4908
|
total2 += cur < next ? -cur : cur;
|
|
4909
4909
|
}
|
|
4910
4910
|
return negative ? -total2 : total2;
|
|
@@ -4991,38 +4991,38 @@ var security = (name, description, pick2) => spec(
|
|
|
4991
4991
|
)
|
|
4992
4992
|
);
|
|
4993
4993
|
var COUPON_FUNCTIONS = [
|
|
4994
|
-
security("COUPPCD", "The coupon date before the settlement date.", (
|
|
4995
|
-
security("COUPNCD", "The coupon date after the settlement date.", (
|
|
4996
|
-
security("COUPNUM", "The number of coupons between settlement and maturity.", (
|
|
4994
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f6) => f6.previous),
|
|
4995
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f6) => f6.next),
|
|
4996
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f6) => f6.count),
|
|
4997
4997
|
security(
|
|
4998
4998
|
"COUPDAYBS",
|
|
4999
4999
|
"The days from the start of the coupon period to settlement.",
|
|
5000
|
-
(
|
|
5000
|
+
(f6) => f6.daysSincePrevious
|
|
5001
5001
|
),
|
|
5002
5002
|
security(
|
|
5003
5003
|
"COUPDAYS",
|
|
5004
5004
|
"The days in the coupon period that contains the settlement date.",
|
|
5005
|
-
(
|
|
5005
|
+
(f6) => f6.daysInPeriod
|
|
5006
5006
|
),
|
|
5007
|
-
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (
|
|
5007
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f6) => f6.daysToNext)
|
|
5008
5008
|
];
|
|
5009
5009
|
|
|
5010
5010
|
// xlsx/formula/functions/financial-core.ts
|
|
5011
5011
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
5012
5012
|
if (nper === 0) fail(ERR.NUM);
|
|
5013
5013
|
if (rate === 0) return -(pv2 + fv2) / nper;
|
|
5014
|
-
const
|
|
5015
|
-
return -rate * (fv2 + pv2 *
|
|
5014
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5015
|
+
return -rate * (fv2 + pv2 * f6) / ((1 + rate * type) * (f6 - 1));
|
|
5016
5016
|
}
|
|
5017
5017
|
function fv(rate, nper, payment, pv2 = 0, type = 0) {
|
|
5018
5018
|
if (rate === 0) return -(pv2 + payment * nper);
|
|
5019
|
-
const
|
|
5020
|
-
return -(pv2 *
|
|
5019
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5020
|
+
return -(pv2 * f6 + payment * (1 + rate * type) * (f6 - 1) / rate);
|
|
5021
5021
|
}
|
|
5022
5022
|
function pv(rate, nper, payment, future = 0, type = 0) {
|
|
5023
5023
|
if (rate === 0) return -(future + payment * nper);
|
|
5024
|
-
const
|
|
5025
|
-
return -(future + payment * (1 + rate * type) * (
|
|
5024
|
+
const f6 = Math.pow(1 + rate, nper);
|
|
5025
|
+
return -(future + payment * (1 + rate * type) * (f6 - 1) / rate) / f6;
|
|
5026
5026
|
}
|
|
5027
5027
|
function ipmt(rate, per, nper, present, future = 0, type = 0) {
|
|
5028
5028
|
if (per < 1 || per > nper) fail(ERR.NUM);
|
|
@@ -5033,14 +5033,14 @@ function ipmt(rate, per, nper, present, future = 0, type = 0) {
|
|
|
5033
5033
|
interest = type === 1 ? fv(rate, per - 2, payment, present, 1) - payment : fv(rate, per - 1, payment, present, 0);
|
|
5034
5034
|
return interest * rate;
|
|
5035
5035
|
}
|
|
5036
|
-
function solve(
|
|
5036
|
+
function solve(f6, guess) {
|
|
5037
5037
|
let x = guess;
|
|
5038
|
-
for (let
|
|
5039
|
-
const y =
|
|
5038
|
+
for (let i2 = 0; i2 < 100; i2++) {
|
|
5039
|
+
const y = f6(x);
|
|
5040
5040
|
if (!Number.isFinite(y)) break;
|
|
5041
5041
|
if (y === 0) return x;
|
|
5042
|
-
const
|
|
5043
|
-
const slope = (
|
|
5042
|
+
const h2 = Math.max(1e-9, Math.abs(x) * 1e-9);
|
|
5043
|
+
const slope = (f6(x + h2) - f6(x - h2)) / (2 * h2);
|
|
5044
5044
|
if (slope === 0 || !Number.isFinite(slope)) break;
|
|
5045
5045
|
const next = x - y / slope;
|
|
5046
5046
|
if (Math.abs(next - x) <= 1e-14 * Math.max(1, Math.abs(next))) return next;
|
|
@@ -5049,11 +5049,11 @@ function solve(f, guess) {
|
|
|
5049
5049
|
}
|
|
5050
5050
|
let lo = -0.999999;
|
|
5051
5051
|
let hi = 10;
|
|
5052
|
-
let flo =
|
|
5053
|
-
if (!Number.isFinite(flo) || flo *
|
|
5054
|
-
for (let
|
|
5052
|
+
let flo = f6(lo);
|
|
5053
|
+
if (!Number.isFinite(flo) || flo * f6(hi) > 0) fail(ERR.NUM);
|
|
5054
|
+
for (let i2 = 0; i2 < 300; i2++) {
|
|
5055
5055
|
const mid = (lo + hi) / 2;
|
|
5056
|
-
const fm =
|
|
5056
|
+
const fm = f6(mid);
|
|
5057
5057
|
if (Math.abs(fm) < 1e-10) return mid;
|
|
5058
5058
|
if (fm * flo < 0) hi = mid;
|
|
5059
5059
|
else {
|
|
@@ -5146,8 +5146,8 @@ function accruedInterest(args, ctx) {
|
|
|
5146
5146
|
const dates = quasiPeriods(first2, start, settlement, frequency2, ctx);
|
|
5147
5147
|
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
5148
5148
|
let sum2 = 0;
|
|
5149
|
-
for (let
|
|
5150
|
-
const [p, q] = [dates[
|
|
5149
|
+
for (let i2 = 0; i2 + 1 < dates.length; i2++) {
|
|
5150
|
+
const [p, q] = [dates[i2], dates[i2 + 1]];
|
|
5151
5151
|
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
5152
5152
|
if (a <= 0) continue;
|
|
5153
5153
|
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
@@ -5182,8 +5182,8 @@ var BOND_FUNCTIONS = [
|
|
|
5182
5182
|
const bond = bondOf(args, ctx, 4, 6);
|
|
5183
5183
|
const price = num(args[3]);
|
|
5184
5184
|
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
5185
|
-
const
|
|
5186
|
-
return solve(
|
|
5185
|
+
const f6 = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
5186
|
+
return solve(f6, bond.rate || 0.05);
|
|
5187
5187
|
}
|
|
5188
5188
|
),
|
|
5189
5189
|
...["DURATION", "MDURATION"].map(
|
|
@@ -5314,9 +5314,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5314
5314
|
"Double-declining balance depreciation.",
|
|
5315
5315
|
4,
|
|
5316
5316
|
5,
|
|
5317
|
-
(c, s = 0, l = 1, p = 1,
|
|
5318
|
-
if (c < 0 || s < 0 || l <= 0 || p <= 0 || p > l ||
|
|
5319
|
-
const rate = Math.min(
|
|
5317
|
+
(c, s = 0, l = 1, p = 1, f6 = 2) => {
|
|
5318
|
+
if (c < 0 || s < 0 || l <= 0 || p <= 0 || p > l || f6 <= 0) fail(ERR.NUM);
|
|
5319
|
+
const rate = Math.min(f6 / l, 1);
|
|
5320
5320
|
const book = c * Math.pow(1 - rate, Math.max(0, p - 1));
|
|
5321
5321
|
return Math.max(0, Math.min(book * rate, book - s));
|
|
5322
5322
|
}
|
|
@@ -5329,7 +5329,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5329
5329
|
5,
|
|
5330
5330
|
7,
|
|
5331
5331
|
(args) => {
|
|
5332
|
-
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((
|
|
5332
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i2) => num(args[i2]));
|
|
5333
5333
|
const factor = args.length > 5 && args[5] !== null ? num(args[5]) : 2;
|
|
5334
5334
|
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
5335
5335
|
if ([cost, salvage, life, start, end, factor].some((v) => v === void 0 || Number.isNaN(v)) || cost < 0 || salvage < 0 || life <= 0 || start < 0 || end < start || end > life || factor <= 0)
|
|
@@ -5427,9 +5427,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5427
5427
|
"Periods required to reach a value.",
|
|
5428
5428
|
3,
|
|
5429
5429
|
3,
|
|
5430
|
-
(r, p = 0,
|
|
5431
|
-
if (r <= 0 || p <= 0 ||
|
|
5432
|
-
return (Math.log(
|
|
5430
|
+
(r, p = 0, f6 = 0) => {
|
|
5431
|
+
if (r <= 0 || p <= 0 || f6 <= 0) fail(ERR.NUM);
|
|
5432
|
+
return (Math.log(f6) - Math.log(p)) / Math.log(1 + r);
|
|
5433
5433
|
}
|
|
5434
5434
|
),
|
|
5435
5435
|
numeric(
|
|
@@ -5439,9 +5439,9 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5439
5439
|
"An equivalent interest rate for growth.",
|
|
5440
5440
|
3,
|
|
5441
5441
|
3,
|
|
5442
|
-
(n, p = 0,
|
|
5442
|
+
(n, p = 0, f6 = 0) => {
|
|
5443
5443
|
if (n <= 0 || p === 0) fail(ERR.NUM);
|
|
5444
|
-
return Math.pow(
|
|
5444
|
+
return Math.pow(f6 / p, 1 / n) - 1;
|
|
5445
5445
|
}
|
|
5446
5446
|
),
|
|
5447
5447
|
spec(
|
|
@@ -5461,8 +5461,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5461
5461
|
"Converts a fractional price to a decimal.",
|
|
5462
5462
|
2,
|
|
5463
5463
|
2,
|
|
5464
|
-
(d,
|
|
5465
|
-
const frac = Math.trunc(
|
|
5464
|
+
(d, f6) => {
|
|
5465
|
+
const frac = Math.trunc(f6 ?? 0);
|
|
5466
5466
|
if (frac < 0) fail(ERR.NUM);
|
|
5467
5467
|
if (frac === 0) fail(ERR.DIV0);
|
|
5468
5468
|
const digits2 = Math.ceil(Math.log10(frac));
|
|
@@ -5477,8 +5477,8 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
5477
5477
|
"Converts a decimal price to a fraction.",
|
|
5478
5478
|
2,
|
|
5479
5479
|
2,
|
|
5480
|
-
(d,
|
|
5481
|
-
const frac = Math.trunc(
|
|
5480
|
+
(d, f6) => {
|
|
5481
|
+
const frac = Math.trunc(f6 ?? 0);
|
|
5482
5482
|
if (frac < 0) fail(ERR.NUM);
|
|
5483
5483
|
if (frac === 0) fail(ERR.DIV0);
|
|
5484
5484
|
const digits2 = Math.ceil(Math.log10(frac));
|
|
@@ -5534,31 +5534,31 @@ var SECURITY_FUNCTIONS = [
|
|
|
5534
5534
|
"DISC",
|
|
5535
5535
|
"The discount rate of a security.",
|
|
5536
5536
|
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
5537
|
-
(pr, redemption,
|
|
5537
|
+
(pr, redemption, f6) => (redemption - pr) / redemption / f6
|
|
5538
5538
|
),
|
|
5539
5539
|
discount(
|
|
5540
5540
|
"PRICEDISC",
|
|
5541
5541
|
"The price per 100 face value of a discounted security.",
|
|
5542
5542
|
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
5543
|
-
(rate, redemption,
|
|
5543
|
+
(rate, redemption, f6) => redemption - rate * redemption * f6
|
|
5544
5544
|
),
|
|
5545
5545
|
discount(
|
|
5546
5546
|
"YIELDDISC",
|
|
5547
5547
|
"The annual yield of a discounted security.",
|
|
5548
5548
|
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
5549
|
-
(pr, redemption,
|
|
5549
|
+
(pr, redemption, f6) => (redemption - pr) / pr / f6
|
|
5550
5550
|
),
|
|
5551
5551
|
discount(
|
|
5552
5552
|
"INTRATE",
|
|
5553
5553
|
"The interest rate of a fully invested security.",
|
|
5554
5554
|
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
5555
|
-
(investment, redemption,
|
|
5555
|
+
(investment, redemption, f6) => (redemption - investment) / investment / f6
|
|
5556
5556
|
),
|
|
5557
5557
|
discount(
|
|
5558
5558
|
"RECEIVED",
|
|
5559
5559
|
"The amount received at maturity for a fully invested security.",
|
|
5560
5560
|
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
5561
|
-
(investment, rate,
|
|
5561
|
+
(investment, rate, f6) => investment / (1 - rate * f6)
|
|
5562
5562
|
),
|
|
5563
5563
|
atMaturity(
|
|
5564
5564
|
"PRICEMAT",
|
|
@@ -5623,7 +5623,7 @@ var SECURITY_FUNCTIONS = [
|
|
|
5623
5623
|
|
|
5624
5624
|
// xlsx/formula/functions/financial.ts
|
|
5625
5625
|
var C12 = "Financial";
|
|
5626
|
-
var npv = (rate, values2) => values2.reduce((acc, v,
|
|
5626
|
+
var npv = (rate, values2) => values2.reduce((acc, v, i2) => acc + v / Math.pow(1 + rate, i2 + 1), 0);
|
|
5627
5627
|
function datedFlows(ctx, args) {
|
|
5628
5628
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
5629
5629
|
const dates = collectNumbers(ctx, [args[1] ?? null]).map(Math.floor);
|
|
@@ -5633,7 +5633,7 @@ function datedFlows(ctx, args) {
|
|
|
5633
5633
|
return { values: values2, dates };
|
|
5634
5634
|
}
|
|
5635
5635
|
var xnpv = (rate, values2, dates) => values2.reduce(
|
|
5636
|
-
(acc, v,
|
|
5636
|
+
(acc, v, i2) => acc + v / Math.pow(1 + rate, (dates[i2] - dates[0]) / 365),
|
|
5637
5637
|
0
|
|
5638
5638
|
);
|
|
5639
5639
|
var FINANCIAL_FUNCTIONS = [
|
|
@@ -5649,7 +5649,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5649
5649
|
"The payment for a loan.",
|
|
5650
5650
|
3,
|
|
5651
5651
|
5,
|
|
5652
|
-
(r, n, p,
|
|
5652
|
+
(r, n, p, f6, t) => pmt(r, n ?? 0, p ?? 0, f6, t)
|
|
5653
5653
|
),
|
|
5654
5654
|
numeric(
|
|
5655
5655
|
"FV",
|
|
@@ -5667,7 +5667,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5667
5667
|
"The present value of an investment.",
|
|
5668
5668
|
3,
|
|
5669
5669
|
5,
|
|
5670
|
-
(r, n, p,
|
|
5670
|
+
(r, n, p, f6, t) => pv(r, n ?? 0, p ?? 0, f6, t)
|
|
5671
5671
|
),
|
|
5672
5672
|
numeric(
|
|
5673
5673
|
"NPER",
|
|
@@ -5676,11 +5676,11 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5676
5676
|
"The number of periods for an investment.",
|
|
5677
5677
|
3,
|
|
5678
5678
|
5,
|
|
5679
|
-
(r, p, v,
|
|
5679
|
+
(r, p, v, f6 = 0, t = 0) => {
|
|
5680
5680
|
const payment = p ?? 0;
|
|
5681
5681
|
const present = v ?? 0;
|
|
5682
|
-
if (r === 0) return payment === 0 ? fail(ERR.NUM) : -(present +
|
|
5683
|
-
const num1 = payment * (1 + r * t) -
|
|
5682
|
+
if (r === 0) return payment === 0 ? fail(ERR.NUM) : -(present + f6) / payment;
|
|
5683
|
+
const num1 = payment * (1 + r * t) - f6 * r;
|
|
5684
5684
|
const den = present * r + payment * (1 + r * t);
|
|
5685
5685
|
if (num1 / den <= 0) fail(ERR.NUM);
|
|
5686
5686
|
return Math.log(num1 / den) / Math.log(1 + r);
|
|
@@ -5693,7 +5693,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5693
5693
|
"The interest part of a payment.",
|
|
5694
5694
|
4,
|
|
5695
5695
|
6,
|
|
5696
|
-
(r, per, n, p,
|
|
5696
|
+
(r, per, n, p, f6, t) => ipmt(r, per ?? 0, n ?? 0, p ?? 0, f6, t)
|
|
5697
5697
|
),
|
|
5698
5698
|
numeric(
|
|
5699
5699
|
"PPMT",
|
|
@@ -5702,7 +5702,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5702
5702
|
"The principal part of a payment.",
|
|
5703
5703
|
4,
|
|
5704
5704
|
6,
|
|
5705
|
-
(r, per, n, p,
|
|
5705
|
+
(r, per, n, p, f6, t) => pmt(r, n ?? 0, p ?? 0, f6, t) - ipmt(r, per ?? 0, n ?? 0, p ?? 0, f6, t)
|
|
5706
5706
|
),
|
|
5707
5707
|
numeric(
|
|
5708
5708
|
"RATE",
|
|
@@ -5711,11 +5711,11 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5711
5711
|
"The interest rate per period.",
|
|
5712
5712
|
3,
|
|
5713
5713
|
6,
|
|
5714
|
-
(n, p, v,
|
|
5715
|
-
if (Math.abs(r) < 1e-12) return (v ?? 0) + (p ?? 0) * n +
|
|
5714
|
+
(n, p, v, f6 = 0, t = 0, g2 = 0.1) => solve((r) => {
|
|
5715
|
+
if (Math.abs(r) < 1e-12) return (v ?? 0) + (p ?? 0) * n + f6;
|
|
5716
5716
|
const growth = Math.expm1(n * Math.log1p(r));
|
|
5717
|
-
return (v ?? 0) * (1 + growth) + (p ?? 0) * (1 + r * t) * growth / r +
|
|
5718
|
-
},
|
|
5717
|
+
return (v ?? 0) * (1 + growth) + (p ?? 0) * (1 + r * t) * growth / r + f6;
|
|
5718
|
+
}, g2)
|
|
5719
5719
|
),
|
|
5720
5720
|
spec(
|
|
5721
5721
|
"NPV",
|
|
@@ -5738,7 +5738,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5738
5738
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
5739
5739
|
if (!values2.some((v) => v > 0) || !values2.some((v) => v < 0)) fail(ERR.NUM);
|
|
5740
5740
|
return solve(
|
|
5741
|
-
(r) => values2.reduce((acc, v,
|
|
5741
|
+
(r) => values2.reduce((acc, v, i2) => acc + v / Math.pow(1 + r, i2), 0),
|
|
5742
5742
|
optNum(args, 1, 0.1)
|
|
5743
5743
|
);
|
|
5744
5744
|
},
|
|
@@ -5785,8 +5785,8 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
5785
5785
|
const n = values2.length;
|
|
5786
5786
|
const positive3 = values2.map((v) => v > 0 ? v : 0);
|
|
5787
5787
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
5788
|
-
const fvPos = positive3.reduce((acc, v,
|
|
5789
|
-
const pvNeg = negative.reduce((acc, v,
|
|
5788
|
+
const fvPos = positive3.reduce((acc, v, i2) => acc + v * Math.pow(1 + reinvest, n - 1 - i2), 0);
|
|
5789
|
+
const pvNeg = negative.reduce((acc, v, i2) => acc + v / Math.pow(1 + finance, i2), 0);
|
|
5790
5790
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
5791
5791
|
return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
|
|
5792
5792
|
},
|
|
@@ -5808,7 +5808,7 @@ function prefixSheets(host, prefix, current) {
|
|
|
5808
5808
|
const last = sheetIndex(host, prefix.sheet2);
|
|
5809
5809
|
if (last < 0) return void 0;
|
|
5810
5810
|
const out = [];
|
|
5811
|
-
for (let
|
|
5811
|
+
for (let i2 = Math.min(first2, last); i2 <= Math.max(first2, last); i2++) out.push(i2);
|
|
5812
5812
|
return out;
|
|
5813
5813
|
}
|
|
5814
5814
|
var specRange = (spec2) => normalizeRange({
|
|
@@ -6191,14 +6191,14 @@ function snapToZero(result2, a, b) {
|
|
|
6191
6191
|
if (result2 !== 0 && Math.abs(result2) <= Math.max(Math.abs(a), Math.abs(b)) * 1e-15) return 0;
|
|
6192
6192
|
return result2;
|
|
6193
6193
|
}
|
|
6194
|
-
function arithmetic(
|
|
6194
|
+
function arithmetic(op2, x, y, snap) {
|
|
6195
6195
|
if (isError(x)) return x;
|
|
6196
6196
|
if (isError(y)) return y;
|
|
6197
6197
|
return signal(() => {
|
|
6198
6198
|
const a = toNumber(x);
|
|
6199
6199
|
const b = toNumber(y);
|
|
6200
6200
|
let r;
|
|
6201
|
-
switch (
|
|
6201
|
+
switch (op2) {
|
|
6202
6202
|
case "+":
|
|
6203
6203
|
r = a + b;
|
|
6204
6204
|
if (snap) r = snapToZero(r, a, b);
|
|
@@ -6220,11 +6220,11 @@ function arithmetic(op, x, y, snap) {
|
|
|
6220
6220
|
return Number.isFinite(r) ? r === 0 ? 0 : r : ERR.NUM;
|
|
6221
6221
|
});
|
|
6222
6222
|
}
|
|
6223
|
-
function comparison(
|
|
6223
|
+
function comparison(op2, x, y) {
|
|
6224
6224
|
if (isError(x)) return x;
|
|
6225
6225
|
if (isError(y)) return y;
|
|
6226
6226
|
const c = compareScalars(x, y);
|
|
6227
|
-
switch (
|
|
6227
|
+
switch (op2) {
|
|
6228
6228
|
case "=":
|
|
6229
6229
|
return c === 0;
|
|
6230
6230
|
case "<>":
|
|
@@ -6244,18 +6244,18 @@ function concat(x, y) {
|
|
|
6244
6244
|
if (isError(y)) return y;
|
|
6245
6245
|
return toText(x) + toText(y);
|
|
6246
6246
|
}
|
|
6247
|
-
function scalarBinary(
|
|
6248
|
-
if (
|
|
6249
|
-
if (
|
|
6250
|
-
return arithmetic(
|
|
6247
|
+
function scalarBinary(op2, x, y, snap = false) {
|
|
6248
|
+
if (op2 === "&") return concat(x, y);
|
|
6249
|
+
if (op2 === "+" || op2 === "-" || op2 === "*" || op2 === "/" || op2 === "^") {
|
|
6250
|
+
return arithmetic(op2, x, y, snap);
|
|
6251
6251
|
}
|
|
6252
|
-
return comparison(
|
|
6252
|
+
return comparison(op2, x, y);
|
|
6253
6253
|
}
|
|
6254
|
-
function scalarUnary(
|
|
6254
|
+
function scalarUnary(op2, x) {
|
|
6255
6255
|
if (isError(x)) return x;
|
|
6256
6256
|
return signal(() => {
|
|
6257
6257
|
const n = toNumber(x);
|
|
6258
|
-
const r =
|
|
6258
|
+
const r = op2 === "-" ? -n : n / 100;
|
|
6259
6259
|
return r === 0 ? 0 : r;
|
|
6260
6260
|
});
|
|
6261
6261
|
}
|
|
@@ -6537,10 +6537,10 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6537
6537
|
254,
|
|
6538
6538
|
(args, ctx) => {
|
|
6539
6539
|
if (args.length % 2 !== 0) fail(ERR.VALUE);
|
|
6540
|
-
for (let
|
|
6541
|
-
const cond = ctx.toScalar(deref(ctx, args[
|
|
6540
|
+
for (let i2 = 0; i2 < args.length; i2 += 2) {
|
|
6541
|
+
const cond = ctx.toScalar(deref(ctx, args[i2].get()));
|
|
6542
6542
|
if (isError(cond)) return cond;
|
|
6543
|
-
if (toBool(cond)) return args[
|
|
6543
|
+
if (toBool(cond)) return args[i2 + 1].get();
|
|
6544
6544
|
}
|
|
6545
6545
|
return ERR.NA;
|
|
6546
6546
|
}
|
|
@@ -6554,15 +6554,15 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6554
6554
|
(args, ctx) => {
|
|
6555
6555
|
const target2 = ctx.toScalar(deref(ctx, args[0].get()));
|
|
6556
6556
|
if (isError(target2)) return target2;
|
|
6557
|
-
let
|
|
6558
|
-
for (;
|
|
6559
|
-
const candidate = ctx.toScalar(deref(ctx, args[
|
|
6557
|
+
let i2 = 1;
|
|
6558
|
+
for (; i2 + 1 < args.length; i2 += 2) {
|
|
6559
|
+
const candidate = ctx.toScalar(deref(ctx, args[i2].get()));
|
|
6560
6560
|
if (isError(candidate)) return candidate;
|
|
6561
6561
|
if (typeof candidate === typeof target2 && compareScalars(candidate, target2) === 0) {
|
|
6562
|
-
return args[
|
|
6562
|
+
return args[i2 + 1].get();
|
|
6563
6563
|
}
|
|
6564
6564
|
}
|
|
6565
|
-
return
|
|
6565
|
+
return i2 < args.length ? args[i2].get() : ERR.NA;
|
|
6566
6566
|
}
|
|
6567
6567
|
),
|
|
6568
6568
|
lazySpec(
|
|
@@ -6625,9 +6625,9 @@ var LOGICAL_FUNCTIONS = [
|
|
|
6625
6625
|
(args, ctx) => {
|
|
6626
6626
|
if (args.length % 2 === 0) fail(ERR.VALUE);
|
|
6627
6627
|
let scope = new Map(ctx.frame.scope ?? []);
|
|
6628
|
-
for (let
|
|
6629
|
-
const name = localName(args[
|
|
6630
|
-
const value2 = ctx.evaluate(args[
|
|
6628
|
+
for (let i2 = 0; i2 + 1 < args.length; i2 += 2) {
|
|
6629
|
+
const name = localName(args[i2]);
|
|
6630
|
+
const value2 = ctx.evaluate(args[i2 + 1].node, scope);
|
|
6631
6631
|
scope = new Map(scope);
|
|
6632
6632
|
scope.set(name, value2);
|
|
6633
6633
|
}
|
|
@@ -6672,7 +6672,7 @@ function line(ctx, value2, axis, index2) {
|
|
|
6672
6672
|
return {
|
|
6673
6673
|
length: length2,
|
|
6674
6674
|
logicalLength: end.row - start.row + 1,
|
|
6675
|
-
get: (
|
|
6675
|
+
get: (i2) => ctx.readCell(area.sheet, start.row + i2, col)
|
|
6676
6676
|
};
|
|
6677
6677
|
}
|
|
6678
6678
|
const row2 = start.row + index2;
|
|
@@ -6680,12 +6680,12 @@ function line(ctx, value2, axis, index2) {
|
|
|
6680
6680
|
return {
|
|
6681
6681
|
length,
|
|
6682
6682
|
logicalLength: end.col - start.col + 1,
|
|
6683
|
-
get: (
|
|
6683
|
+
get: (i2) => ctx.readCell(area.sheet, row2, start.col + i2)
|
|
6684
6684
|
};
|
|
6685
6685
|
}
|
|
6686
6686
|
const m = value2 instanceof Matrix ? value2 : new Matrix([[value2]]);
|
|
6687
|
-
if (axis === "col") return { length: m.rows, get: (
|
|
6688
|
-
return { length: m.cols, get: (
|
|
6687
|
+
if (axis === "col") return { length: m.rows, get: (i2) => m.get(i2, index2) };
|
|
6688
|
+
return { length: m.cols, get: (i2) => m.get(index2, i2) };
|
|
6689
6689
|
}
|
|
6690
6690
|
function vectorOf(ctx, value2) {
|
|
6691
6691
|
const { rows: rows2, cols } = shape(value2);
|
|
@@ -6708,10 +6708,10 @@ function findExact(vector, lookup2, wildcards, reverse = false) {
|
|
|
6708
6708
|
const logicalLength = vector.logicalLength ?? vector.length;
|
|
6709
6709
|
if (reverse) {
|
|
6710
6710
|
if (lookup2 === null && logicalLength > vector.length) return logicalLength - 1;
|
|
6711
|
-
for (let
|
|
6711
|
+
for (let i2 = vector.length - 1; i2 >= 0; i2--) if (test(vector.get(i2))) return i2;
|
|
6712
6712
|
return -1;
|
|
6713
6713
|
}
|
|
6714
|
-
for (let
|
|
6714
|
+
for (let i2 = 0; i2 < vector.length; i2++) if (test(vector.get(i2))) return i2;
|
|
6715
6715
|
if (lookup2 === null && logicalLength > vector.length) return vector.length;
|
|
6716
6716
|
return -1;
|
|
6717
6717
|
}
|
|
@@ -6739,13 +6739,13 @@ function findAscending(vector, lookup2) {
|
|
|
6739
6739
|
function findDescending(vector, lookup2) {
|
|
6740
6740
|
if (isError(lookup2)) fail(lookup2);
|
|
6741
6741
|
let best = -1;
|
|
6742
|
-
for (let
|
|
6743
|
-
const v = vector.get(
|
|
6742
|
+
for (let i2 = 0; i2 < vector.length; i2++) {
|
|
6743
|
+
const v = vector.get(i2);
|
|
6744
6744
|
if (!sameKind(v, lookup2)) continue;
|
|
6745
6745
|
const c = compareScalars(v, lookup2);
|
|
6746
|
-
if (c === 0) return
|
|
6746
|
+
if (c === 0) return i2;
|
|
6747
6747
|
if (c < 0) break;
|
|
6748
|
-
best =
|
|
6748
|
+
best = i2;
|
|
6749
6749
|
}
|
|
6750
6750
|
return best;
|
|
6751
6751
|
}
|
|
@@ -6786,16 +6786,16 @@ function findNearest(vector, lookup2, mode, reverse) {
|
|
|
6786
6786
|
let best = -1;
|
|
6787
6787
|
let bestValue = null;
|
|
6788
6788
|
const n = vector.length;
|
|
6789
|
-
const consider = (
|
|
6789
|
+
const consider = (i2, v) => {
|
|
6790
6790
|
if (isError(v)) return false;
|
|
6791
6791
|
const c = compareLookup(v, lookup2);
|
|
6792
6792
|
if (c === 0) {
|
|
6793
|
-
best =
|
|
6793
|
+
best = i2;
|
|
6794
6794
|
return true;
|
|
6795
6795
|
}
|
|
6796
6796
|
if (mode === -1 ? c < 0 : c > 0) {
|
|
6797
6797
|
if (best < 0 || (mode === -1 ? compareLookup(v, bestValue) > 0 : compareLookup(v, bestValue) < 0)) {
|
|
6798
|
-
best =
|
|
6798
|
+
best = i2;
|
|
6799
6799
|
bestValue = v;
|
|
6800
6800
|
}
|
|
6801
6801
|
}
|
|
@@ -6804,8 +6804,8 @@ function findNearest(vector, lookup2, mode, reverse) {
|
|
|
6804
6804
|
const logicalLength = vector.logicalLength ?? n;
|
|
6805
6805
|
if (reverse && logicalLength > n && consider(logicalLength - 1, null)) return best;
|
|
6806
6806
|
for (let k = 0; k < n; k++) {
|
|
6807
|
-
const
|
|
6808
|
-
if (consider(
|
|
6807
|
+
const i2 = reverse ? n - 1 - k : k;
|
|
6808
|
+
if (consider(i2, vector.get(i2))) return best;
|
|
6809
6809
|
}
|
|
6810
6810
|
if (!reverse && logicalLength > n) consider(n, null);
|
|
6811
6811
|
return best;
|
|
@@ -7286,9 +7286,9 @@ var LOOKUP_FUNCTIONS = [
|
|
|
7286
7286
|
2,
|
|
7287
7287
|
255,
|
|
7288
7288
|
(args) => {
|
|
7289
|
-
const
|
|
7290
|
-
if (
|
|
7291
|
-
return args[
|
|
7289
|
+
const i2 = int(args[0]);
|
|
7290
|
+
if (i2 < 1 || i2 >= args.length) fail(ERR.VALUE);
|
|
7291
|
+
return args[i2] ?? null;
|
|
7292
7292
|
},
|
|
7293
7293
|
["value", "any"]
|
|
7294
7294
|
)
|
|
@@ -7407,8 +7407,8 @@ function matchingCells(ctx, pairs, target2, sameShape) {
|
|
|
7407
7407
|
const out = [];
|
|
7408
7408
|
const first2 = matrices[0];
|
|
7409
7409
|
const holds = (r, c) => {
|
|
7410
|
-
for (let
|
|
7411
|
-
if (!tests[
|
|
7410
|
+
for (let i2 = 0; i2 < tests.length; i2++) {
|
|
7411
|
+
if (!tests[i2](matrices[i2].get(r, c))) return false;
|
|
7412
7412
|
}
|
|
7413
7413
|
return true;
|
|
7414
7414
|
};
|
|
@@ -7429,10 +7429,10 @@ function matchingCells(ctx, pairs, target2, sameShape) {
|
|
|
7429
7429
|
}
|
|
7430
7430
|
function indexedCandidates(pairs, matrices) {
|
|
7431
7431
|
const first2 = matrices[0];
|
|
7432
|
-
for (let
|
|
7433
|
-
const m = matrices[
|
|
7434
|
-
if (!(pairs[
|
|
7435
|
-
const key = equalityKey(scalar(pairs[
|
|
7432
|
+
for (let i2 = 0; i2 < pairs.length; i2++) {
|
|
7433
|
+
const m = matrices[i2];
|
|
7434
|
+
if (!(pairs[i2]?.range instanceof RefValue) || m.cols !== first2.cols) continue;
|
|
7435
|
+
const key = equalityKey(scalar(pairs[i2]?.criteria));
|
|
7436
7436
|
if (key === void 0) continue;
|
|
7437
7437
|
const found = positionsOf(m, key);
|
|
7438
7438
|
if (found) return found;
|
|
@@ -7443,8 +7443,8 @@ var matchingValues = (ctx, pairs, target2, sameShape) => matchingCells(ctx, pair
|
|
|
7443
7443
|
function criteriaPairs(args, from) {
|
|
7444
7444
|
if ((args.length - from) % 2 !== 0) fail(ERR.VALUE);
|
|
7445
7445
|
const pairs = [];
|
|
7446
|
-
for (let
|
|
7447
|
-
pairs.push({ range: args[
|
|
7446
|
+
for (let i2 = from; i2 < args.length; i2 += 2) {
|
|
7447
|
+
pairs.push({ range: args[i2] ?? null, criteria: args[i2 + 1] ?? null });
|
|
7448
7448
|
}
|
|
7449
7449
|
return pairs;
|
|
7450
7450
|
}
|
|
@@ -7510,9 +7510,9 @@ function pairwise(ctx, args, fn) {
|
|
|
7510
7510
|
const ys = ctx.toMatrix(args[1] ?? null).flat();
|
|
7511
7511
|
if (xs.length !== ys.length) fail(ERR.NA);
|
|
7512
7512
|
let total2 = 0;
|
|
7513
|
-
for (let
|
|
7514
|
-
const x = xs[
|
|
7515
|
-
const y = ys[
|
|
7513
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
7514
|
+
const x = xs[i2] ?? null;
|
|
7515
|
+
const y = ys[i2] ?? null;
|
|
7516
7516
|
if (isError(x)) fail(x);
|
|
7517
7517
|
if (isError(y)) fail(y);
|
|
7518
7518
|
if (typeof x === "number" && typeof y === "number") total2 += fn(x, y);
|
|
@@ -7907,7 +7907,7 @@ var MATH_MORE = [
|
|
|
7907
7907
|
const n = num(args[1]);
|
|
7908
7908
|
const m = num(args[2]);
|
|
7909
7909
|
return collectNumbers(ctx, [args[3] ?? null]).reduce(
|
|
7910
|
-
(acc, a,
|
|
7910
|
+
(acc, a, i2) => acc + a * Math.pow(x, n + i2 * m),
|
|
7911
7911
|
0
|
|
7912
7912
|
);
|
|
7913
7913
|
},
|
|
@@ -7920,7 +7920,7 @@ var C20 = "Math & Trig";
|
|
|
7920
7920
|
var fact = (n) => {
|
|
7921
7921
|
if (n < 0) fail(ERR.NUM);
|
|
7922
7922
|
let out = 1;
|
|
7923
|
-
for (let
|
|
7923
|
+
for (let i2 = 2; i2 <= Math.trunc(n); i2++) out *= i2;
|
|
7924
7924
|
return out;
|
|
7925
7925
|
};
|
|
7926
7926
|
function combin(n, k) {
|
|
@@ -7928,8 +7928,8 @@ function combin(n, k) {
|
|
|
7928
7928
|
const kk = Math.trunc(k);
|
|
7929
7929
|
if (nn < 0 || kk < 0 || kk > nn) fail(ERR.NUM);
|
|
7930
7930
|
let out = 1;
|
|
7931
|
-
for (let
|
|
7932
|
-
out = out * (nn - Math.min(kk, nn - kk) +
|
|
7931
|
+
for (let i2 = 1; i2 <= Math.min(kk, nn - kk); i2++)
|
|
7932
|
+
out = out * (nn - Math.min(kk, nn - kk) + i2) / i2;
|
|
7933
7933
|
return Math.round(out);
|
|
7934
7934
|
}
|
|
7935
7935
|
var gcd2 = (a, b) => b === 0 ? a : gcd2(b, a % b);
|
|
@@ -7944,7 +7944,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
7944
7944
|
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
|
|
7945
7945
|
if (n < -1) fail(ERR.NUM);
|
|
7946
7946
|
let out = 1;
|
|
7947
|
-
for (let
|
|
7947
|
+
for (let i2 = Math.trunc(n); i2 > 1; i2 -= 2) out *= i2;
|
|
7948
7948
|
return out;
|
|
7949
7949
|
}),
|
|
7950
7950
|
numeric(
|
|
@@ -8054,9 +8054,9 @@ function roundTo(x, digits2, mode) {
|
|
|
8054
8054
|
const result2 = d >= 0 ? rounded / factor : rounded * factor;
|
|
8055
8055
|
return result2 === 0 ? 0 : sign2 * result2;
|
|
8056
8056
|
}
|
|
8057
|
-
var quotientMultiple = (x, sig,
|
|
8057
|
+
var quotientMultiple = (x, sig, op2) => {
|
|
8058
8058
|
if (sig === 0) return 0;
|
|
8059
|
-
return
|
|
8059
|
+
return op2(round15(x / sig)) * sig;
|
|
8060
8060
|
};
|
|
8061
8061
|
var MATH_FUNCTIONS = [
|
|
8062
8062
|
...MATH_MORE,
|
|
@@ -8322,7 +8322,7 @@ function eliminate(input, invert2) {
|
|
|
8322
8322
|
const a = input.map((row2) => [...row2]);
|
|
8323
8323
|
const inv = Array.from(
|
|
8324
8324
|
{ length: n },
|
|
8325
|
-
(_,
|
|
8325
|
+
(_, i2) => Array.from({ length: n }, (_2, j) => i2 === j ? 1 : 0)
|
|
8326
8326
|
);
|
|
8327
8327
|
let det = 1;
|
|
8328
8328
|
for (let col = 0; col < n; col++) {
|
|
@@ -8427,7 +8427,7 @@ function fitLeastSquares(x, y, hasIntercept) {
|
|
|
8427
8427
|
);
|
|
8428
8428
|
const moment = Array.from(
|
|
8429
8429
|
{ length: k },
|
|
8430
|
-
(_, a) => total(xc.map((row2,
|
|
8430
|
+
(_, a) => total(xc.map((row2, i2) => (row2[a] ?? 0) * (yc[i2] ?? 0)))
|
|
8431
8431
|
);
|
|
8432
8432
|
const { det, inverse } = eliminate(gram, true);
|
|
8433
8433
|
if (!inverse || det === 0 || !Number.isFinite(det)) fail(ERR.NUM);
|
|
@@ -8435,10 +8435,10 @@ function fitLeastSquares(x, y, hasIntercept) {
|
|
|
8435
8435
|
const intercept = hasIntercept ? yMean - total(slopes.map((m, j) => m * (means[j] ?? 0))) : 0;
|
|
8436
8436
|
let ssResid = 0;
|
|
8437
8437
|
let ssTotal = 0;
|
|
8438
|
-
for (let
|
|
8439
|
-
const predicted = intercept + total(slopes.map((m, j) => m * (x[
|
|
8440
|
-
ssResid += ((y[
|
|
8441
|
-
ssTotal += ((y[
|
|
8438
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
8439
|
+
const predicted = intercept + total(slopes.map((m, j) => m * (x[i2]?.[j] ?? 0)));
|
|
8440
|
+
ssResid += ((y[i2] ?? 0) - predicted) ** 2;
|
|
8441
|
+
ssTotal += ((y[i2] ?? 0) - yMean) ** 2;
|
|
8442
8442
|
}
|
|
8443
8443
|
return { slopes, intercept, inverse, means, n, hasIntercept, ssTotal, ssResid };
|
|
8444
8444
|
}
|
|
@@ -8489,7 +8489,7 @@ function layout(ctx, args) {
|
|
|
8489
8489
|
if (rows2 === 0 || cols === 0 || rows2 > 1 && cols > 1) fail(ERR.REF);
|
|
8490
8490
|
const column = cols === 1;
|
|
8491
8491
|
const y = ym.flat();
|
|
8492
|
-
if (omitted(args, 1)) return { y, x: y.map((_,
|
|
8492
|
+
if (omitted(args, 1)) return { y, x: y.map((_, i2) => [i2 + 1]), column };
|
|
8493
8493
|
const xm = numbersOf2(ctx, args[1]);
|
|
8494
8494
|
const x = asObservations(xm, column);
|
|
8495
8495
|
if (x.length !== y.length) {
|
|
@@ -8503,11 +8503,11 @@ var row = (values2, width) => [
|
|
|
8503
8503
|
...values2,
|
|
8504
8504
|
...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
|
|
8505
8505
|
];
|
|
8506
|
-
function coefficientTable(fit, stats,
|
|
8506
|
+
function coefficientTable(fit, stats, transform6) {
|
|
8507
8507
|
const k = fit.slopes.length;
|
|
8508
8508
|
const width = k + 1;
|
|
8509
|
-
const slopes = [...fit.slopes].reverse().map(
|
|
8510
|
-
const head = [...slopes,
|
|
8509
|
+
const slopes = [...fit.slopes].reverse().map(transform6);
|
|
8510
|
+
const head = [...slopes, transform6(fit.intercept)];
|
|
8511
8511
|
if (!stats) return new Matrix([head]);
|
|
8512
8512
|
const s = fitStatistics(fit);
|
|
8513
8513
|
const errors = [...s.slopeErrors].reverse();
|
|
@@ -8519,8 +8519,8 @@ function coefficientTable(fit, stats, transform) {
|
|
|
8519
8519
|
row([s.ssRegression, s.ssResidual], width)
|
|
8520
8520
|
]);
|
|
8521
8521
|
}
|
|
8522
|
-
function predictions(ctx, args, lay, fit,
|
|
8523
|
-
const predict = (obs) =>
|
|
8522
|
+
function predictions(ctx, args, lay, fit, transform6) {
|
|
8523
|
+
const predict = (obs) => transform6(fit.intercept + fit.slopes.reduce((a, m, j) => a + m * (obs[j] ?? 0), 0));
|
|
8524
8524
|
if (omitted(args, 2)) {
|
|
8525
8525
|
const out2 = lay.x.map(predict);
|
|
8526
8526
|
return new Matrix(lay.column ? out2.map((v) => [v]) : [out2]);
|
|
@@ -8620,9 +8620,9 @@ function gammaP(a, x) {
|
|
|
8620
8620
|
let b = x + 1 - a;
|
|
8621
8621
|
let c = 1 / 1e-300;
|
|
8622
8622
|
let d = 1 / b;
|
|
8623
|
-
let
|
|
8624
|
-
for (let
|
|
8625
|
-
const an = -
|
|
8623
|
+
let h2 = d;
|
|
8624
|
+
for (let i2 = 1; i2 < 1e3; i2++) {
|
|
8625
|
+
const an = -i2 * (i2 - a);
|
|
8626
8626
|
b += 2;
|
|
8627
8627
|
d = an * d + b;
|
|
8628
8628
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
@@ -8630,10 +8630,10 @@ function gammaP(a, x) {
|
|
|
8630
8630
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8631
8631
|
d = 1 / d;
|
|
8632
8632
|
const del = d * c;
|
|
8633
|
-
|
|
8633
|
+
h2 *= del;
|
|
8634
8634
|
if (Math.abs(del - 1) < EPS) break;
|
|
8635
8635
|
}
|
|
8636
|
-
return 1 - Math.exp(lnPrefix) *
|
|
8636
|
+
return 1 - Math.exp(lnPrefix) * h2;
|
|
8637
8637
|
}
|
|
8638
8638
|
function betaCf(a, b, x) {
|
|
8639
8639
|
const qab = a + b;
|
|
@@ -8643,7 +8643,7 @@ function betaCf(a, b, x) {
|
|
|
8643
8643
|
let d = 1 - qab * x / qap;
|
|
8644
8644
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
8645
8645
|
d = 1 / d;
|
|
8646
|
-
let
|
|
8646
|
+
let h2 = d;
|
|
8647
8647
|
for (let m = 1; m <= 1e3; m++) {
|
|
8648
8648
|
const m2 = 2 * m;
|
|
8649
8649
|
let aa = m * (b - m) * x / ((qam + m2) * (a + m2));
|
|
@@ -8652,7 +8652,7 @@ function betaCf(a, b, x) {
|
|
|
8652
8652
|
c = 1 + aa / c;
|
|
8653
8653
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8654
8654
|
d = 1 / d;
|
|
8655
|
-
|
|
8655
|
+
h2 *= d * c;
|
|
8656
8656
|
aa = -(a + m) * (qab + m) * x / ((a + m2) * (qap + m2));
|
|
8657
8657
|
d = 1 + aa * d;
|
|
8658
8658
|
if (Math.abs(d) < 1e-300) d = 1e-300;
|
|
@@ -8660,10 +8660,10 @@ function betaCf(a, b, x) {
|
|
|
8660
8660
|
if (Math.abs(c) < 1e-300) c = 1e-300;
|
|
8661
8661
|
d = 1 / d;
|
|
8662
8662
|
const del = d * c;
|
|
8663
|
-
|
|
8663
|
+
h2 *= del;
|
|
8664
8664
|
if (Math.abs(del - 1) < EPS) break;
|
|
8665
8665
|
}
|
|
8666
|
-
return
|
|
8666
|
+
return h2;
|
|
8667
8667
|
}
|
|
8668
8668
|
function betaI(x, a, b) {
|
|
8669
8669
|
if (x <= 0) return 0;
|
|
@@ -8702,7 +8702,7 @@ function normInv(p) {
|
|
|
8702
8702
|
2.938163982698783
|
|
8703
8703
|
];
|
|
8704
8704
|
const d = [0.007784695709041462, 0.3224671290700398, 2.445134137142996, 3.754408661907416];
|
|
8705
|
-
const at = (arr,
|
|
8705
|
+
const at = (arr, i2) => arr[i2];
|
|
8706
8706
|
let x;
|
|
8707
8707
|
if (p < 0.02425) {
|
|
8708
8708
|
const q = Math.sqrt(-2 * Math.log(p));
|
|
@@ -8723,7 +8723,7 @@ function invert(cdf, p, lo, hi) {
|
|
|
8723
8723
|
let a = lo;
|
|
8724
8724
|
let b = hi;
|
|
8725
8725
|
while (cdf(b) < p && b < 1e10) b *= 2;
|
|
8726
|
-
for (let
|
|
8726
|
+
for (let i2 = 0; i2 < 200; i2++) {
|
|
8727
8727
|
const mid = (a + b) / 2;
|
|
8728
8728
|
if (cdf(mid) < p) a = mid;
|
|
8729
8729
|
else b = mid;
|
|
@@ -8755,7 +8755,7 @@ function binomDist(k, n, p, cumulative2) {
|
|
|
8755
8755
|
if (kk < 0 || kk > nn || p < 0 || p > 1) fail(ERR.NUM);
|
|
8756
8756
|
if (!cumulative2) return binomPmf(kk, nn, p);
|
|
8757
8757
|
let total2 = 0;
|
|
8758
|
-
for (let
|
|
8758
|
+
for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
|
|
8759
8759
|
return Math.min(1, total2);
|
|
8760
8760
|
}
|
|
8761
8761
|
function poisson(k, mean2, cumulative2) {
|
|
@@ -8813,16 +8813,16 @@ function binomInverse(trials, p, alpha) {
|
|
|
8813
8813
|
}
|
|
8814
8814
|
return n;
|
|
8815
8815
|
}
|
|
8816
|
-
var hypgeomPmf = (k, n,
|
|
8816
|
+
var hypgeomPmf = (k, n, K5, N) => {
|
|
8817
8817
|
const kk = Math.trunc(k);
|
|
8818
8818
|
const nn = Math.trunc(n);
|
|
8819
|
-
const KK = Math.trunc(
|
|
8819
|
+
const KK = Math.trunc(K5);
|
|
8820
8820
|
const NN = Math.trunc(N);
|
|
8821
8821
|
if (kk < 0 || nn > NN || KK > NN || kk > Math.min(nn, KK) || kk < nn - (NN - KK)) fail(ERR.NUM);
|
|
8822
8822
|
return combin(KK, kk) * combin(NN - KK, nn - kk) / combin(NN, nn);
|
|
8823
8823
|
};
|
|
8824
|
-
var negbinomPmf = (
|
|
8825
|
-
const ff = Math.trunc(
|
|
8824
|
+
var negbinomPmf = (f6, s, p) => {
|
|
8825
|
+
const ff = Math.trunc(f6);
|
|
8826
8826
|
const ss = Math.trunc(s);
|
|
8827
8827
|
if (ff < 0 || ss < 1 || p < 0 || p > 1) fail(ERR.NUM);
|
|
8828
8828
|
return combin(ff + ss - 1, ss - 1) * Math.pow(p, ss) * Math.pow(1 - p, ff);
|
|
@@ -9018,7 +9018,7 @@ function moments(values2) {
|
|
|
9018
9018
|
return { n, m: mean(values2), s: stdev(values2, true) };
|
|
9019
9019
|
}
|
|
9020
9020
|
function frequency(data, bins) {
|
|
9021
|
-
const order = bins.map((b,
|
|
9021
|
+
const order = bins.map((b, i2) => ({ b, i: i2 })).sort((x, y) => x.b - y.b);
|
|
9022
9022
|
const counts = new Array(bins.length + 1).fill(0);
|
|
9023
9023
|
for (const v of data) {
|
|
9024
9024
|
const slot = order.find((o) => v <= o.b);
|
|
@@ -9180,7 +9180,7 @@ var STATISTICAL_SHAPE = [
|
|
|
9180
9180
|
const kk = Math.trunc(k ?? 0);
|
|
9181
9181
|
if (nn < 0 || kk < 0 || kk > nn) fail(ERR.NUM);
|
|
9182
9182
|
let out = 1;
|
|
9183
|
-
for (let
|
|
9183
|
+
for (let i2 = 0; i2 < kk; i2++) out *= nn - i2;
|
|
9184
9184
|
return out;
|
|
9185
9185
|
}
|
|
9186
9186
|
),
|
|
@@ -9241,9 +9241,9 @@ function pairedNumbers(ctx, a, b) {
|
|
|
9241
9241
|
if (ma.length !== mb.length) fail(ERR.NA);
|
|
9242
9242
|
const xs = [];
|
|
9243
9243
|
const ys = [];
|
|
9244
|
-
for (let
|
|
9245
|
-
const x = ma[
|
|
9246
|
-
const y = mb[
|
|
9244
|
+
for (let i2 = 0; i2 < ma.length; i2++) {
|
|
9245
|
+
const x = ma[i2] ?? null;
|
|
9246
|
+
const y = mb[i2] ?? null;
|
|
9247
9247
|
if (isError(x)) fail(x);
|
|
9248
9248
|
if (isError(y)) fail(y);
|
|
9249
9249
|
if (typeof x === "number" && typeof y === "number") {
|
|
@@ -9338,9 +9338,9 @@ var STATISTICAL_MORE = [
|
|
|
9338
9338
|
let sxy = 0;
|
|
9339
9339
|
let sxx = 0;
|
|
9340
9340
|
let syy = 0;
|
|
9341
|
-
for (let
|
|
9342
|
-
const dx = xs[
|
|
9343
|
-
const dy = ys[
|
|
9341
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
9342
|
+
const dx = xs[i2] - mx;
|
|
9343
|
+
const dy = ys[i2] - my;
|
|
9344
9344
|
sxy += dx * dy;
|
|
9345
9345
|
sxx += dx * dx;
|
|
9346
9346
|
syy += dy * dy;
|
|
@@ -9375,7 +9375,7 @@ var numbersOf3 = (ctx, value2) => collectNumbers(ctx, [value2 ?? null]);
|
|
|
9375
9375
|
function tStatistic(a, b, type) {
|
|
9376
9376
|
if (type === 1) {
|
|
9377
9377
|
if (a.length !== b.length) fail(ERR.NA);
|
|
9378
|
-
const diffs = a.map((v,
|
|
9378
|
+
const diffs = a.map((v, i2) => v - (b[i2] ?? 0));
|
|
9379
9379
|
const n = diffs.length;
|
|
9380
9380
|
if (n < 2) fail(ERR.DIV0);
|
|
9381
9381
|
const sd = stdev(diffs, true);
|
|
@@ -9437,8 +9437,8 @@ function probability2(ctx, args) {
|
|
|
9437
9437
|
const upper2 = args.length > 3 && args[3] !== null ? num(args[3]) : lower2;
|
|
9438
9438
|
let total2 = 0;
|
|
9439
9439
|
let hit = 0;
|
|
9440
|
-
for (let
|
|
9441
|
-
const [x, p] = [xs[
|
|
9440
|
+
for (let i2 = 0; i2 < xs.length; i2++) {
|
|
9441
|
+
const [x, p] = [xs[i2] ?? null, ps[i2] ?? null];
|
|
9442
9442
|
if (isError(x)) fail(x);
|
|
9443
9443
|
if (isError(p)) fail(p);
|
|
9444
9444
|
if (typeof p !== "number" || p < 0 || p > 1) fail(ERR.NUM);
|
|
@@ -10095,8 +10095,8 @@ var DISTRIBUTION_MORE = [
|
|
|
10095
10095
|
"The negative binomial distribution.",
|
|
10096
10096
|
4,
|
|
10097
10097
|
4,
|
|
10098
|
-
(
|
|
10099
|
-
const ff = Math.trunc(
|
|
10098
|
+
(f6, s, p, c) => {
|
|
10099
|
+
const ff = Math.trunc(f6);
|
|
10100
10100
|
const ss = Math.trunc(s ?? 0);
|
|
10101
10101
|
const pp = p ?? 0;
|
|
10102
10102
|
if (ff < 0 || ss < 1 || pp < 0 || pp > 1) fail(ERR.NUM);
|
|
@@ -10114,16 +10114,16 @@ var DISTRIBUTION_MORE = [
|
|
|
10114
10114
|
"The hypergeometric distribution.",
|
|
10115
10115
|
5,
|
|
10116
10116
|
5,
|
|
10117
|
-
(k, n,
|
|
10117
|
+
(k, n, K5, N, c) => {
|
|
10118
10118
|
const kk = Math.trunc(k);
|
|
10119
10119
|
const nn = Math.trunc(n ?? 0);
|
|
10120
|
-
const KK = Math.trunc(
|
|
10120
|
+
const KK = Math.trunc(K5 ?? 0);
|
|
10121
10121
|
const NN = Math.trunc(N ?? 0);
|
|
10122
10122
|
if (kk < 0 || nn > NN || KK > NN || kk > Math.min(nn, KK)) fail(ERR.NUM);
|
|
10123
|
-
const pmf = (
|
|
10123
|
+
const pmf = (i2) => combin(KK, i2) * combin(NN - KK, nn - i2) / combin(NN, nn);
|
|
10124
10124
|
if (!c) return pmf(kk);
|
|
10125
10125
|
let total2 = 0;
|
|
10126
|
-
for (let
|
|
10126
|
+
for (let i2 = Math.max(0, nn - (NN - KK)); i2 <= kk; i2++) total2 += pmf(i2);
|
|
10127
10127
|
return total2;
|
|
10128
10128
|
}
|
|
10129
10129
|
)
|
|
@@ -10539,15 +10539,15 @@ function lowerChar(ch, before, after) {
|
|
|
10539
10539
|
function mapChars(text, fn) {
|
|
10540
10540
|
const chars = [...text];
|
|
10541
10541
|
let out = "";
|
|
10542
|
-
for (let
|
|
10542
|
+
for (let i2 = 0; i2 < chars.length; i2++) out += fn(chars[i2], i2, chars);
|
|
10543
10543
|
return out;
|
|
10544
10544
|
}
|
|
10545
10545
|
var upper = (text) => mapChars(text, upperChar);
|
|
10546
|
-
var lower = (text) => mapChars(text, (ch,
|
|
10547
|
-
var proper = (text) => mapChars(text, (ch,
|
|
10546
|
+
var lower = (text) => mapChars(text, (ch, i2, all2) => lowerChar(ch, all2[i2 - 1], all2[i2 + 1]));
|
|
10547
|
+
var proper = (text) => mapChars(text, (ch, i2, all2) => {
|
|
10548
10548
|
if (!isLetter(ch)) return ch;
|
|
10549
|
-
const before = all2[
|
|
10550
|
-
return before !== void 0 && isLetter(before) ? lowerChar(ch, before, all2[
|
|
10549
|
+
const before = all2[i2 - 1];
|
|
10550
|
+
return before !== void 0 && isLetter(before) ? lowerChar(ch, before, all2[i2 + 1]) : upperChar(ch);
|
|
10551
10551
|
});
|
|
10552
10552
|
var isHigh = (code) => code >= 55296 && code <= 56319;
|
|
10553
10553
|
var isLow = (code) => code >= 56320 && code <= 57343;
|
|
@@ -10626,8 +10626,8 @@ var TEXT_FUNCTIONS = [
|
|
|
10626
10626
|
const ignoreEmpty = bool(ctx.toScalar(args[1] ?? null));
|
|
10627
10627
|
const parts = joinValues(ctx, args.slice(2)).filter((p) => !ignoreEmpty || p !== "");
|
|
10628
10628
|
let out = "";
|
|
10629
|
-
parts.forEach((p,
|
|
10630
|
-
if (
|
|
10629
|
+
parts.forEach((p, i2) => {
|
|
10630
|
+
if (i2 > 0) out += delimiters.length ? delimiters[(i2 - 1) % delimiters.length] : "";
|
|
10631
10631
|
out += p;
|
|
10632
10632
|
});
|
|
10633
10633
|
return limit(out);
|
|
@@ -10739,7 +10739,7 @@ var TEXT_FUNCTIONS = [
|
|
|
10739
10739
|
const instance = Math.trunc(num(args[3]));
|
|
10740
10740
|
if (instance < 1) fail(ERR.VALUE);
|
|
10741
10741
|
let at = -1;
|
|
10742
|
-
for (let
|
|
10742
|
+
for (let i2 = 0; i2 < instance; i2++) {
|
|
10743
10743
|
at = text.indexOf(oldText, at + 1);
|
|
10744
10744
|
if (at < 0) return text;
|
|
10745
10745
|
}
|
|
@@ -10885,19 +10885,19 @@ function occurrences(text, delimiters, insensitive) {
|
|
|
10885
10885
|
const hay = insensitive ? text.toLowerCase() : text;
|
|
10886
10886
|
const needles = delimiters.map((d) => insensitive ? d.toLowerCase() : d);
|
|
10887
10887
|
const out = [];
|
|
10888
|
-
let
|
|
10889
|
-
while (
|
|
10888
|
+
let i2 = 0;
|
|
10889
|
+
while (i2 <= hay.length) {
|
|
10890
10890
|
let best;
|
|
10891
10891
|
for (const n of needles) {
|
|
10892
10892
|
if (n === "") continue;
|
|
10893
|
-
const at = hay.indexOf(n,
|
|
10893
|
+
const at = hay.indexOf(n, i2);
|
|
10894
10894
|
if (at >= 0 && (!best || at < best.at || at === best.at && n.length > best.length)) {
|
|
10895
10895
|
best = { at, length: n.length };
|
|
10896
10896
|
}
|
|
10897
10897
|
}
|
|
10898
10898
|
if (!best) break;
|
|
10899
10899
|
out.push(best);
|
|
10900
|
-
|
|
10900
|
+
i2 = best.at + best.length;
|
|
10901
10901
|
}
|
|
10902
10902
|
return out;
|
|
10903
10903
|
}
|
|
@@ -10973,13 +10973,13 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
10973
10973
|
const rowDelims = delimitersOf(ctx, args[2]);
|
|
10974
10974
|
const ignoreEmpty = args.length > 3 && args[3] !== null && Boolean(scalar(ctx.toScalar(args[3] ?? null)));
|
|
10975
10975
|
const insensitive = args.length > 4 && optNum([ctx.toScalar(args[4] ?? null)], 0, 0) === 1;
|
|
10976
|
-
const
|
|
10976
|
+
const pad4 = args.length > 5 ? ctx.toScalar(args[5] ?? null) : ERR.NA;
|
|
10977
10977
|
if (colDelims.length === 0 && rowDelims.length === 0) fail(ERR.VALUE);
|
|
10978
10978
|
const rows2 = splitText(text, rowDelims, insensitive, ignoreEmpty).map(
|
|
10979
10979
|
(line2) => splitText(line2, colDelims, insensitive, ignoreEmpty)
|
|
10980
10980
|
);
|
|
10981
10981
|
const width = rows2.reduce((w, r) => Math.max(w, r.length), 0);
|
|
10982
|
-
return new Matrix(rows2.map((r) => Array.from({ length: width }, (_,
|
|
10982
|
+
return new Matrix(rows2.map((r) => Array.from({ length: width }, (_, i2) => r[i2] ?? pad4)));
|
|
10983
10983
|
},
|
|
10984
10984
|
["any"]
|
|
10985
10985
|
),
|
|
@@ -11085,12 +11085,12 @@ function callFunction(node, frame) {
|
|
|
11085
11085
|
}
|
|
11086
11086
|
const arrayFrame = frame.legacy ? { ...frame, legacy: false } : frame;
|
|
11087
11087
|
const args = node.args.map(
|
|
11088
|
-
(arg,
|
|
11088
|
+
(arg, i2) => evaluateNode(arg, paramKind(spec2, i2) === "any" ? arrayFrame : frame)
|
|
11089
11089
|
);
|
|
11090
|
-
for (let
|
|
11091
|
-
const fallback = spec2.missingDefaults?.[
|
|
11092
|
-
if (node.args[
|
|
11093
|
-
args[
|
|
11090
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
11091
|
+
const fallback = spec2.missingDefaults?.[i2];
|
|
11092
|
+
if (node.args[i2]?.type === "missing" && fallback !== void 0)
|
|
11093
|
+
args[i2] = typeof fallback === "function" ? guard(() => fallback(args, ctx)) : fallback;
|
|
11094
11094
|
}
|
|
11095
11095
|
return applyFunction(spec2, args, ctx);
|
|
11096
11096
|
}
|
|
@@ -11098,9 +11098,9 @@ function applyFunction(spec2, args, ctx) {
|
|
|
11098
11098
|
const fn = spec2.fn;
|
|
11099
11099
|
if (!fn) return ERR.VALUE;
|
|
11100
11100
|
const lifted = [];
|
|
11101
|
-
for (let
|
|
11102
|
-
if (paramKind(spec2,
|
|
11103
|
-
let arg = args[
|
|
11101
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
11102
|
+
if (paramKind(spec2, i2) !== "value") continue;
|
|
11103
|
+
let arg = args[i2];
|
|
11104
11104
|
if (arg instanceof RefValue) {
|
|
11105
11105
|
if (ctx.frame.legacy && !arg.isCell()) arg = ctx.toScalar(arg);
|
|
11106
11106
|
else if (arg.isCell()) {
|
|
@@ -11119,12 +11119,12 @@ function applyFunction(spec2, args, ctx) {
|
|
|
11119
11119
|
if (arg.rows === 1 && arg.cols === 1) arg = arg.get(0, 0);
|
|
11120
11120
|
else lifted.push(arg);
|
|
11121
11121
|
}
|
|
11122
|
-
args[
|
|
11122
|
+
args[i2] = arg;
|
|
11123
11123
|
}
|
|
11124
11124
|
if (lifted.length === 0) return guard(() => fn(args, ctx));
|
|
11125
11125
|
return broadcastShape(lifted, (r, c) => {
|
|
11126
11126
|
const element2 = args.map(
|
|
11127
|
-
(arg,
|
|
11127
|
+
(arg, i2) => arg instanceof Matrix && paramKind(spec2, i2) === "value" ? pick(arg, r, c) : arg
|
|
11128
11128
|
);
|
|
11129
11129
|
return toElement2(
|
|
11130
11130
|
guard(() => fn(element2, ctx)),
|
|
@@ -11256,8 +11256,8 @@ function evaluateBinary(node, frame) {
|
|
|
11256
11256
|
leftmost = leftmost.left;
|
|
11257
11257
|
}
|
|
11258
11258
|
let value2 = evaluateNode(leftmost, frame);
|
|
11259
|
-
for (let
|
|
11260
|
-
value2 = applyBinary(spine[
|
|
11259
|
+
for (let i2 = spine.length - 1; i2 >= 0; i2--)
|
|
11260
|
+
value2 = applyBinary(spine[i2], value2, frame);
|
|
11261
11261
|
return value2;
|
|
11262
11262
|
}
|
|
11263
11263
|
function applyBinary(node, left2, frame) {
|
|
@@ -11318,7 +11318,7 @@ function invokeLambda(callee, args, frame) {
|
|
|
11318
11318
|
if (!(callee instanceof LambdaValue)) return ERR.VALUE;
|
|
11319
11319
|
if (args.length > callee.params.length) return ERR.VALUE;
|
|
11320
11320
|
const scope = new Map(callee.scope ?? []);
|
|
11321
|
-
callee.params.forEach((param,
|
|
11321
|
+
callee.params.forEach((param, i2) => scope.set(param, args[i2] ?? null));
|
|
11322
11322
|
return evaluateNode(callee.body, { ...frame, scope, root: void 0 });
|
|
11323
11323
|
}
|
|
11324
11324
|
|
|
@@ -11398,8 +11398,8 @@ function visit(node, c) {
|
|
|
11398
11398
|
if (spec2?.volatile) c.volatile = true;
|
|
11399
11399
|
if (!spec2 && !isLocalOrDefined(node.rawName, c)) c.unsupported = true;
|
|
11400
11400
|
const reference = spec2 !== void 0 && REFERENCE_ARGUMENT.has(node.name);
|
|
11401
|
-
node.args.forEach((arg,
|
|
11402
|
-
if (reference &&
|
|
11401
|
+
node.args.forEach((arg, i2) => {
|
|
11402
|
+
if (reference && i2 === 0) {
|
|
11403
11403
|
c.dynamic++;
|
|
11404
11404
|
visit(arg, c);
|
|
11405
11405
|
c.dynamic--;
|
|
@@ -11425,11 +11425,11 @@ function visitBinary(node, c) {
|
|
|
11425
11425
|
const staticStart = c.deps.length;
|
|
11426
11426
|
const dynamicStart = c.dynamicDeps.length;
|
|
11427
11427
|
visit(leftmost, c);
|
|
11428
|
-
for (let
|
|
11429
|
-
const
|
|
11430
|
-
visit(
|
|
11431
|
-
if (
|
|
11432
|
-
if (
|
|
11428
|
+
for (let i2 = spine.length - 1; i2 >= 0; i2--) {
|
|
11429
|
+
const op2 = spine[i2];
|
|
11430
|
+
visit(op2.right, c);
|
|
11431
|
+
if (op2.op !== ":") continue;
|
|
11432
|
+
if (op2.left.type === "ref" && op2.right.type === "ref") {
|
|
11433
11433
|
const list = c.dynamic > 0 ? c.dynamicDeps : c.deps;
|
|
11434
11434
|
const l = list[list.length - 2];
|
|
11435
11435
|
const r = list[list.length - 1];
|
|
@@ -11599,8 +11599,8 @@ var ColumnIndex = class {
|
|
|
11599
11599
|
if (list[mid].row < start.row) lo = mid + 1;
|
|
11600
11600
|
else hi = mid;
|
|
11601
11601
|
}
|
|
11602
|
-
for (let
|
|
11603
|
-
const node = list[
|
|
11602
|
+
for (let i2 = lo; i2 < list.length; i2++) {
|
|
11603
|
+
const node = list[i2];
|
|
11604
11604
|
if (node.row > end.row) break;
|
|
11605
11605
|
out.push(node);
|
|
11606
11606
|
}
|
|
@@ -12141,11 +12141,11 @@ var EngineCore = class extends EngineHost {
|
|
|
12141
12141
|
}
|
|
12142
12142
|
run(seeds, everything) {
|
|
12143
12143
|
let current = seeds;
|
|
12144
|
-
for (let
|
|
12145
|
-
const dirty = everything &&
|
|
12144
|
+
for (let round3 = 0; round3 < MAX_ROUNDS && current.size; round3++) {
|
|
12145
|
+
const dirty = everything && round3 === 0 ? current : this.closure(current);
|
|
12146
12146
|
this.footprintChanges = [];
|
|
12147
12147
|
this.evaluatedAt = /* @__PURE__ */ new Map();
|
|
12148
|
-
this.evaluateSet(dirty, everything &&
|
|
12148
|
+
this.evaluateSet(dirty, everything && round3 === 0);
|
|
12149
12149
|
if (this.footprintChanges.length === 0) break;
|
|
12150
12150
|
const next = /* @__PURE__ */ new Set();
|
|
12151
12151
|
const reverse = this.reverse();
|
|
@@ -12561,22 +12561,22 @@ function shiftInterval(a, b, at, count2, max) {
|
|
|
12561
12561
|
function mergeSpacedAreas(tokens) {
|
|
12562
12562
|
const out = [];
|
|
12563
12563
|
const plainCell = (t) => t?.kind === "ref" && t.ref?.kind === "cell" && !t.spill;
|
|
12564
|
-
for (let
|
|
12565
|
-
const first2 = tokens[
|
|
12566
|
-
let j =
|
|
12564
|
+
for (let i2 = 0; i2 < tokens.length; i2++) {
|
|
12565
|
+
const first2 = tokens[i2];
|
|
12566
|
+
let j = i2 + 1;
|
|
12567
12567
|
while (tokens[j]?.kind === "ws") j++;
|
|
12568
12568
|
let k = j + 1;
|
|
12569
12569
|
while (tokens[k]?.kind === "ws") k++;
|
|
12570
12570
|
const colon = tokens[j];
|
|
12571
12571
|
const last = tokens[k];
|
|
12572
|
-
if (plainCell(first2) && colon?.kind === "op" && colon.text === ":" && plainCell(last) && !last?.prefix && k >
|
|
12573
|
-
const text = tokens.slice(
|
|
12572
|
+
if (plainCell(first2) && colon?.kind === "op" && colon.text === ":" && plainCell(last) && !last?.prefix && k > i2 + 2 && first2.ref && last?.ref) {
|
|
12573
|
+
const text = tokens.slice(i2, k + 1).map((t) => t.text).join("");
|
|
12574
12574
|
out.push({
|
|
12575
12575
|
...first2,
|
|
12576
12576
|
text,
|
|
12577
12577
|
ref: { kind: "area", start: first2.ref.start, end: last.ref.start }
|
|
12578
12578
|
});
|
|
12579
|
-
|
|
12579
|
+
i2 = k;
|
|
12580
12580
|
continue;
|
|
12581
12581
|
}
|
|
12582
12582
|
out.push(first2);
|
|
@@ -12751,8 +12751,8 @@ function a1For(ref, t) {
|
|
|
12751
12751
|
const { start, end } = table2.range;
|
|
12752
12752
|
const index2 = (name) => {
|
|
12753
12753
|
if (name === void 0) return void 0;
|
|
12754
|
-
const
|
|
12755
|
-
return
|
|
12754
|
+
const i2 = table2.columns.findIndex((c) => c.name.toLowerCase() === name.toLowerCase());
|
|
12755
|
+
return i2 < 0 ? -1 : start.col + i2;
|
|
12756
12756
|
};
|
|
12757
12757
|
const c1 = index2(ref.column);
|
|
12758
12758
|
const c2 = index2(ref.column2) ?? c1;
|
|
@@ -13001,7 +13001,7 @@ var CHART_COLOR_PALETTES = [
|
|
|
13001
13001
|
colorful(11, 2, ["accent1", "accent3", "accent5"]),
|
|
13002
13002
|
colorful(12, 3, ["accent2", "accent4", "accent6"]),
|
|
13003
13003
|
colorful(13, 4, ["accent6", "accent5", "accent4"]),
|
|
13004
|
-
...ACCENTS2.map((accent,
|
|
13004
|
+
...ACCENTS2.map((accent, i2) => mono(14 + i2, 1 + i2, accent, "withinLinear")),
|
|
13005
13005
|
{
|
|
13006
13006
|
id: 20,
|
|
13007
13007
|
group: "monochromatic",
|
|
@@ -13010,43 +13010,43 @@ var CHART_COLOR_PALETTES = [
|
|
|
13010
13010
|
base: ["dk1"],
|
|
13011
13011
|
variations: GRAY_VARIATIONS
|
|
13012
13012
|
},
|
|
13013
|
-
...ACCENTS2.map((accent,
|
|
13013
|
+
...ACCENTS2.map((accent, i2) => mono(21 + i2, 8 + i2, accent, "withinLinearReversed"))
|
|
13014
13014
|
];
|
|
13015
13015
|
function findChartColorPalette(id) {
|
|
13016
13016
|
return CHART_COLOR_PALETTES.find((palette) => palette.id === id);
|
|
13017
13017
|
}
|
|
13018
|
-
function withinLinearTransform(
|
|
13018
|
+
function withinLinearTransform(i2, n) {
|
|
13019
13019
|
if (n <= 1) {
|
|
13020
13020
|
return {};
|
|
13021
13021
|
}
|
|
13022
13022
|
const step = 140 / (n + 1);
|
|
13023
13023
|
const centre = (n - 1) / 2;
|
|
13024
|
-
const value2 = 100 - step * Math.abs(
|
|
13025
|
-
if (
|
|
13024
|
+
const value2 = 100 - step * Math.abs(i2 - centre);
|
|
13025
|
+
if (i2 < centre) {
|
|
13026
13026
|
return { shade: Math.floor(value2 + 1e-9) * 1e3 };
|
|
13027
13027
|
}
|
|
13028
|
-
if (
|
|
13028
|
+
if (i2 > centre) {
|
|
13029
13029
|
return { tint: Math.ceil(value2 - 1e-9) * 1e3 };
|
|
13030
13030
|
}
|
|
13031
13031
|
return {};
|
|
13032
13032
|
}
|
|
13033
|
-
function chartPaletteSeriesColorChoice(palette,
|
|
13033
|
+
function chartPaletteSeriesColorChoice(palette, i2, n) {
|
|
13034
13034
|
let base;
|
|
13035
|
-
let
|
|
13035
|
+
let transform6;
|
|
13036
13036
|
if (palette.meth === "cycle") {
|
|
13037
|
-
base = palette.base[
|
|
13038
|
-
const
|
|
13039
|
-
|
|
13037
|
+
base = palette.base[i2 % palette.base.length];
|
|
13038
|
+
const round3 = Math.floor(i2 / palette.base.length);
|
|
13039
|
+
transform6 = (palette.variations.length ? palette.variations[round3 % palette.variations.length] : {}) ?? {};
|
|
13040
13040
|
} else {
|
|
13041
|
-
const index2 = palette.meth === "withinLinearReversed" ? n - 1 -
|
|
13041
|
+
const index2 = palette.meth === "withinLinearReversed" ? n - 1 - i2 : i2;
|
|
13042
13042
|
base = palette.base[0];
|
|
13043
|
-
|
|
13043
|
+
transform6 = withinLinearTransform(index2, n);
|
|
13044
13044
|
}
|
|
13045
13045
|
if (!base) throw new RangeError("A chart palette must have a base color");
|
|
13046
13046
|
return {
|
|
13047
13047
|
kind: "scheme",
|
|
13048
13048
|
value: base,
|
|
13049
|
-
transforms: Object.entries(
|
|
13049
|
+
transforms: Object.entries(transform6).map(([name, value2]) => ({ name, value: String(value2) }))
|
|
13050
13050
|
};
|
|
13051
13051
|
}
|
|
13052
13052
|
|
|
@@ -13054,7 +13054,7 @@ function chartPaletteSeriesColorChoice(palette, i, n) {
|
|
|
13054
13054
|
function sameChartColor(a, b) {
|
|
13055
13055
|
if (!a || !b) return a === b;
|
|
13056
13056
|
return a.kind === b.kind && a.value === b.value && a.fallback === b.fallback && a.transforms.length === b.transforms.length && a.transforms.every(
|
|
13057
|
-
(t,
|
|
13057
|
+
(t, i2) => b.transforms[i2]?.name === t.name && b.transforms[i2]?.value === t.value
|
|
13058
13058
|
);
|
|
13059
13059
|
}
|
|
13060
13060
|
function recolorGradient(fill, previous, next) {
|
|
@@ -13123,38 +13123,38 @@ function chartColorPalettePatch(chart, id) {
|
|
|
13123
13123
|
var HLSMAX = 240;
|
|
13124
13124
|
var RGBMAX = 255;
|
|
13125
13125
|
var idiv = (a, b) => Math.trunc(a / b);
|
|
13126
|
-
function rgbToHls240(r,
|
|
13127
|
-
const max = Math.max(r,
|
|
13128
|
-
const min = Math.min(r,
|
|
13126
|
+
function rgbToHls240(r, g2, b) {
|
|
13127
|
+
const max = Math.max(r, g2, b);
|
|
13128
|
+
const min = Math.min(r, g2, b);
|
|
13129
13129
|
const l = idiv((max + min) * HLSMAX + RGBMAX, 2 * RGBMAX);
|
|
13130
13130
|
if (max === min) return { h: idiv(HLSMAX * 2, 3), l, s: 0 };
|
|
13131
13131
|
const sum2 = max + min;
|
|
13132
13132
|
const s = l <= HLSMAX / 2 ? idiv((max - min) * HLSMAX + idiv(sum2, 2), sum2) : idiv((max - min) * HLSMAX + idiv(2 * RGBMAX - sum2, 2), 2 * RGBMAX - sum2);
|
|
13133
13133
|
const delta = (c) => idiv((max - c) * idiv(HLSMAX, 6) + idiv(max - min, 2), max - min);
|
|
13134
13134
|
const rd = delta(r);
|
|
13135
|
-
const gd = delta(
|
|
13135
|
+
const gd = delta(g2);
|
|
13136
13136
|
const bd = delta(b);
|
|
13137
|
-
let
|
|
13138
|
-
if (r === max)
|
|
13139
|
-
else if (
|
|
13140
|
-
else
|
|
13141
|
-
if (
|
|
13142
|
-
if (
|
|
13143
|
-
return { h, l, s };
|
|
13137
|
+
let h2;
|
|
13138
|
+
if (r === max) h2 = bd - gd;
|
|
13139
|
+
else if (g2 === max) h2 = idiv(HLSMAX, 3) + rd - bd;
|
|
13140
|
+
else h2 = idiv(2 * HLSMAX, 3) + gd - rd;
|
|
13141
|
+
if (h2 < 0) h2 += HLSMAX;
|
|
13142
|
+
if (h2 > HLSMAX) h2 -= HLSMAX;
|
|
13143
|
+
return { h: h2, l, s };
|
|
13144
13144
|
}
|
|
13145
13145
|
function hueToRgb(n1, n2, hue) {
|
|
13146
|
-
let
|
|
13147
|
-
if (
|
|
13148
|
-
if (
|
|
13146
|
+
let h2 = hue;
|
|
13147
|
+
if (h2 < 0) h2 += HLSMAX;
|
|
13148
|
+
if (h2 > HLSMAX) h2 -= HLSMAX;
|
|
13149
13149
|
const sixth = idiv(HLSMAX, 6);
|
|
13150
|
-
if (
|
|
13151
|
-
if (
|
|
13152
|
-
if (
|
|
13153
|
-
return n1 + idiv((n2 - n1) * (idiv(HLSMAX * 2, 3) -
|
|
13150
|
+
if (h2 < sixth) return n1 + idiv((n2 - n1) * h2 + idiv(HLSMAX, 12), sixth);
|
|
13151
|
+
if (h2 < idiv(HLSMAX, 2)) return n2;
|
|
13152
|
+
if (h2 < idiv(HLSMAX * 2, 3))
|
|
13153
|
+
return n1 + idiv((n2 - n1) * (idiv(HLSMAX * 2, 3) - h2) + idiv(HLSMAX, 12), sixth);
|
|
13154
13154
|
return n1;
|
|
13155
13155
|
}
|
|
13156
13156
|
var clamp255 = (v) => Math.max(0, Math.min(255, v));
|
|
13157
|
-
function hls240ToRgb({ h, l, s }) {
|
|
13157
|
+
function hls240ToRgb({ h: h2, l, s }) {
|
|
13158
13158
|
if (s === 0) {
|
|
13159
13159
|
const v = clamp255(Math.round(l * RGBMAX / HLSMAX));
|
|
13160
13160
|
return [v, v, v];
|
|
@@ -13162,13 +13162,13 @@ function hls240ToRgb({ h, l, s }) {
|
|
|
13162
13162
|
const m2 = l <= HLSMAX / 2 ? idiv(l * (HLSMAX + s) + idiv(HLSMAX, 2), HLSMAX) : l + s - idiv(l * s + idiv(HLSMAX, 2), HLSMAX);
|
|
13163
13163
|
const m1 = 2 * l - m2;
|
|
13164
13164
|
const channel = (hue) => clamp255(idiv(hueToRgb(m1, m2, hue) * RGBMAX + idiv(HLSMAX, 2), HLSMAX));
|
|
13165
|
-
return [channel(
|
|
13165
|
+
return [channel(h2 + idiv(HLSMAX, 3)), channel(h2), channel(h2 - idiv(HLSMAX, 3))];
|
|
13166
13166
|
}
|
|
13167
13167
|
function parseHex(hex2) {
|
|
13168
13168
|
const clean2 = hex2.replace(/^#/, "");
|
|
13169
13169
|
const rgb2 = clean2.length === 8 ? clean2.slice(2) : clean2;
|
|
13170
13170
|
if (!/^[0-9a-fA-F]{6}$/.test(rgb2)) return void 0;
|
|
13171
|
-
return [0, 2, 4].map((
|
|
13171
|
+
return [0, 2, 4].map((i2) => parseInt(rgb2.slice(i2, i2 + 2), 16));
|
|
13172
13172
|
}
|
|
13173
13173
|
var toHexColor = (rgb2) => `#${rgb2.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
13174
13174
|
function applyTint(hex2, tint) {
|
|
@@ -13296,8 +13296,8 @@ function mixColors(a, b, t, rounding = "nearest") {
|
|
|
13296
13296
|
const cb = parseHex(b) ?? [0, 0, 0];
|
|
13297
13297
|
const k = Math.max(0, Math.min(1, t));
|
|
13298
13298
|
return toHexColor(
|
|
13299
|
-
ca.map((v,
|
|
13300
|
-
const delta = ((cb[
|
|
13299
|
+
ca.map((v, i2) => {
|
|
13300
|
+
const delta = ((cb[i2] ?? 0) - v) * k;
|
|
13301
13301
|
return v + (rounding === "towardStart" ? Math.trunc(delta) : delta);
|
|
13302
13302
|
})
|
|
13303
13303
|
);
|
|
@@ -13681,15 +13681,15 @@ function clearIn(ctx, sheet, r, what) {
|
|
|
13681
13681
|
(c) => !rangesIntersect(cellRange(c.address.row, c.address.col), r)
|
|
13682
13682
|
);
|
|
13683
13683
|
if (what === "all" || what === "hyperlinks")
|
|
13684
|
-
sheet.hyperlinks = sheet.hyperlinks.filter((
|
|
13684
|
+
sheet.hyperlinks = sheet.hyperlinks.filter((h2) => !rangesIntersect(h2.range, r));
|
|
13685
13685
|
}
|
|
13686
13686
|
|
|
13687
13687
|
// xlsx/edit/columns.ts
|
|
13688
13688
|
function copyColumnWidths(sheet, start, end) {
|
|
13689
13689
|
const fallback = sheet.defaultColWidth ?? DEFAULT_COL_WIDTH;
|
|
13690
13690
|
const widths = Array(end - start + 1).fill(fallback);
|
|
13691
|
-
for (let
|
|
13692
|
-
const info = sheet.columns[
|
|
13691
|
+
for (let i2 = sheet.columns.length - 1; i2 >= 0; i2--) {
|
|
13692
|
+
const info = sheet.columns[i2];
|
|
13693
13693
|
const first2 = Math.max(start, info.min);
|
|
13694
13694
|
const last = Math.min(end, info.max);
|
|
13695
13695
|
if (first2 <= last)
|
|
@@ -13974,7 +13974,7 @@ function dateSeries(serials, date1904, format) {
|
|
|
13974
13974
|
const monthIndex = dates.map((d) => d.getUTCFullYear() * 12 + d.getUTCMonth());
|
|
13975
13975
|
const sameDay = dates.every((d) => d.getUTCDate() === dates[0]?.getUTCDate());
|
|
13976
13976
|
const stepMonths = (monthIndex[1] ?? 0) - (monthIndex[0] ?? 0);
|
|
13977
|
-
const evenMonths = stepMonths !== 0 && monthIndex.every((m,
|
|
13977
|
+
const evenMonths = stepMonths !== 0 && monthIndex.every((m, i2) => m - (monthIndex[0] ?? 0) === stepMonths * i2);
|
|
13978
13978
|
const first2 = serials[0] ?? 0;
|
|
13979
13979
|
if (sameDay && evenMonths)
|
|
13980
13980
|
return (k) => ({ kind: "value", value: addMonths2(first2, stepMonths * k, date1904) });
|
|
@@ -14035,21 +14035,21 @@ function fillRange(ctx, s, source, target2, mode = "auto") {
|
|
|
14035
14035
|
const laneCount = vertical2 ? src.end.col - src.start.col + 1 : src.end.row - src.start.row + 1;
|
|
14036
14036
|
const length = vertical2 ? src.end.row - src.start.row + 1 : src.end.col - src.start.col + 1;
|
|
14037
14037
|
for (let lane = 0; lane < laneCount; lane++) {
|
|
14038
|
-
const at = (
|
|
14039
|
-
const cells = Array.from({ length }, (_v,
|
|
14038
|
+
const at = (i2) => vertical2 ? [src.start.row + i2, src.start.col + lane] : [src.start.row + lane, src.start.col + i2];
|
|
14039
|
+
const cells = Array.from({ length }, (_v, i2) => getCell(sheet, ...at(i2)));
|
|
14040
14040
|
const series = mode === "auto" ? detectSeries(ctx.workbook, cells) : void 0;
|
|
14041
14041
|
const from = vertical2 ? all2.start.row - src.start.row : all2.start.col - src.start.col;
|
|
14042
14042
|
const to = vertical2 ? all2.end.row - src.start.row : all2.end.col - src.start.col;
|
|
14043
14043
|
for (let k = from; k <= to; k++) {
|
|
14044
14044
|
if (k >= 0 && k < length) continue;
|
|
14045
14045
|
const [row2, col] = at(k);
|
|
14046
|
-
const
|
|
14047
|
-
const origin = cells[
|
|
14046
|
+
const i2 = mod(k, length);
|
|
14047
|
+
const origin = cells[i2];
|
|
14048
14048
|
if (!origin) {
|
|
14049
14049
|
deleteCell(sheet, row2, col);
|
|
14050
14050
|
continue;
|
|
14051
14051
|
}
|
|
14052
|
-
const [srcRow, srcCol] = at(
|
|
14052
|
+
const [srcRow, srcCol] = at(i2);
|
|
14053
14053
|
const step = series?.(k);
|
|
14054
14054
|
const cell = !step || step.kind === "copy" ? copyCell(origin, row2 - srcRow, col - srcCol) : { value: step.value, ...origin.styleId ? { styleId: origin.styleId } : {} };
|
|
14055
14055
|
putCell(sheet, row2, col, cell);
|
|
@@ -14120,11 +14120,11 @@ function formatAt(sheet, index2) {
|
|
|
14120
14120
|
return format;
|
|
14121
14121
|
}
|
|
14122
14122
|
function rulesByPriority(sheet) {
|
|
14123
|
-
return sheet.conditionalFormats.flatMap((
|
|
14123
|
+
return sheet.conditionalFormats.flatMap((f6) => f6.rules).map((rule, order) => ({ rule, order })).sort((a, b) => a.rule.priority - b.rule.priority || a.order - b.order).map((e) => e.rule);
|
|
14124
14124
|
}
|
|
14125
14125
|
function renumber(rules) {
|
|
14126
|
-
rules.forEach((rule,
|
|
14127
|
-
rule.priority =
|
|
14126
|
+
rules.forEach((rule, i2) => {
|
|
14127
|
+
rule.priority = i2 + 1;
|
|
14128
14128
|
});
|
|
14129
14129
|
}
|
|
14130
14130
|
function replaceConditionalFormat(ctx, s, index2, format) {
|
|
@@ -14167,7 +14167,7 @@ function setConditionalRulePriority(ctx, s, formatIndex, ruleIndex, priority) {
|
|
|
14167
14167
|
const order = rulesByPriority(sheet);
|
|
14168
14168
|
const from = order.indexOf(rule);
|
|
14169
14169
|
const to = Math.max(0, Math.min(order.length - 1, Math.round(priority) - 1));
|
|
14170
|
-
if (from === to && order.every((r,
|
|
14170
|
+
if (from === to && order.every((r, i2) => r.priority === i2 + 1)) return;
|
|
14171
14171
|
ctx.run(
|
|
14172
14172
|
"Rule priority",
|
|
14173
14173
|
"format",
|
|
@@ -14202,7 +14202,7 @@ function randomBytes(length) {
|
|
|
14202
14202
|
const cryptoObj = globalThis.crypto;
|
|
14203
14203
|
if (cryptoObj?.getRandomValues) return cryptoObj.getRandomValues(new Uint8Array(length));
|
|
14204
14204
|
const bytes = new Uint8Array(length);
|
|
14205
|
-
for (let
|
|
14205
|
+
for (let i2 = 0; i2 < length; i2++) bytes[i2] = Math.floor(Math.random() * 256);
|
|
14206
14206
|
return bytes;
|
|
14207
14207
|
}
|
|
14208
14208
|
function randomHex(length) {
|
|
@@ -14223,7 +14223,7 @@ function rebaseConditionalFormat(format, ranges) {
|
|
|
14223
14223
|
for (const rule of next.rules)
|
|
14224
14224
|
rewriteConditionalRule(
|
|
14225
14225
|
rule,
|
|
14226
|
-
(
|
|
14226
|
+
(f6) => moveValidationFormula(f6, to.row - from.row, to.col - from.col)
|
|
14227
14227
|
);
|
|
14228
14228
|
return next;
|
|
14229
14229
|
}
|
|
@@ -14296,8 +14296,8 @@ function pasteConditionalFormats(sheet, dest, cells, transpose2, skipBlanks, cut
|
|
|
14296
14296
|
for (const rule of next.rules)
|
|
14297
14297
|
rewriteConditionalRule(
|
|
14298
14298
|
rule,
|
|
14299
|
-
cutFormula ?? ((
|
|
14300
|
-
|
|
14299
|
+
cutFormula ?? ((f6) => moveValidationFormula(
|
|
14300
|
+
f6,
|
|
14301
14301
|
target2.row - origin.row - source.row,
|
|
14302
14302
|
target2.col - origin.col - source.col
|
|
14303
14303
|
))
|
|
@@ -14342,7 +14342,7 @@ function setComment(ctx, s, at, text, author) {
|
|
|
14342
14342
|
function setHyperlink(ctx, s, range2, link) {
|
|
14343
14343
|
const sheet = sheetAt(ctx.workbook, s);
|
|
14344
14344
|
const r = normalizeRange(range2);
|
|
14345
|
-
if (!link && !sheet.hyperlinks.some((
|
|
14345
|
+
if (!link && !sheet.hyperlinks.some((h2) => rangesIntersect(h2.range, r))) return;
|
|
14346
14346
|
if (link && !link.target && !link.location)
|
|
14347
14347
|
throw new Error("A hyperlink needs a target or a location.");
|
|
14348
14348
|
ctx.run(
|
|
@@ -14350,7 +14350,7 @@ function setHyperlink(ctx, s, range2, link) {
|
|
|
14350
14350
|
"annotations",
|
|
14351
14351
|
[{ kind: "sheet", sheet: s }],
|
|
14352
14352
|
() => {
|
|
14353
|
-
sheet.hyperlinks = sheet.hyperlinks.filter((
|
|
14353
|
+
sheet.hyperlinks = sheet.hyperlinks.filter((h2) => !rangesIntersect(h2.range, r));
|
|
14354
14354
|
if (!link) return;
|
|
14355
14355
|
sheet.hyperlinks.push({ ...structuredClone(link), range: r });
|
|
14356
14356
|
const anchor = getCell(sheet, r.start.row, r.start.col);
|
|
@@ -14379,8 +14379,8 @@ function addConditionalFormat(ctx, s, format) {
|
|
|
14379
14379
|
for (const rule of cf.rules) rule.priority += count2;
|
|
14380
14380
|
const added = structuredClone(format);
|
|
14381
14381
|
added.ranges = added.ranges.map(normalizeRange);
|
|
14382
|
-
added.rules.forEach((rule,
|
|
14383
|
-
rule.priority =
|
|
14382
|
+
added.rules.forEach((rule, i2) => {
|
|
14383
|
+
rule.priority = i2 + 1;
|
|
14384
14384
|
});
|
|
14385
14385
|
sheet.conditionalFormats.push(added);
|
|
14386
14386
|
},
|
|
@@ -14620,8 +14620,8 @@ function rewritePreservedFormulas(sheet, rewrite2) {
|
|
|
14620
14620
|
"extLst",
|
|
14621
14621
|
(root) => {
|
|
14622
14622
|
let changed = false;
|
|
14623
|
-
for (const
|
|
14624
|
-
const text =
|
|
14623
|
+
for (const f6 of descendants2(root, XM2, "f")) {
|
|
14624
|
+
const text = f6.textContent ?? "";
|
|
14625
14625
|
let next = text;
|
|
14626
14626
|
try {
|
|
14627
14627
|
next = rewrite2(text, sheet.name);
|
|
@@ -14629,7 +14629,7 @@ function rewritePreservedFormulas(sheet, rewrite2) {
|
|
|
14629
14629
|
next = text;
|
|
14630
14630
|
}
|
|
14631
14631
|
if (next === text) continue;
|
|
14632
|
-
|
|
14632
|
+
f6.textContent = next;
|
|
14633
14633
|
changed = true;
|
|
14634
14634
|
}
|
|
14635
14635
|
return changed ? "changed" : "same";
|
|
@@ -14665,7 +14665,7 @@ function rewriteSheetFormulas(sheet, rewrite2) {
|
|
|
14665
14665
|
for (const cell of cells.values())
|
|
14666
14666
|
if (cell.formula !== void 0) cell.formula = safe(rewrite2, cell.formula, name);
|
|
14667
14667
|
for (const cf of sheet.conditionalFormats)
|
|
14668
|
-
for (const rule of cf.rules) rewriteConditionalRule(rule, (
|
|
14668
|
+
for (const rule of cf.rules) rewriteConditionalRule(rule, (f6) => rewrite2(f6, name));
|
|
14669
14669
|
for (const dv of sheet.dataValidations) {
|
|
14670
14670
|
if (dv.formula1 !== void 0) dv.formula1 = safe(rewrite2, dv.formula1, name);
|
|
14671
14671
|
if (dv.formula2 !== void 0) dv.formula2 = safe(rewrite2, dv.formula2, name);
|
|
@@ -14691,9 +14691,9 @@ function shiftSheetContent(sheet, shift2, band) {
|
|
|
14691
14691
|
sheet.merges = sheet.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
|
|
14692
14692
|
sheet.conditionalFormats = sheet.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
|
|
14693
14693
|
sheet.dataValidations = sheet.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
|
|
14694
|
-
sheet.hyperlinks = sheet.hyperlinks.flatMap((
|
|
14695
|
-
const range2 = moveRange(
|
|
14696
|
-
return range2 ? [{ ...
|
|
14694
|
+
sheet.hyperlinks = sheet.hyperlinks.flatMap((h2) => {
|
|
14695
|
+
const range2 = moveRange(h2.range);
|
|
14696
|
+
return range2 ? [{ ...h2, range: range2 }] : [];
|
|
14697
14697
|
});
|
|
14698
14698
|
sheet.comments = sheet.comments.flatMap((c) => {
|
|
14699
14699
|
const range2 = moveRange({ start: c.address, end: c.address });
|
|
@@ -14757,17 +14757,17 @@ function shiftTable(sheet, table2, shift2, moveRange) {
|
|
|
14757
14757
|
if (shift2.axis === "col" && widened) {
|
|
14758
14758
|
if (shift2.count > 0) {
|
|
14759
14759
|
const offset2 = shift2.at - old.start.col;
|
|
14760
|
-
for (let
|
|
14760
|
+
for (let i2 = 0; i2 < shift2.count; i2++) {
|
|
14761
14761
|
const column = { name: uniqueColumnName(next.columns) };
|
|
14762
|
-
next.columns.splice(offset2 +
|
|
14762
|
+
next.columns.splice(offset2 + i2, 0, column);
|
|
14763
14763
|
if (next.headerRow) {
|
|
14764
14764
|
const cell = { value: column.name };
|
|
14765
|
-
putCell(sheet, range2.start.row, shift2.at +
|
|
14765
|
+
putCell(sheet, range2.start.row, shift2.at + i2, cell);
|
|
14766
14766
|
}
|
|
14767
14767
|
}
|
|
14768
14768
|
} else {
|
|
14769
14769
|
next.columns = next.columns.filter(
|
|
14770
|
-
(_c,
|
|
14770
|
+
(_c, i2) => shiftIndex(old.start.col + i2, shift2) !== void 0
|
|
14771
14771
|
);
|
|
14772
14772
|
}
|
|
14773
14773
|
}
|
|
@@ -15007,8 +15007,8 @@ function cssFor(style2, theme2) {
|
|
|
15007
15007
|
const bg = cssColor(style2.fill.fgColor, theme2);
|
|
15008
15008
|
if (bg) css.push(`background:${bg}`);
|
|
15009
15009
|
}
|
|
15010
|
-
const
|
|
15011
|
-
if (
|
|
15010
|
+
const h2 = style2.alignment?.horizontal;
|
|
15011
|
+
if (h2 && h2 !== "general") css.push(`text-align:${h2 === "centerContinuous" ? "center" : h2}`);
|
|
15012
15012
|
const v = style2.alignment?.vertical;
|
|
15013
15013
|
if (v) css.push(`vertical-align:${v === "center" ? "middle" : v}`);
|
|
15014
15014
|
if (style2.alignment?.wrapText) css.push("white-space:normal");
|
|
@@ -15160,9 +15160,9 @@ function stylePatchFromCss(css, inner2) {
|
|
|
15160
15160
|
const background = css.get("background-color") ?? css.get("background");
|
|
15161
15161
|
const fill = background && parseCssColor(background.split(/\s+/)[0] ?? "");
|
|
15162
15162
|
if (fill) patch.fill = { type: "pattern", pattern: "solid", fgColor: fill };
|
|
15163
|
-
const
|
|
15163
|
+
const h2 = H_ALIGN[css.get("text-align") ?? ""];
|
|
15164
15164
|
const v = V_ALIGN[css.get("vertical-align") ?? ""];
|
|
15165
|
-
if (
|
|
15165
|
+
if (h2 || v) patch.alignment = { ...h2 ? { horizontal: h2 } : {}, ...v ? { vertical: v } : {} };
|
|
15166
15166
|
const numFmt = css.get("mso-number-format");
|
|
15167
15167
|
if (numFmt) patch.numFmt = decodeNumberFormat(numFmt);
|
|
15168
15168
|
return patch;
|
|
@@ -15180,19 +15180,19 @@ function removeComments(text) {
|
|
|
15180
15180
|
}
|
|
15181
15181
|
function removeTags(text) {
|
|
15182
15182
|
let out = "";
|
|
15183
|
-
let
|
|
15184
|
-
while (
|
|
15185
|
-
const ch = text[
|
|
15183
|
+
let i2 = 0;
|
|
15184
|
+
while (i2 < text.length) {
|
|
15185
|
+
const ch = text[i2];
|
|
15186
15186
|
if (ch === "<") {
|
|
15187
|
-
let j =
|
|
15187
|
+
let j = i2 + 1;
|
|
15188
15188
|
while (j < text.length && text[j] !== "<" && text[j] !== ">") j++;
|
|
15189
15189
|
if (text[j] === ">") {
|
|
15190
|
-
|
|
15190
|
+
i2 = j + 1;
|
|
15191
15191
|
continue;
|
|
15192
15192
|
}
|
|
15193
15193
|
}
|
|
15194
15194
|
out += ch;
|
|
15195
|
-
|
|
15195
|
+
i2++;
|
|
15196
15196
|
}
|
|
15197
15197
|
return out;
|
|
15198
15198
|
}
|
|
@@ -15274,10 +15274,10 @@ function parseHtmlTable(html, base) {
|
|
|
15274
15274
|
r++;
|
|
15275
15275
|
}
|
|
15276
15276
|
const rows2 = grid6.length;
|
|
15277
|
-
const cols = Math.max(0, ...grid6.map((
|
|
15277
|
+
const cols = Math.max(0, ...grid6.map((g2) => g2.length));
|
|
15278
15278
|
const data = Array.from(
|
|
15279
15279
|
{ length: rows2 },
|
|
15280
|
-
(_v,
|
|
15280
|
+
(_v, i2) => Array.from({ length: cols }, (_w, j) => grid6[i2]?.[j] ?? null)
|
|
15281
15281
|
);
|
|
15282
15282
|
return rows2 && cols ? { rows: rows2, cols, data, merges, hyperlinks } : void 0;
|
|
15283
15283
|
}
|
|
@@ -15306,19 +15306,19 @@ function parseTsv(text) {
|
|
|
15306
15306
|
const rows2 = [];
|
|
15307
15307
|
let row2 = [];
|
|
15308
15308
|
let field = "";
|
|
15309
|
-
let
|
|
15309
|
+
let i2 = 0;
|
|
15310
15310
|
let atFieldStart = true;
|
|
15311
15311
|
const body2 = text.replace(/\r\n?/g, "\n").replace(/\n$/, "");
|
|
15312
15312
|
if (body2 === "") return text === "" ? [] : [[""]];
|
|
15313
|
-
while (
|
|
15314
|
-
const ch = body2[
|
|
15313
|
+
while (i2 < body2.length) {
|
|
15314
|
+
const ch = body2[i2] ?? "";
|
|
15315
15315
|
if (atFieldStart && ch === '"') {
|
|
15316
|
-
const close = findClosingQuote(body2,
|
|
15316
|
+
const close = findClosingQuote(body2, i2 + 1);
|
|
15317
15317
|
if (close >= 0) {
|
|
15318
15318
|
const next = body2[close + 1];
|
|
15319
15319
|
if (next === void 0 || next === " " || next === "\n") {
|
|
15320
|
-
field = body2.slice(
|
|
15321
|
-
|
|
15320
|
+
field = body2.slice(i2 + 1, close).replace(/""/g, '"');
|
|
15321
|
+
i2 = close + 1;
|
|
15322
15322
|
atFieldStart = false;
|
|
15323
15323
|
continue;
|
|
15324
15324
|
}
|
|
@@ -15336,7 +15336,7 @@ function parseTsv(text) {
|
|
|
15336
15336
|
field = "";
|
|
15337
15337
|
atFieldStart = true;
|
|
15338
15338
|
} else field += ch;
|
|
15339
|
-
|
|
15339
|
+
i2++;
|
|
15340
15340
|
}
|
|
15341
15341
|
row2.push(field);
|
|
15342
15342
|
rows2.push(row2);
|
|
@@ -15345,13 +15345,13 @@ function parseTsv(text) {
|
|
|
15345
15345
|
return rows2;
|
|
15346
15346
|
}
|
|
15347
15347
|
function findClosingQuote(text, from) {
|
|
15348
|
-
for (let
|
|
15349
|
-
if (text[
|
|
15350
|
-
if (text[
|
|
15351
|
-
|
|
15348
|
+
for (let i2 = from; i2 < text.length; i2++) {
|
|
15349
|
+
if (text[i2] !== '"') continue;
|
|
15350
|
+
if (text[i2 + 1] === '"') {
|
|
15351
|
+
i2++;
|
|
15352
15352
|
continue;
|
|
15353
15353
|
}
|
|
15354
|
-
return
|
|
15354
|
+
return i2;
|
|
15355
15355
|
}
|
|
15356
15356
|
return -1;
|
|
15357
15357
|
}
|
|
@@ -15400,12 +15400,12 @@ function pasteArithmetic(destination, source, operation) {
|
|
|
15400
15400
|
return { value: dest.value, ...dest.formula !== void 0 ? { formula: dest.formula } : {} };
|
|
15401
15401
|
if (source.value === null && dest.value === null && !source.formula && !dest.formula)
|
|
15402
15402
|
return { value: null };
|
|
15403
|
-
const
|
|
15403
|
+
const op2 = OPS[operation];
|
|
15404
15404
|
const result2 = {
|
|
15405
|
-
value: scalarBinary(
|
|
15405
|
+
value: scalarBinary(op2, dest.value, source.value)
|
|
15406
15406
|
};
|
|
15407
15407
|
if (dest.formula !== void 0 || source.formula !== void 0)
|
|
15408
|
-
result2.formula = `${operand2(dest)}${
|
|
15408
|
+
result2.formula = `${operand2(dest)}${op2}${operand2(source)}`;
|
|
15409
15409
|
return result2;
|
|
15410
15410
|
}
|
|
15411
15411
|
|
|
@@ -15696,7 +15696,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15696
15696
|
if (cut && move) {
|
|
15697
15697
|
const from = sheetAt(workbook, cut.sheet);
|
|
15698
15698
|
removeConditionalArea(from, cut.range);
|
|
15699
|
-
rewriteFormulas(workbook, (
|
|
15699
|
+
rewriteFormulas(workbook, (f6, fs) => moveReferencesInFormula(f6, fs, move));
|
|
15700
15700
|
const doomed = [];
|
|
15701
15701
|
forEachCellInRange(from, cut.range, (_c, row2, col) => doomed.push([row2, col]));
|
|
15702
15702
|
for (const [row2, col] of doomed) deleteCell(from, row2, col);
|
|
@@ -15711,7 +15711,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15711
15711
|
mode,
|
|
15712
15712
|
transpose2,
|
|
15713
15713
|
skipBlanks,
|
|
15714
|
-
move ? (
|
|
15714
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0
|
|
15715
15715
|
);
|
|
15716
15716
|
if (mode === "all" || mode === "mergeFormats" || mode === "noBorders")
|
|
15717
15717
|
pasteHyperlinks(
|
|
@@ -15720,7 +15720,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15720
15720
|
cells,
|
|
15721
15721
|
transpose2,
|
|
15722
15722
|
skipBlanks,
|
|
15723
|
-
move ? (
|
|
15723
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0
|
|
15724
15724
|
);
|
|
15725
15725
|
const styleIds = /* @__PURE__ */ new Map();
|
|
15726
15726
|
if (mode === "all" || mode === "mergeFormats" || mode === "noBorders" || mode === "formats")
|
|
@@ -15730,7 +15730,7 @@ function pasteAt(ctx, s, at, payload, request) {
|
|
|
15730
15730
|
cells,
|
|
15731
15731
|
transpose2,
|
|
15732
15732
|
skipBlanks,
|
|
15733
|
-
move ? (
|
|
15733
|
+
move ? (f6) => moveReferencesInFormula(f6, move.fromSheet, move, move.toSheet) : void 0,
|
|
15734
15734
|
mode === "mergeFormats"
|
|
15735
15735
|
);
|
|
15736
15736
|
const styleOf = (clip) => {
|
|
@@ -15902,10 +15902,10 @@ function setRowHeight(ctx, s, rows2, height) {
|
|
|
15902
15902
|
else info.height = fit;
|
|
15903
15903
|
delete info.customHeight;
|
|
15904
15904
|
} else {
|
|
15905
|
-
const
|
|
15906
|
-
info.height =
|
|
15905
|
+
const h2 = Math.max(0, Math.min(MAX_HEIGHT, height));
|
|
15906
|
+
info.height = h2;
|
|
15907
15907
|
info.customHeight = true;
|
|
15908
|
-
if (
|
|
15908
|
+
if (h2 === 0) info.hidden = true;
|
|
15909
15909
|
else delete info.hidden;
|
|
15910
15910
|
}
|
|
15911
15911
|
if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
|
|
@@ -16007,9 +16007,9 @@ function sortRows2(sheet, range2, keys, hasHeader) {
|
|
|
16007
16007
|
return 0;
|
|
16008
16008
|
});
|
|
16009
16009
|
for (const { row: row2, cells } of rows2) for (const col of cells.keys()) deleteCell(sheet, row2, col);
|
|
16010
|
-
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source,
|
|
16011
|
-
sorted2.forEach((source,
|
|
16012
|
-
const row2 = firstRow +
|
|
16010
|
+
moveAnnotations(sheet, dataArea, new Map(sorted2.map((source, i2) => [source.row, firstRow + i2])));
|
|
16011
|
+
sorted2.forEach((source, i2) => {
|
|
16012
|
+
const row2 = firstRow + i2;
|
|
16013
16013
|
const dRow = row2 - source.row;
|
|
16014
16014
|
for (const [col, cell] of source.cells) {
|
|
16015
16015
|
if (cell.formula !== void 0 && dRow) {
|
|
@@ -16204,10 +16204,10 @@ function queryPattern(query, global = false) {
|
|
|
16204
16204
|
if (!query.text) return void 0;
|
|
16205
16205
|
let source = "";
|
|
16206
16206
|
const wildcards = query.wildcards ?? true;
|
|
16207
|
-
for (let
|
|
16208
|
-
const ch = query.text[
|
|
16209
|
-
if (wildcards && ch === "~" &&
|
|
16210
|
-
source += escapeRegex2(query.text[++
|
|
16207
|
+
for (let i2 = 0; i2 < query.text.length; i2++) {
|
|
16208
|
+
const ch = query.text[i2] ?? "";
|
|
16209
|
+
if (wildcards && ch === "~" && i2 + 1 < query.text.length) {
|
|
16210
|
+
source += escapeRegex2(query.text[++i2] ?? "");
|
|
16211
16211
|
} else if (wildcards && ch === "*") source += "[\\s\\S]*";
|
|
16212
16212
|
else if (wildcards && ch === "?") source += "[\\s\\S]";
|
|
16213
16213
|
else source += escapeRegex2(ch);
|
|
@@ -16227,7 +16227,7 @@ function searchText(workbook, query, sheet, row2, col) {
|
|
|
16227
16227
|
function findAll(workbook, query) {
|
|
16228
16228
|
const pattern = queryPattern(query);
|
|
16229
16229
|
if (!pattern) return [];
|
|
16230
|
-
const indices = query.sheet !== void 0 ? [query.sheet] : workbook.sheets.map((_s,
|
|
16230
|
+
const indices = query.sheet !== void 0 ? [query.sheet] : workbook.sheets.map((_s, i2) => i2);
|
|
16231
16231
|
const matches2 = [];
|
|
16232
16232
|
for (const s of indices) {
|
|
16233
16233
|
const sheet = workbook.sheets[s];
|
|
@@ -16622,8 +16622,8 @@ var History = class {
|
|
|
16622
16622
|
undo(workbook) {
|
|
16623
16623
|
const step = this.done.pop();
|
|
16624
16624
|
if (!step) return void 0;
|
|
16625
|
-
for (let
|
|
16626
|
-
const entry = step.entries[
|
|
16625
|
+
for (let i2 = step.entries.length - 1; i2 >= 0; i2--) {
|
|
16626
|
+
const entry = step.entries[i2];
|
|
16627
16627
|
if (entry) restoreSnapshot(workbook, entry.before);
|
|
16628
16628
|
}
|
|
16629
16629
|
this.undone.push(step);
|
|
@@ -16894,8 +16894,8 @@ function updateChart(ctx, s, index2, patch) {
|
|
|
16894
16894
|
const changes = structuredClone(patch);
|
|
16895
16895
|
delete changes.elementFills;
|
|
16896
16896
|
if (formatting) live.formatting = formatting;
|
|
16897
|
-
changes.series?.forEach((series,
|
|
16898
|
-
const before = live.series[
|
|
16897
|
+
changes.series?.forEach((series, i2) => {
|
|
16898
|
+
const before = live.series[i2];
|
|
16899
16899
|
if (!before) return;
|
|
16900
16900
|
const legacyChanged = JSON.stringify(before.color) !== JSON.stringify(series.color);
|
|
16901
16901
|
const drawingChanged = JSON.stringify(before.drawingColor) !== JSON.stringify(series.drawingColor);
|
|
@@ -16994,8 +16994,8 @@ function applyTotalsRow(sheet, table2) {
|
|
|
16994
16994
|
if (first2 && columns.length > 1) first2.totalsRowLabel = "Total";
|
|
16995
16995
|
if (last) last.totalsRowFunction = "sum";
|
|
16996
16996
|
}
|
|
16997
|
-
columns.forEach((column,
|
|
16998
|
-
const col = table2.range.start.col +
|
|
16997
|
+
columns.forEach((column, i2) => {
|
|
16998
|
+
const col = table2.range.start.col + i2;
|
|
16999
16999
|
const code = SUBTOTAL[column.totalsRowFunction ?? ""];
|
|
17000
17000
|
if (code !== void 0) {
|
|
17001
17001
|
const cell = ensureCell(sheet, row2, col);
|
|
@@ -17014,8 +17014,8 @@ function nextTableName(workbook) {
|
|
|
17014
17014
|
}
|
|
17015
17015
|
function uniqueHeaders(texts) {
|
|
17016
17016
|
const used = /* @__PURE__ */ new Set();
|
|
17017
|
-
return texts.map((text,
|
|
17018
|
-
let base = text.trim() || `Column${
|
|
17017
|
+
return texts.map((text, i2) => {
|
|
17018
|
+
let base = text.trim() || `Column${i2 + 1}`;
|
|
17019
17019
|
if (!used.has(base.toLowerCase())) {
|
|
17020
17020
|
used.add(base.toLowerCase());
|
|
17021
17021
|
return base;
|
|
@@ -17047,22 +17047,22 @@ function createTable(ctx, s, range2, hasHeader, styleName = "TableStyleMedium2")
|
|
|
17047
17047
|
if (!hasHeader) {
|
|
17048
17048
|
const shift2 = { axis: "row", at: r.start.row, count: 1 };
|
|
17049
17049
|
const band = { lo: r.start.col, hi: r.end.col };
|
|
17050
|
-
rewriteFormulas(workbook, (
|
|
17050
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
17051
17051
|
shiftSheetContent(sheet, shift2, band);
|
|
17052
17052
|
r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
|
|
17053
17053
|
}
|
|
17054
17054
|
const width = r.end.col - r.start.col + 1;
|
|
17055
17055
|
const texts = Array.from(
|
|
17056
17056
|
{ length: width },
|
|
17057
|
-
(_v,
|
|
17057
|
+
(_v, i2) => hasHeader ? displayText(workbook, getCell(sheet, r.start.row, r.start.col + i2)) : ""
|
|
17058
17058
|
);
|
|
17059
17059
|
const headers = uniqueHeaders(texts);
|
|
17060
|
-
const columns = headers.map((name2,
|
|
17061
|
-
const cell = getCell(sheet, r.start.row, r.start.col +
|
|
17060
|
+
const columns = headers.map((name2, i2) => {
|
|
17061
|
+
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17062
17062
|
if (cell?.value !== name2) {
|
|
17063
17063
|
const styleId = cell?.styleId;
|
|
17064
|
-
writeValue(sheet, r.start.row, r.start.col +
|
|
17065
|
-
const written = getCell(sheet, r.start.row, r.start.col +
|
|
17064
|
+
writeValue(sheet, r.start.row, r.start.col + i2, name2);
|
|
17065
|
+
const written = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17066
17066
|
if (written && styleId) written.styleId = styleId;
|
|
17067
17067
|
}
|
|
17068
17068
|
return { name: name2 };
|
|
@@ -17111,7 +17111,7 @@ function validateTableName(workbook, name, self) {
|
|
|
17111
17111
|
function renameTableIn(workbook, table2, name) {
|
|
17112
17112
|
const old = table2.name;
|
|
17113
17113
|
if (old === name) return;
|
|
17114
|
-
const rename = (
|
|
17114
|
+
const rename = (f6) => renameTableInFormula(f6, old, name);
|
|
17115
17115
|
rewriteFormulas(workbook, rename);
|
|
17116
17116
|
for (const sheet of workbook.sheets)
|
|
17117
17117
|
for (const t of sheet.tables)
|
|
@@ -17129,7 +17129,7 @@ var byId = (sheet, id) => {
|
|
|
17129
17129
|
function insertBandRow(workbook, sheet, table2, row2) {
|
|
17130
17130
|
const shift2 = { axis: "row", at: row2, count: 1 };
|
|
17131
17131
|
const band = { lo: table2.range.start.col, hi: table2.range.end.col };
|
|
17132
|
-
rewriteFormulas(workbook, (
|
|
17132
|
+
rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet.name, shift2, band));
|
|
17133
17133
|
shiftSheetContent(sheet, shift2, band);
|
|
17134
17134
|
}
|
|
17135
17135
|
function setHeaderRow(workbook, sheet, id, on) {
|
|
@@ -17151,10 +17151,10 @@ function setHeaderRow(workbook, sheet, id, on) {
|
|
|
17151
17151
|
const left2 = table2.range.start.col;
|
|
17152
17152
|
table2.range = { start: { row: top, col: left2 }, end: table2.range.end };
|
|
17153
17153
|
table2.headerRow = true;
|
|
17154
|
-
uniqueHeaders(table2.columns.map((c) => c.name)).forEach((name,
|
|
17155
|
-
const column = table2.columns[
|
|
17154
|
+
uniqueHeaders(table2.columns.map((c) => c.name)).forEach((name, i2) => {
|
|
17155
|
+
const column = table2.columns[i2];
|
|
17156
17156
|
if (column) column.name = name;
|
|
17157
|
-
writeValue(sheet, top, left2 +
|
|
17157
|
+
writeValue(sheet, top, left2 + i2, name);
|
|
17158
17158
|
});
|
|
17159
17159
|
}
|
|
17160
17160
|
function setTotalsRow(workbook, sheet, id, on) {
|
|
@@ -17178,14 +17178,14 @@ function setTotalsRow(workbook, sheet, id, on) {
|
|
|
17178
17178
|
function resizedColumns(workbook, sheet, table2, range2) {
|
|
17179
17179
|
const width = range2.end.col - range2.start.col + 1;
|
|
17180
17180
|
const oldAt = (col) => col >= table2.range.start.col && col <= table2.range.end.col ? table2.columns[col - table2.range.start.col] : void 0;
|
|
17181
|
-
const texts = Array.from({ length: width }, (_v,
|
|
17182
|
-
const col = range2.start.col +
|
|
17181
|
+
const texts = Array.from({ length: width }, (_v, i2) => {
|
|
17182
|
+
const col = range2.start.col + i2;
|
|
17183
17183
|
const old = oldAt(col);
|
|
17184
17184
|
if (old) return old.name;
|
|
17185
17185
|
return table2.headerRow ? displayText(workbook, getCell(sheet, range2.start.row, col)) : "";
|
|
17186
17186
|
});
|
|
17187
|
-
return uniqueHeaders(texts).map((name,
|
|
17188
|
-
const old = oldAt(range2.start.col +
|
|
17187
|
+
return uniqueHeaders(texts).map((name, i2) => {
|
|
17188
|
+
const old = oldAt(range2.start.col + i2);
|
|
17189
17189
|
return old ? { ...old, name } : { name };
|
|
17190
17190
|
});
|
|
17191
17191
|
}
|
|
@@ -17205,9 +17205,9 @@ function resizeTableIn(workbook, sheet, id, range2) {
|
|
|
17205
17205
|
table2.columns = resizedColumns(workbook, sheet, table2, r);
|
|
17206
17206
|
table2.range = r;
|
|
17207
17207
|
if (table2.headerRow)
|
|
17208
|
-
table2.columns.forEach((column,
|
|
17209
|
-
const cell = getCell(sheet, r.start.row, r.start.col +
|
|
17210
|
-
if (cell?.value !== column.name) writeValue(sheet, r.start.row, r.start.col +
|
|
17208
|
+
table2.columns.forEach((column, i2) => {
|
|
17209
|
+
const cell = getCell(sheet, r.start.row, r.start.col + i2);
|
|
17210
|
+
if (cell?.value !== column.name) writeValue(sheet, r.start.row, r.start.col + i2, column.name);
|
|
17211
17211
|
});
|
|
17212
17212
|
if (table2.totalsRow) {
|
|
17213
17213
|
if (oldEnd !== r.end.row) clearRow(sheet, oldEnd, r.start.col, r.end.col);
|
|
@@ -17294,7 +17294,7 @@ function convertTableToRange(ctx, s, ref) {
|
|
|
17294
17294
|
inside
|
|
17295
17295
|
});
|
|
17296
17296
|
});
|
|
17297
|
-
rewriteFormulas(workbook, (
|
|
17297
|
+
rewriteFormulas(workbook, (f6, fs) => structuredToA1(f6, { ...base, formulaSheet: fs }));
|
|
17298
17298
|
for (const ws of workbook.sheets)
|
|
17299
17299
|
for (const t of ws.tables)
|
|
17300
17300
|
for (const column of t.columns)
|
|
@@ -17320,7 +17320,7 @@ function removeDuplicates(ctx, s, range2, columns, hasHeader) {
|
|
|
17320
17320
|
if (sheet.merges.some((m) => rangesIntersect(m, data)))
|
|
17321
17321
|
throw new Error("Cannot remove duplicates from a range that contains merged cells.");
|
|
17322
17322
|
const keyCols = columns.filter((c) => c >= r.start.col && c <= r.end.col);
|
|
17323
|
-
const cols = keyCols.length ? keyCols : Array.from({ length: r.end.col - r.start.col + 1 }, (_v,
|
|
17323
|
+
const cols = keyCols.length ? keyCols : Array.from({ length: r.end.col - r.start.col + 1 }, (_v, i2) => r.start.col + i2);
|
|
17324
17324
|
let lastStored = first2;
|
|
17325
17325
|
for (const row2 of sheet.rows.keys()) if (row2 > lastStored) lastStored = row2;
|
|
17326
17326
|
const lastRow = Math.min(r.end.row, lastStored);
|
|
@@ -17348,8 +17348,8 @@ function removeDuplicates(ctx, s, range2, columns, hasHeader) {
|
|
|
17348
17348
|
for (let row2 = first2; row2 <= lastRow; row2++)
|
|
17349
17349
|
for (const col of [...sheet.rows.get(row2)?.keys() ?? []])
|
|
17350
17350
|
if (col >= r.start.col && col <= r.end.col) deleteCell(sheet, row2, col);
|
|
17351
|
-
moved.forEach(({ row: from, cells },
|
|
17352
|
-
const row2 = first2 +
|
|
17351
|
+
moved.forEach(({ row: from, cells }, i2) => {
|
|
17352
|
+
const row2 = first2 + i2;
|
|
17353
17353
|
for (const [col, cell] of cells) {
|
|
17354
17354
|
if (cell.formula !== void 0 && row2 !== from)
|
|
17355
17355
|
cell.formula = translateFormula(cell.formula, row2 - from, 0);
|
|
@@ -17370,7 +17370,7 @@ function nextLevel(level, delta) {
|
|
|
17370
17370
|
function span2(from, to) {
|
|
17371
17371
|
const lo = Math.max(0, Math.min(from, to));
|
|
17372
17372
|
const hi = Math.max(from, to);
|
|
17373
|
-
return Array.from({ length: hi - lo + 1 }, (_v,
|
|
17373
|
+
return Array.from({ length: hi - lo + 1 }, (_v, i2) => lo + i2);
|
|
17374
17374
|
}
|
|
17375
17375
|
function outlineRows(ctx, s, from, to, delta) {
|
|
17376
17376
|
const sheet = sheetAt(ctx.workbook, s);
|
|
@@ -17512,6 +17512,846 @@ function decodeBase64(text) {
|
|
|
17512
17512
|
return out;
|
|
17513
17513
|
}
|
|
17514
17514
|
|
|
17515
|
+
// digest/md2.ts
|
|
17516
|
+
var S = [
|
|
17517
|
+
41,
|
|
17518
|
+
46,
|
|
17519
|
+
67,
|
|
17520
|
+
201,
|
|
17521
|
+
162,
|
|
17522
|
+
216,
|
|
17523
|
+
124,
|
|
17524
|
+
1,
|
|
17525
|
+
61,
|
|
17526
|
+
54,
|
|
17527
|
+
84,
|
|
17528
|
+
161,
|
|
17529
|
+
236,
|
|
17530
|
+
240,
|
|
17531
|
+
6,
|
|
17532
|
+
19,
|
|
17533
|
+
98,
|
|
17534
|
+
167,
|
|
17535
|
+
5,
|
|
17536
|
+
243,
|
|
17537
|
+
192,
|
|
17538
|
+
199,
|
|
17539
|
+
115,
|
|
17540
|
+
140,
|
|
17541
|
+
152,
|
|
17542
|
+
147,
|
|
17543
|
+
43,
|
|
17544
|
+
217,
|
|
17545
|
+
188,
|
|
17546
|
+
76,
|
|
17547
|
+
130,
|
|
17548
|
+
202,
|
|
17549
|
+
30,
|
|
17550
|
+
155,
|
|
17551
|
+
87,
|
|
17552
|
+
60,
|
|
17553
|
+
253,
|
|
17554
|
+
212,
|
|
17555
|
+
224,
|
|
17556
|
+
22,
|
|
17557
|
+
103,
|
|
17558
|
+
66,
|
|
17559
|
+
111,
|
|
17560
|
+
24,
|
|
17561
|
+
138,
|
|
17562
|
+
23,
|
|
17563
|
+
229,
|
|
17564
|
+
18,
|
|
17565
|
+
190,
|
|
17566
|
+
78,
|
|
17567
|
+
196,
|
|
17568
|
+
214,
|
|
17569
|
+
218,
|
|
17570
|
+
158,
|
|
17571
|
+
222,
|
|
17572
|
+
73,
|
|
17573
|
+
160,
|
|
17574
|
+
251,
|
|
17575
|
+
245,
|
|
17576
|
+
142,
|
|
17577
|
+
187,
|
|
17578
|
+
47,
|
|
17579
|
+
238,
|
|
17580
|
+
122,
|
|
17581
|
+
169,
|
|
17582
|
+
104,
|
|
17583
|
+
121,
|
|
17584
|
+
145,
|
|
17585
|
+
21,
|
|
17586
|
+
178,
|
|
17587
|
+
7,
|
|
17588
|
+
63,
|
|
17589
|
+
148,
|
|
17590
|
+
194,
|
|
17591
|
+
16,
|
|
17592
|
+
137,
|
|
17593
|
+
11,
|
|
17594
|
+
34,
|
|
17595
|
+
95,
|
|
17596
|
+
33,
|
|
17597
|
+
128,
|
|
17598
|
+
127,
|
|
17599
|
+
93,
|
|
17600
|
+
154,
|
|
17601
|
+
90,
|
|
17602
|
+
144,
|
|
17603
|
+
50,
|
|
17604
|
+
39,
|
|
17605
|
+
53,
|
|
17606
|
+
62,
|
|
17607
|
+
204,
|
|
17608
|
+
231,
|
|
17609
|
+
191,
|
|
17610
|
+
247,
|
|
17611
|
+
151,
|
|
17612
|
+
3,
|
|
17613
|
+
255,
|
|
17614
|
+
25,
|
|
17615
|
+
48,
|
|
17616
|
+
179,
|
|
17617
|
+
72,
|
|
17618
|
+
165,
|
|
17619
|
+
181,
|
|
17620
|
+
209,
|
|
17621
|
+
215,
|
|
17622
|
+
94,
|
|
17623
|
+
146,
|
|
17624
|
+
42,
|
|
17625
|
+
172,
|
|
17626
|
+
86,
|
|
17627
|
+
170,
|
|
17628
|
+
198,
|
|
17629
|
+
79,
|
|
17630
|
+
184,
|
|
17631
|
+
56,
|
|
17632
|
+
210,
|
|
17633
|
+
150,
|
|
17634
|
+
164,
|
|
17635
|
+
125,
|
|
17636
|
+
182,
|
|
17637
|
+
118,
|
|
17638
|
+
252,
|
|
17639
|
+
107,
|
|
17640
|
+
226,
|
|
17641
|
+
156,
|
|
17642
|
+
116,
|
|
17643
|
+
4,
|
|
17644
|
+
241,
|
|
17645
|
+
69,
|
|
17646
|
+
157,
|
|
17647
|
+
112,
|
|
17648
|
+
89,
|
|
17649
|
+
100,
|
|
17650
|
+
113,
|
|
17651
|
+
135,
|
|
17652
|
+
32,
|
|
17653
|
+
134,
|
|
17654
|
+
91,
|
|
17655
|
+
207,
|
|
17656
|
+
101,
|
|
17657
|
+
230,
|
|
17658
|
+
45,
|
|
17659
|
+
168,
|
|
17660
|
+
2,
|
|
17661
|
+
27,
|
|
17662
|
+
96,
|
|
17663
|
+
37,
|
|
17664
|
+
173,
|
|
17665
|
+
174,
|
|
17666
|
+
176,
|
|
17667
|
+
185,
|
|
17668
|
+
246,
|
|
17669
|
+
28,
|
|
17670
|
+
70,
|
|
17671
|
+
97,
|
|
17672
|
+
105,
|
|
17673
|
+
52,
|
|
17674
|
+
64,
|
|
17675
|
+
126,
|
|
17676
|
+
15,
|
|
17677
|
+
85,
|
|
17678
|
+
71,
|
|
17679
|
+
163,
|
|
17680
|
+
35,
|
|
17681
|
+
221,
|
|
17682
|
+
81,
|
|
17683
|
+
175,
|
|
17684
|
+
58,
|
|
17685
|
+
195,
|
|
17686
|
+
92,
|
|
17687
|
+
249,
|
|
17688
|
+
206,
|
|
17689
|
+
186,
|
|
17690
|
+
197,
|
|
17691
|
+
234,
|
|
17692
|
+
38,
|
|
17693
|
+
44,
|
|
17694
|
+
83,
|
|
17695
|
+
13,
|
|
17696
|
+
110,
|
|
17697
|
+
133,
|
|
17698
|
+
40,
|
|
17699
|
+
132,
|
|
17700
|
+
9,
|
|
17701
|
+
211,
|
|
17702
|
+
223,
|
|
17703
|
+
205,
|
|
17704
|
+
244,
|
|
17705
|
+
65,
|
|
17706
|
+
129,
|
|
17707
|
+
77,
|
|
17708
|
+
82,
|
|
17709
|
+
106,
|
|
17710
|
+
220,
|
|
17711
|
+
55,
|
|
17712
|
+
200,
|
|
17713
|
+
108,
|
|
17714
|
+
193,
|
|
17715
|
+
171,
|
|
17716
|
+
250,
|
|
17717
|
+
36,
|
|
17718
|
+
225,
|
|
17719
|
+
123,
|
|
17720
|
+
8,
|
|
17721
|
+
12,
|
|
17722
|
+
189,
|
|
17723
|
+
177,
|
|
17724
|
+
74,
|
|
17725
|
+
120,
|
|
17726
|
+
136,
|
|
17727
|
+
149,
|
|
17728
|
+
139,
|
|
17729
|
+
227,
|
|
17730
|
+
99,
|
|
17731
|
+
232,
|
|
17732
|
+
109,
|
|
17733
|
+
233,
|
|
17734
|
+
203,
|
|
17735
|
+
213,
|
|
17736
|
+
254,
|
|
17737
|
+
59,
|
|
17738
|
+
0,
|
|
17739
|
+
29,
|
|
17740
|
+
57,
|
|
17741
|
+
242,
|
|
17742
|
+
239,
|
|
17743
|
+
183,
|
|
17744
|
+
14,
|
|
17745
|
+
102,
|
|
17746
|
+
88,
|
|
17747
|
+
208,
|
|
17748
|
+
228,
|
|
17749
|
+
166,
|
|
17750
|
+
119,
|
|
17751
|
+
114,
|
|
17752
|
+
248,
|
|
17753
|
+
235,
|
|
17754
|
+
117,
|
|
17755
|
+
75,
|
|
17756
|
+
10,
|
|
17757
|
+
49,
|
|
17758
|
+
68,
|
|
17759
|
+
80,
|
|
17760
|
+
180,
|
|
17761
|
+
143,
|
|
17762
|
+
237,
|
|
17763
|
+
31,
|
|
17764
|
+
26,
|
|
17765
|
+
219,
|
|
17766
|
+
153,
|
|
17767
|
+
141,
|
|
17768
|
+
51,
|
|
17769
|
+
159,
|
|
17770
|
+
17,
|
|
17771
|
+
131,
|
|
17772
|
+
20
|
|
17773
|
+
];
|
|
17774
|
+
function transform(state, checksum, block) {
|
|
17775
|
+
const x = new Uint8Array(48);
|
|
17776
|
+
x.set(state, 0);
|
|
17777
|
+
x.set(block, 16);
|
|
17778
|
+
for (let k = 0; k < 16; k++) {
|
|
17779
|
+
x[32 + k] = state[k] ^ block[k];
|
|
17780
|
+
}
|
|
17781
|
+
let t = 0;
|
|
17782
|
+
for (let round3 = 0; round3 < 18; round3++) {
|
|
17783
|
+
for (let k = 0; k < 48; k++) {
|
|
17784
|
+
x[k] = x[k] ^ S[t];
|
|
17785
|
+
t = x[k];
|
|
17786
|
+
}
|
|
17787
|
+
t = t + round3 & 255;
|
|
17788
|
+
}
|
|
17789
|
+
state.set(x.subarray(0, 16));
|
|
17790
|
+
t = checksum[15];
|
|
17791
|
+
for (let k = 0; k < 16; k++) {
|
|
17792
|
+
checksum[k] = checksum[k] ^ S[block[k] ^ t];
|
|
17793
|
+
t = checksum[k];
|
|
17794
|
+
}
|
|
17795
|
+
}
|
|
17796
|
+
function md2(message) {
|
|
17797
|
+
const padLength = 16 - message.length % 16;
|
|
17798
|
+
const padded = new Uint8Array(message.length + padLength);
|
|
17799
|
+
padded.set(message);
|
|
17800
|
+
padded.fill(padLength, message.length);
|
|
17801
|
+
const state = new Uint8Array(16);
|
|
17802
|
+
const checksum = new Uint8Array(16);
|
|
17803
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 16) {
|
|
17804
|
+
transform(state, checksum, padded.subarray(offset2, offset2 + 16));
|
|
17805
|
+
}
|
|
17806
|
+
transform(state, checksum, checksum.slice());
|
|
17807
|
+
return state;
|
|
17808
|
+
}
|
|
17809
|
+
|
|
17810
|
+
// digest/bit-ops.ts
|
|
17811
|
+
function rotl32(x, n) {
|
|
17812
|
+
return (x << n | x >>> 32 - n) >>> 0;
|
|
17813
|
+
}
|
|
17814
|
+
function add32(...values2) {
|
|
17815
|
+
let sum2 = 0;
|
|
17816
|
+
for (const value2 of values2) sum2 = sum2 + value2 >>> 0;
|
|
17817
|
+
return sum2;
|
|
17818
|
+
}
|
|
17819
|
+
function padMd4Style(message) {
|
|
17820
|
+
const paddedLength = message.length + 9 + 63 & -64;
|
|
17821
|
+
const padded = new Uint8Array(paddedLength);
|
|
17822
|
+
padded.set(message);
|
|
17823
|
+
padded[message.length] = 128;
|
|
17824
|
+
new DataView(padded.buffer).setBigUint64(paddedLength - 8, BigInt(message.length) * 8n, true);
|
|
17825
|
+
return padded;
|
|
17826
|
+
}
|
|
17827
|
+
function applyRotatingRound(r, ops, f6, x, feedback = false) {
|
|
17828
|
+
let target2 = 0;
|
|
17829
|
+
for (const [k, s, addConst] of ops) {
|
|
17830
|
+
const i1 = target2 + 1 & 3;
|
|
17831
|
+
const next = r[i1];
|
|
17832
|
+
const rotated = rotl32(
|
|
17833
|
+
add32(r[target2], f6(next, r[target2 + 2 & 3], r[target2 + 3 & 3]), x[k], addConst),
|
|
17834
|
+
s
|
|
17835
|
+
);
|
|
17836
|
+
r[target2] = feedback ? add32(next, rotated) : rotated;
|
|
17837
|
+
target2 = target2 + 3 & 3;
|
|
17838
|
+
}
|
|
17839
|
+
}
|
|
17840
|
+
function mdStyleDigest(message, initialState, transform6) {
|
|
17841
|
+
const padded = padMd4Style(message);
|
|
17842
|
+
const view = new DataView(padded.buffer);
|
|
17843
|
+
const state = [...initialState];
|
|
17844
|
+
const words2 = new Array(16).fill(0);
|
|
17845
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 64) {
|
|
17846
|
+
for (let i2 = 0; i2 < 16; i2++) words2[i2] = view.getUint32(offset2 + i2 * 4, true);
|
|
17847
|
+
transform6(state, words2);
|
|
17848
|
+
}
|
|
17849
|
+
const out = new Uint8Array(state.length * 4);
|
|
17850
|
+
const outView = new DataView(out.buffer);
|
|
17851
|
+
for (let i2 = 0; i2 < state.length; i2++) outView.setUint32(i2 * 4, state[i2], true);
|
|
17852
|
+
return out;
|
|
17853
|
+
}
|
|
17854
|
+
|
|
17855
|
+
// digest/md4.ts
|
|
17856
|
+
var INITIAL_STATE = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17857
|
+
var K2 = 1518500249;
|
|
17858
|
+
var K3 = 1859775393;
|
|
17859
|
+
var f1 = (x, y, z) => x & y | ~x & z;
|
|
17860
|
+
var f2 = (x, y, z) => x & y | x & z | y & z;
|
|
17861
|
+
var f3 = (x, y, z) => x ^ y ^ z;
|
|
17862
|
+
function round(order, shifts, k) {
|
|
17863
|
+
return order.map((word, i2) => [word, shifts[i2 % 4], k]);
|
|
17864
|
+
}
|
|
17865
|
+
var SEQUENTIAL = Array.from({ length: 16 }, (_, i2) => i2);
|
|
17866
|
+
var COLUMNS = Array.from({ length: 16 }, (_, i2) => i2 % 4 * 4 + (i2 >> 2));
|
|
17867
|
+
var BIT_REVERSED = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];
|
|
17868
|
+
var ROUND1 = round(SEQUENTIAL, [3, 7, 11, 19], 0);
|
|
17869
|
+
var ROUND2 = round(COLUMNS, [3, 5, 9, 13], K2);
|
|
17870
|
+
var ROUND3 = round(BIT_REVERSED, [3, 9, 11, 15], K3);
|
|
17871
|
+
function transform2(state, x) {
|
|
17872
|
+
const r = [...state];
|
|
17873
|
+
applyRotatingRound(r, ROUND1, f1, x);
|
|
17874
|
+
applyRotatingRound(r, ROUND2, f2, x);
|
|
17875
|
+
applyRotatingRound(r, ROUND3, f3, x);
|
|
17876
|
+
for (let i2 = 0; i2 < 4; i2++) state[i2] = add32(state[i2], r[i2]);
|
|
17877
|
+
}
|
|
17878
|
+
function md4(message) {
|
|
17879
|
+
return mdStyleDigest(message, INITIAL_STATE, transform2);
|
|
17880
|
+
}
|
|
17881
|
+
|
|
17882
|
+
// digest/md5.ts
|
|
17883
|
+
var INITIAL_STATE2 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17884
|
+
function f(x, y, z) {
|
|
17885
|
+
return x & y | ~x & z;
|
|
17886
|
+
}
|
|
17887
|
+
function g(x, y, z) {
|
|
17888
|
+
return x & z | y & ~z;
|
|
17889
|
+
}
|
|
17890
|
+
function h(x, y, z) {
|
|
17891
|
+
return x ^ y ^ z;
|
|
17892
|
+
}
|
|
17893
|
+
function i(x, y, z) {
|
|
17894
|
+
return y ^ (x | ~z);
|
|
17895
|
+
}
|
|
17896
|
+
var T = Array.from(
|
|
17897
|
+
{ length: 64 },
|
|
17898
|
+
(_, index2) => Math.floor(Math.abs(Math.sin(index2 + 1)) * 2 ** 32)
|
|
17899
|
+
);
|
|
17900
|
+
var SHIFTS = [
|
|
17901
|
+
[7, 12, 17, 22],
|
|
17902
|
+
[5, 9, 14, 20],
|
|
17903
|
+
[4, 11, 16, 23],
|
|
17904
|
+
[6, 10, 15, 21]
|
|
17905
|
+
];
|
|
17906
|
+
var WORD_INDEX = [
|
|
17907
|
+
(idx) => idx,
|
|
17908
|
+
(idx) => (5 * idx + 1) % 16,
|
|
17909
|
+
(idx) => (3 * idx + 5) % 16,
|
|
17910
|
+
(idx) => 7 * idx % 16
|
|
17911
|
+
];
|
|
17912
|
+
var ROUND_FNS = [f, g, h, i];
|
|
17913
|
+
function buildOps(round3) {
|
|
17914
|
+
const shifts = SHIFTS[round3];
|
|
17915
|
+
const wordIndex = WORD_INDEX[round3];
|
|
17916
|
+
return Array.from({ length: 16 }, (_, idx) => {
|
|
17917
|
+
const opNumber = round3 * 16 + idx;
|
|
17918
|
+
return [wordIndex(idx), shifts[idx % 4], T[opNumber]];
|
|
17919
|
+
});
|
|
17920
|
+
}
|
|
17921
|
+
var ROUNDS = [0, 1, 2, 3].map(buildOps);
|
|
17922
|
+
function transform3(state, x) {
|
|
17923
|
+
const r = [...state];
|
|
17924
|
+
for (let round3 = 0; round3 < 4; round3++) {
|
|
17925
|
+
applyRotatingRound(r, ROUNDS[round3], ROUND_FNS[round3], x, true);
|
|
17926
|
+
}
|
|
17927
|
+
for (let idx = 0; idx < 4; idx++) {
|
|
17928
|
+
state[idx] = add32(state[idx], r[idx]);
|
|
17929
|
+
}
|
|
17930
|
+
}
|
|
17931
|
+
function md5(message) {
|
|
17932
|
+
return mdStyleDigest(message, INITIAL_STATE2, transform3);
|
|
17933
|
+
}
|
|
17934
|
+
|
|
17935
|
+
// digest/ripemd-functions.ts
|
|
17936
|
+
function f12(x, y, z) {
|
|
17937
|
+
return x ^ y ^ z;
|
|
17938
|
+
}
|
|
17939
|
+
function f22(x, y, z) {
|
|
17940
|
+
return x & y | ~x & z;
|
|
17941
|
+
}
|
|
17942
|
+
function f32(x, y, z) {
|
|
17943
|
+
return (x | ~y) ^ z;
|
|
17944
|
+
}
|
|
17945
|
+
function f4(x, y, z) {
|
|
17946
|
+
return z & x | ~z & y;
|
|
17947
|
+
}
|
|
17948
|
+
function f5(x, y, z) {
|
|
17949
|
+
return x ^ (y | ~z);
|
|
17950
|
+
}
|
|
17951
|
+
|
|
17952
|
+
// digest/ripemd128.ts
|
|
17953
|
+
var INITIAL_STATE3 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
17954
|
+
var LEFT_ROUNDS = [
|
|
17955
|
+
[
|
|
17956
|
+
[0, 11, 0],
|
|
17957
|
+
[1, 14, 0],
|
|
17958
|
+
[2, 15, 0],
|
|
17959
|
+
[3, 12, 0],
|
|
17960
|
+
[4, 5, 0],
|
|
17961
|
+
[5, 8, 0],
|
|
17962
|
+
[6, 7, 0],
|
|
17963
|
+
[7, 9, 0],
|
|
17964
|
+
[8, 11, 0],
|
|
17965
|
+
[9, 13, 0],
|
|
17966
|
+
[10, 14, 0],
|
|
17967
|
+
[11, 15, 0],
|
|
17968
|
+
[12, 6, 0],
|
|
17969
|
+
[13, 7, 0],
|
|
17970
|
+
[14, 9, 0],
|
|
17971
|
+
[15, 8, 0]
|
|
17972
|
+
],
|
|
17973
|
+
[
|
|
17974
|
+
[7, 7, 1518500249],
|
|
17975
|
+
[4, 6, 1518500249],
|
|
17976
|
+
[13, 8, 1518500249],
|
|
17977
|
+
[1, 13, 1518500249],
|
|
17978
|
+
[10, 11, 1518500249],
|
|
17979
|
+
[6, 9, 1518500249],
|
|
17980
|
+
[15, 7, 1518500249],
|
|
17981
|
+
[3, 15, 1518500249],
|
|
17982
|
+
[12, 7, 1518500249],
|
|
17983
|
+
[0, 12, 1518500249],
|
|
17984
|
+
[9, 15, 1518500249],
|
|
17985
|
+
[5, 9, 1518500249],
|
|
17986
|
+
[2, 11, 1518500249],
|
|
17987
|
+
[14, 7, 1518500249],
|
|
17988
|
+
[11, 13, 1518500249],
|
|
17989
|
+
[8, 12, 1518500249]
|
|
17990
|
+
],
|
|
17991
|
+
[
|
|
17992
|
+
[3, 11, 1859775393],
|
|
17993
|
+
[10, 13, 1859775393],
|
|
17994
|
+
[14, 6, 1859775393],
|
|
17995
|
+
[4, 7, 1859775393],
|
|
17996
|
+
[9, 14, 1859775393],
|
|
17997
|
+
[15, 9, 1859775393],
|
|
17998
|
+
[8, 13, 1859775393],
|
|
17999
|
+
[1, 15, 1859775393],
|
|
18000
|
+
[2, 14, 1859775393],
|
|
18001
|
+
[7, 8, 1859775393],
|
|
18002
|
+
[0, 13, 1859775393],
|
|
18003
|
+
[6, 6, 1859775393],
|
|
18004
|
+
[13, 5, 1859775393],
|
|
18005
|
+
[11, 12, 1859775393],
|
|
18006
|
+
[5, 7, 1859775393],
|
|
18007
|
+
[12, 5, 1859775393]
|
|
18008
|
+
],
|
|
18009
|
+
[
|
|
18010
|
+
[1, 11, 2400959708],
|
|
18011
|
+
[9, 12, 2400959708],
|
|
18012
|
+
[11, 14, 2400959708],
|
|
18013
|
+
[10, 15, 2400959708],
|
|
18014
|
+
[0, 14, 2400959708],
|
|
18015
|
+
[8, 15, 2400959708],
|
|
18016
|
+
[12, 9, 2400959708],
|
|
18017
|
+
[4, 8, 2400959708],
|
|
18018
|
+
[13, 9, 2400959708],
|
|
18019
|
+
[3, 14, 2400959708],
|
|
18020
|
+
[7, 5, 2400959708],
|
|
18021
|
+
[15, 6, 2400959708],
|
|
18022
|
+
[14, 8, 2400959708],
|
|
18023
|
+
[5, 6, 2400959708],
|
|
18024
|
+
[6, 5, 2400959708],
|
|
18025
|
+
[2, 12, 2400959708]
|
|
18026
|
+
]
|
|
18027
|
+
];
|
|
18028
|
+
var RIGHT_ROUNDS = [
|
|
18029
|
+
[
|
|
18030
|
+
[5, 8, 1352829926],
|
|
18031
|
+
[14, 9, 1352829926],
|
|
18032
|
+
[7, 9, 1352829926],
|
|
18033
|
+
[0, 11, 1352829926],
|
|
18034
|
+
[9, 13, 1352829926],
|
|
18035
|
+
[2, 15, 1352829926],
|
|
18036
|
+
[11, 15, 1352829926],
|
|
18037
|
+
[4, 5, 1352829926],
|
|
18038
|
+
[13, 7, 1352829926],
|
|
18039
|
+
[6, 7, 1352829926],
|
|
18040
|
+
[15, 8, 1352829926],
|
|
18041
|
+
[8, 11, 1352829926],
|
|
18042
|
+
[1, 14, 1352829926],
|
|
18043
|
+
[10, 14, 1352829926],
|
|
18044
|
+
[3, 12, 1352829926],
|
|
18045
|
+
[12, 6, 1352829926]
|
|
18046
|
+
],
|
|
18047
|
+
[
|
|
18048
|
+
[6, 9, 1548603684],
|
|
18049
|
+
[11, 13, 1548603684],
|
|
18050
|
+
[3, 15, 1548603684],
|
|
18051
|
+
[7, 7, 1548603684],
|
|
18052
|
+
[0, 12, 1548603684],
|
|
18053
|
+
[13, 8, 1548603684],
|
|
18054
|
+
[5, 9, 1548603684],
|
|
18055
|
+
[10, 11, 1548603684],
|
|
18056
|
+
[14, 7, 1548603684],
|
|
18057
|
+
[15, 7, 1548603684],
|
|
18058
|
+
[8, 12, 1548603684],
|
|
18059
|
+
[12, 7, 1548603684],
|
|
18060
|
+
[4, 6, 1548603684],
|
|
18061
|
+
[9, 15, 1548603684],
|
|
18062
|
+
[1, 13, 1548603684],
|
|
18063
|
+
[2, 11, 1548603684]
|
|
18064
|
+
],
|
|
18065
|
+
[
|
|
18066
|
+
[15, 9, 1836072691],
|
|
18067
|
+
[5, 7, 1836072691],
|
|
18068
|
+
[1, 15, 1836072691],
|
|
18069
|
+
[3, 11, 1836072691],
|
|
18070
|
+
[7, 8, 1836072691],
|
|
18071
|
+
[14, 6, 1836072691],
|
|
18072
|
+
[6, 6, 1836072691],
|
|
18073
|
+
[9, 14, 1836072691],
|
|
18074
|
+
[11, 12, 1836072691],
|
|
18075
|
+
[8, 13, 1836072691],
|
|
18076
|
+
[12, 5, 1836072691],
|
|
18077
|
+
[2, 14, 1836072691],
|
|
18078
|
+
[10, 13, 1836072691],
|
|
18079
|
+
[0, 13, 1836072691],
|
|
18080
|
+
[4, 7, 1836072691],
|
|
18081
|
+
[13, 5, 1836072691]
|
|
18082
|
+
],
|
|
18083
|
+
[
|
|
18084
|
+
[8, 15, 0],
|
|
18085
|
+
[6, 5, 0],
|
|
18086
|
+
[4, 8, 0],
|
|
18087
|
+
[1, 11, 0],
|
|
18088
|
+
[3, 14, 0],
|
|
18089
|
+
[11, 14, 0],
|
|
18090
|
+
[15, 6, 0],
|
|
18091
|
+
[0, 14, 0],
|
|
18092
|
+
[5, 6, 0],
|
|
18093
|
+
[12, 9, 0],
|
|
18094
|
+
[2, 12, 0],
|
|
18095
|
+
[13, 9, 0],
|
|
18096
|
+
[9, 12, 0],
|
|
18097
|
+
[7, 5, 0],
|
|
18098
|
+
[10, 15, 0],
|
|
18099
|
+
[14, 8, 0]
|
|
18100
|
+
]
|
|
18101
|
+
];
|
|
18102
|
+
var LEFT_FNS = [f12, f22, f32, f4];
|
|
18103
|
+
var RIGHT_FNS = [f4, f32, f22, f12];
|
|
18104
|
+
function transform4(state, x) {
|
|
18105
|
+
const left2 = [...state];
|
|
18106
|
+
const right2 = [...state];
|
|
18107
|
+
for (let round3 = 0; round3 < 4; round3++) {
|
|
18108
|
+
applyRotatingRound(left2, LEFT_ROUNDS[round3], LEFT_FNS[round3], x);
|
|
18109
|
+
applyRotatingRound(right2, RIGHT_ROUNDS[round3], RIGHT_FNS[round3], x);
|
|
18110
|
+
}
|
|
18111
|
+
const orig = state;
|
|
18112
|
+
const newState = [
|
|
18113
|
+
add32(right2[3], left2[2], orig[1]),
|
|
18114
|
+
add32(orig[2], left2[3], right2[0]),
|
|
18115
|
+
add32(orig[3], left2[0], right2[1]),
|
|
18116
|
+
add32(orig[0], left2[1], right2[2])
|
|
18117
|
+
];
|
|
18118
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
18119
|
+
state[i2] = newState[i2];
|
|
18120
|
+
}
|
|
18121
|
+
}
|
|
18122
|
+
function ripemd128(message) {
|
|
18123
|
+
return mdStyleDigest(message, INITIAL_STATE3, transform4);
|
|
18124
|
+
}
|
|
18125
|
+
|
|
18126
|
+
// digest/ripemd160.ts
|
|
18127
|
+
var INITIAL_STATE4 = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
18128
|
+
var LEFT_ROUNDS2 = [
|
|
18129
|
+
[
|
|
18130
|
+
[0, 11, 0],
|
|
18131
|
+
[1, 14, 0],
|
|
18132
|
+
[2, 15, 0],
|
|
18133
|
+
[3, 12, 0],
|
|
18134
|
+
[4, 5, 0],
|
|
18135
|
+
[5, 8, 0],
|
|
18136
|
+
[6, 7, 0],
|
|
18137
|
+
[7, 9, 0],
|
|
18138
|
+
[8, 11, 0],
|
|
18139
|
+
[9, 13, 0],
|
|
18140
|
+
[10, 14, 0],
|
|
18141
|
+
[11, 15, 0],
|
|
18142
|
+
[12, 6, 0],
|
|
18143
|
+
[13, 7, 0],
|
|
18144
|
+
[14, 9, 0],
|
|
18145
|
+
[15, 8, 0]
|
|
18146
|
+
],
|
|
18147
|
+
[
|
|
18148
|
+
[7, 7, 1518500249],
|
|
18149
|
+
[4, 6, 1518500249],
|
|
18150
|
+
[13, 8, 1518500249],
|
|
18151
|
+
[1, 13, 1518500249],
|
|
18152
|
+
[10, 11, 1518500249],
|
|
18153
|
+
[6, 9, 1518500249],
|
|
18154
|
+
[15, 7, 1518500249],
|
|
18155
|
+
[3, 15, 1518500249],
|
|
18156
|
+
[12, 7, 1518500249],
|
|
18157
|
+
[0, 12, 1518500249],
|
|
18158
|
+
[9, 15, 1518500249],
|
|
18159
|
+
[5, 9, 1518500249],
|
|
18160
|
+
[2, 11, 1518500249],
|
|
18161
|
+
[14, 7, 1518500249],
|
|
18162
|
+
[11, 13, 1518500249],
|
|
18163
|
+
[8, 12, 1518500249]
|
|
18164
|
+
],
|
|
18165
|
+
[
|
|
18166
|
+
[3, 11, 1859775393],
|
|
18167
|
+
[10, 13, 1859775393],
|
|
18168
|
+
[14, 6, 1859775393],
|
|
18169
|
+
[4, 7, 1859775393],
|
|
18170
|
+
[9, 14, 1859775393],
|
|
18171
|
+
[15, 9, 1859775393],
|
|
18172
|
+
[8, 13, 1859775393],
|
|
18173
|
+
[1, 15, 1859775393],
|
|
18174
|
+
[2, 14, 1859775393],
|
|
18175
|
+
[7, 8, 1859775393],
|
|
18176
|
+
[0, 13, 1859775393],
|
|
18177
|
+
[6, 6, 1859775393],
|
|
18178
|
+
[13, 5, 1859775393],
|
|
18179
|
+
[11, 12, 1859775393],
|
|
18180
|
+
[5, 7, 1859775393],
|
|
18181
|
+
[12, 5, 1859775393]
|
|
18182
|
+
],
|
|
18183
|
+
[
|
|
18184
|
+
[1, 11, 2400959708],
|
|
18185
|
+
[9, 12, 2400959708],
|
|
18186
|
+
[11, 14, 2400959708],
|
|
18187
|
+
[10, 15, 2400959708],
|
|
18188
|
+
[0, 14, 2400959708],
|
|
18189
|
+
[8, 15, 2400959708],
|
|
18190
|
+
[12, 9, 2400959708],
|
|
18191
|
+
[4, 8, 2400959708],
|
|
18192
|
+
[13, 9, 2400959708],
|
|
18193
|
+
[3, 14, 2400959708],
|
|
18194
|
+
[7, 5, 2400959708],
|
|
18195
|
+
[15, 6, 2400959708],
|
|
18196
|
+
[14, 8, 2400959708],
|
|
18197
|
+
[5, 6, 2400959708],
|
|
18198
|
+
[6, 5, 2400959708],
|
|
18199
|
+
[2, 12, 2400959708]
|
|
18200
|
+
],
|
|
18201
|
+
[
|
|
18202
|
+
[4, 9, 2840853838],
|
|
18203
|
+
[0, 15, 2840853838],
|
|
18204
|
+
[5, 5, 2840853838],
|
|
18205
|
+
[9, 11, 2840853838],
|
|
18206
|
+
[7, 6, 2840853838],
|
|
18207
|
+
[12, 8, 2840853838],
|
|
18208
|
+
[2, 13, 2840853838],
|
|
18209
|
+
[10, 12, 2840853838],
|
|
18210
|
+
[14, 5, 2840853838],
|
|
18211
|
+
[1, 12, 2840853838],
|
|
18212
|
+
[3, 13, 2840853838],
|
|
18213
|
+
[8, 14, 2840853838],
|
|
18214
|
+
[11, 11, 2840853838],
|
|
18215
|
+
[6, 8, 2840853838],
|
|
18216
|
+
[15, 5, 2840853838],
|
|
18217
|
+
[13, 6, 2840853838]
|
|
18218
|
+
]
|
|
18219
|
+
];
|
|
18220
|
+
var RIGHT_ROUNDS2 = [
|
|
18221
|
+
[
|
|
18222
|
+
[5, 8, 1352829926],
|
|
18223
|
+
[14, 9, 1352829926],
|
|
18224
|
+
[7, 9, 1352829926],
|
|
18225
|
+
[0, 11, 1352829926],
|
|
18226
|
+
[9, 13, 1352829926],
|
|
18227
|
+
[2, 15, 1352829926],
|
|
18228
|
+
[11, 15, 1352829926],
|
|
18229
|
+
[4, 5, 1352829926],
|
|
18230
|
+
[13, 7, 1352829926],
|
|
18231
|
+
[6, 7, 1352829926],
|
|
18232
|
+
[15, 8, 1352829926],
|
|
18233
|
+
[8, 11, 1352829926],
|
|
18234
|
+
[1, 14, 1352829926],
|
|
18235
|
+
[10, 14, 1352829926],
|
|
18236
|
+
[3, 12, 1352829926],
|
|
18237
|
+
[12, 6, 1352829926]
|
|
18238
|
+
],
|
|
18239
|
+
[
|
|
18240
|
+
[6, 9, 1548603684],
|
|
18241
|
+
[11, 13, 1548603684],
|
|
18242
|
+
[3, 15, 1548603684],
|
|
18243
|
+
[7, 7, 1548603684],
|
|
18244
|
+
[0, 12, 1548603684],
|
|
18245
|
+
[13, 8, 1548603684],
|
|
18246
|
+
[5, 9, 1548603684],
|
|
18247
|
+
[10, 11, 1548603684],
|
|
18248
|
+
[14, 7, 1548603684],
|
|
18249
|
+
[15, 7, 1548603684],
|
|
18250
|
+
[8, 12, 1548603684],
|
|
18251
|
+
[12, 7, 1548603684],
|
|
18252
|
+
[4, 6, 1548603684],
|
|
18253
|
+
[9, 15, 1548603684],
|
|
18254
|
+
[1, 13, 1548603684],
|
|
18255
|
+
[2, 11, 1548603684]
|
|
18256
|
+
],
|
|
18257
|
+
[
|
|
18258
|
+
[15, 9, 1836072691],
|
|
18259
|
+
[5, 7, 1836072691],
|
|
18260
|
+
[1, 15, 1836072691],
|
|
18261
|
+
[3, 11, 1836072691],
|
|
18262
|
+
[7, 8, 1836072691],
|
|
18263
|
+
[14, 6, 1836072691],
|
|
18264
|
+
[6, 6, 1836072691],
|
|
18265
|
+
[9, 14, 1836072691],
|
|
18266
|
+
[11, 12, 1836072691],
|
|
18267
|
+
[8, 13, 1836072691],
|
|
18268
|
+
[12, 5, 1836072691],
|
|
18269
|
+
[2, 14, 1836072691],
|
|
18270
|
+
[10, 13, 1836072691],
|
|
18271
|
+
[0, 13, 1836072691],
|
|
18272
|
+
[4, 7, 1836072691],
|
|
18273
|
+
[13, 5, 1836072691]
|
|
18274
|
+
],
|
|
18275
|
+
[
|
|
18276
|
+
[8, 15, 2053994217],
|
|
18277
|
+
[6, 5, 2053994217],
|
|
18278
|
+
[4, 8, 2053994217],
|
|
18279
|
+
[1, 11, 2053994217],
|
|
18280
|
+
[3, 14, 2053994217],
|
|
18281
|
+
[11, 14, 2053994217],
|
|
18282
|
+
[15, 6, 2053994217],
|
|
18283
|
+
[0, 14, 2053994217],
|
|
18284
|
+
[5, 6, 2053994217],
|
|
18285
|
+
[12, 9, 2053994217],
|
|
18286
|
+
[2, 12, 2053994217],
|
|
18287
|
+
[13, 9, 2053994217],
|
|
18288
|
+
[9, 12, 2053994217],
|
|
18289
|
+
[7, 5, 2053994217],
|
|
18290
|
+
[10, 15, 2053994217],
|
|
18291
|
+
[14, 8, 2053994217]
|
|
18292
|
+
],
|
|
18293
|
+
[
|
|
18294
|
+
[12, 8, 0],
|
|
18295
|
+
[15, 5, 0],
|
|
18296
|
+
[10, 12, 0],
|
|
18297
|
+
[4, 9, 0],
|
|
18298
|
+
[1, 12, 0],
|
|
18299
|
+
[5, 5, 0],
|
|
18300
|
+
[8, 14, 0],
|
|
18301
|
+
[7, 6, 0],
|
|
18302
|
+
[6, 8, 0],
|
|
18303
|
+
[2, 13, 0],
|
|
18304
|
+
[13, 6, 0],
|
|
18305
|
+
[14, 5, 0],
|
|
18306
|
+
[0, 15, 0],
|
|
18307
|
+
[3, 13, 0],
|
|
18308
|
+
[9, 11, 0],
|
|
18309
|
+
[11, 11, 0]
|
|
18310
|
+
]
|
|
18311
|
+
];
|
|
18312
|
+
var LEFT_FNS2 = [f12, f22, f32, f4, f5];
|
|
18313
|
+
var RIGHT_FNS2 = [f5, f4, f32, f22, f12];
|
|
18314
|
+
function applyLane(r, ops, f6, x, startTarget) {
|
|
18315
|
+
let target2 = startTarget;
|
|
18316
|
+
for (const [k, s, addConst] of ops) {
|
|
18317
|
+
const i1 = (target2 + 1) % 5;
|
|
18318
|
+
const i2 = (target2 + 2) % 5;
|
|
18319
|
+
const i3 = (target2 + 3) % 5;
|
|
18320
|
+
const i4 = (target2 + 4) % 5;
|
|
18321
|
+
const sum2 = r[target2] + f6(r[i1], r[i2], r[i3]) + x[k] + addConst >>> 0;
|
|
18322
|
+
const newTarget = (sum2 << s | sum2 >>> 32 - s) + r[i4] >>> 0;
|
|
18323
|
+
const c = r[i2];
|
|
18324
|
+
r[i2] = (c << 10 | c >>> 22) >>> 0;
|
|
18325
|
+
r[target2] = newTarget;
|
|
18326
|
+
target2 = (target2 + 4) % 5;
|
|
18327
|
+
}
|
|
18328
|
+
return target2;
|
|
18329
|
+
}
|
|
18330
|
+
function transform5(state, x) {
|
|
18331
|
+
const left2 = [...state];
|
|
18332
|
+
const right2 = [...state];
|
|
18333
|
+
let leftTarget = 0;
|
|
18334
|
+
let rightTarget = 0;
|
|
18335
|
+
for (let round3 = 0; round3 < 5; round3++) {
|
|
18336
|
+
leftTarget = applyLane(left2, LEFT_ROUNDS2[round3], LEFT_FNS2[round3], x, leftTarget);
|
|
18337
|
+
rightTarget = applyLane(right2, RIGHT_ROUNDS2[round3], RIGHT_FNS2[round3], x, rightTarget);
|
|
18338
|
+
}
|
|
18339
|
+
const orig = state;
|
|
18340
|
+
const newState = [
|
|
18341
|
+
add32(right2[3], left2[2], orig[1]),
|
|
18342
|
+
add32(orig[2], left2[3], right2[4]),
|
|
18343
|
+
add32(orig[3], left2[4], right2[0]),
|
|
18344
|
+
add32(orig[4], left2[0], right2[1]),
|
|
18345
|
+
add32(orig[0], left2[1], right2[2])
|
|
18346
|
+
];
|
|
18347
|
+
for (let i2 = 0; i2 < 5; i2++) {
|
|
18348
|
+
state[i2] = newState[i2];
|
|
18349
|
+
}
|
|
18350
|
+
}
|
|
18351
|
+
function ripemd160(message) {
|
|
18352
|
+
return mdStyleDigest(message, INITIAL_STATE4, transform5);
|
|
18353
|
+
}
|
|
18354
|
+
|
|
17515
18355
|
// digest/sha256.ts
|
|
17516
18356
|
var K = new Uint32Array([
|
|
17517
18357
|
1116352408,
|
|
@@ -17591,40 +18431,40 @@ var IV = [
|
|
|
17591
18431
|
];
|
|
17592
18432
|
var W = new Uint32Array(64);
|
|
17593
18433
|
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
17594
|
-
function compress(
|
|
17595
|
-
for (let
|
|
17596
|
-
for (let
|
|
17597
|
-
const a2 = W[
|
|
17598
|
-
const b2 = W[
|
|
18434
|
+
function compress(h2, view, offset2) {
|
|
18435
|
+
for (let i2 = 0; i2 < 16; i2++) W[i2] = view.getUint32(offset2 + i2 * 4);
|
|
18436
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
18437
|
+
const a2 = W[i2 - 15];
|
|
18438
|
+
const b2 = W[i2 - 2];
|
|
17599
18439
|
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
17600
18440
|
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
17601
|
-
W[
|
|
18441
|
+
W[i2] = W[i2 - 16] + s0 + W[i2 - 7] + s1 >>> 0;
|
|
17602
18442
|
}
|
|
17603
|
-
let a =
|
|
17604
|
-
for (let
|
|
18443
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4], f6 = h2[5], g2 = h2[6], k = h2[7];
|
|
18444
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
17605
18445
|
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
17606
|
-
const ch = e &
|
|
17607
|
-
const t1 = k + S1 + ch + K[
|
|
18446
|
+
const ch = e & f6 ^ ~e & g2;
|
|
18447
|
+
const t1 = k + S1 + ch + K[i2] + W[i2] >>> 0;
|
|
17608
18448
|
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
17609
18449
|
const maj = a & b ^ a & c ^ b & c;
|
|
17610
18450
|
const t2 = S0 + maj >>> 0;
|
|
17611
|
-
k =
|
|
17612
|
-
|
|
17613
|
-
|
|
18451
|
+
k = g2;
|
|
18452
|
+
g2 = f6;
|
|
18453
|
+
f6 = e;
|
|
17614
18454
|
e = d + t1 >>> 0;
|
|
17615
18455
|
d = c;
|
|
17616
18456
|
c = b;
|
|
17617
18457
|
b = a;
|
|
17618
18458
|
a = t1 + t2 >>> 0;
|
|
17619
18459
|
}
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
18460
|
+
h2[0] = h2[0] + a >>> 0;
|
|
18461
|
+
h2[1] = h2[1] + b >>> 0;
|
|
18462
|
+
h2[2] = h2[2] + c >>> 0;
|
|
18463
|
+
h2[3] = h2[3] + d >>> 0;
|
|
18464
|
+
h2[4] = h2[4] + e >>> 0;
|
|
18465
|
+
h2[5] = h2[5] + f6 >>> 0;
|
|
18466
|
+
h2[6] = h2[6] + g2 >>> 0;
|
|
18467
|
+
h2[7] = h2[7] + k >>> 0;
|
|
17628
18468
|
}
|
|
17629
18469
|
function pad64(data) {
|
|
17630
18470
|
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
@@ -17636,64 +18476,64 @@ function pad64(data) {
|
|
|
17636
18476
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
17637
18477
|
return view;
|
|
17638
18478
|
}
|
|
17639
|
-
function wordsOut(
|
|
17640
|
-
const out = new Uint8Array(
|
|
18479
|
+
function wordsOut(h2) {
|
|
18480
|
+
const out = new Uint8Array(h2.length * 4);
|
|
17641
18481
|
const view = new DataView(out.buffer);
|
|
17642
|
-
for (let
|
|
18482
|
+
for (let i2 = 0; i2 < h2.length; i2++) view.setUint32(i2 * 4, h2[i2]);
|
|
17643
18483
|
return out;
|
|
17644
18484
|
}
|
|
17645
18485
|
function sha256(data) {
|
|
17646
|
-
const
|
|
18486
|
+
const h2 = new Uint32Array(IV);
|
|
17647
18487
|
const view = pad64(data);
|
|
17648
|
-
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress(
|
|
17649
|
-
return wordsOut(
|
|
18488
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress(h2, view, offset2);
|
|
18489
|
+
return wordsOut(h2);
|
|
17650
18490
|
}
|
|
17651
18491
|
|
|
17652
18492
|
// digest/sha1.ts
|
|
17653
18493
|
var W2 = new Uint32Array(80);
|
|
17654
18494
|
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
17655
|
-
function compress2(
|
|
17656
|
-
for (let
|
|
17657
|
-
for (let
|
|
17658
|
-
let a =
|
|
17659
|
-
for (let
|
|
17660
|
-
let
|
|
18495
|
+
function compress2(h2, view, offset2) {
|
|
18496
|
+
for (let i2 = 0; i2 < 16; i2++) W2[i2] = view.getUint32(offset2 + i2 * 4);
|
|
18497
|
+
for (let i2 = 16; i2 < 80; i2++) W2[i2] = rotl(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1);
|
|
18498
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4];
|
|
18499
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
18500
|
+
let f6;
|
|
17661
18501
|
let k;
|
|
17662
|
-
if (
|
|
17663
|
-
|
|
18502
|
+
if (i2 < 20) {
|
|
18503
|
+
f6 = b & c | ~b & d;
|
|
17664
18504
|
k = 1518500249;
|
|
17665
|
-
} else if (
|
|
17666
|
-
|
|
18505
|
+
} else if (i2 < 40) {
|
|
18506
|
+
f6 = b ^ c ^ d;
|
|
17667
18507
|
k = 1859775393;
|
|
17668
|
-
} else if (
|
|
17669
|
-
|
|
18508
|
+
} else if (i2 < 60) {
|
|
18509
|
+
f6 = b & c | b & d | c & d;
|
|
17670
18510
|
k = 2400959708;
|
|
17671
18511
|
} else {
|
|
17672
|
-
|
|
18512
|
+
f6 = b ^ c ^ d;
|
|
17673
18513
|
k = 3395469782;
|
|
17674
18514
|
}
|
|
17675
|
-
const t = rotl(a, 5) +
|
|
18515
|
+
const t = rotl(a, 5) + f6 + e + k + W2[i2] >>> 0;
|
|
17676
18516
|
e = d;
|
|
17677
18517
|
d = c;
|
|
17678
18518
|
c = rotl(b, 30) >>> 0;
|
|
17679
18519
|
b = a;
|
|
17680
18520
|
a = t;
|
|
17681
18521
|
}
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
18522
|
+
h2[0] = h2[0] + a >>> 0;
|
|
18523
|
+
h2[1] = h2[1] + b >>> 0;
|
|
18524
|
+
h2[2] = h2[2] + c >>> 0;
|
|
18525
|
+
h2[3] = h2[3] + d >>> 0;
|
|
18526
|
+
h2[4] = h2[4] + e >>> 0;
|
|
17687
18527
|
}
|
|
17688
18528
|
function sha1(data) {
|
|
17689
|
-
const
|
|
18529
|
+
const h2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
17690
18530
|
const view = pad64(data);
|
|
17691
|
-
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress2(
|
|
17692
|
-
return wordsOut(
|
|
18531
|
+
for (let offset2 = 0; offset2 < view.byteLength; offset2 += 64) compress2(h2, view, offset2);
|
|
18532
|
+
return wordsOut(h2);
|
|
17693
18533
|
}
|
|
17694
18534
|
|
|
17695
18535
|
// digest/sha512.ts
|
|
17696
|
-
var
|
|
18536
|
+
var K4 = new Uint32Array([
|
|
17697
18537
|
1116352408,
|
|
17698
18538
|
3609767458,
|
|
17699
18539
|
1899447441,
|
|
@@ -17892,35 +18732,35 @@ var IV_384 = [
|
|
|
17892
18732
|
3204075428
|
|
17893
18733
|
];
|
|
17894
18734
|
var W3 = new Uint32Array(160);
|
|
17895
|
-
function compress3(
|
|
17896
|
-
for (let
|
|
17897
|
-
const o = offset2 +
|
|
17898
|
-
W3[
|
|
17899
|
-
}
|
|
17900
|
-
for (let
|
|
17901
|
-
const xh = W3[(
|
|
17902
|
-
const xl = W3[(
|
|
18735
|
+
function compress3(h2, data, offset2) {
|
|
18736
|
+
for (let i2 = 0; i2 < 32; i2++) {
|
|
18737
|
+
const o = offset2 + i2 * 4;
|
|
18738
|
+
W3[i2] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
18739
|
+
}
|
|
18740
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
18741
|
+
const xh = W3[(i2 - 15) * 2];
|
|
18742
|
+
const xl = W3[(i2 - 15) * 2 + 1];
|
|
17903
18743
|
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
17904
18744
|
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
17905
|
-
const yh = W3[(
|
|
17906
|
-
const yl = W3[(
|
|
18745
|
+
const yh = W3[(i2 - 2) * 2];
|
|
18746
|
+
const yl = W3[(i2 - 2) * 2 + 1];
|
|
17907
18747
|
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
17908
18748
|
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
17909
|
-
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(
|
|
17910
|
-
const hi = s0h + s1h + W3[(
|
|
18749
|
+
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i2 - 7) * 2 + 1] + W3[(i2 - 16) * 2 + 1];
|
|
18750
|
+
const hi = s0h + s1h + W3[(i2 - 7) * 2] + W3[(i2 - 16) * 2] + Math.floor(lo / 4294967296);
|
|
17911
18751
|
lo >>>= 0;
|
|
17912
|
-
W3[
|
|
17913
|
-
W3[
|
|
18752
|
+
W3[i2 * 2] = hi >>> 0;
|
|
18753
|
+
W3[i2 * 2 + 1] = lo;
|
|
17914
18754
|
}
|
|
17915
|
-
let ah =
|
|
17916
|
-
let eh =
|
|
17917
|
-
for (let
|
|
18755
|
+
let ah = h2[0], al = h2[1], bh = h2[2], bl = h2[3], ch = h2[4], cl = h2[5], dh = h2[6], dl = h2[7];
|
|
18756
|
+
let eh = h2[8], el = h2[9], fh = h2[10], fl = h2[11], gh = h2[12], gl = h2[13], hh = h2[14], hl = h2[15];
|
|
18757
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
17918
18758
|
const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
|
|
17919
18759
|
const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
|
|
17920
18760
|
const chh = eh & fh ^ ~eh & gh;
|
|
17921
18761
|
const chl = el & fl ^ ~el & gl;
|
|
17922
|
-
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) +
|
|
17923
|
-
const t1h = hh + S1h + chh +
|
|
18762
|
+
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K4[i2 * 2 + 1] + W3[i2 * 2 + 1];
|
|
18763
|
+
const t1h = hh + S1h + chh + K4[i2 * 2] + W3[i2 * 2] + Math.floor(t1l / 4294967296);
|
|
17924
18764
|
t1l >>>= 0;
|
|
17925
18765
|
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
17926
18766
|
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
@@ -17948,10 +18788,10 @@ function compress3(h, data, offset2) {
|
|
|
17948
18788
|
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
17949
18789
|
al = nl >>> 0;
|
|
17950
18790
|
}
|
|
17951
|
-
const add2 = (
|
|
17952
|
-
const lo = (
|
|
17953
|
-
|
|
17954
|
-
|
|
18791
|
+
const add2 = (i2, xh, xl) => {
|
|
18792
|
+
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
18793
|
+
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
18794
|
+
h2[i2 + 1] = lo >>> 0;
|
|
17955
18795
|
};
|
|
17956
18796
|
add2(0, ah, al);
|
|
17957
18797
|
add2(2, bh, bl);
|
|
@@ -17963,7 +18803,7 @@ function compress3(h, data, offset2) {
|
|
|
17963
18803
|
add2(14, hh, hl);
|
|
17964
18804
|
}
|
|
17965
18805
|
function digest64(data, iv, bytes) {
|
|
17966
|
-
const
|
|
18806
|
+
const h2 = new Uint32Array(iv);
|
|
17967
18807
|
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
17968
18808
|
padded.set(data);
|
|
17969
18809
|
padded[data.length] = 128;
|
|
@@ -17971,44 +18811,426 @@ function digest64(data, iv, bytes) {
|
|
|
17971
18811
|
const view = new DataView(padded.buffer);
|
|
17972
18812
|
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
17973
18813
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
17974
|
-
for (let offset2 = 0; offset2 < padded.length; offset2 += 128) compress3(
|
|
18814
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += 128) compress3(h2, padded, offset2);
|
|
17975
18815
|
const out = new Uint8Array(bytes);
|
|
17976
18816
|
const outView = new DataView(out.buffer);
|
|
17977
|
-
for (let
|
|
18817
|
+
for (let i2 = 0; i2 < bytes / 4; i2++) outView.setUint32(i2 * 4, h2[i2]);
|
|
17978
18818
|
return out;
|
|
17979
18819
|
}
|
|
17980
18820
|
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
17981
18821
|
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
17982
18822
|
|
|
18823
|
+
// digest/whirlpool-sbox.ts
|
|
18824
|
+
var TABLE0 = [
|
|
18825
|
+
0x18186018c07830d8n,
|
|
18826
|
+
0x23238c2305af4626n,
|
|
18827
|
+
0xc6c63fc67ef991b8n,
|
|
18828
|
+
0xe8e887e8136fcdfbn,
|
|
18829
|
+
0x878726874ca113cbn,
|
|
18830
|
+
0xb8b8dab8a9626d11n,
|
|
18831
|
+
0x0101040108050209n,
|
|
18832
|
+
0x4f4f214f426e9e0dn,
|
|
18833
|
+
0x3636d836adee6c9bn,
|
|
18834
|
+
0xa6a6a2a6590451ffn,
|
|
18835
|
+
0xd2d26fd2debdb90cn,
|
|
18836
|
+
0xf5f5f3f5fb06f70en,
|
|
18837
|
+
0x7979f979ef80f296n,
|
|
18838
|
+
0x6f6fa16f5fcede30n,
|
|
18839
|
+
0x91917e91fcef3f6dn,
|
|
18840
|
+
0x52525552aa07a4f8n,
|
|
18841
|
+
0x60609d6027fdc047n,
|
|
18842
|
+
0xbcbccabc89766535n,
|
|
18843
|
+
0x9b9b569baccd2b37n,
|
|
18844
|
+
0x8e8e028e048c018an,
|
|
18845
|
+
0xa3a3b6a371155bd2n,
|
|
18846
|
+
0x0c0c300c603c186cn,
|
|
18847
|
+
0x7b7bf17bff8af684n,
|
|
18848
|
+
0x3535d435b5e16a80n,
|
|
18849
|
+
0x1d1d741de8693af5n,
|
|
18850
|
+
0xe0e0a7e05347ddb3n,
|
|
18851
|
+
0xd7d77bd7f6acb321n,
|
|
18852
|
+
0xc2c22fc25eed999cn,
|
|
18853
|
+
0x2e2eb82e6d965c43n,
|
|
18854
|
+
0x4b4b314b627a9629n,
|
|
18855
|
+
0xfefedffea321e15dn,
|
|
18856
|
+
0x575741578216aed5n,
|
|
18857
|
+
0x15155415a8412abdn,
|
|
18858
|
+
0x7777c1779fb6eee8n,
|
|
18859
|
+
0x3737dc37a5eb6e92n,
|
|
18860
|
+
0xe5e5b3e57b56d79en,
|
|
18861
|
+
0x9f9f469f8cd92313n,
|
|
18862
|
+
0xf0f0e7f0d317fd23n,
|
|
18863
|
+
0x4a4a354a6a7f9420n,
|
|
18864
|
+
0xdada4fda9e95a944n,
|
|
18865
|
+
0x58587d58fa25b0a2n,
|
|
18866
|
+
0xc9c903c906ca8fcfn,
|
|
18867
|
+
0x2929a429558d527cn,
|
|
18868
|
+
0x0a0a280a5022145an,
|
|
18869
|
+
0xb1b1feb1e14f7f50n,
|
|
18870
|
+
0xa0a0baa0691a5dc9n,
|
|
18871
|
+
0x6b6bb16b7fdad614n,
|
|
18872
|
+
0x85852e855cab17d9n,
|
|
18873
|
+
0xbdbdcebd8173673cn,
|
|
18874
|
+
0x5d5d695dd234ba8fn,
|
|
18875
|
+
0x1010401080502090n,
|
|
18876
|
+
0xf4f4f7f4f303f507n,
|
|
18877
|
+
0xcbcb0bcb16c08bddn,
|
|
18878
|
+
0x3e3ef83eedc67cd3n,
|
|
18879
|
+
0x0505140528110a2dn,
|
|
18880
|
+
0x676781671fe6ce78n,
|
|
18881
|
+
0xe4e4b7e47353d597n,
|
|
18882
|
+
0x27279c2725bb4e02n,
|
|
18883
|
+
0x4141194132588273n,
|
|
18884
|
+
0x8b8b168b2c9d0ba7n,
|
|
18885
|
+
0xa7a7a6a7510153f6n,
|
|
18886
|
+
0x7d7de97dcf94fab2n,
|
|
18887
|
+
0x95956e95dcfb3749n,
|
|
18888
|
+
0xd8d847d88e9fad56n,
|
|
18889
|
+
0xfbfbcbfb8b30eb70n,
|
|
18890
|
+
0xeeee9fee2371c1cdn,
|
|
18891
|
+
0x7c7ced7cc791f8bbn,
|
|
18892
|
+
0x6666856617e3cc71n,
|
|
18893
|
+
0xdddd53dda68ea77bn,
|
|
18894
|
+
0x17175c17b84b2eafn,
|
|
18895
|
+
0x4747014702468e45n,
|
|
18896
|
+
0x9e9e429e84dc211an,
|
|
18897
|
+
0xcaca0fca1ec589d4n,
|
|
18898
|
+
0x2d2db42d75995a58n,
|
|
18899
|
+
0xbfbfc6bf9179632en,
|
|
18900
|
+
0x07071c07381b0e3fn,
|
|
18901
|
+
0xadad8ead012347acn,
|
|
18902
|
+
0x5a5a755aea2fb4b0n,
|
|
18903
|
+
0x838336836cb51befn,
|
|
18904
|
+
0x3333cc3385ff66b6n,
|
|
18905
|
+
0x636391633ff2c65cn,
|
|
18906
|
+
0x02020802100a0412n,
|
|
18907
|
+
0xaaaa92aa39384993n,
|
|
18908
|
+
0x7171d971afa8e2den,
|
|
18909
|
+
0xc8c807c80ecf8dc6n,
|
|
18910
|
+
0x19196419c87d32d1n,
|
|
18911
|
+
0x494939497270923bn,
|
|
18912
|
+
0xd9d943d9869aaf5fn,
|
|
18913
|
+
0xf2f2eff2c31df931n,
|
|
18914
|
+
0xe3e3abe34b48dba8n,
|
|
18915
|
+
0x5b5b715be22ab6b9n,
|
|
18916
|
+
0x88881a8834920dbcn,
|
|
18917
|
+
0x9a9a529aa4c8293en,
|
|
18918
|
+
0x262698262dbe4c0bn,
|
|
18919
|
+
0x3232c8328dfa64bfn,
|
|
18920
|
+
0xb0b0fab0e94a7d59n,
|
|
18921
|
+
0xe9e983e91b6acff2n,
|
|
18922
|
+
0x0f0f3c0f78331e77n,
|
|
18923
|
+
0xd5d573d5e6a6b733n,
|
|
18924
|
+
0x80803a8074ba1df4n,
|
|
18925
|
+
0xbebec2be997c6127n,
|
|
18926
|
+
0xcdcd13cd26de87ebn,
|
|
18927
|
+
0x3434d034bde46889n,
|
|
18928
|
+
0x48483d487a759032n,
|
|
18929
|
+
0xffffdbffab24e354n,
|
|
18930
|
+
0x7a7af57af78ff48dn,
|
|
18931
|
+
0x90907a90f4ea3d64n,
|
|
18932
|
+
0x5f5f615fc23ebe9dn,
|
|
18933
|
+
0x202080201da0403dn,
|
|
18934
|
+
0x6868bd6867d5d00fn,
|
|
18935
|
+
0x1a1a681ad07234can,
|
|
18936
|
+
0xaeae82ae192c41b7n,
|
|
18937
|
+
0xb4b4eab4c95e757dn,
|
|
18938
|
+
0x54544d549a19a8cen,
|
|
18939
|
+
0x93937693ece53b7fn,
|
|
18940
|
+
0x222288220daa442fn,
|
|
18941
|
+
0x64648d6407e9c863n,
|
|
18942
|
+
0xf1f1e3f1db12ff2an,
|
|
18943
|
+
0x7373d173bfa2e6ccn,
|
|
18944
|
+
0x12124812905a2482n,
|
|
18945
|
+
0x40401d403a5d807an,
|
|
18946
|
+
0x0808200840281048n,
|
|
18947
|
+
0xc3c32bc356e89b95n,
|
|
18948
|
+
0xecec97ec337bc5dfn,
|
|
18949
|
+
0xdbdb4bdb9690ab4dn,
|
|
18950
|
+
0xa1a1bea1611f5fc0n,
|
|
18951
|
+
0x8d8d0e8d1c830791n,
|
|
18952
|
+
0x3d3df43df5c97ac8n,
|
|
18953
|
+
0x97976697ccf1335bn,
|
|
18954
|
+
0x0000000000000000n,
|
|
18955
|
+
0xcfcf1bcf36d483f9n,
|
|
18956
|
+
0x2b2bac2b4587566en,
|
|
18957
|
+
0x7676c57697b3ece1n,
|
|
18958
|
+
0x8282328264b019e6n,
|
|
18959
|
+
0xd6d67fd6fea9b128n,
|
|
18960
|
+
0x1b1b6c1bd87736c3n,
|
|
18961
|
+
0xb5b5eeb5c15b7774n,
|
|
18962
|
+
0xafaf86af112943ben,
|
|
18963
|
+
0x6a6ab56a77dfd41dn,
|
|
18964
|
+
0x50505d50ba0da0ean,
|
|
18965
|
+
0x45450945124c8a57n,
|
|
18966
|
+
0xf3f3ebf3cb18fb38n,
|
|
18967
|
+
0x3030c0309df060adn,
|
|
18968
|
+
0xefef9bef2b74c3c4n,
|
|
18969
|
+
0x3f3ffc3fe5c37edan,
|
|
18970
|
+
0x55554955921caac7n,
|
|
18971
|
+
0xa2a2b2a2791059dbn,
|
|
18972
|
+
0xeaea8fea0365c9e9n,
|
|
18973
|
+
0x656589650fecca6an,
|
|
18974
|
+
0xbabad2bab9686903n,
|
|
18975
|
+
0x2f2fbc2f65935e4an,
|
|
18976
|
+
0xc0c027c04ee79d8en,
|
|
18977
|
+
0xdede5fdebe81a160n,
|
|
18978
|
+
0x1c1c701ce06c38fcn,
|
|
18979
|
+
0xfdfdd3fdbb2ee746n,
|
|
18980
|
+
0x4d4d294d52649a1fn,
|
|
18981
|
+
0x92927292e4e03976n,
|
|
18982
|
+
0x7575c9758fbceafan,
|
|
18983
|
+
0x06061806301e0c36n,
|
|
18984
|
+
0x8a8a128a249809aen,
|
|
18985
|
+
0xb2b2f2b2f940794bn,
|
|
18986
|
+
0xe6e6bfe66359d185n,
|
|
18987
|
+
0x0e0e380e70361c7en,
|
|
18988
|
+
0x1f1f7c1ff8633ee7n,
|
|
18989
|
+
0x6262956237f7c455n,
|
|
18990
|
+
0xd4d477d4eea3b53an,
|
|
18991
|
+
0xa8a89aa829324d81n,
|
|
18992
|
+
0x96966296c4f43152n,
|
|
18993
|
+
0xf9f9c3f99b3aef62n,
|
|
18994
|
+
0xc5c533c566f697a3n,
|
|
18995
|
+
0x2525942535b14a10n,
|
|
18996
|
+
0x59597959f220b2abn,
|
|
18997
|
+
0x84842a8454ae15d0n,
|
|
18998
|
+
0x7272d572b7a7e4c5n,
|
|
18999
|
+
0x3939e439d5dd72ecn,
|
|
19000
|
+
0x4c4c2d4c5a619816n,
|
|
19001
|
+
0x5e5e655eca3bbc94n,
|
|
19002
|
+
0x7878fd78e785f09fn,
|
|
19003
|
+
0x3838e038ddd870e5n,
|
|
19004
|
+
0x8c8c0a8c14860598n,
|
|
19005
|
+
0xd1d163d1c6b2bf17n,
|
|
19006
|
+
0xa5a5aea5410b57e4n,
|
|
19007
|
+
0xe2e2afe2434dd9a1n,
|
|
19008
|
+
0x616199612ff8c24en,
|
|
19009
|
+
0xb3b3f6b3f1457b42n,
|
|
19010
|
+
0x2121842115a54234n,
|
|
19011
|
+
0x9c9c4a9c94d62508n,
|
|
19012
|
+
0x1e1e781ef0663ceen,
|
|
19013
|
+
0x4343114322528661n,
|
|
19014
|
+
0xc7c73bc776fc93b1n,
|
|
19015
|
+
0xfcfcd7fcb32be54fn,
|
|
19016
|
+
0x0404100420140824n,
|
|
19017
|
+
0x51515951b208a2e3n,
|
|
19018
|
+
0x99995e99bcc72f25n,
|
|
19019
|
+
0x6d6da96d4fc4da22n,
|
|
19020
|
+
0x0d0d340d68391a65n,
|
|
19021
|
+
0xfafacffa8335e979n,
|
|
19022
|
+
0xdfdf5bdfb684a369n,
|
|
19023
|
+
0x7e7ee57ed79bfca9n,
|
|
19024
|
+
0x242490243db44819n,
|
|
19025
|
+
0x3b3bec3bc5d776fen,
|
|
19026
|
+
0xabab96ab313d4b9an,
|
|
19027
|
+
0xcece1fce3ed181f0n,
|
|
19028
|
+
0x1111441188552299n,
|
|
19029
|
+
0x8f8f068f0c890383n,
|
|
19030
|
+
0x4e4e254e4a6b9c04n,
|
|
19031
|
+
0xb7b7e6b7d1517366n,
|
|
19032
|
+
0xebeb8beb0b60cbe0n,
|
|
19033
|
+
0x3c3cf03cfdcc78c1n,
|
|
19034
|
+
0x81813e817cbf1ffdn,
|
|
19035
|
+
0x94946a94d4fe3540n,
|
|
19036
|
+
0xf7f7fbf7eb0cf31cn,
|
|
19037
|
+
0xb9b9deb9a1676f18n,
|
|
19038
|
+
0x13134c13985f268bn,
|
|
19039
|
+
0x2c2cb02c7d9c5851n,
|
|
19040
|
+
0xd3d36bd3d6b8bb05n,
|
|
19041
|
+
0xe7e7bbe76b5cd38cn,
|
|
19042
|
+
0x6e6ea56e57cbdc39n,
|
|
19043
|
+
0xc4c437c46ef395aan,
|
|
19044
|
+
0x03030c03180f061bn,
|
|
19045
|
+
0x565645568a13acdcn,
|
|
19046
|
+
0x44440d441a49885en,
|
|
19047
|
+
0x7f7fe17fdf9efea0n,
|
|
19048
|
+
0xa9a99ea921374f88n,
|
|
19049
|
+
0x2a2aa82a4d825467n,
|
|
19050
|
+
0xbbbbd6bbb16d6b0an,
|
|
19051
|
+
0xc1c123c146e29f87n,
|
|
19052
|
+
0x53535153a202a6f1n,
|
|
19053
|
+
0xdcdc57dcae8ba572n,
|
|
19054
|
+
0x0b0b2c0b58271653n,
|
|
19055
|
+
0x9d9d4e9d9cd32701n,
|
|
19056
|
+
0x6c6cad6c47c1d82bn,
|
|
19057
|
+
0x3131c43195f562a4n,
|
|
19058
|
+
0x7474cd7487b9e8f3n,
|
|
19059
|
+
0xf6f6fff6e309f115n,
|
|
19060
|
+
0x464605460a438c4cn,
|
|
19061
|
+
0xacac8aac092645a5n,
|
|
19062
|
+
0x89891e893c970fb5n,
|
|
19063
|
+
0x14145014a04428b4n,
|
|
19064
|
+
0xe1e1a3e15b42dfban,
|
|
19065
|
+
0x16165816b04e2ca6n,
|
|
19066
|
+
0x3a3ae83acdd274f7n,
|
|
19067
|
+
0x6969b9696fd0d206n,
|
|
19068
|
+
0x09092409482d1241n,
|
|
19069
|
+
0x7070dd70a7ade0d7n,
|
|
19070
|
+
0xb6b6e2b6d954716fn,
|
|
19071
|
+
0xd0d067d0ceb7bd1en,
|
|
19072
|
+
0xeded93ed3b7ec7d6n,
|
|
19073
|
+
0xcccc17cc2edb85e2n,
|
|
19074
|
+
0x424215422a578468n,
|
|
19075
|
+
0x98985a98b4c22d2cn,
|
|
19076
|
+
0xa4a4aaa4490e55edn,
|
|
19077
|
+
0x2828a0285d885075n,
|
|
19078
|
+
0x5c5c6d5cda31b886n,
|
|
19079
|
+
0xf8f8c7f8933fed6bn,
|
|
19080
|
+
0x8686228644a411c2n
|
|
19081
|
+
];
|
|
19082
|
+
|
|
19083
|
+
// digest/whirlpool-table.ts
|
|
19084
|
+
var WORD_MASK = (1n << 64n) - 1n;
|
|
19085
|
+
var LOW_MASK = 0xffffffffn;
|
|
19086
|
+
function rotateBytesRight(value2, bytes) {
|
|
19087
|
+
const bits = BigInt(bytes) * 8n;
|
|
19088
|
+
return (value2 >> bits | value2 << 64n - bits) & WORD_MASK;
|
|
19089
|
+
}
|
|
19090
|
+
var TABLES_HI = new Uint32Array(8 * 256);
|
|
19091
|
+
var TABLES_LO = new Uint32Array(8 * 256);
|
|
19092
|
+
for (let t = 0; t < 8; t++) {
|
|
19093
|
+
for (let x = 0; x < 256; x++) {
|
|
19094
|
+
const value2 = t === 0 ? TABLE0[x] : rotateBytesRight(TABLE0[x], t);
|
|
19095
|
+
TABLES_HI[t * 256 + x] = Number(value2 >> 32n);
|
|
19096
|
+
TABLES_LO[t * 256 + x] = Number(value2 & LOW_MASK);
|
|
19097
|
+
}
|
|
19098
|
+
}
|
|
19099
|
+
var ROUND_CONSTANTS = [
|
|
19100
|
+
0x1823c6e887b8014fn,
|
|
19101
|
+
0x36a6d2f5796f9152n,
|
|
19102
|
+
0x60bc9b8ea30c7b35n,
|
|
19103
|
+
0x1de0d7c22e4bfe57n,
|
|
19104
|
+
0x157737e59ff04adan,
|
|
19105
|
+
0x58c9290ab1a06b85n,
|
|
19106
|
+
0xbd5d10f4cb3e0567n,
|
|
19107
|
+
0xe427418ba77d95d8n,
|
|
19108
|
+
0xfbee7c66dd17479en,
|
|
19109
|
+
0xca2dbf07ad5a8333n
|
|
19110
|
+
];
|
|
19111
|
+
var ROUND_CONSTANTS_HI = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c >> 32n));
|
|
19112
|
+
var ROUND_CONSTANTS_LO = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c & LOW_MASK));
|
|
19113
|
+
|
|
19114
|
+
// digest/whirlpool.ts
|
|
19115
|
+
var TABLES_HI2 = TABLES_HI;
|
|
19116
|
+
var TABLES_LO2 = TABLES_LO;
|
|
19117
|
+
var ROUND_CONSTANTS_HI2 = ROUND_CONSTANTS_HI;
|
|
19118
|
+
var ROUND_CONSTANTS_LO2 = ROUND_CONSTANTS_LO;
|
|
19119
|
+
var BLOCK_BYTES = 64;
|
|
19120
|
+
var WORDS = 8;
|
|
19121
|
+
var ROUNDS2 = 10;
|
|
19122
|
+
var words = () => ({ hi: new Uint32Array(WORDS), lo: new Uint32Array(WORDS) });
|
|
19123
|
+
function op(src, column, out) {
|
|
19124
|
+
const { hi: h2, lo: l } = src;
|
|
19125
|
+
const b0 = h2[column] >>> 24;
|
|
19126
|
+
const b1 = h2[column + 7 & 7] >>> 16 & 255;
|
|
19127
|
+
const b2 = h2[column + 6 & 7] >>> 8 & 255;
|
|
19128
|
+
const b3 = h2[column + 5 & 7] & 255;
|
|
19129
|
+
const b4 = l[column + 4 & 7] >>> 24;
|
|
19130
|
+
const b5 = l[column + 3 & 7] >>> 16 & 255;
|
|
19131
|
+
const b6 = l[column + 2 & 7] >>> 8 & 255;
|
|
19132
|
+
const b7 = l[column + 1 & 7] & 255;
|
|
19133
|
+
out.hi[column] = TABLES_HI2[b0] ^ TABLES_HI2[256 + b1] ^ TABLES_HI2[512 + b2] ^ TABLES_HI2[768 + b3] ^ TABLES_HI2[1024 + b4] ^ TABLES_HI2[1280 + b5] ^ TABLES_HI2[1536 + b6] ^ TABLES_HI2[1792 + b7];
|
|
19134
|
+
out.lo[column] = TABLES_LO2[b0] ^ TABLES_LO2[256 + b1] ^ TABLES_LO2[512 + b2] ^ TABLES_LO2[768 + b3] ^ TABLES_LO2[1024 + b4] ^ TABLES_LO2[1280 + b5] ^ TABLES_LO2[1536 + b6] ^ TABLES_LO2[1792 + b7];
|
|
19135
|
+
}
|
|
19136
|
+
var scratch = { key: words(), state: words(), initial: words(), nextKey: words(), next: words() };
|
|
19137
|
+
function processBlock(hash, block) {
|
|
19138
|
+
const { key, state, initial, nextKey, next } = scratch;
|
|
19139
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19140
|
+
initial.hi[i2] = block.hi[i2] ^ hash.hi[i2];
|
|
19141
|
+
initial.lo[i2] = block.lo[i2] ^ hash.lo[i2];
|
|
19142
|
+
}
|
|
19143
|
+
key.hi.set(hash.hi);
|
|
19144
|
+
key.lo.set(hash.lo);
|
|
19145
|
+
state.hi.set(initial.hi);
|
|
19146
|
+
state.lo.set(initial.lo);
|
|
19147
|
+
for (let round3 = 0; round3 < ROUNDS2; round3++) {
|
|
19148
|
+
for (let j = 0; j < WORDS; j++) op(key, j, nextKey);
|
|
19149
|
+
nextKey.hi[0] = nextKey.hi[0] ^ ROUND_CONSTANTS_HI2[round3];
|
|
19150
|
+
nextKey.lo[0] = nextKey.lo[0] ^ ROUND_CONSTANTS_LO2[round3];
|
|
19151
|
+
for (let j = 0; j < WORDS; j++) {
|
|
19152
|
+
op(state, j, next);
|
|
19153
|
+
next.hi[j] = next.hi[j] ^ nextKey.hi[j];
|
|
19154
|
+
next.lo[j] = next.lo[j] ^ nextKey.lo[j];
|
|
19155
|
+
}
|
|
19156
|
+
key.hi.set(nextKey.hi);
|
|
19157
|
+
key.lo.set(nextKey.lo);
|
|
19158
|
+
state.hi.set(next.hi);
|
|
19159
|
+
state.lo.set(next.lo);
|
|
19160
|
+
}
|
|
19161
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19162
|
+
hash.hi[i2] = initial.hi[i2] ^ state.hi[i2];
|
|
19163
|
+
hash.lo[i2] = initial.lo[i2] ^ state.lo[i2];
|
|
19164
|
+
}
|
|
19165
|
+
}
|
|
19166
|
+
function pad3(message) {
|
|
19167
|
+
let total2 = message.length + 1;
|
|
19168
|
+
while (total2 % BLOCK_BYTES !== 32) {
|
|
19169
|
+
total2++;
|
|
19170
|
+
}
|
|
19171
|
+
total2 += 32;
|
|
19172
|
+
const padded = new Uint8Array(total2);
|
|
19173
|
+
padded.set(message);
|
|
19174
|
+
padded[message.length] = 128;
|
|
19175
|
+
new DataView(padded.buffer).setBigUint64(total2 - 8, BigInt(message.length) * 8n, false);
|
|
19176
|
+
return padded;
|
|
19177
|
+
}
|
|
19178
|
+
function whirlpool(message) {
|
|
19179
|
+
const padded = pad3(message);
|
|
19180
|
+
const view = new DataView(padded.buffer);
|
|
19181
|
+
const hash = words();
|
|
19182
|
+
const block = words();
|
|
19183
|
+
for (let offset2 = 0; offset2 < padded.length; offset2 += BLOCK_BYTES) {
|
|
19184
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19185
|
+
block.hi[i2] = view.getUint32(offset2 + i2 * 8, false);
|
|
19186
|
+
block.lo[i2] = view.getUint32(offset2 + i2 * 8 + 4, false);
|
|
19187
|
+
}
|
|
19188
|
+
processBlock(hash, block);
|
|
19189
|
+
}
|
|
19190
|
+
const out = new Uint8Array(BLOCK_BYTES);
|
|
19191
|
+
const outView = new DataView(out.buffer);
|
|
19192
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
19193
|
+
outView.setUint32(i2 * 8, hash.hi[i2], false);
|
|
19194
|
+
outView.setUint32(i2 * 8 + 4, hash.lo[i2], false);
|
|
19195
|
+
}
|
|
19196
|
+
return out;
|
|
19197
|
+
}
|
|
19198
|
+
|
|
17983
19199
|
// digest/digest.ts
|
|
17984
19200
|
var DIGESTS = {
|
|
17985
19201
|
"SHA-1": sha1,
|
|
17986
19202
|
"SHA-256": sha256,
|
|
17987
19203
|
"SHA-384": sha384,
|
|
17988
|
-
"SHA-512": sha512
|
|
19204
|
+
"SHA-512": sha512,
|
|
19205
|
+
MD2: md2,
|
|
19206
|
+
MD4: md4,
|
|
19207
|
+
MD5: md5,
|
|
19208
|
+
"RIPEMD-128": ripemd128,
|
|
19209
|
+
"RIPEMD-160": ripemd160,
|
|
19210
|
+
WHIRLPOOL: whirlpool
|
|
17989
19211
|
};
|
|
17990
19212
|
function digestFunction(name) {
|
|
17991
19213
|
const canonical = normalizeDigestAlgorithmName(name);
|
|
17992
|
-
return canonical &&
|
|
19214
|
+
return canonical && DIGESTS[canonical];
|
|
17993
19215
|
}
|
|
17994
19216
|
|
|
17995
19217
|
// digest/password-hash.ts
|
|
17996
19218
|
var MAX_SPIN_COUNT = 1e7;
|
|
17997
19219
|
var validSpinCount = (spinCount) => spinCount === void 0 || Number.isInteger(spinCount) && spinCount >= 0 && spinCount <= MAX_SPIN_COUNT;
|
|
17998
|
-
function
|
|
19220
|
+
function spinPasswordHash(password, salt, spinCount, digest) {
|
|
17999
19221
|
const input = new Uint8Array(salt.length + password.length * 2);
|
|
18000
19222
|
input.set(salt);
|
|
18001
|
-
for (let
|
|
18002
|
-
const code = password.charCodeAt(
|
|
18003
|
-
input[salt.length +
|
|
18004
|
-
input[salt.length +
|
|
19223
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
19224
|
+
const code = password.charCodeAt(i2);
|
|
19225
|
+
input[salt.length + i2 * 2] = code & 255;
|
|
19226
|
+
input[salt.length + i2 * 2 + 1] = code >> 8;
|
|
18005
19227
|
}
|
|
18006
19228
|
let value2 = digest(input);
|
|
18007
19229
|
const buffer = new Uint8Array(value2.length + 4);
|
|
18008
19230
|
const view = new DataView(buffer.buffer);
|
|
18009
|
-
for (let
|
|
19231
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
18010
19232
|
buffer.set(value2);
|
|
18011
|
-
view.setUint32(value2.length,
|
|
19233
|
+
view.setUint32(value2.length, i2, true);
|
|
18012
19234
|
value2 = digest(buffer);
|
|
18013
19235
|
}
|
|
18014
19236
|
return value2;
|
|
@@ -18017,7 +19239,7 @@ function hashBytes(password, { algorithmName, saltValue, spinCount }) {
|
|
|
18017
19239
|
const digest = digestFunction(algorithmName);
|
|
18018
19240
|
const salt = decodeBase64(saltValue);
|
|
18019
19241
|
if (!digest || !salt || !validSpinCount(spinCount)) return void 0;
|
|
18020
|
-
return
|
|
19242
|
+
return spinPasswordHash(password, salt, spinCount ?? 0, digest);
|
|
18021
19243
|
}
|
|
18022
19244
|
function verifyPasswordHash(password, hash) {
|
|
18023
19245
|
if (!digestFunction(hash.algorithmName)) return void 0;
|
|
@@ -18025,15 +19247,15 @@ function verifyPasswordHash(password, hash) {
|
|
|
18025
19247
|
const actual = expected && hashBytes(password, hash);
|
|
18026
19248
|
if (!expected || !actual || actual.length !== expected.length) return false;
|
|
18027
19249
|
let difference = 0;
|
|
18028
|
-
for (let
|
|
19250
|
+
for (let i2 = 0; i2 < actual.length; i2++) difference |= actual[i2] ^ expected[i2];
|
|
18029
19251
|
return difference === 0;
|
|
18030
19252
|
}
|
|
18031
19253
|
|
|
18032
19254
|
// xlsx/edit/protection.ts
|
|
18033
19255
|
function legacyPasswordHash(password) {
|
|
18034
19256
|
let hash = 0;
|
|
18035
|
-
for (let
|
|
18036
|
-
const value2 = (password.charCodeAt(
|
|
19257
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
19258
|
+
const value2 = (password.charCodeAt(i2) & 65535) << i2 + 1;
|
|
18037
19259
|
hash ^= value2 & 32767 | value2 >> 15;
|
|
18038
19260
|
}
|
|
18039
19261
|
hash ^= password.length;
|
|
@@ -18107,7 +19329,7 @@ var hasContent = (cell) => !!cell && !isSpilledCell(cell) && (cell.formula !== v
|
|
|
18107
19329
|
function mergeTargets(r, mode) {
|
|
18108
19330
|
return mode === "across" ? Array.from(
|
|
18109
19331
|
{ length: r.end.row - r.start.row + 1 },
|
|
18110
|
-
(_v,
|
|
19332
|
+
(_v, i2) => cellRange(r.start.row + i2, r.start.col, r.start.row + i2, r.end.col)
|
|
18111
19333
|
).filter((m) => m.start.col !== m.end.col) : [r];
|
|
18112
19334
|
}
|
|
18113
19335
|
function filledCells(sheet, target2) {
|
|
@@ -18213,10 +19435,10 @@ function fontView(font, theme2) {
|
|
|
18213
19435
|
function fillView(fill, theme2, differential = false) {
|
|
18214
19436
|
if (!fill) return void 0;
|
|
18215
19437
|
if (fill.type === "gradient") {
|
|
18216
|
-
const stops = [...fill.stops].sort((a, b) => a.position - b.position).map((stop) => `${resolveColor(stop.color, theme2, WHITE)} ${
|
|
19438
|
+
const stops = [...fill.stops].sort((a, b) => a.position - b.position).map((stop) => `${resolveColor(stop.color, theme2, WHITE)} ${round2(stop.position * 100)}%`);
|
|
18217
19439
|
if (stops.length === 0) return void 0;
|
|
18218
19440
|
if (stops.length === 1) stops.push(stops[0] ?? WHITE);
|
|
18219
|
-
const css = fill.gradient === "path" ? `radial-gradient(circle, ${stops.join(", ")})` : `linear-gradient(${
|
|
19441
|
+
const css = fill.gradient === "path" ? `radial-gradient(circle, ${stops.join(", ")})` : `linear-gradient(${round2(((fill.degree ?? 0) + 90) % 360)}deg, ${stops.join(", ")})`;
|
|
18220
19442
|
return { gradient: css };
|
|
18221
19443
|
}
|
|
18222
19444
|
if (fill.pattern === "none") {
|
|
@@ -18234,7 +19456,7 @@ function fillView(fill, theme2, differential = false) {
|
|
|
18234
19456
|
bg: resolveColor(fill.bgColor, theme2, WHITE) ?? WHITE
|
|
18235
19457
|
};
|
|
18236
19458
|
}
|
|
18237
|
-
var
|
|
19459
|
+
var round2 = (n) => Math.round(n * 100) / 100;
|
|
18238
19460
|
var BORDER_STYLES = {
|
|
18239
19461
|
hair: { widthPx: 1, style: "dotted" },
|
|
18240
19462
|
thin: { widthPx: 1, style: "solid" },
|
|
@@ -18381,7 +19603,7 @@ function cellView(workbook, sheetIndex2, row2, col, cf, options = {}) {
|
|
|
18381
19603
|
if (fill) view.fill = fill;
|
|
18382
19604
|
if (conditional?.dataBar) view.dataBar = conditional.dataBar;
|
|
18383
19605
|
if (conditional?.icon) view.icon = conditional.icon;
|
|
18384
|
-
const link = sheet.hyperlinks.find((
|
|
19606
|
+
const link = sheet.hyperlinks.find((h2) => rangeContains(h2.range, { row: row2, col }));
|
|
18385
19607
|
if (link) {
|
|
18386
19608
|
view.hasHyperlink = true;
|
|
18387
19609
|
const title = link.tooltip ?? link.target ?? link.location;
|
|
@@ -18442,10 +19664,10 @@ var AxisMetrics = class {
|
|
|
18442
19664
|
}
|
|
18443
19665
|
/** Offset of the leading edge of `index` (`index` may equal `count` for the axis end). */
|
|
18444
19666
|
start(index2) {
|
|
18445
|
-
const
|
|
18446
|
-
const k = this.rank(
|
|
19667
|
+
const i2 = Math.max(0, Math.min(index2, this.count));
|
|
19668
|
+
const k = this.rank(i2);
|
|
18447
19669
|
const before = k < this.indices.length ? this.prefix[k] ?? 0 : this.totalDelta;
|
|
18448
|
-
return
|
|
19670
|
+
return i2 * this.defaultSize + before;
|
|
18449
19671
|
}
|
|
18450
19672
|
/** Total extent of lines `0..count-1`. */
|
|
18451
19673
|
get total() {
|
|
@@ -18478,12 +19700,12 @@ var AxisMetrics = class {
|
|
|
18478
19700
|
}
|
|
18479
19701
|
/** The first line at or after `index` with a non-zero size (or `count - 1`). */
|
|
18480
19702
|
firstVisible(index2) {
|
|
18481
|
-
for (let
|
|
19703
|
+
for (let i2 = Math.max(0, index2); i2 < this.count; i2++) if (this.size(i2) > 0) return i2;
|
|
18482
19704
|
return this.count - 1;
|
|
18483
19705
|
}
|
|
18484
19706
|
/** The last line at or before `index` with a non-zero size (or 0). */
|
|
18485
19707
|
lastVisible(index2) {
|
|
18486
|
-
for (let
|
|
19708
|
+
for (let i2 = Math.min(index2, this.count - 1); i2 >= 0; i2--) if (this.size(i2) > 0) return i2;
|
|
18487
19709
|
return 0;
|
|
18488
19710
|
}
|
|
18489
19711
|
/** Largest custom-entry index, or -1. */
|
|
@@ -18579,10 +19801,10 @@ function lineHeightPoints(sizePt) {
|
|
|
18579
19801
|
if (sizePt <= first2[0]) height = first2[1] / first2[0] * sizePt;
|
|
18580
19802
|
else if (sizePt >= last[0]) height = last[1] / last[0] * sizePt;
|
|
18581
19803
|
else {
|
|
18582
|
-
let
|
|
18583
|
-
while (LINE_HEIGHTS[
|
|
18584
|
-
const [s0, h0] = LINE_HEIGHTS[
|
|
18585
|
-
const [s1, h1] = LINE_HEIGHTS[
|
|
19804
|
+
let i2 = 1;
|
|
19805
|
+
while (LINE_HEIGHTS[i2][0] < sizePt) i2++;
|
|
19806
|
+
const [s0, h0] = LINE_HEIGHTS[i2 - 1];
|
|
19807
|
+
const [s1, h1] = LINE_HEIGHTS[i2];
|
|
18586
19808
|
height = h0 + (h1 - h0) * (sizePt - s0) / (s1 - s0);
|
|
18587
19809
|
}
|
|
18588
19810
|
return Math.max(0.75, Math.ceil(height / 0.75 - 1e-9) * 0.75);
|
|
@@ -18626,7 +19848,7 @@ function autoFitRowHeight(workbook, sheetIndex2, row2, measure2) {
|
|
|
18626
19848
|
const view = cellView(workbook, sheetIndex2, row2, col);
|
|
18627
19849
|
if (!view.text) continue;
|
|
18628
19850
|
const fonts = view.rich?.length ? view.rich.map((run) => run.font) : [view.font];
|
|
18629
|
-
const sizePt = Math.max(...fonts.map((
|
|
19851
|
+
const sizePt = Math.max(...fonts.map((f6) => f6.sizePx * 3 / 4));
|
|
18630
19852
|
let lines = 1;
|
|
18631
19853
|
if (view.wrap) {
|
|
18632
19854
|
const width = metrics.colWidth(col) - COLUMN_PADDING_PX - 1 - view.indentPx;
|
|
@@ -18701,9 +19923,9 @@ function remapSheets(workbook, map) {
|
|
|
18701
19923
|
}
|
|
18702
19924
|
var visibleCount = (workbook) => workbook.sheets.filter((s) => s.state === "visible").length;
|
|
18703
19925
|
function nearestVisible(workbook, index2) {
|
|
18704
|
-
for (let
|
|
18705
|
-
if (workbook.sheets[
|
|
18706
|
-
for (let
|
|
19926
|
+
for (let i2 = index2; i2 < workbook.sheets.length; i2++)
|
|
19927
|
+
if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
19928
|
+
for (let i2 = index2 - 1; i2 >= 0; i2--) if (workbook.sheets[i2]?.state === "visible") return i2;
|
|
18707
19929
|
return 0;
|
|
18708
19930
|
}
|
|
18709
19931
|
function addSheet(ctx, name, at) {
|
|
@@ -18719,7 +19941,7 @@ function addSheet(ctx, name, at) {
|
|
|
18719
19941
|
[{ kind: "workbook" }],
|
|
18720
19942
|
() => {
|
|
18721
19943
|
workbook.sheets.splice(index2, 0, createWorksheet(sheetName, nextSheetId(workbook)));
|
|
18722
|
-
remapSheets(workbook, (
|
|
19944
|
+
remapSheets(workbook, (i2) => i2 >= index2 ? i2 + 1 : i2);
|
|
18723
19945
|
workbook.activeSheet = index2;
|
|
18724
19946
|
return index2;
|
|
18725
19947
|
},
|
|
@@ -18739,7 +19961,7 @@ function deleteSheet(ctx, index2) {
|
|
|
18739
19961
|
() => {
|
|
18740
19962
|
const tables = sheet.tables.map((t) => t.name);
|
|
18741
19963
|
workbook.sheets.splice(index2, 1);
|
|
18742
|
-
remapSheets(workbook, (
|
|
19964
|
+
remapSheets(workbook, (i2) => i2 === index2 ? void 0 : i2 > index2 ? i2 - 1 : i2);
|
|
18743
19965
|
rewriteFormulas(workbook, (formula) => deleteSheetInFormula(formula, sheet.name, tables));
|
|
18744
19966
|
if (workbook.activeSheet > index2) workbook.activeSheet--;
|
|
18745
19967
|
else if (workbook.activeSheet === index2)
|
|
@@ -18781,11 +20003,11 @@ function moveSheet(ctx, from, to) {
|
|
|
18781
20003
|
"sheets",
|
|
18782
20004
|
[{ kind: "workbook" }],
|
|
18783
20005
|
() => {
|
|
18784
|
-
const order = workbook.sheets.map((_s,
|
|
20006
|
+
const order = workbook.sheets.map((_s, i2) => i2);
|
|
18785
20007
|
const [moved] = order.splice(from, 1);
|
|
18786
20008
|
if (moved === void 0) return;
|
|
18787
20009
|
order.splice(target2, 0, moved);
|
|
18788
|
-
const sheets = order.map((
|
|
20010
|
+
const sheets = order.map((i2) => workbook.sheets[i2]).filter((s) => s !== void 0);
|
|
18789
20011
|
workbook.sheets.splice(0, workbook.sheets.length, ...sheets);
|
|
18790
20012
|
const newIndex = (old) => order.indexOf(old);
|
|
18791
20013
|
remapSheets(workbook, newIndex);
|
|
@@ -18849,12 +20071,12 @@ function duplicateSheet(ctx, index2) {
|
|
|
18849
20071
|
if (renames.length)
|
|
18850
20072
|
rewriteSheetFormulas(
|
|
18851
20073
|
copy2,
|
|
18852
|
-
(formula) => renames.reduce((
|
|
20074
|
+
(formula) => renames.reduce((f6, [from, to]) => renameTableInFormula(f6, from, to), formula)
|
|
18853
20075
|
);
|
|
18854
20076
|
for (const drawing of copy2.drawings) if (drawing.kind === "chart") delete drawing.partName;
|
|
18855
20077
|
const copiedNames = namesForCopy(workbook, index2, sheet.name, copy2.name);
|
|
18856
20078
|
workbook.sheets.splice(at, 0, copy2);
|
|
18857
|
-
remapSheets(workbook, (
|
|
20079
|
+
remapSheets(workbook, (i2) => i2 >= at ? i2 + 1 : i2);
|
|
18858
20080
|
for (const n of copiedNames) workbook.definedNames.push({ ...n, localSheet: at });
|
|
18859
20081
|
workbook.activeSheet = at;
|
|
18860
20082
|
return at;
|
|
@@ -19033,18 +20255,18 @@ function withProposedValue(workbook, at, value2, fn) {
|
|
|
19033
20255
|
}
|
|
19034
20256
|
}
|
|
19035
20257
|
function check2(workbook, dv, value2, at, evaluate) {
|
|
19036
|
-
const
|
|
19037
|
-
const
|
|
20258
|
+
const f13 = dv.formula1 === void 0 ? void 0 : relativeTo(dv, dv.formula1, at);
|
|
20259
|
+
const f23 = dv.formula2 === void 0 ? void 0 : relativeTo(dv, dv.formula2, at);
|
|
19038
20260
|
if (dv.type === "list") {
|
|
19039
|
-
const items =
|
|
20261
|
+
const items = f13 === void 0 ? [] : listSource(workbook, at.sheet, f13, evaluate, at) ?? [];
|
|
19040
20262
|
return items.some((item) => listItemMatches(item, value2));
|
|
19041
20263
|
}
|
|
19042
20264
|
if (dv.type === "custom") {
|
|
19043
|
-
const result2 = withProposedValue(workbook, at, value2, () => operand3(
|
|
20265
|
+
const result2 = withProposedValue(workbook, at, value2, () => operand3(f13, evaluate, at));
|
|
19044
20266
|
return result2 === true || typeof result2 === "number" && result2 !== 0;
|
|
19045
20267
|
}
|
|
19046
|
-
const a = asNumber(operand3(
|
|
19047
|
-
const b = asNumber(operand3(
|
|
20268
|
+
const a = asNumber(operand3(f13, evaluate, at) ?? null);
|
|
20269
|
+
const b = asNumber(operand3(f23, evaluate, at) ?? null);
|
|
19048
20270
|
if (a === void 0) return true;
|
|
19049
20271
|
const operator = dv.operator ?? "between";
|
|
19050
20272
|
if (dv.type === "textLength") return compare(operator, rawText(value2).length, a, b);
|
|
@@ -19164,8 +20386,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
19164
20386
|
emit(change);
|
|
19165
20387
|
};
|
|
19166
20388
|
const rollback = (current, from) => {
|
|
19167
|
-
for (let
|
|
19168
|
-
const entry = current.step.entries[
|
|
20389
|
+
for (let i2 = current.step.entries.length - 1; i2 >= from; i2--) {
|
|
20390
|
+
const entry = current.step.entries[i2];
|
|
19169
20391
|
if (entry) restoreSnapshot(workbook, entry.before);
|
|
19170
20392
|
}
|
|
19171
20393
|
current.step.entries.length = from;
|
|
@@ -19185,16 +20407,16 @@ function createEditSession(workbook, options = {}) {
|
|
|
19185
20407
|
try {
|
|
19186
20408
|
result2 = fn();
|
|
19187
20409
|
} catch (error) {
|
|
19188
|
-
for (let
|
|
19189
|
-
const snapshot = befores[
|
|
20410
|
+
for (let i2 = befores.length - 1; i2 >= 0; i2--) {
|
|
20411
|
+
const snapshot = befores[i2];
|
|
19190
20412
|
if (snapshot) restoreSnapshot(workbook, snapshot);
|
|
19191
20413
|
}
|
|
19192
20414
|
current.step.entries.length = mark;
|
|
19193
20415
|
if (outer) open = void 0;
|
|
19194
20416
|
throw error;
|
|
19195
20417
|
}
|
|
19196
|
-
scopes.forEach((scope,
|
|
19197
|
-
const before = befores[
|
|
20418
|
+
scopes.forEach((scope, i2) => {
|
|
20419
|
+
const before = befores[i2];
|
|
19198
20420
|
if (before)
|
|
19199
20421
|
current.step.entries.push({ before, after: captureScope(workbook, scope, before) });
|
|
19200
20422
|
});
|
|
@@ -19258,12 +20480,12 @@ function createEditSession(workbook, options = {}) {
|
|
|
19258
20480
|
replaceAll: (query, replacement) => replaceAll(ctx, query, replacement),
|
|
19259
20481
|
replaceOne: (query, replacement, at) => replaceOne(ctx, query, replacement, at),
|
|
19260
20482
|
addSheet: (name, at) => addSheet(ctx, name, at),
|
|
19261
|
-
deleteSheet: (
|
|
19262
|
-
renameSheet: (
|
|
20483
|
+
deleteSheet: (i2) => deleteSheet(ctx, i2),
|
|
20484
|
+
renameSheet: (i2, name) => renameSheet(ctx, i2, name),
|
|
19263
20485
|
moveSheet: (from, to) => moveSheet(ctx, from, to),
|
|
19264
|
-
duplicateSheet: (
|
|
19265
|
-
setSheetState: (
|
|
19266
|
-
setTabColor: (
|
|
20486
|
+
duplicateSheet: (i2) => duplicateSheet(ctx, i2),
|
|
20487
|
+
setSheetState: (i2, state) => setSheetState(ctx, i2, state),
|
|
20488
|
+
setTabColor: (i2, color) => setTabColor(ctx, i2, color),
|
|
19267
20489
|
setFreeze: (s, freeze) => setFreeze(ctx, s, freeze),
|
|
19268
20490
|
setComment: (s, at, text, author) => setComment(ctx, s, at, text, author),
|
|
19269
20491
|
setHyperlink: (s, range2, link) => setHyperlink(ctx, s, range2, link),
|
|
@@ -19284,8 +20506,8 @@ function createEditSession(workbook, options = {}) {
|
|
|
19284
20506
|
addImage: (s, bytes, type, anchor, name) => addImage(ctx, s, bytes, type, anchor, name),
|
|
19285
20507
|
replaceConditionalFormat: (s, index2, cf) => replaceConditionalFormat(ctx, s, index2, cf),
|
|
19286
20508
|
removeConditionalFormat: (s, index2) => removeConditionalFormat(ctx, s, index2),
|
|
19287
|
-
setConditionalRulePriority: (s,
|
|
19288
|
-
moveConditionalRule: (s,
|
|
20509
|
+
setConditionalRulePriority: (s, f6, r, priority) => setConditionalRulePriority(ctx, s, f6, r, priority),
|
|
20510
|
+
moveConditionalRule: (s, f6, r, direction) => moveConditionalRule(ctx, s, f6, r, direction),
|
|
19289
20511
|
updateTable: (s, table2, patch) => updateTable(ctx, s, table2, patch),
|
|
19290
20512
|
resizeTable: (s, table2, range2) => resizeTable(ctx, s, table2, range2),
|
|
19291
20513
|
convertTableToRange: (s, table2) => convertTableToRange(ctx, s, table2),
|
|
@@ -19373,9 +20595,9 @@ function mergeDxf(acc, next) {
|
|
|
19373
20595
|
}
|
|
19374
20596
|
function iconIndex(value2, cuts, list) {
|
|
19375
20597
|
let index2 = 0;
|
|
19376
|
-
for (let
|
|
19377
|
-
const cut = cuts[
|
|
19378
|
-
if (list[
|
|
20598
|
+
for (let i2 = 1; i2 < cuts.length; i2++) {
|
|
20599
|
+
const cut = cuts[i2] ?? Infinity;
|
|
20600
|
+
if (list[i2]?.gte === false ? value2 > cut : value2 >= cut) index2 = i2;
|
|
19379
20601
|
}
|
|
19380
20602
|
return index2;
|
|
19381
20603
|
}
|
|
@@ -19384,12 +20606,12 @@ function scaleColor(value2, cuts, colors) {
|
|
|
19384
20606
|
if (value2 <= (cuts[0] ?? 0)) return colors[0];
|
|
19385
20607
|
const last = cuts.length - 1;
|
|
19386
20608
|
if (value2 >= (cuts[last] ?? 0)) return colors[last];
|
|
19387
|
-
for (let
|
|
19388
|
-
const lo = cuts[
|
|
19389
|
-
const hi = cuts[
|
|
20609
|
+
for (let i2 = 0; i2 < last; i2++) {
|
|
20610
|
+
const lo = cuts[i2] ?? 0;
|
|
20611
|
+
const hi = cuts[i2 + 1] ?? 0;
|
|
19390
20612
|
if (value2 >= lo && value2 <= hi) {
|
|
19391
|
-
const a = colors[
|
|
19392
|
-
const b = colors[
|
|
20613
|
+
const a = colors[i2] ?? "#FFFFFF";
|
|
20614
|
+
const b = colors[i2 + 1] ?? a;
|
|
19393
20615
|
return hi > lo ? mixColors(a, b, (value2 - lo) / (hi - lo), "towardStart") : b;
|
|
19394
20616
|
}
|
|
19395
20617
|
}
|
|
@@ -19441,27 +20663,27 @@ function dataBarGeometry(value2, low, high, options) {
|
|
|
19441
20663
|
const clamp = (v) => Math.max(0, Math.min(1, v));
|
|
19442
20664
|
const minimum = options.minLength;
|
|
19443
20665
|
const delta = options.maxLength - minimum;
|
|
19444
|
-
const
|
|
20666
|
+
const interpolate2 = (ratio, offset2 = minimum) => clamp(offset2 + clamp(ratio) * delta);
|
|
19445
20667
|
if (options.axis === "none") {
|
|
19446
20668
|
const ratio = hi > lo ? clamp((value2 - lo) / (hi - lo)) : 0.5;
|
|
19447
20669
|
return {
|
|
19448
20670
|
start: 0,
|
|
19449
|
-
fraction:
|
|
20671
|
+
fraction: interpolate2(ratio),
|
|
19450
20672
|
reverse: false
|
|
19451
20673
|
};
|
|
19452
20674
|
}
|
|
19453
20675
|
if (options.axis === "middle") {
|
|
19454
20676
|
const span4 = Math.max(Math.abs(lo), Math.abs(hi));
|
|
19455
|
-
const fraction2 =
|
|
20677
|
+
const fraction2 = interpolate2(span4 > 0 ? Math.abs(value2) / span4 : 0) / 2;
|
|
19456
20678
|
return { start: value2 < 0 ? 0.5 - fraction2 : 0.5, fraction: fraction2, axis: 0.5, reverse: value2 < 0 };
|
|
19457
20679
|
}
|
|
19458
20680
|
if (lo === 0 && hi === 0) return { start: 0.5, fraction: minimum / 2, axis: 0.5, reverse: false };
|
|
19459
20681
|
if (lo >= 0) {
|
|
19460
|
-
const fraction2 = hi > lo ?
|
|
20682
|
+
const fraction2 = hi > lo ? interpolate2((value2 - lo) / (hi - lo), lo === 0 ? minimum / 2 : minimum) : interpolate2(0.5);
|
|
19461
20683
|
return { start: 0, fraction: fraction2, reverse: false };
|
|
19462
20684
|
}
|
|
19463
20685
|
if (hi <= 0) {
|
|
19464
|
-
const fraction2 = hi > lo ?
|
|
20686
|
+
const fraction2 = hi > lo ? interpolate2((hi - value2) / (hi - lo), hi === 0 ? minimum / 2 : minimum) : interpolate2(0.5);
|
|
19465
20687
|
const axis2 = hi === 0 ? (1 + options.maxLength - minimum) / 2 : options.maxLength;
|
|
19466
20688
|
return {
|
|
19467
20689
|
start: axis2 - fraction2,
|
|
@@ -19472,7 +20694,7 @@ function dataBarGeometry(value2, low, high, options) {
|
|
|
19472
20694
|
}
|
|
19473
20695
|
const axis = (1 - options.maxLength + minimum) / 2 + -lo / (hi - lo) * delta;
|
|
19474
20696
|
const bounded = Math.max(lo, Math.min(hi, value2));
|
|
19475
|
-
const fraction =
|
|
20697
|
+
const fraction = interpolate2(Math.abs(bounded) / (hi - lo), minimum / 2);
|
|
19476
20698
|
return { start: bounded < 0 ? axis - fraction : axis, fraction, axis, reverse: bounded < 0 };
|
|
19477
20699
|
}
|
|
19478
20700
|
|
|
@@ -19817,7 +21039,7 @@ function overflowExtent(sheet, metrics, row2, col, textWidth, hAlign, maxSpan =
|
|
|
19817
21039
|
const extend = (need, step) => {
|
|
19818
21040
|
let gained = 0;
|
|
19819
21041
|
let c = col;
|
|
19820
|
-
for (let
|
|
21042
|
+
for (let i2 = 0; i2 < maxSpan && gained < need; i2++) {
|
|
19821
21043
|
const next = c + step;
|
|
19822
21044
|
if (next < 0 || next > MAX_COL || !isOverflowTarget(sheet, row2, next)) break;
|
|
19823
21045
|
c = next;
|
|
@@ -20178,7 +21400,7 @@ var wholeColumns = (r) => r.start.row === 0 && r.end.row >= MAX_ROW;
|
|
|
20178
21400
|
var wholeRows = (r) => r.start.col === 0 && r.end.col >= MAX_COL;
|
|
20179
21401
|
function span3(from, to) {
|
|
20180
21402
|
const out = [];
|
|
20181
|
-
for (let
|
|
21403
|
+
for (let i2 = Math.min(from, to); i2 <= Math.max(from, to); i2++) out.push(i2);
|
|
20182
21404
|
return out;
|
|
20183
21405
|
}
|
|
20184
21406
|
function rowsOf(ranges) {
|
|
@@ -20560,12 +21782,12 @@ function alignmentCommands() {
|
|
|
20560
21782
|
run: (ctx) => {
|
|
20561
21783
|
const current = activeStyle(ctx)?.alignment?.indent ?? 0;
|
|
20562
21784
|
const next = Math.max(0, Math.min(250, current + delta));
|
|
20563
|
-
const
|
|
20564
|
-
const keep =
|
|
21785
|
+
const h2 = horizontal(ctx);
|
|
21786
|
+
const keep = h2 === "right" || h2 === "distributed" || h2 === "left";
|
|
20565
21787
|
style(ctx, {
|
|
20566
21788
|
alignment: {
|
|
20567
21789
|
indent: next || UNSET,
|
|
20568
|
-
horizontal: next ? keep ?
|
|
21790
|
+
horizontal: next ? keep ? h2 : "left" : h2 === "general" ? UNSET : h2
|
|
20569
21791
|
}
|
|
20570
21792
|
});
|
|
20571
21793
|
}
|
|
@@ -20591,8 +21813,24 @@ function alignmentCommands() {
|
|
|
20591
21813
|
];
|
|
20592
21814
|
}
|
|
20593
21815
|
|
|
20594
|
-
//
|
|
20595
|
-
|
|
21816
|
+
// i18n/locale.ts
|
|
21817
|
+
var DEFAULT_REJECTED_SUBTAGS = ["hant", "tw", "hk", "mo"];
|
|
21818
|
+
function normalizeLocale(input, supported, fallback, options = {}) {
|
|
21819
|
+
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
21820
|
+
const language = parts[0];
|
|
21821
|
+
if (!language) return fallback;
|
|
21822
|
+
const find2 = (tag) => supported.find((item) => item.toLowerCase() === tag);
|
|
21823
|
+
const exact = find2(parts.join("-"));
|
|
21824
|
+
if (exact) return exact;
|
|
21825
|
+
const base = find2(language);
|
|
21826
|
+
if (base) return base;
|
|
21827
|
+
const rejected = options.rejectedSubtags ?? DEFAULT_REJECTED_SUBTAGS;
|
|
21828
|
+
if (parts.slice(1).some((part) => rejected.includes(part))) return fallback;
|
|
21829
|
+
return supported.find((item) => item.toLowerCase().split("-")[0] === language && item.includes("-")) ?? fallback;
|
|
21830
|
+
}
|
|
21831
|
+
|
|
21832
|
+
// i18n/dictionary.ts
|
|
21833
|
+
function mergeMessageModules(modules) {
|
|
20596
21834
|
const merged = {};
|
|
20597
21835
|
for (const path of Object.keys(modules).sort()) {
|
|
20598
21836
|
const module = modules[path];
|
|
@@ -20607,6 +21845,29 @@ function mergeStringModules(modules) {
|
|
|
20607
21845
|
return merged;
|
|
20608
21846
|
}
|
|
20609
21847
|
|
|
21848
|
+
// i18n/translator.ts
|
|
21849
|
+
var SINGLE = /\{(\w+)\}/g;
|
|
21850
|
+
var DOUBLE = /\{\{\s*(\w+)\s*\}\}/g;
|
|
21851
|
+
function interpolate(template, params, placeholder = "single") {
|
|
21852
|
+
if (!params) return template;
|
|
21853
|
+
const pattern = placeholder === "double" ? DOUBLE : SINGLE;
|
|
21854
|
+
return template.replace(
|
|
21855
|
+
pattern,
|
|
21856
|
+
(match2, name) => Object.prototype.hasOwnProperty.call(params, name) && params[name] !== void 0 ? String(params[name]) : match2
|
|
21857
|
+
);
|
|
21858
|
+
}
|
|
21859
|
+
function createTranslator(messages, fallbacks = [], options = {}) {
|
|
21860
|
+
const placeholder = options.placeholder ?? "single";
|
|
21861
|
+
return (key, params) => {
|
|
21862
|
+
let text = messages?.[key];
|
|
21863
|
+
for (let i2 = 0; text === void 0 && i2 < fallbacks.length; i2++) text = fallbacks[i2]?.[key];
|
|
21864
|
+
return interpolate(text ?? options.missing?.(key) ?? key, params, placeholder);
|
|
21865
|
+
};
|
|
21866
|
+
}
|
|
21867
|
+
|
|
21868
|
+
// xlsx/ui/locales/merge.ts
|
|
21869
|
+
var mergeStringModules = mergeMessageModules;
|
|
21870
|
+
|
|
20610
21871
|
// xlsx/ui/locales/de/commands.ts
|
|
20611
21872
|
var commands_exports = {};
|
|
20612
21873
|
__export(commands_exports, {
|
|
@@ -26227,28 +27488,13 @@ var STRINGS = {
|
|
|
26227
27488
|
"zh-CN": zhCN
|
|
26228
27489
|
};
|
|
26229
27490
|
function normalizeEditorLocale(value2) {
|
|
26230
|
-
|
|
26231
|
-
switch (parts[0]) {
|
|
26232
|
-
case "fr":
|
|
26233
|
-
case "de":
|
|
26234
|
-
case "es":
|
|
26235
|
-
return parts[0];
|
|
26236
|
-
case "zh":
|
|
26237
|
-
return parts.some((part) => ["hant", "tw", "hk", "mo"].includes(part)) ? "en" : "zh-CN";
|
|
26238
|
-
default:
|
|
26239
|
-
return "en";
|
|
26240
|
-
}
|
|
27491
|
+
return normalizeLocale(value2, EDITOR_LOCALES, "en");
|
|
26241
27492
|
}
|
|
26242
27493
|
function fillTemplate(text, vars) {
|
|
26243
|
-
|
|
26244
|
-
return text.replace(
|
|
26245
|
-
/\{(\w+)\}/g,
|
|
26246
|
-
(match2, name) => name in vars ? String(vars[name]) : match2
|
|
26247
|
-
);
|
|
27494
|
+
return interpolate(text, vars);
|
|
26248
27495
|
}
|
|
26249
27496
|
function translate(locale, key, vars) {
|
|
26250
|
-
|
|
26251
|
-
return fillTemplate(text, vars);
|
|
27497
|
+
return createTranslator(STRINGS[locale], [STRINGS.en])(key, vars);
|
|
26252
27498
|
}
|
|
26253
27499
|
function translator(locale) {
|
|
26254
27500
|
return (key, vars) => translate(locale(), key, vars);
|
|
@@ -26401,7 +27647,7 @@ function cellCommands() {
|
|
|
26401
27647
|
const index2 = ctx.activeSheet();
|
|
26402
27648
|
session.deleteSheet(index2);
|
|
26403
27649
|
const next = session.workbook.sheets.findIndex(
|
|
26404
|
-
(s,
|
|
27650
|
+
(s, i2) => i2 >= Math.min(index2, session.workbook.sheets.length - 1) && s.state === "visible"
|
|
26405
27651
|
);
|
|
26406
27652
|
ctx.setActiveSheet(next >= 0 ? next : 0);
|
|
26407
27653
|
}
|
|
@@ -26627,9 +27873,9 @@ var ICON_SETS = [
|
|
|
26627
27873
|
];
|
|
26628
27874
|
var iconCount = (set) => Number(/^\d/.exec(set)?.[0] ?? 3);
|
|
26629
27875
|
function iconThresholds(count2) {
|
|
26630
|
-
return Array.from({ length: count2 }, (_v,
|
|
27876
|
+
return Array.from({ length: count2 }, (_v, i2) => ({
|
|
26631
27877
|
type: "percent",
|
|
26632
|
-
value: String(Math.round(
|
|
27878
|
+
value: String(Math.round(i2 * 100 / count2))
|
|
26633
27879
|
}));
|
|
26634
27880
|
}
|
|
26635
27881
|
function dataBarRule(hex2) {
|
|
@@ -27219,7 +28465,7 @@ function autoSum(ctx, fn) {
|
|
|
27219
28465
|
}
|
|
27220
28466
|
t.session.batch("AutoSum", () => {
|
|
27221
28467
|
const lastEmpty = [...Array(r.end.col - r.start.col + 1).keys()].every(
|
|
27222
|
-
(
|
|
28468
|
+
(i2) => getCell(t.ws, r.end.row, r.start.col + i2)?.value == null
|
|
27223
28469
|
);
|
|
27224
28470
|
const row2 = lastEmpty ? r.end.row : r.end.row + 1;
|
|
27225
28471
|
const bottom = lastEmpty ? r.end.row - 1 : r.end.row;
|
|
@@ -27412,7 +28658,7 @@ var FUNCTION_MENUS = [
|
|
|
27412
28658
|
["Math & Trig", "Math & Trig", "math"]
|
|
27413
28659
|
];
|
|
27414
28660
|
var MORE_FUNCTION_CATEGORIES = ["Statistical", "Engineering", "Information"];
|
|
27415
|
-
var functionsIn = (category) => FUNCTION_CATALOG.filter((
|
|
28661
|
+
var functionsIn = (category) => FUNCTION_CATALOG.filter((f6) => f6.category === category);
|
|
27416
28662
|
var recent = [
|
|
27417
28663
|
"SUM",
|
|
27418
28664
|
"AVERAGE",
|
|
@@ -27425,10 +28671,10 @@ var recent = [
|
|
|
27425
28671
|
"PMT",
|
|
27426
28672
|
"STDEV"
|
|
27427
28673
|
];
|
|
27428
|
-
var recentFunctions = () => recent.filter((name) => FUNCTION_CATALOG.some((
|
|
28674
|
+
var recentFunctions = () => recent.filter((name) => FUNCTION_CATALOG.some((f6) => f6.name === name));
|
|
27429
28675
|
function noteFunctionUse(name) {
|
|
27430
|
-
const
|
|
27431
|
-
if (
|
|
28676
|
+
const i2 = recent.indexOf(name);
|
|
28677
|
+
if (i2 >= 0) recent.splice(i2, 1);
|
|
27432
28678
|
recent.unshift(name);
|
|
27433
28679
|
recent.length = Math.min(recent.length, 10);
|
|
27434
28680
|
}
|
|
@@ -27467,7 +28713,7 @@ function formulaCommands() {
|
|
|
27467
28713
|
icon: icon("function"),
|
|
27468
28714
|
lock: false,
|
|
27469
28715
|
run: (ctx, arg) => {
|
|
27470
|
-
if (typeof arg === "string" && FUNCTION_CATALOG.some((
|
|
28716
|
+
if (typeof arg === "string" && FUNCTION_CATALOG.some((f6) => f6.name === arg))
|
|
27471
28717
|
insertFunctionCall(ctx, arg);
|
|
27472
28718
|
}
|
|
27473
28719
|
}),
|
|
@@ -27831,20 +29077,20 @@ function pageLayoutCommands() {
|
|
|
27831
29077
|
|
|
27832
29078
|
// xlsx/ui/commands/style-presets.ts
|
|
27833
29079
|
var TABLE_STYLES = [
|
|
27834
|
-
...Array.from({ length: 21 }, (_v,
|
|
27835
|
-
name: `TableStyleLight${
|
|
29080
|
+
...Array.from({ length: 21 }, (_v, i2) => ({
|
|
29081
|
+
name: `TableStyleLight${i2 + 1}`,
|
|
27836
29082
|
family: "Light",
|
|
27837
|
-
index:
|
|
29083
|
+
index: i2 + 1
|
|
27838
29084
|
})),
|
|
27839
|
-
...Array.from({ length: 28 }, (_v,
|
|
27840
|
-
name: `TableStyleMedium${
|
|
29085
|
+
...Array.from({ length: 28 }, (_v, i2) => ({
|
|
29086
|
+
name: `TableStyleMedium${i2 + 1}`,
|
|
27841
29087
|
family: "Medium",
|
|
27842
|
-
index:
|
|
29088
|
+
index: i2 + 1
|
|
27843
29089
|
})),
|
|
27844
|
-
...Array.from({ length: 11 }, (_v,
|
|
27845
|
-
name: `TableStyleDark${
|
|
29090
|
+
...Array.from({ length: 11 }, (_v, i2) => ({
|
|
29091
|
+
name: `TableStyleDark${i2 + 1}`,
|
|
27846
29092
|
family: "Dark",
|
|
27847
|
-
index:
|
|
29093
|
+
index: i2 + 1
|
|
27848
29094
|
}))
|
|
27849
29095
|
];
|
|
27850
29096
|
function tableStyleColor(info, theme2) {
|
|
@@ -28207,8 +29453,8 @@ function buildChart(workbook, sheetIndex2, range2, type, options = {}) {
|
|
|
28207
29453
|
return out;
|
|
28208
29454
|
};
|
|
28209
29455
|
const count2 = byRows ? r.end.row - dataRow0 + 1 : r.end.col - dataCol0 + 1;
|
|
28210
|
-
for (let
|
|
28211
|
-
const fixed2 = byRows ? dataRow0 +
|
|
29456
|
+
for (let i2 = 0; i2 < count2; i2++) {
|
|
29457
|
+
const fixed2 = byRows ? dataRow0 + i2 : dataCol0 + i2;
|
|
28212
29458
|
const values2 = byRows ? lane(fixed2, dataCol0, r.end.col, true) : lane(fixed2, dataRow0, r.end.row, false);
|
|
28213
29459
|
const s = {
|
|
28214
29460
|
valuesRef: prefix + absolute(values2),
|
|
@@ -28381,16 +29627,16 @@ function fillPaint(fill) {
|
|
|
28381
29627
|
}
|
|
28382
29628
|
var edgeCss = (edge) => edge ? `${edge.style === "double" ? Math.max(3, edge.widthPx) : edge.widthPx}px ${edge.style} ${edge.color}` : "";
|
|
28383
29629
|
var hasBorders = (b) => Boolean(b.top || b.right || b.bottom || b.left || b.diagonalUp || b.diagonalDown);
|
|
28384
|
-
function diagonalSvg(b, w,
|
|
29630
|
+
function diagonalSvg(b, w, h2) {
|
|
28385
29631
|
if (!b.diagonalUp && !b.diagonalDown) return void 0;
|
|
28386
29632
|
const line2 = (edge, x1, y1, x2, y2) => {
|
|
28387
29633
|
const dash = edge.style === "dashed" ? ' stroke-dasharray="4 2"' : edge.style === "dotted" ? ' stroke-dasharray="1 2"' : "";
|
|
28388
29634
|
return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${edge.color.replace(/[^#\w(),.%\s-]/gu, "")}" stroke-width="${Number(edge.widthPx)}"${dash}/>`;
|
|
28389
29635
|
};
|
|
28390
29636
|
let body2 = "";
|
|
28391
|
-
if (b.diagonalDown) body2 += line2(b.diagonalDown, 0, 0, w,
|
|
28392
|
-
if (b.diagonalUp) body2 += line2(b.diagonalUp, 0,
|
|
28393
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${Number(w)}" height="${Number(
|
|
29637
|
+
if (b.diagonalDown) body2 += line2(b.diagonalDown, 0, 0, w, h2);
|
|
29638
|
+
if (b.diagonalUp) body2 += line2(b.diagonalUp, 0, h2, w, 0);
|
|
29639
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${Number(w)}" height="${Number(h2)}" viewBox="0 0 ${Number(w)} ${Number(h2)}">${body2}</svg>`;
|
|
28394
29640
|
}
|
|
28395
29641
|
function justify(hAlign) {
|
|
28396
29642
|
if (hAlign === "right") return "flex-end";
|
|
@@ -28440,7 +29686,7 @@ function makeItem(input, row2, col, view, merge2) {
|
|
|
28440
29686
|
const x = metrics.colLeft(col);
|
|
28441
29687
|
const y = metrics.rowTop(row2);
|
|
28442
29688
|
const w = merge2 ? metrics.colLeft(merge2.end.col + 1) - x : metrics.colWidth(col);
|
|
28443
|
-
const
|
|
29689
|
+
const h2 = merge2 ? metrics.rowTop(merge2.end.row + 1) - y : metrics.rowHeight(row2);
|
|
28444
29690
|
const item = {
|
|
28445
29691
|
key: `${row2}:${col}`,
|
|
28446
29692
|
row: row2,
|
|
@@ -28448,7 +29694,7 @@ function makeItem(input, row2, col, view, merge2) {
|
|
|
28448
29694
|
x,
|
|
28449
29695
|
y,
|
|
28450
29696
|
w,
|
|
28451
|
-
h,
|
|
29697
|
+
h: h2,
|
|
28452
29698
|
view,
|
|
28453
29699
|
text: view.text,
|
|
28454
29700
|
textLeft: 0,
|
|
@@ -28699,8 +29945,8 @@ var GridGeometry = class {
|
|
|
28699
29945
|
const x = this.colX(range2.start.col);
|
|
28700
29946
|
const y = this.rowY(range2.start.row);
|
|
28701
29947
|
const w = this.metrics.colLeft(range2.end.col + 1) - this.metrics.colLeft(range2.start.col);
|
|
28702
|
-
const
|
|
28703
|
-
return { x, y, w, h };
|
|
29948
|
+
const h2 = this.metrics.rowTop(range2.end.row + 1) - this.metrics.rowTop(range2.start.row);
|
|
29949
|
+
return { x, y, w, h: h2 };
|
|
28704
29950
|
}
|
|
28705
29951
|
/** Column under a view x (clamped into the cell area). */
|
|
28706
29952
|
colAtX(x) {
|
|
@@ -28757,22 +30003,22 @@ function rowHeaderWidth(lastRow, zoom) {
|
|
|
28757
30003
|
return Math.round((Math.max(2, digits2) * 7 + 12) * (zoom / 100));
|
|
28758
30004
|
}
|
|
28759
30005
|
var columnHeaderHeight = (zoom) => Math.round(20 * (zoom / 100));
|
|
28760
|
-
function scrollToReveal(
|
|
28761
|
-
let { scrollLeft: left2, scrollTop: top } =
|
|
28762
|
-
const m =
|
|
28763
|
-
if (col >=
|
|
28764
|
-
const x = m.colLeft(col) -
|
|
30006
|
+
function scrollToReveal(g2, row2, col) {
|
|
30007
|
+
let { scrollLeft: left2, scrollTop: top } = g2;
|
|
30008
|
+
const m = g2.metrics;
|
|
30009
|
+
if (col >= g2.fCols) {
|
|
30010
|
+
const x = m.colLeft(col) - g2.frozenW;
|
|
28765
30011
|
const w = m.colWidth(col);
|
|
28766
|
-
const viewW = Math.max(0,
|
|
30012
|
+
const viewW = Math.max(0, g2.cellsW - g2.frozenW);
|
|
28767
30013
|
if (x < left2) left2 = x;
|
|
28768
30014
|
else if (x + w > left2 + viewW) left2 = Math.min(x, x + w - viewW);
|
|
28769
30015
|
}
|
|
28770
|
-
if (row2 >=
|
|
28771
|
-
const y = m.rowTop(row2) -
|
|
28772
|
-
const
|
|
28773
|
-
const viewH = Math.max(0,
|
|
30016
|
+
if (row2 >= g2.fRows) {
|
|
30017
|
+
const y = m.rowTop(row2) - g2.frozenH;
|
|
30018
|
+
const h2 = m.rowHeight(row2);
|
|
30019
|
+
const viewH = Math.max(0, g2.cellsH - g2.frozenH);
|
|
28774
30020
|
if (y < top) top = y;
|
|
28775
|
-
else if (y +
|
|
30021
|
+
else if (y + h2 > top + viewH) top = Math.min(y, y + h2 - viewH);
|
|
28776
30022
|
}
|
|
28777
30023
|
return { left: Math.max(0, left2), top: Math.max(0, top) };
|
|
28778
30024
|
}
|
|
@@ -28800,9 +30046,9 @@ var star = (fill) => {
|
|
|
28800
30046
|
};
|
|
28801
30047
|
var bars = (filled, total2) => {
|
|
28802
30048
|
let out = "";
|
|
28803
|
-
for (let
|
|
28804
|
-
const
|
|
28805
|
-
out += `<rect x="${1.5 +
|
|
30049
|
+
for (let i2 = 0; i2 < total2; i2++) {
|
|
30050
|
+
const h2 = 3 + i2 * 10 / Math.max(1, total2 - 1);
|
|
30051
|
+
out += `<rect x="${1.5 + i2 * (13 / total2)}" y="${14.5 - h2}" width="${13 / total2 - 1}" height="${h2}" fill="${i2 < filled ? "#2f6db5" : "#c8c8c8"}"/>`;
|
|
28806
30052
|
}
|
|
28807
30053
|
return out;
|
|
28808
30054
|
};
|
|
@@ -28816,10 +30062,10 @@ var quarters = (n) => {
|
|
|
28816
30062
|
};
|
|
28817
30063
|
var boxes = (n) => {
|
|
28818
30064
|
let out = "";
|
|
28819
|
-
for (let
|
|
28820
|
-
const x =
|
|
28821
|
-
const y =
|
|
28822
|
-
out += `<rect x="${x}" y="${y}" width="6" height="6" fill="${
|
|
30065
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
30066
|
+
const x = i2 % 2 ? 8.5 : 1.5;
|
|
30067
|
+
const y = i2 < 2 ? 1.5 : 8.5;
|
|
30068
|
+
out += `<rect x="${x}" y="${y}" width="6" height="6" fill="${i2 < n ? "#2f6db5" : "#d6d6d6"}"/>`;
|
|
28823
30069
|
}
|
|
28824
30070
|
return out;
|
|
28825
30071
|
};
|
|
@@ -29501,7 +30747,7 @@ function themePaletteItems(ctx) {
|
|
|
29501
30747
|
if (!theme2) return [];
|
|
29502
30748
|
const order = [1, 0, 3, 2, 4, 5, 6, 7, 8, 9];
|
|
29503
30749
|
const rects = order.map(
|
|
29504
|
-
(slot,
|
|
30750
|
+
(slot, i2) => `<rect x="${i2 * 6}" y="0" width="6" height="16" fill="${hex(theme2.colors[slot])}"><title>${THEME_SLOTS[slot] ?? ""}</title></rect>`
|
|
29505
30751
|
).join("");
|
|
29506
30752
|
return [
|
|
29507
30753
|
{
|
|
@@ -29515,8 +30761,8 @@ function themePaletteItems(ctx) {
|
|
|
29515
30761
|
// xlsx/ui/ribbon/tell-me.ts
|
|
29516
30762
|
var MAX_RESULTS = 8;
|
|
29517
30763
|
function searchCommands(ctx, query, isHidden) {
|
|
29518
|
-
const
|
|
29519
|
-
if (!
|
|
30764
|
+
const words2 = query.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
30765
|
+
if (!words2.length) return [];
|
|
29520
30766
|
const scored = [];
|
|
29521
30767
|
const seen = /* @__PURE__ */ new Set();
|
|
29522
30768
|
for (const command of ctx.commands.list()) {
|
|
@@ -29524,10 +30770,10 @@ function searchCommands(ctx, query, isHidden) {
|
|
|
29524
30770
|
const label2 = ctx.t(command.label).toLocaleLowerCase();
|
|
29525
30771
|
const english = command.label.toLocaleLowerCase();
|
|
29526
30772
|
const haystack = `${label2} ${english} ${command.id.replace(/[.-]/g, " ")}`;
|
|
29527
|
-
if (!
|
|
30773
|
+
if (!words2.every((word) => haystack.includes(word))) continue;
|
|
29528
30774
|
if (seen.has(label2)) continue;
|
|
29529
30775
|
seen.add(label2);
|
|
29530
|
-
const score = label2.startsWith(
|
|
30776
|
+
const score = label2.startsWith(words2[0]) ? 0 : label2.includes(words2[0]) ? 1 : 2;
|
|
29531
30777
|
scored.push({ command, score });
|
|
29532
30778
|
}
|
|
29533
30779
|
return scored.sort(
|