@synnaxlabs/x 0.37.0 → 0.38.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 (122) hide show
  1. package/.turbo/turbo-build.log +35 -31
  2. package/dist/box-BZ6d2d5A.cjs +1 -0
  3. package/dist/box-Cto-5Uxu.js +201 -0
  4. package/dist/box.cjs +1 -1
  5. package/dist/box.js +1 -1
  6. package/dist/compare.cjs +1 -1
  7. package/dist/compare.js +1 -1
  8. package/dist/external-C-dNgNQw.cjs +1 -0
  9. package/dist/external-Cax-LfQW.cjs +1 -0
  10. package/dist/external-DqPrWKvU.js +47 -0
  11. package/dist/{external-DKQKvgIi.js → external-vFGUdZf6.js} +9 -9
  12. package/dist/index-BG3Scw3G.cjs +1 -0
  13. package/dist/{index-HQonyH7n.js → index-BVC_8Cg9.js} +1 -1
  14. package/dist/index-D4NCYiQB.js +19 -0
  15. package/dist/index-udOjA9d-.cjs +1 -0
  16. package/dist/index.cjs +2 -2
  17. package/dist/index.js +56 -54
  18. package/dist/kv.cjs +1 -1
  19. package/dist/kv.js +2 -2
  20. package/dist/link.cjs +1 -0
  21. package/dist/link.js +10 -0
  22. package/dist/position-CvSNZkSD.cjs +1 -0
  23. package/dist/position-GeF1oEYk.js +85 -0
  24. package/dist/position.cjs +1 -1
  25. package/dist/position.js +1 -1
  26. package/dist/runtime.cjs +1 -1
  27. package/dist/runtime.js +1 -1
  28. package/dist/{scale-BESJN9LG.cjs → scale-BTgf0Mr-.cjs} +1 -1
  29. package/dist/{scale-CV3O6tkY.js → scale-Dh1UNRoC.js} +2 -2
  30. package/dist/scale.cjs +1 -1
  31. package/dist/scale.js +1 -1
  32. package/dist/series-BMhEEJZL.cjs +11 -0
  33. package/dist/{series-C_B2hAp9.js → series-DxDIugLj.js} +295 -285
  34. package/dist/spatial.cjs +1 -1
  35. package/dist/spatial.js +4 -4
  36. package/dist/src/deep/path.d.ts.map +1 -1
  37. package/dist/src/index.d.ts +1 -0
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/kv/external.d.ts +3 -0
  40. package/dist/src/kv/external.d.ts.map +1 -0
  41. package/dist/src/kv/index.d.ts +1 -1
  42. package/dist/src/kv/index.d.ts.map +1 -1
  43. package/dist/src/kv/mock.d.ts +24 -0
  44. package/dist/src/kv/mock.d.ts.map +1 -0
  45. package/dist/src/kv/mock.spec.d.ts +2 -0
  46. package/dist/src/kv/mock.spec.d.ts.map +1 -0
  47. package/dist/src/kv/types.d.ts +18 -18
  48. package/dist/src/kv/types.d.ts.map +1 -1
  49. package/dist/src/link/index.d.ts +2 -0
  50. package/dist/src/link/index.d.ts.map +1 -0
  51. package/dist/src/link/link.d.ts +2 -0
  52. package/dist/src/link/link.d.ts.map +1 -0
  53. package/dist/src/link/link.spec.d.ts +2 -0
  54. package/dist/src/link/link.spec.d.ts.map +1 -0
  55. package/dist/src/runtime/os.d.ts.map +1 -1
  56. package/dist/src/telem/index.d.ts +1 -1
  57. package/dist/src/telem/index.d.ts.map +1 -1
  58. package/dist/src/telem/series.d.ts +1 -0
  59. package/dist/src/telem/series.d.ts.map +1 -1
  60. package/dist/src/telem/telem.d.ts +2 -0
  61. package/dist/src/telem/telem.d.ts.map +1 -1
  62. package/dist/src/unique/index.d.ts +2 -0
  63. package/dist/src/unique/index.d.ts.map +1 -0
  64. package/dist/src/unique/unique.d.ts +42 -0
  65. package/dist/src/unique/unique.d.ts.map +1 -0
  66. package/dist/src/unique/unique.spec.d.ts +2 -0
  67. package/dist/src/unique/unique.spec.d.ts.map +1 -0
  68. package/dist/src/zodutil/index.d.ts.map +1 -1
  69. package/dist/src/zodutil/zodutil.d.ts +1 -16
  70. package/dist/src/zodutil/zodutil.d.ts.map +1 -1
  71. package/dist/telem.cjs +1 -1
  72. package/dist/telem.js +1 -1
  73. package/dist/unique.cjs +1 -1
  74. package/dist/unique.js +2 -2
  75. package/dist/url.cjs +1 -1
  76. package/dist/url.js +5 -5
  77. package/dist/{xy-LADI2wVU.cjs → xy-Budz-qz-.cjs} +1 -1
  78. package/dist/{xy-DQdccWlc.js → xy-DxjPL2DZ.js} +4 -4
  79. package/dist/xy.cjs +1 -1
  80. package/dist/xy.js +1 -1
  81. package/dist/zodutil-BfrF8jE3.js +23 -0
  82. package/dist/zodutil-DFJyyQd2.cjs +1 -0
  83. package/dist/zodutil.cjs +1 -1
  84. package/dist/zodutil.js +1 -1
  85. package/package.json +5 -7
  86. package/src/caseconv/caseconv.spec.ts +4 -20
  87. package/src/compare/compare.ts +2 -2
  88. package/src/deep/path.ts +1 -1
  89. package/src/index.ts +1 -0
  90. package/src/{unique.ts → kv/external.ts} +2 -1
  91. package/src/kv/index.ts +1 -1
  92. package/src/kv/mock.spec.ts +101 -0
  93. package/src/kv/mock.ts +58 -0
  94. package/src/kv/types.ts +22 -28
  95. package/src/link/index.ts +10 -0
  96. package/src/link/link.spec.ts +68 -0
  97. package/src/link/link.ts +21 -0
  98. package/src/runtime/os.ts +1 -1
  99. package/src/telem/index.ts +1 -1
  100. package/src/telem/series.spec.ts +21 -0
  101. package/src/telem/series.ts +15 -8
  102. package/src/telem/telem.ts +34 -10
  103. package/src/unique/index.ts +10 -0
  104. package/src/unique/unique.spec.ts +192 -0
  105. package/src/unique/unique.ts +67 -0
  106. package/src/zodutil/index.ts +1 -1
  107. package/src/zodutil/zodutil.ts +1 -29
  108. package/tsconfig.tsbuildinfo +1 -1
  109. package/vite.config.ts +6 -8
  110. package/dist/box-BHIyGhI_.cjs +0 -1
  111. package/dist/box-CfhGfJJH.js +0 -201
  112. package/dist/external-CghVMqCA.cjs +0 -1
  113. package/dist/index-h-QAL9T1.cjs +0 -1
  114. package/dist/position-BXFz7I9G.js +0 -85
  115. package/dist/position-CFiSGTz9.cjs +0 -1
  116. package/dist/series-BbxR21uO.cjs +0 -11
  117. package/dist/src/unique.d.ts +0 -2
  118. package/dist/src/unique.d.ts.map +0 -1
  119. package/dist/types-BpAJW2TM.js +0 -11
  120. package/dist/types-zRwnQ1hc.cjs +0 -1
  121. package/dist/zodutil-BRjUdYAv.cjs +0 -1
  122. package/dist/zodutil-DI4gVZkT.js +0 -27
package/dist/index.js CHANGED
@@ -3,34 +3,35 @@ var T = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writab
3
3
  var p = (e, t, r) => T(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  import { e as ne } from "./index-OHIRoCei.js";
5
5
  import { z as c } from "zod";
6
- import { b as x } from "./series-C_B2hAp9.js";
7
- import { d as ie, D as ae, M as ce, R as le, S as ue, e as fe, c as me, T as de, a as pe, g as ge, h as be, i as xe, f as he, s as ye, t as Se } from "./series-C_B2hAp9.js";
8
- import { a as $e } from "./index-BfDeGfej.js";
6
+ import { b as x } from "./series-DxDIugLj.js";
7
+ import { d as ie, D as ae, M as ce, R as le, S as ue, e as fe, c as me, T as de, a as pe, g as ge, h as be, i as xe, f as he, s as ye, t as Se } from "./series-DxDIugLj.js";
8
+ import { a as ve } from "./index-BfDeGfej.js";
9
9
  import { c as je } from "./change-DLl6DccR.js";
10
- import { c as Me, s as Te } from "./scale-CV3O6tkY.js";
11
- import { L as S, G as v, E as k, i as A, a as _, b as O } from "./index-HQonyH7n.js";
12
- import { c as Ae, d as _e, p as Oe } from "./index-HQonyH7n.js";
10
+ import { c as Me, s as Te } from "./scale-Dh1UNRoC.js";
11
+ import { L as S, G as $, E as k, i as A, a as _, b as O } from "./index-BVC_8Cg9.js";
12
+ import { c as Ae, d as _e, p as Oe } from "./index-BVC_8Cg9.js";
13
13
  import { debounce as ze, throttle as Le } from "./debounce.js";
14
14
  import { deep as Pe } from "./deep.js";
15
15
  import { isObject as Ge } from "./identity.js";
16
- import { t as Ze } from "./types-BpAJW2TM.js";
17
- import { b as Ie, f as We } from "./bounds-BtccGJW0.js";
18
- import { observe as Be } from "./observe.js";
19
- import { getEntries as He, mapValues as Qe, unknownRecordZ as Ue } from "./record.js";
20
- import { e as Ke } from "./external-DKQKvgIi.js";
21
- import { Search as Ye } from "./search.js";
22
- import { b as rr } from "./box-CfhGfJJH.js";
23
- import { d as or } from "./dimensions-D-1PnJVI.js";
24
- import { d as sr } from "./direction-CScbfCdT.js";
25
- import { l as ar } from "./location-C5Ot4MVG.js";
26
- import { p as lr } from "./position-BXFz7I9G.js";
27
- import { s as fr } from "./spatial-DozyssiN.js";
28
- import { x as dr } from "./xy-DQdccWlc.js";
29
- import { nullToArr as gr, toArray as br } from "./toArray.js";
30
- import { unique as hr } from "./unique.js";
31
- import { URL as Sr, buildQueryString as vr } from "./url.js";
32
- import { RoutedWorker as Er, TypedWorker as jr, createMockWorkers as wr } from "./worker.js";
33
- import { z as Tr } from "./zodutil-DI4gVZkT.js";
16
+ import { e as Ze } from "./external-DqPrWKvU.js";
17
+ import { link as Ie } from "./link.js";
18
+ import { b as qe, f as Be } from "./bounds-BtccGJW0.js";
19
+ import { observe as He } from "./observe.js";
20
+ import { getEntries as Ue, mapValues as Je, unknownRecordZ as Ke } from "./record.js";
21
+ import { e as Ye } from "./external-vFGUdZf6.js";
22
+ import { Search as rr } from "./search.js";
23
+ import { b as or } from "./box-Cto-5Uxu.js";
24
+ import { d as sr } from "./dimensions-D-1PnJVI.js";
25
+ import { d as ar } from "./direction-CScbfCdT.js";
26
+ import { l as lr } from "./location-C5Ot4MVG.js";
27
+ import { p as fr } from "./position-GeF1oEYk.js";
28
+ import { s as dr } from "./spatial-DozyssiN.js";
29
+ import { x as gr } from "./xy-DxjPL2DZ.js";
30
+ import { nullToArr as xr, toArray as hr } from "./toArray.js";
31
+ import { u as Sr } from "./index-D4NCYiQB.js";
32
+ import { URL as vr, buildQueryString as Er } from "./url.js";
33
+ import { RoutedWorker as wr, TypedWorker as Mr, createMockWorkers as Tr } from "./worker.js";
34
+ import { z as Ar } from "./zodutil-BfrF8jE3.js";
34
35
  const R = async (e) => await new Promise(
35
36
  (t) => setTimeout(t, x.fromMilliseconds(e).milliseconds)
36
37
  ), z = c.object({
@@ -79,8 +80,8 @@ const j = c.object({
79
80
  }
80
81
  };
81
82
  p(m, "MESSAGE", "canceled");
82
- let $ = m;
83
- const C = new $(), J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
83
+ let v = m;
84
+ const C = new v(), J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
84
85
  __proto__: null,
85
86
  CANCELED: C
86
87
  }, Symbol.toStringTag, { value: "Module" })), K = (e) => e ? -1 : 1, E = c.string().regex(/^\d+\.\d+\.\d+$/), g = (e, t, r = {}) => {
@@ -88,15 +89,15 @@ const C = new $(), J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defi
88
89
  const n = E.parse(e), s = E.parse(t), [l, f, d] = n.split(".").map(Number), [i, o, a] = s.split(".").map(Number);
89
90
  if (r.checkMajor) {
90
91
  if (l < i) return S;
91
- if (l > i) return v;
92
+ if (l > i) return $;
92
93
  }
93
94
  if (r.checkMinor) {
94
95
  if (f < o) return S;
95
- if (f > o) return v;
96
+ if (f > o) return $;
96
97
  }
97
98
  if (r.checkPatch) {
98
99
  if (d < a) return S;
99
- if (d > a) return v;
100
+ if (d > a) return $;
100
101
  }
101
102
  return k;
102
103
  }, G = (e, t, r = {}) => A(g(e, t, r)), w = (e, t, r = {}) => _(g(e, t, r)), D = (e, t, r = {}) => O(g(e, t, r)), Z = ({
@@ -204,35 +205,35 @@ export {
204
205
  ae as Density,
205
206
  ce as MultiSeries,
206
207
  le as Rate,
207
- Er as RoutedWorker,
208
- Ye as Search,
208
+ wr as RoutedWorker,
209
+ rr as Search,
209
210
  ue as Series,
210
211
  fe as Size,
211
212
  me as TimeRange,
212
213
  x as TimeSpan,
213
214
  de as TimeStamp,
214
- jr as TypedWorker,
215
- Sr as URL,
215
+ Mr as TypedWorker,
216
+ vr as URL,
216
217
  pe as addSamples,
217
218
  ne as binary,
218
- Ie as bounds,
219
- rr as box,
219
+ qe as bounds,
220
+ or as box,
220
221
  Q as breaker,
221
- vr as buildQueryString,
222
- $e as caseconv,
222
+ Er as buildQueryString,
223
+ ve as caseconv,
223
224
  je as change,
224
225
  Me as clamp,
225
226
  Ae as compare,
226
227
  U as control,
227
228
  ge as convertDataType,
228
229
  Y as convertRenderV,
229
- wr as createMockWorkers,
230
+ Tr as createMockWorkers,
230
231
  ze as debounce,
231
232
  Pe as deep,
232
- or as dimensions,
233
- sr as direction,
233
+ sr as dimensions,
234
+ ar as direction,
234
235
  J as errors,
235
- He as getEntries,
236
+ Ue as getEntries,
236
237
  be as id,
237
238
  K as invert,
238
239
  xe as isCrudeSeries,
@@ -240,25 +241,26 @@ export {
240
241
  _e as isStringer,
241
242
  he as isTelemValue,
242
243
  Ze as kv,
243
- ar as location,
244
- Qe as mapValues,
245
- We as math,
244
+ Ie as link,
245
+ lr as location,
246
+ Je as mapValues,
247
+ Be as math,
246
248
  X as migrate,
247
- gr as nullToArr,
248
- Be as observe,
249
- lr as position,
249
+ xr as nullToArr,
250
+ He as observe,
251
+ fr as position,
250
252
  Oe as primitiveIsZero,
251
- Ke as runtime,
253
+ Ye as runtime,
252
254
  Te as scale,
253
255
  ee as shallowCopy,
254
256
  ye as sortTimeRange,
255
- fr as spatial,
257
+ dr as spatial,
256
258
  re as strings,
257
259
  Le as throttle,
258
- br as toArray,
260
+ hr as toArray,
259
261
  Se as typedArrayZ,
260
- hr as unique,
261
- Ue as unknownRecordZ,
262
- dr as xy,
263
- Tr as zodutil
262
+ Sr as unique,
263
+ Ke as unknownRecordZ,
264
+ gr as xy,
265
+ Ar as zodutil
264
266
  };
package/dist/kv.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./types-zRwnQ1hc.cjs");exports.kv=e.types;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-C-dNgNQw.cjs");exports.kv=e.external;
package/dist/kv.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t } from "./types-BpAJW2TM.js";
1
+ import { e as r } from "./external-DqPrWKvU.js";
2
2
  export {
3
- t as kv
3
+ r as kv
4
4
  };
package/dist/link.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=new RegExp("^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$"),o=e=>t.test(e),l=Object.freeze(Object.defineProperty({__proto__:null,is:o},Symbol.toStringTag,{value:"Module"}));exports.link=l;
package/dist/link.js ADDED
@@ -0,0 +1,10 @@
1
+ const t = new RegExp(
2
+ "^(https?:\\/\\/)?((([a-zA-Z0-9][a-zA-Z0-9-]*\\.)+[a-zA-Z]{2,})|localhost|(\\d{1,3}\\.){3}\\d{1,3})(\\:\\d+)?(\\/[-a-zA-Z0-9@:%._\\+~#=]*)*(\\?[;&a-zA-Z0-9%_.,~+=-]*)?(#[-a-zA-Z0-9_]*)?$"
3
+ // fragment identifier (optional)
4
+ ), o = (e) => t.test(e), a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5
+ __proto__: null,
6
+ is: o
7
+ }, Symbol.toStringTag, { value: "Module" }));
8
+ export {
9
+ a as link
10
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./box-BZ6d2d5A.cjs"),T=require("./direction-D7qoo_GJ.cjs"),n=require("./location-BIet4Mig.cjs"),b=require("./base-B48bPNx5.cjs"),P=t=>{if(t==null)return{x:void 0,y:void 0};const r=n.xy.safeParse(t);if(r.success)return r.data;const e=b.location.safeParse(t);return e.success?T.construct(e.data)==="x"?{x:e.data,y:void 0}:{x:void 0,y:e.data}:t},N=({container:t,target:r,dialog:e,initial:u,prefer:a,alignments:f=["start"],disable:x=[]})=>{const i=P(u);let l=n.XY_LOCATIONS;if(a!=null){const o=a.map(s=>P(s));l=l.slice().sort((s,p)=>{const d=o.findIndex(g=>n.xyMatches(s,g)),h=o.findIndex(g=>n.xyMatches(p,g));return d>-1&&h>-1?d-h:d>-1?-1:h>-1?1:0})}const O=l.filter(o=>!n.xyEquals(o,n.CENTER)&&(i.x==null||o.x===i.x)&&(i.y==null||o.y===i.y)&&!x.some(s=>n.xyMatches(o,s))).map(o=>f==null?void 0:f.map(s=>[o,s])).flat(),A=c.construct(t),M=c.construct(r),_=c.construct(e);let E=-1/0;const y={location:n.CENTER,adjustedDialog:_};return O.forEach(([o,s])=>{const[p,d]=I({option:o,alignment:s,container:A,target:M,dialog:_});d>E&&(E=d,y.location=o,y.adjustedDialog=p)}),y},I=({option:t,alignment:r,container:e,target:u,dialog:a})=>{const f=L(t,r),x=c.xyLoc(u,t),i=c.constructWithAlternateRoot(x.x,x.y,c.width(a),c.height(a),f,n.TOP_LEFT),l=c.area(c.intersection(i,e));return[i,l]},j={start:"left",center:"center",end:"right"},q={start:"bottom",center:"center",end:"top"},L=(t,r)=>{const e={x:"center",y:"center"};if(t.y!=="center"){e.y=n.swap(t.y);const u=t.x==="left"?n.swap:a=>a;e.x=u(j[r])}else e.x=n.swap(t.x),e.y=q[r];return e},w=Object.freeze(Object.defineProperty({__proto__:null,dialog:N,getRoot:L,parseLocationOptions:P},Symbol.toStringTag,{value:"Module"}));exports.position=w;
@@ -0,0 +1,85 @@
1
+ import { c as g, x as I, a as M, h as N, w as X, d as j, i as w } from "./box-Cto-5Uxu.js";
2
+ import { c as B } from "./direction-CScbfCdT.js";
3
+ import { x as C, a as h, b as R, C as O, T as S, s as m, X as Y } from "./location-C5Ot4MVG.js";
4
+ import { l as v } from "./base-DnZzEvvz.js";
5
+ const P = (t) => {
6
+ if (t == null) return { x: void 0, y: void 0 };
7
+ const o = C.safeParse(t);
8
+ if (o.success) return o.data;
9
+ const e = v.safeParse(t);
10
+ return e.success ? B(e.data) === "x" ? { x: e.data, y: void 0 } : { x: void 0, y: e.data } : t;
11
+ }, D = ({
12
+ container: t,
13
+ target: o,
14
+ dialog: e,
15
+ initial: c,
16
+ prefer: a,
17
+ alignments: d = ["start"],
18
+ disable: f = []
19
+ }) => {
20
+ const n = P(c);
21
+ let u = Y;
22
+ if (a != null) {
23
+ const s = a.map((r) => P(r));
24
+ u = u.slice().sort((r, x) => {
25
+ const i = s.findIndex((y) => h(r, y)), p = s.findIndex((y) => h(x, y));
26
+ return i > -1 && p > -1 ? i - p : i > -1 ? -1 : p > -1 ? 1 : 0;
27
+ });
28
+ }
29
+ const T = u.filter(
30
+ (s) => !R(s, O) && (n.x == null || s.x === n.x) && (n.y == null || s.y === n.y) && !f.some((r) => h(s, r))
31
+ ).map((s) => d == null ? void 0 : d.map((r) => [s, r])).flat(), E = g(t), b = g(o), _ = g(e);
32
+ let L = -1 / 0;
33
+ const l = { location: O, adjustedDialog: _ };
34
+ return T.forEach(([s, r]) => {
35
+ const [x, i] = G({
36
+ option: s,
37
+ alignment: r,
38
+ container: E,
39
+ target: b,
40
+ dialog: _
41
+ });
42
+ i > L && (L = i, l.location = s, l.adjustedDialog = x);
43
+ }), l;
44
+ }, G = ({
45
+ option: t,
46
+ alignment: o,
47
+ container: e,
48
+ target: c,
49
+ dialog: a
50
+ }) => {
51
+ const d = A(t, o), f = I(c, t), n = M(
52
+ f.x,
53
+ f.y,
54
+ X(a),
55
+ N(a),
56
+ d,
57
+ S
58
+ ), u = j(w(n, e));
59
+ return [n, u];
60
+ }, $ = {
61
+ start: "left",
62
+ center: "center",
63
+ end: "right"
64
+ }, q = {
65
+ start: "bottom",
66
+ center: "center",
67
+ end: "top"
68
+ }, A = (t, o) => {
69
+ const e = { x: "center", y: "center" };
70
+ if (t.y !== "center") {
71
+ e.y = m(t.y);
72
+ const c = t.x === "left" ? m : (a) => a;
73
+ e.x = c($[o]);
74
+ } else
75
+ e.x = m(t.x), e.y = q[o];
76
+ return e;
77
+ }, H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
78
+ __proto__: null,
79
+ dialog: D,
80
+ getRoot: A,
81
+ parseLocationOptions: P
82
+ }, Symbol.toStringTag, { value: "Module" }));
83
+ export {
84
+ H as p
85
+ };
package/dist/position.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./position-CFiSGTz9.cjs");exports.position=o.position;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./position-CvSNZkSD.cjs");exports.position=o.position;
package/dist/position.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as i } from "./position-BXFz7I9G.js";
1
+ import { p as i } from "./position-GeF1oEYk.js";
2
2
  export {
3
3
  i as position
4
4
  };
package/dist/runtime.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-CghVMqCA.cjs");exports.runtime=e.external;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-Cax-LfQW.cjs");exports.runtime=e.external;
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- import { e as m } from "./external-DKQKvgIi.js";
1
+ import { e as m } from "./external-vFGUdZf6.js";
2
2
  export {
3
3
  m as runtime
4
4
  };
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var R=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var i=(n,t,e)=>R(n,typeof t!="symbol"?t+"":t,e);const h=require("zod"),x=require("./bounds-8aFLdbEj.cjs"),u=require("./box-BHIyGhI_.cjs"),T=require("./location-BIet4Mig.cjs"),d=require("./xy-LADI2wVU.cjs"),B=(n,t,e)=>t!==void 0&&n<t?t:e!==void 0&&n>e?e:n,q=h.z.object({offset:d.crudeZ,scale:d.crudeZ}),z=h.z.object({offset:h.z.number(),scale:h.z.number()}),E=n=>(t,e,s,r)=>e==="dimension"?[t,s]:[t,r?s-n:s+n],I=n=>(t,e,s,r)=>[t,r?s/n:s*n],j=n=>(t,e,s)=>{if(t===null)return[n,s];const{lower:r,upper:o}=t,{lower:p,upper:l}=n,w=o-r,m=l-p;if(e==="dimension")return[n,s*(m/w)];const g=(s-r)*(m/w)+p;return[n,g]},Y=n=>(t,e,s)=>[n,s],D=()=>(n,t,e)=>{if(n===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[n,e];const{lower:s,upper:r}=n;return[n,r-(e-s)]},L=n=>(t,e,s)=>{const{lower:r,upper:o}=n;return s=B(s,r,o),[t,s]},a=class a{constructor(){i(this,"ops",[]);i(this,"currBounds",null);i(this,"currType",null);i(this,"reversed",!1);this.ops=[]}static translate(t){return new a().translate(t)}static magnify(t){return new a().magnify(t)}static scale(t,e){return new a().scale(t,e)}translate(t){const e=this.new(),s=E(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=I(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=x.construct(t,e),r=this.new(),o=j(s);return o.type="scale",r.ops.push(o),r}clamp(t,e){const s=x.construct(t,e),r=this.new(),o=L(s);return o.type="clamp",r.ops.push(o),r}reBound(t,e){const s=x.construct(t,e),r=this.new(),o=Y(s);return o.type="re-bound",r.ops.push(o),r}invert(){const t=D();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new a;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,r],o)=>o(s,t,r,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,r)=>{if(s.type==="scale"||e.some(([p,l])=>r>=p&&r<=l))return;const o=t.ops.findIndex((p,l)=>p.type==="scale"&&l>r);o!==-1&&e.push([r,o])}),e.forEach(([s,r])=>{const o=t.ops.slice(s,r);o.unshift(t.ops[r]),t.ops.splice(s,r-s+1,...o)}),t.reversed=!t.reversed,t}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};i(a,"IDENTITY",new a);let y=a;const c=class c{constructor(t=new y,e=new y,s=null){i(this,"x");i(this,"y");i(this,"currRoot");this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=d.construct(t,e),r=this.copy();return r.x=this.x.translate(s.x),r.y=this.y.translate(s.y),r}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!T.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}dim(t){return{x:this.x.dim(t.x),y:this.y.dim(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};i(c,"IDENTITY",new c);let f=c;const M=Object.freeze(Object.defineProperty({__proto__:null,Scale:y,XY:f,crudeXYTransform:q,transform:z},Symbol.toStringTag,{value:"Module"}));exports.clamp=B;exports.scale=M;
1
+ "use strict";var v=Object.defineProperty;var R=(r,t,e)=>t in r?v(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var i=(r,t,e)=>R(r,typeof t!="symbol"?t+"":t,e);const h=require("zod"),x=require("./bounds-8aFLdbEj.cjs"),u=require("./box-BZ6d2d5A.cjs"),T=require("./location-BIet4Mig.cjs"),d=require("./xy-Budz-qz-.cjs"),B=(r,t,e)=>t!==void 0&&r<t?t:e!==void 0&&r>e?e:r,q=h.z.object({offset:d.crudeZ,scale:d.crudeZ}),z=h.z.object({offset:h.z.number(),scale:h.z.number()}),E=r=>(t,e,s,n)=>e==="dimension"?[t,s]:[t,n?s-r:s+r],I=r=>(t,e,s,n)=>[t,n?s/r:s*r],j=r=>(t,e,s)=>{if(t===null)return[r,s];const{lower:n,upper:o}=t,{lower:p,upper:l}=r,w=o-n,m=l-p;if(e==="dimension")return[r,s*(m/w)];const g=(s-n)*(m/w)+p;return[r,g]},Y=r=>(t,e,s)=>[r,s],D=()=>(r,t,e)=>{if(r===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[r,e];const{lower:s,upper:n}=r;return[r,n-(e-s)]},L=r=>(t,e,s)=>{const{lower:n,upper:o}=r;return s=B(s,n,o),[t,s]},a=class a{constructor(){i(this,"ops",[]);i(this,"currBounds",null);i(this,"currType",null);i(this,"reversed",!1);this.ops=[]}static translate(t){return new a().translate(t)}static magnify(t){return new a().magnify(t)}static scale(t,e){return new a().scale(t,e)}translate(t){const e=this.new(),s=E(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=I(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=x.construct(t,e),n=this.new(),o=j(s);return o.type="scale",n.ops.push(o),n}clamp(t,e){const s=x.construct(t,e),n=this.new(),o=L(s);return o.type="clamp",n.ops.push(o),n}reBound(t,e){const s=x.construct(t,e),n=this.new(),o=Y(s);return o.type="re-bound",n.ops.push(o),n}invert(){const t=D();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new a;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,n],o)=>o(s,t,n,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,n)=>{if(s.type==="scale"||e.some(([p,l])=>n>=p&&n<=l))return;const o=t.ops.findIndex((p,l)=>p.type==="scale"&&l>n);o!==-1&&e.push([n,o])}),e.forEach(([s,n])=>{const o=t.ops.slice(s,n);o.unshift(t.ops[n]),t.ops.splice(s,n-s+1,...o)}),t.reversed=!t.reversed,t}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};i(a,"IDENTITY",new a);let y=a;const c=class c{constructor(t=new y,e=new y,s=null){i(this,"x");i(this,"y");i(this,"currRoot");this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=d.construct(t,e),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!T.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}dim(t){return{x:this.x.dim(t.x),y:this.y.dim(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};i(c,"IDENTITY",new c);let f=c;const M=Object.freeze(Object.defineProperty({__proto__:null,Scale:y,XY:f,crudeXYTransform:q,transform:z},Symbol.toStringTag,{value:"Module"}));exports.clamp=B;exports.scale=M;
@@ -3,9 +3,9 @@ var R = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writab
3
3
  var i = (n, t, e) => R(n, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { z as y } from "zod";
5
5
  import { c as h } from "./bounds-BtccGJW0.js";
6
- import { e as T, f as x, y as f, c as E } from "./box-CfhGfJJH.js";
6
+ import { e as T, f as x, y as f, c as E } from "./box-Cto-5Uxu.js";
7
7
  import { b as I } from "./location-C5Ot4MVG.js";
8
- import { b as g, c as j } from "./xy-DQdccWlc.js";
8
+ import { b as g, c as j } from "./xy-DxjPL2DZ.js";
9
9
  const Y = (n, t, e) => t !== void 0 && n < t ? t : e !== void 0 && n > e ? e : n, z = y.object({ offset: g, scale: g }), D = y.object({ offset: y.number(), scale: y.number() }), L = (n) => (t, e, s, r) => e === "dimension" ? [t, s] : [
10
10
  t,
11
11
  r ? s - n : s + n
package/dist/scale.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-BESJN9LG.cjs");exports.scale=e.scale;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-BTgf0Mr-.cjs");exports.scale=e.scale;
package/dist/scale.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as e } from "./scale-CV3O6tkY.js";
1
+ import { s as e } from "./scale-Dh1UNRoC.js";
2
2
  export {
3
3
  e as scale
4
4
  };
@@ -0,0 +1,11 @@
1
+ "use strict";var tt=Object.defineProperty;var et=(o,t,e)=>t in o?tt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var s=(o,t,e)=>et(o,typeof t!="symbol"?t+"":t,e);const l=require("zod"),D=require("./index-CnclyYpG.cjs"),nt=require("./index-Dd8DLyMx.cjs"),rt=require("./index-BG3Scw3G.cjs"),w=require("./bounds-8aFLdbEj.cjs");require("./box-BZ6d2d5A.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-BIet4Mig.cjs");require("./scale-BTgf0Mr-.cjs");require("./xy-Budz-qz-.cjs");const st=require("./zodutil-DFJyyQd2.cjs");let it=(o,t=21)=>(e=t)=>{let n="",i=e|0;for(;i--;)n+=o[Math.random()*o.length|0];return n};const at="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",K=it(at,11),ut=Object.freeze(Object.defineProperty({__proto__:null,id:K},Symbol.toStringTag,{value:"Module"})),ot=l.z.enum(["static","dynamic"]),X=(o,t)=>{const e=new m(t);if(![O.DAY,O.HOUR,O.MINUTE,O.SECOND,O.MILLISECOND,O.MICROSECOND,O.NANOSECOND].some(i=>i.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=o.valueOf()%e.valueOf();return o instanceof m?new m(n):new O(n)},a=class a{constructor(t,e="UTC"){s(this,"value");s(this,"encodeValue",!0);if(t==null)this.value=a.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*a.MILLISECOND.valueOf();else if(typeof t=="string")this.value=a.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=a.parseDate(t);else{let n=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(n=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())+n}}static parseDate([t=1970,e=1,n=1]){const i=new Date(t,e-1,n,0,0,0,0);return new a(BigInt(i.getTime())*a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[n,i,f]=t.split(":");let h="00",p="00";f!=null&&([h,p]=f.split("."));let y=a.hours(parseInt(n??"00")).add(a.minutes(parseInt(i??"00"))).add(a.seconds(parseInt(h??"00"))).add(a.milliseconds(parseInt(p??"00")));return e==="local"&&(y=y.add(a.utcOffset)),y.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return a.parseTimeString(t,e);const n=new Date(t);return t.includes(":")||n.setUTCHours(0,0,0,0),new a(BigInt(n.getTime())*a.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(a.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const n=this.toISOString(e);return t?n.slice(11,23):n.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${e} ${n}`}static get utcOffset(){return new O(BigInt(new Date().getTimezoneOffset())*a.MINUTE.valueOf())}static since(t){return new a().span(t)}date(){return new Date(this.milliseconds)}equals(t){return this.valueOf()===new a(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(t){return this.valueOf()>new a(t).valueOf()}afterEq(t){return this.valueOf()>=new a(t).valueOf()}before(t){return this.valueOf()<new a(t).valueOf()}beforeEq(t){return this.valueOf()<=new a(t).valueOf()}add(t){return new a(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new a(this.valueOf()-BigInt(t.valueOf()))}get hours(){return Number(this.valueOf())/Number(O.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(O.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(O.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(O.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(a.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(t){const e=this.date();return e.setFullYear(t),new a(e)}get month(){return this.date().getMonth()}setMonth(t){const e=this.date();return e.setMonth(t),new a(e)}get day(){return this.date().getDate()}setDay(t){const e=this.date();return e.setDate(t),new a(e)}get hour(){return this.date().getHours()}setHour(t){const e=this.date();return e.setHours(t),new a(e)}get minute(){return this.date().getMinutes()}setMinute(t){const e=this.date();return e.setMinutes(t),new a(e)}get second(){return this.date().getSeconds()}setSecond(t){const e=this.date();return e.setSeconds(t),new a(e)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(t){const e=this.date();return e.setMilliseconds(t),new a(e)}toString(){return this.date().toISOString()}remainder(t){return X(this,t)}get isToday(){return this.truncate(O.DAY).equals(a.now().truncate(O.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new a(new Date)}static max(...t){let e=a.MIN;for(const n of t){const i=new a(n);i.after(e)&&(e=i)}return e}static min(...t){let e=a.MAX;for(const n of t){const i=new a(n);i.before(e)&&(e=i)}return e}static nanoseconds(t){return new a(t)}static microseconds(t){return a.nanoseconds(t*1e3)}static milliseconds(t){return a.microseconds(t*1e3)}static seconds(t){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};s(a,"NANOSECOND",a.nanoseconds(1)),s(a,"MICROSECOND",a.microseconds(1)),s(a,"MILLISECOND",a.milliseconds(1)),s(a,"SECOND",a.seconds(1)),s(a,"MINUTE",a.minutes(1)),s(a,"HOUR",a.hours(1)),s(a,"DAY",a.days(1)),s(a,"MAX",new a((1n<<63n)-1n)),s(a,"MIN",new a(0)),s(a,"ZERO",new a(0)),s(a,"z",l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new a(t.value)),l.z.string().transform(t=>new a(BigInt(t))),l.z.instanceof(Number).transform(t=>new a(t)),l.z.number().transform(t=>new a(t)),l.z.instanceof(a)]));let m=a;const u=class u{constructor(t){s(this,"value");s(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}static fromSeconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.seconds(t):new u(t)}static fromMilliseconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.milliseconds(t):new u(t)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new u(t).valueOf()}greaterThan(t){return this.valueOf()>new u(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new u(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new u(t).valueOf()}remainder(t){return X(this,t)}truncate(t){return new u(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(u.DAY),e=this.truncate(u.HOUR),n=this.truncate(u.MINUTE),i=this.truncate(u.SECOND),f=this.truncate(u.MILLISECOND),h=this.truncate(u.MICROSECOND),p=this.truncate(u.NANOSECOND),y=t,S=e.sub(t),A=n.sub(e),c=i.sub(n),R=f.sub(i),C=h.sub(f),Y=p.sub(h);let B="";return y.isZero||(B+=`${y.days}d `),S.isZero||(B+=`${S.hours}h `),A.isZero||(B+=`${A.minutes}m `),c.isZero||(B+=`${c.seconds}s `),R.isZero||(B+=`${R.milliseconds}ms `),C.isZero||(B+=`${C.microseconds}µs `),Y.isZero||(B+=`${Y.nanoseconds}ns`),B.trim()}mult(t){return new u(this.valueOf()*BigInt(t))}get days(){return Number(this.valueOf())/Number(u.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(u.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(u.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(u.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(u.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(u.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(t){return this.valueOf()===new u(t).valueOf()}add(t){return new u(this.valueOf()+new u(t).valueOf())}sub(t){return new u(this.valueOf()-new u(t).valueOf())}static nanoseconds(t=1){return new u(t)}static microseconds(t=1){return u.nanoseconds(w.mult(t,1e3))}static milliseconds(t=1){return u.microseconds(w.mult(t,1e3))}static seconds(t=1){return u.milliseconds(w.mult(t,1e3))}static minutes(t=1){return u.seconds(w.mult(t,60))}static hours(t){return u.minutes(w.mult(t,60))}static days(t){return u.hours(w.mult(t,24))}};s(u,"NANOSECOND",u.nanoseconds(1)),s(u,"MICROSECOND",u.microseconds(1)),s(u,"MILLISECOND",u.milliseconds(1)),s(u,"SECOND",u.seconds(1)),s(u,"MINUTE",u.minutes(1)),s(u,"HOUR",u.hours(1)),s(u,"DAY",u.days(1)),s(u,"MAX",new u((1n<<63n)-1n)),s(u,"MIN",new u(0)),s(u,"ZERO",new u(0)),s(u,"z",l.z.union([l.z.object({value:l.z.bigint()}).transform(t=>new u(t.value)),l.z.string().transform(t=>new u(BigInt(t))),l.z.instanceof(Number).transform(t=>new u(t)),l.z.number().transform(t=>new u(t)),l.z.instanceof(u)]));let O=u;const v=class v extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new v(t).valueOf()}get period(){return O.seconds(1/this.valueOf())}sampleCount(t){return new O(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return O.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new v(t)}static khz(t){return v.hz(t*1e3)}};s(v,"z",l.z.union([l.z.number().transform(t=>new v(t)),l.z.instanceof(Number).transform(t=>new v(t)),l.z.instanceof(v)]));let L=v;const b=class b extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new U(t*this.valueOf())}};s(b,"UNKNOWN",new b(0)),s(b,"BIT128",new b(16)),s(b,"BIT64",new b(8)),s(b,"BIT32",new b(4)),s(b,"BIT16",new b(2)),s(b,"BIT8",new b(1)),s(b,"z",l.z.union([l.z.number().transform(t=>new b(t)),l.z.instanceof(Number).transform(t=>new b(t)),l.z.instanceof(b)]));let I=b;const N=class N{constructor(t,e){s(this,"start");s(this,"end");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))}get span(){return new O(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new N(this.end,this.start)}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=O.ZERO){t=t.makeValid();const n=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(n.start)||n.end.equals(t.start))return!1;const i=m.max(n.start,t.start),f=m.min(n.end,t.end);return f.before(i)?!1:new O(f.sub(i)).greaterThanOrEqual(e)}roughlyEquals(t,e){let n=this.start.sub(t.start).valueOf(),i=this.end.sub(t.end).valueOf();return n<0&&(n=-n),i<0&&(i=-i),n<=e.valueOf()&&i<=e.valueOf()}contains(t){return t instanceof N?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new N(this.start,this.end);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}};s(N,"MAX",new N(m.MIN,m.MAX)),s(N,"MIN",new N(m.MAX,m.MIN)),s(N,"ZERO",new N(m.ZERO,m.ZERO)),s(N,"z",l.z.union([l.z.object({start:m.z,end:m.z}).transform(t=>new N(t.start,t.end)),l.z.instanceof(N)]));let M=N;const lt=(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,r=class r extends String{constructor(t){if(t instanceof r||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}const e=r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}throw super(r.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=r.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(e=>this.equals(e))}toString(){return this.valueOf()}get isVariable(){return this.equals(r.JSON)||this.equals(r.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(r.UUID)}get isInteger(){const t=this.toString();return t.startsWith("int")||t.startsWith("uint")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=r.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}get isUnsigned(){return this.equals(r.UINT8)||this.equals(r.UINT16)||this.equals(r.UINT32)||this.equals(r.UINT64)}get isSigned(){return this.equals(r.INT8)||this.equals(r.INT16)||this.equals(r.INT32)||this.equals(r.INT64)}canSafelyCastTo(t){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(r.INT32)&&t.equals(r.FLOAT64)||this.equals(r.INT8)&&t.equals(r.FLOAT32)?!0:this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf()&&this.isUnsigned===t.isUnsigned:!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return r.BIG_INT_TYPES.some(t=>t.equals(this))}};s(r,"UNKNOWN",new r("unknown")),s(r,"FLOAT64",new r("float64")),s(r,"FLOAT32",new r("float32")),s(r,"INT64",new r("int64")),s(r,"INT32",new r("int32")),s(r,"INT16",new r("int16")),s(r,"INT8",new r("int8")),s(r,"UINT64",new r("uint64")),s(r,"UINT32",new r("uint32")),s(r,"UINT16",new r("uint16")),s(r,"UINT8",new r("uint8")),s(r,"BOOLEAN",r.UINT8),s(r,"TIMESTAMP",new r("timestamp")),s(r,"UUID",new r("uuid")),s(r,"STRING",new r("string")),s(r,"JSON",new r("json")),s(r,"ARRAY_CONSTRUCTORS",new Map([[r.UINT8.toString(),Uint8Array],[r.UINT16.toString(),Uint16Array],[r.UINT32.toString(),Uint32Array],[r.UINT64.toString(),BigUint64Array],[r.FLOAT32.toString(),Float32Array],[r.FLOAT64.toString(),Float64Array],[r.INT8.toString(),Int8Array],[r.INT16.toString(),Int16Array],[r.INT32.toString(),Int32Array],[r.INT64.toString(),BigInt64Array],[r.TIMESTAMP.toString(),BigInt64Array],[r.STRING.toString(),Uint8Array],[r.JSON.toString(),Uint8Array],[r.UUID.toString(),Uint8Array]])),s(r,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,r.UINT8],[Uint16Array.name,r.UINT16],[Uint32Array.name,r.UINT32],[BigUint64Array.name,r.UINT64],[Float32Array.name,r.FLOAT32],[Float64Array.name,r.FLOAT64],[Int8Array.name,r.INT8],[Int16Array.name,r.INT16],[Int32Array.name,r.INT32],[BigInt64Array.name,r.INT64]])),s(r,"DENSITIES",new Map([[r.UINT8.toString(),I.BIT8],[r.UINT16.toString(),I.BIT16],[r.UINT32.toString(),I.BIT32],[r.UINT64.toString(),I.BIT64],[r.FLOAT32.toString(),I.BIT32],[r.FLOAT64.toString(),I.BIT64],[r.INT8.toString(),I.BIT8],[r.INT16.toString(),I.BIT16],[r.INT32.toString(),I.BIT32],[r.INT64.toString(),I.BIT64],[r.TIMESTAMP.toString(),I.BIT64],[r.STRING.toString(),I.UNKNOWN],[r.JSON.toString(),I.UNKNOWN],[r.UUID.toString(),I.BIT128]])),s(r,"ALL",[r.UNKNOWN,r.FLOAT64,r.FLOAT32,r.INT64,r.INT32,r.INT16,r.INT8,r.UINT64,r.UINT32,r.UINT16,r.UINT8,r.TIMESTAMP,r.UUID,r.STRING,r.JSON]),s(r,"BIG_INT_TYPES",[r.INT64,r.UINT64,r.TIMESTAMP]),s(r,"z",l.z.union([l.z.string().transform(t=>new r(t)),l.z.instanceof(r)]));let g=r;const d=class d extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return d.bytes(this.valueOf()+t.valueOf())}sub(t){return d.bytes(this.valueOf()-t.valueOf())}truncate(t){return new d(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return d.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/d.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/d.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/d.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/d.TERABYTE.valueOf()}toString(){const t=this.truncate(d.TERABYTE),e=this.truncate(d.GIGABYTE),n=this.truncate(d.MEGABYTE),i=this.truncate(d.KILOBYTE),f=this.truncate(d.BYTE),h=t,p=e.sub(t),y=n.sub(e),S=i.sub(n),A=f.sub(i);let c="";return h.isZero||(c+=`${h.terabytes}TB `),p.isZero||(c+=`${p.gigabytes}GB `),y.isZero||(c+=`${y.megabytes}MB `),S.isZero||(c+=`${S.kilobytes}KB `),(!A.isZero||c==="")&&(c+=`${A.valueOf()}B`),c.trim()}static bytes(t=1){return new d(t)}static kilobytes(t=1){return d.bytes(t.valueOf()*1e3)}static megabytes(t=1){return d.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return d.megabytes(t.valueOf()*1e3)}static terabytes(t){return d.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};s(d,"BYTE",new d(1)),s(d,"KILOBYTE",d.kilobytes(1)),s(d,"MEGABYTE",d.megabytes(1)),s(d,"GIGABYTE",d.gigabytes(1)),s(d,"TERABYTE",d.terabytes(1)),s(d,"ZERO",new d(0)),s(d,"z",l.z.union([l.z.number().transform(t=>new d(t)),l.z.instanceof(d)]));let U=d;const ft=l.z.union([l.z.instanceof(Uint8Array),l.z.instanceof(Uint16Array),l.z.instanceof(Uint32Array),l.z.instanceof(BigUint64Array),l.z.instanceof(Float32Array),l.z.instanceof(Float64Array),l.z.instanceof(Int8Array),l.z.instanceof(Int16Array),l.z.instanceof(Int32Array),l.z.instanceof(BigInt64Array)]),P=o=>{const t=typeof o;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||o instanceof m||o instanceof O||o instanceof Date},Q=(o,t,e,n=0)=>o.usesBigInt&&!t.usesBigInt?Number(e)-Number(n):!o.usesBigInt&&t.usesBigInt?BigInt(e.valueOf())-BigInt(n.valueOf()):x(e,-n).valueOf(),_=o=>o==null?!1:Array.isArray(o)||o instanceof ArrayBuffer||ArrayBuffer.isView(o)&&!(o instanceof DataView)||o instanceof q?!0:P(o),E=-1,$={[Symbol.iterator]:()=>$,next:()=>({done:!0,value:void 0})},ct=l.z.string().transform(o=>new Uint8Array(atob(o).split("").map(t=>t.charCodeAt(0))).buffer),ht=l.z.union([l.z.null(),l.z.undefined()]).transform(()=>new Uint8Array().buffer),F=10,T=class T{constructor(t){s(this,"key","");s(this,"isSynnaxSeries",!0);s(this,"dataType");s(this,"sampleOffset");s(this,"gl");s(this,"_data");s(this,"_timeRange");s(this,"alignment",0n);s(this,"_cachedMin");s(this,"_cachedMax");s(this,"writePos",E);s(this,"_refCount",0);s(this,"_cachedLength");s(this,"_cachedIndexes");_(t)&&(t={data:t});const{dataType:e,timeRange:n,sampleOffset:i=0,glBufferUsage:f="static",alignment:h=0n,key:p=K()}=t,y=t.data??[];if(y instanceof T||typeof y=="object"&&"isSynnaxSeries"in y&&y.isSynnaxSeries===!0){const c=y;this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this._timeRange=c._timeRange,this.alignment=c.alignment,this._cachedMin=c._cachedMin,this._cachedMax=c._cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this._cachedLength=c._cachedLength;return}const S=P(y),A=Array.isArray(y);if(e!=null)this.dataType=new g(e);else{if(y instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(A||S){let c=y;if(!S){if(y.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");c=y[0]}if(typeof c=="string")this.dataType=g.STRING;else if(typeof c=="number")this.dataType=g.FLOAT64;else if(typeof c=="bigint")this.dataType=g.INT64;else if(typeof c=="boolean")this.dataType=g.BOOLEAN;else if(c instanceof m||c instanceof Date||c instanceof m)this.dataType=g.TIMESTAMP;else if(typeof c=="object")this.dataType=g.JSON;else throw new Error(`cannot infer data type of ${typeof c} when constructing a Series from a JS array`)}else this.dataType=new g(y)}if(!A&&!S)this._data=y;else{let c=S?[y]:y;const R=c[0];(R instanceof m||R instanceof Date||R instanceof O)&&(c=c.map(C=>new m(C).valueOf())),this.dataType.equals(g.STRING)?(this._cachedLength=c.length,this._data=new TextEncoder().encode(`${c.join(`
2
+ `)}
3
+ `).buffer):this.dataType.equals(g.JSON)?(this._cachedLength=c.length,this._data=new TextEncoder().encode(`${c.map(C=>D.JSON_CODEC.encodeString(C)).join(`
4
+ `)}
5
+ `).buffer):this._data=new this.dataType.Array(c).buffer}this.key=p,this.alignment=h,this.sampleOffset=i??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:f}}static alloc({capacity:t,dataType:e,...n}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new g(e).Array(t),f=new T({data:i.buffer,dataType:e,...n});return f.writePos=0,f}static generateTimestamps(t,e,n){const i=n.spanRange(e.span(t)),f=new BigInt64Array(t);for(let h=0;h<t;h++)f[h]=BigInt(n.add(e.span(h)).valueOf());return new T({data:f,dataType:g.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(t,e){const n=new TextEncoder().encode(`${t.join(`
6
+ `)}
7
+ `);return new T({data:n,dataType:g.STRING,timeRange:e})}static fromJSON(t,e){const n=new TextEncoder().encode(`${t.map(i=>D.JSON_CODEC.encodeString(i)).join(`
8
+ `)}
9
+ `);return new T({data:n,dataType:g.JSON,timeRange:e})}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(t):this.writeFixed(t)}writeVariable(t){if(this.writePos===E)return 0;const e=this.byteCapacity.valueOf()-this.writePos,n=t.subBytes(0,e);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(t){if(this.writePos===E)return 0;const e=this.capacity-this.writePos,n=t.sub(0,e);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(t){this.underlyingData.set(t.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===E?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(g.STRING,g.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
10
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(g.UUID))throw new Error("cannot convert non-uuid series to uuids");const t=g.UUID.density.valueOf(),e=Array(this.length);for(let n=0;n<this.length;n++){const i=this.underlyingData.slice(n*t,(n+1)*t),f=Array.from(new Uint8Array(i.buffer),h=>h.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");e[n]=f}return e}parseJSON(t){if(!this.dataType.equals(g.JSON))throw new Error("cannot parse non-JSON series as JSON");return new TextDecoder().decode(this.underlyingData).split(`
11
+ `).slice(0,-1).map(e=>t.parse(D.JSON_CODEC.decodeString(e)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new U(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity:this.dataType.isVariable?new U(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===E?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const e=[0];return this.data.forEach((n,i)=>{n===F&&(t++,e.push(i+1))}),this._cachedIndexes=e,this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const n=new t.Array(this.length);for(let i=0;i<this.length;i++)n[i]=Q(this.dataType,t,this.data[i],e);return new T({data:n.buffer,dataType:t,timeRange:this._timeRange,sampleOffset:e,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}else{const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax??(this._cachedMax=this.calcRawMax()),x(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}else{const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin??(this._cachedMin=this.calcRawMin()),x(this._cachedMin,this.sampleOffset))}get bounds(){return w.construct(Number(this.min),Number(this.max))}maybeRecomputeMinMax(t){if(this._cachedMin!=null){const e=t._cachedMin??t.calcRawMin();e<this._cachedMin&&(this._cachedMin=e)}if(this._cachedMax!=null){const e=t._cachedMax??t.calcRawMax();e>this._cachedMax&&(this._cachedMax=e)}}enrich(){this.max,this.min}get range(){return x(this.max,-this.min)}atAlignment(t,e){const n=Number(t-this.alignment);if(n<0||n>=this.length){if(e===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,e)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const n=this.data[t];if(n==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return x(n,this.sampleOffset)}atVariable(t,e){let n=0,i=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[t],i=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let h=0;h<this.data.length;h++)if(this.data[h]===F){if(t===0){i=h;break}n=h+1,t--}if(i===0&&(i=this.data.length),n>=i||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}}const f=this.data.slice(n,i);return this.dataType.equals(g.STRING)?new TextDecoder().decode(f):nt.snakeToCamel(JSON.parse(new TextDecoder().decode(f)))}binarySearch(t){let e=0,n=this.length-1;const i=rt.newF(t);for(;e<=n;){const f=Math.floor((e+n)/2),h=i(this.at(f,!0),t);if(h===0)return f;h<0?e=f+1:n=f-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(g.FLOAT32)&&!this.dataType.equals(g.UINT8))throw new Error("Only FLOAT32 and UINT8 arrays can be used in WebGL");const{buffer:e,bufferUsage:n,prevBuffer:i}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==i)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==E){i===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const f=this.dataType.density.size(i).valueOf(),h=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,f,h.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,n==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=E}as(t){if(t==="string"){if(!this.dataType.equals(g.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(t==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(t==="bigint"){if(!this.dataType.equals(g.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${t}`)}get digest(){var t;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:k(this.alignmentBounds.lower),upper:k(this.alignmentBounds.upper)},timeRange:(t=this._timeRange)==null?void 0:t.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return w.construct(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new dt(this);return this.dataType.equals(g.JSON)?new gt(t):t}return new mt(this)}slice(t,e){return this.sliceSub(!1,t,e)}sub(t,e){return this.sliceSub(!0,t,e)}subIterator(t,e){return new Z(this,t,e??this.length)}subAlignmentIterator(t,e){return new Z(this,Number(t-this.alignment),Number(e-this.alignment))}subBytes(t,e){if(t>=0&&(e==null||e>=this.byteLength.valueOf()))return this;const n=this.data.subarray(t,e);return new T({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,e,n){if(e<=0&&(n==null||n>=this.length))return this;let i;return t?i=this.data.subarray(e,n):i=this.data.slice(e,n),new T({data:i,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(t){return new T({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}};s(T,"crudeZ",l.z.object({timeRange:M.z.optional(),dataType:g.z,alignment:st.bigInt.optional(),data:l.z.union([ct,ht,l.z.instanceof(ArrayBuffer),l.z.instanceof(Uint8Array)]),glBufferUsage:ot.optional().default("static").optional()})),s(T,"z",T.crudeZ.transform(t=>new T(t)));let q=T;class Z{constructor(t,e,n){s(this,"series");s(this,"end");s(this,"index");this.series=t;const i=w.construct(0,t.length);this.end=w.clamp(i,n),this.index=w.clamp(i,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class dt{constructor(t){s(this,"series");s(this,"index");s(this,"decoder");if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==F;)this.index++;const n=this.index;return t===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,n))})}[Symbol.iterator](){return this}}var G,V;class gt{constructor(t){s(this,"wrapped");s(this,G,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:D.JSON_CODEC.decodeString(t.value)}}[(V=Symbol.iterator,G=Symbol.toStringTag,V)](){return this}}var J,W;class mt{constructor(t){s(this,"series");s(this,"index");s(this,J,"SeriesIterator");this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(W=Symbol.iterator,J=Symbol.toStringTag,W)](){return this}}const x=(o,t)=>typeof o=="bigint"&&typeof t=="bigint"||typeof o=="number"&&typeof t=="number"?o+t:t===0?o:o===0?t:Number(o)+Number(t);class Ot{constructor(t){s(this,"series");if(t.length!==0){const e=t[0].dataType;for(let n=1;n<t.length;n++)if(!t[n].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){if(!new g(t).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`);return this}get dataType(){return this.series.length===0?g.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?w.construct(0n,0n):w.construct(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){this.series.push(t)}get length(){return this.series.reduce((t,e)=>t+e.length,0)}atAlignment(t,e){if(this.series.length===0){if(e)throw new Error(`[series] - no value at alignment ${t}`);return}for(const n of this.series)if(w.contains(n.alignmentBounds,t))return n.atAlignment(t,e);if(e)throw new Error(`[series] - no value at alignment ${t}`)}at(t,e=!1){t<0&&(t=this.length+t);for(const n of this.series){if(t<n.length)return n.at(t,e);t-=n.length}if(e)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,e){return new z(this,t,e??this.length)}subAlignmentIterator(t,e){if(t>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return $;let n=0;for(let f=0;f<this.series.length;f++){const h=this.series[f];if(t<h.alignment)break;if(t>=h.alignmentBounds.upper)n+=h.length;else if(w.contains(h.alignmentBounds,t)){n+=Number(t-h.alignment);break}}let i=0;for(let f=0;f<this.series.length;f++){const h=this.series[f];if(e<h.alignment)break;if(e>=h.alignmentBounds.upper)i+=h.length;else if(w.contains(h.alignmentBounds,e)){i+=Number(e-h.alignment);break}}return new z(this,n,i)}subAlignmentSpanIterator(t,e){if(t>=this.alignmentBounds.upper)return $;let n=0;for(let i=0;i<this.series.length;i++){const f=this.series[i];if(t<f.alignment)break;if(t>=f.alignmentBounds.upper)n+=f.length;else if(w.contains(f.alignmentBounds,t)){n+=Number(t-f.alignment);break}}return new z(this,n,n+e)}get byteLength(){return new U(this.series.reduce((t,e)=>t+e.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let e=0;for(const n of this.series)t.set(n.data,e),e+=n.length;return new this.dataType.Array(t.buffer)}traverseAlignment(t,e){const n=this.series.map(i=>i.alignmentBounds);return w.traverse(n,t,e)}distance(t,e){const n=this.series.map(i=>i.alignmentBounds);return w.distance(n,t,e)}parseJSON(t){if(!this.dataType.equals(g.JSON))throw new Error("cannot parse non-JSON series as JSON");return this.series.flatMap(e=>e.parseJSON(t))}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new yt(this.series)}}var j,H;class yt{constructor(t){s(this,"series");s(this,"seriesIndex");s(this,"internal");s(this,j,"MultiSeriesIterator");this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();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())}[(H=Symbol.iterator,j=Symbol.toStringTag,H)](){return this}}class z{constructor(t,e,n){s(this,"series");s(this,"index");s(this,"end");this.series=t,this.end=n,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}const k=o=>{const t=o>>32n,e=o&0xffffffffn;return{domain:t,sample:e}};exports.DataType=g;exports.Density=I;exports.MultiSeries=Ot;exports.Rate=L;exports.Series=q;exports.Size=U;exports.TimeRange=M;exports.TimeSpan=O;exports.TimeStamp=m;exports.addSamples=x;exports.convertDataType=Q;exports.id=ut;exports.isCrudeSeries=_;exports.isTelemValue=P;exports.sortTimeRange=lt;exports.typedArrayZ=ft;