@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.
Files changed (569) hide show
  1. package/README.md +100 -0
  2. package/dist/cjs/core/ast-traverser.cjs +124 -0
  3. package/dist/cjs/core/ast-traverser.cjs.map +10 -0
  4. package/dist/cjs/core/autofill-utils.cjs +304 -0
  5. package/dist/cjs/core/autofill-utils.cjs.map +10 -0
  6. package/dist/cjs/core/engine.cjs +390 -0
  7. package/dist/cjs/core/engine.cjs.map +10 -0
  8. package/dist/cjs/core/managers/cache-manager.cjs +58 -0
  9. package/dist/cjs/core/managers/cache-manager.cjs.map +10 -0
  10. package/dist/cjs/core/managers/dependency-manager.cjs +620 -0
  11. package/dist/cjs/core/managers/dependency-manager.cjs.map +10 -0
  12. package/dist/cjs/core/managers/dependency-node.cjs +24 -0
  13. package/dist/cjs/core/managers/dependency-node.cjs.map +9 -0
  14. package/dist/cjs/core/managers/evaluation-manager.cjs +433 -0
  15. package/dist/cjs/core/managers/evaluation-manager.cjs.map +10 -0
  16. package/dist/cjs/core/managers/event-manager.cjs +49 -0
  17. package/dist/cjs/core/managers/event-manager.cjs.map +10 -0
  18. package/dist/cjs/core/managers/frontier-dependency-manager.cjs +181 -0
  19. package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +10 -0
  20. package/dist/cjs/core/managers/index.cjs +49 -0
  21. package/dist/cjs/core/managers/index.cjs.map +10 -0
  22. package/dist/cjs/core/managers/isDependencyNode.cjs +44 -0
  23. package/dist/cjs/core/managers/isDependencyNode.cjs.map +10 -0
  24. package/dist/cjs/core/managers/named-expression-manager.cjs +379 -0
  25. package/dist/cjs/core/managers/named-expression-manager.cjs.map +10 -0
  26. package/dist/cjs/core/managers/range-eval-order-builder.cjs +644 -0
  27. package/dist/cjs/core/managers/range-eval-order-builder.cjs.map +10 -0
  28. package/dist/cjs/core/managers/table-manager.cjs +254 -0
  29. package/dist/cjs/core/managers/table-manager.cjs.map +10 -0
  30. package/dist/cjs/core/managers/workbook-manager.cjs +474 -0
  31. package/dist/cjs/core/managers/workbook-manager.cjs.map +10 -0
  32. package/dist/cjs/core/map-serializer.cjs +69 -0
  33. package/dist/cjs/core/map-serializer.cjs.map +10 -0
  34. package/dist/cjs/core/named-expression-renamer.cjs +88 -0
  35. package/dist/cjs/core/named-expression-renamer.cjs.map +10 -0
  36. package/dist/cjs/core/sheet-renamer.cjs +89 -0
  37. package/dist/cjs/core/sheet-renamer.cjs.map +10 -0
  38. package/dist/cjs/core/sheet-utils.cjs +39 -0
  39. package/dist/cjs/core/sheet-utils.cjs.map +10 -0
  40. package/dist/cjs/core/table-renamer.cjs +88 -0
  41. package/dist/cjs/core/table-renamer.cjs.map +10 -0
  42. package/dist/cjs/core/types.cjs +48 -0
  43. package/dist/cjs/core/types.cjs.map +10 -0
  44. package/dist/cjs/core/utils/range-serializer.cjs +65 -0
  45. package/dist/cjs/core/utils/range-serializer.cjs.map +10 -0
  46. package/dist/cjs/core/utils/spreadsheet-visualizer.cjs +142 -0
  47. package/dist/cjs/core/utils/spreadsheet-visualizer.cjs.map +10 -0
  48. package/dist/cjs/core/utils.cjs +434 -0
  49. package/dist/cjs/core/utils.cjs.map +10 -0
  50. package/dist/cjs/core/workbook-renamer.cjs +106 -0
  51. package/dist/cjs/core/workbook-renamer.cjs.map +10 -0
  52. package/dist/cjs/debug/flags.cjs +47 -0
  53. package/dist/cjs/debug/flags.cjs.map +10 -0
  54. package/dist/cjs/evaluator/arithmetic/add/add.cjs +82 -0
  55. package/dist/cjs/evaluator/arithmetic/add/add.cjs.map +10 -0
  56. package/dist/cjs/evaluator/arithmetic/divide/divide.cjs +107 -0
  57. package/dist/cjs/evaluator/arithmetic/divide/divide.cjs.map +10 -0
  58. package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs +93 -0
  59. package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs.map +10 -0
  60. package/dist/cjs/evaluator/arithmetic/power/power.cjs +125 -0
  61. package/dist/cjs/evaluator/arithmetic/power/power.cjs.map +10 -0
  62. package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs +84 -0
  63. package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs.map +10 -0
  64. package/dist/cjs/evaluator/comparison/equals.cjs +64 -0
  65. package/dist/cjs/evaluator/comparison/equals.cjs.map +10 -0
  66. package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs +61 -0
  67. package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs.map +10 -0
  68. package/dist/cjs/evaluator/comparison/greater-than.cjs +61 -0
  69. package/dist/cjs/evaluator/comparison/greater-than.cjs.map +10 -0
  70. package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs +69 -0
  71. package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs.map +10 -0
  72. package/dist/cjs/evaluator/comparison/less-than.cjs +68 -0
  73. package/dist/cjs/evaluator/comparison/less-than.cjs.map +10 -0
  74. package/dist/cjs/evaluator/comparison/not-equals.cjs +53 -0
  75. package/dist/cjs/evaluator/comparison/not-equals.cjs.map +10 -0
  76. package/dist/cjs/evaluator/concatenation/concatenate.cjs +72 -0
  77. package/dist/cjs/evaluator/concatenation/concatenate.cjs.map +10 -0
  78. package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs +58 -0
  79. package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs.map +10 -0
  80. package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs +112 -0
  81. package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs.map +10 -0
  82. package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs +54 -0
  83. package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs.map +10 -0
  84. package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs +108 -0
  85. package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs.map +10 -0
  86. package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs +50 -0
  87. package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs.map +10 -0
  88. package/dist/cjs/evaluator/evaluate-scalar-operator.cjs +254 -0
  89. package/dist/cjs/evaluator/evaluate-scalar-operator.cjs.map +10 -0
  90. package/dist/cjs/evaluator/evaluation-context.cjs +154 -0
  91. package/dist/cjs/evaluator/evaluation-context.cjs.map +10 -0
  92. package/dist/cjs/evaluator/evaluation-error.cjs +75 -0
  93. package/dist/cjs/evaluator/evaluation-error.cjs.map +10 -0
  94. package/dist/cjs/evaluator/formula-evaluator.cjs +797 -0
  95. package/dist/cjs/evaluator/formula-evaluator.cjs.map +10 -0
  96. package/dist/cjs/evaluator/range-evaluation-node.cjs +88 -0
  97. package/dist/cjs/evaluator/range-evaluation-node.cjs.map +10 -0
  98. package/dist/cjs/functions/_template/template.cjs +42 -0
  99. package/dist/cjs/functions/_template/template.cjs.map +10 -0
  100. package/dist/cjs/functions/array/sequence/sequence.cjs +315 -0
  101. package/dist/cjs/functions/array/sequence/sequence.cjs.map +10 -0
  102. package/dist/cjs/functions/criteria-parser.cjs +217 -0
  103. package/dist/cjs/functions/criteria-parser.cjs.map +10 -0
  104. package/dist/cjs/functions/criteria-utils.cjs +291 -0
  105. package/dist/cjs/functions/criteria-utils.cjs.map +10 -0
  106. package/dist/cjs/functions/function-utils.cjs +63 -0
  107. package/dist/cjs/functions/function-utils.cjs.map +10 -0
  108. package/dist/cjs/functions/index.cjs +125 -0
  109. package/dist/cjs/functions/index.cjs.map +10 -0
  110. package/dist/cjs/functions/information/cell/cell.cjs +196 -0
  111. package/dist/cjs/functions/information/cell/cell.cjs.map +10 -0
  112. package/dist/cjs/functions/information/column/column.cjs +144 -0
  113. package/dist/cjs/functions/information/column/column.cjs.map +10 -0
  114. package/dist/cjs/functions/information/row/row.cjs +150 -0
  115. package/dist/cjs/functions/information/row/row.cjs.map +10 -0
  116. package/dist/cjs/functions/logical/and/and.cjs +112 -0
  117. package/dist/cjs/functions/logical/and/and.cjs.map +10 -0
  118. package/dist/cjs/functions/logical/if/if.cjs +195 -0
  119. package/dist/cjs/functions/logical/if/if.cjs.map +10 -0
  120. package/dist/cjs/functions/logical/iferror/iferror.cjs +126 -0
  121. package/dist/cjs/functions/logical/iferror/iferror.cjs.map +10 -0
  122. package/dist/cjs/functions/logical/or/or.cjs +112 -0
  123. package/dist/cjs/functions/logical/or/or.cjs.map +10 -0
  124. package/dist/cjs/functions/lookup/count/count-utils.cjs +65 -0
  125. package/dist/cjs/functions/lookup/count/count-utils.cjs.map +10 -0
  126. package/dist/cjs/functions/lookup/count/count.cjs +48 -0
  127. package/dist/cjs/functions/lookup/count/count.cjs.map +10 -0
  128. package/dist/cjs/functions/lookup/count/countif.cjs +94 -0
  129. package/dist/cjs/functions/lookup/count/countif.cjs.map +10 -0
  130. package/dist/cjs/functions/lookup/count/countifs.cjs +63 -0
  131. package/dist/cjs/functions/lookup/count/countifs.cjs.map +10 -0
  132. package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs +187 -0
  133. package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs.map +10 -0
  134. package/dist/cjs/functions/lookup/match/match.cjs +168 -0
  135. package/dist/cjs/functions/lookup/match/match.cjs.map +10 -0
  136. package/dist/cjs/functions/lookup/xlookup/xlookup.cjs +410 -0
  137. package/dist/cjs/functions/lookup/xlookup/xlookup.cjs.map +10 -0
  138. package/dist/cjs/functions/math/average/average-utils.cjs +72 -0
  139. package/dist/cjs/functions/math/average/average-utils.cjs.map +10 -0
  140. package/dist/cjs/functions/math/average/average.cjs +48 -0
  141. package/dist/cjs/functions/math/average/average.cjs.map +10 -0
  142. package/dist/cjs/functions/math/average/averageif.cjs +83 -0
  143. package/dist/cjs/functions/math/average/averageif.cjs.map +10 -0
  144. package/dist/cjs/functions/math/average/averageifs.cjs +61 -0
  145. package/dist/cjs/functions/math/average/averageifs.cjs.map +10 -0
  146. package/dist/cjs/functions/math/ceiling/ceiling.cjs +219 -0
  147. package/dist/cjs/functions/math/ceiling/ceiling.cjs.map +10 -0
  148. package/dist/cjs/functions/math/max/max-utils.cjs +71 -0
  149. package/dist/cjs/functions/math/max/max-utils.cjs.map +10 -0
  150. package/dist/cjs/functions/math/max/max.cjs +48 -0
  151. package/dist/cjs/functions/math/max/max.cjs.map +10 -0
  152. package/dist/cjs/functions/math/max/maxif.cjs +83 -0
  153. package/dist/cjs/functions/math/max/maxif.cjs.map +10 -0
  154. package/dist/cjs/functions/math/max/maxifs.cjs +61 -0
  155. package/dist/cjs/functions/math/max/maxifs.cjs.map +10 -0
  156. package/dist/cjs/functions/math/min/min-utils.cjs +71 -0
  157. package/dist/cjs/functions/math/min/min-utils.cjs.map +10 -0
  158. package/dist/cjs/functions/math/min/min.cjs +48 -0
  159. package/dist/cjs/functions/math/min/min.cjs.map +10 -0
  160. package/dist/cjs/functions/math/min/minif.cjs +83 -0
  161. package/dist/cjs/functions/math/min/minif.cjs.map +10 -0
  162. package/dist/cjs/functions/math/min/minifs.cjs +61 -0
  163. package/dist/cjs/functions/math/min/minifs.cjs.map +10 -0
  164. package/dist/cjs/functions/math/sum/sum.cjs +48 -0
  165. package/dist/cjs/functions/math/sum/sum.cjs.map +10 -0
  166. package/dist/cjs/functions/math/sum/sumif.cjs +83 -0
  167. package/dist/cjs/functions/math/sum/sumif.cjs.map +10 -0
  168. package/dist/cjs/functions/math/sum/sumifs.cjs +60 -0
  169. package/dist/cjs/functions/math/sum/sumifs.cjs.map +10 -0
  170. package/dist/cjs/functions/math/sum/summation-utils.cjs +57 -0
  171. package/dist/cjs/functions/math/sum/summation-utils.cjs.map +10 -0
  172. package/dist/cjs/functions/reference/address/address.cjs +163 -0
  173. package/dist/cjs/functions/reference/address/address.cjs.map +10 -0
  174. package/dist/cjs/functions/reference/indirect/indirect.cjs +102 -0
  175. package/dist/cjs/functions/reference/indirect/indirect.cjs.map +10 -0
  176. package/dist/cjs/functions/reference/offset/offset.cjs +233 -0
  177. package/dist/cjs/functions/reference/offset/offset.cjs.map +10 -0
  178. package/dist/cjs/functions/text/concatenate/concatenate.cjs +167 -0
  179. package/dist/cjs/functions/text/concatenate/concatenate.cjs.map +10 -0
  180. package/dist/cjs/functions/text/exact/exact.cjs +171 -0
  181. package/dist/cjs/functions/text/exact/exact.cjs.map +10 -0
  182. package/dist/cjs/functions/text/find/find.cjs +397 -0
  183. package/dist/cjs/functions/text/find/find.cjs.map +10 -0
  184. package/dist/cjs/functions/text/left/left.cjs +109 -0
  185. package/dist/cjs/functions/text/left/left.cjs.map +10 -0
  186. package/dist/cjs/functions/text/len/len.cjs +119 -0
  187. package/dist/cjs/functions/text/len/len.cjs.map +10 -0
  188. package/dist/cjs/functions/text/mid/mid.cjs +103 -0
  189. package/dist/cjs/functions/text/mid/mid.cjs.map +10 -0
  190. package/dist/cjs/functions/text/right/right.cjs +167 -0
  191. package/dist/cjs/functions/text/right/right.cjs.map +10 -0
  192. package/dist/cjs/functions/text/text-helpers.cjs +179 -0
  193. package/dist/cjs/functions/text/text-helpers.cjs.map +10 -0
  194. package/dist/cjs/functions/text/textjoin/textjoin.cjs +173 -0
  195. package/dist/cjs/functions/text/textjoin/textjoin.cjs.map +10 -0
  196. package/dist/cjs/package.json +5 -0
  197. package/dist/cjs/parser/ast.cjs +175 -0
  198. package/dist/cjs/parser/ast.cjs.map +10 -0
  199. package/dist/cjs/parser/formatter.cjs +319 -0
  200. package/dist/cjs/parser/formatter.cjs.map +10 -0
  201. package/dist/cjs/parser/grammar.cjs +375 -0
  202. package/dist/cjs/parser/grammar.cjs.map +10 -0
  203. package/dist/cjs/parser/lexer.cjs +443 -0
  204. package/dist/cjs/parser/lexer.cjs.map +10 -0
  205. package/dist/cjs/parser/parser.cjs +1700 -0
  206. package/dist/cjs/parser/parser.cjs.map +10 -0
  207. package/dist/cjs/react/hooks.cjs +59 -0
  208. package/dist/cjs/react/hooks.cjs.map +10 -0
  209. package/dist/mjs/core/ast-traverser.mjs +94 -0
  210. package/dist/mjs/core/ast-traverser.mjs.map +10 -0
  211. package/dist/mjs/core/autofill-utils.mjs +274 -0
  212. package/dist/mjs/core/autofill-utils.mjs.map +10 -0
  213. package/dist/mjs/core/engine.mjs +366 -0
  214. package/dist/mjs/core/engine.mjs.map +10 -0
  215. package/dist/mjs/core/managers/cache-manager.mjs +27 -0
  216. package/dist/mjs/core/managers/cache-manager.mjs.map +10 -0
  217. package/dist/mjs/core/managers/dependency-manager.mjs +593 -0
  218. package/dist/mjs/core/managers/dependency-manager.mjs.map +10 -0
  219. package/dist/mjs/core/managers/dependency-node.mjs +2 -0
  220. package/dist/mjs/core/managers/dependency-node.mjs.map +9 -0
  221. package/dist/mjs/core/managers/evaluation-manager.mjs +415 -0
  222. package/dist/mjs/core/managers/evaluation-manager.mjs.map +10 -0
  223. package/dist/mjs/core/managers/event-manager.mjs +18 -0
  224. package/dist/mjs/core/managers/event-manager.mjs.map +10 -0
  225. package/dist/mjs/core/managers/frontier-dependency-manager.mjs +151 -0
  226. package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +10 -0
  227. package/dist/mjs/core/managers/index.mjs +21 -0
  228. package/dist/mjs/core/managers/index.mjs.map +10 -0
  229. package/dist/mjs/core/managers/isDependencyNode.mjs +14 -0
  230. package/dist/mjs/core/managers/isDependencyNode.mjs.map +10 -0
  231. package/dist/mjs/core/managers/named-expression-manager.mjs +348 -0
  232. package/dist/mjs/core/managers/named-expression-manager.mjs.map +10 -0
  233. package/dist/mjs/core/managers/range-eval-order-builder.mjs +618 -0
  234. package/dist/mjs/core/managers/range-eval-order-builder.mjs.map +10 -0
  235. package/dist/mjs/core/managers/table-manager.mjs +224 -0
  236. package/dist/mjs/core/managers/table-manager.mjs.map +10 -0
  237. package/dist/mjs/core/managers/workbook-manager.mjs +447 -0
  238. package/dist/mjs/core/managers/workbook-manager.mjs.map +10 -0
  239. package/dist/mjs/core/map-serializer.mjs +39 -0
  240. package/dist/mjs/core/map-serializer.mjs.map +10 -0
  241. package/dist/mjs/core/named-expression-renamer.mjs +58 -0
  242. package/dist/mjs/core/named-expression-renamer.mjs.map +10 -0
  243. package/dist/mjs/core/sheet-renamer.mjs +59 -0
  244. package/dist/mjs/core/sheet-renamer.mjs.map +10 -0
  245. package/dist/mjs/core/sheet-utils.mjs +8 -0
  246. package/dist/mjs/core/sheet-utils.mjs.map +10 -0
  247. package/dist/mjs/core/table-renamer.mjs +58 -0
  248. package/dist/mjs/core/table-renamer.mjs.map +10 -0
  249. package/dist/mjs/core/types.mjs +18 -0
  250. package/dist/mjs/core/types.mjs.map +10 -0
  251. package/dist/mjs/core/utils/range-serializer.mjs +35 -0
  252. package/dist/mjs/core/utils/range-serializer.mjs.map +10 -0
  253. package/dist/mjs/core/utils/spreadsheet-visualizer.mjs +112 -0
  254. package/dist/mjs/core/utils/spreadsheet-visualizer.mjs.map +10 -0
  255. package/dist/mjs/core/utils.mjs +409 -0
  256. package/dist/mjs/core/utils.mjs.map +10 -0
  257. package/dist/mjs/core/workbook-renamer.mjs +76 -0
  258. package/dist/mjs/core/workbook-renamer.mjs.map +10 -0
  259. package/dist/mjs/debug/flags.mjs +17 -0
  260. package/dist/mjs/debug/flags.mjs.map +10 -0
  261. package/dist/mjs/evaluator/arithmetic/add/add.mjs +52 -0
  262. package/dist/mjs/evaluator/arithmetic/add/add.mjs.map +10 -0
  263. package/dist/mjs/evaluator/arithmetic/divide/divide.mjs +77 -0
  264. package/dist/mjs/evaluator/arithmetic/divide/divide.mjs.map +10 -0
  265. package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs +63 -0
  266. package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs.map +10 -0
  267. package/dist/mjs/evaluator/arithmetic/power/power.mjs +95 -0
  268. package/dist/mjs/evaluator/arithmetic/power/power.mjs.map +10 -0
  269. package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs +54 -0
  270. package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs.map +10 -0
  271. package/dist/mjs/evaluator/comparison/equals.mjs +34 -0
  272. package/dist/mjs/evaluator/comparison/equals.mjs.map +10 -0
  273. package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs +31 -0
  274. package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs.map +10 -0
  275. package/dist/mjs/evaluator/comparison/greater-than.mjs +31 -0
  276. package/dist/mjs/evaluator/comparison/greater-than.mjs.map +10 -0
  277. package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs +39 -0
  278. package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs.map +10 -0
  279. package/dist/mjs/evaluator/comparison/less-than.mjs +38 -0
  280. package/dist/mjs/evaluator/comparison/less-than.mjs.map +10 -0
  281. package/dist/mjs/evaluator/comparison/not-equals.mjs +23 -0
  282. package/dist/mjs/evaluator/comparison/not-equals.mjs.map +10 -0
  283. package/dist/mjs/evaluator/concatenation/concatenate.mjs +42 -0
  284. package/dist/mjs/evaluator/concatenation/concatenate.mjs.map +10 -0
  285. package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs +28 -0
  286. package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs.map +10 -0
  287. package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs +81 -0
  288. package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs.map +10 -0
  289. package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs +24 -0
  290. package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs.map +10 -0
  291. package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs +78 -0
  292. package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs.map +10 -0
  293. package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs +20 -0
  294. package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs.map +10 -0
  295. package/dist/mjs/evaluator/evaluate-scalar-operator.mjs +226 -0
  296. package/dist/mjs/evaluator/evaluate-scalar-operator.mjs.map +10 -0
  297. package/dist/mjs/evaluator/evaluation-context.mjs +123 -0
  298. package/dist/mjs/evaluator/evaluation-context.mjs.map +10 -0
  299. package/dist/mjs/evaluator/evaluation-error.mjs +44 -0
  300. package/dist/mjs/evaluator/evaluation-error.mjs.map +10 -0
  301. package/dist/mjs/evaluator/formula-evaluator.mjs +780 -0
  302. package/dist/mjs/evaluator/formula-evaluator.mjs.map +10 -0
  303. package/dist/mjs/evaluator/range-evaluation-node.mjs +58 -0
  304. package/dist/mjs/evaluator/range-evaluation-node.mjs.map +10 -0
  305. package/dist/mjs/functions/_template/template.mjs +12 -0
  306. package/dist/mjs/functions/_template/template.mjs.map +10 -0
  307. package/dist/mjs/functions/array/sequence/sequence.mjs +287 -0
  308. package/dist/mjs/functions/array/sequence/sequence.mjs.map +10 -0
  309. package/dist/mjs/functions/criteria-parser.mjs +187 -0
  310. package/dist/mjs/functions/criteria-parser.mjs.map +10 -0
  311. package/dist/mjs/functions/criteria-utils.mjs +268 -0
  312. package/dist/mjs/functions/criteria-utils.mjs.map +10 -0
  313. package/dist/mjs/functions/function-utils.mjs +33 -0
  314. package/dist/mjs/functions/function-utils.mjs.map +10 -0
  315. package/dist/mjs/functions/index.mjs +95 -0
  316. package/dist/mjs/functions/index.mjs.map +10 -0
  317. package/dist/mjs/functions/information/cell/cell.mjs +168 -0
  318. package/dist/mjs/functions/information/cell/cell.mjs.map +10 -0
  319. package/dist/mjs/functions/information/column/column.mjs +120 -0
  320. package/dist/mjs/functions/information/column/column.mjs.map +10 -0
  321. package/dist/mjs/functions/information/row/row.mjs +126 -0
  322. package/dist/mjs/functions/information/row/row.mjs.map +10 -0
  323. package/dist/mjs/functions/logical/and/and.mjs +84 -0
  324. package/dist/mjs/functions/logical/and/and.mjs.map +10 -0
  325. package/dist/mjs/functions/logical/if/if.mjs +167 -0
  326. package/dist/mjs/functions/logical/if/if.mjs.map +10 -0
  327. package/dist/mjs/functions/logical/iferror/iferror.mjs +98 -0
  328. package/dist/mjs/functions/logical/iferror/iferror.mjs.map +10 -0
  329. package/dist/mjs/functions/logical/or/or.mjs +84 -0
  330. package/dist/mjs/functions/logical/or/or.mjs.map +10 -0
  331. package/dist/mjs/functions/lookup/count/count-utils.mjs +35 -0
  332. package/dist/mjs/functions/lookup/count/count-utils.mjs.map +10 -0
  333. package/dist/mjs/functions/lookup/count/count.mjs +18 -0
  334. package/dist/mjs/functions/lookup/count/count.mjs.map +10 -0
  335. package/dist/mjs/functions/lookup/count/countif.mjs +68 -0
  336. package/dist/mjs/functions/lookup/count/countif.mjs.map +10 -0
  337. package/dist/mjs/functions/lookup/count/countifs.mjs +37 -0
  338. package/dist/mjs/functions/lookup/count/countifs.mjs.map +10 -0
  339. package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs +159 -0
  340. package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs.map +10 -0
  341. package/dist/mjs/functions/lookup/match/match.mjs +140 -0
  342. package/dist/mjs/functions/lookup/match/match.mjs.map +10 -0
  343. package/dist/mjs/functions/lookup/xlookup/xlookup.mjs +382 -0
  344. package/dist/mjs/functions/lookup/xlookup/xlookup.mjs.map +10 -0
  345. package/dist/mjs/functions/math/average/average-utils.mjs +44 -0
  346. package/dist/mjs/functions/math/average/average-utils.mjs.map +10 -0
  347. package/dist/mjs/functions/math/average/average.mjs +18 -0
  348. package/dist/mjs/functions/math/average/average.mjs.map +10 -0
  349. package/dist/mjs/functions/math/average/averageif.mjs +58 -0
  350. package/dist/mjs/functions/math/average/averageif.mjs.map +10 -0
  351. package/dist/mjs/functions/math/average/averageifs.mjs +35 -0
  352. package/dist/mjs/functions/math/average/averageifs.mjs.map +10 -0
  353. package/dist/mjs/functions/math/ceiling/ceiling.mjs +191 -0
  354. package/dist/mjs/functions/math/ceiling/ceiling.mjs.map +10 -0
  355. package/dist/mjs/functions/math/max/max-utils.mjs +43 -0
  356. package/dist/mjs/functions/math/max/max-utils.mjs.map +10 -0
  357. package/dist/mjs/functions/math/max/max.mjs +18 -0
  358. package/dist/mjs/functions/math/max/max.mjs.map +10 -0
  359. package/dist/mjs/functions/math/max/maxif.mjs +58 -0
  360. package/dist/mjs/functions/math/max/maxif.mjs.map +10 -0
  361. package/dist/mjs/functions/math/max/maxifs.mjs +35 -0
  362. package/dist/mjs/functions/math/max/maxifs.mjs.map +10 -0
  363. package/dist/mjs/functions/math/min/min-utils.mjs +43 -0
  364. package/dist/mjs/functions/math/min/min-utils.mjs.map +10 -0
  365. package/dist/mjs/functions/math/min/min.mjs +18 -0
  366. package/dist/mjs/functions/math/min/min.mjs.map +10 -0
  367. package/dist/mjs/functions/math/min/minif.mjs +58 -0
  368. package/dist/mjs/functions/math/min/minif.mjs.map +10 -0
  369. package/dist/mjs/functions/math/min/minifs.mjs +35 -0
  370. package/dist/mjs/functions/math/min/minifs.mjs.map +10 -0
  371. package/dist/mjs/functions/math/sum/sum.mjs +18 -0
  372. package/dist/mjs/functions/math/sum/sum.mjs.map +10 -0
  373. package/dist/mjs/functions/math/sum/sumif.mjs +58 -0
  374. package/dist/mjs/functions/math/sum/sumif.mjs.map +10 -0
  375. package/dist/mjs/functions/math/sum/sumifs.mjs +34 -0
  376. package/dist/mjs/functions/math/sum/sumifs.mjs.map +10 -0
  377. package/dist/mjs/functions/math/sum/summation-utils.mjs +27 -0
  378. package/dist/mjs/functions/math/sum/summation-utils.mjs.map +10 -0
  379. package/dist/mjs/functions/reference/address/address.mjs +135 -0
  380. package/dist/mjs/functions/reference/address/address.mjs.map +10 -0
  381. package/dist/mjs/functions/reference/indirect/indirect.mjs +74 -0
  382. package/dist/mjs/functions/reference/indirect/indirect.mjs.map +10 -0
  383. package/dist/mjs/functions/reference/offset/offset.mjs +205 -0
  384. package/dist/mjs/functions/reference/offset/offset.mjs.map +10 -0
  385. package/dist/mjs/functions/text/concatenate/concatenate.mjs +139 -0
  386. package/dist/mjs/functions/text/concatenate/concatenate.mjs.map +10 -0
  387. package/dist/mjs/functions/text/exact/exact.mjs +143 -0
  388. package/dist/mjs/functions/text/exact/exact.mjs.map +10 -0
  389. package/dist/mjs/functions/text/find/find.mjs +369 -0
  390. package/dist/mjs/functions/text/find/find.mjs.map +10 -0
  391. package/dist/mjs/functions/text/left/left.mjs +81 -0
  392. package/dist/mjs/functions/text/left/left.mjs.map +10 -0
  393. package/dist/mjs/functions/text/len/len.mjs +91 -0
  394. package/dist/mjs/functions/text/len/len.mjs.map +10 -0
  395. package/dist/mjs/functions/text/mid/mid.mjs +75 -0
  396. package/dist/mjs/functions/text/mid/mid.mjs.map +10 -0
  397. package/dist/mjs/functions/text/right/right.mjs +143 -0
  398. package/dist/mjs/functions/text/right/right.mjs.map +10 -0
  399. package/dist/mjs/functions/text/text-helpers.mjs +151 -0
  400. package/dist/mjs/functions/text/text-helpers.mjs.map +10 -0
  401. package/dist/mjs/functions/text/textjoin/textjoin.mjs +145 -0
  402. package/dist/mjs/functions/text/textjoin/textjoin.mjs.map +10 -0
  403. package/dist/mjs/package.json +5 -0
  404. package/dist/mjs/parser/ast.mjs +145 -0
  405. package/dist/mjs/parser/ast.mjs.map +10 -0
  406. package/dist/mjs/parser/formatter.mjs +289 -0
  407. package/dist/mjs/parser/formatter.mjs.map +10 -0
  408. package/dist/mjs/parser/grammar.mjs +345 -0
  409. package/dist/mjs/parser/grammar.mjs.map +10 -0
  410. package/dist/mjs/parser/lexer.mjs +412 -0
  411. package/dist/mjs/parser/lexer.mjs.map +10 -0
  412. package/dist/mjs/parser/parser.mjs +1692 -0
  413. package/dist/mjs/parser/parser.mjs.map +10 -0
  414. package/dist/mjs/react/hooks.mjs +16 -0
  415. package/dist/mjs/react/hooks.mjs.map +10 -0
  416. package/dist/types/core/ast-traverser.d.ts +28 -0
  417. package/dist/types/core/autofill-utils.d.ts +32 -0
  418. package/dist/types/core/engine.d.ts +184 -0
  419. package/dist/types/core/managers/cache-manager.d.ts +14 -0
  420. package/dist/types/core/managers/dependency-manager.d.ts +147 -0
  421. package/dist/types/core/managers/dependency-node.d.ts +13 -0
  422. package/dist/types/core/managers/evaluation-manager.d.ts +30 -0
  423. package/dist/types/core/managers/event-manager.d.ts +8 -0
  424. package/dist/types/core/managers/frontier-dependency-manager.d.ts +69 -0
  425. package/dist/types/core/managers/index.d.ts +7 -0
  426. package/dist/types/core/managers/isDependencyNode.d.ts +2 -0
  427. package/dist/types/core/managers/named-expression-manager.d.ts +101 -0
  428. package/dist/types/core/managers/range-eval-order-builder.d.ts +33 -0
  429. package/dist/types/core/managers/table-manager.d.ts +84 -0
  430. package/dist/types/core/managers/workbook-manager.d.ts +136 -0
  431. package/dist/types/core/map-serializer.d.ts +4 -0
  432. package/dist/types/core/named-expression-renamer.d.ts +21 -0
  433. package/dist/types/core/sheet-renamer.d.ts +28 -0
  434. package/dist/types/core/sheet-utils.d.ts +2 -0
  435. package/dist/types/core/table-renamer.d.ts +21 -0
  436. package/dist/types/core/types.d.ts +272 -0
  437. package/dist/types/core/utils/cell-address-parsing.test.d.ts +1 -0
  438. package/dist/types/core/utils/range-serializer.d.ts +22 -0
  439. package/dist/types/core/utils/range-serializer.test.d.ts +1 -0
  440. package/dist/types/core/utils/spreadsheet-visualizer.d.ts +30 -0
  441. package/dist/types/core/utils.d.ts +48 -0
  442. package/dist/types/core/workbook-renamer.d.ts +28 -0
  443. package/dist/types/debug/flags.d.ts +11 -0
  444. package/dist/types/evaluator/arithmetic/add/add.d.ts +2 -0
  445. package/dist/types/evaluator/arithmetic/add/add.test.d.ts +1 -0
  446. package/dist/types/evaluator/arithmetic/divide/divide.d.ts +2 -0
  447. package/dist/types/evaluator/arithmetic/divide/divide.test.d.ts +1 -0
  448. package/dist/types/evaluator/arithmetic/multiply/multiply.d.ts +2 -0
  449. package/dist/types/evaluator/arithmetic/multiply/multiply.test.d.ts +1 -0
  450. package/dist/types/evaluator/arithmetic/power/power.d.ts +2 -0
  451. package/dist/types/evaluator/arithmetic/power/power.test.d.ts +1 -0
  452. package/dist/types/evaluator/arithmetic/subtract/subtract.d.ts +2 -0
  453. package/dist/types/evaluator/arithmetic/subtract/subtract.test.d.ts +1 -0
  454. package/dist/types/evaluator/comparison/comparison-operators.test.d.ts +1 -0
  455. package/dist/types/evaluator/comparison/equals.d.ts +6 -0
  456. package/dist/types/evaluator/comparison/greater-than-or-equal.d.ts +6 -0
  457. package/dist/types/evaluator/comparison/greater-than.d.ts +6 -0
  458. package/dist/types/evaluator/comparison/less-than-or-equal.d.ts +6 -0
  459. package/dist/types/evaluator/comparison/less-than.d.ts +6 -0
  460. package/dist/types/evaluator/comparison/not-equals.d.ts +6 -0
  461. package/dist/types/evaluator/concatenation/concatenate.d.ts +6 -0
  462. package/dist/types/evaluator/concatenation/concatenate.test.d.ts +1 -0
  463. package/dist/types/evaluator/dependency-nodes/ast-evaluation-node.d.ts +12 -0
  464. package/dist/types/evaluator/dependency-nodes/base-eval-node.d.ts +31 -0
  465. package/dist/types/evaluator/dependency-nodes/cell-value-node.d.ts +10 -0
  466. package/dist/types/evaluator/dependency-nodes/empty-cell-evaluation-node.d.ts +17 -0
  467. package/dist/types/evaluator/dependency-nodes/spill-meta-node.d.ts +7 -0
  468. package/dist/types/evaluator/evaluate-scalar-operator.d.ts +12 -0
  469. package/dist/types/evaluator/evaluation-context.d.ts +66 -0
  470. package/dist/types/evaluator/evaluation-error.d.ts +20 -0
  471. package/dist/types/evaluator/formula-evaluator.d.ts +67 -0
  472. package/dist/types/evaluator/open-range-evaluator.test.d.ts +1 -0
  473. package/dist/types/evaluator/range-evaluation-node.d.ts +16 -0
  474. package/dist/types/functions/_template/template.d.ts +5 -0
  475. package/dist/types/functions/_template/template.test.d.ts +1 -0
  476. package/dist/types/functions/array/sequence/performance-test.d.ts +1 -0
  477. package/dist/types/functions/array/sequence/sequence.d.ts +14 -0
  478. package/dist/types/functions/array/sequence/sequence.test.d.ts +1 -0
  479. package/dist/types/functions/criteria-parser.d.ts +27 -0
  480. package/dist/types/functions/criteria-utils.d.ts +61 -0
  481. package/dist/types/functions/function-utils.d.ts +21 -0
  482. package/dist/types/functions/index.d.ts +2 -0
  483. package/dist/types/functions/information/cell/cell.d.ts +24 -0
  484. package/dist/types/functions/information/cell/cell.test.d.ts +1 -0
  485. package/dist/types/functions/information/column/column.d.ts +14 -0
  486. package/dist/types/functions/information/column/column.test.d.ts +1 -0
  487. package/dist/types/functions/information/row/row.d.ts +14 -0
  488. package/dist/types/functions/information/row/row.test.d.ts +1 -0
  489. package/dist/types/functions/logical/and/and.d.ts +5 -0
  490. package/dist/types/functions/logical/and/and.test.d.ts +1 -0
  491. package/dist/types/functions/logical/if/if.d.ts +5 -0
  492. package/dist/types/functions/logical/if/if.test.d.ts +1 -0
  493. package/dist/types/functions/logical/iferror/iferror.d.ts +5 -0
  494. package/dist/types/functions/logical/iferror/iferror.test.d.ts +1 -0
  495. package/dist/types/functions/logical/or/or.d.ts +5 -0
  496. package/dist/types/functions/logical/or/or.test.d.ts +1 -0
  497. package/dist/types/functions/lookup/count/count-utils.d.ts +14 -0
  498. package/dist/types/functions/lookup/count/count.d.ts +21 -0
  499. package/dist/types/functions/lookup/count/count.test.d.ts +1 -0
  500. package/dist/types/functions/lookup/count/countif.d.ts +26 -0
  501. package/dist/types/functions/lookup/count/countif.test.d.ts +1 -0
  502. package/dist/types/functions/lookup/count/countifs.d.ts +21 -0
  503. package/dist/types/functions/lookup/count/countifs.test.d.ts +1 -0
  504. package/dist/types/functions/lookup/index-lookup/index-lookup.d.ts +2 -0
  505. package/dist/types/functions/lookup/index-lookup/index-lookup.test.d.ts +1 -0
  506. package/dist/types/functions/lookup/match/match.d.ts +2 -0
  507. package/dist/types/functions/lookup/match/match.test.d.ts +1 -0
  508. package/dist/types/functions/lookup/xlookup/xlookup.d.ts +2 -0
  509. package/dist/types/functions/lookup/xlookup/xlookup.test.d.ts +1 -0
  510. package/dist/types/functions/math/average/average-utils.d.ts +10 -0
  511. package/dist/types/functions/math/average/average.d.ts +18 -0
  512. package/dist/types/functions/math/average/average.test.d.ts +1 -0
  513. package/dist/types/functions/math/average/averageif.d.ts +23 -0
  514. package/dist/types/functions/math/average/averageif.test.d.ts +1 -0
  515. package/dist/types/functions/math/average/averageifs.d.ts +21 -0
  516. package/dist/types/functions/math/average/averageifs.test.d.ts +1 -0
  517. package/dist/types/functions/math/ceiling/ceiling.d.ts +5 -0
  518. package/dist/types/functions/math/ceiling/ceiling.test.d.ts +1 -0
  519. package/dist/types/functions/math/max/max-utils.d.ts +20 -0
  520. package/dist/types/functions/math/max/max.d.ts +18 -0
  521. package/dist/types/functions/math/max/max.test.d.ts +1 -0
  522. package/dist/types/functions/math/max/maxif.d.ts +23 -0
  523. package/dist/types/functions/math/max/maxif.test.d.ts +1 -0
  524. package/dist/types/functions/math/max/maxifs.d.ts +21 -0
  525. package/dist/types/functions/math/max/maxifs.test.d.ts +1 -0
  526. package/dist/types/functions/math/min/min-utils.d.ts +20 -0
  527. package/dist/types/functions/math/min/min.d.ts +5 -0
  528. package/dist/types/functions/math/min/min.test.d.ts +1 -0
  529. package/dist/types/functions/math/min/minif.d.ts +23 -0
  530. package/dist/types/functions/math/min/minif.test.d.ts +1 -0
  531. package/dist/types/functions/math/min/minifs.d.ts +21 -0
  532. package/dist/types/functions/math/min/minifs.test.d.ts +1 -0
  533. package/dist/types/functions/math/sum/sum.d.ts +5 -0
  534. package/dist/types/functions/math/sum/sum.test.d.ts +1 -0
  535. package/dist/types/functions/math/sum/sumif.d.ts +23 -0
  536. package/dist/types/functions/math/sum/sumif.test.d.ts +1 -0
  537. package/dist/types/functions/math/sum/sumifs.d.ts +21 -0
  538. package/dist/types/functions/math/sum/sumifs.test.d.ts +1 -0
  539. package/dist/types/functions/math/sum/summation-utils.d.ts +19 -0
  540. package/dist/types/functions/reference/address/address.d.ts +18 -0
  541. package/dist/types/functions/reference/address/address.test.d.ts +1 -0
  542. package/dist/types/functions/reference/indirect/indirect.d.ts +20 -0
  543. package/dist/types/functions/reference/indirect/indirect.test.d.ts +1 -0
  544. package/dist/types/functions/reference/offset/offset.d.ts +23 -0
  545. package/dist/types/functions/reference/offset/offset.test.d.ts +1 -0
  546. package/dist/types/functions/text/concatenate/concatenate.d.ts +5 -0
  547. package/dist/types/functions/text/concatenate/concatenate.test.d.ts +1 -0
  548. package/dist/types/functions/text/exact/exact.d.ts +5 -0
  549. package/dist/types/functions/text/exact/exact.test.d.ts +1 -0
  550. package/dist/types/functions/text/find/find.d.ts +20 -0
  551. package/dist/types/functions/text/find/find.test.d.ts +1 -0
  552. package/dist/types/functions/text/left/left.d.ts +19 -0
  553. package/dist/types/functions/text/left/left.test.d.ts +1 -0
  554. package/dist/types/functions/text/len/len.d.ts +16 -0
  555. package/dist/types/functions/text/len/len.test.d.ts +1 -0
  556. package/dist/types/functions/text/mid/mid.d.ts +20 -0
  557. package/dist/types/functions/text/mid/mid.test.d.ts +1 -0
  558. package/dist/types/functions/text/right/right.d.ts +2 -0
  559. package/dist/types/functions/text/right/right.test.d.ts +1 -0
  560. package/dist/types/functions/text/text-helpers.d.ts +27 -0
  561. package/dist/types/functions/text/textjoin/textjoin.d.ts +5 -0
  562. package/dist/types/functions/text/textjoin/textjoin.test.d.ts +1 -0
  563. package/dist/types/parser/ast.d.ts +275 -0
  564. package/dist/types/parser/formatter.d.ts +6 -0
  565. package/dist/types/parser/grammar.d.ts +203 -0
  566. package/dist/types/parser/lexer.d.ts +144 -0
  567. package/dist/types/parser/parser.d.ts +159 -0
  568. package/dist/types/react/hooks.d.ts +5 -0
  569. package/package.json +41 -0
@@ -0,0 +1,397 @@
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/functions/text/find/find.ts
30
+ var exports_find = {};
31
+ __export(exports_find, {
32
+ FIND: () => FIND
33
+ });
34
+ module.exports = __toCommonJS(exports_find);
35
+ var import_types = require("src/core/types");
36
+ var import_text_helpers = require("../text-helpers.cjs");
37
+ function findOperation(findTextResult, withinTextResult, startNumResult, context) {
38
+ const findStr = import_text_helpers.convertToString(findTextResult, context);
39
+ const withinStr = import_text_helpers.convertToString(withinTextResult, context);
40
+ const startNum = import_text_helpers.extractNumericValue(startNumResult, context);
41
+ if (typeof findStr === "object" && (findStr.type === "awaiting-evaluation" || findStr.type === "error")) {
42
+ return findStr;
43
+ }
44
+ if (typeof withinStr === "object" && (withinStr.type === "awaiting-evaluation" || withinStr.type === "error")) {
45
+ return withinStr;
46
+ }
47
+ if (typeof startNum === "object" && (startNum.type === "awaiting-evaluation" || startNum.type === "error")) {
48
+ return startNum;
49
+ }
50
+ const findValue = findStr;
51
+ const withinValue = withinStr;
52
+ const startNumValue = startNum;
53
+ if (startNumValue < 1) {
54
+ return {
55
+ type: "error",
56
+ err: import_types.FormulaError.VALUE,
57
+ message: "Text not found #2",
58
+ errAddress: context.dependencyNode
59
+ };
60
+ }
61
+ const start = Math.floor(startNumValue) - 1;
62
+ if (start >= withinValue.length) {
63
+ return {
64
+ type: "error",
65
+ err: import_types.FormulaError.VALUE,
66
+ message: "Text not found #2",
67
+ errAddress: context.dependencyNode
68
+ };
69
+ }
70
+ const index = withinValue.indexOf(findValue, start);
71
+ if (index === -1) {
72
+ return {
73
+ type: "error",
74
+ err: import_types.FormulaError.VALUE,
75
+ message: "Text not found #2",
76
+ errAddress: context.dependencyNode
77
+ };
78
+ }
79
+ return { type: "number", value: index + 1 };
80
+ }
81
+ function createFindSpilledResult({
82
+ findTextResult,
83
+ withinTextResult,
84
+ startNumResult,
85
+ context
86
+ }) {
87
+ if (findTextResult.type === "spilled-values" && withinTextResult.type === "spilled-values") {
88
+ return {
89
+ type: "spilled-values",
90
+ spillArea: (origin) => {
91
+ let spillArea = this.unionRanges(this.projectRange(findTextResult.spillArea(origin), origin), this.projectRange(withinTextResult.spillArea(origin), origin));
92
+ if (startNumResult.type === "spilled-values") {
93
+ spillArea = this.unionRanges(spillArea, this.projectRange(startNumResult.spillArea(origin), origin));
94
+ }
95
+ return spillArea;
96
+ },
97
+ source: "FIND with zipped spilled findText and withinText values",
98
+ evaluate: (spillOffset, evalContext) => {
99
+ const spillFindResult = findTextResult.evaluate(spillOffset, evalContext);
100
+ const spillWithinResult = withinTextResult.evaluate(spillOffset, evalContext);
101
+ if (!spillFindResult || spillFindResult.type === "error") {
102
+ return spillFindResult;
103
+ }
104
+ if (!spillWithinResult || spillWithinResult.type === "error") {
105
+ return spillWithinResult;
106
+ }
107
+ let startNumArg = startNumResult;
108
+ if (startNumResult.type === "spilled-values") {
109
+ const spillStartNumResult = startNumResult.evaluate(spillOffset, evalContext);
110
+ if (!spillStartNumResult || spillStartNumResult.type === "error") {
111
+ return spillStartNumResult;
112
+ }
113
+ startNumArg = spillStartNumResult;
114
+ }
115
+ const result = findOperation(spillFindResult, spillWithinResult, startNumArg, evalContext);
116
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
117
+ return result;
118
+ }
119
+ return {
120
+ type: "value",
121
+ result
122
+ };
123
+ },
124
+ evaluateAllCells: (intersectingRange) => {
125
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
126
+ }
127
+ };
128
+ } else if (findTextResult.type === "spilled-values" && withinTextResult.type !== "spilled-values" && startNumResult.type !== "spilled-values") {
129
+ return {
130
+ type: "spilled-values",
131
+ spillArea: (origin) => {
132
+ return findTextResult.spillArea(origin);
133
+ },
134
+ source: "FIND with spilled findText values",
135
+ evaluate: (spillOffset, evalContext) => {
136
+ const spillResult = findTextResult.evaluate(spillOffset, evalContext);
137
+ if (!spillResult || spillResult.type === "error") {
138
+ return spillResult;
139
+ }
140
+ const result = findOperation(spillResult, withinTextResult, startNumResult, evalContext);
141
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
142
+ return result;
143
+ }
144
+ return {
145
+ type: "value",
146
+ result
147
+ };
148
+ },
149
+ evaluateAllCells: (intersectingRange) => {
150
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
151
+ }
152
+ };
153
+ } else if (withinTextResult.type === "spilled-values" && findTextResult.type !== "spilled-values" && startNumResult.type !== "spilled-values") {
154
+ return {
155
+ type: "spilled-values",
156
+ spillArea: (origin) => withinTextResult.spillArea(origin),
157
+ source: "FIND with spilled withinText values",
158
+ evaluate: (spillOffset, evalContext) => {
159
+ const spillResult = withinTextResult.evaluate(spillOffset, evalContext);
160
+ if (!spillResult || spillResult.type === "error") {
161
+ return spillResult;
162
+ }
163
+ const result = findOperation(findTextResult, spillResult, startNumResult, evalContext);
164
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
165
+ return result;
166
+ }
167
+ return {
168
+ type: "value",
169
+ result
170
+ };
171
+ },
172
+ evaluateAllCells: (intersectingRange) => {
173
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
174
+ }
175
+ };
176
+ } else if (findTextResult.type === "spilled-values" && startNumResult.type === "spilled-values" && withinTextResult.type !== "spilled-values") {
177
+ if (withinTextResult.type !== "value") {
178
+ return {
179
+ type: "error",
180
+ err: import_types.FormulaError.VALUE,
181
+ message: "Invalid withinText argument",
182
+ errAddress: context.dependencyNode
183
+ };
184
+ }
185
+ if (withinTextResult.result.type !== "string") {
186
+ return {
187
+ type: "error",
188
+ err: import_types.FormulaError.VALUE,
189
+ message: "WithinText argument must be a string",
190
+ errAddress: context.dependencyNode
191
+ };
192
+ }
193
+ return {
194
+ type: "spilled-values",
195
+ spillArea: (origin) => {
196
+ const spillArea = this.unionRanges(this.projectRange(findTextResult.spillArea(origin), origin), this.projectRange(startNumResult.spillArea(origin), origin));
197
+ return spillArea;
198
+ },
199
+ source: "FIND with spilled findText and startNum values",
200
+ evaluate: (spillOffset, evalContext) => {
201
+ const spillFindResult = findTextResult.evaluate(spillOffset, evalContext);
202
+ const spillStartNumResult = startNumResult.evaluate(spillOffset, evalContext);
203
+ if (!spillFindResult || spillFindResult.type === "error") {
204
+ return spillFindResult;
205
+ }
206
+ if (!spillStartNumResult || spillStartNumResult.type === "error") {
207
+ return spillStartNumResult;
208
+ }
209
+ const result = findOperation(spillFindResult, withinTextResult, spillStartNumResult, evalContext);
210
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
211
+ return result;
212
+ }
213
+ return {
214
+ type: "value",
215
+ result
216
+ };
217
+ },
218
+ evaluateAllCells: (intersectingRange) => {
219
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
220
+ }
221
+ };
222
+ } else if (withinTextResult.type === "spilled-values" && startNumResult.type === "spilled-values" && findTextResult.type !== "spilled-values") {
223
+ if (findTextResult.type !== "value") {
224
+ return {
225
+ type: "error",
226
+ err: import_types.FormulaError.VALUE,
227
+ message: "Invalid findText argument",
228
+ errAddress: context.dependencyNode
229
+ };
230
+ }
231
+ if (findTextResult.result.type !== "string") {
232
+ return {
233
+ type: "error",
234
+ err: import_types.FormulaError.VALUE,
235
+ message: "FindText argument must be a string",
236
+ errAddress: context.dependencyNode
237
+ };
238
+ }
239
+ return {
240
+ type: "spilled-values",
241
+ spillArea: (origin) => {
242
+ const spillArea = this.unionRanges(this.projectRange(withinTextResult.spillArea(origin), origin), this.projectRange(startNumResult.spillArea(origin), origin));
243
+ return spillArea;
244
+ },
245
+ source: "FIND with spilled withinText and startNum values",
246
+ evaluate: (spillOffset, evalContext) => {
247
+ const spillWithinResult = withinTextResult.evaluate(spillOffset, evalContext);
248
+ const spillStartNumResult = startNumResult.evaluate(spillOffset, evalContext);
249
+ if (!spillWithinResult || spillWithinResult.type === "error") {
250
+ return spillWithinResult;
251
+ }
252
+ if (!spillStartNumResult || spillStartNumResult.type === "error") {
253
+ return spillStartNumResult;
254
+ }
255
+ const result = findOperation(findTextResult, spillWithinResult, spillStartNumResult, evalContext);
256
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
257
+ return result;
258
+ }
259
+ return {
260
+ type: "value",
261
+ result
262
+ };
263
+ },
264
+ evaluateAllCells: (intersectingRange) => {
265
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
266
+ }
267
+ };
268
+ } else if (startNumResult.type === "spilled-values" && findTextResult.type !== "spilled-values" && withinTextResult.type !== "spilled-values") {
269
+ if (findTextResult.type !== "value") {
270
+ return findTextResult;
271
+ }
272
+ if (withinTextResult.type !== "value") {
273
+ return withinTextResult;
274
+ }
275
+ if (findTextResult.result.type !== "string") {
276
+ return {
277
+ type: "error",
278
+ err: import_types.FormulaError.VALUE,
279
+ message: "FindText argument must be a string",
280
+ errAddress: context.dependencyNode
281
+ };
282
+ }
283
+ if (withinTextResult.result.type !== "string") {
284
+ return {
285
+ type: "error",
286
+ err: import_types.FormulaError.VALUE,
287
+ message: "WithinText argument must be a string",
288
+ errAddress: context.dependencyNode
289
+ };
290
+ }
291
+ return {
292
+ type: "spilled-values",
293
+ spillArea: (origin) => startNumResult.spillArea(origin),
294
+ source: "FIND with spilled startNum values",
295
+ evaluate: (spillOffset, evalContext) => {
296
+ const spillResult = startNumResult.evaluate(spillOffset, evalContext);
297
+ if (!spillResult || spillResult.type === "error") {
298
+ return spillResult;
299
+ }
300
+ if (spillResult.type !== "value") {
301
+ return spillResult;
302
+ }
303
+ const startNumArg = {
304
+ type: "value",
305
+ result: spillResult.result
306
+ };
307
+ const result = findOperation(findTextResult, withinTextResult, startNumArg, evalContext);
308
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
309
+ return result;
310
+ }
311
+ return {
312
+ type: "value",
313
+ result
314
+ };
315
+ },
316
+ evaluateAllCells: (intersectingRange) => {
317
+ throw new Error("WIP: evaluateAllCells for FIND is not implemented");
318
+ }
319
+ };
320
+ }
321
+ return {
322
+ type: "error",
323
+ err: import_types.FormulaError.VALUE,
324
+ message: "Invalid arguments for FIND",
325
+ errAddress: context.dependencyNode
326
+ };
327
+ }
328
+ var FIND = {
329
+ name: "FIND",
330
+ evaluate: function(node, context) {
331
+ if (node.args.length < 2 || node.args.length > 3) {
332
+ return {
333
+ type: "error",
334
+ err: import_types.FormulaError.VALUE,
335
+ message: "FIND function takes 2 or 3 arguments",
336
+ errAddress: context.dependencyNode
337
+ };
338
+ }
339
+ const findTextResult = this.evaluateNode(node.args[0], context);
340
+ if (findTextResult.type === "error") {
341
+ return findTextResult;
342
+ }
343
+ const withinTextResult = this.evaluateNode(node.args[1], context);
344
+ if (withinTextResult.type === "error") {
345
+ return withinTextResult;
346
+ }
347
+ let startNumResult;
348
+ if (node.args.length > 2) {
349
+ startNumResult = this.evaluateNode(node.args[2], context);
350
+ } else {
351
+ startNumResult = {
352
+ type: "value",
353
+ result: { type: "number", value: 1 }
354
+ };
355
+ }
356
+ if (findTextResult.type === "spilled-values" || withinTextResult.type === "spilled-values" || startNumResult.type === "spilled-values") {
357
+ return createFindSpilledResult.call(this, {
358
+ findTextResult,
359
+ withinTextResult,
360
+ startNumResult,
361
+ context
362
+ });
363
+ }
364
+ if (findTextResult.type === "awaiting-evaluation") {
365
+ return findTextResult;
366
+ }
367
+ if (withinTextResult.type === "awaiting-evaluation") {
368
+ return withinTextResult;
369
+ }
370
+ if (findTextResult.result.type !== "string") {
371
+ return {
372
+ type: "error",
373
+ err: import_types.FormulaError.VALUE,
374
+ message: "FindText argument must be a string",
375
+ errAddress: context.dependencyNode
376
+ };
377
+ }
378
+ if (withinTextResult.result.type !== "string") {
379
+ return {
380
+ type: "error",
381
+ err: import_types.FormulaError.VALUE,
382
+ message: "WithinText argument must be a string",
383
+ errAddress: context.dependencyNode
384
+ };
385
+ }
386
+ const result = findOperation(findTextResult, withinTextResult, startNumResult, context);
387
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
388
+ return result;
389
+ }
390
+ return {
391
+ type: "value",
392
+ result
393
+ };
394
+ }
395
+ };
396
+
397
+ //# debugId=5159A9608D2C084264756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/functions/text/find/find.ts"],
4
+ "sourcesContent": [
5
+ "import {\n FormulaError,\n type CellNumber,\n type FunctionDefinition,\n type FunctionEvaluationResult,\n type ValueEvaluationResult,\n type CellAddress,\n type ErrorEvaluationResult,\n} from \"src/core/types\";\nimport type { FormulaEngine } from \"src/core/engine\";\nimport { convertToString, extractNumericValue } from \"../text-helpers.cjs\";\nimport type { FormulaEvaluator } from \"src/evaluator/formula-evaluator\";\nimport type { EvaluationContext } from \"src/evaluator/evaluation-context\";\n\n// Helper function for FIND operation - returns the result, error, or null if not found\nfunction findOperation(\n findTextResult: FunctionEvaluationResult,\n withinTextResult: FunctionEvaluationResult,\n startNumResult: FunctionEvaluationResult,\n context: EvaluationContext\n): CellNumber | ErrorEvaluationResult {\n const findStr = convertToString(findTextResult, context);\n const withinStr = convertToString(withinTextResult, context);\n const startNum = extractNumericValue(startNumResult, context);\n\n // Check if any of the results are awaiting evaluation or errors\n if (\n typeof findStr === \"object\" &&\n (findStr.type === \"awaiting-evaluation\" || findStr.type === \"error\")\n ) {\n return findStr;\n }\n if (\n typeof withinStr === \"object\" &&\n (withinStr.type === \"awaiting-evaluation\" || withinStr.type === \"error\")\n ) {\n return withinStr;\n }\n if (\n typeof startNum === \"object\" &&\n (startNum.type === \"awaiting-evaluation\" || startNum.type === \"error\")\n ) {\n return startNum;\n }\n\n // At this point, all values should be primitive types\n const findValue = findStr as string;\n const withinValue = withinStr as string;\n const startNumValue = startNum as number;\n\n // Validate startNum\n if (startNumValue < 1) {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Text not found #2\",\n errAddress: context.dependencyNode,\n };\n }\n\n const start = Math.floor(startNumValue) - 1; // Convert to 0-based index\n\n if (start >= withinValue.length) {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Text not found #2\",\n errAddress: context.dependencyNode,\n };\n }\n\n const index = withinValue.indexOf(findValue, start);\n if (index === -1) {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Text not found #2\",\n errAddress: context.dependencyNode,\n };\n }\n\n return { type: \"number\", value: index + 1 }; // Convert back to 1-based index\n}\n\n/**\n * Helper for creating spilled-values result for FIND function\n */\nfunction createFindSpilledResult(\n this: FormulaEvaluator,\n {\n findTextResult,\n withinTextResult,\n startNumResult,\n context,\n }: {\n findTextResult: FunctionEvaluationResult;\n withinTextResult: FunctionEvaluationResult;\n startNumResult: FunctionEvaluationResult;\n context: EvaluationContext;\n }\n): FunctionEvaluationResult {\n // If both findText and withinText are spilled-values, we need to zip them together\n if (\n findTextResult.type === \"spilled-values\" &&\n withinTextResult.type === \"spilled-values\"\n ) {\n return {\n type: \"spilled-values\",\n spillArea: (origin: CellAddress) => {\n // Create unified spill area (union of all spilled ranges)\n let spillArea = this.unionRanges(\n this.projectRange(findTextResult.spillArea(origin), origin),\n this.projectRange(withinTextResult.spillArea(origin), origin)\n );\n\n // Also include startNum spill area if it's spilled\n if (startNumResult.type === \"spilled-values\") {\n spillArea = this.unionRanges(\n spillArea,\n this.projectRange(startNumResult.spillArea(origin), origin)\n );\n }\n return spillArea;\n },\n source: \"FIND with zipped spilled findText and withinText values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n // Evaluate both spilled arrays at this position\n const spillFindResult = findTextResult.evaluate(\n spillOffset,\n evalContext\n );\n const spillWithinResult = withinTextResult.evaluate(\n spillOffset,\n evalContext\n );\n\n if (!spillFindResult || spillFindResult.type === \"error\") {\n return spillFindResult;\n }\n if (!spillWithinResult || spillWithinResult.type === \"error\") {\n return spillWithinResult;\n }\n\n // Handle startNum - evaluate if spilled, otherwise use as-is\n let startNumArg = startNumResult;\n if (startNumResult.type === \"spilled-values\") {\n const spillStartNumResult = startNumResult.evaluate(\n spillOffset,\n evalContext\n );\n if (!spillStartNumResult || spillStartNumResult.type === \"error\") {\n return spillStartNumResult;\n }\n startNumArg = spillStartNumResult;\n }\n\n const result = findOperation(\n spillFindResult,\n spillWithinResult,\n startNumArg,\n evalContext\n );\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n // If only findText is spilled-values\n else if (\n findTextResult.type === \"spilled-values\" &&\n withinTextResult.type !== \"spilled-values\" &&\n startNumResult.type !== \"spilled-values\"\n ) {\n return {\n type: \"spilled-values\",\n spillArea: (origin: CellAddress) => {\n return findTextResult.spillArea(origin);\n },\n source: \"FIND with spilled findText values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n const spillResult = findTextResult.evaluate(spillOffset, evalContext);\n if (!spillResult || spillResult.type === \"error\") {\n return spillResult;\n }\n const result = findOperation(\n spillResult,\n withinTextResult,\n startNumResult,\n evalContext\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n // If only withinText is spilled-values\n else if (\n withinTextResult.type === \"spilled-values\" &&\n findTextResult.type !== \"spilled-values\" &&\n startNumResult.type !== \"spilled-values\"\n ) {\n return {\n type: \"spilled-values\",\n spillArea: (origin) => withinTextResult.spillArea(origin),\n source: \"FIND with spilled withinText values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n const spillResult = withinTextResult.evaluate(spillOffset, evalContext);\n if (!spillResult || spillResult.type === \"error\") {\n return spillResult;\n }\n const result = findOperation(\n findTextResult,\n spillResult,\n startNumResult,\n evalContext\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n // If findText and startNum are spilled (but not withinText)\n else if (\n findTextResult.type === \"spilled-values\" &&\n startNumResult.type === \"spilled-values\" &&\n withinTextResult.type !== \"spilled-values\"\n ) {\n if (withinTextResult.type !== \"value\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Invalid withinText argument\",\n errAddress: context.dependencyNode,\n };\n }\n\n // Strict type checking\n if (withinTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"WithinText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n return {\n type: \"spilled-values\",\n spillArea: (origin: CellAddress) => {\n // Create unified spill area (union of both ranges)\n const spillArea = this.unionRanges(\n this.projectRange(findTextResult.spillArea(origin), origin),\n this.projectRange(startNumResult.spillArea(origin), origin)\n );\n return spillArea;\n },\n source: \"FIND with spilled findText and startNum values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n // Evaluate both spilled arrays at this position\n const spillFindResult = findTextResult.evaluate(\n spillOffset,\n evalContext\n );\n const spillStartNumResult = startNumResult.evaluate(\n spillOffset,\n evalContext\n );\n\n if (!spillFindResult || spillFindResult.type === \"error\") {\n return spillFindResult;\n }\n if (!spillStartNumResult || spillStartNumResult.type === \"error\") {\n return spillStartNumResult;\n }\n\n const result = findOperation(\n spillFindResult,\n withinTextResult,\n spillStartNumResult,\n evalContext\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n // If withinText and startNum are spilled (but not findText)\n else if (\n withinTextResult.type === \"spilled-values\" &&\n startNumResult.type === \"spilled-values\" &&\n findTextResult.type !== \"spilled-values\"\n ) {\n if (findTextResult.type !== \"value\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Invalid findText argument\",\n errAddress: context.dependencyNode,\n };\n }\n\n // Strict type checking\n if (findTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"FindText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n return {\n type: \"spilled-values\",\n spillArea: (origin: CellAddress) => {\n // Create unified spill area (union of both ranges)\n const spillArea = this.unionRanges(\n this.projectRange(withinTextResult.spillArea(origin), origin),\n this.projectRange(startNumResult.spillArea(origin), origin)\n );\n return spillArea;\n },\n source: \"FIND with spilled withinText and startNum values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n // Evaluate both spilled arrays at this position\n const spillWithinResult = withinTextResult.evaluate(\n spillOffset,\n evalContext\n );\n const spillStartNumResult = startNumResult.evaluate(\n spillOffset,\n evalContext\n );\n\n if (!spillWithinResult || spillWithinResult.type === \"error\") {\n return spillWithinResult;\n }\n if (!spillStartNumResult || spillStartNumResult.type === \"error\") {\n return spillStartNumResult;\n }\n\n const result = findOperation(\n findTextResult,\n spillWithinResult,\n spillStartNumResult,\n evalContext\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n // If only startNum is spilled-values\n else if (\n startNumResult.type === \"spilled-values\" &&\n findTextResult.type !== \"spilled-values\" &&\n withinTextResult.type !== \"spilled-values\"\n ) {\n if (findTextResult.type !== \"value\") {\n return findTextResult;\n }\n if (withinTextResult.type !== \"value\") {\n return withinTextResult;\n }\n\n // Strict type checking\n if (findTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"FindText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n if (withinTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"WithinText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n return {\n type: \"spilled-values\",\n spillArea: (origin: CellAddress) => startNumResult.spillArea(origin),\n source: \"FIND with spilled startNum values\",\n evaluate: (spillOffset, evalContext: EvaluationContext) => {\n const spillResult = startNumResult.evaluate(spillOffset, evalContext);\n if (!spillResult || spillResult.type === \"error\") {\n return spillResult;\n }\n\n // Create a proper startNum argument for findOperation\n if (spillResult.type !== \"value\") {\n return spillResult;\n }\n const startNumArg: ValueEvaluationResult = {\n type: \"value\",\n result: spillResult.result,\n };\n\n const result = findOperation(\n findTextResult,\n withinTextResult,\n startNumArg,\n evalContext\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result,\n };\n },\n evaluateAllCells: (intersectingRange) => {\n throw new Error(\"WIP: evaluateAllCells for FIND is not implemented\");\n },\n };\n }\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Invalid arguments for FIND\",\n errAddress: context.dependencyNode,\n };\n}\n\n/**\n * FIND function - Finds one text string within another (case-sensitive)\n *\n * Usage: FIND(find_text, within_text, [start_num])\n *\n * find_text: The text you want to find.\n * within_text: The text containing the text you want to find.\n * start_num: [Optional] The character at which to start the search (default: 1).\n *\n * Example: FIND(\"World\", \"Hello World\", 1) returns 7\n *\n * Note:\n * - The search is case-sensitive\n * - Returns the position of the first character of find_text within within_text\n * - Returns #VALUE! error if text is not found\n * - Supports dynamic arrays (spilled values) for find_text and within_text\n * - Strict type checking: text arguments must be strings, start_num must be number\n */\nexport const FIND: FunctionDefinition = {\n name: \"FIND\",\n evaluate: function (node, context): FunctionEvaluationResult {\n if (node.args.length < 2 || node.args.length > 3) {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"FIND function takes 2 or 3 arguments\",\n errAddress: context.dependencyNode,\n };\n }\n\n // Evaluate findText argument\n const findTextResult = this.evaluateNode(node.args[0]!, context);\n if (findTextResult.type === \"error\") {\n return findTextResult;\n }\n\n // Evaluate withinText argument\n const withinTextResult = this.evaluateNode(node.args[1]!, context);\n if (withinTextResult.type === \"error\") {\n return withinTextResult;\n }\n\n // Evaluate startNum argument (optional, defaults to 1)\n let startNumResult: FunctionEvaluationResult;\n if (node.args.length > 2) {\n startNumResult = this.evaluateNode(node.args[2]!, context);\n } else {\n startNumResult = {\n type: \"value\",\n result: { type: \"number\", value: 1 },\n };\n }\n\n // Handle spilled-values inputs - return spilled-values for spilling\n if (\n findTextResult.type === \"spilled-values\" ||\n withinTextResult.type === \"spilled-values\" ||\n startNumResult.type === \"spilled-values\"\n ) {\n return createFindSpilledResult.call(this, {\n findTextResult,\n withinTextResult,\n startNumResult,\n context,\n });\n }\n\n if (findTextResult.type === \"awaiting-evaluation\") {\n return findTextResult;\n }\n if (withinTextResult.type === \"awaiting-evaluation\") {\n return withinTextResult;\n }\n\n // Strict type checking - no coercion\n if (findTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"FindText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n if (withinTextResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"WithinText argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n const result = findOperation(\n findTextResult,\n withinTextResult,\n startNumResult,\n context\n );\n\n // Handle error or awaiting evaluation results\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n\n return {\n type: \"value\",\n result: result,\n };\n },\n};\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO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A,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEA,IAAI,eAAe,SAAS,uBAAuB;AAAA,MACjD,OAAO;AAAA,IACT;AAAA,IACA,IAAI,iBAAiB,SAAS,uBAAuB;AAAA,MACnD,OAAO;AAAA,IACT;AAAA,IAGA,IAAI,eAAe,OAAO,SAAS,UAAU;AAAA,MAC3C,OAAO;AAAA,QACL,MAAM;AAAA,QACN,KAAK,0BAAa;AAAA,QAClB,SAAS;AAAA,QACT,YAAY,QAAQ;AAAA,MACtB;AAAA,IACF;AAAA,IAEA,IAAI,iBAAiB,OAAO,SAAS,UAAU;AAAA,MAC7C,OAAO;AAAA,QACL,MAAM;AAAA,QACN,KAAK,0BAAa;AAAA,QAClB,SAAS;AAAA,QACT,YAAY,QAAQ;AAAA,MACtB;AAAA,IACF;AAAA,IAEA,MAAM,SAAS,cACb,gBACA,kBACA,gBACA,OACF;AAAA,IAGA,IAAI,OAAO,SAAS,WAAW,OAAO,SAAS,uBAAuB;AAAA,MACpE,OAAO;AAAA,IACT;AAAA,IAEA,OAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,IACF;AAAA;AAEJ;",
8
+ "debugId": "5159A9608D2C084264756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,109 @@
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/functions/text/left/left.ts
30
+ var exports_left = {};
31
+ __export(exports_left, {
32
+ LEFT: () => LEFT
33
+ });
34
+ module.exports = __toCommonJS(exports_left);
35
+ var import_types = require("src/core/types");
36
+ var import_text_helpers = require("../text-helpers.cjs");
37
+ var LEFT = {
38
+ name: "LEFT",
39
+ evaluate: function(node, context) {
40
+ if (node.args.length < 1 || node.args.length > 2) {
41
+ return {
42
+ type: "error",
43
+ err: import_types.FormulaError.VALUE,
44
+ message: "LEFT function takes 1 or 2 arguments",
45
+ errAddress: context.dependencyNode
46
+ };
47
+ }
48
+ const textResult = this.evaluateNode(node.args[0], context);
49
+ if (textResult.type === "error") {
50
+ return textResult;
51
+ }
52
+ let numCharsResult;
53
+ if (node.args.length > 1) {
54
+ numCharsResult = this.evaluateNode(node.args[1], context);
55
+ if (numCharsResult.type === "error") {
56
+ return numCharsResult;
57
+ }
58
+ } else {
59
+ numCharsResult = {
60
+ type: "value",
61
+ result: { type: "number", value: 1 }
62
+ };
63
+ }
64
+ const startNumResult = {
65
+ type: "value",
66
+ result: { type: "number", value: 1 }
67
+ };
68
+ if (textResult.type === "spilled-values" || numCharsResult.type === "spilled-values") {
69
+ return import_text_helpers.createMidSpilledResult.call(this, {
70
+ textResult,
71
+ startNumResult,
72
+ numCharsResult,
73
+ context
74
+ });
75
+ }
76
+ if (textResult.type === "awaiting-evaluation") {
77
+ return textResult;
78
+ }
79
+ if (numCharsResult.type === "awaiting-evaluation") {
80
+ return numCharsResult;
81
+ }
82
+ if (textResult.result.type !== "string") {
83
+ return {
84
+ type: "error",
85
+ err: import_types.FormulaError.VALUE,
86
+ message: "Text argument must be a string",
87
+ errAddress: context.dependencyNode
88
+ };
89
+ }
90
+ if (numCharsResult.result.type !== "number") {
91
+ return {
92
+ type: "error",
93
+ err: import_types.FormulaError.VALUE,
94
+ message: "NumChars argument must be a number",
95
+ errAddress: context.dependencyNode
96
+ };
97
+ }
98
+ const result = import_text_helpers.midOperation(textResult, startNumResult, numCharsResult, context);
99
+ if (result.type === "error" || result.type === "awaiting-evaluation") {
100
+ return result;
101
+ }
102
+ return {
103
+ type: "value",
104
+ result: result.result
105
+ };
106
+ }
107
+ };
108
+
109
+ //# debugId=5DF7F73BD93E071864756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/functions/text/left/left.ts"],
4
+ "sourcesContent": [
5
+ "import {\n FormulaError,\n type FunctionDefinition,\n type FunctionEvaluationResult,\n} from \"src/core/types\";\nimport { midOperation, createMidSpilledResult } from \"../text-helpers.cjs\";\n\n/**\n * LEFT function - Returns the leftmost characters from a text string\n *\n * Usage: LEFT(text, num_chars)\n *\n * text: The text string to extract characters from.\n * num_chars: The number of characters to extract from the left side of the text.\n *\n * Example: LEFT(\"Hello, World!\", 5) returns \"Hello\"\n *\n * Note:\n * - If num_chars is less than 0, the function returns an error.\n * - If num_chars is greater than the length of text, the function returns the entire text.\n * - Supports dynamic arrays (spilled values) for both arguments\n * - Strict type checking: text must be string, num_chars must be number\n * - Implemented as MID(text, 1, num_chars)\n */\nexport const LEFT: FunctionDefinition = {\n name: \"LEFT\",\n evaluate: function (node, context): FunctionEvaluationResult {\n if (node.args.length < 1 || node.args.length > 2) {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"LEFT function takes 1 or 2 arguments\",\n errAddress: context.dependencyNode,\n };\n }\n\n // Evaluate the text argument\n const textResult = this.evaluateNode(node.args[0]!, context);\n if (textResult.type === \"error\") {\n return textResult;\n }\n\n // Evaluate the numChars argument (optional, defaults to 1)\n let numCharsResult: FunctionEvaluationResult;\n if (node.args.length > 1) {\n numCharsResult = this.evaluateNode(node.args[1]!, context);\n if (numCharsResult.type === \"error\") {\n return numCharsResult;\n }\n } else {\n numCharsResult = {\n type: \"value\",\n result: { type: \"number\", value: 1 },\n };\n }\n\n // Create start_num argument (always 1 for LEFT)\n const startNumResult: FunctionEvaluationResult = {\n type: \"value\",\n result: { type: \"number\", value: 1 },\n };\n\n // Handle spilled-values inputs using MID's spilled result handler\n if (textResult.type === \"spilled-values\" || numCharsResult.type === \"spilled-values\") {\n return createMidSpilledResult.call(this, {\n textResult,\n startNumResult,\n numCharsResult,\n context,\n });\n }\n\n // Both arguments are single values\n if (textResult.type === \"awaiting-evaluation\") {\n return textResult;\n }\n\n if (numCharsResult.type === \"awaiting-evaluation\") {\n return numCharsResult;\n }\n\n // Strict type checking - no coercion\n if (textResult.result.type !== \"string\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"Text argument must be a string\",\n errAddress: context.dependencyNode,\n };\n }\n\n if (numCharsResult.result.type !== \"number\") {\n return {\n type: \"error\",\n err: FormulaError.VALUE,\n message: \"NumChars argument must be a number\",\n errAddress: context.dependencyNode,\n };\n }\n\n // Use MID operation: LEFT(text, num_chars) = MID(text, 1, num_chars)\n const result = midOperation(textResult, startNumResult, numCharsResult, context);\n if (result.type === \"error\" || result.type === \"awaiting-evaluation\") {\n return result;\n }\n return {\n type: \"value\",\n result: result.result,\n };\n },\n};"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAJP;AAKqD,IAArD;AAmBO,IAAM,OAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU,QAAS,CAAC,MAAM,SAAmC;AAAA,IAC3D,IAAI,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,SAAS,GAAG;AAAA,MAChD,OAAO;AAAA,QACL,MAAM;AAAA,QACN,KAAK,0BAAa;AAAA,QAClB,SAAS;AAAA,QACT,YAAY,QAAQ;AAAA,MACtB;AAAA,IACF;AAAA,IAGA,MAAM,aAAa,KAAK,aA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