@math.gl/sql 0.0.0-stage → 5.0.0-beta.12

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 (353) hide show
  1. package/LICENSE +249 -0
  2. package/README.md +26 -2
  3. package/THIRD-PARTY-NOTICES.md +5 -0
  4. package/dist/arrow/aggregates.d.ts +46 -0
  5. package/dist/arrow/aggregates.d.ts.map +1 -0
  6. package/dist/arrow/aggregates.js +289 -0
  7. package/dist/arrow/aggregates.js.map +1 -0
  8. package/dist/arrow/buffers.d.ts +30 -0
  9. package/dist/arrow/buffers.d.ts.map +1 -0
  10. package/dist/arrow/buffers.js +177 -0
  11. package/dist/arrow/buffers.js.map +1 -0
  12. package/dist/arrow/cast.d.ts +19 -0
  13. package/dist/arrow/cast.d.ts.map +1 -0
  14. package/dist/arrow/cast.js +138 -0
  15. package/dist/arrow/cast.js.map +1 -0
  16. package/dist/arrow/compiler.d.ts +10 -0
  17. package/dist/arrow/compiler.d.ts.map +1 -0
  18. package/dist/arrow/compiler.js +1538 -0
  19. package/dist/arrow/compiler.js.map +1 -0
  20. package/dist/arrow/float16.d.ts +7 -0
  21. package/dist/arrow/float16.d.ts.map +1 -0
  22. package/dist/arrow/float16.js +26 -0
  23. package/dist/arrow/float16.js.map +1 -0
  24. package/dist/arrow/index.cjs +3321 -0
  25. package/dist/arrow/index.cjs.map +6 -0
  26. package/dist/arrow/index.d.ts +5 -0
  27. package/dist/arrow/index.d.ts.map +1 -0
  28. package/dist/arrow/index.js +7 -0
  29. package/dist/arrow/index.js.map +1 -0
  30. package/dist/arrow/like.d.ts +3 -0
  31. package/dist/arrow/like.d.ts.map +1 -0
  32. package/dist/arrow/like.js +75 -0
  33. package/dist/arrow/like.js.map +1 -0
  34. package/dist/arrow/list-values.d.ts +14 -0
  35. package/dist/arrow/list-values.d.ts.map +1 -0
  36. package/dist/arrow/list-values.js +201 -0
  37. package/dist/arrow/list-values.js.map +1 -0
  38. package/dist/arrow/predicate.d.ts +7 -0
  39. package/dist/arrow/predicate.d.ts.map +1 -0
  40. package/dist/arrow/predicate.js +10 -0
  41. package/dist/arrow/predicate.js.map +1 -0
  42. package/dist/arrow/query-arrow-aggregate-snapshots.d.ts +24 -0
  43. package/dist/arrow/query-arrow-aggregate-snapshots.d.ts.map +1 -0
  44. package/dist/arrow/query-arrow-aggregate-snapshots.js +64 -0
  45. package/dist/arrow/query-arrow-aggregate-snapshots.js.map +1 -0
  46. package/dist/arrow/query-arrow-sql.d.ts +8 -0
  47. package/dist/arrow/query-arrow-sql.d.ts.map +1 -0
  48. package/dist/arrow/query-arrow-sql.js +223 -0
  49. package/dist/arrow/query-arrow-sql.js.map +1 -0
  50. package/dist/arrow/query-arrow-table.d.ts +36 -0
  51. package/dist/arrow/query-arrow-table.d.ts.map +1 -0
  52. package/dist/arrow/query-arrow-table.js +208 -0
  53. package/dist/arrow/query-arrow-table.js.map +1 -0
  54. package/dist/arrow/query-worker-entry.d.ts +2 -0
  55. package/dist/arrow/query-worker-entry.d.ts.map +1 -0
  56. package/dist/arrow/query-worker-entry.js +7 -0
  57. package/dist/arrow/query-worker-entry.js.map +1 -0
  58. package/dist/arrow/query-worker.d.ts +65 -0
  59. package/dist/arrow/query-worker.d.ts.map +1 -0
  60. package/dist/arrow/query-worker.js +135 -0
  61. package/dist/arrow/query-worker.js.map +1 -0
  62. package/dist/arrow/registry.d.ts +4 -0
  63. package/dist/arrow/registry.d.ts.map +1 -0
  64. package/dist/arrow/registry.js +66 -0
  65. package/dist/arrow/registry.js.map +1 -0
  66. package/dist/arrow/relational-query.d.ts +36 -0
  67. package/dist/arrow/relational-query.d.ts.map +1 -0
  68. package/dist/arrow/relational-query.js +174 -0
  69. package/dist/arrow/relational-query.js.map +1 -0
  70. package/dist/arrow/replace-arrow-columns.d.ts +8 -0
  71. package/dist/arrow/replace-arrow-columns.d.ts.map +1 -0
  72. package/dist/arrow/replace-arrow-columns.js +63 -0
  73. package/dist/arrow/replace-arrow-columns.js.map +1 -0
  74. package/dist/arrow/signature.d.ts +6 -0
  75. package/dist/arrow/signature.d.ts.map +1 -0
  76. package/dist/arrow/signature.js +51 -0
  77. package/dist/arrow/signature.js.map +1 -0
  78. package/dist/arrow/temporal-cast.d.ts +9 -0
  79. package/dist/arrow/temporal-cast.d.ts.map +1 -0
  80. package/dist/arrow/temporal-cast.js +60 -0
  81. package/dist/arrow/temporal-cast.js.map +1 -0
  82. package/dist/arrow/types.d.ts +62 -0
  83. package/dist/arrow/types.d.ts.map +1 -0
  84. package/dist/arrow/types.js +5 -0
  85. package/dist/arrow/types.js.map +1 -0
  86. package/dist/arrow/unnest-arrow-column.d.ts +22 -0
  87. package/dist/arrow/unnest-arrow-column.d.ts.map +1 -0
  88. package/dist/arrow/unnest-arrow-column.js +112 -0
  89. package/dist/arrow/unnest-arrow-column.js.map +1 -0
  90. package/dist/arrow/worker-entry.d.ts +2 -0
  91. package/dist/arrow/worker-entry.d.ts.map +1 -0
  92. package/dist/arrow/worker-entry.js +9 -0
  93. package/dist/arrow/worker-entry.js.map +1 -0
  94. package/dist/arrow/worker.cjs +4074 -0
  95. package/dist/arrow/worker.cjs.map +6 -0
  96. package/dist/arrow/worker.d.ts +58 -0
  97. package/dist/arrow/worker.d.ts.map +1 -0
  98. package/dist/arrow/worker.js +84 -0
  99. package/dist/arrow/worker.js.map +1 -0
  100. package/dist/color-functions/index.cjs +382 -0
  101. package/dist/color-functions/index.cjs.map +6 -0
  102. package/dist/color-functions/index.d.ts +26 -0
  103. package/dist/color-functions/index.d.ts.map +1 -0
  104. package/dist/color-functions/index.js +306 -0
  105. package/dist/color-functions/index.js.map +1 -0
  106. package/dist/diagnostic-log.d.ts +8 -0
  107. package/dist/diagnostic-log.d.ts.map +1 -0
  108. package/dist/diagnostic-log.js +15 -0
  109. package/dist/diagnostic-log.js.map +1 -0
  110. package/dist/expressions/ast.d.ts +12 -0
  111. package/dist/expressions/ast.d.ts.map +1 -0
  112. package/dist/expressions/ast.js +114 -0
  113. package/dist/expressions/ast.js.map +1 -0
  114. package/dist/expressions/columnar-predicate.d.ts +56 -0
  115. package/dist/expressions/columnar-predicate.d.ts.map +1 -0
  116. package/dist/expressions/columnar-predicate.js +176 -0
  117. package/dist/expressions/columnar-predicate.js.map +1 -0
  118. package/dist/expressions/evaluation-error.d.ts +14 -0
  119. package/dist/expressions/evaluation-error.d.ts.map +1 -0
  120. package/dist/expressions/evaluation-error.js +26 -0
  121. package/dist/expressions/evaluation-error.js.map +1 -0
  122. package/dist/expressions/expression-eval.d.ts +105 -0
  123. package/dist/expressions/expression-eval.d.ts.map +1 -0
  124. package/dist/expressions/expression-eval.js +330 -0
  125. package/dist/expressions/expression-eval.js.map +1 -0
  126. package/dist/expressions/function-libraries.d.ts +63 -0
  127. package/dist/expressions/function-libraries.d.ts.map +1 -0
  128. package/dist/expressions/function-libraries.js +69 -0
  129. package/dist/expressions/function-libraries.js.map +1 -0
  130. package/dist/expressions/function-registry.d.ts +93 -0
  131. package/dist/expressions/function-registry.d.ts.map +1 -0
  132. package/dist/expressions/function-registry.js +139 -0
  133. package/dist/expressions/function-registry.js.map +1 -0
  134. package/dist/expressions/get.d.ts +9 -0
  135. package/dist/expressions/get.d.ts.map +1 -0
  136. package/dist/expressions/get.js +32 -0
  137. package/dist/expressions/get.js.map +1 -0
  138. package/dist/expressions/index.cjs +1888 -0
  139. package/dist/expressions/index.cjs.map +6 -0
  140. package/dist/expressions/index.d.ts +13 -0
  141. package/dist/expressions/index.d.ts.map +1 -0
  142. package/dist/expressions/index.js +14 -0
  143. package/dist/expressions/index.js.map +1 -0
  144. package/dist/expressions/numeric-functions.d.ts +277 -0
  145. package/dist/expressions/numeric-functions.d.ts.map +1 -0
  146. package/dist/expressions/numeric-functions.js +52 -0
  147. package/dist/expressions/numeric-functions.js.map +1 -0
  148. package/dist/expressions/parse-expression-string.d.ts +21 -0
  149. package/dist/expressions/parse-expression-string.d.ts.map +1 -0
  150. package/dist/expressions/parse-expression-string.js +61 -0
  151. package/dist/expressions/parse-expression-string.js.map +1 -0
  152. package/dist/expressions/predicate-expression.d.ts +7 -0
  153. package/dist/expressions/predicate-expression.d.ts.map +1 -0
  154. package/dist/expressions/predicate-expression.js +112 -0
  155. package/dist/expressions/predicate-expression.js.map +1 -0
  156. package/dist/expressions/scalar-type.d.ts +6 -0
  157. package/dist/expressions/scalar-type.d.ts.map +1 -0
  158. package/dist/expressions/scalar-type.js +23 -0
  159. package/dist/expressions/scalar-type.js.map +1 -0
  160. package/dist/expressions/vendor/jsep/runtime.d.ts +3 -0
  161. package/dist/expressions/vendor/jsep/runtime.d.ts.map +1 -0
  162. package/dist/expressions/vendor/jsep/runtime.js +972 -0
  163. package/dist/expressions/vendor/jsep/runtime.js.map +1 -0
  164. package/dist/expressions/vendor/jsep/types.d.ts +148 -0
  165. package/dist/expressions/vendor/jsep/types.d.ts.map +1 -0
  166. package/dist/expressions/vendor/jsep/types.js +6 -0
  167. package/dist/expressions/vendor/jsep/types.js.map +1 -0
  168. package/dist/index.cjs +5294 -0
  169. package/dist/index.cjs.map +6 -0
  170. package/dist/index.d.ts +11 -0
  171. package/dist/index.d.ts.map +1 -0
  172. package/dist/index.js +11 -0
  173. package/dist/index.js.map +1 -0
  174. package/dist/math-functions/index.cjs +444 -0
  175. package/dist/math-functions/index.cjs.map +6 -0
  176. package/dist/math-functions/index.d.ts +44 -0
  177. package/dist/math-functions/index.d.ts.map +1 -0
  178. package/dist/math-functions/index.js +182 -0
  179. package/dist/math-functions/index.js.map +1 -0
  180. package/dist/parser/bind-sql-predicate.d.ts +4 -0
  181. package/dist/parser/bind-sql-predicate.d.ts.map +1 -0
  182. package/dist/parser/bind-sql-predicate.js +11 -0
  183. package/dist/parser/bind-sql-predicate.js.map +1 -0
  184. package/dist/parser/index.cjs +1807 -0
  185. package/dist/parser/index.cjs.map +6 -0
  186. package/dist/parser/index.d.ts +12 -0
  187. package/dist/parser/index.d.ts.map +1 -0
  188. package/dist/parser/index.js +11 -0
  189. package/dist/parser/index.js.map +1 -0
  190. package/dist/parser/parameter-snapshots.d.ts +21 -0
  191. package/dist/parser/parameter-snapshots.d.ts.map +1 -0
  192. package/dist/parser/parameter-snapshots.js +85 -0
  193. package/dist/parser/parameter-snapshots.js.map +1 -0
  194. package/dist/parser/parse-sql-expression.d.ts +50 -0
  195. package/dist/parser/parse-sql-expression.d.ts.map +1 -0
  196. package/dist/parser/parse-sql-expression.js +501 -0
  197. package/dist/parser/parse-sql-expression.js.map +1 -0
  198. package/dist/parser/parse-sql-predicate.d.ts +13 -0
  199. package/dist/parser/parse-sql-predicate.d.ts.map +1 -0
  200. package/dist/parser/parse-sql-predicate.js +365 -0
  201. package/dist/parser/parse-sql-predicate.js.map +1 -0
  202. package/dist/parser/parse-sql-query.d.ts +9 -0
  203. package/dist/parser/parse-sql-query.d.ts.map +1 -0
  204. package/dist/parser/parse-sql-query.js +81 -0
  205. package/dist/parser/parse-sql-query.js.map +1 -0
  206. package/dist/parser/parse-sql-select.d.ts +57 -0
  207. package/dist/parser/parse-sql-select.d.ts.map +1 -0
  208. package/dist/parser/parse-sql-select.js +247 -0
  209. package/dist/parser/parse-sql-select.js.map +1 -0
  210. package/dist/parser/parse-sql-statement.d.ts +54 -0
  211. package/dist/parser/parse-sql-statement.d.ts.map +1 -0
  212. package/dist/parser/parse-sql-statement.js +207 -0
  213. package/dist/parser/parse-sql-statement.js.map +1 -0
  214. package/dist/parser/query-types.d.ts +56 -0
  215. package/dist/parser/query-types.d.ts.map +1 -0
  216. package/dist/parser/query-types.js +5 -0
  217. package/dist/parser/query-types.js.map +1 -0
  218. package/dist/parser/sql-parameters.d.ts +29 -0
  219. package/dist/parser/sql-parameters.d.ts.map +1 -0
  220. package/dist/parser/sql-parameters.js +110 -0
  221. package/dist/parser/sql-parameters.js.map +1 -0
  222. package/dist/parser/sql-parse-error.d.ts +13 -0
  223. package/dist/parser/sql-parse-error.d.ts.map +1 -0
  224. package/dist/parser/sql-parse-error.js +20 -0
  225. package/dist/parser/sql-parse-error.js.map +1 -0
  226. package/dist/parser/sql-predicate-schema.d.ts +164 -0
  227. package/dist/parser/sql-predicate-schema.d.ts.map +1 -0
  228. package/dist/parser/sql-predicate-schema.js +249 -0
  229. package/dist/parser/sql-predicate-schema.js.map +1 -0
  230. package/dist/parser/sql-predicate-types.d.ts +48 -0
  231. package/dist/parser/sql-predicate-types.d.ts.map +1 -0
  232. package/dist/parser/sql-predicate-types.js +9 -0
  233. package/dist/parser/sql-predicate-types.js.map +1 -0
  234. package/dist/parser/sql-predicate.d.ts +6 -0
  235. package/dist/parser/sql-predicate.d.ts.map +1 -0
  236. package/dist/parser/sql-predicate.js +8 -0
  237. package/dist/parser/sql-predicate.js.map +1 -0
  238. package/dist/scales/arrow-domains.d.ts +22 -0
  239. package/dist/scales/arrow-domains.d.ts.map +1 -0
  240. package/dist/scales/arrow-domains.js +166 -0
  241. package/dist/scales/arrow-domains.js.map +1 -0
  242. package/dist/scales/arrow-scales.d.ts +44 -0
  243. package/dist/scales/arrow-scales.d.ts.map +1 -0
  244. package/dist/scales/arrow-scales.js +255 -0
  245. package/dist/scales/arrow-scales.js.map +1 -0
  246. package/dist/scales/compile-scale.d.ts +2 -0
  247. package/dist/scales/compile-scale.d.ts.map +1 -0
  248. package/dist/scales/compile-scale.js +5 -0
  249. package/dist/scales/compile-scale.js.map +1 -0
  250. package/dist/scales/conformance.cjs +180 -0
  251. package/dist/scales/conformance.cjs.map +6 -0
  252. package/dist/scales/conformance.d.ts +26 -0
  253. package/dist/scales/conformance.d.ts.map +1 -0
  254. package/dist/scales/conformance.js +164 -0
  255. package/dist/scales/conformance.js.map +1 -0
  256. package/dist/scales/hdr-colors.d.ts +2 -0
  257. package/dist/scales/hdr-colors.d.ts.map +1 -0
  258. package/dist/scales/hdr-colors.js +5 -0
  259. package/dist/scales/hdr-colors.js.map +1 -0
  260. package/dist/scales/index.cjs +4334 -0
  261. package/dist/scales/index.cjs.map +6 -0
  262. package/dist/scales/index.d.ts +10 -0
  263. package/dist/scales/index.d.ts.map +1 -0
  264. package/dist/scales/index.js +11 -0
  265. package/dist/scales/index.js.map +1 -0
  266. package/dist/scales/palettes.d.ts +2 -0
  267. package/dist/scales/palettes.d.ts.map +1 -0
  268. package/dist/scales/palettes.js +5 -0
  269. package/dist/scales/palettes.js.map +1 -0
  270. package/dist/scales/parse-sql-scale.d.ts +27 -0
  271. package/dist/scales/parse-sql-scale.d.ts.map +1 -0
  272. package/dist/scales/parse-sql-scale.js +257 -0
  273. package/dist/scales/parse-sql-scale.js.map +1 -0
  274. package/dist/scales/quantile-sketch.d.ts +2 -0
  275. package/dist/scales/quantile-sketch.d.ts.map +1 -0
  276. package/dist/scales/quantile-sketch.js +5 -0
  277. package/dist/scales/quantile-sketch.js.map +1 -0
  278. package/dist/scales/scale-types.d.ts +2 -0
  279. package/dist/scales/scale-types.d.ts.map +1 -0
  280. package/dist/scales/scale-types.js +5 -0
  281. package/dist/scales/scale-types.js.map +1 -0
  282. package/dist/scales/streaming-domains.d.ts +18 -0
  283. package/dist/scales/streaming-domains.d.ts.map +1 -0
  284. package/dist/scales/streaming-domains.js +115 -0
  285. package/dist/scales/streaming-domains.js.map +1 -0
  286. package/package.json +92 -4
  287. package/src/arrow/aggregates.ts +386 -0
  288. package/src/arrow/buffers.ts +177 -0
  289. package/src/arrow/cast.ts +160 -0
  290. package/src/arrow/compiler.ts +1778 -0
  291. package/src/arrow/float16.ts +25 -0
  292. package/src/arrow/index.ts +22 -0
  293. package/src/arrow/like.ts +72 -0
  294. package/src/arrow/list-values.ts +221 -0
  295. package/src/arrow/predicate.ts +19 -0
  296. package/src/arrow/query-arrow-aggregate-snapshots.ts +107 -0
  297. package/src/arrow/query-arrow-sql.ts +255 -0
  298. package/src/arrow/query-arrow-table.ts +298 -0
  299. package/src/arrow/query-worker-entry.ts +8 -0
  300. package/src/arrow/query-worker.ts +194 -0
  301. package/src/arrow/registry.ts +87 -0
  302. package/src/arrow/relational-query.ts +247 -0
  303. package/src/arrow/replace-arrow-columns.ts +71 -0
  304. package/src/arrow/signature.ts +50 -0
  305. package/src/arrow/temporal-cast.ts +66 -0
  306. package/src/arrow/types.ts +76 -0
  307. package/src/arrow/unnest-arrow-column.ts +145 -0
  308. package/src/arrow/worker-entry.ts +10 -0
  309. package/src/arrow/worker.ts +143 -0
  310. package/src/color-functions/index.ts +405 -0
  311. package/src/diagnostic-log.ts +20 -0
  312. package/src/expressions/ast.ts +143 -0
  313. package/src/expressions/columnar-predicate.ts +293 -0
  314. package/src/expressions/evaluation-error.ts +29 -0
  315. package/src/expressions/expression-eval.ts +489 -0
  316. package/src/expressions/function-libraries.ts +126 -0
  317. package/src/expressions/function-registry.ts +171 -0
  318. package/src/expressions/get.ts +37 -0
  319. package/src/expressions/index.ts +40 -0
  320. package/src/expressions/numeric-functions.ts +99 -0
  321. package/src/expressions/parse-expression-string.ts +80 -0
  322. package/src/expressions/predicate-expression.ts +128 -0
  323. package/src/expressions/scalar-type.ts +39 -0
  324. package/src/expressions/vendor/jsep/LICENSE.txt +23 -0
  325. package/src/expressions/vendor/jsep/runtime.ts +949 -0
  326. package/src/expressions/vendor/jsep/types.ts +191 -0
  327. package/src/index.ts +54 -0
  328. package/src/math-functions/index.ts +235 -0
  329. package/src/parser/bind-sql-predicate.ts +21 -0
  330. package/src/parser/index.ts +43 -0
  331. package/src/parser/parameter-snapshots.ts +103 -0
  332. package/src/parser/parse-sql-expression.ts +500 -0
  333. package/src/parser/parse-sql-predicate.ts +454 -0
  334. package/src/parser/parse-sql-query.ts +90 -0
  335. package/src/parser/parse-sql-select.ts +272 -0
  336. package/src/parser/parse-sql-statement.ts +260 -0
  337. package/src/parser/query-types.ts +71 -0
  338. package/src/parser/sql-parameters.ts +174 -0
  339. package/src/parser/sql-parse-error.ts +33 -0
  340. package/src/parser/sql-predicate-schema.ts +279 -0
  341. package/src/parser/sql-predicate-types.ts +91 -0
  342. package/src/parser/sql-predicate.ts +28 -0
  343. package/src/scales/arrow-domains.ts +190 -0
  344. package/src/scales/arrow-scales.ts +363 -0
  345. package/src/scales/compile-scale.ts +5 -0
  346. package/src/scales/conformance.ts +186 -0
  347. package/src/scales/hdr-colors.ts +5 -0
  348. package/src/scales/index.ts +37 -0
  349. package/src/scales/palettes.ts +5 -0
  350. package/src/scales/parse-sql-scale.ts +300 -0
  351. package/src/scales/quantile-sketch.ts +5 -0
  352. package/src/scales/scale-types.ts +5 -0
  353. package/src/scales/streaming-domains.ts +139 -0
@@ -0,0 +1,1888 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // dist/expressions/index.js
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ BASIC_MATH_FUNCTION_LIBRARY: () => BASIC_MATH_FUNCTION_LIBRARY,
23
+ COLUMNAR_SCALAR_TYPES: () => COLUMNAR_SCALAR_TYPES,
24
+ ExpressionEvaluationError: () => ExpressionEvaluationError,
25
+ ExpressionFunctionRegistry: () => ExpressionFunctionRegistry,
26
+ NUMERIC_FUNCTION_DEFINITIONS: () => NUMERIC_FUNCTION_DEFINITIONS,
27
+ addBinaryOp: () => addBinaryOp,
28
+ addUnaryOp: () => addUnaryOp,
29
+ bindColumnarPredicateParameters: () => bindColumnarPredicateParameters,
30
+ columnarPredicateToExpression: () => columnarPredicateToExpression,
31
+ compile: () => compile,
32
+ compileAsync: () => compileAsync,
33
+ copyColumnarPredicate: () => copyColumnarPredicate,
34
+ evaluate: () => evaluateWithDiagnostics,
35
+ evaluateAsync: () => evaluateAsync,
36
+ getColumnarPredicateColumns: () => getColumnarPredicateColumns,
37
+ getColumnarPredicateParameterNames: () => getColumnarPredicateParameterNames,
38
+ getColumnarPredicatePath: () => getColumnarPredicatePath,
39
+ getColumnarPredicatePaths: () => getColumnarPredicatePaths,
40
+ getExpressionColumns: () => getExpressionColumns,
41
+ isColumnarPredicateParameter: () => isColumnarPredicateParameter,
42
+ isColumnarPredicateValue: () => isColumnarPredicateValue,
43
+ isColumnarScalarType: () => isColumnarScalarType,
44
+ isExpressionEvaluationError: () => isExpressionEvaluationError,
45
+ mergeFunctionLibraries: () => mergeFunctionLibraries,
46
+ parse: () => parse,
47
+ parseExpressionString: () => parseExpressionString,
48
+ validateColumnarPredicate: () => validateColumnarPredicate,
49
+ validateExpressionAST: () => validateExpressionAST
50
+ });
51
+ module.exports = __toCommonJS(index_exports);
52
+
53
+ // dist/expressions/function-registry.js
54
+ var FUNCTION_NAME_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
55
+ var DISALLOWED_FUNCTION_NAMES = /* @__PURE__ */ new Set([
56
+ "__proto__",
57
+ "prototype",
58
+ "constructor",
59
+ "true",
60
+ "false",
61
+ "null",
62
+ "this"
63
+ ]);
64
+ var ExpressionFunctionRegistry = class {
65
+ /**
66
+ * Creates a function registry.
67
+ *
68
+ * @param functionTables - Function tables to register in order.
69
+ * @throws If a table contains an invalid or duplicate function name.
70
+ */
71
+ constructor(functionTables = []) {
72
+ this.functions = /* @__PURE__ */ Object.create(null);
73
+ for (const functionTable of functionTables) {
74
+ this.registerFunctions(functionTable);
75
+ }
76
+ }
77
+ /**
78
+ * Registers one named function.
79
+ *
80
+ * @param name - Identifier used to call the function from an expression.
81
+ * @param fn - JavaScript function invoked with evaluated expression arguments.
82
+ * @param options - Duplicate registration behavior.
83
+ * @returns This registry.
84
+ * @throws If the name is invalid, the value is not a function, or the name is
85
+ * already registered and replacement was not requested.
86
+ */
87
+ registerFunction(name, fn, options = {}) {
88
+ validateFunction(name, fn);
89
+ if (this.hasFunction(name) && !options.replace) {
90
+ throw new Error(`Expression function "${name}" is already registered.`);
91
+ }
92
+ this.functions[name] = fn;
93
+ return this;
94
+ }
95
+ /**
96
+ * Registers all entries in a function table.
97
+ *
98
+ * @param functionTable - Map from expression identifiers to JavaScript functions.
99
+ * @param options - Duplicate registration behavior.
100
+ * @returns This registry.
101
+ * @throws If any entry is invalid or conflicts with an existing registration.
102
+ *
103
+ * @remarks
104
+ * Validation is atomic: no entries are registered when any entry is invalid.
105
+ */
106
+ registerFunctions(functionTable, options = {}) {
107
+ const entries = Object.entries(functionTable);
108
+ const names = /* @__PURE__ */ new Set();
109
+ for (const [name, fn] of entries) {
110
+ validateFunction(name, fn);
111
+ if (names.has(name) || this.hasFunction(name) && !options.replace) {
112
+ throw new Error(`Expression function "${name}" is already registered.`);
113
+ }
114
+ names.add(name);
115
+ }
116
+ for (const [name, fn] of entries) {
117
+ this.functions[name] = fn;
118
+ }
119
+ return this;
120
+ }
121
+ /**
122
+ * Removes a registered function.
123
+ *
124
+ * @param name - Function name to remove.
125
+ * @returns `true` when a function was removed.
126
+ */
127
+ unregisterFunction(name) {
128
+ if (!this.hasFunction(name)) {
129
+ return false;
130
+ }
131
+ return delete this.functions[name];
132
+ }
133
+ /**
134
+ * Tests whether a function is registered.
135
+ *
136
+ * @param name - Function name to inspect.
137
+ * @returns `true` when the registry contains the name.
138
+ */
139
+ hasFunction(name) {
140
+ return Object.prototype.hasOwnProperty.call(this.functions, name);
141
+ }
142
+ /**
143
+ * Returns a registered function.
144
+ *
145
+ * @param name - Function name to retrieve.
146
+ * @returns The registered function, or `undefined`.
147
+ */
148
+ getFunction(name) {
149
+ return this.functions[name];
150
+ }
151
+ /**
152
+ * Returns an immutable snapshot of all registered functions.
153
+ *
154
+ * @returns A frozen function table.
155
+ */
156
+ getFunctionTable() {
157
+ return Object.freeze({ ...this.functions });
158
+ }
159
+ };
160
+ function validateFunction(name, fn) {
161
+ if (!FUNCTION_NAME_PATTERN.test(name) || DISALLOWED_FUNCTION_NAMES.has(name)) {
162
+ throw new Error(`Invalid expression function name "${name}".`);
163
+ }
164
+ if (typeof fn !== "function") {
165
+ throw new TypeError(`Expression function "${name}" must be a function.`);
166
+ }
167
+ }
168
+
169
+ // dist/diagnostic-log.js
170
+ function reportDiagnosticError(log, error) {
171
+ if (log) {
172
+ try {
173
+ log.error(error instanceof Error ? error.message : String(error), error)();
174
+ } catch {
175
+ }
176
+ }
177
+ }
178
+
179
+ // dist/expressions/vendor/jsep/runtime.js
180
+ var Hooks = class {
181
+ /**
182
+ * @callback HookCallback
183
+ * @this {*|Jsep} this
184
+ * @param {Jsep} env
185
+ * @returns: void
186
+ */
187
+ /**
188
+ * Adds the given callback to the list of callbacks for the given hook.
189
+ *
190
+ * The callback will be invoked when the hook it is registered for is run.
191
+ *
192
+ * One callback function can be registered to multiple hooks and the same hook multiple times.
193
+ *
194
+ * @param {string|object} name The name of the hook, or an object of callbacks keyed by name
195
+ * @param {HookCallback|boolean} callback The callback function which is given environment variables.
196
+ * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
197
+ * @public
198
+ */
199
+ add(name, callback, first) {
200
+ if (typeof arguments[0] != "string") {
201
+ for (let name2 in arguments[0]) {
202
+ this.add(name2, arguments[0][name2], arguments[1]);
203
+ }
204
+ } else {
205
+ (Array.isArray(name) ? name : [name]).forEach(function(name2) {
206
+ this[name2] = this[name2] || [];
207
+ if (callback) {
208
+ this[name2][first ? "unshift" : "push"](callback);
209
+ }
210
+ }, this);
211
+ }
212
+ }
213
+ /**
214
+ * Runs a hook invoking all registered callbacks with the given environment variables.
215
+ *
216
+ * Callbacks will be invoked synchronously and in the order in which they were registered.
217
+ *
218
+ * @param {string} name The name of the hook.
219
+ * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
220
+ * @public
221
+ */
222
+ run(name, env) {
223
+ this[name] = this[name] || [];
224
+ this[name].forEach(function(callback) {
225
+ callback.call(env && env.context ? env.context : env, env);
226
+ });
227
+ }
228
+ };
229
+ var Plugins = class {
230
+ constructor(jsep22) {
231
+ this.jsep = jsep22;
232
+ this.registered = {};
233
+ }
234
+ /**
235
+ * @callback PluginSetup
236
+ * @this {Jsep} jsep
237
+ * @returns: void
238
+ */
239
+ /**
240
+ * Adds the given plugin(s) to the registry
241
+ *
242
+ * @param {object} plugins
243
+ * @param {string} plugins.name The name of the plugin
244
+ * @param {PluginSetup} plugins.init The init function
245
+ * @public
246
+ */
247
+ register(...plugins) {
248
+ plugins.forEach((plugin) => {
249
+ if (typeof plugin !== "object" || !plugin.name || !plugin.init) {
250
+ throw new Error("Invalid JSEP plugin format");
251
+ }
252
+ if (this.registered[plugin.name]) {
253
+ return;
254
+ }
255
+ plugin.init(this.jsep);
256
+ this.registered[plugin.name] = plugin;
257
+ });
258
+ }
259
+ };
260
+ var Jsep = class _Jsep {
261
+ /**
262
+ * @returns {string}
263
+ */
264
+ static get version() {
265
+ return "1.4.0";
266
+ }
267
+ /**
268
+ * @returns {string}
269
+ */
270
+ static toString() {
271
+ return "JavaScript Expression Parser (JSEP) v" + _Jsep.version;
272
+ }
273
+ // ==================== CONFIG ================================
274
+ /**
275
+ * @method addUnaryOp
276
+ * @param {string} op_name The name of the unary op to add
277
+ * @returns {Jsep}
278
+ */
279
+ static addUnaryOp(op_name) {
280
+ _Jsep.max_unop_len = Math.max(op_name.length, _Jsep.max_unop_len);
281
+ _Jsep.unary_ops[op_name] = 1;
282
+ return _Jsep;
283
+ }
284
+ /**
285
+ * @method jsep.addBinaryOp
286
+ * @param {string} op_name The name of the binary op to add
287
+ * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
288
+ * @param {boolean} [isRightAssociative=false] whether operator is right-associative
289
+ * @returns {Jsep}
290
+ */
291
+ static addBinaryOp(op_name, precedence, isRightAssociative) {
292
+ _Jsep.max_binop_len = Math.max(op_name.length, _Jsep.max_binop_len);
293
+ _Jsep.binary_ops[op_name] = precedence;
294
+ if (isRightAssociative) {
295
+ _Jsep.right_associative.add(op_name);
296
+ } else {
297
+ _Jsep.right_associative.delete(op_name);
298
+ }
299
+ return _Jsep;
300
+ }
301
+ /**
302
+ * @method addIdentifierChar
303
+ * @param {string} char The additional character to treat as a valid part of an identifier
304
+ * @returns {Jsep}
305
+ */
306
+ static addIdentifierChar(char) {
307
+ _Jsep.additional_identifier_chars.add(char);
308
+ return _Jsep;
309
+ }
310
+ /**
311
+ * @method addLiteral
312
+ * @param {string} literal_name The name of the literal to add
313
+ * @param {*} literal_value The value of the literal
314
+ * @returns {Jsep}
315
+ */
316
+ static addLiteral(literal_name, literal_value) {
317
+ _Jsep.literals[literal_name] = literal_value;
318
+ return _Jsep;
319
+ }
320
+ /**
321
+ * @method removeUnaryOp
322
+ * @param {string} op_name The name of the unary op to remove
323
+ * @returns {Jsep}
324
+ */
325
+ static removeUnaryOp(op_name) {
326
+ delete _Jsep.unary_ops[op_name];
327
+ if (op_name.length === _Jsep.max_unop_len) {
328
+ _Jsep.max_unop_len = _Jsep.getMaxKeyLen(_Jsep.unary_ops);
329
+ }
330
+ return _Jsep;
331
+ }
332
+ /**
333
+ * @method removeAllUnaryOps
334
+ * @returns {Jsep}
335
+ */
336
+ static removeAllUnaryOps() {
337
+ _Jsep.unary_ops = {};
338
+ _Jsep.max_unop_len = 0;
339
+ return _Jsep;
340
+ }
341
+ /**
342
+ * @method removeIdentifierChar
343
+ * @param {string} char The additional character to stop treating as a valid part of an identifier
344
+ * @returns {Jsep}
345
+ */
346
+ static removeIdentifierChar(char) {
347
+ _Jsep.additional_identifier_chars.delete(char);
348
+ return _Jsep;
349
+ }
350
+ /**
351
+ * @method removeBinaryOp
352
+ * @param {string} op_name The name of the binary op to remove
353
+ * @returns {Jsep}
354
+ */
355
+ static removeBinaryOp(op_name) {
356
+ delete _Jsep.binary_ops[op_name];
357
+ if (op_name.length === _Jsep.max_binop_len) {
358
+ _Jsep.max_binop_len = _Jsep.getMaxKeyLen(_Jsep.binary_ops);
359
+ }
360
+ _Jsep.right_associative.delete(op_name);
361
+ return _Jsep;
362
+ }
363
+ /**
364
+ * @method removeAllBinaryOps
365
+ * @returns {Jsep}
366
+ */
367
+ static removeAllBinaryOps() {
368
+ _Jsep.binary_ops = {};
369
+ _Jsep.max_binop_len = 0;
370
+ return _Jsep;
371
+ }
372
+ /**
373
+ * @method removeLiteral
374
+ * @param {string} literal_name The name of the literal to remove
375
+ * @returns {Jsep}
376
+ */
377
+ static removeLiteral(literal_name) {
378
+ delete _Jsep.literals[literal_name];
379
+ return _Jsep;
380
+ }
381
+ /**
382
+ * @method removeAllLiterals
383
+ * @returns {Jsep}
384
+ */
385
+ static removeAllLiterals() {
386
+ _Jsep.literals = {};
387
+ return _Jsep;
388
+ }
389
+ // ==================== END CONFIG ============================
390
+ /**
391
+ * @returns {string}
392
+ */
393
+ get char() {
394
+ return this.expr.charAt(this.index);
395
+ }
396
+ /**
397
+ * @returns {number}
398
+ */
399
+ get code() {
400
+ return this.expr.charCodeAt(this.index);
401
+ }
402
+ /**
403
+ * @param {string} expr a string with the passed in express
404
+ * @returns Jsep
405
+ */
406
+ constructor(expr) {
407
+ this.expr = expr;
408
+ this.index = 0;
409
+ }
410
+ /**
411
+ * static top-level parser
412
+ * @returns {jsep.Expression}
413
+ */
414
+ static parse(expr) {
415
+ return new _Jsep(expr).parse();
416
+ }
417
+ /**
418
+ * Get the longest key length of any object
419
+ * @param {object} obj
420
+ * @returns {number}
421
+ */
422
+ static getMaxKeyLen(obj) {
423
+ return Math.max(0, ...Object.keys(obj).map((k) => k.length));
424
+ }
425
+ /**
426
+ * `ch` is a character code in the next three functions
427
+ * @param {number} ch
428
+ * @returns {boolean}
429
+ */
430
+ static isDecimalDigit(ch) {
431
+ return ch >= 48 && ch <= 57;
432
+ }
433
+ /**
434
+ * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
435
+ * @param {string} op_val
436
+ * @returns {number}
437
+ */
438
+ static binaryPrecedence(op_val) {
439
+ return _Jsep.binary_ops[op_val] || 0;
440
+ }
441
+ /**
442
+ * Looks for start of identifier
443
+ * @param {number} ch
444
+ * @returns {boolean}
445
+ */
446
+ static isIdentifierStart(ch) {
447
+ return ch >= 65 && ch <= 90 || // A...Z
448
+ ch >= 97 && ch <= 122 || // a...z
449
+ ch >= 128 && !_Jsep.binary_ops[String.fromCharCode(ch)] || // any non-ASCII that is not an operator
450
+ _Jsep.additional_identifier_chars.has(String.fromCharCode(ch));
451
+ }
452
+ /**
453
+ * @param {number} ch
454
+ * @returns {boolean}
455
+ */
456
+ static isIdentifierPart(ch) {
457
+ return _Jsep.isIdentifierStart(ch) || _Jsep.isDecimalDigit(ch);
458
+ }
459
+ /**
460
+ * throw error at index of the expression
461
+ * @param {string} message
462
+ * @throws
463
+ */
464
+ throwError(message) {
465
+ const error = new Error(message + " at character " + this.index);
466
+ error.index = this.index;
467
+ error.description = message;
468
+ throw error;
469
+ }
470
+ /**
471
+ * Run a given hook
472
+ * @param {string} name
473
+ * @param {jsep.Expression|false} [node]
474
+ * @returns {?jsep.Expression}
475
+ */
476
+ runHook(name, node) {
477
+ if (_Jsep.hooks[name]) {
478
+ const env = { context: this, node };
479
+ _Jsep.hooks.run(name, env);
480
+ return env.node;
481
+ }
482
+ return node;
483
+ }
484
+ /**
485
+ * Runs a given hook until one returns a node
486
+ * @param {string} name
487
+ * @returns {?jsep.Expression}
488
+ */
489
+ searchHook(name) {
490
+ if (_Jsep.hooks[name]) {
491
+ const env = { context: this };
492
+ _Jsep.hooks[name].find(function(callback) {
493
+ callback.call(env.context, env);
494
+ return env.node;
495
+ });
496
+ return env.node;
497
+ }
498
+ }
499
+ /**
500
+ * Push `index` up to the next non-space character
501
+ */
502
+ gobbleSpaces() {
503
+ let ch = this.code;
504
+ while (ch === _Jsep.SPACE_CODE || ch === _Jsep.TAB_CODE || ch === _Jsep.LF_CODE || ch === _Jsep.CR_CODE) {
505
+ ch = this.expr.charCodeAt(++this.index);
506
+ }
507
+ this.runHook("gobble-spaces");
508
+ }
509
+ /**
510
+ * Top-level method to parse all expressions and returns compound or single node
511
+ * @returns {jsep.Expression}
512
+ */
513
+ parse() {
514
+ this.runHook("before-all");
515
+ const nodes = this.gobbleExpressions();
516
+ const node = nodes.length === 1 ? nodes[0] : {
517
+ type: _Jsep.COMPOUND,
518
+ body: nodes
519
+ };
520
+ return this.runHook("after-all", node);
521
+ }
522
+ /**
523
+ * top-level parser (but can be reused within as well)
524
+ * @param {number} [untilICode]
525
+ * @returns {jsep.Expression[]}
526
+ */
527
+ gobbleExpressions(untilICode) {
528
+ let nodes = [], ch_i, node;
529
+ while (this.index < this.expr.length) {
530
+ ch_i = this.code;
531
+ if (ch_i === _Jsep.SEMCOL_CODE || ch_i === _Jsep.COMMA_CODE) {
532
+ this.index++;
533
+ } else {
534
+ if (node = this.gobbleExpression()) {
535
+ nodes.push(node);
536
+ } else if (this.index < this.expr.length) {
537
+ if (ch_i === untilICode) {
538
+ break;
539
+ }
540
+ this.throwError('Unexpected "' + this.char + '"');
541
+ }
542
+ }
543
+ }
544
+ return nodes;
545
+ }
546
+ /**
547
+ * The main parsing function.
548
+ * @returns {?jsep.Expression}
549
+ */
550
+ gobbleExpression() {
551
+ const node = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
552
+ this.gobbleSpaces();
553
+ return this.runHook("after-expression", node);
554
+ }
555
+ /**
556
+ * Search for the operation portion of the string (e.g. `+`, `===`)
557
+ * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
558
+ * and move down from 3 to 2 to 1 character until a matching binary operation is found
559
+ * then, return that binary operation
560
+ * @returns {string|boolean}
561
+ */
562
+ gobbleBinaryOp() {
563
+ this.gobbleSpaces();
564
+ let to_check = this.expr.substr(this.index, _Jsep.max_binop_len);
565
+ let tc_len = to_check.length;
566
+ while (tc_len > 0) {
567
+ if (_Jsep.binary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
568
+ this.index += tc_len;
569
+ return to_check;
570
+ }
571
+ to_check = to_check.substr(0, --tc_len);
572
+ }
573
+ return false;
574
+ }
575
+ /**
576
+ * This function is responsible for gobbling an individual expression,
577
+ * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
578
+ * @returns {?jsep.BinaryExpression}
579
+ */
580
+ gobbleBinaryExpression() {
581
+ let node, biop, prec, stack, biop_info, left, right, i, cur_biop;
582
+ left = this.gobbleToken();
583
+ if (!left) {
584
+ return left;
585
+ }
586
+ biop = this.gobbleBinaryOp();
587
+ if (!biop) {
588
+ return left;
589
+ }
590
+ biop_info = { value: biop, prec: _Jsep.binaryPrecedence(biop), right_a: _Jsep.right_associative.has(biop) };
591
+ right = this.gobbleToken();
592
+ if (!right) {
593
+ this.throwError("Expected expression after " + biop);
594
+ }
595
+ stack = [left, biop_info, right];
596
+ while (biop = this.gobbleBinaryOp()) {
597
+ prec = _Jsep.binaryPrecedence(biop);
598
+ if (prec === 0) {
599
+ this.index -= biop.length;
600
+ break;
601
+ }
602
+ biop_info = { value: biop, prec, right_a: _Jsep.right_associative.has(biop) };
603
+ cur_biop = biop;
604
+ const comparePrev = (prev) => biop_info.right_a && prev.right_a ? prec > prev.prec : prec <= prev.prec;
605
+ while (stack.length > 2 && comparePrev(stack[stack.length - 2])) {
606
+ right = stack.pop();
607
+ biop = stack.pop().value;
608
+ left = stack.pop();
609
+ node = {
610
+ type: _Jsep.BINARY_EXP,
611
+ operator: biop,
612
+ left,
613
+ right
614
+ };
615
+ stack.push(node);
616
+ }
617
+ node = this.gobbleToken();
618
+ if (!node) {
619
+ this.throwError("Expected expression after " + cur_biop);
620
+ }
621
+ stack.push(biop_info, node);
622
+ }
623
+ i = stack.length - 1;
624
+ node = stack[i];
625
+ while (i > 1) {
626
+ node = {
627
+ type: _Jsep.BINARY_EXP,
628
+ operator: stack[i - 1].value,
629
+ left: stack[i - 2],
630
+ right: node
631
+ };
632
+ i -= 2;
633
+ }
634
+ return node;
635
+ }
636
+ /**
637
+ * An individual part of a binary expression:
638
+ * e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
639
+ * @returns {boolean|jsep.Expression}
640
+ */
641
+ gobbleToken() {
642
+ let ch, to_check, tc_len, node;
643
+ this.gobbleSpaces();
644
+ node = this.searchHook("gobble-token");
645
+ if (node) {
646
+ return this.runHook("after-token", node);
647
+ }
648
+ ch = this.code;
649
+ if (_Jsep.isDecimalDigit(ch) || ch === _Jsep.PERIOD_CODE) {
650
+ return this.gobbleNumericLiteral();
651
+ }
652
+ if (ch === _Jsep.SQUOTE_CODE || ch === _Jsep.DQUOTE_CODE) {
653
+ node = this.gobbleStringLiteral();
654
+ } else if (ch === _Jsep.OBRACK_CODE) {
655
+ node = this.gobbleArray();
656
+ } else {
657
+ to_check = this.expr.substr(this.index, _Jsep.max_unop_len);
658
+ tc_len = to_check.length;
659
+ while (tc_len > 0) {
660
+ if (_Jsep.unary_ops.hasOwnProperty(to_check) && (!_Jsep.isIdentifierStart(this.code) || this.index + to_check.length < this.expr.length && !_Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))) {
661
+ this.index += tc_len;
662
+ const argument = this.gobbleToken();
663
+ if (!argument) {
664
+ this.throwError("missing unaryOp argument");
665
+ }
666
+ return this.runHook("after-token", {
667
+ type: _Jsep.UNARY_EXP,
668
+ operator: to_check,
669
+ argument,
670
+ prefix: true
671
+ });
672
+ }
673
+ to_check = to_check.substr(0, --tc_len);
674
+ }
675
+ if (_Jsep.isIdentifierStart(ch)) {
676
+ node = this.gobbleIdentifier();
677
+ if (_Jsep.literals.hasOwnProperty(node.name)) {
678
+ node = {
679
+ type: _Jsep.LITERAL,
680
+ value: _Jsep.literals[node.name],
681
+ raw: node.name
682
+ };
683
+ } else if (node.name === _Jsep.this_str) {
684
+ node = { type: _Jsep.THIS_EXP };
685
+ }
686
+ } else if (ch === _Jsep.OPAREN_CODE) {
687
+ node = this.gobbleGroup();
688
+ }
689
+ }
690
+ if (!node) {
691
+ return this.runHook("after-token", false);
692
+ }
693
+ node = this.gobbleTokenProperty(node);
694
+ return this.runHook("after-token", node);
695
+ }
696
+ /**
697
+ * Gobble properties of of identifiers/strings/arrays/groups.
698
+ * e.g. `foo`, `bar.baz`, `foo['bar'].baz`
699
+ * It also gobbles function calls:
700
+ * e.g. `Math.acos(obj.angle)`
701
+ * @param {jsep.Expression} node
702
+ * @returns {jsep.Expression}
703
+ */
704
+ gobbleTokenProperty(node) {
705
+ this.gobbleSpaces();
706
+ let ch = this.code;
707
+ while (ch === _Jsep.PERIOD_CODE || ch === _Jsep.OBRACK_CODE || ch === _Jsep.OPAREN_CODE || ch === _Jsep.QUMARK_CODE) {
708
+ let optional;
709
+ if (ch === _Jsep.QUMARK_CODE) {
710
+ if (this.expr.charCodeAt(this.index + 1) !== _Jsep.PERIOD_CODE) {
711
+ break;
712
+ }
713
+ optional = true;
714
+ this.index += 2;
715
+ this.gobbleSpaces();
716
+ ch = this.code;
717
+ }
718
+ this.index++;
719
+ if (ch === _Jsep.OBRACK_CODE) {
720
+ node = {
721
+ type: _Jsep.MEMBER_EXP,
722
+ computed: true,
723
+ object: node,
724
+ property: this.gobbleExpression()
725
+ };
726
+ if (!node.property) {
727
+ this.throwError('Unexpected "' + this.char + '"');
728
+ }
729
+ this.gobbleSpaces();
730
+ ch = this.code;
731
+ if (ch !== _Jsep.CBRACK_CODE) {
732
+ this.throwError("Unclosed [");
733
+ }
734
+ this.index++;
735
+ } else if (ch === _Jsep.OPAREN_CODE) {
736
+ node = {
737
+ type: _Jsep.CALL_EXP,
738
+ "arguments": this.gobbleArguments(_Jsep.CPAREN_CODE),
739
+ callee: node
740
+ };
741
+ } else if (ch === _Jsep.PERIOD_CODE || optional) {
742
+ if (optional) {
743
+ this.index--;
744
+ }
745
+ this.gobbleSpaces();
746
+ node = {
747
+ type: _Jsep.MEMBER_EXP,
748
+ computed: false,
749
+ object: node,
750
+ property: this.gobbleIdentifier()
751
+ };
752
+ }
753
+ if (optional) {
754
+ node.optional = true;
755
+ }
756
+ this.gobbleSpaces();
757
+ ch = this.code;
758
+ }
759
+ return node;
760
+ }
761
+ /**
762
+ * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
763
+ * keep track of everything in the numeric literal and then calling `parseFloat` on that string
764
+ * @returns {jsep.Literal}
765
+ */
766
+ gobbleNumericLiteral() {
767
+ let number = "", ch, chCode;
768
+ while (_Jsep.isDecimalDigit(this.code)) {
769
+ number += this.expr.charAt(this.index++);
770
+ }
771
+ if (this.code === _Jsep.PERIOD_CODE) {
772
+ number += this.expr.charAt(this.index++);
773
+ while (_Jsep.isDecimalDigit(this.code)) {
774
+ number += this.expr.charAt(this.index++);
775
+ }
776
+ }
777
+ ch = this.char;
778
+ if (ch === "e" || ch === "E") {
779
+ number += this.expr.charAt(this.index++);
780
+ ch = this.char;
781
+ if (ch === "+" || ch === "-") {
782
+ number += this.expr.charAt(this.index++);
783
+ }
784
+ while (_Jsep.isDecimalDigit(this.code)) {
785
+ number += this.expr.charAt(this.index++);
786
+ }
787
+ if (!_Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1))) {
788
+ this.throwError("Expected exponent (" + number + this.char + ")");
789
+ }
790
+ }
791
+ chCode = this.code;
792
+ if (_Jsep.isIdentifierStart(chCode)) {
793
+ this.throwError("Variable names cannot start with a number (" + number + this.char + ")");
794
+ } else if (chCode === _Jsep.PERIOD_CODE || number.length === 1 && number.charCodeAt(0) === _Jsep.PERIOD_CODE) {
795
+ this.throwError("Unexpected period");
796
+ }
797
+ return {
798
+ type: _Jsep.LITERAL,
799
+ value: parseFloat(number),
800
+ raw: number
801
+ };
802
+ }
803
+ /**
804
+ * Parses a string literal, staring with single or double quotes with basic support for escape codes
805
+ * e.g. `"hello world"`, `'this is\nJSEP'`
806
+ * @returns {jsep.Literal}
807
+ */
808
+ gobbleStringLiteral() {
809
+ let str = "";
810
+ const startIndex = this.index;
811
+ const quote = this.expr.charAt(this.index++);
812
+ let closed = false;
813
+ while (this.index < this.expr.length) {
814
+ let ch = this.expr.charAt(this.index++);
815
+ if (ch === quote) {
816
+ closed = true;
817
+ break;
818
+ } else if (ch === "\\") {
819
+ ch = this.expr.charAt(this.index++);
820
+ switch (ch) {
821
+ case "n":
822
+ str += "\n";
823
+ break;
824
+ case "r":
825
+ str += "\r";
826
+ break;
827
+ case "t":
828
+ str += " ";
829
+ break;
830
+ case "b":
831
+ str += "\b";
832
+ break;
833
+ case "f":
834
+ str += "\f";
835
+ break;
836
+ case "v":
837
+ str += "\v";
838
+ break;
839
+ default:
840
+ str += ch;
841
+ }
842
+ } else {
843
+ str += ch;
844
+ }
845
+ }
846
+ if (!closed) {
847
+ this.throwError('Unclosed quote after "' + str + '"');
848
+ }
849
+ return {
850
+ type: _Jsep.LITERAL,
851
+ value: str,
852
+ raw: this.expr.substring(startIndex, this.index)
853
+ };
854
+ }
855
+ /**
856
+ * Gobbles only identifiers
857
+ * e.g.: `foo`, `_value`, `$x1`
858
+ * Also, this function checks if that identifier is a literal:
859
+ * (e.g. `true`, `false`, `null`) or `this`
860
+ * @returns {jsep.Identifier}
861
+ */
862
+ gobbleIdentifier() {
863
+ let ch = this.code, start = this.index;
864
+ if (_Jsep.isIdentifierStart(ch)) {
865
+ this.index++;
866
+ } else {
867
+ this.throwError("Unexpected " + this.char);
868
+ }
869
+ while (this.index < this.expr.length) {
870
+ ch = this.code;
871
+ if (_Jsep.isIdentifierPart(ch)) {
872
+ this.index++;
873
+ } else {
874
+ break;
875
+ }
876
+ }
877
+ return {
878
+ type: _Jsep.IDENTIFIER,
879
+ name: this.expr.slice(start, this.index)
880
+ };
881
+ }
882
+ /**
883
+ * Gobbles a list of arguments within the context of a function call
884
+ * or array literal. This function also assumes that the opening character
885
+ * `(` or `[` has already been gobbled, and gobbles expressions and commas
886
+ * until the terminator character `)` or `]` is encountered.
887
+ * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
888
+ * @param {number} termination
889
+ * @returns {jsep.Expression[]}
890
+ */
891
+ gobbleArguments(termination) {
892
+ const args = [];
893
+ let closed = false;
894
+ let separator_count = 0;
895
+ while (this.index < this.expr.length) {
896
+ this.gobbleSpaces();
897
+ let ch_i = this.code;
898
+ if (ch_i === termination) {
899
+ closed = true;
900
+ this.index++;
901
+ if (termination === _Jsep.CPAREN_CODE && separator_count && separator_count >= args.length) {
902
+ this.throwError("Unexpected token " + String.fromCharCode(termination));
903
+ }
904
+ break;
905
+ } else if (ch_i === _Jsep.COMMA_CODE) {
906
+ this.index++;
907
+ separator_count++;
908
+ if (separator_count !== args.length) {
909
+ if (termination === _Jsep.CPAREN_CODE) {
910
+ this.throwError("Unexpected token ,");
911
+ } else if (termination === _Jsep.CBRACK_CODE) {
912
+ for (let arg = args.length; arg < separator_count; arg++) {
913
+ args.push(null);
914
+ }
915
+ }
916
+ }
917
+ } else if (args.length !== separator_count && separator_count !== 0) {
918
+ this.throwError("Expected comma");
919
+ } else {
920
+ const node = this.gobbleExpression();
921
+ if (!node || node.type === _Jsep.COMPOUND) {
922
+ this.throwError("Expected comma");
923
+ }
924
+ args.push(node);
925
+ }
926
+ }
927
+ if (!closed) {
928
+ this.throwError("Expected " + String.fromCharCode(termination));
929
+ }
930
+ return args;
931
+ }
932
+ /**
933
+ * Responsible for parsing a group of things within parentheses `()`
934
+ * that have no identifier in front (so not a function call)
935
+ * This function assumes that it needs to gobble the opening parenthesis
936
+ * and then tries to gobble everything within that parenthesis, assuming
937
+ * that the next thing it should see is the close parenthesis. If not,
938
+ * then the expression probably doesn't have a `)`
939
+ * @returns {boolean|jsep.Expression}
940
+ */
941
+ gobbleGroup() {
942
+ this.index++;
943
+ let nodes = this.gobbleExpressions(_Jsep.CPAREN_CODE);
944
+ if (this.code === _Jsep.CPAREN_CODE) {
945
+ this.index++;
946
+ if (nodes.length === 1) {
947
+ return nodes[0];
948
+ } else if (!nodes.length) {
949
+ return false;
950
+ } else {
951
+ return {
952
+ type: _Jsep.SEQUENCE_EXP,
953
+ expressions: nodes
954
+ };
955
+ }
956
+ } else {
957
+ this.throwError("Unclosed (");
958
+ }
959
+ }
960
+ /**
961
+ * Responsible for parsing Array literals `[1, 2, 3]`
962
+ * This function assumes that it needs to gobble the opening bracket
963
+ * and then tries to gobble the expressions as arguments.
964
+ * @returns {jsep.ArrayExpression}
965
+ */
966
+ gobbleArray() {
967
+ this.index++;
968
+ return {
969
+ type: _Jsep.ARRAY_EXP,
970
+ elements: this.gobbleArguments(_Jsep.CBRACK_CODE)
971
+ };
972
+ }
973
+ };
974
+ var hooks = new Hooks();
975
+ Object.assign(Jsep, {
976
+ hooks,
977
+ plugins: new Plugins(Jsep),
978
+ // Node Types
979
+ // ----------
980
+ // This is the full set of types that any JSEP node can be.
981
+ // Store them here to save space when minified
982
+ COMPOUND: "Compound",
983
+ SEQUENCE_EXP: "SequenceExpression",
984
+ IDENTIFIER: "Identifier",
985
+ MEMBER_EXP: "MemberExpression",
986
+ LITERAL: "Literal",
987
+ THIS_EXP: "ThisExpression",
988
+ CALL_EXP: "CallExpression",
989
+ UNARY_EXP: "UnaryExpression",
990
+ BINARY_EXP: "BinaryExpression",
991
+ ARRAY_EXP: "ArrayExpression",
992
+ TAB_CODE: 9,
993
+ LF_CODE: 10,
994
+ CR_CODE: 13,
995
+ SPACE_CODE: 32,
996
+ PERIOD_CODE: 46,
997
+ // '.'
998
+ COMMA_CODE: 44,
999
+ // ','
1000
+ SQUOTE_CODE: 39,
1001
+ // single quote
1002
+ DQUOTE_CODE: 34,
1003
+ // double quotes
1004
+ OPAREN_CODE: 40,
1005
+ // (
1006
+ CPAREN_CODE: 41,
1007
+ // )
1008
+ OBRACK_CODE: 91,
1009
+ // [
1010
+ CBRACK_CODE: 93,
1011
+ // ]
1012
+ QUMARK_CODE: 63,
1013
+ // ?
1014
+ SEMCOL_CODE: 59,
1015
+ // ;
1016
+ COLON_CODE: 58,
1017
+ // :
1018
+ // Operations
1019
+ // ----------
1020
+ // Use a quickly-accessible map to store all of the unary operators
1021
+ // Values are set to `1` (it really doesn't matter)
1022
+ unary_ops: {
1023
+ "-": 1,
1024
+ "!": 1,
1025
+ "~": 1,
1026
+ "+": 1
1027
+ },
1028
+ // Also use a map for the binary operations but set their values to their
1029
+ // binary precedence for quick reference (higher number = higher precedence)
1030
+ // see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
1031
+ binary_ops: {
1032
+ "||": 1,
1033
+ "??": 1,
1034
+ "&&": 2,
1035
+ "|": 3,
1036
+ "^": 4,
1037
+ "&": 5,
1038
+ "==": 6,
1039
+ "!=": 6,
1040
+ "===": 6,
1041
+ "!==": 6,
1042
+ "<": 7,
1043
+ ">": 7,
1044
+ "<=": 7,
1045
+ ">=": 7,
1046
+ "<<": 8,
1047
+ ">>": 8,
1048
+ ">>>": 8,
1049
+ "+": 9,
1050
+ "-": 9,
1051
+ "*": 10,
1052
+ "/": 10,
1053
+ "%": 10,
1054
+ "**": 11
1055
+ },
1056
+ // sets specific binary_ops as right-associative
1057
+ right_associative: /* @__PURE__ */ new Set(["**"]),
1058
+ // Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
1059
+ additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
1060
+ // Literals
1061
+ // ----------
1062
+ // Store the values to return for the various literals we may encounter
1063
+ literals: {
1064
+ "true": true,
1065
+ "false": false,
1066
+ "null": null
1067
+ },
1068
+ // Except for `this`, which is special. This could be changed to something like `'self'` as well
1069
+ this_str: "this"
1070
+ });
1071
+ Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
1072
+ Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
1073
+ var jsep = (expr) => new Jsep(expr).parse();
1074
+ var stdClassProps = Object.getOwnPropertyNames(class Test {
1075
+ });
1076
+ Object.getOwnPropertyNames(Jsep).filter((prop) => !stdClassProps.includes(prop) && jsep[prop] === void 0).forEach((m) => {
1077
+ jsep[m] = Jsep[m];
1078
+ });
1079
+ jsep.Jsep = Jsep;
1080
+ var CONDITIONAL_EXP = "ConditionalExpression";
1081
+ var ternary = {
1082
+ name: "ternary",
1083
+ init(jsep22) {
1084
+ jsep22.hooks.add("after-expression", function gobbleTernary(env) {
1085
+ if (env.node && this.code === jsep22.QUMARK_CODE) {
1086
+ this.index++;
1087
+ const test = env.node;
1088
+ const consequent = this.gobbleExpression();
1089
+ if (!consequent) {
1090
+ this.throwError("Expected expression");
1091
+ }
1092
+ this.gobbleSpaces();
1093
+ if (this.code === jsep22.COLON_CODE) {
1094
+ this.index++;
1095
+ const alternate = this.gobbleExpression();
1096
+ if (!alternate) {
1097
+ this.throwError("Expected expression");
1098
+ }
1099
+ env.node = {
1100
+ type: CONDITIONAL_EXP,
1101
+ test,
1102
+ consequent,
1103
+ alternate
1104
+ };
1105
+ if (test.operator && jsep22.binary_ops[test.operator] <= 0.9) {
1106
+ let newTest = test;
1107
+ while (newTest.right.operator && jsep22.binary_ops[newTest.right.operator] <= 0.9) {
1108
+ newTest = newTest.right;
1109
+ }
1110
+ env.node.test = newTest.right;
1111
+ newTest.right = env.node;
1112
+ env.node = test;
1113
+ }
1114
+ } else {
1115
+ this.throwError("Expected :");
1116
+ }
1117
+ }
1118
+ });
1119
+ }
1120
+ };
1121
+ jsep.plugins.register(ternary);
1122
+ var runtime_default = jsep;
1123
+
1124
+ // dist/expressions/function-libraries.js
1125
+ var import_core = require("@math.gl/core");
1126
+ var BASIC_MATH_FUNCTION_LIBRARY = {
1127
+ abs: Math.abs,
1128
+ acos: Math.acos,
1129
+ asin: Math.asin,
1130
+ atan: Math.atan,
1131
+ ceil: Math.ceil,
1132
+ clamp: import_core.clamp,
1133
+ cos: Math.cos,
1134
+ degrees: import_core.degrees,
1135
+ exp: Math.exp,
1136
+ floor: Math.floor,
1137
+ lerp: import_core.lerp,
1138
+ log: Math.log,
1139
+ max: Math.max,
1140
+ min: Math.min,
1141
+ normalizeAngle: import_core.normalizeAngle,
1142
+ pow: Math.pow,
1143
+ radians: import_core.radians,
1144
+ round: Math.round,
1145
+ safeMod: import_core.safeMod,
1146
+ sign: Math.sign,
1147
+ sin: Math.sin,
1148
+ sqrt: Math.sqrt,
1149
+ tan: Math.tan,
1150
+ toDegrees: import_core.toDegrees,
1151
+ toRadians: import_core.toRadians,
1152
+ trunc: Math.trunc
1153
+ };
1154
+ function mergeFunctionLibraries(context, options) {
1155
+ var _a2, _b;
1156
+ if (!((_a2 = options == null ? void 0 : options.libraries) == null ? void 0 : _a2.length)) {
1157
+ if (!(options == null ? void 0 : options.registry)) {
1158
+ return context;
1159
+ }
1160
+ }
1161
+ return Object.assign({}, (_b = options.registry) == null ? void 0 : _b.getFunctionTable(), ...options.libraries || [], context);
1162
+ }
1163
+
1164
+ // dist/expressions/expression-eval.js
1165
+ var jsep2 = runtime_default;
1166
+ var DEFAULT_PRECEDENCE = {
1167
+ "||": 1,
1168
+ "&&": 2,
1169
+ "|": 3,
1170
+ "^": 4,
1171
+ "&": 5,
1172
+ "==": 6,
1173
+ "!=": 6,
1174
+ "===": 6,
1175
+ "!==": 6,
1176
+ "<": 7,
1177
+ ">": 7,
1178
+ "<=": 7,
1179
+ ">=": 7,
1180
+ "<<": 8,
1181
+ ">>": 8,
1182
+ ">>>": 8,
1183
+ "+": 9,
1184
+ "-": 9,
1185
+ "*": 10,
1186
+ "/": 10,
1187
+ "%": 10
1188
+ };
1189
+ var binops = {
1190
+ "||": (a, b) => a || b,
1191
+ "&&": (a, b) => a && b,
1192
+ "|": (a, b) => a | b,
1193
+ "^": (a, b) => a ^ b,
1194
+ "&": (a, b) => a & b,
1195
+ "==": (a, b) => {
1196
+ return a == b;
1197
+ },
1198
+ "!=": (a, b) => {
1199
+ return a != b;
1200
+ },
1201
+ "===": (a, b) => a === b,
1202
+ "!==": (a, b) => a !== b,
1203
+ "<": (a, b) => a < b,
1204
+ ">": (a, b) => a > b,
1205
+ "<=": (a, b) => a <= b,
1206
+ ">=": (a, b) => a >= b,
1207
+ "<<": (a, b) => a << b,
1208
+ ">>": (a, b) => a >> b,
1209
+ ">>>": (a, b) => a >>> b,
1210
+ "+": (a, b) => {
1211
+ return a + b;
1212
+ },
1213
+ "-": (a, b) => a - b,
1214
+ "*": (a, b) => a * b,
1215
+ "/": (a, b) => a / b,
1216
+ "%": (a, b) => a % b
1217
+ };
1218
+ var unops = {
1219
+ "-": (a) => -a,
1220
+ "+": (a) => {
1221
+ return +a;
1222
+ },
1223
+ "~": (a) => ~a,
1224
+ "!": (a) => !a
1225
+ };
1226
+ function evaluateArray(list, context) {
1227
+ return list.map((value) => evaluate(value, context));
1228
+ }
1229
+ async function evaluateArrayAsync(list, context) {
1230
+ return await Promise.all(list.map((value) => evaluateExpressionAsync(value, context)));
1231
+ }
1232
+ function evaluateMember(node, context) {
1233
+ const object = evaluate(node.object, context);
1234
+ const key = node.computed ? evaluate(node.property, context) : node.property.name;
1235
+ if (/^__proto__|prototype|constructor$/.test(key)) {
1236
+ throw new Error(`Access to member "${key}" disallowed.`);
1237
+ }
1238
+ return [object, object == null ? void 0 : object[key]];
1239
+ }
1240
+ async function evaluateMemberAsync(node, context) {
1241
+ const object = await evaluateExpressionAsync(node.object, context);
1242
+ const key = node.computed ? await evaluateExpressionAsync(node.property, context) : node.property.name;
1243
+ if (/^__proto__|prototype|constructor$/.test(key)) {
1244
+ throw new Error(`Access to member "${key}" disallowed.`);
1245
+ }
1246
+ return [object, object == null ? void 0 : object[key]];
1247
+ }
1248
+ function evaluateExpression(node, context, options) {
1249
+ const expression = node;
1250
+ const mergedContext = mergeFunctionLibraries(context, options);
1251
+ switch (expression.type) {
1252
+ case "ArrayExpression":
1253
+ return evaluateArray(expression.elements, mergedContext);
1254
+ case "LogicalExpression":
1255
+ case "BinaryExpression":
1256
+ if (expression.operator === "||") {
1257
+ return evaluate(expression.left, mergedContext) || evaluate(expression.right, mergedContext);
1258
+ }
1259
+ if (expression.operator === "&&") {
1260
+ return evaluate(expression.left, mergedContext) && evaluate(expression.right, mergedContext);
1261
+ }
1262
+ return binops[expression.operator](evaluate(expression.left, mergedContext), evaluate(expression.right, mergedContext));
1263
+ case "CallExpression": {
1264
+ let caller;
1265
+ let fn;
1266
+ if (expression.callee.type === "MemberExpression") {
1267
+ const member = evaluateMember(expression.callee, mergedContext);
1268
+ caller = member[0];
1269
+ fn = member[1];
1270
+ } else {
1271
+ fn = evaluate(expression.callee, mergedContext);
1272
+ }
1273
+ if (typeof fn !== "function") {
1274
+ return void 0;
1275
+ }
1276
+ return fn.apply(caller, evaluateArray(expression.arguments, mergedContext));
1277
+ }
1278
+ case "ConditionalExpression":
1279
+ return evaluate(expression.test, mergedContext) ? evaluate(expression.consequent, mergedContext) : evaluate(expression.alternate, mergedContext);
1280
+ case "Identifier":
1281
+ return mergedContext[expression.name];
1282
+ case "Literal":
1283
+ return expression.value;
1284
+ case "MemberExpression":
1285
+ return evaluateMember(expression, mergedContext)[1];
1286
+ case "ThisExpression":
1287
+ return mergedContext;
1288
+ case "UnaryExpression":
1289
+ return unops[expression.operator](evaluate(expression.argument, mergedContext));
1290
+ default:
1291
+ return void 0;
1292
+ }
1293
+ }
1294
+ function evaluate(node, context) {
1295
+ return evaluateExpression(node, context);
1296
+ }
1297
+ async function evaluateExpressionAsync(node, context, options) {
1298
+ const expression = node;
1299
+ const mergedContext = mergeFunctionLibraries(context, options);
1300
+ switch (expression.type) {
1301
+ case "ArrayExpression":
1302
+ return await evaluateArrayAsync(expression.elements, mergedContext);
1303
+ case "LogicalExpression":
1304
+ case "BinaryExpression":
1305
+ if (expression.operator === "||") {
1306
+ return await evaluateExpressionAsync(expression.left, mergedContext) || await evaluateExpressionAsync(expression.right, mergedContext);
1307
+ }
1308
+ if (expression.operator === "&&") {
1309
+ return await evaluateExpressionAsync(expression.left, mergedContext) && await evaluateExpressionAsync(expression.right, mergedContext);
1310
+ }
1311
+ return binops[expression.operator](await evaluateExpressionAsync(expression.left, mergedContext), await evaluateExpressionAsync(expression.right, mergedContext));
1312
+ case "CallExpression": {
1313
+ let caller;
1314
+ let fn;
1315
+ if (expression.callee.type === "MemberExpression") {
1316
+ const member = await evaluateMemberAsync(expression.callee, mergedContext);
1317
+ caller = member[0];
1318
+ fn = member[1];
1319
+ } else {
1320
+ fn = await evaluateExpressionAsync(expression.callee, mergedContext);
1321
+ }
1322
+ if (typeof fn !== "function") {
1323
+ return void 0;
1324
+ }
1325
+ return await fn.apply(caller, await evaluateArrayAsync(expression.arguments, mergedContext));
1326
+ }
1327
+ case "ConditionalExpression":
1328
+ return await evaluateExpressionAsync(expression.test, mergedContext) ? await evaluateExpressionAsync(expression.consequent, mergedContext) : await evaluateExpressionAsync(expression.alternate, mergedContext);
1329
+ case "Identifier":
1330
+ return mergedContext[expression.name];
1331
+ case "Literal":
1332
+ return expression.value;
1333
+ case "MemberExpression":
1334
+ return (await evaluateMemberAsync(expression, mergedContext))[1];
1335
+ case "ThisExpression":
1336
+ return mergedContext;
1337
+ case "UnaryExpression":
1338
+ return unops[expression.operator](await evaluateExpressionAsync(expression.argument, mergedContext));
1339
+ default:
1340
+ return void 0;
1341
+ }
1342
+ }
1343
+ function compile(expression, options) {
1344
+ const ast = parse(expression, options);
1345
+ return (context) => evaluateWithDiagnostics(ast, context, options);
1346
+ }
1347
+ function compileAsync(expression, options) {
1348
+ const ast = parse(expression, options);
1349
+ return (context) => evaluateAsync(ast, context, options);
1350
+ }
1351
+ function addUnaryOp(operator, fn) {
1352
+ jsep2.addUnaryOp(operator);
1353
+ unops[operator] = fn;
1354
+ }
1355
+ function addBinaryOp(operator, precedenceOrFn, fn) {
1356
+ if (fn) {
1357
+ jsep2.addBinaryOp(operator, precedenceOrFn);
1358
+ binops[operator] = fn;
1359
+ return;
1360
+ }
1361
+ jsep2.addBinaryOp(operator, DEFAULT_PRECEDENCE[operator] || 1);
1362
+ binops[operator] = precedenceOrFn;
1363
+ }
1364
+ function parse(expression, options) {
1365
+ try {
1366
+ return typeof expression === "string" ? jsep2(expression) : expression;
1367
+ } catch (error) {
1368
+ reportDiagnosticError(options == null ? void 0 : options.log, error);
1369
+ throw error;
1370
+ }
1371
+ }
1372
+ function evaluateWithDiagnostics(node, context, options) {
1373
+ try {
1374
+ return evaluateExpression(node, context, options);
1375
+ } catch (error) {
1376
+ reportDiagnosticError(options == null ? void 0 : options.log, error);
1377
+ throw error;
1378
+ }
1379
+ }
1380
+ async function evaluateAsync(node, context, options) {
1381
+ try {
1382
+ return await evaluateExpressionAsync(node, context, options);
1383
+ } catch (error) {
1384
+ reportDiagnosticError(options == null ? void 0 : options.log, error);
1385
+ throw error;
1386
+ }
1387
+ }
1388
+
1389
+ // dist/expressions/get.js
1390
+ function get(container, compositeKey) {
1391
+ let value = container;
1392
+ for (const key of getKeys(compositeKey)) {
1393
+ value = isObject(value) ? value[key] : void 0;
1394
+ }
1395
+ return value;
1396
+ }
1397
+ function isObject(value) {
1398
+ return value !== null && typeof value === "object";
1399
+ }
1400
+ var keyMap = /* @__PURE__ */ Object.create(null);
1401
+ function getKeys(compositeKey) {
1402
+ let keyList = keyMap[compositeKey];
1403
+ if (!keyList) {
1404
+ keyList = compositeKey.split(".");
1405
+ keyMap[compositeKey] = keyList;
1406
+ }
1407
+ return keyList;
1408
+ }
1409
+
1410
+ // dist/expressions/parse-expression-string.js
1411
+ var cachedExpressionMap = Object.assign(/* @__PURE__ */ Object.create(null), {
1412
+ "-": (object) => object
1413
+ });
1414
+ function parseExpressionString(propValue) {
1415
+ if (propValue in cachedExpressionMap) {
1416
+ return cachedExpressionMap[propValue];
1417
+ }
1418
+ const ast = parse(propValue);
1419
+ const func = ast.type === "Identifier" ? (row) => get(row, propValue) : compileAst(ast);
1420
+ cachedExpressionMap[propValue] = func;
1421
+ return func;
1422
+ }
1423
+ function compileAst(ast) {
1424
+ traverse(ast, (node) => {
1425
+ if (node.type === "CallExpression") {
1426
+ throw new Error("Function calls not allowed in expression accessors");
1427
+ }
1428
+ });
1429
+ return (row) => evaluateWithDiagnostics(ast, row);
1430
+ }
1431
+ function traverse(node, visitor) {
1432
+ if (Array.isArray(node)) {
1433
+ node.forEach((element) => traverse(element, visitor));
1434
+ return;
1435
+ }
1436
+ if (node && typeof node === "object") {
1437
+ if (isNodeLike(node)) {
1438
+ visitor(node);
1439
+ }
1440
+ for (const key in node) {
1441
+ traverse(node[key], visitor);
1442
+ }
1443
+ }
1444
+ }
1445
+ function isNodeLike(node) {
1446
+ return "type" in node && typeof node.type === "string";
1447
+ }
1448
+
1449
+ // dist/expressions/scalar-type.js
1450
+ var COLUMNAR_SCALAR_TYPES = Object.freeze([
1451
+ "int8",
1452
+ "int16",
1453
+ "int32",
1454
+ "int64",
1455
+ "uint8",
1456
+ "uint16",
1457
+ "uint32",
1458
+ "uint64",
1459
+ "float16",
1460
+ "float32",
1461
+ "float64",
1462
+ "bool",
1463
+ "utf8"
1464
+ ]);
1465
+ function isColumnarScalarType(value) {
1466
+ return typeof value === "string" && COLUMNAR_SCALAR_TYPES.includes(value);
1467
+ }
1468
+
1469
+ // dist/expressions/columnar-predicate.js
1470
+ function getColumnarPredicateColumns(predicate) {
1471
+ return [...new Set(getColumnarPredicatePaths(predicate).map((path) => path[0]))];
1472
+ }
1473
+ function getColumnarPredicatePath(property) {
1474
+ return typeof property.property === "string" ? [property.property] : [...property.property];
1475
+ }
1476
+ function getColumnarPredicatePaths(predicate) {
1477
+ const paths = /* @__PURE__ */ new Map();
1478
+ visitColumnarPredicate(predicate, (child) => {
1479
+ if ("property" in child.args[0]) {
1480
+ const path = getColumnarPredicatePath(child.args[0]);
1481
+ paths.set(path.join("\0"), path);
1482
+ }
1483
+ });
1484
+ return [...paths.values()];
1485
+ }
1486
+ function getColumnarPredicateParameterNames(predicate) {
1487
+ const parameterNames = /* @__PURE__ */ new Set();
1488
+ visitColumnarPredicate(predicate, (child) => {
1489
+ if (child.op === "and" || child.op === "or" || child.op === "not" || child.op === "isNull") {
1490
+ return;
1491
+ }
1492
+ const values = child.op === "in" ? child.args[1] : [child.args[1]];
1493
+ for (const value of values) {
1494
+ if (isColumnarPredicateParameter(value)) {
1495
+ parameterNames.add(value.parameter);
1496
+ }
1497
+ }
1498
+ });
1499
+ return [...parameterNames];
1500
+ }
1501
+ function copyColumnarPredicate(predicate) {
1502
+ if (predicate.op === "and" || predicate.op === "or") {
1503
+ return { op: predicate.op, args: predicate.args.map(copyColumnarPredicate) };
1504
+ }
1505
+ if (predicate.op === "not") {
1506
+ return { op: "not", args: [copyColumnarPredicate(predicate.args[0])] };
1507
+ }
1508
+ const leaf = predicate;
1509
+ const property = copyColumnarPredicateProperty({
1510
+ ...leaf.args[0],
1511
+ property: [...getColumnarPredicatePath(leaf.args[0])]
1512
+ });
1513
+ if (leaf.op === "isNull")
1514
+ return { op: "isNull", args: [property] };
1515
+ if (leaf.op === "in") {
1516
+ return { op: "in", args: [property, leaf.args[1].map(copyColumnarPredicateValue)] };
1517
+ }
1518
+ return { op: leaf.op, args: [property, copyColumnarPredicateValue(leaf.args[1])] };
1519
+ }
1520
+ function validateColumnarPredicate(predicate, availableColumns) {
1521
+ visitColumnarPredicate(predicate, (child) => {
1522
+ if (child.op === "and" || child.op === "or") {
1523
+ if (child.args.length < 2)
1524
+ throw new Error(`Columnar predicate ${child.op} requires at least two child predicates`);
1525
+ return;
1526
+ }
1527
+ if (child.op === "not")
1528
+ return;
1529
+ const leaf = child;
1530
+ const casts = leaf.args[0].casts;
1531
+ if (casts !== void 0 && (!Array.isArray(casts) || !casts.length || casts.length > 64 || Array.from(casts).some((type) => !isColumnarScalarType(type))))
1532
+ throw new Error("Invalid columnar predicate casts");
1533
+ const path = getColumnarPredicatePath(leaf.args[0]);
1534
+ if (!path.length || path.some((component) => !component)) {
1535
+ throw new Error("Columnar predicate property path must contain non-empty strings");
1536
+ }
1537
+ if (!availableColumns.has(path[0]))
1538
+ throw new Error(`Columnar predicate column not found: ${path.join(".")}`);
1539
+ if (leaf.op === "in" && leaf.args[1].length === 0) {
1540
+ throw new Error("Columnar predicate in requires at least one value");
1541
+ }
1542
+ });
1543
+ }
1544
+ function isColumnarPredicateParameter(value) {
1545
+ const parameterValue = value;
1546
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && Object.prototype.hasOwnProperty.call(value, "parameter") && typeof parameterValue.parameter === "string" && parameterValue.parameter.length > 0;
1547
+ }
1548
+ function isColumnarPredicateValue(value) {
1549
+ return typeof value === "boolean" || typeof value === "bigint" || typeof value === "string" || typeof value === "number" && Number.isFinite(value) || value instanceof Date && Number.isFinite(value.getTime()) || value instanceof Uint8Array;
1550
+ }
1551
+ function bindColumnarPredicateParameters(predicate, parameters) {
1552
+ switch (predicate.op) {
1553
+ case "and":
1554
+ case "or":
1555
+ return {
1556
+ op: predicate.op,
1557
+ args: predicate.args.map((child) => bindColumnarPredicateParameters(child, parameters))
1558
+ };
1559
+ case "not":
1560
+ return {
1561
+ op: "not",
1562
+ args: [bindColumnarPredicateParameters(predicate.args[0], parameters)]
1563
+ };
1564
+ case "isNull":
1565
+ return { op: "isNull", args: [copyColumnarPredicateProperty(predicate.args[0])] };
1566
+ case "in":
1567
+ return {
1568
+ op: "in",
1569
+ args: [
1570
+ copyColumnarPredicateProperty(predicate.args[0]),
1571
+ predicate.args[1].map((value) => bindColumnarPredicateValue(value, parameters))
1572
+ ]
1573
+ };
1574
+ default:
1575
+ return {
1576
+ op: predicate.op,
1577
+ args: [
1578
+ copyColumnarPredicateProperty(predicate.args[0]),
1579
+ bindColumnarPredicateValue(predicate.args[1], parameters)
1580
+ ]
1581
+ };
1582
+ }
1583
+ }
1584
+ function visitColumnarPredicate(predicate, visitor) {
1585
+ visitor(predicate);
1586
+ if (predicate.op === "and" || predicate.op === "or")
1587
+ predicate.args.forEach((child) => visitColumnarPredicate(child, visitor));
1588
+ else if (predicate.op === "not")
1589
+ visitColumnarPredicate(predicate.args[0], visitor);
1590
+ }
1591
+ function bindColumnarPredicateValue(value, parameters) {
1592
+ if (!isColumnarPredicateParameter(value))
1593
+ return value;
1594
+ if (!Object.prototype.hasOwnProperty.call(parameters, value.parameter)) {
1595
+ throw new Error(`Columnar predicate parameter ":${value.parameter}" requires a value`);
1596
+ }
1597
+ const parameterValue = parameters[value.parameter];
1598
+ if (isColumnarPredicateParameter(parameterValue)) {
1599
+ throw new Error(`Columnar predicate parameter ":${value.parameter}" cannot reference another parameter`);
1600
+ }
1601
+ if (!isColumnarPredicateValue(parameterValue)) {
1602
+ throw new Error(`Columnar predicate parameter ":${value.parameter}" has an unsupported value`);
1603
+ }
1604
+ return copyColumnarPredicateValue(parameterValue);
1605
+ }
1606
+ function copyColumnarPredicateProperty(property) {
1607
+ return {
1608
+ ...property,
1609
+ ...property.casts ? { casts: [...property.casts] } : {},
1610
+ property: typeof property.property === "string" ? property.property : [...property.property]
1611
+ };
1612
+ }
1613
+ function copyColumnarPredicateValue(value) {
1614
+ if (value instanceof Uint8Array)
1615
+ return value.slice();
1616
+ if (value instanceof Date)
1617
+ return new Date(value.getTime());
1618
+ return value;
1619
+ }
1620
+
1621
+ // dist/expressions/ast.js
1622
+ var MAXIMUM_EXPRESSION_NODES = 16384;
1623
+ var MAXIMUM_EXPRESSION_DEPTH = 192;
1624
+ function validateExpressionAST(value, options = {}) {
1625
+ visitExpressionAST(value, () => {
1626
+ }, options);
1627
+ }
1628
+ function getExpressionColumns(expression, options = {}) {
1629
+ const columns = /* @__PURE__ */ new Set();
1630
+ visitExpressionAST(expression, (node) => {
1631
+ if (node.type === "Identifier")
1632
+ columns.add(node.name);
1633
+ }, options);
1634
+ return [...columns];
1635
+ }
1636
+ function visitExpressionAST(value, visit, options) {
1637
+ var _a2;
1638
+ const maxNodes = options.maxNodes ?? MAXIMUM_EXPRESSION_NODES, maxDepth = options.maxDepth ?? MAXIMUM_EXPRESSION_DEPTH;
1639
+ if (!Number.isSafeInteger(maxNodes) || maxNodes < 1 || maxNodes > MAXIMUM_EXPRESSION_NODES || !Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > MAXIMUM_EXPRESSION_DEPTH)
1640
+ throw new Error(`Expression AST limits must not exceed ${MAXIMUM_EXPRESSION_NODES} nodes and ${MAXIMUM_EXPRESSION_DEPTH} levels`);
1641
+ const stack = [{ node: value, depth: 0 }];
1642
+ const ancestors = /* @__PURE__ */ new Set();
1643
+ let count = 0;
1644
+ while (stack.length) {
1645
+ const { node: input, depth, exit } = stack.pop();
1646
+ if (!input || typeof input !== "object" || Array.isArray(input))
1647
+ throw new Error("Invalid expression AST node");
1648
+ if (exit) {
1649
+ ancestors.delete(input);
1650
+ continue;
1651
+ }
1652
+ if (++count > maxNodes || depth > maxDepth)
1653
+ throw new Error("Expression AST exceeds node or depth limit");
1654
+ if (ancestors.has(input))
1655
+ throw new Error("Expression AST contains a cycle");
1656
+ ancestors.add(input);
1657
+ stack.push({ node: input, depth, exit: true });
1658
+ const node = input;
1659
+ const children = [];
1660
+ switch (node.type) {
1661
+ case "Identifier":
1662
+ if (typeof node.name !== "string" || !node.name.length || node.name.length > 65536)
1663
+ throw new Error("Invalid expression identifier");
1664
+ break;
1665
+ case "Literal":
1666
+ if (node.value !== null && !["number", "bigint", "boolean", "string"].includes(typeof node.value) && !(node.value instanceof Uint8Array) && !(node.value instanceof Date && Number.isFinite(node.value.getTime())))
1667
+ throw new Error("Unsupported expression literal");
1668
+ if (node.raw !== void 0 && typeof node.raw !== "string")
1669
+ throw new Error("Invalid literal annotation");
1670
+ break;
1671
+ case "UnaryExpression":
1672
+ if (typeof node.operator !== "string" || !node.operator.length || node.operator.length > 32)
1673
+ throw new Error("Invalid expression operator");
1674
+ if (node.prefix !== void 0 && typeof node.prefix !== "boolean")
1675
+ throw new Error("Invalid unary annotation");
1676
+ children.push(node.argument);
1677
+ break;
1678
+ case "LogicalExpression":
1679
+ if (node.operator !== "&&" && node.operator !== "||")
1680
+ throw new Error("Invalid logical operator");
1681
+ children.push(node.left, node.right);
1682
+ break;
1683
+ case "BinaryExpression":
1684
+ if (typeof node.operator !== "string" || !node.operator.length || node.operator.length > 32)
1685
+ throw new Error("Invalid expression operator");
1686
+ children.push(node.left, node.right);
1687
+ break;
1688
+ case "ConditionalExpression":
1689
+ children.push(node.test, node.consequent, node.alternate);
1690
+ break;
1691
+ case "ArrayExpression":
1692
+ if (!Array.isArray(node.elements))
1693
+ throw new Error("Invalid expression array");
1694
+ if (node.elements.length + count > maxNodes)
1695
+ throw new Error("Expression AST exceeds node limit");
1696
+ for (const element of node.elements) {
1697
+ if (element == null)
1698
+ throw new Error("Expression array contains holes");
1699
+ children.push(element);
1700
+ }
1701
+ break;
1702
+ case "CallExpression":
1703
+ if (((_a2 = node.callee) == null ? void 0 : _a2.type) !== "Identifier" || typeof node.callee.name !== "string" || !node.callee.name.length || node.callee.name.length > 65536 || !Array.isArray(node.arguments) || node.sqlFunction !== void 0 && node.sqlFunction !== true)
1704
+ throw new Error("Expressions require named function calls");
1705
+ if (node.arguments.length + count > maxNodes)
1706
+ throw new Error("Expression AST exceeds node limit");
1707
+ children.push(...node.arguments);
1708
+ break;
1709
+ default:
1710
+ throw new Error(`Unsupported portable expression AST node: ${node.type}`);
1711
+ }
1712
+ if (children.length + count + stack.length - ancestors.size > maxNodes)
1713
+ throw new Error("Expression AST exceeds node limit");
1714
+ visit(node);
1715
+ for (let index = children.length - 1; index >= 0; index--)
1716
+ stack.push({ node: children[index], depth: depth + 1 });
1717
+ }
1718
+ }
1719
+
1720
+ // dist/expressions/predicate-expression.js
1721
+ function columnarPredicateToExpression(predicate, options = {}) {
1722
+ const stack = [{ node: predicate, depth: 0 }];
1723
+ let count = 0;
1724
+ let expressionNodes = 0;
1725
+ while (stack.length) {
1726
+ const { node, depth } = stack.pop();
1727
+ if (++count > 4096 || depth > 64)
1728
+ throw new Error("Predicate exceeds node or depth limit");
1729
+ if (!node || typeof node !== "object" || !Array.isArray(node.args) || !["and", "or", "not", "isNull", "in", "=", "<>", "<", "<=", ">", ">="].includes(node.op))
1730
+ throw new Error("Invalid columnar predicate");
1731
+ if (node.op === "and" || node.op === "or" || node.op === "not") {
1732
+ if (node.op === "not" && node.args.length !== 1)
1733
+ throw new Error("NOT requires one predicate");
1734
+ if (node.args.length + count + stack.length > 4096)
1735
+ throw new Error("Predicate exceeds node limit");
1736
+ expressionNodes += node.op === "not" ? 1 : Math.max(0, node.args.length - 1);
1737
+ for (const child of node.args)
1738
+ stack.push({ node: child, depth: depth + 1 });
1739
+ } else if (node.args.length !== (node.op === "isNull" ? 1 : 2) || !node.args[0] || typeof node.args[0] !== "object" || node.op === "in" && !Array.isArray(node.args[1]))
1740
+ throw new Error("Invalid predicate arguments");
1741
+ if (node.op !== "and" && node.op !== "or" && node.op !== "not") {
1742
+ const property = node.args[0];
1743
+ if (typeof property.property !== "string" && (!Array.isArray(property.property) || property.property.length !== 1))
1744
+ throw new Error("Expression normalization requires top-level columns");
1745
+ const casts = property.casts;
1746
+ if (casts !== void 0 && (!Array.isArray(casts) || casts.length > 64))
1747
+ throw new Error("Invalid columnar predicate casts");
1748
+ const literals = node.op === "in" ? node.args[1].length : node.op === "isNull" ? 0 : 1;
1749
+ if (literals > 4096)
1750
+ throw new Error("Predicate membership exceeds node limit");
1751
+ expressionNodes += 2 + 2 * ((casts == null ? void 0 : casts.length) ?? 0) + literals;
1752
+ }
1753
+ if (expressionNodes > MAXIMUM_EXPRESSION_NODES)
1754
+ throw new Error("Predicate exceeds normalized AST node limit");
1755
+ }
1756
+ const bound = bindColumnarPredicateParameters(predicate, options.parameters ?? {});
1757
+ validateColumnarPredicate(bound, new Set(getColumnarPredicateColumns(bound)));
1758
+ const expression = convert(bound);
1759
+ validateExpressionAST(expression);
1760
+ return expression;
1761
+ }
1762
+ function combine(operator, expressions) {
1763
+ if (expressions.length === 1)
1764
+ return expressions[0];
1765
+ const midpoint = Math.floor(expressions.length / 2);
1766
+ return {
1767
+ type: "BinaryExpression",
1768
+ operator,
1769
+ left: combine(operator, expressions.slice(0, midpoint)),
1770
+ right: combine(operator, expressions.slice(midpoint))
1771
+ };
1772
+ }
1773
+ function convert(predicate) {
1774
+ if (predicate.op === "and" || predicate.op === "or")
1775
+ return combine(predicate.op === "and" ? "&&" : "||", predicate.args.map(convert));
1776
+ if (predicate.op === "not")
1777
+ return {
1778
+ type: "UnaryExpression",
1779
+ operator: "!",
1780
+ prefix: true,
1781
+ argument: convert(predicate.args[0])
1782
+ };
1783
+ const property = predicate.args[0];
1784
+ const path = typeof property.property === "string" ? [property.property] : property.property;
1785
+ if (path.length !== 1)
1786
+ throw new Error("Expression normalization requires top-level columns");
1787
+ let left = { type: "Identifier", name: path[0] };
1788
+ const call = (name, args) => ({ type: "CallExpression", callee: { type: "Identifier", name }, arguments: args });
1789
+ for (const type of property.casts ?? [])
1790
+ left = call("cast", [
1791
+ left,
1792
+ { type: "Literal", value: type, raw: JSON.stringify(type) }
1793
+ ]);
1794
+ const literal = (value) => {
1795
+ var _a2;
1796
+ if (value instanceof Date || value instanceof Uint8Array)
1797
+ throw new Error("Date and binary predicate literals require explicit backend conversion");
1798
+ if (["int64", "uint64"].includes(((_a2 = property.casts) == null ? void 0 : _a2.at(-1)) ?? "") && typeof value === "number" && Number.isSafeInteger(value))
1799
+ value = BigInt(value);
1800
+ return {
1801
+ type: "Literal",
1802
+ value,
1803
+ raw: typeof value === "bigint" ? String(value) : JSON.stringify(value)
1804
+ };
1805
+ };
1806
+ if (predicate.op === "isNull")
1807
+ return call("isNull", [left]);
1808
+ if (predicate.op === "in")
1809
+ return call("in", [left, ...predicate.args[1].map(literal)]);
1810
+ return {
1811
+ type: "BinaryExpression",
1812
+ operator: predicate.op === "=" ? "==" : predicate.op === "<>" ? "!=" : predicate.op,
1813
+ left,
1814
+ right: literal(predicate.args[1])
1815
+ };
1816
+ }
1817
+
1818
+ // dist/expressions/evaluation-error.js
1819
+ var _a;
1820
+ var brand = /* @__PURE__ */ Symbol.for("@math.gl/core/ExpressionEvaluationError");
1821
+ var codes = ["domain", "conversion", "overflow", "divisionByZero"];
1822
+ var ExpressionEvaluationError = class extends Error {
1823
+ constructor(code, message) {
1824
+ super(message);
1825
+ this.code = code;
1826
+ this.name = "ExpressionEvaluationError";
1827
+ this[_a] = true;
1828
+ if (!codes.includes(code))
1829
+ throw new TypeError("Unknown Arrow evaluation error code");
1830
+ }
1831
+ };
1832
+ _a = brand;
1833
+ function isExpressionEvaluationError(error) {
1834
+ return typeof error === "object" && error !== null && error[brand] === true && codes.includes(error.code);
1835
+ }
1836
+
1837
+ // dist/expressions/numeric-functions.js
1838
+ var numericTypes = [
1839
+ "int8",
1840
+ "int16",
1841
+ "int32",
1842
+ "int64",
1843
+ "uint8",
1844
+ "uint16",
1845
+ "uint32",
1846
+ "uint64",
1847
+ "float16",
1848
+ "float32",
1849
+ "float64"
1850
+ ];
1851
+ function definition(name, arity = 1, preserveInteger = false, semantics = {}, errors = ["domain", "overflow"]) {
1852
+ return Object.freeze({
1853
+ name,
1854
+ prototypes: Object.freeze(numericTypes.map((type) => Object.freeze({
1855
+ arguments: Object.freeze(Array.from({ length: arity }, () => type)),
1856
+ result: preserveInteger || type.startsWith("float") ? type : "float64"
1857
+ }))),
1858
+ nullHandling: "propagate",
1859
+ overloadResolution: "exactThenFloatingWidening",
1860
+ nanHandling: "propagate",
1861
+ errors: Object.freeze([...errors]),
1862
+ ...semantics
1863
+ });
1864
+ }
1865
+ var NUMERIC_FUNCTION_DEFINITIONS = Object.freeze({
1866
+ ABS: definition("ABS", 1, true, {}, ["overflow"]),
1867
+ SIGN: definition("SIGN", 1, true, {}, []),
1868
+ FLOOR: definition("FLOOR", 1, true, {}, []),
1869
+ CEILING: definition("CEILING", 1, true, {}, []),
1870
+ ROUND: definition("ROUND", 1, true, { rounding: "tiesAwayFromZero" }, []),
1871
+ TRUNC: definition("TRUNC", 1, true, {}, []),
1872
+ SQRT: definition("SQRT", 1, false, { domain: "nonNegative" }),
1873
+ POWER: definition("POWER", 2, false, { domain: "power" }),
1874
+ EXP: definition("EXP"),
1875
+ LN: definition("LN", 1, false, { domain: "positive" }),
1876
+ LOG10: definition("LOG10", 1, false, { domain: "positive" }),
1877
+ SIN: definition("SIN", 1, false, { angleUnit: "radians" }),
1878
+ COS: definition("COS", 1, false, { angleUnit: "radians" }),
1879
+ TAN: definition("TAN", 1, false, { angleUnit: "radians" }),
1880
+ ASIN: definition("ASIN", 1, false, { domain: "signedUnitInterval", angleUnit: "radians" }),
1881
+ ACOS: definition("ACOS", 1, false, { domain: "signedUnitInterval", angleUnit: "radians" }),
1882
+ ATAN: definition("ATAN", 1, false, { angleUnit: "radians" }),
1883
+ ATAN2: definition("ATAN2", 2, false, { angleUnit: "radians" }),
1884
+ DEGREES: definition("DEGREES"),
1885
+ RADIANS: definition("RADIANS"),
1886
+ MOD: definition("MOD", 2, true, { remainderSign: "dividend" }, ["divisionByZero", "domain"])
1887
+ });
1888
+ //# sourceMappingURL=index.cjs.map