@kbve/droid 0.0.5 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +3 -1
  2. package/comlink.js +1 -7
  3. package/droid.mjs +191 -61
  4. package/index.d.ts +29 -0
  5. package/index.js +9054 -2763
  6. package/lib/gateway/SupabaseGateway.d.ts +38 -0
  7. package/lib/gateway/SupabaseGateway.d.ts.map +1 -0
  8. package/lib/gateway/WorkerCommunication.d.ts +39 -0
  9. package/lib/gateway/WorkerCommunication.d.ts.map +1 -0
  10. package/lib/gateway/WorkerPool.d.ts +55 -0
  11. package/lib/gateway/WorkerPool.d.ts.map +1 -0
  12. package/lib/gateway/capabilities.d.ts +23 -0
  13. package/lib/gateway/capabilities.d.ts.map +1 -0
  14. package/lib/gateway/index.d.ts +9 -0
  15. package/lib/gateway/index.d.ts.map +1 -0
  16. package/lib/gateway/strategies/DirectStrategy.d.ts +52 -0
  17. package/lib/gateway/strategies/DirectStrategy.d.ts.map +1 -0
  18. package/lib/gateway/strategies/SharedWorkerStrategy.d.ts +46 -0
  19. package/lib/gateway/strategies/SharedWorkerStrategy.d.ts.map +1 -0
  20. package/lib/gateway/strategies/WebWorkerStrategy.d.ts +45 -0
  21. package/lib/gateway/strategies/WebWorkerStrategy.d.ts.map +1 -0
  22. package/lib/gateway/types.d.ts +81 -0
  23. package/lib/gateway/types.d.ts.map +1 -0
  24. package/lib/workers/canvas-ui-renderer.d.ts +25 -0
  25. package/lib/workers/canvas-ui-renderer.d.ts.map +1 -0
  26. package/lib/workers/canvas-worker.d.ts +14 -0
  27. package/lib/workers/canvas-worker.d.ts.map +1 -0
  28. package/lib/workers/canvas-worker.js +291 -145
  29. package/lib/workers/data.d.ts +40 -0
  30. package/lib/workers/data.d.ts.map +1 -0
  31. package/lib/workers/db-worker.d.ts +69 -0
  32. package/lib/workers/db-worker.d.ts.map +1 -0
  33. package/lib/workers/db-worker.js +2680 -2147
  34. package/lib/workers/events.d.ts +11 -0
  35. package/lib/workers/events.d.ts.map +1 -0
  36. package/lib/workers/flexbuilder.d.ts +4 -0
  37. package/lib/workers/flexbuilder.d.ts.map +1 -0
  38. package/lib/workers/init.d.ts +11 -0
  39. package/lib/workers/init.d.ts.map +1 -0
  40. package/lib/workers/main.d.ts +107 -0
  41. package/lib/workers/main.d.ts.map +1 -0
  42. package/lib/workers/supabase-db-worker.d.ts +2 -0
  43. package/lib/workers/supabase-db-worker.d.ts.map +1 -0
  44. package/lib/workers/supabase-db-worker.js +9337 -0
  45. package/lib/workers/supabase-shared-worker.d.ts +2 -0
  46. package/lib/workers/supabase-shared-worker.d.ts.map +1 -0
  47. package/lib/workers/supabase-shared-worker.js +12635 -0
  48. package/lib/workers/tools.d.ts +4 -0
  49. package/lib/workers/tools.d.ts.map +1 -0
  50. package/lib/workers/validate.d.ts +15 -0
  51. package/lib/workers/validate.d.ts.map +1 -0
  52. package/lib/workers/ws-worker.d.ts +11 -0
  53. package/lib/workers/ws-worker.d.ts.map +1 -0
  54. package/lib/workers/ws-worker.js +174 -115
  55. package/main.js +4875 -0
  56. package/package.json +17 -6
  57. package/reference.js +688 -228
  58. package/src/index.ts +38 -13
  59. package/src/lib/droid.spec.ts +14 -19
  60. package/src/lib/droid.ts +48 -4
  61. package/src/lib/gateway/SupabaseGateway.ts +183 -0
  62. package/src/lib/gateway/WorkerCommunication.ts +132 -0
  63. package/src/lib/gateway/WorkerPool.ts +304 -0
  64. package/src/lib/gateway/capabilities.ts +80 -0
  65. package/src/lib/gateway/index.ts +15 -0
  66. package/src/lib/gateway/strategies/DirectStrategy.ts +443 -0
  67. package/src/lib/gateway/strategies/SharedWorkerStrategy.ts +278 -0
  68. package/src/lib/gateway/strategies/WebWorkerStrategy.ts +278 -0
  69. package/src/lib/gateway/types.ts +112 -0
  70. package/src/lib/mod/mod-manager.ts +13 -8
  71. package/src/lib/mod/module/bento/mod-bento.worker.ts +1 -1
  72. package/src/lib/mod/module/supabase/mod-supabase.spec.ts +21 -25
  73. package/src/lib/mod/module/supabase/mod-supabase.ts +68 -0
  74. package/src/lib/mod/module/supabase/mod-supabase.worker.ts +1 -56
  75. package/src/lib/state/auth.spec.ts +58 -0
  76. package/src/lib/state/auth.ts +30 -0
  77. package/src/lib/state/index.ts +34 -0
  78. package/src/lib/state/overlay-manager.ts +125 -0
  79. package/src/lib/state/router.ts +24 -0
  80. package/src/lib/state/theme-sync.ts +75 -0
  81. package/src/lib/state/toasts.spec.ts +106 -0
  82. package/src/lib/state/toasts.ts +34 -0
  83. package/src/lib/state/ui.spec.ts +148 -0
  84. package/src/lib/state/ui.ts +45 -0
  85. package/src/lib/state/welcome-toast.ts +76 -0
  86. package/src/lib/types/bento.spec.ts +116 -0
  87. package/src/lib/types/bento.ts +94 -55
  88. package/src/lib/types/event-types.spec.ts +93 -0
  89. package/src/lib/types/event-types.ts +39 -3
  90. package/src/lib/types/modules.ts +12 -5
  91. package/src/lib/types/ui-event-types.ts +66 -0
  92. package/src/lib/workers/canvas-ui-renderer.ts +266 -0
  93. package/src/lib/workers/canvas-worker.ts +94 -9
  94. package/src/lib/workers/data.ts +59 -36
  95. package/src/lib/workers/db-worker.ts +79 -32
  96. package/src/lib/workers/events.spec.ts +208 -0
  97. package/src/lib/workers/events.ts +27 -14
  98. package/src/lib/workers/flexbuilder.ts +2 -2
  99. package/src/lib/workers/init.ts +25 -17
  100. package/src/lib/workers/main.ts +509 -272
  101. package/src/lib/workers/supabase-db-worker.ts +221 -0
  102. package/src/lib/workers/supabase-shared-worker.ts +572 -0
  103. package/src/lib/workers/validate.ts +64 -0
  104. package/src/lib/workers/ws-worker.ts +156 -25
  105. package/src/setup-vitest.ts +4 -2
  106. package/src/types.ts +30 -0
  107. package/src/vite-env.d.ts +1 -0
  108. package/workers/main.js +10 -1089
  109. package/src/types.d.ts +0 -31
package/reference.js CHANGED
@@ -1,259 +1,719 @@
1
- var T = /* @__PURE__ */ ((t) => (t[t.WIDTH8 = 0] = "WIDTH8", t[t.WIDTH16 = 1] = "WIDTH16", t[t.WIDTH32 = 2] = "WIDTH32", t[t.WIDTH64 = 3] = "WIDTH64", t))(T || {});
2
- function S(t) {
3
- return 1 << t;
1
+ var N = {}, E = {}, j;
2
+ function L() {
3
+ if (j) return E;
4
+ j = 1, Object.defineProperty(E, "__esModule", { value: !0 }), E.BitWidth = void 0;
5
+ var o;
6
+ return (function(e) {
7
+ e[e.WIDTH8 = 0] = "WIDTH8", e[e.WIDTH16 = 1] = "WIDTH16", e[e.WIDTH32 = 2] = "WIDTH32", e[e.WIDTH64 = 3] = "WIDTH64";
8
+ })(o || (E.BitWidth = o = {})), E;
4
9
  }
5
- function K(t) {
6
- return t >= -128 && t <= 127 ? T.WIDTH8 : t >= -32768 && t <= 32767 ? T.WIDTH16 : t >= -2147483648 && t <= 2147483647 ? T.WIDTH32 : T.WIDTH64;
7
- }
8
- function $(t) {
9
- return t === Math.fround(t) ? T.WIDTH32 : T.WIDTH64;
10
- }
11
- function x(t) {
12
- return t <= 255 ? T.WIDTH8 : t <= 65535 ? T.WIDTH16 : t <= 4294967295 ? T.WIDTH32 : T.WIDTH64;
13
- }
14
- function f(t) {
15
- return t === 1 ? T.WIDTH8 : t === 2 ? T.WIDTH16 : t === 4 ? T.WIDTH32 : T.WIDTH64;
16
- }
17
- function G(t, i) {
18
- return ~t + 1 & i - 1;
19
- }
20
- function U(t) {
21
- return new TextDecoder().decode(t);
22
- }
23
- function p(t) {
24
- return new TextEncoder().encode(t);
25
- }
26
- var e = /* @__PURE__ */ ((t) => (t[t.NULL = 0] = "NULL", t[t.INT = 1] = "INT", t[t.UINT = 2] = "UINT", t[t.FLOAT = 3] = "FLOAT", t[t.KEY = 4] = "KEY", t[t.STRING = 5] = "STRING", t[t.INDIRECT_INT = 6] = "INDIRECT_INT", t[t.INDIRECT_UINT = 7] = "INDIRECT_UINT", t[t.INDIRECT_FLOAT = 8] = "INDIRECT_FLOAT", t[t.MAP = 9] = "MAP", t[t.VECTOR = 10] = "VECTOR", t[t.VECTOR_INT = 11] = "VECTOR_INT", t[t.VECTOR_UINT = 12] = "VECTOR_UINT", t[t.VECTOR_FLOAT = 13] = "VECTOR_FLOAT", t[t.VECTOR_KEY = 14] = "VECTOR_KEY", t[t.VECTOR_STRING_DEPRECATED = 15] = "VECTOR_STRING_DEPRECATED", t[t.VECTOR_INT2 = 16] = "VECTOR_INT2", t[t.VECTOR_UINT2 = 17] = "VECTOR_UINT2", t[t.VECTOR_FLOAT2 = 18] = "VECTOR_FLOAT2", t[t.VECTOR_INT3 = 19] = "VECTOR_INT3", t[t.VECTOR_UINT3 = 20] = "VECTOR_UINT3", t[t.VECTOR_FLOAT3 = 21] = "VECTOR_FLOAT3", t[t.VECTOR_INT4 = 22] = "VECTOR_INT4", t[t.VECTOR_UINT4 = 23] = "VECTOR_UINT4", t[t.VECTOR_FLOAT4 = 24] = "VECTOR_FLOAT4", t[t.BLOB = 25] = "BLOB", t[t.BOOL = 26] = "BOOL", t[t.VECTOR_BOOL = 36] = "VECTOR_BOOL", t))(e || {});
27
- function M(t) {
28
- return t === e.BOOL || t <= e.FLOAT;
29
- }
30
- function B(t) {
31
- return t >= e.INT && t <= e.FLOAT;
32
- }
33
- function F(t) {
34
- return t >= e.INDIRECT_INT && t <= e.INDIRECT_FLOAT;
35
- }
36
- function P(t) {
37
- return t === e.BOOL || t >= e.INT && t <= e.STRING;
38
- }
39
- function A(t) {
40
- return t === e.VECTOR_BOOL || t >= e.VECTOR_INT && t <= e.VECTOR_STRING_DEPRECATED;
41
- }
42
- function a(t) {
43
- return t >= e.VECTOR_INT2 && t <= e.VECTOR_FLOAT4;
44
- }
45
- function g(t) {
46
- return A(t) || a(t) || t === e.VECTOR;
47
- }
48
- function Y(t, i) {
49
- if (i === 0) return t - e.INT + e.VECTOR_INT;
50
- if (i === 2) return t - e.INT + e.VECTOR_INT2;
51
- if (i === 3) return t - e.INT + e.VECTOR_INT3;
52
- if (i === 4) return t - e.INT + e.VECTOR_INT4;
53
- throw "Unexpected length " + i;
54
- }
55
- function H(t) {
56
- return t - e.VECTOR_INT + e.INT;
57
- }
58
- function m(t) {
59
- return (t - e.VECTOR_INT2) % 3 + e.INT;
60
- }
61
- function w(t) {
62
- return ((t - e.VECTOR_INT2) / 3 >> 0) + 2;
63
- }
64
- function b(t, i) {
65
- return i | t << 2;
66
- }
67
- function C(t, i, n) {
68
- return n < 2 ? n < 1 ? t.getInt8(i) : t.getInt16(i, !0) : n < 3 ? t.getInt32(i, !0) : t.setBigInt64 === void 0 ? BigInt(t.getUint32(i, !0)) + (BigInt(t.getUint32(i + 4, !0)) << BigInt(32)) : t.getBigInt64(i, !0);
69
- }
70
- function c(t, i, n) {
71
- return n < 2 ? n < 1 ? t.getUint8(i) : t.getUint16(i, !0) : n < 3 ? t.getUint32(i, !0) : t.getBigUint64 === void 0 ? BigInt(t.getUint32(i, !0)) + (BigInt(t.getUint32(i + 4, !0)) << BigInt(32)) : t.getBigUint64(i, !0);
72
- }
73
- function D(t, i, n) {
74
- if (n < T.WIDTH32)
75
- throw "Bad width: " + n;
76
- return n === T.WIDTH32 ? t.getFloat32(i, !0) : t.getFloat64(i, !0);
77
- }
78
- function I(t, i, n) {
79
- const r = c(t, i, n);
80
- return i - r;
81
- }
82
- function V(t, i, n, r, s, h) {
83
- const o = p(t), u = I(i, n, r) - s * 3, O = f(s), N = u - Number(c(i, u, O)), E = Number(c(i, u + s, O));
84
- let d = 0, l = h - 1;
85
- for (; d <= l; ) {
86
- const _ = l + d >> 1, W = v(o, _, i, N, E);
87
- if (W === 0) return _;
88
- W < 0 ? l = _ - 1 : d = _ + 1;
89
- }
90
- return null;
91
- }
92
- function v(t, i, n, r, s) {
93
- const h = r + i * s, o = h - Number(c(n, h, f(s)));
94
- for (let u = 0; u < t.length; u++) {
95
- const O = t[u] - n.getUint8(o + u);
96
- if (O !== 0)
97
- return O;
98
- }
99
- return n.getUint8(o + t.length) === 0 ? 0 : -1;
100
- }
101
- function y(t, i, n, r, s) {
102
- const h = I(i, n, r) - s * 3, o = f(s), u = h - Number(c(i, h, o)), O = Number(c(i, h + s, o)), N = u + t * O, E = N - Number(c(i, N, f(O)));
103
- let d = 0;
104
- for (; i.getUint8(E + d) !== 0; )
105
- d++;
106
- return U(new Uint8Array(i.buffer, E, d));
10
+ var b = {}, x;
11
+ function A() {
12
+ if (x) return b;
13
+ x = 1, Object.defineProperty(b, "__esModule", { value: !0 }), b.paddingSize = b.fromByteWidth = b.uwidth = b.fwidth = b.iwidth = b.toByteWidth = void 0;
14
+ const o = L();
15
+ function e(p) {
16
+ return 1 << p;
17
+ }
18
+ b.toByteWidth = e;
19
+ function T(p) {
20
+ return p >= -128 && p <= 127 ? o.BitWidth.WIDTH8 : p >= -32768 && p <= 32767 ? o.BitWidth.WIDTH16 : p >= -2147483648 && p <= 2147483647 ? o.BitWidth.WIDTH32 : o.BitWidth.WIDTH64;
21
+ }
22
+ b.iwidth = T;
23
+ function f(p) {
24
+ return p === Math.fround(p) ? o.BitWidth.WIDTH32 : o.BitWidth.WIDTH64;
25
+ }
26
+ b.fwidth = f;
27
+ function W(p) {
28
+ return p <= 255 ? o.BitWidth.WIDTH8 : p <= 65535 ? o.BitWidth.WIDTH16 : p <= 4294967295 ? o.BitWidth.WIDTH32 : o.BitWidth.WIDTH64;
29
+ }
30
+ b.uwidth = W;
31
+ function I(p) {
32
+ return p === 1 ? o.BitWidth.WIDTH8 : p === 2 ? o.BitWidth.WIDTH16 : p === 4 ? o.BitWidth.WIDTH32 : o.BitWidth.WIDTH64;
33
+ }
34
+ b.fromByteWidth = I;
35
+ function V(p, t) {
36
+ return ~p + 1 & t - 1;
37
+ }
38
+ return b.paddingSize = V, b;
107
39
  }
108
- function j(t) {
109
- const i = t.byteLength;
110
- if (i < 3)
111
- throw "Buffer needs to be bigger than 3";
112
- const n = new DataView(t), r = n.getUint8(i - 1), s = n.getUint8(i - 2), h = f(r), o = i - r - 2;
113
- return new R(n, o, h, s, "/");
40
+ var B = {}, H;
41
+ function F() {
42
+ if (H) return B;
43
+ H = 1, Object.defineProperty(B, "__esModule", { value: !0 }), B.toUTF8Array = B.fromUTF8Array = void 0;
44
+ function o(T) {
45
+ return new TextDecoder().decode(T);
46
+ }
47
+ B.fromUTF8Array = o;
48
+ function e(T) {
49
+ return new TextEncoder().encode(T);
50
+ }
51
+ return B.toUTF8Array = e, B;
114
52
  }
115
- function L(t, i, n, r, s, h, o, u) {
116
- const O = I(n, r, s), N = O + t * h, E = n.getUint8(O + o * h + t);
117
- return new R(n, N, f(h), E, `${u}/${i}`);
53
+ var m = {}, K;
54
+ function C() {
55
+ if (K) return m;
56
+ K = 1, Object.defineProperty(m, "__esModule", { value: !0 }), m.ValueType = void 0;
57
+ var o;
58
+ return (function(e) {
59
+ e[e.NULL = 0] = "NULL", e[e.INT = 1] = "INT", e[e.UINT = 2] = "UINT", e[e.FLOAT = 3] = "FLOAT", e[e.KEY = 4] = "KEY", e[e.STRING = 5] = "STRING", e[e.INDIRECT_INT = 6] = "INDIRECT_INT", e[e.INDIRECT_UINT = 7] = "INDIRECT_UINT", e[e.INDIRECT_FLOAT = 8] = "INDIRECT_FLOAT", e[e.MAP = 9] = "MAP", e[e.VECTOR = 10] = "VECTOR", e[e.VECTOR_INT = 11] = "VECTOR_INT", e[e.VECTOR_UINT = 12] = "VECTOR_UINT", e[e.VECTOR_FLOAT = 13] = "VECTOR_FLOAT", e[e.VECTOR_KEY = 14] = "VECTOR_KEY", e[e.VECTOR_STRING_DEPRECATED = 15] = "VECTOR_STRING_DEPRECATED", e[e.VECTOR_INT2 = 16] = "VECTOR_INT2", e[e.VECTOR_UINT2 = 17] = "VECTOR_UINT2", e[e.VECTOR_FLOAT2 = 18] = "VECTOR_FLOAT2", e[e.VECTOR_INT3 = 19] = "VECTOR_INT3", e[e.VECTOR_UINT3 = 20] = "VECTOR_UINT3", e[e.VECTOR_FLOAT3 = 21] = "VECTOR_FLOAT3", e[e.VECTOR_INT4 = 22] = "VECTOR_INT4", e[e.VECTOR_UINT4 = 23] = "VECTOR_UINT4", e[e.VECTOR_FLOAT4 = 24] = "VECTOR_FLOAT4", e[e.BLOB = 25] = "BLOB", e[e.BOOL = 26] = "BOOL", e[e.VECTOR_BOOL = 36] = "VECTOR_BOOL";
60
+ })(o || (m.ValueType = o = {})), m;
118
61
  }
119
- class R {
120
- constructor(i, n, r, s, h) {
121
- this.dataView = i, this.offset = n, this.parentWidth = r, this.packedType = s, this.path = h, this._length = -1, this.byteWidth = 1 << (s & 3), this.valueType = s >> 2;
62
+ var y = {}, $;
63
+ function v() {
64
+ if ($) return y;
65
+ $ = 1, Object.defineProperty(y, "__esModule", { value: !0 }), y.packedType = y.fixedTypedVectorElementSize = y.fixedTypedVectorElementType = y.typedVectorElementType = y.toTypedVector = y.isAVector = y.isFixedTypedVector = y.isTypedVector = y.isTypedVectorElement = y.isIndirectNumber = y.isNumber = y.isInline = void 0;
66
+ const o = C();
67
+ function e(h) {
68
+ return h === o.ValueType.BOOL || h <= o.ValueType.FLOAT;
69
+ }
70
+ y.isInline = e;
71
+ function T(h) {
72
+ return h >= o.ValueType.INT && h <= o.ValueType.FLOAT;
73
+ }
74
+ y.isNumber = T;
75
+ function f(h) {
76
+ return h >= o.ValueType.INDIRECT_INT && h <= o.ValueType.INDIRECT_FLOAT;
77
+ }
78
+ y.isIndirectNumber = f;
79
+ function W(h) {
80
+ return h === o.ValueType.BOOL || h >= o.ValueType.INT && h <= o.ValueType.STRING;
122
81
  }
123
- isNull() {
124
- return this.valueType === e.NULL;
82
+ y.isTypedVectorElement = W;
83
+ function I(h) {
84
+ return h === o.ValueType.VECTOR_BOOL || h >= o.ValueType.VECTOR_INT && h <= o.ValueType.VECTOR_STRING_DEPRECATED;
125
85
  }
126
- isNumber() {
127
- return B(this.valueType) || F(this.valueType);
86
+ y.isTypedVector = I;
87
+ function V(h) {
88
+ return h >= o.ValueType.VECTOR_INT2 && h <= o.ValueType.VECTOR_FLOAT4;
128
89
  }
129
- isFloat() {
130
- return e.FLOAT === this.valueType || e.INDIRECT_FLOAT === this.valueType;
90
+ y.isFixedTypedVector = V;
91
+ function p(h) {
92
+ return I(h) || V(h) || h === o.ValueType.VECTOR;
131
93
  }
132
- isInt() {
133
- return this.isNumber() && !this.isFloat();
94
+ y.isAVector = p;
95
+ function t(h, a) {
96
+ if (a === 0)
97
+ return h - o.ValueType.INT + o.ValueType.VECTOR_INT;
98
+ if (a === 2)
99
+ return h - o.ValueType.INT + o.ValueType.VECTOR_INT2;
100
+ if (a === 3)
101
+ return h - o.ValueType.INT + o.ValueType.VECTOR_INT3;
102
+ if (a === 4)
103
+ return h - o.ValueType.INT + o.ValueType.VECTOR_INT4;
104
+ throw "Unexpected length " + a;
134
105
  }
135
- isString() {
136
- return e.STRING === this.valueType || e.KEY === this.valueType;
106
+ y.toTypedVector = t;
107
+ function n(h) {
108
+ return h - o.ValueType.VECTOR_INT + o.ValueType.INT;
137
109
  }
138
- isBool() {
139
- return e.BOOL === this.valueType;
110
+ y.typedVectorElementType = n;
111
+ function s(h) {
112
+ return (h - o.ValueType.VECTOR_INT2) % 3 + o.ValueType.INT;
140
113
  }
141
- isBlob() {
142
- return e.BLOB === this.valueType;
114
+ y.fixedTypedVectorElementType = s;
115
+ function i(h) {
116
+ return ((h - o.ValueType.VECTOR_INT2) / 3 >> 0) + 2;
117
+ }
118
+ y.fixedTypedVectorElementSize = i;
119
+ function r(h, a) {
120
+ return a | h << 2;
121
+ }
122
+ return y.packedType = r, y;
123
+ }
124
+ var R = {}, M;
125
+ function G() {
126
+ if (M) return R;
127
+ M = 1, Object.defineProperty(R, "__esModule", { value: !0 }), R.StackValue = void 0;
128
+ const o = L(), e = A(), T = C(), f = v();
129
+ class W {
130
+ constructor(V, p, t, n = null, s = 0) {
131
+ this.builder = V, this.type = p, this.width = t, this.value = n, this.offset = s;
132
+ }
133
+ elementWidth(V, p) {
134
+ if ((0, f.isInline)(this.type))
135
+ return this.width;
136
+ for (let t = 0; t < 4; t++) {
137
+ const n = 1 << t, i = V + (0, e.paddingSize)(V, n) + p * n - this.offset, r = (0, e.uwidth)(i);
138
+ if (1 << r === n)
139
+ return r;
140
+ }
141
+ throw `Element is unknown. Size: ${V} at index: ${p}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
142
+ }
143
+ writeToBuffer(V) {
144
+ const p = this.builder.computeOffset(V);
145
+ if (this.type === T.ValueType.FLOAT)
146
+ this.width === o.BitWidth.WIDTH32 ? this.builder.view.setFloat32(this.builder.offset, this.value, !0) : this.builder.view.setFloat64(this.builder.offset, this.value, !0);
147
+ else if (this.type === T.ValueType.INT) {
148
+ const t = (0, e.fromByteWidth)(V);
149
+ this.builder.pushInt(this.value, t);
150
+ } else if (this.type === T.ValueType.UINT) {
151
+ const t = (0, e.fromByteWidth)(V);
152
+ this.builder.pushUInt(this.value, t);
153
+ } else if (this.type === T.ValueType.NULL)
154
+ this.builder.pushInt(0, this.width);
155
+ else if (this.type === T.ValueType.BOOL)
156
+ this.builder.pushInt(this.value ? 1 : 0, this.width);
157
+ else
158
+ throw `Unexpected type: ${this.type}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
159
+ this.offset = p;
160
+ }
161
+ storedWidth(V = o.BitWidth.WIDTH8) {
162
+ return (0, f.isInline)(this.type) ? Math.max(V, this.width) : this.width;
163
+ }
164
+ storedPackedType(V = o.BitWidth.WIDTH8) {
165
+ return (0, f.packedType)(this.type, this.storedWidth(V));
166
+ }
167
+ isOffset() {
168
+ return !(0, f.isInline)(this.type);
169
+ }
143
170
  }
144
- isVector() {
145
- return g(this.valueType);
171
+ return R.StackValue = W, R;
172
+ }
173
+ var q;
174
+ function J() {
175
+ if (q) return N;
176
+ q = 1, Object.defineProperty(N, "__esModule", { value: !0 }), N.Builder = void 0;
177
+ const o = L(), e = A(), T = F(), f = C(), W = v(), I = G();
178
+ class V {
179
+ constructor(t = 2048, n = !0, s = !0, i = !0) {
180
+ this.dedupStrings = n, this.dedupKeys = s, this.dedupKeyVectors = i, this.stack = [], this.stackPointers = [], this.offset = 0, this.finished = !1, this.stringLookup = {}, this.keyLookup = {}, this.keyVectorLookup = {}, this.indirectIntLookup = {}, this.indirectUIntLookup = {}, this.indirectFloatLookup = {}, this.buffer = new ArrayBuffer(t > 0 ? t : 2048), this.view = new DataView(this.buffer);
181
+ }
182
+ align(t) {
183
+ const n = (0, e.toByteWidth)(t);
184
+ return this.offset += (0, e.paddingSize)(this.offset, n), n;
185
+ }
186
+ computeOffset(t) {
187
+ const n = this.offset + t;
188
+ let s = this.buffer.byteLength;
189
+ const i = s;
190
+ for (; s < n; )
191
+ s <<= 1;
192
+ if (i < s) {
193
+ const r = this.buffer;
194
+ this.buffer = new ArrayBuffer(s), this.view = new DataView(this.buffer), new Uint8Array(this.buffer).set(new Uint8Array(r), 0);
195
+ }
196
+ return n;
197
+ }
198
+ pushInt(t, n) {
199
+ if (n === o.BitWidth.WIDTH8)
200
+ this.view.setInt8(this.offset, t);
201
+ else if (n === o.BitWidth.WIDTH16)
202
+ this.view.setInt16(this.offset, t, !0);
203
+ else if (n === o.BitWidth.WIDTH32)
204
+ this.view.setInt32(this.offset, t, !0);
205
+ else if (n === o.BitWidth.WIDTH64)
206
+ this.view.setBigInt64(this.offset, BigInt(t), !0);
207
+ else
208
+ throw `Unexpected width: ${n} for value: ${t}`;
209
+ }
210
+ pushUInt(t, n) {
211
+ if (n === o.BitWidth.WIDTH8)
212
+ this.view.setUint8(this.offset, t);
213
+ else if (n === o.BitWidth.WIDTH16)
214
+ this.view.setUint16(this.offset, t, !0);
215
+ else if (n === o.BitWidth.WIDTH32)
216
+ this.view.setUint32(this.offset, t, !0);
217
+ else if (n === o.BitWidth.WIDTH64)
218
+ this.view.setBigUint64(this.offset, BigInt(t), !0);
219
+ else
220
+ throw `Unexpected width: ${n} for value: ${t}`;
221
+ }
222
+ writeInt(t, n) {
223
+ const s = this.computeOffset(n);
224
+ this.pushInt(t, (0, e.fromByteWidth)(n)), this.offset = s;
225
+ }
226
+ writeUInt(t, n) {
227
+ const s = this.computeOffset(n);
228
+ this.pushUInt(t, (0, e.fromByteWidth)(n)), this.offset = s;
229
+ }
230
+ writeBlob(t) {
231
+ const n = t.byteLength, s = (0, e.uwidth)(n), i = this.align(s);
232
+ this.writeUInt(n, i);
233
+ const r = this.offset, h = this.computeOffset(n);
234
+ new Uint8Array(this.buffer).set(new Uint8Array(t), r), this.stack.push(this.offsetStackValue(r, f.ValueType.BLOB, s)), this.offset = h;
235
+ }
236
+ writeString(t) {
237
+ if (this.dedupStrings && Object.prototype.hasOwnProperty.call(this.stringLookup, t)) {
238
+ this.stack.push(this.stringLookup[t]);
239
+ return;
240
+ }
241
+ const n = (0, T.toUTF8Array)(t), s = n.length, i = (0, e.uwidth)(s), r = this.align(i);
242
+ this.writeUInt(s, r);
243
+ const h = this.offset, a = this.computeOffset(s + 1);
244
+ new Uint8Array(this.buffer).set(n, h);
245
+ const l = this.offsetStackValue(h, f.ValueType.STRING, i);
246
+ this.stack.push(l), this.dedupStrings && (this.stringLookup[t] = l), this.offset = a;
247
+ }
248
+ writeKey(t) {
249
+ if (this.dedupKeys && Object.prototype.hasOwnProperty.call(this.keyLookup, t)) {
250
+ this.stack.push(this.keyLookup[t]);
251
+ return;
252
+ }
253
+ const n = (0, T.toUTF8Array)(t), s = n.length, i = this.computeOffset(s + 1);
254
+ new Uint8Array(this.buffer).set(n, this.offset);
255
+ const r = this.offsetStackValue(this.offset, f.ValueType.KEY, o.BitWidth.WIDTH8);
256
+ this.stack.push(r), this.dedupKeys && (this.keyLookup[t] = r), this.offset = i;
257
+ }
258
+ writeStackValue(t, n) {
259
+ const s = this.computeOffset(n);
260
+ if (t.isOffset()) {
261
+ const i = this.offset - t.offset;
262
+ if (n === 8 || BigInt(i) < BigInt(1) << BigInt(n * 8))
263
+ this.writeUInt(i, n);
264
+ else
265
+ throw `Unexpected size ${n}. This might be a bug. Please create an issue https://github.com/google/flatbuffers/issues/new`;
266
+ } else
267
+ t.writeToBuffer(n);
268
+ this.offset = s;
269
+ }
270
+ integrityCheckOnValueAddition() {
271
+ if (this.finished)
272
+ throw "Adding values after finish is prohibited";
273
+ if (this.stackPointers.length !== 0 && this.stackPointers[this.stackPointers.length - 1].isVector === !1 && this.stack[this.stack.length - 1].type !== f.ValueType.KEY)
274
+ throw "Adding value to a map before adding a key is prohibited";
275
+ }
276
+ integrityCheckOnKeyAddition() {
277
+ if (this.finished)
278
+ throw "Adding values after finish is prohibited";
279
+ if (this.stackPointers.length === 0 || this.stackPointers[this.stackPointers.length - 1].isVector)
280
+ throw "Adding key before starting a map is prohibited";
281
+ }
282
+ startVector() {
283
+ this.stackPointers.push({ stackPosition: this.stack.length, isVector: !0 });
284
+ }
285
+ startMap(t = !1) {
286
+ this.stackPointers.push({ stackPosition: this.stack.length, isVector: !1, presorted: t });
287
+ }
288
+ endVector(t) {
289
+ const n = this.stack.length - t.stackPosition, s = this.createVector(t.stackPosition, n, 1);
290
+ this.stack.splice(t.stackPosition, n), this.stack.push(s);
291
+ }
292
+ endMap(t) {
293
+ t.presorted || this.sort(t);
294
+ let n = "";
295
+ for (let h = t.stackPosition; h < this.stack.length; h += 2)
296
+ n += `,${this.stack[h].offset}`;
297
+ const s = this.stack.length - t.stackPosition >> 1;
298
+ this.dedupKeyVectors && !Object.prototype.hasOwnProperty.call(this.keyVectorLookup, n) && (this.keyVectorLookup[n] = this.createVector(t.stackPosition, s, 2));
299
+ const i = this.dedupKeyVectors ? this.keyVectorLookup[n] : this.createVector(t.stackPosition, s, 2), r = this.createVector(t.stackPosition + 1, s, 2, i);
300
+ this.stack.splice(t.stackPosition, s << 1), this.stack.push(r);
301
+ }
302
+ sort(t) {
303
+ const n = this.view, s = this.stack;
304
+ function i(c, d) {
305
+ if (c.type !== f.ValueType.KEY || d.type !== f.ValueType.KEY)
306
+ throw `Stack values are not keys ${c} | ${d}. Check if you combined [addKey] with add... method calls properly.`;
307
+ let u, k, O = 0;
308
+ do {
309
+ if (u = n.getUint8(c.offset + O), k = n.getUint8(d.offset + O), k < u)
310
+ return !0;
311
+ if (u < k)
312
+ return !1;
313
+ O += 1;
314
+ } while (u !== 0 && k !== 0);
315
+ return !1;
316
+ }
317
+ function r(c, d, u) {
318
+ if (d === u)
319
+ return;
320
+ const k = c[d], O = c[d + 1];
321
+ c[d] = c[u], c[d + 1] = c[u + 1], c[u] = k, c[u + 1] = O;
322
+ }
323
+ function h() {
324
+ for (let c = t.stackPosition; c < s.length; c += 2) {
325
+ let d = c;
326
+ for (let u = c + 2; u < s.length; u += 2)
327
+ i(s[d], s[u]) && (d = u);
328
+ d !== c && r(s, d, c);
329
+ }
330
+ }
331
+ function a(c, d) {
332
+ if (c.type !== f.ValueType.KEY || d.type !== f.ValueType.KEY)
333
+ throw `Stack values are not keys ${c} | ${d}. Check if you combined [addKey] with add... method calls properly.`;
334
+ if (c.offset === d.offset)
335
+ return !1;
336
+ let u, k, O = 0;
337
+ do {
338
+ if (u = n.getUint8(c.offset + O), k = n.getUint8(d.offset + O), u < k)
339
+ return !0;
340
+ if (k < u)
341
+ return !1;
342
+ O += 1;
343
+ } while (u !== 0 && k !== 0);
344
+ return !1;
345
+ }
346
+ function l(c, d) {
347
+ if (c < d) {
348
+ const u = c + (d - c >> 2) * 2, k = s[u];
349
+ let O = c, w = d;
350
+ do {
351
+ for (; a(s[O], k); )
352
+ O += 2;
353
+ for (; a(k, s[w]); )
354
+ w -= 2;
355
+ O <= w && (r(s, O, w), O += 2, w -= 2);
356
+ } while (O <= w);
357
+ l(c, w), l(O, d);
358
+ }
359
+ }
360
+ let g = !0;
361
+ for (let c = t.stackPosition; c < this.stack.length - 2; c += 2)
362
+ if (i(this.stack[c], this.stack[c + 2])) {
363
+ g = !1;
364
+ break;
365
+ }
366
+ g || (this.stack.length - t.stackPosition > 40 ? l(t.stackPosition, this.stack.length - 2) : h());
367
+ }
368
+ end() {
369
+ if (this.stackPointers.length < 1)
370
+ return;
371
+ const t = this.stackPointers.pop();
372
+ t.isVector ? this.endVector(t) : this.endMap(t);
373
+ }
374
+ createVector(t, n, s, i = null) {
375
+ let r = (0, e.uwidth)(n), h = 1;
376
+ if (i !== null) {
377
+ const u = i.elementWidth(this.offset, 0);
378
+ u > r && (r = u), h += 2;
379
+ }
380
+ let a = f.ValueType.KEY, l = i === null;
381
+ for (let u = t; u < this.stack.length; u += s) {
382
+ const k = this.stack[u].elementWidth(this.offset, u + h);
383
+ k > r && (r = k), u === t ? (a = this.stack[u].type, l = l && (0, W.isTypedVectorElement)(a)) : a !== this.stack[u].type && (l = !1);
384
+ }
385
+ const g = this.align(r), c = l && (0, W.isNumber)(a) && n >= 2 && n <= 4;
386
+ i !== null && (this.writeStackValue(i, g), this.writeUInt(1 << i.width, g)), c || this.writeUInt(n, g);
387
+ const d = this.offset;
388
+ for (let u = t; u < this.stack.length; u += s)
389
+ this.writeStackValue(this.stack[u], g);
390
+ if (!l)
391
+ for (let u = t; u < this.stack.length; u += s)
392
+ this.writeUInt(this.stack[u].storedPackedType(), 1);
393
+ if (i !== null)
394
+ return this.offsetStackValue(d, f.ValueType.MAP, r);
395
+ if (l) {
396
+ const u = (0, W.toTypedVector)(a, c ? n : 0);
397
+ return this.offsetStackValue(d, u, r);
398
+ }
399
+ return this.offsetStackValue(d, f.ValueType.VECTOR, r);
400
+ }
401
+ nullStackValue() {
402
+ return new I.StackValue(this, f.ValueType.NULL, o.BitWidth.WIDTH8);
403
+ }
404
+ boolStackValue(t) {
405
+ return new I.StackValue(this, f.ValueType.BOOL, o.BitWidth.WIDTH8, t);
406
+ }
407
+ intStackValue(t) {
408
+ return new I.StackValue(this, f.ValueType.INT, (0, e.iwidth)(t), t);
409
+ }
410
+ uintStackValue(t) {
411
+ return new I.StackValue(this, f.ValueType.UINT, (0, e.uwidth)(t), t);
412
+ }
413
+ floatStackValue(t) {
414
+ return new I.StackValue(this, f.ValueType.FLOAT, (0, e.fwidth)(t), t);
415
+ }
416
+ offsetStackValue(t, n, s) {
417
+ return new I.StackValue(this, n, s, null, t);
418
+ }
419
+ finishBuffer() {
420
+ if (this.stack.length !== 1)
421
+ throw `Stack has to be exactly 1, but it is ${this.stack.length}. You have to end all started vectors and maps before calling [finish]`;
422
+ const t = this.stack[0], n = this.align(t.elementWidth(this.offset, 0));
423
+ this.writeStackValue(t, n), this.writeUInt(t.storedPackedType(), 1), this.writeUInt(n, 1), this.finished = !0;
424
+ }
425
+ add(t) {
426
+ if (this.integrityCheckOnValueAddition(), typeof t > "u")
427
+ throw "You need to provide a value";
428
+ if (t === null)
429
+ this.stack.push(this.nullStackValue());
430
+ else if (typeof t == "boolean")
431
+ this.stack.push(this.boolStackValue(t));
432
+ else if (typeof t == "bigint")
433
+ this.stack.push(this.intStackValue(t));
434
+ else if (typeof t == "number")
435
+ Number.isInteger(t) ? this.stack.push(this.intStackValue(t)) : this.stack.push(this.floatStackValue(t));
436
+ else if (ArrayBuffer.isView(t))
437
+ this.writeBlob(t.buffer);
438
+ else if (typeof t == "string" || t instanceof String)
439
+ this.writeString(t);
440
+ else if (Array.isArray(t)) {
441
+ this.startVector();
442
+ for (let n = 0; n < t.length; n++)
443
+ this.add(t[n]);
444
+ this.end();
445
+ } else if (typeof t == "object") {
446
+ const n = Object.getOwnPropertyNames(t).sort();
447
+ this.startMap(!0);
448
+ for (let s = 0; s < n.length; s++) {
449
+ const i = n[s];
450
+ this.addKey(i), this.add(t[i]);
451
+ }
452
+ this.end();
453
+ } else
454
+ throw `Unexpected value input ${t}`;
455
+ }
456
+ finish() {
457
+ this.finished || this.finishBuffer();
458
+ const t = this.buffer.slice(0, this.offset);
459
+ return new Uint8Array(t);
460
+ }
461
+ isFinished() {
462
+ return this.finished;
463
+ }
464
+ addKey(t) {
465
+ this.integrityCheckOnKeyAddition(), this.writeKey(t);
466
+ }
467
+ addInt(t, n = !1, s = !1) {
468
+ if (this.integrityCheckOnValueAddition(), !n) {
469
+ this.stack.push(this.intStackValue(t));
470
+ return;
471
+ }
472
+ if (s && Object.prototype.hasOwnProperty.call(this.indirectIntLookup, t)) {
473
+ this.stack.push(this.indirectIntLookup[t]);
474
+ return;
475
+ }
476
+ const i = this.intStackValue(t), r = this.align(i.width), h = this.computeOffset(r), a = this.offset;
477
+ i.writeToBuffer(r);
478
+ const l = this.offsetStackValue(a, f.ValueType.INDIRECT_INT, i.width);
479
+ this.stack.push(l), this.offset = h, s && (this.indirectIntLookup[t] = l);
480
+ }
481
+ addUInt(t, n = !1, s = !1) {
482
+ if (this.integrityCheckOnValueAddition(), !n) {
483
+ this.stack.push(this.uintStackValue(t));
484
+ return;
485
+ }
486
+ if (s && Object.prototype.hasOwnProperty.call(this.indirectUIntLookup, t)) {
487
+ this.stack.push(this.indirectUIntLookup[t]);
488
+ return;
489
+ }
490
+ const i = this.uintStackValue(t), r = this.align(i.width), h = this.computeOffset(r), a = this.offset;
491
+ i.writeToBuffer(r);
492
+ const l = this.offsetStackValue(a, f.ValueType.INDIRECT_UINT, i.width);
493
+ this.stack.push(l), this.offset = h, s && (this.indirectUIntLookup[t] = l);
494
+ }
495
+ addFloat(t, n = !1, s = !1) {
496
+ if (this.integrityCheckOnValueAddition(), !n) {
497
+ this.stack.push(this.floatStackValue(t));
498
+ return;
499
+ }
500
+ if (s && Object.prototype.hasOwnProperty.call(this.indirectFloatLookup, t)) {
501
+ this.stack.push(this.indirectFloatLookup[t]);
502
+ return;
503
+ }
504
+ const i = this.floatStackValue(t), r = this.align(i.width), h = this.computeOffset(r), a = this.offset;
505
+ i.writeToBuffer(r);
506
+ const l = this.offsetStackValue(a, f.ValueType.INDIRECT_FLOAT, i.width);
507
+ this.stack.push(l), this.offset = h, s && (this.indirectFloatLookup[t] = l);
508
+ }
146
509
  }
147
- isMap() {
148
- return e.MAP === this.valueType;
510
+ return N.Builder = V, N;
511
+ }
512
+ var Z = J(), U = {}, _ = {}, Y;
513
+ function Q() {
514
+ if (Y) return _;
515
+ Y = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.keyForIndex = _.diffKeys = _.keyIndex = _.indirect = _.readFloat = _.readUInt = _.readInt = _.validateOffset = void 0;
516
+ const o = L(), e = A(), T = F();
517
+ function f(i, r, h) {
518
+ if (i.byteLength <= r + h || (r & (0, e.toByteWidth)(h) - 1) !== 0)
519
+ throw "Bad offset: " + r + ", width: " + h;
149
520
  }
150
- boolValue() {
151
- return this.isBool() ? C(this.dataView, this.offset, this.parentWidth) > 0 : null;
521
+ _.validateOffset = f;
522
+ function W(i, r, h) {
523
+ return h < 2 ? h < 1 ? i.getInt8(r) : i.getInt16(r, !0) : h < 3 ? i.getInt32(r, !0) : i.setBigInt64 === void 0 ? BigInt(i.getUint32(r, !0)) + (BigInt(i.getUint32(r + 4, !0)) << BigInt(32)) : i.getBigInt64(r, !0);
152
524
  }
153
- intValue() {
154
- return this.valueType === e.INT ? C(this.dataView, this.offset, this.parentWidth) : this.valueType === e.UINT ? c(this.dataView, this.offset, this.parentWidth) : this.valueType === e.INDIRECT_INT ? C(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : this.valueType === e.INDIRECT_UINT ? c(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : null;
525
+ _.readInt = W;
526
+ function I(i, r, h) {
527
+ return h < 2 ? h < 1 ? i.getUint8(r) : i.getUint16(r, !0) : h < 3 ? i.getUint32(r, !0) : i.getBigUint64 === void 0 ? BigInt(i.getUint32(r, !0)) + (BigInt(i.getUint32(r + 4, !0)) << BigInt(32)) : i.getBigUint64(r, !0);
155
528
  }
156
- floatValue() {
157
- return this.valueType === e.FLOAT ? D(this.dataView, this.offset, this.parentWidth) : this.valueType === e.INDIRECT_FLOAT ? D(this.dataView, I(this.dataView, this.offset, this.parentWidth), f(this.byteWidth)) : null;
529
+ _.readUInt = I;
530
+ function V(i, r, h) {
531
+ if (h < o.BitWidth.WIDTH32)
532
+ throw "Bad width: " + h;
533
+ return h === o.BitWidth.WIDTH32 ? i.getFloat32(r, !0) : i.getFloat64(r, !0);
158
534
  }
159
- numericValue() {
160
- return this.floatValue() || this.intValue();
535
+ _.readFloat = V;
536
+ function p(i, r, h) {
537
+ const a = I(i, r, h);
538
+ return r - a;
161
539
  }
162
- stringValue() {
163
- if (this.valueType === e.STRING || this.valueType === e.KEY) {
164
- const i = I(this.dataView, this.offset, this.parentWidth);
165
- return U(new Uint8Array(this.dataView.buffer, i, this.length()));
540
+ _.indirect = p;
541
+ function t(i, r, h, a, l, g) {
542
+ const c = (0, T.toUTF8Array)(i), d = p(r, h, a) - l * 3, u = (0, e.fromByteWidth)(l), k = d - Number(I(r, d, u)), O = Number(I(r, d + l, u));
543
+ let w = 0, D = g - 1;
544
+ for (; w <= D; ) {
545
+ const S = D + w >> 1, P = n(c, S, r, k, O);
546
+ if (P === 0)
547
+ return S;
548
+ P < 0 ? D = S - 1 : w = S + 1;
166
549
  }
167
550
  return null;
168
551
  }
169
- blobValue() {
170
- if (this.isBlob()) {
171
- const i = I(this.dataView, this.offset, this.parentWidth);
172
- return new Uint8Array(this.dataView.buffer, i, this.length());
552
+ _.keyIndex = t;
553
+ function n(i, r, h, a, l) {
554
+ const g = a + r * l, c = g - Number(I(h, g, (0, e.fromByteWidth)(l)));
555
+ for (let d = 0; d < i.length; d++) {
556
+ const u = i[d] - h.getUint8(c + d);
557
+ if (u !== 0)
558
+ return u;
173
559
  }
174
- return null;
560
+ return h.getUint8(c + i.length) === 0 ? 0 : -1;
561
+ }
562
+ _.diffKeys = n;
563
+ function s(i, r, h, a, l) {
564
+ const g = p(r, h, a) - l * 3, c = (0, e.fromByteWidth)(l), d = g - Number(I(r, g, c)), u = Number(I(r, g + l, c)), k = d + i * u, O = k - Number(I(r, k, (0, e.fromByteWidth)(u)));
565
+ let w = 0;
566
+ for (; r.getUint8(O + w) !== 0; )
567
+ w++;
568
+ return (0, T.fromUTF8Array)(new Uint8Array(r.buffer, O, w));
569
+ }
570
+ return _.keyForIndex = s, _;
571
+ }
572
+ var z;
573
+ function X() {
574
+ if (z) return U;
575
+ z = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.Reference = U.toReference = void 0;
576
+ const o = A(), e = C(), T = v(), f = Q(), W = F(), I = L();
577
+ function V(n) {
578
+ const s = n.byteLength;
579
+ if (s < 3)
580
+ throw "Buffer needs to be bigger than 3";
581
+ const i = new DataView(n), r = i.getUint8(s - 1), h = i.getUint8(s - 2), a = (0, o.fromByteWidth)(r), l = s - r - 2;
582
+ return new t(i, l, a, h, "/");
175
583
  }
176
- get(i) {
177
- const n = this.length();
178
- if (Number.isInteger(i) && g(this.valueType)) {
179
- if (i >= n || i < 0)
180
- throw `Key: [${i}] is not applicable on ${this.path} of ${this.valueType} length: ${n}`;
181
- const r = I(this.dataView, this.offset, this.parentWidth), s = r + i * this.byteWidth;
182
- let h = this.dataView.getUint8(r + n * this.byteWidth + i);
183
- if (A(this.valueType)) {
184
- const o = H(this.valueType);
185
- h = b(o, T.WIDTH8);
186
- } else if (a(this.valueType)) {
187
- const o = m(this.valueType);
188
- h = b(o, T.WIDTH8);
584
+ U.toReference = V;
585
+ function p(n, s, i, r, h, a, l, g) {
586
+ const c = (0, f.indirect)(i, r, h), d = c + n * a, u = i.getUint8(c + l * a + n);
587
+ return new t(i, d, (0, o.fromByteWidth)(a), u, `${g}/${s}`);
588
+ }
589
+ class t {
590
+ constructor(s, i, r, h, a) {
591
+ this.dataView = s, this.offset = i, this.parentWidth = r, this.packedType = h, this.path = a, this._length = -1, this.byteWidth = 1 << (h & 3), this.valueType = h >> 2;
592
+ }
593
+ isNull() {
594
+ return this.valueType === e.ValueType.NULL;
595
+ }
596
+ isNumber() {
597
+ return (0, T.isNumber)(this.valueType) || (0, T.isIndirectNumber)(this.valueType);
598
+ }
599
+ isFloat() {
600
+ return e.ValueType.FLOAT === this.valueType || e.ValueType.INDIRECT_FLOAT === this.valueType;
601
+ }
602
+ isInt() {
603
+ return this.isNumber() && !this.isFloat();
604
+ }
605
+ isString() {
606
+ return e.ValueType.STRING === this.valueType || e.ValueType.KEY === this.valueType;
607
+ }
608
+ isBool() {
609
+ return e.ValueType.BOOL === this.valueType;
610
+ }
611
+ isBlob() {
612
+ return e.ValueType.BLOB === this.valueType;
613
+ }
614
+ isVector() {
615
+ return (0, T.isAVector)(this.valueType);
616
+ }
617
+ isMap() {
618
+ return e.ValueType.MAP === this.valueType;
619
+ }
620
+ boolValue() {
621
+ return this.isBool() ? (0, f.readInt)(this.dataView, this.offset, this.parentWidth) > 0 : null;
622
+ }
623
+ intValue() {
624
+ return this.valueType === e.ValueType.INT ? (0, f.readInt)(this.dataView, this.offset, this.parentWidth) : this.valueType === e.ValueType.UINT ? (0, f.readUInt)(this.dataView, this.offset, this.parentWidth) : this.valueType === e.ValueType.INDIRECT_INT ? (0, f.readInt)(this.dataView, (0, f.indirect)(this.dataView, this.offset, this.parentWidth), (0, o.fromByteWidth)(this.byteWidth)) : this.valueType === e.ValueType.INDIRECT_UINT ? (0, f.readUInt)(this.dataView, (0, f.indirect)(this.dataView, this.offset, this.parentWidth), (0, o.fromByteWidth)(this.byteWidth)) : null;
625
+ }
626
+ floatValue() {
627
+ return this.valueType === e.ValueType.FLOAT ? (0, f.readFloat)(this.dataView, this.offset, this.parentWidth) : this.valueType === e.ValueType.INDIRECT_FLOAT ? (0, f.readFloat)(this.dataView, (0, f.indirect)(this.dataView, this.offset, this.parentWidth), (0, o.fromByteWidth)(this.byteWidth)) : null;
628
+ }
629
+ numericValue() {
630
+ return this.floatValue() || this.intValue();
631
+ }
632
+ stringValue() {
633
+ if (this.valueType === e.ValueType.STRING || this.valueType === e.ValueType.KEY) {
634
+ const s = (0, f.indirect)(this.dataView, this.offset, this.parentWidth);
635
+ return (0, W.fromUTF8Array)(new Uint8Array(this.dataView.buffer, s, this.length()));
189
636
  }
190
- return new R(this.dataView, s, f(this.byteWidth), h, `${this.path}[${i}]`);
191
- }
192
- if (typeof i == "string") {
193
- const r = V(i, this.dataView, this.offset, this.parentWidth, this.byteWidth, n);
194
- if (r !== null)
195
- return L(r, i, this.dataView, this.offset, this.parentWidth, this.byteWidth, n, this.path);
196
- }
197
- throw `Key [${i}] is not applicable on ${this.path} of ${this.valueType}`;
198
- }
199
- length() {
200
- let i;
201
- if (this._length > -1)
202
- return this._length;
203
- if (a(this.valueType))
204
- this._length = w(this.valueType);
205
- else if (this.valueType === e.BLOB || this.valueType === e.MAP || g(this.valueType))
206
- this._length = c(this.dataView, I(this.dataView, this.offset, this.parentWidth) - this.byteWidth, f(this.byteWidth));
207
- else if (this.valueType === e.NULL)
208
- this._length = 0;
209
- else if (this.valueType === e.STRING) {
210
- const n = I(this.dataView, this.offset, this.parentWidth);
211
- let r = this.byteWidth;
212
- for (i = c(this.dataView, n - r, f(this.byteWidth)); this.dataView.getInt8(n + i) !== 0; )
213
- r <<= 1, i = c(this.dataView, n - r, f(this.byteWidth));
214
- this._length = i;
215
- } else if (this.valueType === e.KEY) {
216
- const n = I(this.dataView, this.offset, this.parentWidth);
217
- for (i = 1; this.dataView.getInt8(n + i) !== 0; )
218
- i++;
219
- this._length = i;
220
- } else
221
- this._length = 1;
222
- return Number(this._length);
223
- }
224
- toObject() {
225
- const i = this.length();
226
- if (this.isVector()) {
227
- const n = [];
228
- for (let r = 0; r < i; r++)
229
- n.push(this.get(r).toObject());
230
- return n;
637
+ return null;
231
638
  }
232
- if (this.isMap()) {
233
- const n = {};
234
- for (let r = 0; r < i; r++) {
235
- const s = y(r, this.dataView, this.offset, this.parentWidth, this.byteWidth);
236
- n[s] = L(r, s, this.dataView, this.offset, this.parentWidth, this.byteWidth, i, this.path).toObject();
639
+ blobValue() {
640
+ if (this.isBlob()) {
641
+ const s = (0, f.indirect)(this.dataView, this.offset, this.parentWidth);
642
+ return new Uint8Array(this.dataView.buffer, s, this.length());
237
643
  }
238
- return n;
644
+ return null;
645
+ }
646
+ get(s) {
647
+ const i = this.length();
648
+ if (Number.isInteger(s) && (0, T.isAVector)(this.valueType)) {
649
+ if (s >= i || s < 0)
650
+ throw `Key: [${s}] is not applicable on ${this.path} of ${this.valueType} length: ${i}`;
651
+ const r = (0, f.indirect)(this.dataView, this.offset, this.parentWidth), h = r + s * this.byteWidth;
652
+ let a = this.dataView.getUint8(r + i * this.byteWidth + s);
653
+ if ((0, T.isTypedVector)(this.valueType)) {
654
+ const l = (0, T.typedVectorElementType)(this.valueType);
655
+ a = (0, T.packedType)(l, I.BitWidth.WIDTH8);
656
+ } else if ((0, T.isFixedTypedVector)(this.valueType)) {
657
+ const l = (0, T.fixedTypedVectorElementType)(this.valueType);
658
+ a = (0, T.packedType)(l, I.BitWidth.WIDTH8);
659
+ }
660
+ return new t(this.dataView, h, (0, o.fromByteWidth)(this.byteWidth), a, `${this.path}[${s}]`);
661
+ }
662
+ if (typeof s == "string") {
663
+ const r = (0, f.keyIndex)(s, this.dataView, this.offset, this.parentWidth, this.byteWidth, i);
664
+ if (r !== null)
665
+ return p(r, s, this.dataView, this.offset, this.parentWidth, this.byteWidth, i, this.path);
666
+ }
667
+ throw `Key [${s}] is not applicable on ${this.path} of ${this.valueType}`;
668
+ }
669
+ length() {
670
+ let s;
671
+ if (this._length > -1)
672
+ return this._length;
673
+ if ((0, T.isFixedTypedVector)(this.valueType))
674
+ this._length = (0, T.fixedTypedVectorElementSize)(this.valueType);
675
+ else if (this.valueType === e.ValueType.BLOB || this.valueType === e.ValueType.MAP || (0, T.isAVector)(this.valueType))
676
+ this._length = (0, f.readUInt)(this.dataView, (0, f.indirect)(this.dataView, this.offset, this.parentWidth) - this.byteWidth, (0, o.fromByteWidth)(this.byteWidth));
677
+ else if (this.valueType === e.ValueType.NULL)
678
+ this._length = 0;
679
+ else if (this.valueType === e.ValueType.STRING) {
680
+ const i = (0, f.indirect)(this.dataView, this.offset, this.parentWidth);
681
+ let r = this.byteWidth;
682
+ for (s = (0, f.readUInt)(this.dataView, i - r, (0, o.fromByteWidth)(this.byteWidth)); this.dataView.getInt8(i + s) !== 0; )
683
+ r <<= 1, s = (0, f.readUInt)(this.dataView, i - r, (0, o.fromByteWidth)(this.byteWidth));
684
+ this._length = s;
685
+ } else if (this.valueType === e.ValueType.KEY) {
686
+ const i = (0, f.indirect)(this.dataView, this.offset, this.parentWidth);
687
+ for (s = 1; this.dataView.getInt8(i + s) !== 0; )
688
+ s++;
689
+ this._length = s;
690
+ } else
691
+ this._length = 1;
692
+ return Number(this._length);
693
+ }
694
+ toObject() {
695
+ const s = this.length();
696
+ if (this.isVector()) {
697
+ const i = [];
698
+ for (let r = 0; r < s; r++)
699
+ i.push(this.get(r).toObject());
700
+ return i;
701
+ }
702
+ if (this.isMap()) {
703
+ const i = {};
704
+ for (let r = 0; r < s; r++) {
705
+ const h = (0, f.keyForIndex)(r, this.dataView, this.offset, this.parentWidth, this.byteWidth);
706
+ i[h] = p(r, h, this.dataView, this.offset, this.parentWidth, this.byteWidth, s, this.path).toObject();
707
+ }
708
+ return i;
709
+ }
710
+ return this.isNull() ? null : this.isBool() ? this.boolValue() : this.isNumber() ? this.numericValue() : this.blobValue() || this.stringValue();
239
711
  }
240
- return this.isNull() ? null : this.isBool() ? this.boolValue() : this.isNumber() ? this.numericValue() : this.blobValue() || this.stringValue();
241
712
  }
713
+ return U.Reference = t, U;
242
714
  }
715
+ var tt = X();
243
716
  export {
244
- T as B,
245
- e as V,
246
- G as a,
247
- p as b,
248
- P as c,
249
- B as d,
250
- Y as e,
251
- f,
252
- K as g,
253
- $ as h,
254
- M as i,
255
- j,
256
- b as p,
257
- S as t,
258
- x as u
717
+ Z as b,
718
+ tt as r
259
719
  };