@synnaxlabs/x 0.34.0 → 0.36.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 (118) hide show
  1. package/.turbo/turbo-build.log +30 -30
  2. package/dist/bounds-8aFLdbEj.cjs +1 -0
  3. package/dist/{bounds-CFI9wDXn.js → bounds-BtccGJW0.js} +22 -18
  4. package/dist/bounds.cjs +1 -1
  5. package/dist/bounds.js +1 -1
  6. package/dist/{box-Mf8E1Ypp.cjs → box-BpSX4si6.cjs} +1 -1
  7. package/dist/{box-DVCNGsJG.js → box-CYXc9-qp.js} +2 -2
  8. package/dist/box.cjs +1 -1
  9. package/dist/box.js +1 -1
  10. package/dist/deep.cjs +1 -1
  11. package/dist/deep.js +1 -1
  12. package/dist/index.cjs +2 -2
  13. package/dist/index.js +169 -151
  14. package/dist/location-Cn1ByVTZ.js +95 -0
  15. package/dist/location-DLP2ZS0o.cjs +1 -0
  16. package/dist/location.cjs +1 -1
  17. package/dist/location.js +1 -1
  18. package/dist/path-1tZLZ4AN.cjs +1 -0
  19. package/dist/path-DD6ytXzr.js +76 -0
  20. package/dist/{position-CFc9RsSn.js → position-DJXB-pDS.js} +2 -2
  21. package/dist/{position-DKhPhvPh.cjs → position-JCN6-sJC.cjs} +1 -1
  22. package/dist/position.cjs +1 -1
  23. package/dist/position.js +1 -1
  24. package/dist/record.cjs +1 -1
  25. package/dist/record.js +5 -4
  26. package/dist/scale-BI4wJF3b.cjs +1 -0
  27. package/dist/{scale-DNQE1LMm.js → scale-rZ1YKDFy.js} +70 -67
  28. package/dist/scale.cjs +1 -1
  29. package/dist/scale.js +1 -1
  30. package/dist/series-BN9CILsQ.cjs +11 -0
  31. package/dist/{series-sjWkW8qe.js → series-CnEQe1dh.js} +473 -370
  32. package/dist/spatial.cjs +1 -1
  33. package/dist/spatial.js +6 -6
  34. package/dist/src/breaker/breaker.d.ts +33 -0
  35. package/dist/src/breaker/breaker.d.ts.map +1 -0
  36. package/dist/src/breaker/breaker.spec.d.ts +2 -0
  37. package/dist/src/breaker/breaker.spec.d.ts.map +1 -0
  38. package/dist/src/breaker/index.d.ts +2 -0
  39. package/dist/src/breaker/index.d.ts.map +1 -0
  40. package/dist/src/change/change.d.ts +5 -5
  41. package/dist/src/change/change.d.ts.map +1 -1
  42. package/dist/src/control/control.d.ts +5 -5
  43. package/dist/src/control/control.d.ts.map +1 -1
  44. package/dist/src/deep/path.d.ts.map +1 -1
  45. package/dist/src/index.d.ts +1 -0
  46. package/dist/src/index.d.ts.map +1 -1
  47. package/dist/src/mock/MockGLBufferController.d.ts +2 -2
  48. package/dist/src/mock/MockGLBufferController.d.ts.map +1 -1
  49. package/dist/src/record.d.ts +1 -0
  50. package/dist/src/record.d.ts.map +1 -1
  51. package/dist/src/record.spec.d.ts +2 -0
  52. package/dist/src/record.spec.d.ts.map +1 -0
  53. package/dist/src/sleep/index.d.ts +2 -0
  54. package/dist/src/sleep/index.d.ts.map +1 -0
  55. package/dist/src/sleep/sleep.d.ts +3 -0
  56. package/dist/src/sleep/sleep.d.ts.map +1 -0
  57. package/dist/src/spatial/bounds/bounds.d.ts +12 -0
  58. package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
  59. package/dist/src/spatial/location/location.d.ts +1 -0
  60. package/dist/src/spatial/location/location.d.ts.map +1 -1
  61. package/dist/src/spatial/scale/scale.d.ts +17 -1
  62. package/dist/src/spatial/scale/scale.d.ts.map +1 -1
  63. package/dist/src/spatial/xy/xy.d.ts +36 -1
  64. package/dist/src/spatial/xy/xy.d.ts.map +1 -1
  65. package/dist/src/telem/gl.d.ts +2 -2
  66. package/dist/src/telem/gl.d.ts.map +1 -1
  67. package/dist/src/telem/series.d.ts +16 -9
  68. package/dist/src/telem/series.d.ts.map +1 -1
  69. package/dist/src/telem/telem.d.ts +43 -2
  70. package/dist/src/telem/telem.d.ts.map +1 -1
  71. package/dist/src/zodutil/zodutil.d.ts.map +1 -1
  72. package/dist/telem.cjs +1 -1
  73. package/dist/telem.js +11 -10
  74. package/dist/xy-DQdccWlc.js +128 -0
  75. package/dist/xy-LADI2wVU.cjs +1 -0
  76. package/dist/xy.cjs +1 -1
  77. package/dist/xy.js +1 -1
  78. package/dist/zodutil-BRjUdYAv.cjs +1 -0
  79. package/dist/{zodutil-Tmuc4CNq.js → zodutil-DI4gVZkT.js} +11 -11
  80. package/dist/zodutil.cjs +1 -1
  81. package/dist/zodutil.js +1 -1
  82. package/package.json +64 -65
  83. package/src/binary/encoder.ts +3 -3
  84. package/src/breaker/breaker.spec.ts +74 -0
  85. package/src/breaker/breaker.ts +32 -0
  86. package/src/breaker/index.ts +1 -0
  87. package/src/deep/path.ts +6 -1
  88. package/src/index.ts +1 -0
  89. package/src/mock/MockGLBufferController.ts +6 -6
  90. package/src/record.spec.ts +29 -0
  91. package/src/record.ts +6 -0
  92. package/src/sleep/index.ts +1 -0
  93. package/src/sleep/sleep.ts +6 -0
  94. package/src/spatial/bounds/bounds.spec.ts +6 -0
  95. package/src/spatial/bounds/bounds.ts +16 -0
  96. package/src/spatial/location/location.ts +1 -0
  97. package/src/spatial/scale/scale.spec.ts +62 -51
  98. package/src/spatial/scale/scale.ts +21 -12
  99. package/src/spatial/xy/xy.spec.ts +22 -1
  100. package/src/spatial/xy/xy.ts +101 -5
  101. package/src/strings/strings.spec.ts +0 -4
  102. package/src/telem/gl.ts +6 -2
  103. package/src/telem/series.spec.ts +3 -3
  104. package/src/telem/series.ts +45 -16
  105. package/src/telem/telem.ts +121 -2
  106. package/src/zodutil/zodutil.ts +4 -1
  107. package/tsconfig.json +1 -1
  108. package/tsconfig.tsbuildinfo +1 -1
  109. package/dist/bounds-DzCDHgdE.cjs +0 -1
  110. package/dist/location-CI9x53qR.js +0 -94
  111. package/dist/location-DetomF8Z.cjs +0 -1
  112. package/dist/path-BBCx3K6k.cjs +0 -1
  113. package/dist/path-CmnoH3RC.js +0 -72
  114. package/dist/scale-CT61XD_X.cjs +0 -1
  115. package/dist/series-DWLXo7J6.cjs +0 -11
  116. package/dist/xy-CrgPnICw.js +0 -89
  117. package/dist/xy-cP-FXJtR.cjs +0 -1
  118. package/dist/zodutil-C6RYzvXd.cjs +0 -1
@@ -0,0 +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-BpSX4si6.cjs"),T=require("./location-DLP2ZS0o.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,31 +1,31 @@
1
- var g = Object.defineProperty;
2
- var B = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var i = (r, t, e) => B(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { z as R } from "zod";
5
- import { c as l } from "./bounds-CFI9wDXn.js";
6
- import { e as T, f as x, y as h, c as E } from "./box-DVCNGsJG.js";
7
- import { b as I } from "./location-CI9x53qR.js";
8
- import { b as w, c as Y } from "./xy-CrgPnICw.js";
9
- const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r, z = R.object({ offset: w, scale: w }), D = (r) => (t, e, s, n) => e === "dimension" ? [t, s] : [
1
+ var B = Object.defineProperty;
2
+ var R = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var i = (n, t, e) => R(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { z as y } from "zod";
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-CYXc9-qp.js";
7
+ import { b as I } from "./location-Cn1ByVTZ.js";
8
+ import { b as g, c as j } from "./xy-DQdccWlc.js";
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
- n ? s - r : s + r
12
- ], L = (r) => (t, e, s, n) => [
11
+ r ? s - n : s + n
12
+ ], M = (n) => (t, e, s, r) => [
13
13
  t,
14
- n ? s / r : s * r
15
- ], M = (r) => (t, e, s) => {
16
- if (t === null) return [r, s];
17
- const { lower: n, upper: o } = t, { lower: a, upper: p } = r, d = o - n, m = p - a;
18
- if (e === "dimension") return [r, s * (m / d)];
19
- const v = (s - n) * (m / d) + a;
20
- return [r, v];
21
- }, N = (r) => (t, e, s) => [r, s], O = () => (r, t, e) => {
22
- if (r === null) throw new Error("cannot invert without bounds");
23
- if (t === "dimension") return [r, e];
24
- const { lower: s, upper: n } = r;
25
- return [r, n - (e - s)];
26
- }, U = (r) => (t, e, s) => {
27
- const { lower: n, upper: o } = r;
28
- return s = j(s, n, o), [t, s];
14
+ r ? s / n : s * n
15
+ ], N = (n) => (t, e, s) => {
16
+ if (t === null) return [n, s];
17
+ const { lower: r, upper: o } = t, { lower: a, upper: p } = n, m = o - r, w = p - a;
18
+ if (e === "dimension") return [n, s * (w / m)];
19
+ const v = (s - r) * (w / m) + a;
20
+ return [n, v];
21
+ }, O = (n) => (t, e, s) => [n, s], U = () => (n, t, e) => {
22
+ if (n === null) throw new Error("cannot invert without bounds");
23
+ if (t === "dimension") return [n, e];
24
+ const { lower: s, upper: r } = n;
25
+ return [n, r - (e - s)];
26
+ }, X = (n) => (t, e, s) => {
27
+ const { lower: r, upper: o } = n;
28
+ return s = Y(s, r, o), [t, s];
29
29
  }, u = class u {
30
30
  constructor() {
31
31
  i(this, "ops", []);
@@ -60,7 +60,7 @@ const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r
60
60
  * @param value - The amount to translate by.
61
61
  */
62
62
  translate(t) {
63
- const e = this.new(), s = D(t);
63
+ const e = this.new(), s = L(t);
64
64
  return s.type = "translate", e.ops.push(s), e;
65
65
  }
66
66
  /**
@@ -70,23 +70,23 @@ const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r
70
70
  * @param value - The amount to magnify by.
71
71
  */
72
72
  magnify(t) {
73
- const e = this.new(), s = L(t);
73
+ const e = this.new(), s = M(t);
74
74
  return s.type = "magnify", e.ops.push(s), e;
75
75
  }
76
76
  scale(t, e) {
77
- const s = l(t, e), n = this.new(), o = M(s);
78
- return o.type = "scale", n.ops.push(o), n;
77
+ const s = h(t, e), r = this.new(), o = N(s);
78
+ return o.type = "scale", r.ops.push(o), r;
79
79
  }
80
80
  clamp(t, e) {
81
- const s = l(t, e), n = this.new(), o = U(s);
82
- return o.type = "clamp", n.ops.push(o), n;
81
+ const s = h(t, e), r = this.new(), o = X(s);
82
+ return o.type = "clamp", r.ops.push(o), r;
83
83
  }
84
84
  reBound(t, e) {
85
- const s = l(t, e), n = this.new(), o = N(s);
86
- return o.type = "re-bound", n.ops.push(o), n;
85
+ const s = h(t, e), r = this.new(), o = O(s);
86
+ return o.type = "re-bound", r.ops.push(o), r;
87
87
  }
88
88
  invert() {
89
- const t = O();
89
+ const t = U();
90
90
  t.type = "invert";
91
91
  const e = this.new();
92
92
  return e.ops.push(t), e;
@@ -103,7 +103,7 @@ const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r
103
103
  }
104
104
  exec(t, e) {
105
105
  return this.currBounds = null, this.ops.reduce(
106
- ([s, n], o) => o(s, t, n, this.reversed),
106
+ ([s, r], o) => o(s, t, r, this.reversed),
107
107
  [null, e]
108
108
  )[1];
109
109
  }
@@ -111,30 +111,24 @@ const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r
111
111
  const t = this.new();
112
112
  t.ops.reverse();
113
113
  const e = [];
114
- return t.ops.forEach((s, n) => {
115
- if (s.type === "scale" || e.some(([a, p]) => n >= a && n <= p))
114
+ return t.ops.forEach((s, r) => {
115
+ if (s.type === "scale" || e.some(([a, p]) => r >= a && r <= p))
116
116
  return;
117
- const o = t.ops.findIndex((a, p) => a.type === "scale" && p > n);
118
- o !== -1 && e.push([n, o]);
119
- }), e.forEach(([s, n]) => {
120
- const o = t.ops.slice(s, n);
121
- o.unshift(t.ops[n]), t.ops.splice(s, n - s + 1, ...o);
117
+ const o = t.ops.findIndex((a, p) => a.type === "scale" && p > r);
118
+ o !== -1 && e.push([r, o]);
119
+ }), e.forEach(([s, r]) => {
120
+ const o = t.ops.slice(s, r);
121
+ o.unshift(t.ops[r]), t.ops.splice(s, r - s + 1, ...o);
122
122
  }), t.reversed = !t.reversed, t;
123
123
  }
124
+ get transform() {
125
+ return { scale: this.dim(1), offset: this.pos(0) };
126
+ }
124
127
  };
125
128
  i(u, "IDENTITY", new u());
126
- let y = u;
127
- const X = (r) => ({
128
- scale: {
129
- x: r.x.dim(1),
130
- y: r.y.dim(1)
131
- },
132
- offset: {
133
- x: r.x.pos(0),
134
- y: r.y.pos(0)
135
- }
136
- }), c = class c {
137
- constructor(t = new y(), e = new y(), s = null) {
129
+ let l = u;
130
+ const c = class c {
131
+ constructor(t = new l(), e = new l(), s = null) {
138
132
  i(this, "x");
139
133
  i(this, "y");
140
134
  i(this, "currRoot");
@@ -162,8 +156,8 @@ const X = (r) => ({
162
156
  return new c().reBound(t);
163
157
  }
164
158
  translate(t, e) {
165
- const s = Y(t, e), n = this.copy();
166
- return n.x = this.x.translate(s.x), n.y = this.y.translate(s.y), n;
159
+ const s = j(t, e), r = this.copy();
160
+ return r.x = this.x.translate(s.x), r.y = this.y.translate(s.y), r;
167
161
  }
168
162
  translateX(t) {
169
163
  const e = this.copy();
@@ -181,17 +175,17 @@ const X = (r) => ({
181
175
  const e = this.copy();
182
176
  if (T(t)) {
183
177
  const s = this.currRoot;
184
- return e.currRoot = t.root, s != null && !I(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(x(t)), e.y = e.y.scale(h(t)), e;
178
+ return e.currRoot = t.root, s != null && !I(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(x(t)), e.y = e.y.scale(f(t)), e;
185
179
  }
186
180
  return e.x = e.x.scale(t.width), e.y = e.y.scale(t.height), e;
187
181
  }
188
182
  reBound(t) {
189
183
  const e = this.copy();
190
- return e.x = this.x.reBound(x(t)), e.y = this.y.reBound(h(t)), e;
184
+ return e.x = this.x.reBound(x(t)), e.y = this.y.reBound(f(t)), e;
191
185
  }
192
186
  clamp(t) {
193
187
  const e = this.copy();
194
- return e.x = this.x.clamp(x(t)), e.y = this.y.clamp(h(t)), e;
188
+ return e.x = this.x.clamp(x(t)), e.y = this.y.clamp(f(t)), e;
195
189
  }
196
190
  copy() {
197
191
  const t = new c();
@@ -204,6 +198,9 @@ const X = (r) => ({
204
198
  pos(t) {
205
199
  return { x: this.x.pos(t.x), y: this.y.pos(t.y) };
206
200
  }
201
+ dim(t) {
202
+ return { x: this.x.dim(t.x), y: this.y.dim(t.y) };
203
+ }
207
204
  box(t) {
208
205
  return E(
209
206
  this.pos(t.one),
@@ -213,17 +210,23 @@ const X = (r) => ({
213
210
  this.currRoot ?? t.root
214
211
  );
215
212
  }
213
+ get transform() {
214
+ return {
215
+ scale: this.dim({ x: 1, y: 1 }),
216
+ offset: this.pos({ x: 0, y: 0 })
217
+ };
218
+ }
216
219
  };
217
220
  i(c, "IDENTITY", new c());
218
- let f = c;
219
- const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
221
+ let d = c;
222
+ const b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
220
223
  __proto__: null,
221
- Scale: y,
222
- XY: f,
224
+ Scale: l,
225
+ XY: d,
223
226
  crudeXYTransform: z,
224
- xyScaleToTransform: X
227
+ transform: D
225
228
  }, Symbol.toStringTag, { value: "Module" }));
226
229
  export {
227
- j as c,
228
- k as s
230
+ Y as c,
231
+ b as s
229
232
  };
package/dist/scale.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-CT61XD_X.cjs");exports.scale=e.scale;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-BI4wJF3b.cjs");exports.scale=e.scale;
package/dist/scale.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as e } from "./scale-DNQE1LMm.js";
1
+ import { s as e } from "./scale-rZ1YKDFy.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"),L=require("./index-CYxQwEdX.cjs"),rt=require("./index-YsO0EMN8.cjs"),nt=require("./index-h-QAL9T1.cjs"),w=require("./bounds-8aFLdbEj.cjs");require("./box-BpSX4si6.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-DLP2ZS0o.cjs");require("./scale-BI4wJF3b.cjs");require("./xy-LADI2wVU.cjs");const st=require("./zodutil-BRjUdYAv.cjs");let it=(o,t=21)=>(e=t)=>{let r="",i=e;for(;i--;)r+=o[Math.random()*o.length|0];return r};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 r=o.valueOf()%e.valueOf();return o instanceof m?new m(r):new O(r)},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 r=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(r=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())+r}}static parseDate([t=1970,e=1,r=1]){const i=new Date(t,e-1,r,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[r,i,c]=t.split(":");let h="00",v="00";c!=null&&([h,v]=c.split("."));let y=a.hours(parseInt(r??"00")).add(a.minutes(parseInt(i??"00"))).add(a.seconds(parseInt(h??"00"))).add(a.milliseconds(parseInt(v??"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 r=new Date(t);return t.includes(":")||r.setUTCHours(0,0,0,0),new a(BigInt(r.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 r=this.toISOString(e);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${e} ${r}`}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 r of t){const i=new a(r);i.after(e)&&(e=i)}return e}static min(...t){let e=a.MAX;for(const r of t){const i=new a(r);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 D?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 D?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),r=this.truncate(u.MINUTE),i=this.truncate(u.SECOND),c=this.truncate(u.MILLISECOND),h=this.truncate(u.MICROSECOND),v=this.truncate(u.NANOSECOND),y=t,S=e.sub(t),A=r.sub(e),f=i.sub(r),R=c.sub(i),C=h.sub(c),Y=v.sub(h);let B="";return y.isZero||(B+=`${y.days}d `),S.isZero||(B+=`${S.hours}h `),A.isZero||(B+=`${A.minutes}m `),f.isZero||(B+=`${f.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 p=class p extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new p(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 p(t)}static khz(t){return p.hz(t*1e3)}};s(p,"z",l.z.union([l.z.number().transform(t=>new p(t)),l.z.instanceof(Number).transform(t=>new p(t)),l.z.instanceof(p)]));let D=p;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 r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const i=m.max(r.start,t.start),c=m.min(r.end,t.end);return c.before(i)?!1:new O(c.sub(i)).greaterThanOrEqual(e)}roughlyEquals(t,e){let r=this.start.sub(t.start).valueOf(),i=this.end.sub(t.end).valueOf();return r<0&&(r=-r),i<0&&(i=-i),r<=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,n=class n extends String{constructor(t){if(t instanceof n||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}const e=n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}throw super(n.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=n.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(n.JSON)||this.equals(n.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(n.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=n.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}canSafelyCastTo(t){return this.equals(t)?!0:this.isVariable&&!t.isVariable||!this.isVariable&&t.isVariable?!1:this.isFloat&&t.isInteger||this.isInteger&&t.isFloat?this.density.valueOf()<t.density.valueOf():this.isFloat&&t.isFloat||this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf():!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 n.BIG_INT_TYPES.some(t=>t.equals(this))}};s(n,"UNKNOWN",new n("unknown")),s(n,"FLOAT64",new n("float64")),s(n,"FLOAT32",new n("float32")),s(n,"INT64",new n("int64")),s(n,"INT32",new n("int32")),s(n,"INT16",new n("int16")),s(n,"INT8",new n("int8")),s(n,"UINT64",new n("uint64")),s(n,"UINT32",new n("uint32")),s(n,"UINT16",new n("uint16")),s(n,"UINT8",new n("uint8")),s(n,"BOOLEAN",n.UINT8),s(n,"TIMESTAMP",new n("timestamp")),s(n,"UUID",new n("uuid")),s(n,"STRING",new n("string")),s(n,"JSON",new n("json")),s(n,"ARRAY_CONSTRUCTORS",new Map([[n.UINT8.toString(),Uint8Array],[n.UINT16.toString(),Uint16Array],[n.UINT32.toString(),Uint32Array],[n.UINT64.toString(),BigUint64Array],[n.FLOAT32.toString(),Float32Array],[n.FLOAT64.toString(),Float64Array],[n.INT8.toString(),Int8Array],[n.INT16.toString(),Int16Array],[n.INT32.toString(),Int32Array],[n.INT64.toString(),BigInt64Array],[n.TIMESTAMP.toString(),BigInt64Array],[n.STRING.toString(),Uint8Array],[n.JSON.toString(),Uint8Array],[n.UUID.toString(),Uint8Array]])),s(n,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,n.UINT8],[Uint16Array.name,n.UINT16],[Uint32Array.name,n.UINT32],[BigUint64Array.name,n.UINT64],[Float32Array.name,n.FLOAT32],[Float64Array.name,n.FLOAT64],[Int8Array.name,n.INT8],[Int16Array.name,n.INT16],[Int32Array.name,n.INT32],[BigInt64Array.name,n.INT64]])),s(n,"DENSITIES",new Map([[n.UINT8.toString(),I.BIT8],[n.UINT16.toString(),I.BIT16],[n.UINT32.toString(),I.BIT32],[n.UINT64.toString(),I.BIT64],[n.FLOAT32.toString(),I.BIT32],[n.FLOAT64.toString(),I.BIT64],[n.INT8.toString(),I.BIT8],[n.INT16.toString(),I.BIT16],[n.INT32.toString(),I.BIT32],[n.INT64.toString(),I.BIT64],[n.TIMESTAMP.toString(),I.BIT64],[n.STRING.toString(),I.UNKNOWN],[n.JSON.toString(),I.UNKNOWN],[n.UUID.toString(),I.BIT128]])),s(n,"ALL",[n.UNKNOWN,n.FLOAT64,n.FLOAT32,n.INT64,n.INT32,n.INT16,n.INT8,n.UINT64,n.UINT32,n.UINT16,n.UINT8,n.TIMESTAMP,n.UUID,n.STRING,n.JSON]),s(n,"BIG_INT_TYPES",[n.INT64,n.UINT64,n.TIMESTAMP]),s(n,"z",l.z.union([l.z.string().transform(t=>new n(t)),l.z.instanceof(n)]));let g=n;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),r=this.truncate(d.MEGABYTE),i=this.truncate(d.KILOBYTE),c=this.truncate(d.BYTE),h=t,v=e.sub(t),y=r.sub(e),S=i.sub(r),A=c.sub(i);let f="";return h.isZero||(f+=`${h.terabytes}TB `),v.isZero||(f+=`${v.gigabytes}GB `),y.isZero||(f+=`${y.megabytes}MB `),S.isZero||(f+=`${S.kilobytes}KB `),(!A.isZero||f==="")&&(f+=`${A.valueOf()}B`),f.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 ct=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,r=0)=>o.usesBigInt&&!t.usesBigInt?Number(e)-Number(r):!o.usesBigInt&&t.usesBigInt?BigInt(e.valueOf())-BigInt(r.valueOf()):x(e,-r).valueOf(),_=o=>o==null?!1:Array.isArray(o)||o instanceof ArrayBuffer||ArrayBuffer.isView(o)&&!(o instanceof DataView)||o instanceof z?!0:P(o),E=-1,$={[Symbol.iterator]:()=>$,next:()=>({done:!0,value:void 0})},ft=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:r,sampleOffset:i=0,glBufferUsage:c="static",alignment:h=0n,key:v=K()}=t,y=t.data??[];if(y instanceof T||typeof y=="object"&&"isSynnaxSeries"in y&&y.isSynnaxSeries===!0){const f=y;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;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 f=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.");f=y[0]}if(typeof f=="string")this.dataType=g.STRING;else if(typeof f=="number")this.dataType=g.FLOAT64;else if(typeof f=="bigint")this.dataType=g.INT64;else if(typeof f=="boolean")this.dataType=g.BOOLEAN;else if(f instanceof m||f instanceof Date||f instanceof m)this.dataType=g.TIMESTAMP;else if(typeof f=="object")this.dataType=g.JSON;else throw new Error(`cannot infer data type of ${typeof f} when constructing a Series from a JS array`)}else this.dataType=new g(y)}if(!A&&!S)this._data=y;else{let f=S?[y]:y;const R=f[0];(R instanceof m||R instanceof Date||R instanceof O)&&(f=f.map(C=>new m(C).valueOf())),this.dataType.equals(g.STRING)?(this._cachedLength=f.length,this._data=new TextEncoder().encode(`${f.join(`
2
+ `)}
3
+ `).buffer):this.dataType.equals(g.JSON)?(this._cachedLength=f.length,this._data=new TextEncoder().encode(`${f.map(C=>L.JSON_CODEC.encodeString(C)).join(`
4
+ `)}
5
+ `).buffer):this._data=new this.dataType.Array(f).buffer}this.key=v,this.alignment=h,this.sampleOffset=i??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:c}}static alloc({capacity:t,dataType:e,...r}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const i=new new g(e).Array(t),c=new T({data:i.buffer,dataType:e,...r});return c.writePos=0,c}static generateTimestamps(t,e,r){const i=r.spanRange(e.span(t)),c=new BigInt64Array(t);for(let h=0;h<t;h++)c[h]=BigInt(r.add(e.span(h)).valueOf());return new T({data:c,dataType:g.TIMESTAMP,timeRange:i})}get refCount(){return this._refCount}static fromStrings(t,e){const r=new TextEncoder().encode(`${t.join(`
6
+ `)}
7
+ `);return new T({data:r,dataType:g.STRING,timeRange:e})}static fromJSON(t,e){const r=new TextEncoder().encode(`${t.map(i=>L.JSON_CODEC.encodeString(i)).join(`
8
+ `)}
9
+ `);return new T({data:r,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,r=t.subBytes(0,e);return this.writeToUnderlyingData(r),this.writePos+=r.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=r.length,this.calculateCachedLength()),r.length}writeFixed(t){if(this.writePos===E)return 0;const e=this.capacity-this.writePos,r=t.sub(0,e);return this.writeToUnderlyingData(r),this._cachedLength=void 0,this.maybeRecomputeMinMax(r),this.writePos+=r.length,r.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 r=0;r<this.length;r++){const i=this.underlyingData.slice(r*t,(r+1)*t),c=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[r]=c}return e}parseJSON(t){if(!this.dataType.equals(g.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
11
+ `).slice(0,-1).map(e=>t.parse(L.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((r,i)=>{r===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 r=new t.Array(this.length);for(let i=0;i<this.length;i++)r[i]=Q(this.dataType,t,this.data[i],e);return new T({data:r.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,r)=>e>r?e:r)}else{const t=this.data;this._cachedMax=t.reduce((e,r)=>e>r?e:r)}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,r)=>e<r?e:r)}else{const t=this.data;this._cachedMin=t.reduce((e,r)=>e<r?e:r)}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 r=Number(t-this.alignment);if(r<0||r>=this.length){if(e===!0)throw new Error(`[series] - no value at index ${r}`);return}return this.at(r,e)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const r=this.data[t];if(r==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return x(r,this.sampleOffset)}atVariable(t,e){let r=0,i=0;if(this._cachedIndexes!=null)r=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}r=h+1,t--}if(i===0&&(i=this.data.length),r>=i||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}}const c=this.data.slice(r,i);return this.dataType.equals(g.STRING)?new TextDecoder().decode(c):rt.snakeToCamel(JSON.parse(new TextDecoder().decode(c)))}binarySearch(t){let e=0,r=this.length-1;const i=nt.newF(t);for(;e<=r;){const c=Math.floor((e+r)/2),h=i(this.at(c,!0),t);if(h===0)return c;h<0?e=c+1:r=c-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(g.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:e,bufferUsage:r,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 c=this.dataType.density.size(i).valueOf(),h=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,c,h.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,r==="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:Z(this.alignmentBounds.lower),upper:Z(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 V(this,t,e??this.length)}subAlignmentIterator(t,e){return new V(this,Number(t-this.alignment),Number(e-this.alignment))}subBytes(t,e){if(t>=0&&(e==null||e>=this.byteLength.valueOf()))return this;const r=this.data.subarray(t,e);return new T({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,e,r){if(e<=0&&(r==null||r>=this.length))return this;let i;return t?i=this.data.subarray(e,r):i=this.data.slice(e,r),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([ft,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 z=T;class V{constructor(t,e,r){s(this,"series");s(this,"end");s(this,"index");this.series=t;const i=w.construct(0,t.length);this.end=w.clamp(i,r),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 r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}[Symbol.iterator](){return this}}var k,G;class gt{constructor(t){s(this,"wrapped");s(this,k,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:L.JSON_CODEC.decodeString(t.value)}}[(G=Symbol.iterator,k=Symbol.toStringTag,G)](){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 r=1;r<t.length;r++)if(!t[r].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 r of this.series)if(w.contains(r.alignmentBounds,t))return r.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 r of this.series){if(t<r.length)return r.at(t,e);t-=r.length}if(e)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,e){return new q(this,t,e??this.length)}subAlignmentIterator(t,e){if(t>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return $;let r=0;for(let c=0;c<this.series.length;c++){const h=this.series[c];if(t<h.alignment)break;if(t>=h.alignmentBounds.upper)r+=h.length;else if(w.contains(h.alignmentBounds,t)){r+=Number(t-h.alignment);break}}let i=0;for(let c=0;c<this.series.length;c++){const h=this.series[c];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 q(this,r,i)}subAlignmentSpanIterator(t,e){if(t>=this.alignmentBounds.upper)return $;let r=0;for(let i=0;i<this.series.length;i++){const c=this.series[i];if(t<c.alignment)break;if(t>=c.alignmentBounds.upper)r+=c.length;else if(w.contains(c.alignmentBounds,t)){r+=Number(t-c.alignment);break}}return new q(this,r,r+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 r of this.series)t.set(r.data,e),e+=r.length;return new this.dataType.Array(t.buffer)}traverseAlignment(t,e){const r=this.series.map(i=>i.alignmentBounds);return w.traverse(r,t,e)}distance(t,e){const r=this.series.map(i=>i.alignmentBounds);return w.distance(r,t,e)}[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 q{constructor(t,e,r){s(this,"series");s(this,"index");s(this,"end");this.series=t,this.end=r,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 Z=o=>{const t=o>>32n,e=o&0xffffffffn;return{domain:t,sample:e}};exports.DataType=g;exports.Density=I;exports.MultiSeries=Ot;exports.Rate=D;exports.Series=z;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=ct;