@synnaxlabs/x 0.42.1 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/.turbo/turbo-build.log +93 -105
  2. package/.vscode/settings.json +4 -6
  3. package/README.md +1 -7
  4. package/dist/array.cjs +1 -0
  5. package/dist/array.js +7 -0
  6. package/dist/base-B5lQIJKc.js +38 -0
  7. package/dist/base-CTq-lhpU.cjs +1 -0
  8. package/dist/binary.cjs +1 -1
  9. package/dist/binary.js +1 -1
  10. package/dist/bounds.cjs +1 -1
  11. package/dist/bounds.js +2 -2
  12. package/dist/box.cjs +1 -1
  13. package/dist/box.js +1 -1
  14. package/dist/caseconv.cjs +1 -1
  15. package/dist/caseconv.js +2 -2
  16. package/dist/change.cjs +1 -1
  17. package/dist/change.js +10 -2
  18. package/dist/compare.cjs +1 -1
  19. package/dist/compare.js +1 -1
  20. package/dist/deep.cjs +1 -1
  21. package/dist/deep.js +92 -79
  22. package/dist/dimensions.cjs +1 -1
  23. package/dist/dimensions.js +41 -2
  24. package/dist/direction.cjs +1 -1
  25. package/dist/direction.js +1 -1
  26. package/dist/index-4GlOgZuh.js +99 -0
  27. package/dist/{direction-C-b6XTeU.cjs → index-B58dnYRu.cjs} +1 -1
  28. package/dist/index-BMGaoK93.cjs +1 -0
  29. package/dist/index-BTet04Hd.cjs +6 -0
  30. package/dist/{scale-DfJe9755.js → index-BUa-NXAX.js} +46 -46
  31. package/dist/{xy-D_LqxaGt.js → index-C-qYOegc.js} +62 -62
  32. package/dist/index-C07SBJhr.js +128 -0
  33. package/dist/{bounds-Bn5_l4Z3.js → index-C9EdKeu1.js} +77 -76
  34. package/dist/index-CM8ZDZ6s.cjs +1 -0
  35. package/dist/index-CV2JaHfw.cjs +1 -0
  36. package/dist/index-CeBvOwG8.cjs +3 -0
  37. package/dist/index-ClrGyGDp.js +205 -0
  38. package/dist/index-CqQXXeCI.cjs +1 -0
  39. package/dist/{location-C3aeu046.js → index-D6V-8SKw.js} +26 -26
  40. package/dist/index-DBGAIs_7.js +2492 -0
  41. package/dist/index-DEdq2tza.cjs +1 -0
  42. package/dist/index-DKMnHBGR.cjs +1 -0
  43. package/dist/index-Dql5FMcH.js +47 -0
  44. package/dist/{direction-BL0PhD1k.js → index-DxU1zwsd.js} +1 -1
  45. package/dist/index-WwMnwoLy.cjs +1 -0
  46. package/dist/index.cjs +5 -3
  47. package/dist/index.js +5372 -649
  48. package/dist/kv.cjs +1 -1
  49. package/dist/kv.js +45 -2
  50. package/dist/location.cjs +1 -1
  51. package/dist/location.js +1 -1
  52. package/dist/position.cjs +1 -1
  53. package/dist/position.js +83 -2
  54. package/dist/record.cjs +1 -1
  55. package/dist/record.js +8 -10
  56. package/dist/runtime.cjs +1 -1
  57. package/dist/runtime.js +27 -2
  58. package/dist/scale.cjs +1 -1
  59. package/dist/scale.js +1 -1
  60. package/dist/schemas-55Usj0Fg.js +3998 -0
  61. package/dist/schemas-DbXuI2Qr.cjs +27 -0
  62. package/dist/spatial.cjs +1 -1
  63. package/dist/spatial.js +25 -18
  64. package/dist/src/array/index.d.ts +2 -0
  65. package/dist/src/array/index.d.ts.map +1 -0
  66. package/dist/src/array/toArray.d.ts +19 -0
  67. package/dist/src/array/toArray.d.ts.map +1 -0
  68. package/dist/src/array/toArray.spec.d.ts +2 -0
  69. package/dist/src/array/toArray.spec.d.ts.map +1 -0
  70. package/dist/src/binary/codec.d.ts +8 -16
  71. package/dist/src/binary/codec.d.ts.map +1 -1
  72. package/dist/src/breaker/breaker.d.ts +6 -6
  73. package/dist/src/breaker/breaker.d.ts.map +1 -1
  74. package/dist/src/caseconv/caseconv.d.ts +1 -1
  75. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  76. package/dist/src/change/change.d.ts +3 -3
  77. package/dist/src/change/change.d.ts.map +1 -1
  78. package/dist/src/color/color.d.ts +63 -28
  79. package/dist/src/color/color.d.ts.map +1 -1
  80. package/dist/src/color/external.d.ts +0 -1
  81. package/dist/src/color/external.d.ts.map +1 -1
  82. package/dist/src/color/gradient.d.ts +9 -5
  83. package/dist/src/color/gradient.d.ts.map +1 -1
  84. package/dist/src/color/palette.d.ts +14 -6
  85. package/dist/src/color/palette.d.ts.map +1 -1
  86. package/dist/src/compare/compare.d.ts +4 -4
  87. package/dist/src/compare/compare.d.ts.map +1 -1
  88. package/dist/src/control/control.d.ts +32 -32
  89. package/dist/src/control/control.d.ts.map +1 -1
  90. package/dist/src/debounce/debounce.d.ts +1 -1
  91. package/dist/src/debounce/debounce.d.ts.map +1 -1
  92. package/dist/src/deep/delete.d.ts +1 -1
  93. package/dist/src/deep/delete.d.ts.map +1 -1
  94. package/dist/src/deep/difference.d.ts.map +1 -1
  95. package/dist/src/deep/equal.d.ts +4 -4
  96. package/dist/src/deep/equal.d.ts.map +1 -1
  97. package/dist/src/deep/merge.d.ts +1 -1
  98. package/dist/src/deep/merge.d.ts.map +1 -1
  99. package/dist/src/errors/errors.d.ts +62 -36
  100. package/dist/src/errors/errors.d.ts.map +1 -1
  101. package/dist/src/index.d.ts +4 -1
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/instance/index.d.ts +2 -0
  104. package/dist/src/instance/index.d.ts.map +1 -0
  105. package/dist/src/instance/matcher.d.ts +79 -0
  106. package/dist/src/instance/matcher.d.ts.map +1 -0
  107. package/dist/src/instance/matcher.spec.d.ts +2 -0
  108. package/dist/src/instance/matcher.spec.d.ts.map +1 -0
  109. package/dist/src/jsonrpc/jsonrpc.d.ts +40 -9
  110. package/dist/src/jsonrpc/jsonrpc.d.ts.map +1 -1
  111. package/dist/src/kv/types.d.ts +2 -2
  112. package/dist/src/kv/types.d.ts.map +1 -1
  113. package/dist/src/migrate/migrate.d.ts +5 -5
  114. package/dist/src/migrate/migrate.d.ts.map +1 -1
  115. package/dist/src/notation/notation.d.ts +1 -1
  116. package/dist/src/notation/notation.d.ts.map +1 -1
  117. package/dist/src/primitive/index.d.ts +2 -0
  118. package/dist/src/primitive/index.d.ts.map +1 -0
  119. package/dist/src/primitive/primitive.d.ts +39 -0
  120. package/dist/src/primitive/primitive.d.ts.map +1 -0
  121. package/dist/src/primitive/primitive.spec.d.ts +2 -0
  122. package/dist/src/primitive/primitive.spec.d.ts.map +1 -0
  123. package/dist/src/record.d.ts +2 -2
  124. package/dist/src/record.d.ts.map +1 -1
  125. package/dist/src/renderable.d.ts +1 -1
  126. package/dist/src/renderable.d.ts.map +1 -1
  127. package/dist/src/replace.d.ts.map +1 -1
  128. package/dist/src/runtime/detect.d.ts.map +1 -1
  129. package/dist/src/runtime/os.d.ts +1 -1
  130. package/dist/src/runtime/os.d.ts.map +1 -1
  131. package/dist/src/spatial/base.d.ts +10 -10
  132. package/dist/src/spatial/base.d.ts.map +1 -1
  133. package/dist/src/spatial/bounds/bounds.d.ts +82 -16
  134. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  135. package/dist/src/spatial/box/box.d.ts +7 -7
  136. package/dist/src/spatial/box/box.d.ts.map +1 -1
  137. package/dist/src/spatial/dimensions/dimensions.d.ts +5 -5
  138. package/dist/src/spatial/dimensions/dimensions.d.ts.map +1 -1
  139. package/dist/src/spatial/direction/direction.d.ts +1 -1
  140. package/dist/src/spatial/location/location.d.ts +4 -4
  141. package/dist/src/spatial/location/location.d.ts.map +1 -1
  142. package/dist/src/spatial/scale/scale.d.ts +11 -11
  143. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  144. package/dist/src/spatial/xy/xy.d.ts +5 -5
  145. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  146. package/dist/src/status/index.d.ts +2 -0
  147. package/dist/src/status/index.d.ts.map +1 -0
  148. package/dist/src/status/types.d.ts +11 -0
  149. package/dist/src/status/types.d.ts.map +1 -0
  150. package/dist/src/sync/index.d.ts.map +1 -1
  151. package/dist/src/sync/mutex.d.ts +0 -1
  152. package/dist/src/sync/mutex.d.ts.map +1 -1
  153. package/dist/src/telem/gl.d.ts +1 -1
  154. package/dist/src/telem/gl.d.ts.map +1 -1
  155. package/dist/src/telem/series.d.ts +468 -62
  156. package/dist/src/telem/series.d.ts.map +1 -1
  157. package/dist/src/telem/telem.d.ts +243 -53
  158. package/dist/src/telem/telem.d.ts.map +1 -1
  159. package/dist/src/uuid/index.d.ts +2 -0
  160. package/dist/src/uuid/index.d.ts.map +1 -0
  161. package/dist/src/uuid/uuid.d.ts +35 -0
  162. package/dist/src/uuid/uuid.d.ts.map +1 -0
  163. package/dist/src/uuid/uuid.spec.d.ts +2 -0
  164. package/dist/src/uuid/uuid.spec.d.ts.map +1 -0
  165. package/dist/src/zod/external.d.ts +1 -1
  166. package/dist/src/zod/external.d.ts.map +1 -1
  167. package/dist/src/zod/nullToUndefined.d.ts +3 -0
  168. package/dist/src/zod/nullToUndefined.d.ts.map +1 -0
  169. package/dist/src/zod/nullToUndefined.spec.d.ts +2 -0
  170. package/dist/src/zod/nullToUndefined.spec.d.ts.map +1 -0
  171. package/dist/src/zod/util.d.ts +2 -2
  172. package/dist/src/zod/util.d.ts.map +1 -1
  173. package/dist/telem.cjs +1 -1
  174. package/dist/telem.js +1 -1
  175. package/dist/xy.cjs +1 -1
  176. package/dist/xy.js +1 -1
  177. package/dist/zod.cjs +1 -1
  178. package/dist/zod.js +19 -2
  179. package/eslint.config.js +1 -1
  180. package/package.json +16 -14
  181. package/src/{toArray.ts → array/index.ts} +1 -5
  182. package/src/array/toArray.spec.ts +56 -0
  183. package/src/array/toArray.ts +28 -0
  184. package/src/binary/codec.spec.ts +201 -278
  185. package/src/binary/codec.ts +20 -76
  186. package/src/breaker/breaker.ts +3 -3
  187. package/src/caseconv/caseconv.ts +6 -4
  188. package/src/change/change.ts +2 -2
  189. package/src/color/color.spec.ts +121 -2
  190. package/src/color/color.ts +90 -54
  191. package/src/color/external.ts +0 -1
  192. package/src/color/gradient.ts +20 -28
  193. package/src/color/palette.ts +1 -1
  194. package/src/compare/compare.ts +5 -5
  195. package/src/control/control.ts +22 -19
  196. package/src/debounce/debounce.ts +1 -1
  197. package/src/deep/delete.ts +5 -4
  198. package/src/deep/difference.ts +6 -2
  199. package/src/deep/equal.spec.ts +1 -1
  200. package/src/deep/equal.ts +5 -5
  201. package/src/deep/merge.spec.ts +13 -1
  202. package/src/deep/merge.ts +16 -7
  203. package/src/deep/path.ts +1 -1
  204. package/src/errors/errors.ts +65 -44
  205. package/src/index.ts +4 -1
  206. package/src/instance/index.ts +10 -0
  207. package/src/instance/matcher.spec.ts +78 -0
  208. package/src/instance/matcher.ts +98 -0
  209. package/src/jsonrpc/jsonrpc.spec.ts +2 -1
  210. package/src/jsonrpc/jsonrpc.ts +36 -7
  211. package/src/kv/types.ts +1 -1
  212. package/src/migrate/migrate.spec.ts +1 -1
  213. package/src/migrate/migrate.ts +7 -7
  214. package/src/notation/notation.ts +1 -1
  215. package/src/primitive/index.ts +10 -0
  216. package/src/primitive/primitive.spec.ts +126 -0
  217. package/src/primitive/primitive.ts +82 -0
  218. package/src/record.ts +3 -5
  219. package/src/renderable.ts +1 -1
  220. package/src/replace.ts +9 -0
  221. package/src/runtime/detect.ts +0 -2
  222. package/src/runtime/os.ts +1 -1
  223. package/src/spatial/base.ts +1 -1
  224. package/src/spatial/bounds/bounds.spec.ts +20 -0
  225. package/src/spatial/bounds/bounds.ts +101 -18
  226. package/src/spatial/box/box.ts +1 -1
  227. package/src/spatial/dimensions/dimensions.ts +3 -3
  228. package/src/spatial/location/location.ts +1 -1
  229. package/src/spatial/scale/scale.ts +1 -1
  230. package/src/spatial/xy/xy.ts +1 -1
  231. package/src/status/index.ts +10 -0
  232. package/src/status/types.ts +22 -0
  233. package/src/sync/index.ts +9 -0
  234. package/src/sync/mutex.ts +9 -4
  235. package/src/telem/gl.ts +1 -1
  236. package/src/telem/series.spec.ts +735 -68
  237. package/src/telem/series.ts +536 -195
  238. package/src/telem/telem.spec.ts +60 -7
  239. package/src/telem/telem.ts +287 -95
  240. package/src/uuid/index.ts +10 -0
  241. package/src/uuid/uuid.spec.ts +82 -0
  242. package/src/uuid/uuid.ts +48 -0
  243. package/src/zod/external.ts +1 -1
  244. package/src/zod/nullToUndefined.spec.ts +31 -0
  245. package/src/zod/nullToUndefined.ts +23 -0
  246. package/src/zod/util.spec.ts +1 -1
  247. package/src/zod/util.ts +6 -6
  248. package/tsconfig.json +1 -1
  249. package/tsconfig.tsbuildinfo +1 -1
  250. package/vite.config.ts +1 -1
  251. package/dist/base-BAM2mqCy.cjs +0 -1
  252. package/dist/base-DFq0vvGn.js +0 -38
  253. package/dist/bounds-BQo7rvs9.cjs +0 -1
  254. package/dist/box-0YrQibkB.cjs +0 -1
  255. package/dist/box-Cc8IzcNo.js +0 -205
  256. package/dist/change-C-YELKx6.cjs +0 -1
  257. package/dist/change-DLl6DccR.js +0 -12
  258. package/dist/dimensions-CRgergMS.js +0 -43
  259. package/dist/dimensions-D2QGoNXO.cjs +0 -1
  260. package/dist/external-BPgtxa8d.js +0 -29
  261. package/dist/external-C-dNgNQw.cjs +0 -1
  262. package/dist/external-C8TFju8Q.js +0 -29
  263. package/dist/external-DWQITF5_.cjs +0 -1
  264. package/dist/external-DqPrWKvU.js +0 -47
  265. package/dist/external-uXk0Avrg.cjs +0 -1
  266. package/dist/index-BywOGO8U.js +0 -1074
  267. package/dist/index-CYYjI7Uf.cjs +0 -1
  268. package/dist/index-C_6NXBlg.cjs +0 -3
  269. package/dist/index-Dd8DLyMx.cjs +0 -1
  270. package/dist/index-DizUWH6z.js +0 -47
  271. package/dist/index-QGplUHuy.js +0 -98
  272. package/dist/location-BGl5Ddds.cjs +0 -1
  273. package/dist/position-Cai5-wi1.cjs +0 -1
  274. package/dist/position-DIglP1l2.js +0 -85
  275. package/dist/scale-BtZINJ-A.cjs +0 -1
  276. package/dist/series-B9JERcqi.js +0 -1977
  277. package/dist/series-DqJ6f97G.cjs +0 -11
  278. package/dist/spatial-BSWPzMkK.js +0 -11
  279. package/dist/spatial-DGpZ2sO3.cjs +0 -1
  280. package/dist/src/color/transformColorsToHex.d.ts +0 -6
  281. package/dist/src/color/transformColorsToHex.d.ts.map +0 -1
  282. package/dist/src/primitive.d.ts +0 -9
  283. package/dist/src/primitive.d.ts.map +0 -1
  284. package/dist/src/toArray.d.ts +0 -3
  285. package/dist/src/toArray.d.ts.map +0 -1
  286. package/dist/src/zod/integer.d.ts +0 -10
  287. package/dist/src/zod/integer.d.ts.map +0 -1
  288. package/dist/src/zod/integer.spec.d.ts +0 -2
  289. package/dist/src/zod/integer.spec.d.ts.map +0 -1
  290. package/dist/toArray.cjs +0 -1
  291. package/dist/toArray.js +0 -5
  292. package/dist/xy-B7065J2S.cjs +0 -1
  293. package/src/color/transformColorsToHex.ts +0 -30
  294. package/src/primitive.ts +0 -46
  295. package/src/zod/integer.spec.ts +0 -148
  296. package/src/zod/integer.ts +0 -38
@@ -1,1977 +0,0 @@
1
- var rt = Object.defineProperty;
2
- var it = (o, t, e) => t in o ? rt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var r = (o, t, e) => it(o, typeof t != "symbol" ? t + "" : t, e);
4
- import { z as l } from "zod";
5
- import { J as q } from "./index-BywOGO8U.js";
6
- import { s as at } from "./index-DizUWH6z.js";
7
- import { n as ut } from "./index-QGplUHuy.js";
8
- import { m as C, c as L, a as J, d as D, e as ot, t as lt, f as ft } from "./bounds-Bn5_l4Z3.js";
9
- import "./box-Cc8IzcNo.js";
10
- import "./dimensions-CRgergMS.js";
11
- import "./base-DFq0vvGn.js";
12
- import "./location-C3aeu046.js";
13
- import "./scale-DfJe9755.js";
14
- import "./xy-D_LqxaGt.js";
15
- let ht = (o, t = 21) => (e = t) => {
16
- let s = "", i = e | 0;
17
- for (; i--; )
18
- s += o[Math.random() * o.length | 0];
19
- return s;
20
- };
21
- const ct = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", dt = ht(ct, 11), tt = () => dt(), Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
- __proto__: null,
23
- create: tt
24
- }, Symbol.toStringTag, { value: "Module" })), gt = l.enum(["static", "dynamic"]), et = (o, t) => {
25
- const e = new m(t);
26
- if (![
27
- O.DAY,
28
- O.HOUR,
29
- O.MINUTE,
30
- O.SECOND,
31
- O.MILLISECOND,
32
- O.MICROSECOND,
33
- O.NANOSECOND
34
- ].some((i) => i.equals(e)))
35
- throw new Error(
36
- "Invalid argument for remainder. Must be an even TimeSpan or Timestamp"
37
- );
38
- const s = o.valueOf() % e.valueOf();
39
- return o instanceof m ? new m(s) : new O(s);
40
- }, a = class a {
41
- constructor(t, e = "UTC") {
42
- /** The underlying value for the time stamp */
43
- r(this, "value");
44
- /** Makes sure JSON encodes the value and not the class. */
45
- r(this, "encodeValue", !0);
46
- if (t == null) this.value = a.now().valueOf();
47
- else if (t instanceof Date)
48
- this.value = BigInt(t.getTime()) * a.MILLISECOND.valueOf();
49
- else if (typeof t == "string")
50
- this.value = a.parseDateTimeString(t, e).valueOf();
51
- else if (Array.isArray(t)) this.value = a.parseDate(t);
52
- else {
53
- let s = BigInt(0);
54
- t instanceof Number && (t = t.valueOf()), e === "local" && (s = a.utcOffset.valueOf()), typeof t == "number" && (isFinite(t) ? t = Math.trunc(t) : (isNaN(t) && (t = 0), t === 1 / 0 ? t = a.MAX : t = a.MIN)), this.value = BigInt(t.valueOf()) + s;
55
- }
56
- }
57
- static parseDate([t = 1970, e = 1, s = 1]) {
58
- const i = new Date(t, e - 1, s, 0, 0, 0, 0);
59
- return new a(BigInt(i.getTime()) * a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf();
60
- }
61
- valueOf() {
62
- return this.value;
63
- }
64
- static parseTimeString(t, e = "UTC") {
65
- const [s, i, h] = t.split(":");
66
- let c = "00", v = "00";
67
- h != null && ([c, v] = h.split("."));
68
- let b = a.hours(parseInt(s ?? "00")).add(a.minutes(parseInt(i ?? "00"))).add(a.seconds(parseInt(c ?? "00"))).add(a.milliseconds(parseInt(v ?? "00")));
69
- return e === "local" && (b = b.add(a.utcOffset)), b.valueOf();
70
- }
71
- static parseDateTimeString(t, e = "UTC") {
72
- if (!t.includes("/") && !t.includes("-"))
73
- return a.parseTimeString(t, e);
74
- const s = new Date(t);
75
- return t.includes(":") || s.setUTCHours(0, 0, 0, 0), new a(
76
- BigInt(s.getTime()) * a.MILLISECOND.valueOf(),
77
- e
78
- ).valueOf();
79
- }
80
- fString(t = "ISO", e = "UTC") {
81
- switch (t) {
82
- case "ISODate":
83
- return this.toISOString(e).slice(0, 10);
84
- case "ISOTime":
85
- return this.toISOString(e).slice(11, 23);
86
- case "time":
87
- return this.timeString(!1, e);
88
- case "preciseTime":
89
- return this.timeString(!0, e);
90
- case "date":
91
- return this.dateString();
92
- case "preciseDate":
93
- return `${this.dateString()} ${this.timeString(!0, e)}`;
94
- case "dateTime":
95
- return `${this.dateString()} ${this.timeString(!1, e)}`;
96
- default:
97
- return this.toISOString(e);
98
- }
99
- }
100
- toISOString(t = "UTC") {
101
- return t === "UTC" ? this.date().toISOString() : this.sub(a.utcOffset).date().toISOString();
102
- }
103
- timeString(t = !1, e = "UTC") {
104
- const s = this.toISOString(e);
105
- return t ? s.slice(11, 23) : s.slice(11, 19);
106
- }
107
- dateString() {
108
- const t = this.date(), e = t.toLocaleString("default", { month: "short" }), s = t.toLocaleString("default", { day: "numeric" });
109
- return `${e} ${s}`;
110
- }
111
- static get utcOffset() {
112
- return new O(
113
- BigInt((/* @__PURE__ */ new Date()).getTimezoneOffset()) * a.MINUTE.valueOf()
114
- );
115
- }
116
- /**
117
- * @returns a TimeSpan representing the amount time elapsed since
118
- * the other timestamp.
119
- * @param other - The other timestamp.
120
- */
121
- static since(t) {
122
- return new a().span(t);
123
- }
124
- /** @returns A JavaScript Date object representing the TimeStamp. */
125
- date() {
126
- return new Date(this.milliseconds);
127
- }
128
- /**
129
- * Checks if the TimeStamp is equal to another TimeStamp.
130
- *
131
- * @param other - The other TimeStamp to compare to.
132
- * @returns True if the TimeStamps are equal, false otherwise.
133
- */
134
- equals(t) {
135
- return this.valueOf() === new a(t).valueOf();
136
- }
137
- /**
138
- * Creates a TimeSpan representing the duration between the two timestamps.
139
- *
140
- * @param other - The other TimeStamp to compare to.
141
- * @returns A TimeSpan representing the duration between the two timestamps.
142
- * The span is guaranteed to be positive.
143
- */
144
- span(t) {
145
- return this.range(t).span;
146
- }
147
- /**
148
- * Creates a TimeRange spanning the given TimeStamp.
149
- *
150
- * @param other - The other TimeStamp to compare to.
151
- * @returns A TimeRange spanning the given TimeStamp that is guaranteed to be
152
- * valid, regardless of the TimeStamp order.
153
- */
154
- range(t) {
155
- return new A(this, t).makeValid();
156
- }
157
- /**
158
- * Creates a TimeRange starting at the TimeStamp and spanning the given
159
- * TimeSpan.
160
- *
161
- * @param other - The TimeSpan to span.
162
- * @returns A TimeRange starting at the TimeStamp and spanning the given
163
- * TimeSpan. The TimeRange is guaranteed to be valid.
164
- */
165
- spanRange(t) {
166
- return this.range(this.add(t)).makeValid();
167
- }
168
- /**
169
- * Checks if the TimeStamp represents the unix epoch.
170
- *
171
- * @returns True if the TimeStamp represents the unix epoch, false otherwise.
172
- */
173
- get isZero() {
174
- return this.valueOf() === BigInt(0);
175
- }
176
- /**
177
- * Checks if the TimeStamp is after the given TimeStamp.
178
- *
179
- * @param other - The other TimeStamp to compare to.
180
- * @returns True if the TimeStamp is after the given TimeStamp, false
181
- * otherwise.
182
- */
183
- after(t) {
184
- return this.valueOf() > new a(t).valueOf();
185
- }
186
- /**
187
- * Checks if the TimeStamp is after or equal to the given TimeStamp.
188
- *
189
- * @param other - The other TimeStamp to compare to.
190
- * @returns True if the TimeStamp is after or equal to the given TimeStamp,
191
- * false otherwise.
192
- */
193
- afterEq(t) {
194
- return this.valueOf() >= new a(t).valueOf();
195
- }
196
- /**
197
- * Checks if the TimeStamp is before the given TimeStamp.
198
- *
199
- * @param other - The other TimeStamp to compare to.
200
- * @returns True if the TimeStamp is before the given TimeStamp, false
201
- * otherwise.
202
- */
203
- before(t) {
204
- return this.valueOf() < new a(t).valueOf();
205
- }
206
- /**
207
- * Checks if TimeStamp is before or equal to the current timestamp.
208
- *
209
- * @param other - The other TimeStamp to compare to.
210
- * @returns True if TimeStamp is before or equal to the current timestamp,
211
- * false otherwise.
212
- */
213
- beforeEq(t) {
214
- return this.valueOf() <= new a(t).valueOf();
215
- }
216
- /**
217
- * Adds a TimeSpan to the TimeStamp.
218
- *
219
- * @param span - The TimeSpan to add.
220
- * @returns A new TimeStamp representing the sum of the TimeStamp and
221
- * TimeSpan.
222
- */
223
- add(t) {
224
- return new a(this.valueOf() + BigInt(t.valueOf()));
225
- }
226
- /**
227
- * Subtracts a TimeSpan from the TimeStamp.
228
- *
229
- * @param span - The TimeSpan to subtract.
230
- * @returns A new TimeStamp representing the difference of the TimeStamp and
231
- * TimeSpan.
232
- */
233
- sub(t) {
234
- return new a(this.valueOf() - BigInt(t.valueOf()));
235
- }
236
- /**
237
- * @returns the floating point number of hours since the unix epoch to the timestamp
238
- * value.
239
- */
240
- get hours() {
241
- return Number(this.valueOf()) / Number(O.HOUR.valueOf());
242
- }
243
- /**
244
- * @returns the floating point number of minutes since the unix epoch to the timestamp
245
- * value.
246
- */
247
- get minutes() {
248
- return Number(this.valueOf()) / Number(O.MINUTE.valueOf());
249
- }
250
- /**
251
- * @returns the floating point number of days since the unix epoch to the timestamp
252
- * value.
253
- */
254
- get days() {
255
- return Number(this.valueOf()) / Number(O.DAY.valueOf());
256
- }
257
- /**
258
- * @returns the floating point number of seconds since the unix epoch to the timestamp
259
- * value.
260
- */
261
- get seconds() {
262
- return Number(this.valueOf()) / Number(O.SECOND.valueOf());
263
- }
264
- /** @returns the floating point number of milliseconds since the unix epoch. */
265
- get milliseconds() {
266
- return Number(this.valueOf()) / Number(a.MILLISECOND.valueOf());
267
- }
268
- /** @returns the floating point number of microseconds since the unix epoch */
269
- get microseconds() {
270
- return Number(this.valueOf()) / Number(a.MICROSECOND.valueOf());
271
- }
272
- /**
273
- * @returns the floating point number of nanoseconds since the unix epoch.
274
- * Note that since we're converting to float64, this reduces the resolution
275
- * to a quarter of a microsecond.
276
- */
277
- get nanoseconds() {
278
- return Number(this.valueOf());
279
- }
280
- /** @returns the integer year that the timestamp corresponds to. */
281
- get year() {
282
- return this.date().getFullYear();
283
- }
284
- /**
285
- * @returns a copy of the timestamp with the year changed.
286
- * @param year the value to set the year to.
287
- */
288
- setYear(t) {
289
- const e = this.date();
290
- return e.setFullYear(t), new a(e);
291
- }
292
- /** @returns the integer month that the timestamp corresponds to with its year. */
293
- get month() {
294
- return this.date().getUTCMonth();
295
- }
296
- /**
297
- * @returns a copy of the timestamp with the month changed.
298
- * @param month the value to set the month to.
299
- */
300
- setMonth(t) {
301
- const e = this.date();
302
- return e.setUTCMonth(t), new a(e);
303
- }
304
- /** @returns the integer day that the timestamp corresponds to within its month. */
305
- get day() {
306
- return this.date().getUTCDate();
307
- }
308
- /**
309
- * @returns a copy of the timestamp with the day changed.
310
- * @param day the value the set the day to.
311
- */
312
- setDay(t) {
313
- const e = this.date();
314
- return e.setUTCDate(t), new a(e);
315
- }
316
- /**
317
- * @returns the integer hour that the timestamp corresponds to within its day.
318
- */
319
- get hour() {
320
- return this.date().getUTCHours();
321
- }
322
- /**
323
- * @returns a copy of the timestamp with the hour changed.
324
- * @param hour the value to set the hour to.
325
- */
326
- setHour(t) {
327
- const e = this.date();
328
- return e.setUTCHours(t), new a(e, "UTC");
329
- }
330
- /** @returns the integer minute that the timestamp corresponds to within its hour. */
331
- get minute() {
332
- return this.date().getMinutes();
333
- }
334
- /**
335
- * @returns a copy of the timestamp with the minute changed.
336
- * @param minute the value to set the minute to.
337
- */
338
- setMinute(t) {
339
- const e = this.date();
340
- return e.setUTCMinutes(t), new a(e);
341
- }
342
- /**
343
- * @returns the integer second that the timestamp corresponds to within its
344
- * minute.
345
- */
346
- get second() {
347
- return this.date().getSeconds();
348
- }
349
- /**
350
- * @returns a copy of the timestamp with the second changed.
351
- * @param second the value to set the second to.
352
- */
353
- setSecond(t) {
354
- const e = this.date();
355
- return e.setUTCSeconds(t), new a(e);
356
- }
357
- /**
358
- * @reutrns the integer millisecond that the timestamp corresponds to within
359
- * its second.
360
- */
361
- get millisecond() {
362
- return this.date().getMilliseconds();
363
- }
364
- /**
365
- * @returns a copy of the timestamp with the milliseconds changed.
366
- * @param millisecond the value to set the millisecond to.
367
- */
368
- setMillisecond(t) {
369
- const e = this.date();
370
- return e.setMilliseconds(t), new a(e);
371
- }
372
- /** @returns the time stamp formatted as an ISO string. */
373
- toString() {
374
- return this.date().toISOString();
375
- }
376
- /**
377
- * @returns A new TimeStamp that is the remainder of the TimeStamp divided by the
378
- * given span. This is useful in cases where you want only part of a TimeStamp's value
379
- * i.e., the hours, minutes, seconds, milliseconds, microseconds, and nanoseconds but
380
- * not the days, years, etc.
381
- *
382
- * @param divisor - The TimeSpan to divide by. Must be an even TimeSpan or TimeStamp. Even
383
- * means it must be a day, hour, minute, second, millisecond, or microsecond, etc.
384
- *
385
- * @example TimeStamp.now().remainder(TimeStamp.DAY) // => TimeStamp representing the current day
386
- */
387
- remainder(t) {
388
- return et(this, t);
389
- }
390
- /** @returns true if the day portion TimeStamp is today, false otherwise. */
391
- get isToday() {
392
- return this.truncate(O.DAY).equals(a.now().truncate(O.DAY));
393
- }
394
- truncate(t) {
395
- return this.sub(this.remainder(t));
396
- }
397
- /**
398
- * @returns A new TimeStamp representing the current time in UTC. It's important to
399
- * note that this TimeStamp is only accurate to the millisecond level (that's the best
400
- * JavaScript can do).
401
- */
402
- static now() {
403
- return new a(/* @__PURE__ */ new Date());
404
- }
405
- /** @returns the maximum value of all the timestamps. */
406
- static max(...t) {
407
- let e = a.MIN;
408
- for (const s of t) {
409
- const i = new a(s);
410
- i.after(e) && (e = i);
411
- }
412
- return e;
413
- }
414
- /** @returns the minimum value of all the timestamps. */
415
- static min(...t) {
416
- let e = a.MAX;
417
- for (const s of t) {
418
- const i = new a(s);
419
- i.before(e) && (e = i);
420
- }
421
- return e;
422
- }
423
- /** @returns a new TimeStamp n nanoseconds after the unix epoch */
424
- static nanoseconds(t, e = "UTC") {
425
- return new a(t, e);
426
- }
427
- /** @returns a new TimeStamp n microseconds after the unix epoch */
428
- static microseconds(t, e = "UTC") {
429
- return a.nanoseconds(t * 1e3, e);
430
- }
431
- /** @returns a new TimeStamp n milliseconds after the unix epoch */
432
- static milliseconds(t, e = "UTC") {
433
- return a.microseconds(t * 1e3, e);
434
- }
435
- /** @returns a new TimeStamp n seconds after the unix epoch */
436
- static seconds(t, e = "UTC") {
437
- return a.milliseconds(t * 1e3, e);
438
- }
439
- /** @returns a new TimeStamp n minutes after the unix epoch */
440
- static minutes(t, e = "UTC") {
441
- return a.seconds(t * 60, e);
442
- }
443
- /** @returns a new TimeStamp n hours after the unix epoch */
444
- static hours(t, e = "UTC") {
445
- return a.minutes(t * 60, e);
446
- }
447
- /** @returns a new TimeStamp n days after the unix epoch */
448
- static days(t, e = "UTC") {
449
- return a.hours(t * 24, e);
450
- }
451
- };
452
- /** One nanosecond after the unix epoch */
453
- r(a, "NANOSECOND", a.nanoseconds(1)), /** One microsecond after the unix epoch */
454
- r(a, "MICROSECOND", a.microseconds(1)), /** One millisecond after the unix epoch */
455
- r(a, "MILLISECOND", a.milliseconds(1)), /** One second after the unix epoch */
456
- r(a, "SECOND", a.seconds(1)), /** One minute after the unix epoch */
457
- r(a, "MINUTE", a.minutes(1)), /** One hour after the unix epoch */
458
- r(a, "HOUR", a.hours(1)), /** One day after the unix epoch */
459
- r(a, "DAY", a.days(1)), /** The maximum possible value for a timestamp */
460
- r(a, "MAX", new a((1n << 63n) - 1n)), /** The minimum possible value for a timestamp */
461
- r(a, "MIN", new a(0)), /** The unix epoch */
462
- r(a, "ZERO", new a(0)), /** A zod schema for validating timestamps */
463
- r(a, "z", l.union([
464
- l.object({ value: l.bigint() }).transform((t) => new a(t.value)),
465
- l.string().transform((t) => new a(BigInt(t))),
466
- l.instanceof(Number).transform((t) => new a(t)),
467
- l.number().transform((t) => new a(t)),
468
- l.instanceof(a)
469
- ]));
470
- let m = a;
471
- const u = class u {
472
- constructor(t) {
473
- r(this, "value");
474
- r(this, "encodeValue", !0);
475
- typeof t == "number" && (t = Math.trunc(t.valueOf())), this.value = BigInt(t.valueOf());
476
- }
477
- static fromSeconds(t) {
478
- return t instanceof u ? t : t instanceof $ ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.seconds(t) : new u(t);
479
- }
480
- static fromMilliseconds(t) {
481
- return t instanceof u ? t : t instanceof $ ? t.period : t instanceof m ? new u(t) : ["number", "bigint"].includes(typeof t) ? u.milliseconds(t) : new u(t);
482
- }
483
- encode() {
484
- return this.value.toString();
485
- }
486
- valueOf() {
487
- return this.value;
488
- }
489
- lessThan(t) {
490
- return this.valueOf() < new u(t).valueOf();
491
- }
492
- greaterThan(t) {
493
- return this.valueOf() > new u(t).valueOf();
494
- }
495
- lessThanOrEqual(t) {
496
- return this.valueOf() <= new u(t).valueOf();
497
- }
498
- greaterThanOrEqual(t) {
499
- return this.valueOf() >= new u(t).valueOf();
500
- }
501
- remainder(t) {
502
- return et(this, t);
503
- }
504
- truncate(t) {
505
- return new u(
506
- BigInt(Math.trunc(Number(this.valueOf() / t.valueOf()))) * t.valueOf()
507
- );
508
- }
509
- toString() {
510
- const t = this.truncate(u.DAY), e = this.truncate(u.HOUR), s = this.truncate(u.MINUTE), i = this.truncate(u.SECOND), h = this.truncate(u.MILLISECOND), c = this.truncate(u.MICROSECOND), v = this.truncate(u.NANOSECOND), b = t, N = e.sub(t), B = s.sub(e), f = i.sub(s), U = h.sub(i), S = c.sub(h), V = v.sub(c);
511
- let E = "";
512
- return b.isZero || (E += `${b.days}d `), N.isZero || (E += `${N.hours}h `), B.isZero || (E += `${B.minutes}m `), f.isZero || (E += `${f.seconds}s `), U.isZero || (E += `${U.milliseconds}ms `), S.isZero || (E += `${S.microseconds}µs `), V.isZero || (E += `${V.nanoseconds}ns`), E.trim();
513
- }
514
- mult(t) {
515
- return new u(this.valueOf() * BigInt(t));
516
- }
517
- /** @returns the decimal number of days in the timespan */
518
- get days() {
519
- return Number(this.valueOf()) / Number(u.DAY.valueOf());
520
- }
521
- /** @returns the decimal number of hours in the timespan */
522
- get hours() {
523
- return Number(this.valueOf()) / Number(u.HOUR.valueOf());
524
- }
525
- /** @returns the decimal number of minutes in the timespan */
526
- get minutes() {
527
- return Number(this.valueOf()) / Number(u.MINUTE.valueOf());
528
- }
529
- /** @returns The number of seconds in the TimeSpan. */
530
- get seconds() {
531
- return Number(this.valueOf()) / Number(u.SECOND.valueOf());
532
- }
533
- /** @returns The number of milliseconds in the TimeSpan. */
534
- get milliseconds() {
535
- return Number(this.valueOf()) / Number(u.MILLISECOND.valueOf());
536
- }
537
- get microseconds() {
538
- return Number(this.valueOf()) / Number(u.MICROSECOND.valueOf());
539
- }
540
- get nanoseconds() {
541
- return Number(this.valueOf());
542
- }
543
- /**
544
- * Checks if the TimeSpan represents a zero duration.
545
- *
546
- * @returns True if the TimeSpan represents a zero duration, false otherwise.
547
- */
548
- get isZero() {
549
- return this.valueOf() === BigInt(0);
550
- }
551
- /**
552
- * Checks if the TimeSpan is equal to another TimeSpan.
553
- *
554
- * @returns True if the TimeSpans are equal, false otherwise.
555
- */
556
- equals(t) {
557
- return this.valueOf() === new u(t).valueOf();
558
- }
559
- /**
560
- * Adds a TimeSpan to the TimeSpan.
561
- *
562
- * @returns A new TimeSpan representing the sum of the two TimeSpans.
563
- */
564
- add(t) {
565
- return new u(this.valueOf() + new u(t).valueOf());
566
- }
567
- /**
568
- * Creates a TimeSpan representing the duration between the two timestamps.
569
- *
570
- * @param other
571
- */
572
- sub(t) {
573
- return new u(this.valueOf() - new u(t).valueOf());
574
- }
575
- /**
576
- * Creates a TimeSpan representing the given number of nanoseconds.
577
- *
578
- * @param value - The number of nanoseconds.
579
- * @returns A TimeSpan representing the given number of nanoseconds.
580
- */
581
- static nanoseconds(t = 1) {
582
- return new u(t);
583
- }
584
- /**
585
- * Creates a TimeSpan representing the given number of microseconds.
586
- *
587
- * @param value - The number of microseconds.
588
- * @returns A TimeSpan representing the given number of microseconds.
589
- */
590
- static microseconds(t = 1) {
591
- return u.nanoseconds(C(t, 1e3));
592
- }
593
- /**
594
- * Creates a TimeSpan representing the given number of milliseconds.
595
- *
596
- * @param value - The number of milliseconds.
597
- * @returns A TimeSpan representing the given number of milliseconds.
598
- */
599
- static milliseconds(t = 1) {
600
- return u.microseconds(C(t, 1e3));
601
- }
602
- /**
603
- * Creates a TimeSpan representing the given number of seconds.
604
- *
605
- * @param value - The number of seconds.
606
- * @returns A TimeSpan representing the given number of seconds.
607
- */
608
- static seconds(t = 1) {
609
- return u.milliseconds(C(t, 1e3));
610
- }
611
- /**
612
- * Creates a TimeSpan representing the given number of minutes.
613
- *
614
- * @param value - The number of minutes.
615
- * @returns A TimeSpan representing the given number of minutes.
616
- */
617
- static minutes(t = 1) {
618
- return u.seconds(C(t, 60));
619
- }
620
- /**
621
- * Creates a TimeSpan representing the given number of hours.
622
- *
623
- * @param value - The number of hours.
624
- * @returns A TimeSpan representing the given number of hours.
625
- */
626
- static hours(t) {
627
- return u.minutes(C(t, 60));
628
- }
629
- /**
630
- * Creates a TimeSpan representing the given number of days.
631
- *
632
- * @param value - The number of days.
633
- * @returns A TimeSpan representing the given number of days.
634
- */
635
- static days(t) {
636
- return u.hours(C(t, 24));
637
- }
638
- };
639
- /** A nanosecond. */
640
- r(u, "NANOSECOND", u.nanoseconds(1)), /** A microsecond. */
641
- r(u, "MICROSECOND", u.microseconds(1)), /** A millisecond. */
642
- r(u, "MILLISECOND", u.milliseconds(1)), /** A second. */
643
- r(u, "SECOND", u.seconds(1)), /** A minute. */
644
- r(u, "MINUTE", u.minutes(1)), /** Represents an hour. */
645
- r(u, "HOUR", u.hours(1)), /** Represents a day. */
646
- r(u, "DAY", u.days(1)), /** The maximum possible value for a TimeSpan. */
647
- r(u, "MAX", new u((1n << 63n) - 1n)), /** The minimum possible value for a TimeSpan. */
648
- r(u, "MIN", new u(0)), /** The zero value for a TimeSpan. */
649
- r(u, "ZERO", new u(0)), /** A zod schema for validating and transforming timespans */
650
- r(u, "z", l.union([
651
- l.object({ value: l.bigint() }).transform((t) => new u(t.value)),
652
- l.string().transform((t) => new u(BigInt(t))),
653
- l.instanceof(Number).transform((t) => new u(t)),
654
- l.number().transform((t) => new u(t)),
655
- l.instanceof(u)
656
- ]));
657
- let O = u;
658
- const p = class p extends Number {
659
- constructor(t) {
660
- t instanceof Number ? super(t.valueOf()) : super(t);
661
- }
662
- /** @returns a pretty string representation of the rate in the format "X Hz". */
663
- toString() {
664
- return `${this.valueOf()} Hz`;
665
- }
666
- /** @returns The number of seconds in the Rate. */
667
- equals(t) {
668
- return this.valueOf() === new p(t).valueOf();
669
- }
670
- /**
671
- * Calculates the period of the Rate as a TimeSpan.
672
- *
673
- * @returns A TimeSpan representing the period of the Rate.
674
- */
675
- get period() {
676
- return O.seconds(1 / this.valueOf());
677
- }
678
- /**
679
- * Calculates the number of samples in the given TimeSpan at this rate.
680
- *
681
- * @param duration - The duration to calculate the sample count from.
682
- * @returns The number of samples in the given TimeSpan at this rate.
683
- */
684
- sampleCount(t) {
685
- return new O(t).seconds * this.valueOf();
686
- }
687
- /**
688
- * Calculates the number of bytes in the given TimeSpan at this rate.
689
- *
690
- * @param span - The duration to calculate the byte count from.
691
- * @param density - The density of the data in bytes per sample.
692
- * @returns The number of bytes in the given TimeSpan at this rate.
693
- */
694
- byteCount(t, e) {
695
- return this.sampleCount(t) * new y(e).valueOf();
696
- }
697
- /**
698
- * Calculates a TimeSpan given the number of samples at this rate.
699
- *
700
- * @param sampleCount - The number of samples in the span.
701
- * @returns A TimeSpan that corresponds to the given number of samples.
702
- */
703
- span(t) {
704
- return O.seconds(t / this.valueOf());
705
- }
706
- /**
707
- * Calculates a TimeSpan given the number of bytes at this rate.
708
- *
709
- * @param size - The number of bytes in the span.
710
- * @param density - The density of the data in bytes per sample.
711
- * @returns A TimeSpan that corresponds to the given number of bytes.
712
- */
713
- byteSpan(t, e) {
714
- return this.span(t.valueOf() / e.valueOf());
715
- }
716
- /**
717
- * Creates a Rate representing the given number of Hz.
718
- *
719
- * @param value - The number of Hz.
720
- * @returns A Rate representing the given number of Hz.
721
- */
722
- static hz(t) {
723
- return new p(t);
724
- }
725
- /**
726
- * Creates a Rate representing the given number of kHz.
727
- *
728
- * @param value - The number of kHz.
729
- * @returns A Rate representing the given number of kHz.
730
- */
731
- static khz(t) {
732
- return p.hz(t * 1e3);
733
- }
734
- };
735
- /** A zod schema for validating and transforming rates */
736
- r(p, "z", l.union([
737
- l.number().transform((t) => new p(t)),
738
- l.instanceof(Number).transform((t) => new p(t)),
739
- l.instanceof(p)
740
- ]));
741
- let $ = p;
742
- const w = class w extends Number {
743
- /**
744
- * Creates a Density representing the given number of bytes per value.
745
- *
746
- * @class
747
- * @param value - The number of bytes per value.
748
- * @returns A Density representing the given number of bytes per value.
749
- */
750
- constructor(t) {
751
- t instanceof Number ? super(t.valueOf()) : super(t);
752
- }
753
- length(t) {
754
- return t.valueOf() / this.valueOf();
755
- }
756
- size(t) {
757
- return new R(t * this.valueOf());
758
- }
759
- };
760
- /** Unknown/Invalid Density. */
761
- r(w, "UNKNOWN", new w(0)), /** 128 bits per value. */
762
- r(w, "BIT128", new w(16)), /** 64 bits per value. */
763
- r(w, "BIT64", new w(8)), /** 32 bits per value. */
764
- r(w, "BIT32", new w(4)), /** 16 bits per value. */
765
- r(w, "BIT16", new w(2)), /** 8 bits per value. */
766
- r(w, "BIT8", new w(1)), /** A zod schema for validating and transforming densities */
767
- r(w, "z", l.union([
768
- l.number().transform((t) => new w(t)),
769
- l.instanceof(Number).transform((t) => new w(t)),
770
- l.instanceof(w)
771
- ]));
772
- let y = w;
773
- const I = class I {
774
- /**
775
- * Creates a TimeRange from the given start and end TimeStamps.
776
- *
777
- * @param start - A TimeStamp representing the start of the range.
778
- * @param end - A TimeStamp representing the end of the range.
779
- */
780
- constructor(t, e) {
781
- /**
782
- * The starting TimeStamp of the TimeRange.
783
- *
784
- * Note that this value is not guaranteed to be before or equal to the ending value.
785
- * To ensure that this is the case, call TimeRange.make_valid().
786
- *
787
- * In most cases, operations should treat start as inclusive.
788
- */
789
- r(this, "start");
790
- /**
791
- * The starting TimeStamp of the TimeRange.
792
- *
793
- * Note that this value is not guaranteed to be before or equal to the ending value.
794
- * To ensure that this is the case, call TimeRange.make_valid().
795
- *
796
- * In most cases, operations should treat end as exclusive.
797
- */
798
- r(this, "end");
799
- typeof t == "object" && "start" in t ? (this.start = new m(t.start), this.end = new m(t.end)) : (this.start = new m(t), this.end = new m(e));
800
- }
801
- /** @returns The TimeSpan occupied by the TimeRange. */
802
- get span() {
803
- return new O(this.end.valueOf() - this.start.valueOf());
804
- }
805
- /**
806
- * Checks if the timestamp is valid i.e. the start is before the end.
807
- *
808
- * @returns True if the TimeRange is valid.
809
- */
810
- get isValid() {
811
- return this.start.valueOf() <= this.end.valueOf();
812
- }
813
- /**
814
- * Makes sure the TimeRange is valid i.e. the start is before the end.
815
- *
816
- * @returns A TimeRange that is valid.
817
- */
818
- makeValid() {
819
- return this.isValid ? this : this.swap();
820
- }
821
- /**
822
- * Checks if the TimeRange has a zero span.
823
- *
824
- * @returns True if the TimeRange has a zero span.
825
- */
826
- get isZero() {
827
- return this.span.isZero;
828
- }
829
- /**
830
- * @returns the TimeRange as a numeric object with start and end properties.
831
- */
832
- get numeric() {
833
- return { start: Number(this.start.valueOf()), end: Number(this.end.valueOf()) };
834
- }
835
- /**
836
- * Creates a new TimeRange with the start and end swapped.
837
- *
838
- * @returns A TimeRange with the start and end swapped.
839
- */
840
- swap() {
841
- return new I(this.end, this.start);
842
- }
843
- get numericBounds() {
844
- return {
845
- lower: Number(this.start.valueOf()),
846
- upper: Number(this.end.valueOf())
847
- };
848
- }
849
- /**
850
- * Checks if the TimeRange is equal to the given TimeRange.
851
- *
852
- * @param other - The TimeRange to compare to.
853
- * @returns True if the TimeRange is equal to the given TimeRange.
854
- */
855
- equals(t, e = O.ZERO) {
856
- if (e.isZero)
857
- return this.start.equals(t.start) && this.end.equals(t.end);
858
- let s = this.start.sub(t.start).valueOf(), i = this.end.sub(t.end).valueOf();
859
- return s < 0 && (s = -s), i < 0 && (i = -i), s <= e.valueOf() && i <= e.valueOf();
860
- }
861
- toString() {
862
- return `${this.start.toString()} - ${this.end.toString()}`;
863
- }
864
- toPrettyString() {
865
- return `${this.start.fString("preciseDate")} - ${this.span.toString()}`;
866
- }
867
- /**
868
- * Checks if the two time ranges overlap. If the two time ranges are equal, returns
869
- * true. If the start of one range is equal to the end of the other, it returns false.
870
- * Just follow the rule [start, end), i.e., start is inclusive, and the end is exclusive.
871
- *
872
- * @param other - The other TimeRange to compare to.
873
- * @param delta - A TimeSpan representing the minimum amount of overlap for
874
- * overlap to return true. This allows for a slight amount of leeway when
875
- * checking for overlap.
876
- * @returns True if the two TimeRanges overlap, false otherwise.
877
- */
878
- overlapsWith(t, e = O.ZERO) {
879
- t = t.makeValid();
880
- const s = this.makeValid();
881
- if (this.equals(t)) return !0;
882
- if (t.end.equals(s.start) || s.end.equals(t.start)) return !1;
883
- const i = m.max(s.start, t.start), h = m.min(s.end, t.end);
884
- return h.before(i) ? !1 : new O(h.sub(i)).greaterThanOrEqual(e);
885
- }
886
- contains(t) {
887
- return t instanceof I ? this.contains(t.start) && this.contains(t.end) : this.start.beforeEq(t) && this.end.after(t);
888
- }
889
- boundBy(t) {
890
- const e = new I(this.start, this.end);
891
- return t.start.after(this.start) && (e.start = t.start), t.start.after(this.end) && (e.end = t.start), t.end.before(this.end) && (e.end = t.end), t.end.before(this.start) && (e.start = t.end), e;
892
- }
893
- static max(...t) {
894
- return new I(
895
- m.min(...t.map((e) => e.start)),
896
- m.max(...t.map((e) => e.end))
897
- );
898
- }
899
- };
900
- /** The maximum possible time range. */
901
- r(I, "MAX", new I(m.MIN, m.MAX)), /** The minimum possible time range. */
902
- r(I, "MIN", new I(m.MAX, m.MIN)), /** A time range whose start and end are both zero. */
903
- r(I, "ZERO", new I(m.ZERO, m.ZERO)), /** A zod schema for validating and transforming time ranges */
904
- r(I, "z", l.union([
905
- l.object({ start: m.z, end: m.z }).transform((t) => new I(t.start, t.end)),
906
- l.instanceof(I)
907
- ]));
908
- let A = I;
909
- const Dt = (o, t) => o.start.before(t.start) ? -1 : o.start.after(t.start) ? 1 : o.end.before(t.end) ? -1 : o.end.after(t.end) ? 1 : 0, n = class n {
910
- constructor(t) {
911
- r(this, "value");
912
- r(this, "encodeValue", !0);
913
- if (t instanceof n || typeof t == "string" || typeof t.valueOf() == "string") {
914
- this.value = t.valueOf();
915
- return;
916
- }
917
- const e = n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);
918
- if (e != null) {
919
- this.value = e.valueOf();
920
- return;
921
- }
922
- throw this.value = n.UNKNOWN.valueOf(), new Error(`unable to find data type for ${t.toString()}`);
923
- }
924
- valueOf() {
925
- return this.value;
926
- }
927
- /**
928
- * @returns the TypedArray constructor for the DataType.
929
- */
930
- get Array() {
931
- const t = n.ARRAY_CONSTRUCTORS.get(this.toString());
932
- if (t == null)
933
- throw new Error(`unable to find array constructor for ${this.valueOf()}`);
934
- return t;
935
- }
936
- /**
937
- * @returns true if the DataType is equal to the given DataType.
938
- */
939
- equals(t) {
940
- return this.valueOf() === t.valueOf();
941
- }
942
- /**
943
- * @returns true if the DataType is equal to any of the given DataTypes.
944
- */
945
- matches(...t) {
946
- return t.some((e) => this.equals(e));
947
- }
948
- /** @returns a string representation of the DataType. */
949
- toString() {
950
- return this.valueOf();
951
- }
952
- get isVariable() {
953
- return this.equals(n.JSON) || this.equals(n.STRING);
954
- }
955
- get isNumeric() {
956
- return !this.isVariable && !this.equals(n.UUID);
957
- }
958
- get isInteger() {
959
- const t = this.toString();
960
- return t.startsWith("int") || t.startsWith("uint");
961
- }
962
- get isFloat() {
963
- return this.toString().startsWith("float");
964
- }
965
- get density() {
966
- const t = n.DENSITIES.get(this.toString());
967
- if (t == null) throw new Error(`unable to find density for ${this.valueOf()}`);
968
- return t;
969
- }
970
- /** @returns ture if the data type is an unsigned numeric integer type */
971
- get isUnsigned() {
972
- return this.equals(n.UINT8) || this.equals(n.UINT16) || this.equals(n.UINT32) || this.equals(n.UINT64);
973
- }
974
- /** @returns true if the data type is a signed numeric integer type */
975
- get isSigned() {
976
- return this.equals(n.INT8) || this.equals(n.INT16) || this.equals(n.INT32) || this.equals(n.INT64);
977
- }
978
- /** @returns true if the data type can be cast to the other data type without loss of precision. */
979
- canSafelyCastTo(t) {
980
- return this.equals(t) ? !0 : !this.isNumeric || !t.isNumeric || this.isVariable || t.isVariable || this.isUnsigned && t.isSigned ? !1 : this.isFloat ? t.isFloat && this.density.valueOf() <= t.density.valueOf() : this.equals(n.INT32) && t.equals(n.FLOAT64) || this.equals(n.INT8) && t.equals(n.FLOAT32) ? !0 : this.isInteger && t.isInteger ? this.density.valueOf() <= t.density.valueOf() && this.isUnsigned === t.isUnsigned : !1;
981
- }
982
- /** @returns true if the data type can be cast to the other data type, even if there is a loss of precision. */
983
- canCastTo(t) {
984
- return this.isNumeric && t.isNumeric ? !0 : this.equals(t);
985
- }
986
- toJSON() {
987
- return this.toString();
988
- }
989
- get usesBigInt() {
990
- return n.BIG_INT_TYPES.some((t) => t.equals(this));
991
- }
992
- };
993
- /** Represents an Unknown/Invalid DataType. */
994
- r(n, "UNKNOWN", new n("unknown")), /** Represents a 64-bit floating point value. */
995
- r(n, "FLOAT64", new n("float64")), /** Represents a 32-bit floating point value. */
996
- r(n, "FLOAT32", new n("float32")), /** Represents a 64-bit signed integer value. */
997
- r(n, "INT64", new n("int64")), /** Represents a 32-bit signed integer value. */
998
- r(n, "INT32", new n("int32")), /** Represents a 16-bit signed integer value. */
999
- r(n, "INT16", new n("int16")), /** Represents a 8-bit signed integer value. */
1000
- r(n, "INT8", new n("int8")), /** Represents a 64-bit unsigned integer value. */
1001
- r(n, "UINT64", new n("uint64")), /** Represents a 32-bit unsigned integer value. */
1002
- r(n, "UINT32", new n("uint32")), /** Represents a 16-bit unsigned integer value. */
1003
- r(n, "UINT16", new n("uint16")), /** Represents a 8-bit unsigned integer value. */
1004
- r(n, "UINT8", new n("uint8")), /** Represents a boolean value. Alias for UINT8. */
1005
- r(n, "BOOLEAN", n.UINT8), /** Represents a 64-bit unix epoch. */
1006
- r(n, "TIMESTAMP", new n("timestamp")), /** Represents a UUID data type */
1007
- r(n, "UUID", new n("uuid")), /** Represents a string data type. Strings have an unknown density, and are separate
1008
- * by a newline character. */
1009
- r(n, "STRING", new n("string")), /** Represents a JSON data type. JSON has an unknown density, and is separated by a
1010
- * newline character. */
1011
- r(n, "JSON", new n("json")), r(n, "ARRAY_CONSTRUCTORS", /* @__PURE__ */ new Map([
1012
- [n.UINT8.toString(), Uint8Array],
1013
- [n.UINT16.toString(), Uint16Array],
1014
- [n.UINT32.toString(), Uint32Array],
1015
- [n.UINT64.toString(), BigUint64Array],
1016
- [n.FLOAT32.toString(), Float32Array],
1017
- [n.FLOAT64.toString(), Float64Array],
1018
- [n.INT8.toString(), Int8Array],
1019
- [n.INT16.toString(), Int16Array],
1020
- [n.INT32.toString(), Int32Array],
1021
- [n.INT64.toString(), BigInt64Array],
1022
- [n.TIMESTAMP.toString(), BigInt64Array],
1023
- [n.STRING.toString(), Uint8Array],
1024
- [n.JSON.toString(), Uint8Array],
1025
- [n.UUID.toString(), Uint8Array]
1026
- ])), r(n, "ARRAY_CONSTRUCTOR_DATA_TYPES", /* @__PURE__ */ new Map([
1027
- [Uint8Array.name, n.UINT8],
1028
- [Uint16Array.name, n.UINT16],
1029
- [Uint32Array.name, n.UINT32],
1030
- [BigUint64Array.name, n.UINT64],
1031
- [Float32Array.name, n.FLOAT32],
1032
- [Float64Array.name, n.FLOAT64],
1033
- [Int8Array.name, n.INT8],
1034
- [Int16Array.name, n.INT16],
1035
- [Int32Array.name, n.INT32],
1036
- [BigInt64Array.name, n.INT64]
1037
- ])), r(n, "DENSITIES", /* @__PURE__ */ new Map([
1038
- [n.UINT8.toString(), y.BIT8],
1039
- [n.UINT16.toString(), y.BIT16],
1040
- [n.UINT32.toString(), y.BIT32],
1041
- [n.UINT64.toString(), y.BIT64],
1042
- [n.FLOAT32.toString(), y.BIT32],
1043
- [n.FLOAT64.toString(), y.BIT64],
1044
- [n.INT8.toString(), y.BIT8],
1045
- [n.INT16.toString(), y.BIT16],
1046
- [n.INT32.toString(), y.BIT32],
1047
- [n.INT64.toString(), y.BIT64],
1048
- [n.TIMESTAMP.toString(), y.BIT64],
1049
- [n.STRING.toString(), y.UNKNOWN],
1050
- [n.JSON.toString(), y.UNKNOWN],
1051
- [n.UUID.toString(), y.BIT128]
1052
- ])), /** All the data types. */
1053
- r(n, "ALL", [
1054
- n.UNKNOWN,
1055
- n.FLOAT64,
1056
- n.FLOAT32,
1057
- n.INT64,
1058
- n.INT32,
1059
- n.INT16,
1060
- n.INT8,
1061
- n.UINT64,
1062
- n.UINT32,
1063
- n.UINT16,
1064
- n.UINT8,
1065
- n.TIMESTAMP,
1066
- n.UUID,
1067
- n.STRING,
1068
- n.JSON
1069
- ]), r(n, "BIG_INT_TYPES", [n.INT64, n.UINT64, n.TIMESTAMP]), /** A zod schema for a DataType. */
1070
- r(n, "z", l.union([
1071
- l.string().transform((t) => new n(t)),
1072
- l.instanceof(n)
1073
- ]));
1074
- let g = n;
1075
- const d = class d extends Number {
1076
- constructor(t) {
1077
- super(t.valueOf());
1078
- }
1079
- /** @returns true if the Size is larger than the other size. */
1080
- largerThan(t) {
1081
- return this.valueOf() > t.valueOf();
1082
- }
1083
- /** @returns true if the Size is smaller than the other size. */
1084
- smallerThan(t) {
1085
- return this.valueOf() < t.valueOf();
1086
- }
1087
- add(t) {
1088
- return d.bytes(this.valueOf() + t.valueOf());
1089
- }
1090
- sub(t) {
1091
- return d.bytes(this.valueOf() - t.valueOf());
1092
- }
1093
- truncate(t) {
1094
- return new d(Math.trunc(this.valueOf() / t.valueOf()) * t.valueOf());
1095
- }
1096
- remainder(t) {
1097
- return d.bytes(this.valueOf() % t.valueOf());
1098
- }
1099
- get gigabytes() {
1100
- return this.valueOf() / d.GIGABYTE.valueOf();
1101
- }
1102
- get megabytes() {
1103
- return this.valueOf() / d.MEGABYTE.valueOf();
1104
- }
1105
- get kilobytes() {
1106
- return this.valueOf() / d.KILOBYTE.valueOf();
1107
- }
1108
- get terabytes() {
1109
- return this.valueOf() / d.TERABYTE.valueOf();
1110
- }
1111
- toString() {
1112
- const t = this.truncate(d.TERABYTE), e = this.truncate(d.GIGABYTE), s = this.truncate(d.MEGABYTE), i = this.truncate(d.KILOBYTE), h = this.truncate(d.BYTE), c = t, v = e.sub(t), b = s.sub(e), N = i.sub(s), B = h.sub(i);
1113
- let f = "";
1114
- return c.isZero || (f += `${c.terabytes}TB `), v.isZero || (f += `${v.gigabytes}GB `), b.isZero || (f += `${b.megabytes}MB `), N.isZero || (f += `${N.kilobytes}KB `), (!B.isZero || f === "") && (f += `${B.valueOf()}B`), f.trim();
1115
- }
1116
- /**
1117
- * Creates a Size from the given number of bytes.
1118
- *
1119
- * @param value - The number of bytes.
1120
- * @returns A Size representing the given number of bytes.
1121
- */
1122
- static bytes(t = 1) {
1123
- return new d(t);
1124
- }
1125
- /**
1126
- * Creates a Size from the given number if kilobytes.
1127
- *
1128
- * @param value - The number of kilobytes.
1129
- * @returns A Size representing the given number of kilobytes.
1130
- */
1131
- static kilobytes(t = 1) {
1132
- return d.bytes(t.valueOf() * 1e3);
1133
- }
1134
- /**
1135
- * Creates a Size from the given number of megabytes.
1136
- *
1137
- * @param value - The number of megabytes.
1138
- * @returns A Size representing the given number of megabytes.
1139
- */
1140
- static megabytes(t = 1) {
1141
- return d.kilobytes(t.valueOf() * 1e3);
1142
- }
1143
- /**
1144
- * Creates a Size from the given number of gigabytes.
1145
- *
1146
- * @param value - The number of gigabytes.
1147
- * @returns A Size representing the given number of gigabytes.
1148
- */
1149
- static gigabytes(t = 1) {
1150
- return d.megabytes(t.valueOf() * 1e3);
1151
- }
1152
- /**
1153
- * Creates a Size from the given number of terabytes.
1154
- *
1155
- * @param value - The number of terabytes.
1156
- * @returns A Size representing the given number of terabytes.
1157
- */
1158
- static terabytes(t) {
1159
- return d.gigabytes(t.valueOf() * 1e3);
1160
- }
1161
- get isZero() {
1162
- return this.valueOf() === 0;
1163
- }
1164
- };
1165
- /** A single byte */
1166
- r(d, "BYTE", new d(1)), /** A kilobyte */
1167
- r(d, "KILOBYTE", d.kilobytes(1)), /** A megabyte */
1168
- r(d, "MEGABYTE", d.megabytes(1)), /** A gigabyte */
1169
- r(d, "GIGABYTE", d.gigabytes(1)), /** A terabyte. */
1170
- r(d, "TERABYTE", d.terabytes(1)), /** The zero value for Size */
1171
- r(d, "ZERO", new d(0)), /** A zod schema for a Size. */
1172
- r(d, "z", l.union([
1173
- l.number().transform((t) => new d(t)),
1174
- l.instanceof(d)
1175
- ]));
1176
- let R = d;
1177
- const qt = l.union([
1178
- l.instanceof(Uint8Array),
1179
- l.instanceof(Uint16Array),
1180
- l.instanceof(Uint32Array),
1181
- l.instanceof(BigUint64Array),
1182
- l.instanceof(Float32Array),
1183
- l.instanceof(Float64Array),
1184
- l.instanceof(Int8Array),
1185
- l.instanceof(Int16Array),
1186
- l.instanceof(Int32Array),
1187
- l.instanceof(BigInt64Array)
1188
- ]), st = (o) => {
1189
- const t = typeof o;
1190
- return t === "string" || t === "number" || t === "boolean" || t === "bigint" || o instanceof m || o instanceof O || o instanceof Date;
1191
- }, mt = (o, t, e, s = 0) => o.usesBigInt && !t.usesBigInt ? Number(e) - Number(s) : !o.usesBigInt && t.usesBigInt ? BigInt(e.valueOf()) - BigInt(s.valueOf()) : x(e, -s).valueOf(), x = (o, t) => t == 0 ? o : o == 0 ? t : typeof o == "bigint" && typeof t == "bigint" || typeof o == "number" && typeof t == "number" ? o + t : Number(o) + Number(t), Ot = (o) => o == null ? !1 : Array.isArray(o) || o instanceof ArrayBuffer || ArrayBuffer.isView(o) && !(o instanceof DataView) || o instanceof k ? !0 : st(o), M = -1, Y = {
1192
- [Symbol.iterator]: () => Y,
1193
- next: () => ({ done: !0, value: void 0 })
1194
- }, bt = l.string().transform(
1195
- (o) => new Uint8Array(
1196
- atob(o).split("").map((t) => t.charCodeAt(0))
1197
- ).buffer
1198
- ), wt = l.union([l.null(), l.undefined()]).transform(() => new Uint8Array().buffer), Z = 10, nt = (o, t) => {
1199
- if (o === "string" && !t.isVariable)
1200
- throw new Error(`cannot convert series of type ${t.toString()} to string`);
1201
- if (o === "number" && !t.isNumeric)
1202
- throw new Error(`cannot convert series of type ${t.toString()} to number`);
1203
- if (o === "bigint" && !t.usesBigInt)
1204
- throw new Error(`cannot convert series of type ${t.toString()} to bigint`);
1205
- }, T = class T {
1206
- constructor(t) {
1207
- r(this, "key", "");
1208
- r(this, "isSynnaxSeries", !0);
1209
- /** The data type of the array */
1210
- r(this, "dataType");
1211
- /**
1212
- * A sample offset that can be used to shift the values of all samples upwards or
1213
- * downwards. Typically used to convert arrays to lower precision while preserving
1214
- * the relative range of actual values.
1215
- */
1216
- r(this, "sampleOffset");
1217
- /**
1218
- * Stores information about the buffer state of this array into a WebGL buffer.
1219
- */
1220
- r(this, "gl");
1221
- /** The underlying data. */
1222
- r(this, "_data");
1223
- r(this, "timeRange", A.ZERO);
1224
- r(this, "alignment", 0n);
1225
- /** A cached minimum value. */
1226
- r(this, "_cachedMin");
1227
- /** A cached maximum value. */
1228
- r(this, "_cachedMax");
1229
- /** The write position of the buffer. */
1230
- r(this, "writePos", M);
1231
- /** Tracks the number of entities currently using this array. */
1232
- r(this, "_refCount", 0);
1233
- /** Caches the length of the array for variable length data types. */
1234
- r(this, "_cachedLength");
1235
- /** Caches the indexes of the array for variable length data types. */
1236
- r(this, "_cachedIndexes");
1237
- Ot(t) && (t = { data: t });
1238
- const {
1239
- dataType: e,
1240
- timeRange: s,
1241
- sampleOffset: i = 0,
1242
- glBufferUsage: h = "static",
1243
- alignment: c = 0n,
1244
- key: v = tt()
1245
- } = t, b = t.data ?? [];
1246
- if (b instanceof T || typeof b == "object" && "isSynnaxSeries" in b && b.isSynnaxSeries === !0) {
1247
- const f = b;
1248
- this.key = f.key, this.dataType = f.dataType, this.sampleOffset = f.sampleOffset, this.gl = f.gl, this._data = f._data, this.timeRange = f.timeRange, this.alignment = f.alignment, this._cachedMin = f._cachedMin, this._cachedMax = f._cachedMax, this.writePos = f.writePos, this._refCount = f._refCount, this._cachedLength = f._cachedLength;
1249
- return;
1250
- }
1251
- const N = st(b), B = Array.isArray(b);
1252
- if (e != null) this.dataType = new g(e);
1253
- else {
1254
- if (b instanceof ArrayBuffer)
1255
- throw new Error(
1256
- "cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type."
1257
- );
1258
- if (B || N) {
1259
- let f = b;
1260
- if (!N) {
1261
- if (b.length === 0)
1262
- throw new Error(
1263
- "cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type."
1264
- );
1265
- f = b[0];
1266
- }
1267
- if (typeof f == "string") this.dataType = g.STRING;
1268
- else if (typeof f == "number") this.dataType = g.FLOAT64;
1269
- else if (typeof f == "bigint") this.dataType = g.INT64;
1270
- else if (typeof f == "boolean") this.dataType = g.BOOLEAN;
1271
- else if (f instanceof m || f instanceof Date || f instanceof m)
1272
- this.dataType = g.TIMESTAMP;
1273
- else if (typeof f == "object") this.dataType = g.JSON;
1274
- else
1275
- throw new Error(
1276
- `cannot infer data type of ${typeof f} when constructing a Series from a JS array`
1277
- );
1278
- } else this.dataType = new g(b);
1279
- }
1280
- if (!B && !N) this._data = b;
1281
- else {
1282
- let f = N ? [b] : b;
1283
- const U = f[0];
1284
- (U instanceof m || U instanceof Date || U instanceof O) && (f = f.map((S) => new m(S).valueOf())), this.dataType.equals(g.STRING) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(`${f.join(`
1285
- `)}
1286
- `).buffer) : this.dataType.equals(g.JSON) ? (this._cachedLength = f.length, this._data = new TextEncoder().encode(
1287
- `${f.map((S) => q.encodeString(S)).join(`
1288
- `)}
1289
- `
1290
- ).buffer) : this.dataType.usesBigInt && typeof U == "number" ? this._data = new this.dataType.Array(
1291
- f.map((S) => BigInt(Math.round(S)))
1292
- ).buffer : !this.dataType.usesBigInt && typeof U == "bigint" ? this._data = new this.dataType.Array(
1293
- f.map((S) => Number(S))
1294
- ).buffer : this._data = new this.dataType.Array(f).buffer;
1295
- }
1296
- this.key = v, this.alignment = c, this.sampleOffset = i ?? 0, this.timeRange = s ?? A.ZERO, this.gl = {
1297
- control: null,
1298
- buffer: null,
1299
- prevBuffer: 0,
1300
- bufferUsage: h
1301
- };
1302
- }
1303
- static alloc({ capacity: t, dataType: e, ...s }) {
1304
- if (t === 0)
1305
- throw new Error("[Series] - cannot allocate an array of length 0");
1306
- const i = new new g(e).Array(t), h = new T({
1307
- data: i.buffer,
1308
- dataType: e,
1309
- ...s
1310
- });
1311
- return h.writePos = 0, h;
1312
- }
1313
- static createTimestamps(t, e, s) {
1314
- const i = s.spanRange(e.span(t)), h = new BigInt64Array(t);
1315
- for (let c = 0; c < t; c++)
1316
- h[c] = BigInt(s.add(e.span(c)).valueOf());
1317
- return new T({ data: h, dataType: g.TIMESTAMP, timeRange: i });
1318
- }
1319
- get refCount() {
1320
- return this._refCount;
1321
- }
1322
- static fromStrings(t, e) {
1323
- const s = new TextEncoder().encode(
1324
- `${t.join(`
1325
- `)}
1326
- `
1327
- );
1328
- return new T({ data: s, dataType: g.STRING, timeRange: e });
1329
- }
1330
- static fromJSON(t, e) {
1331
- const s = new TextEncoder().encode(
1332
- `${t.map((i) => q.encodeString(i)).join(`
1333
- `)}
1334
- `
1335
- );
1336
- return new T({ data: s, dataType: g.JSON, timeRange: e });
1337
- }
1338
- acquire(t) {
1339
- this._refCount++, t != null && this.updateGLBuffer(t);
1340
- }
1341
- release() {
1342
- if (this._refCount <= 0) {
1343
- console.warn("attempted to release a series with a negative reference count");
1344
- return;
1345
- }
1346
- this._refCount--, this._refCount === 0 && this.gl.control != null && this.maybeGarbageCollectGLBuffer(this.gl.control);
1347
- }
1348
- /**
1349
- * Writes the given series to this series. If the series being written exceeds the
1350
- * remaining of series being written to, only the portion that fits will be written.
1351
- * @param other the series to write to this series. The data type of the series written
1352
- * must be the same as the data type of the series being written to.
1353
- * @returns the number of samples written. If the entire series fits, this value is
1354
- * equal to the length of the series being written.
1355
- */
1356
- write(t) {
1357
- if (!t.dataType.equals(this.dataType))
1358
- throw new Error("buffer must be of the same type as this array");
1359
- return this.dataType.isVariable ? this.writeVariable(t) : this.writeFixed(t);
1360
- }
1361
- writeVariable(t) {
1362
- if (this.writePos === M) return 0;
1363
- const e = this.byteCapacity.valueOf() - this.writePos, s = t.subBytes(0, e);
1364
- return this.writeToUnderlyingData(s), this.writePos += s.byteLength.valueOf(), this._cachedLength != null && (this._cachedLength += s.length, this.calculateCachedLength()), s.length;
1365
- }
1366
- writeFixed(t) {
1367
- if (this.writePos === M) return 0;
1368
- const e = this.capacity - this.writePos, s = t.sub(0, e);
1369
- return this.writeToUnderlyingData(s), this._cachedLength = void 0, this.maybeRecomputeMinMax(s), this.writePos += s.length, s.length;
1370
- }
1371
- writeToUnderlyingData(t) {
1372
- this.underlyingData.set(
1373
- t.data,
1374
- this.writePos
1375
- );
1376
- }
1377
- /** @returns the underlying buffer backing this array. */
1378
- get buffer() {
1379
- return typeof this._data == "object" && "buffer" in this._data ? this._data.buffer : this._data;
1380
- }
1381
- get underlyingData() {
1382
- return new this.dataType.Array(this._data);
1383
- }
1384
- /** @returns a native typed array with the proper data type. */
1385
- get data() {
1386
- return this.writePos === M ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
1387
- }
1388
- toStrings() {
1389
- if (!this.dataType.matches(g.STRING, g.UUID))
1390
- throw new Error("cannot convert non-string series to strings");
1391
- return new TextDecoder().decode(this.underlyingData).split(`
1392
- `).slice(0, -1);
1393
- }
1394
- toUUIDs() {
1395
- if (!this.dataType.equals(g.UUID))
1396
- throw new Error("cannot convert non-uuid series to uuids");
1397
- const t = g.UUID.density.valueOf(), e = Array(this.length);
1398
- for (let s = 0; s < this.length; s++) {
1399
- const i = this.underlyingData.slice(s * t, (s + 1) * t), h = Array.from(
1400
- new Uint8Array(i.buffer),
1401
- (c) => c.toString(16).padStart(2, "0")
1402
- ).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
1403
- e[s] = h;
1404
- }
1405
- return e;
1406
- }
1407
- parseJSON(t) {
1408
- if (!this.dataType.equals(g.JSON))
1409
- throw new Error("cannot parse non-JSON series as JSON");
1410
- return new TextDecoder().decode(this.underlyingData).split(`
1411
- `).slice(0, -1).map((e) => t.parse(q.decodeString(e)));
1412
- }
1413
- /** @returns the capacity of the series in bytes. */
1414
- get byteCapacity() {
1415
- return new R(this.underlyingData.byteLength);
1416
- }
1417
- /** @returns the capacity of the series in samples. */
1418
- get capacity() {
1419
- return this.dataType.isVariable ? this.byteCapacity.valueOf() : this.dataType.density.length(this.byteCapacity);
1420
- }
1421
- /** @returns the length of the series in bytes. */
1422
- get byteLength() {
1423
- return this.writePos === M ? this.byteCapacity : this.dataType.isVariable ? new R(this.writePos) : this.dataType.density.size(this.writePos);
1424
- }
1425
- /** @returns the number of samples in this array. */
1426
- get length() {
1427
- return this._cachedLength != null ? this._cachedLength : this.dataType.isVariable ? this.calculateCachedLength() : this.writePos === M ? this.data.length : this.writePos;
1428
- }
1429
- calculateCachedLength() {
1430
- if (!this.dataType.isVariable)
1431
- throw new Error("cannot calculate length of a non-variable length data type");
1432
- let t = 0;
1433
- const e = [0];
1434
- return this.data.forEach((s, i) => {
1435
- s === Z && (t++, e.push(i + 1));
1436
- }), this._cachedIndexes = e, this._cachedLength = t, t;
1437
- }
1438
- /**
1439
- * Creates a new array with a different data type.
1440
- * @param target the data type to convert to.
1441
- * @param sampleOffset an offset to apply to each sample. This can help with precision
1442
- * issues when converting between data types.
1443
- *
1444
- * WARNING: This method is expensive and copies the entire underlying array. There
1445
- * also may be untimely precision issues when converting between data types.
1446
- */
1447
- convert(t, e = 0) {
1448
- if (this.dataType.equals(t)) return this;
1449
- const s = new t.Array(this.length);
1450
- for (let i = 0; i < this.length; i++)
1451
- s[i] = mt(this.dataType, t, this.data[i], e);
1452
- return new T({
1453
- data: s.buffer,
1454
- dataType: t,
1455
- timeRange: this.timeRange,
1456
- sampleOffset: e,
1457
- glBufferUsage: this.gl.bufferUsage,
1458
- alignment: this.alignment
1459
- });
1460
- }
1461
- calcRawMax() {
1462
- if (this.length === 0) return -1 / 0;
1463
- if (this.dataType.equals(g.TIMESTAMP))
1464
- this._cachedMax = this.data[this.data.length - 1];
1465
- else if (this.dataType.usesBigInt) {
1466
- const t = this.data;
1467
- this._cachedMax = t.reduce((e, s) => e > s ? e : s);
1468
- } else {
1469
- const t = this.data;
1470
- this._cachedMax = t.reduce((e, s) => e > s ? e : s);
1471
- }
1472
- return this._cachedMax;
1473
- }
1474
- /** @returns the maximum value in the array */
1475
- get max() {
1476
- if (this.dataType.isVariable)
1477
- throw new Error("cannot calculate maximum on a variable length data type");
1478
- return this.writePos === 0 ? -1 / 0 : (this._cachedMax ?? (this._cachedMax = this.calcRawMax()), x(this._cachedMax, this.sampleOffset));
1479
- }
1480
- calcRawMin() {
1481
- if (this.length === 0) return 1 / 0;
1482
- if (this.dataType.equals(g.TIMESTAMP)) this._cachedMin = this.data[0];
1483
- else if (this.dataType.usesBigInt) {
1484
- const t = this.data;
1485
- this._cachedMin = t.reduce((e, s) => e < s ? e : s);
1486
- } else {
1487
- const t = this.data;
1488
- this._cachedMin = t.reduce((e, s) => e < s ? e : s);
1489
- }
1490
- return this._cachedMin;
1491
- }
1492
- /** @returns the minimum value in the array */
1493
- get min() {
1494
- if (this.dataType.isVariable)
1495
- throw new Error("cannot calculate minimum on a variable length data type");
1496
- return this.writePos === 0 ? 1 / 0 : (this._cachedMin ?? (this._cachedMin = this.calcRawMin()), x(this._cachedMin, this.sampleOffset));
1497
- }
1498
- /** @returns the bounds of this array. */
1499
- get bounds() {
1500
- return L(Number(this.min), Number(this.max));
1501
- }
1502
- maybeRecomputeMinMax(t) {
1503
- if (this._cachedMin != null) {
1504
- const e = t._cachedMin ?? t.calcRawMin();
1505
- e < this._cachedMin && (this._cachedMin = e);
1506
- }
1507
- if (this._cachedMax != null) {
1508
- const e = t._cachedMax ?? t.calcRawMax();
1509
- e > this._cachedMax && (this._cachedMax = e);
1510
- }
1511
- }
1512
- enrich() {
1513
- this.max, this.min;
1514
- }
1515
- get range() {
1516
- return x(this.max, -this.min);
1517
- }
1518
- atAlignment(t, e) {
1519
- const s = Number(t - this.alignment);
1520
- if (s < 0 || s >= this.length) {
1521
- if (e === !0) throw new Error(`[series] - no value at index ${s}`);
1522
- return;
1523
- }
1524
- return this.at(s, e);
1525
- }
1526
- at(t, e) {
1527
- if (this.dataType.isVariable) return this.atVariable(t, e ?? !1);
1528
- t < 0 && (t = this.length + t);
1529
- const s = this.data[t];
1530
- if (s == null) {
1531
- if (e === !0) throw new Error(`[series] - no value at index ${t}`);
1532
- return;
1533
- }
1534
- return x(s, this.sampleOffset);
1535
- }
1536
- atVariable(t, e) {
1537
- let s = 0, i = 0;
1538
- if (this._cachedIndexes != null)
1539
- s = this._cachedIndexes[t], i = this._cachedIndexes[t + 1] - 1;
1540
- else {
1541
- t < 0 && (t = this.length + t);
1542
- for (let c = 0; c < this.data.length; c++)
1543
- if (this.data[c] === Z) {
1544
- if (t === 0) {
1545
- i = c;
1546
- break;
1547
- }
1548
- s = c + 1, t--;
1549
- }
1550
- if (i === 0 && (i = this.data.length), s >= i || t > 0) {
1551
- if (e) throw new Error(`[series] - no value at index ${t}`);
1552
- return;
1553
- }
1554
- }
1555
- const h = this.data.slice(s, i);
1556
- return this.dataType.equals(g.STRING) ? new TextDecoder().decode(h) : at(JSON.parse(new TextDecoder().decode(h)));
1557
- }
1558
- /**
1559
- * @returns the index of the first sample that is greater than or equal to the given value.
1560
- * The underlying array must be sorted. If it is not, the behavior of this method is undefined.
1561
- * @param value the value to search for.
1562
- */
1563
- binarySearch(t) {
1564
- let e = 0, s = this.length - 1;
1565
- const i = ut(t);
1566
- for (; e <= s; ) {
1567
- const h = Math.floor((e + s) / 2), c = i(this.at(h, !0), t);
1568
- if (c === 0) return h;
1569
- c < 0 ? e = h + 1 : s = h - 1;
1570
- }
1571
- return e;
1572
- }
1573
- updateGLBuffer(t) {
1574
- if (this.gl.control = t, !this.dataType.equals(g.FLOAT32) && !this.dataType.equals(g.UINT8))
1575
- throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");
1576
- const { buffer: e, bufferUsage: s, prevBuffer: i } = this.gl;
1577
- if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== i)
1578
- if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== M) {
1579
- i === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
1580
- const h = this.dataType.density.size(i).valueOf(), c = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
1581
- t.bufferSubData(t.ARRAY_BUFFER, h, c.buffer), this.gl.prevBuffer = this.writePos;
1582
- } else
1583
- t.bufferData(
1584
- t.ARRAY_BUFFER,
1585
- this.buffer,
1586
- s === "static" ? t.STATIC_DRAW : t.DYNAMIC_DRAW
1587
- ), this.gl.prevBuffer = M;
1588
- }
1589
- as(t) {
1590
- return nt(t, this.dataType), this;
1591
- }
1592
- get digest() {
1593
- var t;
1594
- return {
1595
- key: this.key,
1596
- dataType: this.dataType.toString(),
1597
- sampleOffset: this.sampleOffset,
1598
- alignment: {
1599
- lower: H(this.alignmentBounds.lower),
1600
- upper: H(this.alignmentBounds.upper)
1601
- },
1602
- timeRange: (t = this.timeRange) == null ? void 0 : t.toString(),
1603
- length: this.length,
1604
- capacity: this.capacity
1605
- };
1606
- }
1607
- get memInfo() {
1608
- return {
1609
- key: this.key,
1610
- length: this.length,
1611
- byteLength: this.byteLength,
1612
- glBuffer: this.gl.buffer != null
1613
- };
1614
- }
1615
- get alignmentBounds() {
1616
- return L(this.alignment, this.alignment + BigInt(this.length));
1617
- }
1618
- maybeGarbageCollectGLBuffer(t) {
1619
- this.gl.buffer != null && (t.deleteBuffer(this.gl.buffer), this.gl.buffer = null, this.gl.prevBuffer = 0, this.gl.control = null);
1620
- }
1621
- get glBuffer() {
1622
- if (this.gl.buffer == null) throw new Error("gl buffer not initialized");
1623
- return this.gl.prevBuffer !== this.writePos && console.warn("buffer not updated"), this.gl.buffer;
1624
- }
1625
- [Symbol.iterator]() {
1626
- if (this.dataType.isVariable) {
1627
- const t = new yt(this);
1628
- return this.dataType.equals(g.JSON) ? new G(t) : t;
1629
- }
1630
- return new It(this);
1631
- }
1632
- slice(t, e) {
1633
- return this.sliceSub(!1, t, e);
1634
- }
1635
- sub(t, e) {
1636
- return this.sliceSub(!0, t, e);
1637
- }
1638
- subIterator(t, e) {
1639
- return new W(this, t, e ?? this.length);
1640
- }
1641
- subAlignmentIterator(t, e) {
1642
- return new W(
1643
- this,
1644
- Number(t - this.alignment),
1645
- Number(e - this.alignment)
1646
- );
1647
- }
1648
- subBytes(t, e) {
1649
- if (t >= 0 && (e == null || e >= this.byteLength.valueOf())) return this;
1650
- const s = this.data.subarray(t, e);
1651
- return new T({
1652
- data: s,
1653
- dataType: this.dataType,
1654
- timeRange: this.timeRange,
1655
- sampleOffset: this.sampleOffset,
1656
- glBufferUsage: this.gl.bufferUsage,
1657
- alignment: this.alignment + BigInt(t)
1658
- });
1659
- }
1660
- sliceSub(t, e, s) {
1661
- if (e <= 0 && (s == null || s >= this.length)) return this;
1662
- let i;
1663
- return t ? i = this.data.subarray(e, s) : i = this.data.slice(e, s), new T({
1664
- data: i,
1665
- dataType: this.dataType,
1666
- timeRange: this.timeRange,
1667
- sampleOffset: this.sampleOffset,
1668
- glBufferUsage: this.gl.bufferUsage,
1669
- alignment: this.alignment + BigInt(e)
1670
- });
1671
- }
1672
- reAlign(t) {
1673
- return new T({
1674
- data: this.buffer,
1675
- dataType: this.dataType,
1676
- timeRange: A.ZERO,
1677
- sampleOffset: this.sampleOffset,
1678
- glBufferUsage: "static",
1679
- alignment: t
1680
- });
1681
- }
1682
- toString() {
1683
- var e, s;
1684
- let t = `${this.dataType.toString()} ${this.length} [`;
1685
- if (this.length <= 10) t += Array.from(this).map((i) => i.toString());
1686
- else {
1687
- for (let i = 0; i < 5; i++)
1688
- t += `${(e = this.at(i)) == null ? void 0 : e.toString()}`, i < 4 && (t += ",");
1689
- t += "...";
1690
- for (let i = -5; i < 0; i++)
1691
- t += (s = this.at(i)) == null ? void 0 : s.toString(), i < -1 && (t += ",");
1692
- }
1693
- return t += "]", t;
1694
- }
1695
- };
1696
- r(T, "crudeZ", l.object({
1697
- timeRange: A.z.optional(),
1698
- dataType: g.z,
1699
- alignment: l.coerce.bigint().optional(),
1700
- data: l.union([
1701
- bt,
1702
- wt,
1703
- l.instanceof(ArrayBuffer),
1704
- l.instanceof(Uint8Array)
1705
- ]),
1706
- glBufferUsage: gt.optional().default("static").optional()
1707
- })), r(T, "z", T.crudeZ.transform((t) => new T(t)));
1708
- let k = T;
1709
- class W {
1710
- constructor(t, e, s) {
1711
- r(this, "series");
1712
- r(this, "end");
1713
- r(this, "index");
1714
- this.series = t;
1715
- const i = L(0, t.length);
1716
- this.end = J(i, s), this.index = J(i, e);
1717
- }
1718
- next() {
1719
- return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
1720
- }
1721
- [Symbol.iterator]() {
1722
- return this;
1723
- }
1724
- }
1725
- class yt {
1726
- constructor(t) {
1727
- r(this, "series");
1728
- r(this, "index");
1729
- r(this, "decoder");
1730
- if (!t.dataType.isVariable)
1731
- throw new Error(
1732
- "cannot create a variable series iterator for a non-variable series"
1733
- );
1734
- this.series = t, this.index = 0, this.decoder = new TextDecoder();
1735
- }
1736
- next() {
1737
- const t = this.index, e = this.series.data;
1738
- for (; this.index < e.length && e[this.index] !== Z; ) this.index++;
1739
- const s = this.index;
1740
- return t === s ? { done: !0, value: void 0 } : (this.index++, { done: !1, value: this.decoder.decode(this.series.buffer.slice(t, s)) });
1741
- }
1742
- [Symbol.iterator]() {
1743
- return this;
1744
- }
1745
- }
1746
- var j, K;
1747
- const P = class P {
1748
- constructor(t) {
1749
- r(this, "wrapped");
1750
- r(this, j, "JSONSeriesIterator");
1751
- this.wrapped = t;
1752
- }
1753
- next() {
1754
- const t = this.wrapped.next();
1755
- return t.done === !0 ? { done: !0, value: void 0 } : {
1756
- done: !1,
1757
- value: q.decodeString(t.value, P.SCHEMA)
1758
- };
1759
- }
1760
- [(K = Symbol.iterator, j = Symbol.toStringTag, K)]() {
1761
- return this;
1762
- }
1763
- };
1764
- r(P, "SCHEMA", l.record(l.string(), l.unknown()));
1765
- let G = P;
1766
- var z, X;
1767
- class It {
1768
- constructor(t) {
1769
- r(this, "series");
1770
- r(this, "index");
1771
- r(this, z, "SeriesIterator");
1772
- this.series = t, this.index = 0;
1773
- }
1774
- next() {
1775
- return this.index >= this.series.length ? { done: !0, value: void 0 } : {
1776
- done: !1,
1777
- value: this.series.at(this.index++, !0)
1778
- };
1779
- }
1780
- [(X = Symbol.iterator, z = Symbol.toStringTag, X)]() {
1781
- return this;
1782
- }
1783
- }
1784
- class $t {
1785
- constructor(t = []) {
1786
- r(this, "series");
1787
- if (t.length !== 0) {
1788
- const e = t[0].dataType;
1789
- for (let s = 1; s < t.length; s++)
1790
- if (!t[s].dataType.equals(e))
1791
- throw new Error("[multi-series] - series must have the same data type");
1792
- }
1793
- this.series = t;
1794
- }
1795
- as(t) {
1796
- return nt(t, this.dataType), this;
1797
- }
1798
- get dataType() {
1799
- return this.series.length === 0 ? g.UNKNOWN : this.series[0].dataType;
1800
- }
1801
- get timeRange() {
1802
- return this.series.length === 0 ? A.ZERO : new A(
1803
- this.series[0].timeRange.start,
1804
- this.series[this.series.length - 1].timeRange.end
1805
- );
1806
- }
1807
- get alignment() {
1808
- return this.series.length === 0 ? 0n : this.series[0].alignment;
1809
- }
1810
- get alignmentBounds() {
1811
- return this.series.length === 0 ? L(0n, 0n) : L(
1812
- this.series[0].alignmentBounds.lower,
1813
- this.series[this.series.length - 1].alignmentBounds.upper
1814
- );
1815
- }
1816
- push(t) {
1817
- "isSynnaxSeries" in t && t.isSynnaxSeries ? this.series.push(t) : this.series.push(...t.series);
1818
- }
1819
- get length() {
1820
- return this.series.reduce((t, e) => t + e.length, 0);
1821
- }
1822
- atAlignment(t, e) {
1823
- if (this.series.length === 0) {
1824
- if (e) throw new Error(`[series] - no value at alignment ${t}`);
1825
- return;
1826
- }
1827
- for (const s of this.series)
1828
- if (D(s.alignmentBounds, t))
1829
- return s.atAlignment(t, e);
1830
- if (e) throw new Error(`[series] - no value at alignment ${t}`);
1831
- }
1832
- at(t, e = !1) {
1833
- t < 0 && (t = this.length + t);
1834
- for (const s of this.series) {
1835
- if (t < s.length) return s.at(t, e);
1836
- t -= s.length;
1837
- }
1838
- if (e) throw new Error(`[series] - no value at index ${t}`);
1839
- }
1840
- subIterator(t, e) {
1841
- return new F(this, t, e ?? this.length);
1842
- }
1843
- subAlignmentIterator(t, e) {
1844
- if (t >= this.alignmentBounds.upper || e <= this.alignmentBounds.lower)
1845
- return Y;
1846
- let s = 0;
1847
- for (let h = 0; h < this.series.length; h++) {
1848
- const c = this.series[h];
1849
- if (t < c.alignment) break;
1850
- if (t >= c.alignmentBounds.upper) s += c.length;
1851
- else if (D(c.alignmentBounds, t)) {
1852
- s += Number(t - c.alignment);
1853
- break;
1854
- }
1855
- }
1856
- let i = 0;
1857
- for (let h = 0; h < this.series.length; h++) {
1858
- const c = this.series[h];
1859
- if (e < c.alignment) break;
1860
- if (e >= c.alignmentBounds.upper) i += c.length;
1861
- else if (D(c.alignmentBounds, e)) {
1862
- i += Number(e - c.alignment);
1863
- break;
1864
- }
1865
- }
1866
- return new F(this, s, i);
1867
- }
1868
- subAlignmentSpanIterator(t, e) {
1869
- if (t >= this.alignmentBounds.upper) return Y;
1870
- let s = 0;
1871
- for (let i = 0; i < this.series.length; i++) {
1872
- const h = this.series[i];
1873
- if (t < h.alignment) break;
1874
- if (t >= h.alignmentBounds.upper) s += h.length;
1875
- else if (D(h.alignmentBounds, t)) {
1876
- s += Number(t - h.alignment);
1877
- break;
1878
- }
1879
- }
1880
- return new F(this, s, s + e);
1881
- }
1882
- updateGLBuffer(t) {
1883
- this.series.forEach((e) => e.updateGLBuffer(t));
1884
- }
1885
- get bounds() {
1886
- return ot(this.series.map((t) => t.bounds));
1887
- }
1888
- get byteLength() {
1889
- return new R(this.series.reduce((t, e) => t + e.byteLength.valueOf(), 0));
1890
- }
1891
- get data() {
1892
- const t = new this.dataType.Array(this.length);
1893
- let e = 0;
1894
- for (const s of this.series)
1895
- t.set(s.data, e), e += s.length;
1896
- return new this.dataType.Array(t.buffer);
1897
- }
1898
- traverseAlignment(t, e) {
1899
- const s = this.series.map((i) => i.alignmentBounds);
1900
- return lt(s, t, e);
1901
- }
1902
- acquire() {
1903
- this.series.forEach((t) => t.acquire());
1904
- }
1905
- release() {
1906
- this.series.forEach((t) => t.release());
1907
- }
1908
- distance(t, e) {
1909
- const s = this.series.map((i) => i.alignmentBounds);
1910
- return ft(s, t, e);
1911
- }
1912
- parseJSON(t) {
1913
- if (!this.dataType.equals(g.JSON))
1914
- throw new Error("cannot parse non-JSON series as JSON");
1915
- return this.series.flatMap((e) => e.parseJSON(t));
1916
- }
1917
- [Symbol.iterator]() {
1918
- return this.series.length === 0 ? {
1919
- next() {
1920
- return { done: !0, value: void 0 };
1921
- }
1922
- } : new Tt(this.series);
1923
- }
1924
- }
1925
- var Q, _;
1926
- class Tt {
1927
- constructor(t) {
1928
- r(this, "series");
1929
- r(this, "seriesIndex");
1930
- r(this, "internal");
1931
- r(this, Q, "MultiSeriesIterator");
1932
- this.series = t, this.seriesIndex = 0, this.internal = t[0][Symbol.iterator]();
1933
- }
1934
- next() {
1935
- const t = this.internal.next();
1936
- return t.done === !1 ? t : this.seriesIndex === this.series.length - 1 ? { done: !0, value: void 0 } : (this.internal = this.series[++this.seriesIndex][Symbol.iterator](), this.next());
1937
- }
1938
- [(_ = Symbol.iterator, Q = Symbol.toStringTag, _)]() {
1939
- return this;
1940
- }
1941
- }
1942
- class F {
1943
- constructor(t, e, s) {
1944
- r(this, "series");
1945
- r(this, "index");
1946
- r(this, "end");
1947
- this.series = t, this.end = s, this.index = e;
1948
- }
1949
- next() {
1950
- return this.index >= this.end ? { done: !0, value: void 0 } : { done: !1, value: this.series.at(this.index++, !0) };
1951
- }
1952
- [Symbol.iterator]() {
1953
- return this;
1954
- }
1955
- }
1956
- const H = (o) => {
1957
- const t = o >> 32n, e = o & 0xffffffffn;
1958
- return { domain: t, sample: e };
1959
- };
1960
- export {
1961
- y as D,
1962
- $t as M,
1963
- $ as R,
1964
- k as S,
1965
- m as T,
1966
- O as a,
1967
- A as b,
1968
- g as c,
1969
- R as d,
1970
- st as e,
1971
- mt as f,
1972
- x as g,
1973
- Lt as h,
1974
- Ot as i,
1975
- Dt as s,
1976
- qt as t
1977
- };