@ricsam/formula-engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/cjs/core/ast-traverser.cjs +124 -0
- package/dist/cjs/core/ast-traverser.cjs.map +10 -0
- package/dist/cjs/core/autofill-utils.cjs +304 -0
- package/dist/cjs/core/autofill-utils.cjs.map +10 -0
- package/dist/cjs/core/engine.cjs +390 -0
- package/dist/cjs/core/engine.cjs.map +10 -0
- package/dist/cjs/core/managers/cache-manager.cjs +58 -0
- package/dist/cjs/core/managers/cache-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/dependency-manager.cjs +620 -0
- package/dist/cjs/core/managers/dependency-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/dependency-node.cjs +24 -0
- package/dist/cjs/core/managers/dependency-node.cjs.map +9 -0
- package/dist/cjs/core/managers/evaluation-manager.cjs +433 -0
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/event-manager.cjs +49 -0
- package/dist/cjs/core/managers/event-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/frontier-dependency-manager.cjs +181 -0
- package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/index.cjs +49 -0
- package/dist/cjs/core/managers/index.cjs.map +10 -0
- package/dist/cjs/core/managers/isDependencyNode.cjs +44 -0
- package/dist/cjs/core/managers/isDependencyNode.cjs.map +10 -0
- package/dist/cjs/core/managers/named-expression-manager.cjs +379 -0
- package/dist/cjs/core/managers/named-expression-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/range-eval-order-builder.cjs +644 -0
- package/dist/cjs/core/managers/range-eval-order-builder.cjs.map +10 -0
- package/dist/cjs/core/managers/table-manager.cjs +254 -0
- package/dist/cjs/core/managers/table-manager.cjs.map +10 -0
- package/dist/cjs/core/managers/workbook-manager.cjs +474 -0
- package/dist/cjs/core/managers/workbook-manager.cjs.map +10 -0
- package/dist/cjs/core/map-serializer.cjs +69 -0
- package/dist/cjs/core/map-serializer.cjs.map +10 -0
- package/dist/cjs/core/named-expression-renamer.cjs +88 -0
- package/dist/cjs/core/named-expression-renamer.cjs.map +10 -0
- package/dist/cjs/core/sheet-renamer.cjs +89 -0
- package/dist/cjs/core/sheet-renamer.cjs.map +10 -0
- package/dist/cjs/core/sheet-utils.cjs +39 -0
- package/dist/cjs/core/sheet-utils.cjs.map +10 -0
- package/dist/cjs/core/table-renamer.cjs +88 -0
- package/dist/cjs/core/table-renamer.cjs.map +10 -0
- package/dist/cjs/core/types.cjs +48 -0
- package/dist/cjs/core/types.cjs.map +10 -0
- package/dist/cjs/core/utils/range-serializer.cjs +65 -0
- package/dist/cjs/core/utils/range-serializer.cjs.map +10 -0
- package/dist/cjs/core/utils/spreadsheet-visualizer.cjs +142 -0
- package/dist/cjs/core/utils/spreadsheet-visualizer.cjs.map +10 -0
- package/dist/cjs/core/utils.cjs +434 -0
- package/dist/cjs/core/utils.cjs.map +10 -0
- package/dist/cjs/core/workbook-renamer.cjs +106 -0
- package/dist/cjs/core/workbook-renamer.cjs.map +10 -0
- package/dist/cjs/debug/flags.cjs +47 -0
- package/dist/cjs/debug/flags.cjs.map +10 -0
- package/dist/cjs/evaluator/arithmetic/add/add.cjs +82 -0
- package/dist/cjs/evaluator/arithmetic/add/add.cjs.map +10 -0
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs +107 -0
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs.map +10 -0
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs +93 -0
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs.map +10 -0
- package/dist/cjs/evaluator/arithmetic/power/power.cjs +125 -0
- package/dist/cjs/evaluator/arithmetic/power/power.cjs.map +10 -0
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs +84 -0
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/equals.cjs +64 -0
- package/dist/cjs/evaluator/comparison/equals.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs +61 -0
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/greater-than.cjs +61 -0
- package/dist/cjs/evaluator/comparison/greater-than.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs +69 -0
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/less-than.cjs +68 -0
- package/dist/cjs/evaluator/comparison/less-than.cjs.map +10 -0
- package/dist/cjs/evaluator/comparison/not-equals.cjs +53 -0
- package/dist/cjs/evaluator/comparison/not-equals.cjs.map +10 -0
- package/dist/cjs/evaluator/concatenation/concatenate.cjs +72 -0
- package/dist/cjs/evaluator/concatenation/concatenate.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs +58 -0
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs +112 -0
- package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs +54 -0
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs +108 -0
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs +50 -0
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs.map +10 -0
- package/dist/cjs/evaluator/evaluate-scalar-operator.cjs +254 -0
- package/dist/cjs/evaluator/evaluate-scalar-operator.cjs.map +10 -0
- package/dist/cjs/evaluator/evaluation-context.cjs +154 -0
- package/dist/cjs/evaluator/evaluation-context.cjs.map +10 -0
- package/dist/cjs/evaluator/evaluation-error.cjs +75 -0
- package/dist/cjs/evaluator/evaluation-error.cjs.map +10 -0
- package/dist/cjs/evaluator/formula-evaluator.cjs +797 -0
- package/dist/cjs/evaluator/formula-evaluator.cjs.map +10 -0
- package/dist/cjs/evaluator/range-evaluation-node.cjs +88 -0
- package/dist/cjs/evaluator/range-evaluation-node.cjs.map +10 -0
- package/dist/cjs/functions/_template/template.cjs +42 -0
- package/dist/cjs/functions/_template/template.cjs.map +10 -0
- package/dist/cjs/functions/array/sequence/sequence.cjs +315 -0
- package/dist/cjs/functions/array/sequence/sequence.cjs.map +10 -0
- package/dist/cjs/functions/criteria-parser.cjs +217 -0
- package/dist/cjs/functions/criteria-parser.cjs.map +10 -0
- package/dist/cjs/functions/criteria-utils.cjs +291 -0
- package/dist/cjs/functions/criteria-utils.cjs.map +10 -0
- package/dist/cjs/functions/function-utils.cjs +63 -0
- package/dist/cjs/functions/function-utils.cjs.map +10 -0
- package/dist/cjs/functions/index.cjs +125 -0
- package/dist/cjs/functions/index.cjs.map +10 -0
- package/dist/cjs/functions/information/cell/cell.cjs +196 -0
- package/dist/cjs/functions/information/cell/cell.cjs.map +10 -0
- package/dist/cjs/functions/information/column/column.cjs +144 -0
- package/dist/cjs/functions/information/column/column.cjs.map +10 -0
- package/dist/cjs/functions/information/row/row.cjs +150 -0
- package/dist/cjs/functions/information/row/row.cjs.map +10 -0
- package/dist/cjs/functions/logical/and/and.cjs +112 -0
- package/dist/cjs/functions/logical/and/and.cjs.map +10 -0
- package/dist/cjs/functions/logical/if/if.cjs +195 -0
- package/dist/cjs/functions/logical/if/if.cjs.map +10 -0
- package/dist/cjs/functions/logical/iferror/iferror.cjs +126 -0
- package/dist/cjs/functions/logical/iferror/iferror.cjs.map +10 -0
- package/dist/cjs/functions/logical/or/or.cjs +112 -0
- package/dist/cjs/functions/logical/or/or.cjs.map +10 -0
- package/dist/cjs/functions/lookup/count/count-utils.cjs +65 -0
- package/dist/cjs/functions/lookup/count/count-utils.cjs.map +10 -0
- package/dist/cjs/functions/lookup/count/count.cjs +48 -0
- package/dist/cjs/functions/lookup/count/count.cjs.map +10 -0
- package/dist/cjs/functions/lookup/count/countif.cjs +94 -0
- package/dist/cjs/functions/lookup/count/countif.cjs.map +10 -0
- package/dist/cjs/functions/lookup/count/countifs.cjs +63 -0
- package/dist/cjs/functions/lookup/count/countifs.cjs.map +10 -0
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs +187 -0
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs.map +10 -0
- package/dist/cjs/functions/lookup/match/match.cjs +168 -0
- package/dist/cjs/functions/lookup/match/match.cjs.map +10 -0
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs +410 -0
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs.map +10 -0
- package/dist/cjs/functions/math/average/average-utils.cjs +72 -0
- package/dist/cjs/functions/math/average/average-utils.cjs.map +10 -0
- package/dist/cjs/functions/math/average/average.cjs +48 -0
- package/dist/cjs/functions/math/average/average.cjs.map +10 -0
- package/dist/cjs/functions/math/average/averageif.cjs +83 -0
- package/dist/cjs/functions/math/average/averageif.cjs.map +10 -0
- package/dist/cjs/functions/math/average/averageifs.cjs +61 -0
- package/dist/cjs/functions/math/average/averageifs.cjs.map +10 -0
- package/dist/cjs/functions/math/ceiling/ceiling.cjs +219 -0
- package/dist/cjs/functions/math/ceiling/ceiling.cjs.map +10 -0
- package/dist/cjs/functions/math/max/max-utils.cjs +71 -0
- package/dist/cjs/functions/math/max/max-utils.cjs.map +10 -0
- package/dist/cjs/functions/math/max/max.cjs +48 -0
- package/dist/cjs/functions/math/max/max.cjs.map +10 -0
- package/dist/cjs/functions/math/max/maxif.cjs +83 -0
- package/dist/cjs/functions/math/max/maxif.cjs.map +10 -0
- package/dist/cjs/functions/math/max/maxifs.cjs +61 -0
- package/dist/cjs/functions/math/max/maxifs.cjs.map +10 -0
- package/dist/cjs/functions/math/min/min-utils.cjs +71 -0
- package/dist/cjs/functions/math/min/min-utils.cjs.map +10 -0
- package/dist/cjs/functions/math/min/min.cjs +48 -0
- package/dist/cjs/functions/math/min/min.cjs.map +10 -0
- package/dist/cjs/functions/math/min/minif.cjs +83 -0
- package/dist/cjs/functions/math/min/minif.cjs.map +10 -0
- package/dist/cjs/functions/math/min/minifs.cjs +61 -0
- package/dist/cjs/functions/math/min/minifs.cjs.map +10 -0
- package/dist/cjs/functions/math/sum/sum.cjs +48 -0
- package/dist/cjs/functions/math/sum/sum.cjs.map +10 -0
- package/dist/cjs/functions/math/sum/sumif.cjs +83 -0
- package/dist/cjs/functions/math/sum/sumif.cjs.map +10 -0
- package/dist/cjs/functions/math/sum/sumifs.cjs +60 -0
- package/dist/cjs/functions/math/sum/sumifs.cjs.map +10 -0
- package/dist/cjs/functions/math/sum/summation-utils.cjs +57 -0
- package/dist/cjs/functions/math/sum/summation-utils.cjs.map +10 -0
- package/dist/cjs/functions/reference/address/address.cjs +163 -0
- package/dist/cjs/functions/reference/address/address.cjs.map +10 -0
- package/dist/cjs/functions/reference/indirect/indirect.cjs +102 -0
- package/dist/cjs/functions/reference/indirect/indirect.cjs.map +10 -0
- package/dist/cjs/functions/reference/offset/offset.cjs +233 -0
- package/dist/cjs/functions/reference/offset/offset.cjs.map +10 -0
- package/dist/cjs/functions/text/concatenate/concatenate.cjs +167 -0
- package/dist/cjs/functions/text/concatenate/concatenate.cjs.map +10 -0
- package/dist/cjs/functions/text/exact/exact.cjs +171 -0
- package/dist/cjs/functions/text/exact/exact.cjs.map +10 -0
- package/dist/cjs/functions/text/find/find.cjs +397 -0
- package/dist/cjs/functions/text/find/find.cjs.map +10 -0
- package/dist/cjs/functions/text/left/left.cjs +109 -0
- package/dist/cjs/functions/text/left/left.cjs.map +10 -0
- package/dist/cjs/functions/text/len/len.cjs +119 -0
- package/dist/cjs/functions/text/len/len.cjs.map +10 -0
- package/dist/cjs/functions/text/mid/mid.cjs +103 -0
- package/dist/cjs/functions/text/mid/mid.cjs.map +10 -0
- package/dist/cjs/functions/text/right/right.cjs +167 -0
- package/dist/cjs/functions/text/right/right.cjs.map +10 -0
- package/dist/cjs/functions/text/text-helpers.cjs +179 -0
- package/dist/cjs/functions/text/text-helpers.cjs.map +10 -0
- package/dist/cjs/functions/text/textjoin/textjoin.cjs +173 -0
- package/dist/cjs/functions/text/textjoin/textjoin.cjs.map +10 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/parser/ast.cjs +175 -0
- package/dist/cjs/parser/ast.cjs.map +10 -0
- package/dist/cjs/parser/formatter.cjs +319 -0
- package/dist/cjs/parser/formatter.cjs.map +10 -0
- package/dist/cjs/parser/grammar.cjs +375 -0
- package/dist/cjs/parser/grammar.cjs.map +10 -0
- package/dist/cjs/parser/lexer.cjs +443 -0
- package/dist/cjs/parser/lexer.cjs.map +10 -0
- package/dist/cjs/parser/parser.cjs +1700 -0
- package/dist/cjs/parser/parser.cjs.map +10 -0
- package/dist/cjs/react/hooks.cjs +59 -0
- package/dist/cjs/react/hooks.cjs.map +10 -0
- package/dist/mjs/core/ast-traverser.mjs +94 -0
- package/dist/mjs/core/ast-traverser.mjs.map +10 -0
- package/dist/mjs/core/autofill-utils.mjs +274 -0
- package/dist/mjs/core/autofill-utils.mjs.map +10 -0
- package/dist/mjs/core/engine.mjs +366 -0
- package/dist/mjs/core/engine.mjs.map +10 -0
- package/dist/mjs/core/managers/cache-manager.mjs +27 -0
- package/dist/mjs/core/managers/cache-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/dependency-manager.mjs +593 -0
- package/dist/mjs/core/managers/dependency-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/dependency-node.mjs +2 -0
- package/dist/mjs/core/managers/dependency-node.mjs.map +9 -0
- package/dist/mjs/core/managers/evaluation-manager.mjs +415 -0
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/event-manager.mjs +18 -0
- package/dist/mjs/core/managers/event-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/frontier-dependency-manager.mjs +151 -0
- package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/index.mjs +21 -0
- package/dist/mjs/core/managers/index.mjs.map +10 -0
- package/dist/mjs/core/managers/isDependencyNode.mjs +14 -0
- package/dist/mjs/core/managers/isDependencyNode.mjs.map +10 -0
- package/dist/mjs/core/managers/named-expression-manager.mjs +348 -0
- package/dist/mjs/core/managers/named-expression-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/range-eval-order-builder.mjs +618 -0
- package/dist/mjs/core/managers/range-eval-order-builder.mjs.map +10 -0
- package/dist/mjs/core/managers/table-manager.mjs +224 -0
- package/dist/mjs/core/managers/table-manager.mjs.map +10 -0
- package/dist/mjs/core/managers/workbook-manager.mjs +447 -0
- package/dist/mjs/core/managers/workbook-manager.mjs.map +10 -0
- package/dist/mjs/core/map-serializer.mjs +39 -0
- package/dist/mjs/core/map-serializer.mjs.map +10 -0
- package/dist/mjs/core/named-expression-renamer.mjs +58 -0
- package/dist/mjs/core/named-expression-renamer.mjs.map +10 -0
- package/dist/mjs/core/sheet-renamer.mjs +59 -0
- package/dist/mjs/core/sheet-renamer.mjs.map +10 -0
- package/dist/mjs/core/sheet-utils.mjs +8 -0
- package/dist/mjs/core/sheet-utils.mjs.map +10 -0
- package/dist/mjs/core/table-renamer.mjs +58 -0
- package/dist/mjs/core/table-renamer.mjs.map +10 -0
- package/dist/mjs/core/types.mjs +18 -0
- package/dist/mjs/core/types.mjs.map +10 -0
- package/dist/mjs/core/utils/range-serializer.mjs +35 -0
- package/dist/mjs/core/utils/range-serializer.mjs.map +10 -0
- package/dist/mjs/core/utils/spreadsheet-visualizer.mjs +112 -0
- package/dist/mjs/core/utils/spreadsheet-visualizer.mjs.map +10 -0
- package/dist/mjs/core/utils.mjs +409 -0
- package/dist/mjs/core/utils.mjs.map +10 -0
- package/dist/mjs/core/workbook-renamer.mjs +76 -0
- package/dist/mjs/core/workbook-renamer.mjs.map +10 -0
- package/dist/mjs/debug/flags.mjs +17 -0
- package/dist/mjs/debug/flags.mjs.map +10 -0
- package/dist/mjs/evaluator/arithmetic/add/add.mjs +52 -0
- package/dist/mjs/evaluator/arithmetic/add/add.mjs.map +10 -0
- package/dist/mjs/evaluator/arithmetic/divide/divide.mjs +77 -0
- package/dist/mjs/evaluator/arithmetic/divide/divide.mjs.map +10 -0
- package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs +63 -0
- package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs.map +10 -0
- package/dist/mjs/evaluator/arithmetic/power/power.mjs +95 -0
- package/dist/mjs/evaluator/arithmetic/power/power.mjs.map +10 -0
- package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs +54 -0
- package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/equals.mjs +34 -0
- package/dist/mjs/evaluator/comparison/equals.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs +31 -0
- package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/greater-than.mjs +31 -0
- package/dist/mjs/evaluator/comparison/greater-than.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs +39 -0
- package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/less-than.mjs +38 -0
- package/dist/mjs/evaluator/comparison/less-than.mjs.map +10 -0
- package/dist/mjs/evaluator/comparison/not-equals.mjs +23 -0
- package/dist/mjs/evaluator/comparison/not-equals.mjs.map +10 -0
- package/dist/mjs/evaluator/concatenation/concatenate.mjs +42 -0
- package/dist/mjs/evaluator/concatenation/concatenate.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs +28 -0
- package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs +81 -0
- package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs +24 -0
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs +78 -0
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs +20 -0
- package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs.map +10 -0
- package/dist/mjs/evaluator/evaluate-scalar-operator.mjs +226 -0
- package/dist/mjs/evaluator/evaluate-scalar-operator.mjs.map +10 -0
- package/dist/mjs/evaluator/evaluation-context.mjs +123 -0
- package/dist/mjs/evaluator/evaluation-context.mjs.map +10 -0
- package/dist/mjs/evaluator/evaluation-error.mjs +44 -0
- package/dist/mjs/evaluator/evaluation-error.mjs.map +10 -0
- package/dist/mjs/evaluator/formula-evaluator.mjs +780 -0
- package/dist/mjs/evaluator/formula-evaluator.mjs.map +10 -0
- package/dist/mjs/evaluator/range-evaluation-node.mjs +58 -0
- package/dist/mjs/evaluator/range-evaluation-node.mjs.map +10 -0
- package/dist/mjs/functions/_template/template.mjs +12 -0
- package/dist/mjs/functions/_template/template.mjs.map +10 -0
- package/dist/mjs/functions/array/sequence/sequence.mjs +287 -0
- package/dist/mjs/functions/array/sequence/sequence.mjs.map +10 -0
- package/dist/mjs/functions/criteria-parser.mjs +187 -0
- package/dist/mjs/functions/criteria-parser.mjs.map +10 -0
- package/dist/mjs/functions/criteria-utils.mjs +268 -0
- package/dist/mjs/functions/criteria-utils.mjs.map +10 -0
- package/dist/mjs/functions/function-utils.mjs +33 -0
- package/dist/mjs/functions/function-utils.mjs.map +10 -0
- package/dist/mjs/functions/index.mjs +95 -0
- package/dist/mjs/functions/index.mjs.map +10 -0
- package/dist/mjs/functions/information/cell/cell.mjs +168 -0
- package/dist/mjs/functions/information/cell/cell.mjs.map +10 -0
- package/dist/mjs/functions/information/column/column.mjs +120 -0
- package/dist/mjs/functions/information/column/column.mjs.map +10 -0
- package/dist/mjs/functions/information/row/row.mjs +126 -0
- package/dist/mjs/functions/information/row/row.mjs.map +10 -0
- package/dist/mjs/functions/logical/and/and.mjs +84 -0
- package/dist/mjs/functions/logical/and/and.mjs.map +10 -0
- package/dist/mjs/functions/logical/if/if.mjs +167 -0
- package/dist/mjs/functions/logical/if/if.mjs.map +10 -0
- package/dist/mjs/functions/logical/iferror/iferror.mjs +98 -0
- package/dist/mjs/functions/logical/iferror/iferror.mjs.map +10 -0
- package/dist/mjs/functions/logical/or/or.mjs +84 -0
- package/dist/mjs/functions/logical/or/or.mjs.map +10 -0
- package/dist/mjs/functions/lookup/count/count-utils.mjs +35 -0
- package/dist/mjs/functions/lookup/count/count-utils.mjs.map +10 -0
- package/dist/mjs/functions/lookup/count/count.mjs +18 -0
- package/dist/mjs/functions/lookup/count/count.mjs.map +10 -0
- package/dist/mjs/functions/lookup/count/countif.mjs +68 -0
- package/dist/mjs/functions/lookup/count/countif.mjs.map +10 -0
- package/dist/mjs/functions/lookup/count/countifs.mjs +37 -0
- package/dist/mjs/functions/lookup/count/countifs.mjs.map +10 -0
- package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs +159 -0
- package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs.map +10 -0
- package/dist/mjs/functions/lookup/match/match.mjs +140 -0
- package/dist/mjs/functions/lookup/match/match.mjs.map +10 -0
- package/dist/mjs/functions/lookup/xlookup/xlookup.mjs +382 -0
- package/dist/mjs/functions/lookup/xlookup/xlookup.mjs.map +10 -0
- package/dist/mjs/functions/math/average/average-utils.mjs +44 -0
- package/dist/mjs/functions/math/average/average-utils.mjs.map +10 -0
- package/dist/mjs/functions/math/average/average.mjs +18 -0
- package/dist/mjs/functions/math/average/average.mjs.map +10 -0
- package/dist/mjs/functions/math/average/averageif.mjs +58 -0
- package/dist/mjs/functions/math/average/averageif.mjs.map +10 -0
- package/dist/mjs/functions/math/average/averageifs.mjs +35 -0
- package/dist/mjs/functions/math/average/averageifs.mjs.map +10 -0
- package/dist/mjs/functions/math/ceiling/ceiling.mjs +191 -0
- package/dist/mjs/functions/math/ceiling/ceiling.mjs.map +10 -0
- package/dist/mjs/functions/math/max/max-utils.mjs +43 -0
- package/dist/mjs/functions/math/max/max-utils.mjs.map +10 -0
- package/dist/mjs/functions/math/max/max.mjs +18 -0
- package/dist/mjs/functions/math/max/max.mjs.map +10 -0
- package/dist/mjs/functions/math/max/maxif.mjs +58 -0
- package/dist/mjs/functions/math/max/maxif.mjs.map +10 -0
- package/dist/mjs/functions/math/max/maxifs.mjs +35 -0
- package/dist/mjs/functions/math/max/maxifs.mjs.map +10 -0
- package/dist/mjs/functions/math/min/min-utils.mjs +43 -0
- package/dist/mjs/functions/math/min/min-utils.mjs.map +10 -0
- package/dist/mjs/functions/math/min/min.mjs +18 -0
- package/dist/mjs/functions/math/min/min.mjs.map +10 -0
- package/dist/mjs/functions/math/min/minif.mjs +58 -0
- package/dist/mjs/functions/math/min/minif.mjs.map +10 -0
- package/dist/mjs/functions/math/min/minifs.mjs +35 -0
- package/dist/mjs/functions/math/min/minifs.mjs.map +10 -0
- package/dist/mjs/functions/math/sum/sum.mjs +18 -0
- package/dist/mjs/functions/math/sum/sum.mjs.map +10 -0
- package/dist/mjs/functions/math/sum/sumif.mjs +58 -0
- package/dist/mjs/functions/math/sum/sumif.mjs.map +10 -0
- package/dist/mjs/functions/math/sum/sumifs.mjs +34 -0
- package/dist/mjs/functions/math/sum/sumifs.mjs.map +10 -0
- package/dist/mjs/functions/math/sum/summation-utils.mjs +27 -0
- package/dist/mjs/functions/math/sum/summation-utils.mjs.map +10 -0
- package/dist/mjs/functions/reference/address/address.mjs +135 -0
- package/dist/mjs/functions/reference/address/address.mjs.map +10 -0
- package/dist/mjs/functions/reference/indirect/indirect.mjs +74 -0
- package/dist/mjs/functions/reference/indirect/indirect.mjs.map +10 -0
- package/dist/mjs/functions/reference/offset/offset.mjs +205 -0
- package/dist/mjs/functions/reference/offset/offset.mjs.map +10 -0
- package/dist/mjs/functions/text/concatenate/concatenate.mjs +139 -0
- package/dist/mjs/functions/text/concatenate/concatenate.mjs.map +10 -0
- package/dist/mjs/functions/text/exact/exact.mjs +143 -0
- package/dist/mjs/functions/text/exact/exact.mjs.map +10 -0
- package/dist/mjs/functions/text/find/find.mjs +369 -0
- package/dist/mjs/functions/text/find/find.mjs.map +10 -0
- package/dist/mjs/functions/text/left/left.mjs +81 -0
- package/dist/mjs/functions/text/left/left.mjs.map +10 -0
- package/dist/mjs/functions/text/len/len.mjs +91 -0
- package/dist/mjs/functions/text/len/len.mjs.map +10 -0
- package/dist/mjs/functions/text/mid/mid.mjs +75 -0
- package/dist/mjs/functions/text/mid/mid.mjs.map +10 -0
- package/dist/mjs/functions/text/right/right.mjs +143 -0
- package/dist/mjs/functions/text/right/right.mjs.map +10 -0
- package/dist/mjs/functions/text/text-helpers.mjs +151 -0
- package/dist/mjs/functions/text/text-helpers.mjs.map +10 -0
- package/dist/mjs/functions/text/textjoin/textjoin.mjs +145 -0
- package/dist/mjs/functions/text/textjoin/textjoin.mjs.map +10 -0
- package/dist/mjs/package.json +5 -0
- package/dist/mjs/parser/ast.mjs +145 -0
- package/dist/mjs/parser/ast.mjs.map +10 -0
- package/dist/mjs/parser/formatter.mjs +289 -0
- package/dist/mjs/parser/formatter.mjs.map +10 -0
- package/dist/mjs/parser/grammar.mjs +345 -0
- package/dist/mjs/parser/grammar.mjs.map +10 -0
- package/dist/mjs/parser/lexer.mjs +412 -0
- package/dist/mjs/parser/lexer.mjs.map +10 -0
- package/dist/mjs/parser/parser.mjs +1692 -0
- package/dist/mjs/parser/parser.mjs.map +10 -0
- package/dist/mjs/react/hooks.mjs +16 -0
- package/dist/mjs/react/hooks.mjs.map +10 -0
- package/dist/types/core/ast-traverser.d.ts +28 -0
- package/dist/types/core/autofill-utils.d.ts +32 -0
- package/dist/types/core/engine.d.ts +184 -0
- package/dist/types/core/managers/cache-manager.d.ts +14 -0
- package/dist/types/core/managers/dependency-manager.d.ts +147 -0
- package/dist/types/core/managers/dependency-node.d.ts +13 -0
- package/dist/types/core/managers/evaluation-manager.d.ts +30 -0
- package/dist/types/core/managers/event-manager.d.ts +8 -0
- package/dist/types/core/managers/frontier-dependency-manager.d.ts +69 -0
- package/dist/types/core/managers/index.d.ts +7 -0
- package/dist/types/core/managers/isDependencyNode.d.ts +2 -0
- package/dist/types/core/managers/named-expression-manager.d.ts +101 -0
- package/dist/types/core/managers/range-eval-order-builder.d.ts +33 -0
- package/dist/types/core/managers/table-manager.d.ts +84 -0
- package/dist/types/core/managers/workbook-manager.d.ts +136 -0
- package/dist/types/core/map-serializer.d.ts +4 -0
- package/dist/types/core/named-expression-renamer.d.ts +21 -0
- package/dist/types/core/sheet-renamer.d.ts +28 -0
- package/dist/types/core/sheet-utils.d.ts +2 -0
- package/dist/types/core/table-renamer.d.ts +21 -0
- package/dist/types/core/types.d.ts +272 -0
- package/dist/types/core/utils/cell-address-parsing.test.d.ts +1 -0
- package/dist/types/core/utils/range-serializer.d.ts +22 -0
- package/dist/types/core/utils/range-serializer.test.d.ts +1 -0
- package/dist/types/core/utils/spreadsheet-visualizer.d.ts +30 -0
- package/dist/types/core/utils.d.ts +48 -0
- package/dist/types/core/workbook-renamer.d.ts +28 -0
- package/dist/types/debug/flags.d.ts +11 -0
- package/dist/types/evaluator/arithmetic/add/add.d.ts +2 -0
- package/dist/types/evaluator/arithmetic/add/add.test.d.ts +1 -0
- package/dist/types/evaluator/arithmetic/divide/divide.d.ts +2 -0
- package/dist/types/evaluator/arithmetic/divide/divide.test.d.ts +1 -0
- package/dist/types/evaluator/arithmetic/multiply/multiply.d.ts +2 -0
- package/dist/types/evaluator/arithmetic/multiply/multiply.test.d.ts +1 -0
- package/dist/types/evaluator/arithmetic/power/power.d.ts +2 -0
- package/dist/types/evaluator/arithmetic/power/power.test.d.ts +1 -0
- package/dist/types/evaluator/arithmetic/subtract/subtract.d.ts +2 -0
- package/dist/types/evaluator/arithmetic/subtract/subtract.test.d.ts +1 -0
- package/dist/types/evaluator/comparison/comparison-operators.test.d.ts +1 -0
- package/dist/types/evaluator/comparison/equals.d.ts +6 -0
- package/dist/types/evaluator/comparison/greater-than-or-equal.d.ts +6 -0
- package/dist/types/evaluator/comparison/greater-than.d.ts +6 -0
- package/dist/types/evaluator/comparison/less-than-or-equal.d.ts +6 -0
- package/dist/types/evaluator/comparison/less-than.d.ts +6 -0
- package/dist/types/evaluator/comparison/not-equals.d.ts +6 -0
- package/dist/types/evaluator/concatenation/concatenate.d.ts +6 -0
- package/dist/types/evaluator/concatenation/concatenate.test.d.ts +1 -0
- package/dist/types/evaluator/dependency-nodes/ast-evaluation-node.d.ts +12 -0
- package/dist/types/evaluator/dependency-nodes/base-eval-node.d.ts +31 -0
- package/dist/types/evaluator/dependency-nodes/cell-value-node.d.ts +10 -0
- package/dist/types/evaluator/dependency-nodes/empty-cell-evaluation-node.d.ts +17 -0
- package/dist/types/evaluator/dependency-nodes/spill-meta-node.d.ts +7 -0
- package/dist/types/evaluator/evaluate-scalar-operator.d.ts +12 -0
- package/dist/types/evaluator/evaluation-context.d.ts +66 -0
- package/dist/types/evaluator/evaluation-error.d.ts +20 -0
- package/dist/types/evaluator/formula-evaluator.d.ts +67 -0
- package/dist/types/evaluator/open-range-evaluator.test.d.ts +1 -0
- package/dist/types/evaluator/range-evaluation-node.d.ts +16 -0
- package/dist/types/functions/_template/template.d.ts +5 -0
- package/dist/types/functions/_template/template.test.d.ts +1 -0
- package/dist/types/functions/array/sequence/performance-test.d.ts +1 -0
- package/dist/types/functions/array/sequence/sequence.d.ts +14 -0
- package/dist/types/functions/array/sequence/sequence.test.d.ts +1 -0
- package/dist/types/functions/criteria-parser.d.ts +27 -0
- package/dist/types/functions/criteria-utils.d.ts +61 -0
- package/dist/types/functions/function-utils.d.ts +21 -0
- package/dist/types/functions/index.d.ts +2 -0
- package/dist/types/functions/information/cell/cell.d.ts +24 -0
- package/dist/types/functions/information/cell/cell.test.d.ts +1 -0
- package/dist/types/functions/information/column/column.d.ts +14 -0
- package/dist/types/functions/information/column/column.test.d.ts +1 -0
- package/dist/types/functions/information/row/row.d.ts +14 -0
- package/dist/types/functions/information/row/row.test.d.ts +1 -0
- package/dist/types/functions/logical/and/and.d.ts +5 -0
- package/dist/types/functions/logical/and/and.test.d.ts +1 -0
- package/dist/types/functions/logical/if/if.d.ts +5 -0
- package/dist/types/functions/logical/if/if.test.d.ts +1 -0
- package/dist/types/functions/logical/iferror/iferror.d.ts +5 -0
- package/dist/types/functions/logical/iferror/iferror.test.d.ts +1 -0
- package/dist/types/functions/logical/or/or.d.ts +5 -0
- package/dist/types/functions/logical/or/or.test.d.ts +1 -0
- package/dist/types/functions/lookup/count/count-utils.d.ts +14 -0
- package/dist/types/functions/lookup/count/count.d.ts +21 -0
- package/dist/types/functions/lookup/count/count.test.d.ts +1 -0
- package/dist/types/functions/lookup/count/countif.d.ts +26 -0
- package/dist/types/functions/lookup/count/countif.test.d.ts +1 -0
- package/dist/types/functions/lookup/count/countifs.d.ts +21 -0
- package/dist/types/functions/lookup/count/countifs.test.d.ts +1 -0
- package/dist/types/functions/lookup/index-lookup/index-lookup.d.ts +2 -0
- package/dist/types/functions/lookup/index-lookup/index-lookup.test.d.ts +1 -0
- package/dist/types/functions/lookup/match/match.d.ts +2 -0
- package/dist/types/functions/lookup/match/match.test.d.ts +1 -0
- package/dist/types/functions/lookup/xlookup/xlookup.d.ts +2 -0
- package/dist/types/functions/lookup/xlookup/xlookup.test.d.ts +1 -0
- package/dist/types/functions/math/average/average-utils.d.ts +10 -0
- package/dist/types/functions/math/average/average.d.ts +18 -0
- package/dist/types/functions/math/average/average.test.d.ts +1 -0
- package/dist/types/functions/math/average/averageif.d.ts +23 -0
- package/dist/types/functions/math/average/averageif.test.d.ts +1 -0
- package/dist/types/functions/math/average/averageifs.d.ts +21 -0
- package/dist/types/functions/math/average/averageifs.test.d.ts +1 -0
- package/dist/types/functions/math/ceiling/ceiling.d.ts +5 -0
- package/dist/types/functions/math/ceiling/ceiling.test.d.ts +1 -0
- package/dist/types/functions/math/max/max-utils.d.ts +20 -0
- package/dist/types/functions/math/max/max.d.ts +18 -0
- package/dist/types/functions/math/max/max.test.d.ts +1 -0
- package/dist/types/functions/math/max/maxif.d.ts +23 -0
- package/dist/types/functions/math/max/maxif.test.d.ts +1 -0
- package/dist/types/functions/math/max/maxifs.d.ts +21 -0
- package/dist/types/functions/math/max/maxifs.test.d.ts +1 -0
- package/dist/types/functions/math/min/min-utils.d.ts +20 -0
- package/dist/types/functions/math/min/min.d.ts +5 -0
- package/dist/types/functions/math/min/min.test.d.ts +1 -0
- package/dist/types/functions/math/min/minif.d.ts +23 -0
- package/dist/types/functions/math/min/minif.test.d.ts +1 -0
- package/dist/types/functions/math/min/minifs.d.ts +21 -0
- package/dist/types/functions/math/min/minifs.test.d.ts +1 -0
- package/dist/types/functions/math/sum/sum.d.ts +5 -0
- package/dist/types/functions/math/sum/sum.test.d.ts +1 -0
- package/dist/types/functions/math/sum/sumif.d.ts +23 -0
- package/dist/types/functions/math/sum/sumif.test.d.ts +1 -0
- package/dist/types/functions/math/sum/sumifs.d.ts +21 -0
- package/dist/types/functions/math/sum/sumifs.test.d.ts +1 -0
- package/dist/types/functions/math/sum/summation-utils.d.ts +19 -0
- package/dist/types/functions/reference/address/address.d.ts +18 -0
- package/dist/types/functions/reference/address/address.test.d.ts +1 -0
- package/dist/types/functions/reference/indirect/indirect.d.ts +20 -0
- package/dist/types/functions/reference/indirect/indirect.test.d.ts +1 -0
- package/dist/types/functions/reference/offset/offset.d.ts +23 -0
- package/dist/types/functions/reference/offset/offset.test.d.ts +1 -0
- package/dist/types/functions/text/concatenate/concatenate.d.ts +5 -0
- package/dist/types/functions/text/concatenate/concatenate.test.d.ts +1 -0
- package/dist/types/functions/text/exact/exact.d.ts +5 -0
- package/dist/types/functions/text/exact/exact.test.d.ts +1 -0
- package/dist/types/functions/text/find/find.d.ts +20 -0
- package/dist/types/functions/text/find/find.test.d.ts +1 -0
- package/dist/types/functions/text/left/left.d.ts +19 -0
- package/dist/types/functions/text/left/left.test.d.ts +1 -0
- package/dist/types/functions/text/len/len.d.ts +16 -0
- package/dist/types/functions/text/len/len.test.d.ts +1 -0
- package/dist/types/functions/text/mid/mid.d.ts +20 -0
- package/dist/types/functions/text/mid/mid.test.d.ts +1 -0
- package/dist/types/functions/text/right/right.d.ts +2 -0
- package/dist/types/functions/text/right/right.test.d.ts +1 -0
- package/dist/types/functions/text/text-helpers.d.ts +27 -0
- package/dist/types/functions/text/textjoin/textjoin.d.ts +5 -0
- package/dist/types/functions/text/textjoin/textjoin.test.d.ts +1 -0
- package/dist/types/parser/ast.d.ts +275 -0
- package/dist/types/parser/formatter.d.ts +6 -0
- package/dist/types/parser/grammar.d.ts +203 -0
- package/dist/types/parser/lexer.d.ts +144 -0
- package/dist/types/parser/parser.d.ts +159 -0
- package/dist/types/react/hooks.d.ts +5 -0
- package/package.json +41 -0
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
6
|
+
var __toCommonJS = (from) => {
|
|
7
|
+
var entry = __moduleCache.get(from), desc;
|
|
8
|
+
if (entry)
|
|
9
|
+
return entry;
|
|
10
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
+
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
}));
|
|
16
|
+
__moduleCache.set(from, entry);
|
|
17
|
+
return entry;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, {
|
|
22
|
+
get: all[name],
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
set: (newValue) => all[name] = () => newValue
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// src/core/managers/range-eval-order-builder.ts
|
|
30
|
+
var exports_range_eval_order_builder = {};
|
|
31
|
+
__export(exports_range_eval_order_builder, {
|
|
32
|
+
buildRangeEvalOrder: () => buildRangeEvalOrder
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(exports_range_eval_order_builder);
|
|
35
|
+
var import_types = require("../types.cjs");
|
|
36
|
+
var import_utils = require("../utils.cjs");
|
|
37
|
+
var import_workbook_manager = require("./workbook-manager.cjs");
|
|
38
|
+
var import_evaluation_error = require("src/evaluator/evaluation-error");
|
|
39
|
+
function buildRangeEvalOrder(lookupOrder, lookupRange) {
|
|
40
|
+
const sheet = this.getSheet(lookupRange);
|
|
41
|
+
if (!sheet) {
|
|
42
|
+
throw new import_evaluation_error.EvaluationError(import_types.FormulaError.REF, `Sheet ${lookupRange.sheetName} not found`);
|
|
43
|
+
}
|
|
44
|
+
const result = [];
|
|
45
|
+
const startRow = lookupRange.range.start.row;
|
|
46
|
+
const startCol = lookupRange.range.start.col;
|
|
47
|
+
const occupiedCells = new Map;
|
|
48
|
+
let maxRow = startRow;
|
|
49
|
+
let maxCol = startCol;
|
|
50
|
+
for (const cellAddr of this.iterateCellsInRange(lookupRange)) {
|
|
51
|
+
occupiedCells.set(import_utils.getCellReference(cellAddr), cellAddr);
|
|
52
|
+
maxRow = Math.max(maxRow, cellAddr.rowIndex);
|
|
53
|
+
maxCol = Math.max(maxCol, cellAddr.colIndex);
|
|
54
|
+
}
|
|
55
|
+
if (lookupRange.range.end.row.type === "infinity" || lookupRange.range.end.col.type === "infinity") {
|
|
56
|
+
const allCells = this.iterateCellsInRange({
|
|
57
|
+
workbookName: lookupRange.workbookName,
|
|
58
|
+
sheetName: lookupRange.sheetName,
|
|
59
|
+
range: {
|
|
60
|
+
start: { row: 0, col: 0 },
|
|
61
|
+
end: {
|
|
62
|
+
row: { type: "infinity", sign: "positive" },
|
|
63
|
+
col: { type: "infinity", sign: "positive" }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
for (const cellAddr of allCells) {
|
|
68
|
+
maxRow = Math.max(maxRow, cellAddr.rowIndex);
|
|
69
|
+
maxCol = Math.max(maxCol, cellAddr.colIndex);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const endRow = lookupRange.range.end.row.type === "number" ? lookupRange.range.end.row.value : maxRow;
|
|
73
|
+
const endCol = lookupRange.range.end.col.type === "number" ? lookupRange.range.end.col.value : maxCol;
|
|
74
|
+
const isInfinite = lookupRange.range.end.row.type === "infinity" || lookupRange.range.end.col.type === "infinity";
|
|
75
|
+
if (isInfinite && occupiedCells.size === 0) {
|
|
76
|
+
const leftCandidates = new Map;
|
|
77
|
+
const aboveCandidates = new Map;
|
|
78
|
+
const diagonalCandidates = new Map;
|
|
79
|
+
const allCells = this.iterateCellsInRange({
|
|
80
|
+
workbookName: lookupRange.workbookName,
|
|
81
|
+
sheetName: lookupRange.sheetName,
|
|
82
|
+
range: {
|
|
83
|
+
start: { row: 0, col: 0 },
|
|
84
|
+
end: {
|
|
85
|
+
row: { type: "infinity", sign: "positive" },
|
|
86
|
+
col: { type: "infinity", sign: "positive" }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
for (const cellAddr of allCells) {
|
|
91
|
+
const cellRef = import_utils.getCellReference(cellAddr);
|
|
92
|
+
const content = sheet.content.get(cellRef);
|
|
93
|
+
if (typeof content === "string" && content.startsWith("=")) {
|
|
94
|
+
const isLeftCandidate = cellAddr.colIndex < startCol && cellAddr.rowIndex >= startRow;
|
|
95
|
+
const isAboveCandidate = cellAddr.rowIndex < startRow && cellAddr.colIndex >= startCol;
|
|
96
|
+
const isDiagonalCandidate = cellAddr.rowIndex < startRow && cellAddr.colIndex < startCol;
|
|
97
|
+
if (isLeftCandidate) {
|
|
98
|
+
leftCandidates.set(cellRef, cellAddr);
|
|
99
|
+
} else if (isAboveCandidate) {
|
|
100
|
+
aboveCandidates.set(cellRef, cellAddr);
|
|
101
|
+
} else if (isDiagonalCandidate) {
|
|
102
|
+
diagonalCandidates.set(cellRef, cellAddr);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const candidateMap = new Map;
|
|
107
|
+
if (leftCandidates.size > 0 || aboveCandidates.size > 0) {
|
|
108
|
+
for (const [ref, addr] of leftCandidates) {
|
|
109
|
+
candidateMap.set(ref, addr);
|
|
110
|
+
}
|
|
111
|
+
for (const [ref, addr] of aboveCandidates) {
|
|
112
|
+
candidateMap.set(ref, addr);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
for (const [ref, addr] of diagonalCandidates) {
|
|
116
|
+
candidateMap.set(ref, addr);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const candidates = sortCandidates(Array.from(candidateMap.values()), lookupOrder);
|
|
120
|
+
result.push({
|
|
121
|
+
type: "empty_range",
|
|
122
|
+
address: lookupRange,
|
|
123
|
+
candidates
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
if (lookupOrder === "row-major") {
|
|
128
|
+
const indexes = this.getSheetIndexes({
|
|
129
|
+
workbookName: lookupRange.workbookName,
|
|
130
|
+
sheetName: lookupRange.sheetName
|
|
131
|
+
});
|
|
132
|
+
for (let row = startRow;row <= endRow; row++) {
|
|
133
|
+
const hasOccupiedInRow = indexes.rowGroups.has(row);
|
|
134
|
+
if (!hasOccupiedInRow && lookupRange.range.end.col.type === "infinity") {
|
|
135
|
+
const firstCell = {
|
|
136
|
+
rowIndex: row,
|
|
137
|
+
colIndex: startCol,
|
|
138
|
+
sheetName: lookupRange.sheetName,
|
|
139
|
+
workbookName: lookupRange.workbookName
|
|
140
|
+
};
|
|
141
|
+
const candidates = findCandidatesForCell.call(this, firstCell, sheet, lookupOrder);
|
|
142
|
+
result.push({
|
|
143
|
+
type: "empty_range",
|
|
144
|
+
address: {
|
|
145
|
+
workbookName: lookupRange.workbookName,
|
|
146
|
+
sheetName: lookupRange.sheetName,
|
|
147
|
+
range: {
|
|
148
|
+
start: {
|
|
149
|
+
row,
|
|
150
|
+
col: startCol
|
|
151
|
+
},
|
|
152
|
+
end: {
|
|
153
|
+
row: { type: "number", value: row },
|
|
154
|
+
col: lookupRange.range.end.col
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
candidates
|
|
159
|
+
});
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
processRowMajorRow.call(this, row, startCol, endCol, lookupRange, occupiedCells, sheet, result, indexes);
|
|
163
|
+
if (lookupRange.range.end.col.type === "infinity") {
|
|
164
|
+
const nextCol = endCol + 1;
|
|
165
|
+
const firstCellBeyondEnd = {
|
|
166
|
+
rowIndex: row,
|
|
167
|
+
colIndex: nextCol,
|
|
168
|
+
sheetName: lookupRange.sheetName,
|
|
169
|
+
workbookName: lookupRange.workbookName
|
|
170
|
+
};
|
|
171
|
+
const candidates = findCandidatesForCell.call(this, firstCellBeyondEnd, sheet, lookupOrder);
|
|
172
|
+
result.push({
|
|
173
|
+
type: "empty_range",
|
|
174
|
+
address: {
|
|
175
|
+
workbookName: lookupRange.workbookName,
|
|
176
|
+
sheetName: lookupRange.sheetName,
|
|
177
|
+
range: {
|
|
178
|
+
start: {
|
|
179
|
+
row,
|
|
180
|
+
col: nextCol
|
|
181
|
+
},
|
|
182
|
+
end: {
|
|
183
|
+
row: { type: "number", value: row },
|
|
184
|
+
col: lookupRange.range.end.col
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
candidates
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (lookupRange.range.end.row.type === "infinity") {
|
|
193
|
+
const nextRow = endRow + 1;
|
|
194
|
+
const firstCellInNextRow = {
|
|
195
|
+
rowIndex: nextRow,
|
|
196
|
+
colIndex: startCol,
|
|
197
|
+
sheetName: lookupRange.sheetName,
|
|
198
|
+
workbookName: lookupRange.workbookName
|
|
199
|
+
};
|
|
200
|
+
const candidates = findCandidatesForCell.call(this, firstCellInNextRow, sheet, lookupOrder);
|
|
201
|
+
result.push({
|
|
202
|
+
type: "empty_range",
|
|
203
|
+
address: {
|
|
204
|
+
workbookName: lookupRange.workbookName,
|
|
205
|
+
sheetName: lookupRange.sheetName,
|
|
206
|
+
range: {
|
|
207
|
+
start: {
|
|
208
|
+
row: nextRow,
|
|
209
|
+
col: startCol
|
|
210
|
+
},
|
|
211
|
+
end: {
|
|
212
|
+
row: lookupRange.range.end.row,
|
|
213
|
+
col: lookupRange.range.end.col
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
candidates
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
const indexes = this.getSheetIndexes({
|
|
222
|
+
workbookName: lookupRange.workbookName,
|
|
223
|
+
sheetName: lookupRange.sheetName
|
|
224
|
+
});
|
|
225
|
+
for (let col = startCol;col <= endCol; col++) {
|
|
226
|
+
const hasOccupiedInColumn = indexes.colGroups.has(col);
|
|
227
|
+
if (!hasOccupiedInColumn && lookupRange.range.end.row.type === "infinity") {
|
|
228
|
+
const firstCell = {
|
|
229
|
+
rowIndex: startRow,
|
|
230
|
+
colIndex: col,
|
|
231
|
+
sheetName: lookupRange.sheetName,
|
|
232
|
+
workbookName: lookupRange.workbookName
|
|
233
|
+
};
|
|
234
|
+
const candidates = findCandidatesForCell.call(this, firstCell, sheet, lookupOrder);
|
|
235
|
+
result.push({
|
|
236
|
+
type: "empty_range",
|
|
237
|
+
address: {
|
|
238
|
+
workbookName: lookupRange.workbookName,
|
|
239
|
+
sheetName: lookupRange.sheetName,
|
|
240
|
+
range: {
|
|
241
|
+
start: {
|
|
242
|
+
row: startRow,
|
|
243
|
+
col
|
|
244
|
+
},
|
|
245
|
+
end: {
|
|
246
|
+
row: lookupRange.range.end.row,
|
|
247
|
+
col: { type: "number", value: col }
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
candidates
|
|
252
|
+
});
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
processColMajorColumn.call(this, col, startRow, endRow, lookupRange, occupiedCells, sheet, result, indexes);
|
|
256
|
+
if (lookupRange.range.end.row.type === "infinity") {
|
|
257
|
+
const nextRow = endRow + 1;
|
|
258
|
+
const firstCellBeyondEnd = {
|
|
259
|
+
rowIndex: nextRow,
|
|
260
|
+
colIndex: col,
|
|
261
|
+
sheetName: lookupRange.sheetName,
|
|
262
|
+
workbookName: lookupRange.workbookName
|
|
263
|
+
};
|
|
264
|
+
const candidates = findCandidatesForCell.call(this, firstCellBeyondEnd, sheet, lookupOrder);
|
|
265
|
+
result.push({
|
|
266
|
+
type: "empty_range",
|
|
267
|
+
address: {
|
|
268
|
+
workbookName: lookupRange.workbookName,
|
|
269
|
+
sheetName: lookupRange.sheetName,
|
|
270
|
+
range: {
|
|
271
|
+
start: {
|
|
272
|
+
row: nextRow,
|
|
273
|
+
col
|
|
274
|
+
},
|
|
275
|
+
end: {
|
|
276
|
+
row: lookupRange.range.end.row,
|
|
277
|
+
col: { type: "number", value: col }
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
candidates
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (lookupRange.range.end.col.type === "infinity") {
|
|
286
|
+
const nextCol = endCol + 1;
|
|
287
|
+
const firstCellInNextCol = {
|
|
288
|
+
rowIndex: startRow,
|
|
289
|
+
colIndex: nextCol,
|
|
290
|
+
sheetName: lookupRange.sheetName,
|
|
291
|
+
workbookName: lookupRange.workbookName
|
|
292
|
+
};
|
|
293
|
+
const candidates = findCandidatesForCell.call(this, firstCellInNextCol, sheet, lookupOrder);
|
|
294
|
+
result.push({
|
|
295
|
+
type: "empty_range",
|
|
296
|
+
address: {
|
|
297
|
+
workbookName: lookupRange.workbookName,
|
|
298
|
+
sheetName: lookupRange.sheetName,
|
|
299
|
+
range: {
|
|
300
|
+
start: {
|
|
301
|
+
row: startRow,
|
|
302
|
+
col: nextCol
|
|
303
|
+
},
|
|
304
|
+
end: {
|
|
305
|
+
row: lookupRange.range.end.row,
|
|
306
|
+
col: lookupRange.range.end.col
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
candidates
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
function processRowMajorRow(row, startCol, endCol, lookupRange, occupiedCells, sheet, result, indexes) {
|
|
317
|
+
let col = startCol;
|
|
318
|
+
while (col <= endCol) {
|
|
319
|
+
const cellAddr = {
|
|
320
|
+
rowIndex: row,
|
|
321
|
+
colIndex: col,
|
|
322
|
+
sheetName: lookupRange.sheetName,
|
|
323
|
+
workbookName: lookupRange.workbookName
|
|
324
|
+
};
|
|
325
|
+
const cellRef = import_utils.getCellReference(cellAddr);
|
|
326
|
+
if (occupiedCells.has(cellRef)) {
|
|
327
|
+
result.push({
|
|
328
|
+
type: "value",
|
|
329
|
+
address: cellAddr
|
|
330
|
+
});
|
|
331
|
+
col++;
|
|
332
|
+
} else {
|
|
333
|
+
const emptyRangeStart = col;
|
|
334
|
+
let emptyRangeEnd = endCol;
|
|
335
|
+
const rowGroup = indexes.rowGroups.get(row);
|
|
336
|
+
if (rowGroup) {
|
|
337
|
+
const nextCellIdx = import_workbook_manager.IndexEntryBinarySearch.findFirstGreaterOrEqual(rowGroup, col + 1);
|
|
338
|
+
if (nextCellIdx !== -1) {
|
|
339
|
+
emptyRangeEnd = rowGroup[nextCellIdx].number - 1;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const allCandidates = findAllCandidatesForRange(this, {
|
|
343
|
+
workbookName: lookupRange.workbookName,
|
|
344
|
+
sheetName: lookupRange.sheetName,
|
|
345
|
+
range: {
|
|
346
|
+
start: { row, col: emptyRangeStart },
|
|
347
|
+
end: {
|
|
348
|
+
row: { type: "number", value: row },
|
|
349
|
+
col: { type: "number", value: emptyRangeEnd }
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}, sheet, "row-major");
|
|
353
|
+
if (emptyRangeStart === emptyRangeEnd) {
|
|
354
|
+
result.push({
|
|
355
|
+
type: "empty_cell",
|
|
356
|
+
address: cellAddr,
|
|
357
|
+
candidates: allCandidates
|
|
358
|
+
});
|
|
359
|
+
} else {
|
|
360
|
+
result.push({
|
|
361
|
+
type: "empty_range",
|
|
362
|
+
address: {
|
|
363
|
+
workbookName: lookupRange.workbookName,
|
|
364
|
+
sheetName: lookupRange.sheetName,
|
|
365
|
+
range: {
|
|
366
|
+
start: {
|
|
367
|
+
row,
|
|
368
|
+
col: emptyRangeStart
|
|
369
|
+
},
|
|
370
|
+
end: {
|
|
371
|
+
row: { type: "number", value: row },
|
|
372
|
+
col: { type: "number", value: emptyRangeEnd }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
candidates: allCandidates
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
col = emptyRangeEnd + 1;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function processColMajorColumn(col, startRow, endRow, lookupRange, occupiedCells, sheet, result, indexes) {
|
|
384
|
+
let row = startRow;
|
|
385
|
+
while (row <= endRow) {
|
|
386
|
+
const cellAddr = {
|
|
387
|
+
rowIndex: row,
|
|
388
|
+
colIndex: col,
|
|
389
|
+
sheetName: lookupRange.sheetName,
|
|
390
|
+
workbookName: lookupRange.workbookName
|
|
391
|
+
};
|
|
392
|
+
const cellRef = import_utils.getCellReference(cellAddr);
|
|
393
|
+
if (occupiedCells.has(cellRef)) {
|
|
394
|
+
result.push({
|
|
395
|
+
type: "value",
|
|
396
|
+
address: cellAddr
|
|
397
|
+
});
|
|
398
|
+
row++;
|
|
399
|
+
} else {
|
|
400
|
+
const emptyRangeStart = row;
|
|
401
|
+
let emptyRangeEnd = endRow;
|
|
402
|
+
const colGroup = indexes.colGroups.get(col);
|
|
403
|
+
if (colGroup) {
|
|
404
|
+
const nextCellIdx = import_workbook_manager.IndexEntryBinarySearch.findFirstGreaterOrEqual(colGroup, row + 1);
|
|
405
|
+
if (nextCellIdx !== -1) {
|
|
406
|
+
emptyRangeEnd = colGroup[nextCellIdx].number - 1;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const allCandidates = findAllCandidatesForRange(this, {
|
|
410
|
+
workbookName: lookupRange.workbookName,
|
|
411
|
+
sheetName: lookupRange.sheetName,
|
|
412
|
+
range: {
|
|
413
|
+
start: { row: emptyRangeStart, col },
|
|
414
|
+
end: {
|
|
415
|
+
row: { type: "number", value: emptyRangeEnd },
|
|
416
|
+
col: { type: "number", value: col }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}, sheet, "col-major");
|
|
420
|
+
if (emptyRangeStart === emptyRangeEnd) {
|
|
421
|
+
result.push({
|
|
422
|
+
type: "empty_cell",
|
|
423
|
+
address: cellAddr,
|
|
424
|
+
candidates: allCandidates
|
|
425
|
+
});
|
|
426
|
+
} else {
|
|
427
|
+
result.push({
|
|
428
|
+
type: "empty_range",
|
|
429
|
+
address: {
|
|
430
|
+
workbookName: lookupRange.workbookName,
|
|
431
|
+
sheetName: lookupRange.sheetName,
|
|
432
|
+
range: {
|
|
433
|
+
start: {
|
|
434
|
+
row: emptyRangeStart,
|
|
435
|
+
col
|
|
436
|
+
},
|
|
437
|
+
end: {
|
|
438
|
+
row: { type: "number", value: emptyRangeEnd },
|
|
439
|
+
col: { type: "number", value: col }
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
candidates: allCandidates
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
row = emptyRangeEnd + 1;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function findAllCandidatesForRange(manager, emptyRange, sheet, lookupOrder) {
|
|
451
|
+
const candidateMap = new Map;
|
|
452
|
+
const startRow = emptyRange.range.start.row;
|
|
453
|
+
const startCol = emptyRange.range.start.col;
|
|
454
|
+
const endRow = emptyRange.range.end.row.type === "number" ? emptyRange.range.end.row.value : startRow;
|
|
455
|
+
const endCol = emptyRange.range.end.col.type === "number" ? emptyRange.range.end.col.value : startCol;
|
|
456
|
+
const positionsToCheck = [];
|
|
457
|
+
if (startRow === endRow) {
|
|
458
|
+
for (let col = startCol;col <= endCol; col++) {
|
|
459
|
+
positionsToCheck.push({ row: startRow, col });
|
|
460
|
+
}
|
|
461
|
+
} else if (startCol === endCol) {
|
|
462
|
+
const maxSamples = 100;
|
|
463
|
+
const numRows = endRow - startRow + 1;
|
|
464
|
+
if (numRows <= maxSamples) {
|
|
465
|
+
for (let row = startRow;row <= endRow; row++) {
|
|
466
|
+
positionsToCheck.push({ row, col: startCol });
|
|
467
|
+
}
|
|
468
|
+
} else {
|
|
469
|
+
positionsToCheck.push({ row: startRow, col: startCol });
|
|
470
|
+
positionsToCheck.push({ row: endRow, col: startCol });
|
|
471
|
+
const indexes = manager.getSheetIndexes({
|
|
472
|
+
workbookName: emptyRange.workbookName,
|
|
473
|
+
sheetName: emptyRange.sheetName
|
|
474
|
+
});
|
|
475
|
+
const seenRows = new Set;
|
|
476
|
+
for (let c = 0;c < startCol; c++) {
|
|
477
|
+
const colGroup = indexes.colGroups.get(c);
|
|
478
|
+
if (colGroup) {
|
|
479
|
+
const startIdx = import_workbook_manager.IndexEntryBinarySearch.findFirstGreaterOrEqual(colGroup, startRow);
|
|
480
|
+
if (startIdx !== -1) {
|
|
481
|
+
for (let i = startIdx;i < colGroup.length; i++) {
|
|
482
|
+
const entry = colGroup[i];
|
|
483
|
+
if (!entry || entry.number > endRow)
|
|
484
|
+
break;
|
|
485
|
+
if (!seenRows.has(entry.number)) {
|
|
486
|
+
seenRows.add(entry.number);
|
|
487
|
+
positionsToCheck.push({ row: entry.number, col: startCol });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
positionsToCheck.push({ row: startRow, col: startCol });
|
|
496
|
+
positionsToCheck.push({ row: startRow, col: endCol });
|
|
497
|
+
positionsToCheck.push({ row: endRow, col: startCol });
|
|
498
|
+
positionsToCheck.push({ row: endRow, col: endCol });
|
|
499
|
+
}
|
|
500
|
+
for (const pos of positionsToCheck) {
|
|
501
|
+
const candidates = findCandidatesForCell.call(manager, {
|
|
502
|
+
rowIndex: pos.row,
|
|
503
|
+
colIndex: pos.col,
|
|
504
|
+
sheetName: emptyRange.sheetName,
|
|
505
|
+
workbookName: emptyRange.workbookName
|
|
506
|
+
}, sheet, lookupOrder);
|
|
507
|
+
for (const cand of candidates) {
|
|
508
|
+
candidateMap.set(import_utils.getCellReference(cand), cand);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return sortCandidates(Array.from(candidateMap.values()), lookupOrder);
|
|
512
|
+
}
|
|
513
|
+
function findCandidatesForCell(cellAddr, sheet, lookupOrder) {
|
|
514
|
+
const leftCandidate = findNearestLeftAnchor.call(this, cellAddr, sheet);
|
|
515
|
+
const aboveCandidate = findNearestAboveAnchor.call(this, cellAddr, sheet);
|
|
516
|
+
if (leftCandidate || aboveCandidate) {
|
|
517
|
+
const candidates = [];
|
|
518
|
+
if (leftCandidate)
|
|
519
|
+
candidates.push(leftCandidate);
|
|
520
|
+
if (aboveCandidate)
|
|
521
|
+
candidates.push(aboveCandidate);
|
|
522
|
+
return sortCandidates(candidates, lookupOrder);
|
|
523
|
+
}
|
|
524
|
+
const diagonalCandidates = findAllDiagonalStepCandidates.call(this, cellAddr, sheet);
|
|
525
|
+
return sortCandidates(diagonalCandidates, lookupOrder);
|
|
526
|
+
}
|
|
527
|
+
function sortCandidates(candidates, lookupOrder) {
|
|
528
|
+
return candidates.sort((a, b) => {
|
|
529
|
+
if (lookupOrder === "row-major") {
|
|
530
|
+
if (a.colIndex !== b.colIndex)
|
|
531
|
+
return a.colIndex - b.colIndex;
|
|
532
|
+
return a.rowIndex - b.rowIndex;
|
|
533
|
+
} else {
|
|
534
|
+
if (a.rowIndex !== b.rowIndex)
|
|
535
|
+
return a.rowIndex - b.rowIndex;
|
|
536
|
+
return a.colIndex - b.colIndex;
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function findNearestLeftAnchor(targetCell, sheet) {
|
|
541
|
+
const row = targetCell.rowIndex;
|
|
542
|
+
const targetCol = targetCell.colIndex;
|
|
543
|
+
const indexes = this.getSheetIndexes({
|
|
544
|
+
workbookName: targetCell.workbookName,
|
|
545
|
+
sheetName: targetCell.sheetName
|
|
546
|
+
});
|
|
547
|
+
const rowGroup = indexes.rowGroups.get(row);
|
|
548
|
+
if (!rowGroup) {
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
for (let i = rowGroup.length - 1;i >= 0; i--) {
|
|
552
|
+
const entry = rowGroup[i];
|
|
553
|
+
if (!entry || entry.number >= targetCol) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
const content = sheet.content.get(entry.key);
|
|
557
|
+
if (typeof content === "string" && content.startsWith("=")) {
|
|
558
|
+
return {
|
|
559
|
+
rowIndex: row,
|
|
560
|
+
colIndex: entry.number,
|
|
561
|
+
sheetName: targetCell.sheetName,
|
|
562
|
+
workbookName: targetCell.workbookName
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
function findNearestAboveAnchor(targetCell, sheet) {
|
|
569
|
+
const col = targetCell.colIndex;
|
|
570
|
+
const targetRow = targetCell.rowIndex;
|
|
571
|
+
const indexes = this.getSheetIndexes({
|
|
572
|
+
workbookName: targetCell.workbookName,
|
|
573
|
+
sheetName: targetCell.sheetName
|
|
574
|
+
});
|
|
575
|
+
const colGroup = indexes.colGroups.get(col);
|
|
576
|
+
if (!colGroup) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
for (let i = colGroup.length - 1;i >= 0; i--) {
|
|
580
|
+
const entry = colGroup[i];
|
|
581
|
+
if (!entry || entry.number >= targetRow) {
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
const content = sheet.content.get(entry.key);
|
|
585
|
+
if (typeof content === "string" && content.startsWith("=")) {
|
|
586
|
+
return {
|
|
587
|
+
rowIndex: entry.number,
|
|
588
|
+
colIndex: col,
|
|
589
|
+
sheetName: targetCell.sheetName,
|
|
590
|
+
workbookName: targetCell.workbookName
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
function findAllDiagonalStepCandidates(targetCell, sheet) {
|
|
597
|
+
const targetRow = targetCell.rowIndex;
|
|
598
|
+
const targetCol = targetCell.colIndex;
|
|
599
|
+
const allCandidates = [];
|
|
600
|
+
const indexes = this.getSheetIndexes({
|
|
601
|
+
workbookName: targetCell.workbookName,
|
|
602
|
+
sheetName: targetCell.sheetName
|
|
603
|
+
});
|
|
604
|
+
for (let col = 0;col < targetCol; col++) {
|
|
605
|
+
const colGroup = indexes.colGroups.get(col);
|
|
606
|
+
if (!colGroup) {
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
for (const entry of colGroup) {
|
|
610
|
+
if (entry.number >= targetRow) {
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
const content = sheet.content.get(entry.key);
|
|
614
|
+
if (typeof content === "string" && content.startsWith("=")) {
|
|
615
|
+
allCandidates.push({
|
|
616
|
+
rowIndex: entry.number,
|
|
617
|
+
colIndex: col,
|
|
618
|
+
sheetName: targetCell.sheetName,
|
|
619
|
+
workbookName: targetCell.workbookName
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
allCandidates.sort((a, b) => {
|
|
625
|
+
if (a.rowIndex !== b.rowIndex)
|
|
626
|
+
return b.rowIndex - a.rowIndex;
|
|
627
|
+
return b.colIndex - a.colIndex;
|
|
628
|
+
});
|
|
629
|
+
const unblockedCandidates = [];
|
|
630
|
+
let maxColSeen = -1;
|
|
631
|
+
let prevRow = -1;
|
|
632
|
+
for (const candidate of allCandidates) {
|
|
633
|
+
if (candidate.rowIndex !== prevRow) {
|
|
634
|
+
if (candidate.colIndex > maxColSeen) {
|
|
635
|
+
unblockedCandidates.push(candidate);
|
|
636
|
+
maxColSeen = candidate.colIndex;
|
|
637
|
+
}
|
|
638
|
+
prevRow = candidate.rowIndex;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return unblockedCandidates;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
//# debugId=5275BD56EBC306E164756E2164756E21
|