buttplug 3.1.0 → 3.2.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 (74) hide show
  1. package/.eslintrc.js +13 -8
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +24 -25
  4. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -16
  5. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js +23 -57
  6. package/dist/main/src/client/ButtplugBrowserWebsocketClientConnector.js.map +1 -1
  7. package/dist/main/src/client/ButtplugClientConnectorException.d.ts +11 -11
  8. package/dist/main/src/client/ButtplugClientConnectorException.js +41 -41
  9. package/dist/main/src/client/ButtplugClientDevice.d.ts +67 -68
  10. package/dist/main/src/client/ButtplugClientDevice.js +324 -324
  11. package/dist/main/src/client/ButtplugClientDevice.js.map +1 -1
  12. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -19
  13. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js +19 -21
  14. package/dist/main/src/client/ButtplugNodeWebsocketClientConnector.js.map +1 -1
  15. package/dist/main/src/client/Client.d.ts +41 -41
  16. package/dist/main/src/client/Client.js +240 -235
  17. package/dist/main/src/client/Client.js.map +1 -1
  18. package/dist/main/src/client/IButtplugClientConnector.d.ts +16 -17
  19. package/dist/main/src/client/IButtplugClientConnector.js +9 -9
  20. package/dist/main/src/core/Exceptions.d.ts +36 -36
  21. package/dist/main/src/core/Exceptions.js +106 -106
  22. package/dist/main/src/core/Logging.d.ts +112 -113
  23. package/dist/main/src/core/Logging.js +170 -170
  24. package/dist/main/src/core/Logging.js.map +1 -1
  25. package/dist/main/src/core/MessageUtils.d.ts +9 -9
  26. package/dist/main/src/core/MessageUtils.js +58 -58
  27. package/dist/main/src/core/Messages.d.ts +275 -275
  28. package/dist/main/src/core/Messages.js +429 -429
  29. package/dist/main/src/core/Messages.js.map +1 -1
  30. package/dist/main/src/index.d.ts +18 -18
  31. package/dist/main/src/index.js +34 -34
  32. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -24
  33. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js +95 -102
  34. package/dist/main/src/utils/ButtplugBrowserWebsocketConnector.js.map +1 -1
  35. package/dist/main/src/utils/ButtplugMessageSorter.d.ts +19 -19
  36. package/dist/main/src/utils/ButtplugMessageSorter.js +81 -81
  37. package/dist/main/src/utils/Utils.d.ts +1 -1
  38. package/dist/main/src/utils/Utils.js +7 -7
  39. package/dist/web/buttplug.js +38 -7616
  40. package/dist/web/buttplug.mjs +2254 -0
  41. package/dist/web/client/ButtplugBrowserWebsocketClientConnector.d.ts +13 -0
  42. package/dist/web/client/ButtplugClientConnectorException.d.ts +11 -0
  43. package/dist/web/client/ButtplugClientDevice.d.ts +67 -0
  44. package/dist/web/client/ButtplugNodeWebsocketClientConnector.d.ts +18 -0
  45. package/dist/web/client/Client.d.ts +41 -0
  46. package/dist/web/client/IButtplugClientConnector.d.ts +16 -0
  47. package/dist/web/core/Exceptions.d.ts +36 -0
  48. package/dist/web/core/Logging.d.ts +112 -0
  49. package/dist/web/core/MessageUtils.d.ts +9 -0
  50. package/dist/web/core/Messages.d.ts +274 -0
  51. package/dist/web/index.d.ts +18 -0
  52. package/dist/web/utils/ButtplugBrowserWebsocketConnector.d.ts +22 -0
  53. package/dist/web/utils/ButtplugMessageSorter.d.ts +19 -0
  54. package/dist/web/utils/Utils.d.ts +1 -0
  55. package/node-test.ts +5 -0
  56. package/package.json +23 -53
  57. package/src/client/ButtplugBrowserWebsocketClientConnector.ts +2 -28
  58. package/src/client/ButtplugClientDevice.ts +2 -2
  59. package/src/client/ButtplugNodeWebsocketClientConnector.ts +0 -2
  60. package/src/client/Client.ts +13 -7
  61. package/src/client/IButtplugClientConnector.ts +5 -5
  62. package/src/core/Logging.ts +1 -1
  63. package/src/core/MessageUtils.ts +1 -1
  64. package/src/utils/ButtplugBrowserWebsocketConnector.ts +14 -20
  65. package/vite.config.ts +26 -0
  66. package/.github/FUNDING.yml +0 -5
  67. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -17
  68. package/.github/workflows/docs.yaml +0 -29
  69. package/azure-pipelines.yml +0 -19
  70. package/dist/web/buttplug.min.js +0 -3
  71. package/dist/web/buttplug.min.js.LICENSE.txt +0 -31
  72. package/dist/web/buttplug.min.js.map +0 -1
  73. package/jest-puppeteer.config.js +0 -5
  74. package/rollup.config.js +0 -55
@@ -0,0 +1,2254 @@
1
+ var nt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
+ function It(r) {
3
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
4
+ }
5
+ var ot = { exports: {} };
6
+ (function(r) {
7
+ var e = Object.prototype.hasOwnProperty, t = "~";
8
+ function n() {
9
+ }
10
+ Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (t = !1));
11
+ function i(l, v, p) {
12
+ this.fn = l, this.context = v, this.once = p || !1;
13
+ }
14
+ function u(l, v, p, m, h) {
15
+ if (typeof p != "function")
16
+ throw new TypeError("The listener must be a function");
17
+ var R = new i(p, m || l, h), E = t ? t + v : v;
18
+ return l._events[E] ? l._events[E].fn ? l._events[E] = [l._events[E], R] : l._events[E].push(R) : (l._events[E] = R, l._eventsCount++), l;
19
+ }
20
+ function a(l, v) {
21
+ --l._eventsCount === 0 ? l._events = new n() : delete l._events[v];
22
+ }
23
+ function f() {
24
+ this._events = new n(), this._eventsCount = 0;
25
+ }
26
+ f.prototype.eventNames = function() {
27
+ var v = [], p, m;
28
+ if (this._eventsCount === 0)
29
+ return v;
30
+ for (m in p = this._events)
31
+ e.call(p, m) && v.push(t ? m.slice(1) : m);
32
+ return Object.getOwnPropertySymbols ? v.concat(Object.getOwnPropertySymbols(p)) : v;
33
+ }, f.prototype.listeners = function(v) {
34
+ var p = t ? t + v : v, m = this._events[p];
35
+ if (!m)
36
+ return [];
37
+ if (m.fn)
38
+ return [m.fn];
39
+ for (var h = 0, R = m.length, E = new Array(R); h < R; h++)
40
+ E[h] = m[h].fn;
41
+ return E;
42
+ }, f.prototype.listenerCount = function(v) {
43
+ var p = t ? t + v : v, m = this._events[p];
44
+ return m ? m.fn ? 1 : m.length : 0;
45
+ }, f.prototype.emit = function(v, p, m, h, R, E) {
46
+ var $ = t ? t + v : v;
47
+ if (!this._events[$])
48
+ return !1;
49
+ var g = this._events[$], I = arguments.length, O, S;
50
+ if (g.fn) {
51
+ switch (g.once && this.removeListener(v, g.fn, void 0, !0), I) {
52
+ case 1:
53
+ return g.fn.call(g.context), !0;
54
+ case 2:
55
+ return g.fn.call(g.context, p), !0;
56
+ case 3:
57
+ return g.fn.call(g.context, p, m), !0;
58
+ case 4:
59
+ return g.fn.call(g.context, p, m, h), !0;
60
+ case 5:
61
+ return g.fn.call(g.context, p, m, h, R), !0;
62
+ case 6:
63
+ return g.fn.call(g.context, p, m, h, R, E), !0;
64
+ }
65
+ for (S = 1, O = new Array(I - 1); S < I; S++)
66
+ O[S - 1] = arguments[S];
67
+ g.fn.apply(g.context, O);
68
+ } else {
69
+ var W = g.length, C;
70
+ for (S = 0; S < W; S++)
71
+ switch (g[S].once && this.removeListener(v, g[S].fn, void 0, !0), I) {
72
+ case 1:
73
+ g[S].fn.call(g[S].context);
74
+ break;
75
+ case 2:
76
+ g[S].fn.call(g[S].context, p);
77
+ break;
78
+ case 3:
79
+ g[S].fn.call(g[S].context, p, m);
80
+ break;
81
+ case 4:
82
+ g[S].fn.call(g[S].context, p, m, h);
83
+ break;
84
+ default:
85
+ if (!O)
86
+ for (C = 1, O = new Array(I - 1); C < I; C++)
87
+ O[C - 1] = arguments[C];
88
+ g[S].fn.apply(g[S].context, O);
89
+ }
90
+ }
91
+ return !0;
92
+ }, f.prototype.on = function(v, p, m) {
93
+ return u(this, v, p, m, !1);
94
+ }, f.prototype.once = function(v, p, m) {
95
+ return u(this, v, p, m, !0);
96
+ }, f.prototype.removeListener = function(v, p, m, h) {
97
+ var R = t ? t + v : v;
98
+ if (!this._events[R])
99
+ return this;
100
+ if (!p)
101
+ return a(this, R), this;
102
+ var E = this._events[R];
103
+ if (E.fn)
104
+ E.fn === p && (!h || E.once) && (!m || E.context === m) && a(this, R);
105
+ else {
106
+ for (var $ = 0, g = [], I = E.length; $ < I; $++)
107
+ (E[$].fn !== p || h && !E[$].once || m && E[$].context !== m) && g.push(E[$]);
108
+ g.length ? this._events[R] = g.length === 1 ? g[0] : g : a(this, R);
109
+ }
110
+ return this;
111
+ }, f.prototype.removeAllListeners = function(v) {
112
+ var p;
113
+ return v ? (p = t ? t + v : v, this._events[p] && a(this, p)) : (this._events = new n(), this._eventsCount = 0), this;
114
+ }, f.prototype.off = f.prototype.removeListener, f.prototype.addListener = f.prototype.on, f.prefixed = t, f.EventEmitter = f, r.exports = f;
115
+ })(ot);
116
+ var Rt = ot.exports;
117
+ const ye = /* @__PURE__ */ It(Rt);
118
+ /*!
119
+ * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
120
+ * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
121
+ * project root for full license information.
122
+ *
123
+ * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
124
+ */
125
+ var at = /* @__PURE__ */ ((r) => (r[r.Off = 0] = "Off", r[r.Error = 1] = "Error", r[r.Warn = 2] = "Warn", r[r.Info = 3] = "Info", r[r.Debug = 4] = "Debug", r[r.Trace = 5] = "Trace", r))(at || {});
126
+ class Dt {
127
+ /**
128
+ * @param logMessage Log message.
129
+ * @param logLevel: Log severity level.
130
+ */
131
+ constructor(e, t) {
132
+ const n = /* @__PURE__ */ new Date(), i = n.getHours(), u = n.getMinutes(), a = n.getSeconds();
133
+ this.timestamp = `${i}:${u}:${a}`, this.logMessage = e, this.logLevel = t;
134
+ }
135
+ /**
136
+ * Returns the log message.
137
+ */
138
+ get Message() {
139
+ return this.logMessage;
140
+ }
141
+ /**
142
+ * Returns the log message level.
143
+ */
144
+ get LogLevel() {
145
+ return this.logLevel;
146
+ }
147
+ /**
148
+ * Returns the log message timestamp.
149
+ */
150
+ get Timestamp() {
151
+ return this.timestamp;
152
+ }
153
+ /**
154
+ * Returns a formatted string with timestamp, level, and message.
155
+ */
156
+ get FormattedMessage() {
157
+ return `${at[this.logLevel]} : ${this.timestamp} : ${this.logMessage}`;
158
+ }
159
+ }
160
+ const ct = class pe extends ye {
161
+ /**
162
+ * Constructor. Can only be called internally since we regulate ButtplugLogger
163
+ * ownership.
164
+ */
165
+ constructor() {
166
+ super(), this.maximumConsoleLogLevel = 0, this.maximumEventLogLevel = 0;
167
+ }
168
+ /**
169
+ * Returns the stored static instance of the logger, creating one if it
170
+ * doesn't currently exist.
171
+ */
172
+ static get Logger() {
173
+ return pe.sLogger === void 0 && (pe.sLogger = new pe()), this.sLogger;
174
+ }
175
+ /**
176
+ * Set the maximum log level to output to console.
177
+ */
178
+ get MaximumConsoleLogLevel() {
179
+ return this.maximumConsoleLogLevel;
180
+ }
181
+ /**
182
+ * Get the maximum log level to output to console.
183
+ */
184
+ set MaximumConsoleLogLevel(e) {
185
+ this.maximumConsoleLogLevel = e;
186
+ }
187
+ /**
188
+ * Set the global maximum log level
189
+ */
190
+ get MaximumEventLogLevel() {
191
+ return this.maximumEventLogLevel;
192
+ }
193
+ /**
194
+ * Get the global maximum log level
195
+ */
196
+ set MaximumEventLogLevel(e) {
197
+ this.maximumEventLogLevel = e;
198
+ }
199
+ /**
200
+ * Log new message at Error level.
201
+ */
202
+ Error(e) {
203
+ this.AddLogMessage(
204
+ e,
205
+ 1
206
+ /* Error */
207
+ );
208
+ }
209
+ /**
210
+ * Log new message at Warn level.
211
+ */
212
+ Warn(e) {
213
+ this.AddLogMessage(
214
+ e,
215
+ 2
216
+ /* Warn */
217
+ );
218
+ }
219
+ /**
220
+ * Log new message at Info level.
221
+ */
222
+ Info(e) {
223
+ this.AddLogMessage(
224
+ e,
225
+ 3
226
+ /* Info */
227
+ );
228
+ }
229
+ /**
230
+ * Log new message at Debug level.
231
+ */
232
+ Debug(e) {
233
+ this.AddLogMessage(
234
+ e,
235
+ 4
236
+ /* Debug */
237
+ );
238
+ }
239
+ /**
240
+ * Log new message at Trace level.
241
+ */
242
+ Trace(e) {
243
+ this.AddLogMessage(
244
+ e,
245
+ 5
246
+ /* Trace */
247
+ );
248
+ }
249
+ /**
250
+ * Checks to see if message should be logged, and if so, adds message to the
251
+ * log buffer. May also print message and emit event.
252
+ */
253
+ AddLogMessage(e, t) {
254
+ if (t > this.maximumEventLogLevel && t > this.maximumConsoleLogLevel)
255
+ return;
256
+ const n = new Dt(e, t);
257
+ t <= this.maximumConsoleLogLevel && console.log(n.FormattedMessage), t <= this.maximumEventLogLevel && this.emit("log", n);
258
+ }
259
+ };
260
+ ct.sLogger = void 0;
261
+ let Tt = ct;
262
+ var b;
263
+ (function(r) {
264
+ r[r.PLAIN_TO_CLASS = 0] = "PLAIN_TO_CLASS", r[r.CLASS_TO_PLAIN = 1] = "CLASS_TO_PLAIN", r[r.CLASS_TO_CLASS = 2] = "CLASS_TO_CLASS";
265
+ })(b || (b = {}));
266
+ var Nt = (
267
+ /** @class */
268
+ function() {
269
+ function r() {
270
+ this._typeMetadatas = /* @__PURE__ */ new Map(), this._transformMetadatas = /* @__PURE__ */ new Map(), this._exposeMetadatas = /* @__PURE__ */ new Map(), this._excludeMetadatas = /* @__PURE__ */ new Map(), this._ancestorsMap = /* @__PURE__ */ new Map();
271
+ }
272
+ return r.prototype.addTypeMetadata = function(e) {
273
+ this._typeMetadatas.has(e.target) || this._typeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._typeMetadatas.get(e.target).set(e.propertyName, e);
274
+ }, r.prototype.addTransformMetadata = function(e) {
275
+ this._transformMetadatas.has(e.target) || this._transformMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._transformMetadatas.get(e.target).has(e.propertyName) || this._transformMetadatas.get(e.target).set(e.propertyName, []), this._transformMetadatas.get(e.target).get(e.propertyName).push(e);
276
+ }, r.prototype.addExposeMetadata = function(e) {
277
+ this._exposeMetadatas.has(e.target) || this._exposeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._exposeMetadatas.get(e.target).set(e.propertyName, e);
278
+ }, r.prototype.addExcludeMetadata = function(e) {
279
+ this._excludeMetadatas.has(e.target) || this._excludeMetadatas.set(e.target, /* @__PURE__ */ new Map()), this._excludeMetadatas.get(e.target).set(e.propertyName, e);
280
+ }, r.prototype.findTransformMetadatas = function(e, t, n) {
281
+ return this.findMetadatas(this._transformMetadatas, e, t).filter(function(i) {
282
+ return !i.options || i.options.toClassOnly === !0 && i.options.toPlainOnly === !0 ? !0 : i.options.toClassOnly === !0 ? n === b.CLASS_TO_CLASS || n === b.PLAIN_TO_CLASS : i.options.toPlainOnly === !0 ? n === b.CLASS_TO_PLAIN : !0;
283
+ });
284
+ }, r.prototype.findExcludeMetadata = function(e, t) {
285
+ return this.findMetadata(this._excludeMetadatas, e, t);
286
+ }, r.prototype.findExposeMetadata = function(e, t) {
287
+ return this.findMetadata(this._exposeMetadatas, e, t);
288
+ }, r.prototype.findExposeMetadataByCustomName = function(e, t) {
289
+ return this.getExposedMetadatas(e).find(function(n) {
290
+ return n.options && n.options.name === t;
291
+ });
292
+ }, r.prototype.findTypeMetadata = function(e, t) {
293
+ return this.findMetadata(this._typeMetadatas, e, t);
294
+ }, r.prototype.getStrategy = function(e) {
295
+ var t = this._excludeMetadatas.get(e), n = t && t.get(void 0), i = this._exposeMetadatas.get(e), u = i && i.get(void 0);
296
+ return n && u || !n && !u ? "none" : n ? "excludeAll" : "exposeAll";
297
+ }, r.prototype.getExposedMetadatas = function(e) {
298
+ return this.getMetadata(this._exposeMetadatas, e);
299
+ }, r.prototype.getExcludedMetadatas = function(e) {
300
+ return this.getMetadata(this._excludeMetadatas, e);
301
+ }, r.prototype.getExposedProperties = function(e, t) {
302
+ return this.getExposedMetadatas(e).filter(function(n) {
303
+ return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === b.CLASS_TO_CLASS || t === b.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === b.CLASS_TO_PLAIN : !0;
304
+ }).map(function(n) {
305
+ return n.propertyName;
306
+ });
307
+ }, r.prototype.getExcludedProperties = function(e, t) {
308
+ return this.getExcludedMetadatas(e).filter(function(n) {
309
+ return !n.options || n.options.toClassOnly === !0 && n.options.toPlainOnly === !0 ? !0 : n.options.toClassOnly === !0 ? t === b.CLASS_TO_CLASS || t === b.PLAIN_TO_CLASS : n.options.toPlainOnly === !0 ? t === b.CLASS_TO_PLAIN : !0;
310
+ }).map(function(n) {
311
+ return n.propertyName;
312
+ });
313
+ }, r.prototype.clear = function() {
314
+ this._typeMetadatas.clear(), this._exposeMetadatas.clear(), this._excludeMetadatas.clear(), this._ancestorsMap.clear();
315
+ }, r.prototype.getMetadata = function(e, t) {
316
+ var n = e.get(t), i;
317
+ n && (i = Array.from(n.values()).filter(function(m) {
318
+ return m.propertyName !== void 0;
319
+ }));
320
+ for (var u = [], a = 0, f = this.getAncestors(t); a < f.length; a++) {
321
+ var l = f[a], v = e.get(l);
322
+ if (v) {
323
+ var p = Array.from(v.values()).filter(function(m) {
324
+ return m.propertyName !== void 0;
325
+ });
326
+ u.push.apply(u, p);
327
+ }
328
+ }
329
+ return u.concat(i || []);
330
+ }, r.prototype.findMetadata = function(e, t, n) {
331
+ var i = e.get(t);
332
+ if (i) {
333
+ var u = i.get(n);
334
+ if (u)
335
+ return u;
336
+ }
337
+ for (var a = 0, f = this.getAncestors(t); a < f.length; a++) {
338
+ var l = f[a], v = e.get(l);
339
+ if (v) {
340
+ var p = v.get(n);
341
+ if (p)
342
+ return p;
343
+ }
344
+ }
345
+ }, r.prototype.findMetadatas = function(e, t, n) {
346
+ var i = e.get(t), u;
347
+ i && (u = i.get(n));
348
+ for (var a = [], f = 0, l = this.getAncestors(t); f < l.length; f++) {
349
+ var v = l[f], p = e.get(v);
350
+ p && p.has(n) && a.push.apply(a, p.get(n));
351
+ }
352
+ return a.slice().reverse().concat((u || []).slice().reverse());
353
+ }, r.prototype.getAncestors = function(e) {
354
+ if (!e)
355
+ return [];
356
+ if (!this._ancestorsMap.has(e)) {
357
+ for (var t = [], n = Object.getPrototypeOf(e.prototype.constructor); typeof n.prototype < "u"; n = Object.getPrototypeOf(n.prototype.constructor))
358
+ t.push(n);
359
+ this._ancestorsMap.set(e, t);
360
+ }
361
+ return this._ancestorsMap.get(e);
362
+ }, r;
363
+ }()
364
+ ), F = new Nt();
365
+ function Pt() {
366
+ if (typeof globalThis < "u")
367
+ return globalThis;
368
+ if (typeof global < "u")
369
+ return global;
370
+ if (typeof window < "u")
371
+ return window;
372
+ if (typeof self < "u")
373
+ return self;
374
+ }
375
+ function kt(r) {
376
+ return r !== null && typeof r == "object" && typeof r.then == "function";
377
+ }
378
+ var rt = globalThis && globalThis.__spreadArray || function(r, e, t) {
379
+ if (t || arguments.length === 2)
380
+ for (var n = 0, i = e.length, u; n < i; n++)
381
+ (u || !(n in e)) && (u || (u = Array.prototype.slice.call(e, 0, n)), u[n] = e[n]);
382
+ return r.concat(u || Array.prototype.slice.call(e));
383
+ };
384
+ function jt(r) {
385
+ var e = new r();
386
+ return !(e instanceof Set) && !("push" in e) ? [] : e;
387
+ }
388
+ var ie = (
389
+ /** @class */
390
+ function() {
391
+ function r(e, t) {
392
+ this.transformationType = e, this.options = t, this.recursionStack = /* @__PURE__ */ new Set();
393
+ }
394
+ return r.prototype.transform = function(e, t, n, i, u, a) {
395
+ var f = this;
396
+ if (a === void 0 && (a = 0), Array.isArray(t) || t instanceof Set) {
397
+ var l = i && this.transformationType === b.PLAIN_TO_CLASS ? jt(i) : [];
398
+ return t.forEach(function(g, I) {
399
+ var O = e ? e[I] : void 0;
400
+ if (!f.options.enableCircularCheck || !f.isCircular(g)) {
401
+ var S = void 0;
402
+ if (typeof n != "function" && n && n.options && n.options.discriminator && n.options.discriminator.property && n.options.discriminator.subTypes) {
403
+ if (f.transformationType === b.PLAIN_TO_CLASS) {
404
+ S = n.options.discriminator.subTypes.find(function(Y) {
405
+ return Y.name === g[n.options.discriminator.property];
406
+ });
407
+ var W = { newObject: l, object: g, property: void 0 }, C = n.typeFunction(W);
408
+ S === void 0 ? S = C : S = S.value, n.options.keepDiscriminatorProperty || delete g[n.options.discriminator.property];
409
+ }
410
+ f.transformationType === b.CLASS_TO_CLASS && (S = g.constructor), f.transformationType === b.CLASS_TO_PLAIN && (g[n.options.discriminator.property] = n.options.discriminator.subTypes.find(function(Y) {
411
+ return Y.value === g.constructor;
412
+ }).name);
413
+ } else
414
+ S = n;
415
+ var k = f.transform(O, g, S, void 0, g instanceof Map, a + 1);
416
+ l instanceof Set ? l.add(k) : l.push(k);
417
+ } else
418
+ f.transformationType === b.CLASS_TO_CLASS && (l instanceof Set ? l.add(g) : l.push(g));
419
+ }), l;
420
+ } else {
421
+ if (n === String && !u)
422
+ return t == null ? t : String(t);
423
+ if (n === Number && !u)
424
+ return t == null ? t : Number(t);
425
+ if (n === Boolean && !u)
426
+ return t == null ? t : !!t;
427
+ if ((n === Date || t instanceof Date) && !u)
428
+ return t instanceof Date ? new Date(t.valueOf()) : t == null ? t : new Date(t);
429
+ if (Pt().Buffer && (n === Buffer || t instanceof Buffer) && !u)
430
+ return t == null ? t : Buffer.from(t);
431
+ if (kt(t) && !u)
432
+ return new Promise(function(g, I) {
433
+ t.then(function(O) {
434
+ return g(f.transform(void 0, O, n, void 0, void 0, a + 1));
435
+ }, I);
436
+ });
437
+ if (!u && t !== null && typeof t == "object" && typeof t.then == "function")
438
+ return t;
439
+ if (typeof t == "object" && t !== null) {
440
+ !n && t.constructor !== Object && (!Array.isArray(t) && t.constructor === Array || (n = t.constructor)), !n && e && (n = e.constructor), this.options.enableCircularCheck && this.recursionStack.add(t);
441
+ var v = this.getKeys(n, t, u), p = e || {};
442
+ !e && (this.transformationType === b.PLAIN_TO_CLASS || this.transformationType === b.CLASS_TO_CLASS) && (u ? p = /* @__PURE__ */ new Map() : n ? p = new n() : p = {});
443
+ for (var m = function(g) {
444
+ if (g === "__proto__" || g === "constructor")
445
+ return "continue";
446
+ var I = g, O = g, S = g;
447
+ if (!h.options.ignoreDecorators && n) {
448
+ if (h.transformationType === b.PLAIN_TO_CLASS) {
449
+ var W = F.findExposeMetadataByCustomName(n, g);
450
+ W && (S = W.propertyName, O = W.propertyName);
451
+ } else if (h.transformationType === b.CLASS_TO_PLAIN || h.transformationType === b.CLASS_TO_CLASS) {
452
+ var W = F.findExposeMetadata(n, g);
453
+ W && W.options && W.options.name && (O = W.options.name);
454
+ }
455
+ }
456
+ var C = void 0;
457
+ h.transformationType === b.PLAIN_TO_CLASS ? C = t[I] : t instanceof Map ? C = t.get(I) : t[I] instanceof Function ? C = t[I]() : C = t[I];
458
+ var k = void 0, Y = C instanceof Map;
459
+ if (n && u)
460
+ k = n;
461
+ else if (n) {
462
+ var T = F.findTypeMetadata(n, S);
463
+ if (T) {
464
+ var Se = { newObject: p, object: t, property: S }, de = T.typeFunction ? T.typeFunction(Se) : T.reflectedType;
465
+ T.options && T.options.discriminator && T.options.discriminator.property && T.options.discriminator.subTypes ? t[I] instanceof Array ? k = T : (h.transformationType === b.PLAIN_TO_CLASS && (k = T.options.discriminator.subTypes.find(function(q) {
466
+ if (C && C instanceof Object && T.options.discriminator.property in C)
467
+ return q.name === C[T.options.discriminator.property];
468
+ }), k === void 0 ? k = de : k = k.value, T.options.keepDiscriminatorProperty || C && C instanceof Object && T.options.discriminator.property in C && delete C[T.options.discriminator.property]), h.transformationType === b.CLASS_TO_CLASS && (k = C.constructor), h.transformationType === b.CLASS_TO_PLAIN && C && (C[T.options.discriminator.property] = T.options.discriminator.subTypes.find(function(q) {
469
+ return q.value === C.constructor;
470
+ }).name)) : k = de, Y = Y || T.reflectedType === Map;
471
+ } else if (h.options.targetMaps)
472
+ h.options.targetMaps.filter(function(q) {
473
+ return q.target === n && !!q.properties[S];
474
+ }).forEach(function(q) {
475
+ return k = q.properties[S];
476
+ });
477
+ else if (h.options.enableImplicitConversion && h.transformationType === b.PLAIN_TO_CLASS) {
478
+ var he = Reflect.getMetadata("design:type", n.prototype, S);
479
+ he && (k = he);
480
+ }
481
+ }
482
+ var K = Array.isArray(t[I]) ? h.getReflectedType(n, S) : void 0, ue = e ? e[I] : void 0;
483
+ if (p.constructor.prototype) {
484
+ var ne = Object.getOwnPropertyDescriptor(p.constructor.prototype, O);
485
+ if ((h.transformationType === b.PLAIN_TO_CLASS || h.transformationType === b.CLASS_TO_CLASS) && // eslint-disable-next-line @typescript-eslint/unbound-method
486
+ (ne && !ne.set || p[O] instanceof Function))
487
+ return "continue";
488
+ }
489
+ if (!h.options.enableCircularCheck || !h.isCircular(C)) {
490
+ var te = h.transformationType === b.PLAIN_TO_CLASS ? O : g, L = void 0;
491
+ h.transformationType === b.CLASS_TO_PLAIN ? (L = t[te], L = h.applyCustomTransformations(L, n, te, t, h.transformationType), L = t[te] === L ? C : L, L = h.transform(ue, L, k, K, Y, a + 1)) : C === void 0 && h.options.exposeDefaultValues ? L = p[O] : (L = h.transform(ue, C, k, K, Y, a + 1), L = h.applyCustomTransformations(L, n, te, t, h.transformationType)), (L !== void 0 || h.options.exposeUnsetFields) && (p instanceof Map ? p.set(O, L) : p[O] = L);
492
+ } else if (h.transformationType === b.CLASS_TO_CLASS) {
493
+ var L = C;
494
+ L = h.applyCustomTransformations(L, n, g, t, h.transformationType), (L !== void 0 || h.options.exposeUnsetFields) && (p instanceof Map ? p.set(O, L) : p[O] = L);
495
+ }
496
+ }, h = this, R = 0, E = v; R < E.length; R++) {
497
+ var $ = E[R];
498
+ m($);
499
+ }
500
+ return this.options.enableCircularCheck && this.recursionStack.delete(t), p;
501
+ } else
502
+ return t;
503
+ }
504
+ }, r.prototype.applyCustomTransformations = function(e, t, n, i, u) {
505
+ var a = this, f = F.findTransformMetadatas(t, n, this.transformationType);
506
+ return this.options.version !== void 0 && (f = f.filter(function(l) {
507
+ return l.options ? a.checkVersion(l.options.since, l.options.until) : !0;
508
+ })), this.options.groups && this.options.groups.length ? f = f.filter(function(l) {
509
+ return l.options ? a.checkGroups(l.options.groups) : !0;
510
+ }) : f = f.filter(function(l) {
511
+ return !l.options || !l.options.groups || !l.options.groups.length;
512
+ }), f.forEach(function(l) {
513
+ e = l.transformFn({ value: e, key: n, obj: i, type: u, options: a.options });
514
+ }), e;
515
+ }, r.prototype.isCircular = function(e) {
516
+ return this.recursionStack.has(e);
517
+ }, r.prototype.getReflectedType = function(e, t) {
518
+ if (e) {
519
+ var n = F.findTypeMetadata(e, t);
520
+ return n ? n.reflectedType : void 0;
521
+ }
522
+ }, r.prototype.getKeys = function(e, t, n) {
523
+ var i = this, u = F.getStrategy(e);
524
+ u === "none" && (u = this.options.strategy || "exposeAll");
525
+ var a = [];
526
+ if ((u === "exposeAll" || n) && (t instanceof Map ? a = Array.from(t.keys()) : a = Object.keys(t)), n)
527
+ return a;
528
+ if (this.options.ignoreDecorators && this.options.excludeExtraneousValues && e) {
529
+ var f = F.getExposedProperties(e, this.transformationType), l = F.getExcludedProperties(e, this.transformationType);
530
+ a = rt(rt([], f, !0), l, !0);
531
+ }
532
+ if (!this.options.ignoreDecorators && e) {
533
+ var f = F.getExposedProperties(e, this.transformationType);
534
+ this.transformationType === b.PLAIN_TO_CLASS && (f = f.map(function(m) {
535
+ var h = F.findExposeMetadata(e, m);
536
+ return h && h.options && h.options.name ? h.options.name : m;
537
+ })), this.options.excludeExtraneousValues ? a = f : a = a.concat(f);
538
+ var v = F.getExcludedProperties(e, this.transformationType);
539
+ v.length > 0 && (a = a.filter(function(m) {
540
+ return !v.includes(m);
541
+ })), this.options.version !== void 0 && (a = a.filter(function(m) {
542
+ var h = F.findExposeMetadata(e, m);
543
+ return !h || !h.options ? !0 : i.checkVersion(h.options.since, h.options.until);
544
+ })), this.options.groups && this.options.groups.length ? a = a.filter(function(m) {
545
+ var h = F.findExposeMetadata(e, m);
546
+ return !h || !h.options ? !0 : i.checkGroups(h.options.groups);
547
+ }) : a = a.filter(function(m) {
548
+ var h = F.findExposeMetadata(e, m);
549
+ return !h || !h.options || !h.options.groups || !h.options.groups.length;
550
+ });
551
+ }
552
+ return this.options.excludePrefixes && this.options.excludePrefixes.length && (a = a.filter(function(p) {
553
+ return i.options.excludePrefixes.every(function(m) {
554
+ return p.substr(0, m.length) !== m;
555
+ });
556
+ })), a = a.filter(function(p, m, h) {
557
+ return h.indexOf(p) === m;
558
+ }), a;
559
+ }, r.prototype.checkVersion = function(e, t) {
560
+ var n = !0;
561
+ return n && e && (n = this.options.version >= e), n && t && (n = this.options.version < t), n;
562
+ }, r.prototype.checkGroups = function(e) {
563
+ return e ? this.options.groups.some(function(t) {
564
+ return e.includes(t);
565
+ }) : !0;
566
+ }, r;
567
+ }()
568
+ ), oe = {
569
+ enableCircularCheck: !1,
570
+ enableImplicitConversion: !1,
571
+ excludeExtraneousValues: !1,
572
+ excludePrefixes: void 0,
573
+ exposeDefaultValues: !1,
574
+ exposeUnsetFields: !0,
575
+ groups: void 0,
576
+ ignoreDecorators: !1,
577
+ strategy: void 0,
578
+ targetMaps: void 0,
579
+ version: void 0
580
+ }, G = globalThis && globalThis.__assign || function() {
581
+ return G = Object.assign || function(r) {
582
+ for (var e, t = 1, n = arguments.length; t < n; t++) {
583
+ e = arguments[t];
584
+ for (var i in e)
585
+ Object.prototype.hasOwnProperty.call(e, i) && (r[i] = e[i]);
586
+ }
587
+ return r;
588
+ }, G.apply(this, arguments);
589
+ }, Bt = (
590
+ /** @class */
591
+ function() {
592
+ function r() {
593
+ }
594
+ return r.prototype.instanceToPlain = function(e, t) {
595
+ var n = new ie(b.CLASS_TO_PLAIN, G(G({}, oe), t));
596
+ return n.transform(void 0, e, void 0, void 0, void 0, void 0);
597
+ }, r.prototype.classToPlainFromExist = function(e, t, n) {
598
+ var i = new ie(b.CLASS_TO_PLAIN, G(G({}, oe), n));
599
+ return i.transform(t, e, void 0, void 0, void 0, void 0);
600
+ }, r.prototype.plainToInstance = function(e, t, n) {
601
+ var i = new ie(b.PLAIN_TO_CLASS, G(G({}, oe), n));
602
+ return i.transform(void 0, t, e, void 0, void 0, void 0);
603
+ }, r.prototype.plainToClassFromExist = function(e, t, n) {
604
+ var i = new ie(b.PLAIN_TO_CLASS, G(G({}, oe), n));
605
+ return i.transform(e, t, void 0, void 0, void 0, void 0);
606
+ }, r.prototype.instanceToInstance = function(e, t) {
607
+ var n = new ie(b.CLASS_TO_CLASS, G(G({}, oe), t));
608
+ return n.transform(void 0, e, void 0, void 0, void 0, void 0);
609
+ }, r.prototype.classToClassFromExist = function(e, t, n) {
610
+ var i = new ie(b.CLASS_TO_CLASS, G(G({}, oe), n));
611
+ return i.transform(t, e, void 0, void 0, void 0, void 0);
612
+ }, r.prototype.serialize = function(e, t) {
613
+ return JSON.stringify(this.instanceToPlain(e, t));
614
+ }, r.prototype.deserialize = function(e, t, n) {
615
+ var i = JSON.parse(t);
616
+ return this.plainToInstance(e, i, n);
617
+ }, r.prototype.deserializeArray = function(e, t, n) {
618
+ var i = JSON.parse(t);
619
+ return this.plainToInstance(e, i, n);
620
+ }, r;
621
+ }()
622
+ );
623
+ function Oe(r, e) {
624
+ return e === void 0 && (e = {}), function(t, n) {
625
+ var i = Reflect.getMetadata("design:type", t, n);
626
+ F.addTypeMetadata({
627
+ target: t.constructor,
628
+ propertyName: n,
629
+ reflectedType: i,
630
+ typeFunction: r,
631
+ options: e
632
+ });
633
+ };
634
+ }
635
+ var ut = new Bt();
636
+ function $t(r, e) {
637
+ return ut.instanceToPlain(r, e);
638
+ }
639
+ function Ft(r, e, t) {
640
+ return ut.plainToInstance(r, e, t);
641
+ }
642
+ /*! *****************************************************************************
643
+ Copyright (C) Microsoft. All rights reserved.
644
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
645
+ this file except in compliance with the License. You may obtain a copy of the
646
+ License at http://www.apache.org/licenses/LICENSE-2.0
647
+
648
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
649
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
650
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
651
+ MERCHANTABLITY OR NON-INFRINGEMENT.
652
+
653
+ See the Apache Version 2.0 License for specific language governing permissions
654
+ and limitations under the License.
655
+ ***************************************************************************** */
656
+ var st;
657
+ (function(r) {
658
+ (function(e) {
659
+ var t = typeof nt == "object" ? nt : typeof self == "object" ? self : typeof this == "object" ? this : Function("return this;")(), n = i(r);
660
+ typeof t.Reflect > "u" ? t.Reflect = r : n = i(t.Reflect, n), e(n);
661
+ function i(u, a) {
662
+ return function(f, l) {
663
+ typeof u[f] != "function" && Object.defineProperty(u, f, { configurable: !0, writable: !0, value: l }), a && a(f, l);
664
+ };
665
+ }
666
+ })(function(e) {
667
+ var t = Object.prototype.hasOwnProperty, n = typeof Symbol == "function", i = n && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", u = n && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", a = typeof Object.create == "function", f = { __proto__: [] } instanceof Array, l = !a && !f, v = {
668
+ // create an object in dictionary mode (a.k.a. "slow" mode in v8)
669
+ create: a ? function() {
670
+ return be(/* @__PURE__ */ Object.create(null));
671
+ } : f ? function() {
672
+ return be({ __proto__: null });
673
+ } : function() {
674
+ return be({});
675
+ },
676
+ has: l ? function(s, o) {
677
+ return t.call(s, o);
678
+ } : function(s, o) {
679
+ return o in s;
680
+ },
681
+ get: l ? function(s, o) {
682
+ return t.call(s, o) ? s[o] : void 0;
683
+ } : function(s, o) {
684
+ return s[o];
685
+ }
686
+ }, p = Object.getPrototypeOf(Function), m = typeof process == "object" && process.env && process.env.REFLECT_METADATA_USE_MAP_POLYFILL === "true", h = !m && typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : Et(), R = !m && typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Ot(), E = !m && typeof WeakMap == "function" ? WeakMap : Lt(), $ = new E();
687
+ function g(s, o, c, d) {
688
+ if (N(c)) {
689
+ if (!Ke(s))
690
+ throw new TypeError();
691
+ if (!Ve(o))
692
+ throw new TypeError();
693
+ return de(s, o);
694
+ } else {
695
+ if (!Ke(s))
696
+ throw new TypeError();
697
+ if (!j(o))
698
+ throw new TypeError();
699
+ if (!j(d) && !N(d) && !re(d))
700
+ throw new TypeError();
701
+ return re(d) && (d = void 0), c = Z(c), he(s, o, c, d);
702
+ }
703
+ }
704
+ e("decorate", g);
705
+ function I(s, o) {
706
+ function c(d, y) {
707
+ if (!j(d))
708
+ throw new TypeError();
709
+ if (!N(y) && !Mt(y))
710
+ throw new TypeError();
711
+ q(s, o, d, y);
712
+ }
713
+ return c;
714
+ }
715
+ e("metadata", I);
716
+ function O(s, o, c, d) {
717
+ if (!j(c))
718
+ throw new TypeError();
719
+ return N(d) || (d = Z(d)), q(s, o, c, d);
720
+ }
721
+ e("defineMetadata", O);
722
+ function S(s, o, c) {
723
+ if (!j(o))
724
+ throw new TypeError();
725
+ return N(c) || (c = Z(c)), ue(s, o, c);
726
+ }
727
+ e("hasMetadata", S);
728
+ function W(s, o, c) {
729
+ if (!j(o))
730
+ throw new TypeError();
731
+ return N(c) || (c = Z(c)), ne(s, o, c);
732
+ }
733
+ e("hasOwnMetadata", W);
734
+ function C(s, o, c) {
735
+ if (!j(o))
736
+ throw new TypeError();
737
+ return N(c) || (c = Z(c)), te(s, o, c);
738
+ }
739
+ e("getMetadata", C);
740
+ function k(s, o, c) {
741
+ if (!j(o))
742
+ throw new TypeError();
743
+ return N(c) || (c = Z(c)), L(s, o, c);
744
+ }
745
+ e("getOwnMetadata", k);
746
+ function Y(s, o) {
747
+ if (!j(s))
748
+ throw new TypeError();
749
+ return N(o) || (o = Z(o)), Xe(s, o);
750
+ }
751
+ e("getMetadataKeys", Y);
752
+ function T(s, o) {
753
+ if (!j(s))
754
+ throw new TypeError();
755
+ return N(o) || (o = Z(o)), Ze(s, o);
756
+ }
757
+ e("getOwnMetadataKeys", T);
758
+ function Se(s, o, c) {
759
+ if (!j(o))
760
+ throw new TypeError();
761
+ N(c) || (c = Z(c));
762
+ var d = K(
763
+ o,
764
+ c,
765
+ /*Create*/
766
+ !1
767
+ );
768
+ if (N(d) || !d.delete(s))
769
+ return !1;
770
+ if (d.size > 0)
771
+ return !0;
772
+ var y = $.get(o);
773
+ return y.delete(c), y.size > 0 || $.delete(o), !0;
774
+ }
775
+ e("deleteMetadata", Se);
776
+ function de(s, o) {
777
+ for (var c = s.length - 1; c >= 0; --c) {
778
+ var d = s[c], y = d(o);
779
+ if (!N(y) && !re(y)) {
780
+ if (!Ve(y))
781
+ throw new TypeError();
782
+ o = y;
783
+ }
784
+ }
785
+ return o;
786
+ }
787
+ function he(s, o, c, d) {
788
+ for (var y = s.length - 1; y >= 0; --y) {
789
+ var B = s[y], _ = B(o, c, d);
790
+ if (!N(_) && !re(_)) {
791
+ if (!j(_))
792
+ throw new TypeError();
793
+ d = _;
794
+ }
795
+ }
796
+ return d;
797
+ }
798
+ function K(s, o, c) {
799
+ var d = $.get(s);
800
+ if (N(d)) {
801
+ if (!c)
802
+ return;
803
+ d = new h(), $.set(s, d);
804
+ }
805
+ var y = d.get(o);
806
+ if (N(y)) {
807
+ if (!c)
808
+ return;
809
+ y = new h(), d.set(o, y);
810
+ }
811
+ return y;
812
+ }
813
+ function ue(s, o, c) {
814
+ var d = ne(s, o, c);
815
+ if (d)
816
+ return !0;
817
+ var y = Me(o);
818
+ return re(y) ? !1 : ue(s, y, c);
819
+ }
820
+ function ne(s, o, c) {
821
+ var d = K(
822
+ o,
823
+ c,
824
+ /*Create*/
825
+ !1
826
+ );
827
+ return N(d) ? !1 : _t(d.has(s));
828
+ }
829
+ function te(s, o, c) {
830
+ var d = ne(s, o, c);
831
+ if (d)
832
+ return L(s, o, c);
833
+ var y = Me(o);
834
+ if (!re(y))
835
+ return te(s, y, c);
836
+ }
837
+ function L(s, o, c) {
838
+ var d = K(
839
+ o,
840
+ c,
841
+ /*Create*/
842
+ !1
843
+ );
844
+ if (!N(d))
845
+ return d.get(s);
846
+ }
847
+ function q(s, o, c, d) {
848
+ var y = K(
849
+ c,
850
+ d,
851
+ /*Create*/
852
+ !0
853
+ );
854
+ y.set(s, o);
855
+ }
856
+ function Xe(s, o) {
857
+ var c = Ze(s, o), d = Me(s);
858
+ if (d === null)
859
+ return c;
860
+ var y = Xe(d, o);
861
+ if (y.length <= 0)
862
+ return c;
863
+ if (c.length <= 0)
864
+ return y;
865
+ for (var B = new R(), _ = [], M = 0, w = c; M < w.length; M++) {
866
+ var x = w[M], A = B.has(x);
867
+ A || (B.add(x), _.push(x));
868
+ }
869
+ for (var V = 0, tt = y; V < tt.length; V++) {
870
+ var x = tt[V], A = B.has(x);
871
+ A || (B.add(x), _.push(x));
872
+ }
873
+ return _;
874
+ }
875
+ function Ze(s, o) {
876
+ var c = [], d = K(
877
+ s,
878
+ o,
879
+ /*Create*/
880
+ !1
881
+ );
882
+ if (N(d))
883
+ return c;
884
+ for (var y = d.keys(), B = bt(y), _ = 0; ; ) {
885
+ var M = xt(B);
886
+ if (!M)
887
+ return c.length = _, c;
888
+ var w = Ct(M);
889
+ try {
890
+ c[_] = w;
891
+ } catch (x) {
892
+ try {
893
+ At(B);
894
+ } finally {
895
+ throw x;
896
+ }
897
+ }
898
+ _++;
899
+ }
900
+ }
901
+ function Qe(s) {
902
+ if (s === null)
903
+ return 1;
904
+ switch (typeof s) {
905
+ case "undefined":
906
+ return 0;
907
+ case "boolean":
908
+ return 2;
909
+ case "string":
910
+ return 3;
911
+ case "symbol":
912
+ return 4;
913
+ case "number":
914
+ return 5;
915
+ case "object":
916
+ return s === null ? 1 : 6;
917
+ default:
918
+ return 6;
919
+ }
920
+ }
921
+ function N(s) {
922
+ return s === void 0;
923
+ }
924
+ function re(s) {
925
+ return s === null;
926
+ }
927
+ function yt(s) {
928
+ return typeof s == "symbol";
929
+ }
930
+ function j(s) {
931
+ return typeof s == "object" ? s !== null : typeof s == "function";
932
+ }
933
+ function vt(s, o) {
934
+ switch (Qe(s)) {
935
+ case 0:
936
+ return s;
937
+ case 1:
938
+ return s;
939
+ case 2:
940
+ return s;
941
+ case 3:
942
+ return s;
943
+ case 4:
944
+ return s;
945
+ case 5:
946
+ return s;
947
+ }
948
+ var c = o === 3 ? "string" : o === 5 ? "number" : "default", d = et(s, i);
949
+ if (d !== void 0) {
950
+ var y = d.call(s, c);
951
+ if (j(y))
952
+ throw new TypeError();
953
+ return y;
954
+ }
955
+ return wt(s, c === "default" ? "number" : c);
956
+ }
957
+ function wt(s, o) {
958
+ if (o === "string") {
959
+ var c = s.toString;
960
+ if (se(c)) {
961
+ var d = c.call(s);
962
+ if (!j(d))
963
+ return d;
964
+ }
965
+ var y = s.valueOf;
966
+ if (se(y)) {
967
+ var d = y.call(s);
968
+ if (!j(d))
969
+ return d;
970
+ }
971
+ } else {
972
+ var y = s.valueOf;
973
+ if (se(y)) {
974
+ var d = y.call(s);
975
+ if (!j(d))
976
+ return d;
977
+ }
978
+ var B = s.toString;
979
+ if (se(B)) {
980
+ var d = B.call(s);
981
+ if (!j(d))
982
+ return d;
983
+ }
984
+ }
985
+ throw new TypeError();
986
+ }
987
+ function _t(s) {
988
+ return !!s;
989
+ }
990
+ function St(s) {
991
+ return "" + s;
992
+ }
993
+ function Z(s) {
994
+ var o = vt(
995
+ s,
996
+ 3
997
+ /* String */
998
+ );
999
+ return yt(o) ? o : St(o);
1000
+ }
1001
+ function Ke(s) {
1002
+ return Array.isArray ? Array.isArray(s) : s instanceof Object ? s instanceof Array : Object.prototype.toString.call(s) === "[object Array]";
1003
+ }
1004
+ function se(s) {
1005
+ return typeof s == "function";
1006
+ }
1007
+ function Ve(s) {
1008
+ return typeof s == "function";
1009
+ }
1010
+ function Mt(s) {
1011
+ switch (Qe(s)) {
1012
+ case 3:
1013
+ return !0;
1014
+ case 4:
1015
+ return !0;
1016
+ default:
1017
+ return !1;
1018
+ }
1019
+ }
1020
+ function et(s, o) {
1021
+ var c = s[o];
1022
+ if (c != null) {
1023
+ if (!se(c))
1024
+ throw new TypeError();
1025
+ return c;
1026
+ }
1027
+ }
1028
+ function bt(s) {
1029
+ var o = et(s, u);
1030
+ if (!se(o))
1031
+ throw new TypeError();
1032
+ var c = o.call(s);
1033
+ if (!j(c))
1034
+ throw new TypeError();
1035
+ return c;
1036
+ }
1037
+ function Ct(s) {
1038
+ return s.value;
1039
+ }
1040
+ function xt(s) {
1041
+ var o = s.next();
1042
+ return o.done ? !1 : o;
1043
+ }
1044
+ function At(s) {
1045
+ var o = s.return;
1046
+ o && o.call(s);
1047
+ }
1048
+ function Me(s) {
1049
+ var o = Object.getPrototypeOf(s);
1050
+ if (typeof s != "function" || s === p || o !== p)
1051
+ return o;
1052
+ var c = s.prototype, d = c && Object.getPrototypeOf(c);
1053
+ if (d == null || d === Object.prototype)
1054
+ return o;
1055
+ var y = d.constructor;
1056
+ return typeof y != "function" || y === s ? o : y;
1057
+ }
1058
+ function Et() {
1059
+ var s = {}, o = [], c = (
1060
+ /** @class */
1061
+ function() {
1062
+ function _(M, w, x) {
1063
+ this._index = 0, this._keys = M, this._values = w, this._selector = x;
1064
+ }
1065
+ return _.prototype["@@iterator"] = function() {
1066
+ return this;
1067
+ }, _.prototype[u] = function() {
1068
+ return this;
1069
+ }, _.prototype.next = function() {
1070
+ var M = this._index;
1071
+ if (M >= 0 && M < this._keys.length) {
1072
+ var w = this._selector(this._keys[M], this._values[M]);
1073
+ return M + 1 >= this._keys.length ? (this._index = -1, this._keys = o, this._values = o) : this._index++, { value: w, done: !1 };
1074
+ }
1075
+ return { value: void 0, done: !0 };
1076
+ }, _.prototype.throw = function(M) {
1077
+ throw this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), M;
1078
+ }, _.prototype.return = function(M) {
1079
+ return this._index >= 0 && (this._index = -1, this._keys = o, this._values = o), { value: M, done: !0 };
1080
+ }, _;
1081
+ }()
1082
+ );
1083
+ return (
1084
+ /** @class */
1085
+ function() {
1086
+ function _() {
1087
+ this._keys = [], this._values = [], this._cacheKey = s, this._cacheIndex = -2;
1088
+ }
1089
+ return Object.defineProperty(_.prototype, "size", {
1090
+ get: function() {
1091
+ return this._keys.length;
1092
+ },
1093
+ enumerable: !0,
1094
+ configurable: !0
1095
+ }), _.prototype.has = function(M) {
1096
+ return this._find(
1097
+ M,
1098
+ /*insert*/
1099
+ !1
1100
+ ) >= 0;
1101
+ }, _.prototype.get = function(M) {
1102
+ var w = this._find(
1103
+ M,
1104
+ /*insert*/
1105
+ !1
1106
+ );
1107
+ return w >= 0 ? this._values[w] : void 0;
1108
+ }, _.prototype.set = function(M, w) {
1109
+ var x = this._find(
1110
+ M,
1111
+ /*insert*/
1112
+ !0
1113
+ );
1114
+ return this._values[x] = w, this;
1115
+ }, _.prototype.delete = function(M) {
1116
+ var w = this._find(
1117
+ M,
1118
+ /*insert*/
1119
+ !1
1120
+ );
1121
+ if (w >= 0) {
1122
+ for (var x = this._keys.length, A = w + 1; A < x; A++)
1123
+ this._keys[A - 1] = this._keys[A], this._values[A - 1] = this._values[A];
1124
+ return this._keys.length--, this._values.length--, M === this._cacheKey && (this._cacheKey = s, this._cacheIndex = -2), !0;
1125
+ }
1126
+ return !1;
1127
+ }, _.prototype.clear = function() {
1128
+ this._keys.length = 0, this._values.length = 0, this._cacheKey = s, this._cacheIndex = -2;
1129
+ }, _.prototype.keys = function() {
1130
+ return new c(this._keys, this._values, d);
1131
+ }, _.prototype.values = function() {
1132
+ return new c(this._keys, this._values, y);
1133
+ }, _.prototype.entries = function() {
1134
+ return new c(this._keys, this._values, B);
1135
+ }, _.prototype["@@iterator"] = function() {
1136
+ return this.entries();
1137
+ }, _.prototype[u] = function() {
1138
+ return this.entries();
1139
+ }, _.prototype._find = function(M, w) {
1140
+ return this._cacheKey !== M && (this._cacheIndex = this._keys.indexOf(this._cacheKey = M)), this._cacheIndex < 0 && w && (this._cacheIndex = this._keys.length, this._keys.push(M), this._values.push(void 0)), this._cacheIndex;
1141
+ }, _;
1142
+ }()
1143
+ );
1144
+ function d(_, M) {
1145
+ return _;
1146
+ }
1147
+ function y(_, M) {
1148
+ return M;
1149
+ }
1150
+ function B(_, M) {
1151
+ return [_, M];
1152
+ }
1153
+ }
1154
+ function Ot() {
1155
+ return (
1156
+ /** @class */
1157
+ function() {
1158
+ function s() {
1159
+ this._map = new h();
1160
+ }
1161
+ return Object.defineProperty(s.prototype, "size", {
1162
+ get: function() {
1163
+ return this._map.size;
1164
+ },
1165
+ enumerable: !0,
1166
+ configurable: !0
1167
+ }), s.prototype.has = function(o) {
1168
+ return this._map.has(o);
1169
+ }, s.prototype.add = function(o) {
1170
+ return this._map.set(o, o), this;
1171
+ }, s.prototype.delete = function(o) {
1172
+ return this._map.delete(o);
1173
+ }, s.prototype.clear = function() {
1174
+ this._map.clear();
1175
+ }, s.prototype.keys = function() {
1176
+ return this._map.keys();
1177
+ }, s.prototype.values = function() {
1178
+ return this._map.values();
1179
+ }, s.prototype.entries = function() {
1180
+ return this._map.entries();
1181
+ }, s.prototype["@@iterator"] = function() {
1182
+ return this.keys();
1183
+ }, s.prototype[u] = function() {
1184
+ return this.keys();
1185
+ }, s;
1186
+ }()
1187
+ );
1188
+ }
1189
+ function Lt() {
1190
+ var s = 16, o = v.create(), c = d();
1191
+ return (
1192
+ /** @class */
1193
+ function() {
1194
+ function w() {
1195
+ this._key = d();
1196
+ }
1197
+ return w.prototype.has = function(x) {
1198
+ var A = y(
1199
+ x,
1200
+ /*create*/
1201
+ !1
1202
+ );
1203
+ return A !== void 0 ? v.has(A, this._key) : !1;
1204
+ }, w.prototype.get = function(x) {
1205
+ var A = y(
1206
+ x,
1207
+ /*create*/
1208
+ !1
1209
+ );
1210
+ return A !== void 0 ? v.get(A, this._key) : void 0;
1211
+ }, w.prototype.set = function(x, A) {
1212
+ var V = y(
1213
+ x,
1214
+ /*create*/
1215
+ !0
1216
+ );
1217
+ return V[this._key] = A, this;
1218
+ }, w.prototype.delete = function(x) {
1219
+ var A = y(
1220
+ x,
1221
+ /*create*/
1222
+ !1
1223
+ );
1224
+ return A !== void 0 ? delete A[this._key] : !1;
1225
+ }, w.prototype.clear = function() {
1226
+ this._key = d();
1227
+ }, w;
1228
+ }()
1229
+ );
1230
+ function d() {
1231
+ var w;
1232
+ do
1233
+ w = "@@WeakMap@@" + M();
1234
+ while (v.has(o, w));
1235
+ return o[w] = !0, w;
1236
+ }
1237
+ function y(w, x) {
1238
+ if (!t.call(w, c)) {
1239
+ if (!x)
1240
+ return;
1241
+ Object.defineProperty(w, c, { value: v.create() });
1242
+ }
1243
+ return w[c];
1244
+ }
1245
+ function B(w, x) {
1246
+ for (var A = 0; A < x; ++A)
1247
+ w[A] = Math.random() * 255 | 0;
1248
+ return w;
1249
+ }
1250
+ function _(w) {
1251
+ return typeof Uint8Array == "function" ? typeof crypto < "u" ? crypto.getRandomValues(new Uint8Array(w)) : typeof msCrypto < "u" ? msCrypto.getRandomValues(new Uint8Array(w)) : B(new Uint8Array(w), w) : B(new Array(w), w);
1252
+ }
1253
+ function M() {
1254
+ var w = _(s);
1255
+ w[6] = w[6] & 79 | 64, w[8] = w[8] & 191 | 128;
1256
+ for (var x = "", A = 0; A < s; ++A) {
1257
+ var V = w[A];
1258
+ (A === 4 || A === 6 || A === 8) && (x += "-"), V < 16 && (x += "0"), x += V.toString(16).toLowerCase();
1259
+ }
1260
+ return x;
1261
+ }
1262
+ }
1263
+ function be(s) {
1264
+ return s.__ = void 0, delete s.__, s;
1265
+ }
1266
+ });
1267
+ })(st || (st = {}));
1268
+ var Ut = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Le = (r, e, t, n) => {
1269
+ for (var i = n > 1 ? void 0 : n ? Wt(e, t) : e, u = r.length - 1, a; u >= 0; u--)
1270
+ (a = r[u]) && (i = (n ? a(e, t, i) : a(i)) || i);
1271
+ return n && i && Ut(e, t, i), i;
1272
+ };
1273
+ const X = 0, D = 1, Gt = 4294967295, le = 3;
1274
+ class Ie {
1275
+ constructor(e) {
1276
+ Object.assign(this, e);
1277
+ }
1278
+ update() {
1279
+ var e, t, n, i, u;
1280
+ (e = this.ScalarCmd) == null || e.forEach((a, f) => a.Index = f), (t = this.RotateCmd) == null || t.forEach((a, f) => a.Index = f), (n = this.LinearCmd) == null || n.forEach((a, f) => a.Index = f), (i = this.SensorReadCmd) == null || i.forEach((a, f) => a.Index = f), (u = this.SensorSubscribeCmd) == null || u.forEach((a, f) => a.Index = f);
1281
+ }
1282
+ }
1283
+ var ae = /* @__PURE__ */ ((r) => (r.Unknown = "Unknown", r.Vibrate = "Vibrate", r.Rotate = "Rotate", r.Oscillate = "Oscillate", r.Constrict = "Constrict", r.Inflate = "Inflate", r.Position = "Position", r))(ae || {}), ee = /* @__PURE__ */ ((r) => (r.Unknown = "Unknown", r.Battery = "Battery", r.RSSI = "RSSI", r.Button = "Button", r.Pressure = "Pressure", r))(ee || {});
1284
+ class zt {
1285
+ constructor(e) {
1286
+ this.Index = 0, Object.assign(this, e);
1287
+ }
1288
+ }
1289
+ class Jt {
1290
+ constructor(e) {
1291
+ this.Endpoints = e;
1292
+ }
1293
+ }
1294
+ class qt {
1295
+ constructor(e) {
1296
+ this.Index = 0, Object.assign(this, e);
1297
+ }
1298
+ }
1299
+ class H {
1300
+ constructor(e) {
1301
+ this.Id = e;
1302
+ }
1303
+ // tslint:disable-next-line:ban-types
1304
+ get Type() {
1305
+ return this.constructor;
1306
+ }
1307
+ toJSON() {
1308
+ return JSON.stringify(this.toProtocolFormat());
1309
+ }
1310
+ toProtocolFormat() {
1311
+ const e = {};
1312
+ return e[this.constructor.Name] = $t(this), e;
1313
+ }
1314
+ update() {
1315
+ }
1316
+ }
1317
+ class J extends H {
1318
+ constructor(e, t) {
1319
+ super(t), this.DeviceIndex = e, this.Id = t;
1320
+ }
1321
+ }
1322
+ class ce extends H {
1323
+ constructor(e = X) {
1324
+ super(e), this.Id = e;
1325
+ }
1326
+ }
1327
+ class ve extends ce {
1328
+ constructor(e = D) {
1329
+ super(e), this.Id = e;
1330
+ }
1331
+ }
1332
+ ve.Name = "Ok";
1333
+ class ft extends H {
1334
+ constructor(e = D) {
1335
+ super(e), this.Id = e;
1336
+ }
1337
+ }
1338
+ ft.Name = "Ping";
1339
+ var z = /* @__PURE__ */ ((r) => (r[r.ERROR_UNKNOWN = 0] = "ERROR_UNKNOWN", r[r.ERROR_INIT = 1] = "ERROR_INIT", r[r.ERROR_PING = 2] = "ERROR_PING", r[r.ERROR_MSG = 3] = "ERROR_MSG", r[r.ERROR_DEVICE = 4] = "ERROR_DEVICE", r))(z || {});
1340
+ let Q = class extends H {
1341
+ constructor(e, t = 0, n = D) {
1342
+ super(n), this.ErrorMessage = e, this.ErrorCode = t, this.Id = n;
1343
+ }
1344
+ get Schemversion() {
1345
+ return 0;
1346
+ }
1347
+ };
1348
+ Q.Name = "Error";
1349
+ class Re {
1350
+ constructor(e) {
1351
+ Object.assign(this, e);
1352
+ }
1353
+ }
1354
+ Le([
1355
+ Oe(() => Ie)
1356
+ ], Re.prototype, "DeviceMessages", 2);
1357
+ class De extends H {
1358
+ constructor(e, t = D) {
1359
+ super(t), this.Devices = e, this.Id = t;
1360
+ }
1361
+ update() {
1362
+ for (const e of this.Devices)
1363
+ e.DeviceMessages.update();
1364
+ }
1365
+ }
1366
+ De.Name = "DeviceList";
1367
+ Le([
1368
+ Oe(() => Re)
1369
+ ], De.prototype, "Devices", 2);
1370
+ class we extends ce {
1371
+ constructor(e) {
1372
+ super(), Object.assign(this, e);
1373
+ }
1374
+ update() {
1375
+ this.DeviceMessages.update();
1376
+ }
1377
+ }
1378
+ we.Name = "DeviceAdded";
1379
+ Le([
1380
+ Oe(() => Ie)
1381
+ ], we.prototype, "DeviceMessages", 2);
1382
+ class Te extends ce {
1383
+ constructor(e) {
1384
+ super(), this.DeviceIndex = e;
1385
+ }
1386
+ }
1387
+ Te.Name = "DeviceRemoved";
1388
+ class Ne extends H {
1389
+ constructor(e = D) {
1390
+ super(e), this.Id = e;
1391
+ }
1392
+ }
1393
+ Ne.Name = "RequestDeviceList";
1394
+ class Pe extends H {
1395
+ constructor(e = D) {
1396
+ super(e), this.Id = e;
1397
+ }
1398
+ }
1399
+ Pe.Name = "StartScanning";
1400
+ class ke extends H {
1401
+ constructor(e = D) {
1402
+ super(e), this.Id = e;
1403
+ }
1404
+ }
1405
+ ke.Name = "StopScanning";
1406
+ class je extends ce {
1407
+ constructor() {
1408
+ super();
1409
+ }
1410
+ }
1411
+ je.Name = "ScanningFinished";
1412
+ class Be extends H {
1413
+ constructor(e, t = 0, n = D) {
1414
+ super(n), this.ClientName = e, this.MessageVersion = t, this.Id = n;
1415
+ }
1416
+ }
1417
+ Be.Name = "RequestServerInfo";
1418
+ class $e extends ce {
1419
+ constructor(e, t, n, i = D) {
1420
+ super(), this.MessageVersion = e, this.MaxPingTime = t, this.ServerName = n, this.Id = i;
1421
+ }
1422
+ }
1423
+ $e.Name = "ServerInfo";
1424
+ class Fe extends J {
1425
+ constructor(e = -1, t = D) {
1426
+ super(e, t), this.DeviceIndex = e, this.Id = t;
1427
+ }
1428
+ }
1429
+ Fe.Name = "StopDeviceCmd";
1430
+ class Ue extends H {
1431
+ constructor(e = D) {
1432
+ super(e), this.Id = e;
1433
+ }
1434
+ }
1435
+ Ue.Name = "StopAllDevices";
1436
+ class _e {
1437
+ constructor(e) {
1438
+ this.Index = e;
1439
+ }
1440
+ }
1441
+ class Ce extends _e {
1442
+ constructor(e, t, n) {
1443
+ super(e), this.Scalar = t, this.ActuatorType = n;
1444
+ }
1445
+ }
1446
+ class ge extends J {
1447
+ constructor(e, t = -1, n = D) {
1448
+ super(t, n), this.Scalars = e, this.DeviceIndex = t, this.Id = n;
1449
+ }
1450
+ }
1451
+ ge.Name = "ScalarCmd";
1452
+ class dt extends _e {
1453
+ constructor(e, t, n) {
1454
+ super(e), this.Speed = t, this.Clockwise = n;
1455
+ }
1456
+ }
1457
+ const ht = class pt extends J {
1458
+ constructor(e, t = -1, n = D) {
1459
+ super(t, n), this.Rotations = e, this.DeviceIndex = t, this.Id = n;
1460
+ }
1461
+ static Create(e, t) {
1462
+ const n = new Array();
1463
+ let i = 0;
1464
+ for (const [u, a] of t)
1465
+ n.push(new dt(i, u, a)), ++i;
1466
+ return new pt(n, e);
1467
+ }
1468
+ };
1469
+ ht.Name = "RotateCmd";
1470
+ let xe = ht;
1471
+ class lt extends _e {
1472
+ constructor(e, t, n) {
1473
+ super(e), this.Position = t, this.Duration = n;
1474
+ }
1475
+ }
1476
+ const gt = class mt extends J {
1477
+ constructor(e, t = -1, n = D) {
1478
+ super(t, n), this.Vectors = e, this.DeviceIndex = t, this.Id = n;
1479
+ }
1480
+ static Create(e, t) {
1481
+ const n = new Array();
1482
+ let i = 0;
1483
+ for (const u of t)
1484
+ n.push(new lt(i, u[0], u[1])), ++i;
1485
+ return new mt(n, e);
1486
+ }
1487
+ };
1488
+ gt.Name = "LinearCmd";
1489
+ let Ae = gt;
1490
+ class We extends J {
1491
+ constructor(e, t, n, i = D) {
1492
+ super(e, i), this.DeviceIndex = e, this.SensorIndex = t, this.SensorType = n, this.Id = i;
1493
+ }
1494
+ }
1495
+ We.Name = "SensorReadCmd";
1496
+ class Ge extends J {
1497
+ constructor(e, t, n, i, u = D) {
1498
+ super(e, u), this.DeviceIndex = e, this.SensorIndex = t, this.SensorType = n, this.Data = i, this.Id = u;
1499
+ }
1500
+ }
1501
+ Ge.Name = "SensorReading";
1502
+ class ze extends J {
1503
+ constructor(e, t, n, i, u = D) {
1504
+ super(e, u), this.DeviceIndex = e, this.Endpoint = t, this.ExpectedLength = n, this.Timeout = i, this.Id = u;
1505
+ }
1506
+ }
1507
+ ze.Name = "RawReadCmd";
1508
+ class Je extends J {
1509
+ constructor(e, t, n, i, u = D) {
1510
+ super(e, u), this.DeviceIndex = e, this.Endpoint = t, this.Data = n, this.WriteWithResponse = i, this.Id = u;
1511
+ }
1512
+ }
1513
+ Je.Name = "RawWriteCmd";
1514
+ class qe extends J {
1515
+ constructor(e, t, n = D) {
1516
+ super(e, n), this.DeviceIndex = e, this.Endpoint = t, this.Id = n;
1517
+ }
1518
+ }
1519
+ qe.Name = "RawSubscribeCmd";
1520
+ class He extends J {
1521
+ constructor(e, t, n = D) {
1522
+ super(e, n), this.DeviceIndex = e, this.Endpoint = t, this.Id = n;
1523
+ }
1524
+ }
1525
+ He.Name = "RawUnsubscribeCmd";
1526
+ class Ye extends J {
1527
+ constructor(e, t, n, i = D) {
1528
+ super(e, i), this.DeviceIndex = e, this.Endpoint = t, this.Data = n, this.Id = i;
1529
+ }
1530
+ }
1531
+ Ye.Name = "RawReading";
1532
+ const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1533
+ __proto__: null,
1534
+ ActuatorType: ae,
1535
+ ButtplugDeviceMessage: J,
1536
+ ButtplugMessage: H,
1537
+ ButtplugSystemMessage: ce,
1538
+ DEFAULT_MESSAGE_ID: D,
1539
+ DeviceAdded: we,
1540
+ DeviceInfo: Re,
1541
+ DeviceList: De,
1542
+ DeviceRemoved: Te,
1543
+ Error: Q,
1544
+ ErrorClass: z,
1545
+ GenericDeviceMessageAttributes: zt,
1546
+ GenericMessageSubcommand: _e,
1547
+ LinearCmd: Ae,
1548
+ MAX_ID: Gt,
1549
+ MESSAGE_SPEC_VERSION: le,
1550
+ MessageAttributes: Ie,
1551
+ Ok: ve,
1552
+ Ping: ft,
1553
+ RawDeviceMessageAttributes: Jt,
1554
+ RawReadCmd: ze,
1555
+ RawReading: Ye,
1556
+ RawSubscribeCmd: qe,
1557
+ RawUnsubscribeCmd: He,
1558
+ RawWriteCmd: Je,
1559
+ RequestDeviceList: Ne,
1560
+ RequestServerInfo: Be,
1561
+ RotateCmd: xe,
1562
+ RotateSubcommand: dt,
1563
+ SYSTEM_MESSAGE_ID: X,
1564
+ ScalarCmd: ge,
1565
+ ScalarSubcommand: Ce,
1566
+ ScanningFinished: je,
1567
+ SensorDeviceMessageAttributes: qt,
1568
+ SensorReadCmd: We,
1569
+ SensorReading: Ge,
1570
+ SensorType: ee,
1571
+ ServerInfo: $e,
1572
+ StartScanning: Pe,
1573
+ StopAllDevices: Ue,
1574
+ StopDeviceCmd: Fe,
1575
+ StopScanning: ke,
1576
+ VectorSubcommand: lt
1577
+ }, Symbol.toStringTag, { value: "Module" }));
1578
+ /*!
1579
+ * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1580
+ * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1581
+ * project root for full license information.
1582
+ *
1583
+ * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1584
+ */
1585
+ class U extends Error {
1586
+ constructor(e, t, n = X, i) {
1587
+ super(e), this.errorClass = z.ERROR_UNKNOWN, this.errorClass = t, this.innerError = i, this.messageId = n;
1588
+ }
1589
+ get ErrorClass() {
1590
+ return this.errorClass;
1591
+ }
1592
+ get InnerError() {
1593
+ return this.innerError;
1594
+ }
1595
+ get Id() {
1596
+ return this.messageId;
1597
+ }
1598
+ get ErrorMessage() {
1599
+ return new Q(this.message, this.ErrorClass, this.Id);
1600
+ }
1601
+ static LogAndError(e, t, n, i = X) {
1602
+ return t.Error(n), new e(n, i);
1603
+ }
1604
+ static FromError(e) {
1605
+ switch (e.ErrorCode) {
1606
+ case z.ERROR_DEVICE:
1607
+ return new P(e.ErrorMessage, e.Id);
1608
+ case z.ERROR_INIT:
1609
+ return new Ee(e.ErrorMessage, e.Id);
1610
+ case z.ERROR_UNKNOWN:
1611
+ return new Xt(e.ErrorMessage, e.Id);
1612
+ case z.ERROR_PING:
1613
+ return new Yt(e.ErrorMessage, e.Id);
1614
+ case z.ERROR_MSG:
1615
+ return new fe(e.ErrorMessage, e.Id);
1616
+ default:
1617
+ throw new Error(`Message type ${e.ErrorCode} not handled`);
1618
+ }
1619
+ }
1620
+ }
1621
+ class Ee extends U {
1622
+ constructor(e, t = X) {
1623
+ super(e, z.ERROR_INIT, t);
1624
+ }
1625
+ }
1626
+ class P extends U {
1627
+ constructor(e, t = X) {
1628
+ super(e, z.ERROR_DEVICE, t);
1629
+ }
1630
+ }
1631
+ class fe extends U {
1632
+ constructor(e, t = X) {
1633
+ super(e, z.ERROR_MSG, t);
1634
+ }
1635
+ }
1636
+ class Yt extends U {
1637
+ constructor(e, t = X) {
1638
+ super(e, z.ERROR_PING, t);
1639
+ }
1640
+ }
1641
+ class Xt extends U {
1642
+ constructor(e, t = X) {
1643
+ super(e, z.ERROR_UNKNOWN, t);
1644
+ }
1645
+ }
1646
+ class me extends ye {
1647
+ /**
1648
+ * @param _index Index of the device, as created by the device manager.
1649
+ * @param _name Name of the device.
1650
+ * @param allowedMsgs Buttplug messages the device can receive.
1651
+ */
1652
+ constructor(e, t) {
1653
+ super(), this._deviceInfo = e, this._sendClosure = t, this.allowedMsgs = /* @__PURE__ */ new Map(), e.DeviceMessages.update();
1654
+ }
1655
+ /**
1656
+ * Return the name of the device.
1657
+ */
1658
+ get name() {
1659
+ return this._deviceInfo.DeviceName;
1660
+ }
1661
+ /**
1662
+ * Return the user set name of the device.
1663
+ */
1664
+ get displayName() {
1665
+ return this._deviceInfo.DeviceDisplayName;
1666
+ }
1667
+ /**
1668
+ * Return the index of the device.
1669
+ */
1670
+ get index() {
1671
+ return this._deviceInfo.DeviceIndex;
1672
+ }
1673
+ /**
1674
+ * Return the index of the device.
1675
+ */
1676
+ get messageTimingGap() {
1677
+ return this._deviceInfo.DeviceMessageTimingGap;
1678
+ }
1679
+ /**
1680
+ * Return a list of message types the device accepts.
1681
+ */
1682
+ get messageAttributes() {
1683
+ return this._deviceInfo.DeviceMessages;
1684
+ }
1685
+ static fromMsg(e, t) {
1686
+ return new me(e, t);
1687
+ }
1688
+ async send(e) {
1689
+ return await this._sendClosure(this, e);
1690
+ }
1691
+ async sendExpectOk(e) {
1692
+ const t = await this.send(e);
1693
+ switch (t.constructor) {
1694
+ case ve:
1695
+ return;
1696
+ case Q:
1697
+ throw U.FromError(t);
1698
+ default:
1699
+ throw new fe(
1700
+ `Message type ${t.constructor} not handled by SendMsgExpectOk`
1701
+ );
1702
+ }
1703
+ }
1704
+ async scalar(e) {
1705
+ Array.isArray(e) ? await this.sendExpectOk(new ge(e, this.index)) : await this.sendExpectOk(new ge([e], this.index));
1706
+ }
1707
+ async scalarCommandBuilder(e, t) {
1708
+ var u;
1709
+ const n = (u = this.messageAttributes.ScalarCmd) == null ? void 0 : u.filter(
1710
+ (a) => a.ActuatorType === t
1711
+ );
1712
+ if (!n || n.length === 0)
1713
+ throw new P(
1714
+ `Device ${this.name} has no ${t} capabilities`
1715
+ );
1716
+ const i = [];
1717
+ if (typeof e == "number")
1718
+ n.forEach(
1719
+ (a) => i.push(new Ce(a.Index, e, t))
1720
+ );
1721
+ else if (Array.isArray(e)) {
1722
+ if (e.length > n.length)
1723
+ throw new P(
1724
+ `${e.length} commands send to a device with ${n.length} vibrators`
1725
+ );
1726
+ n.forEach((a, f) => {
1727
+ i.push(new Ce(a.Index, e[f], t));
1728
+ });
1729
+ } else
1730
+ throw new P(
1731
+ `${t} can only take numbers or arrays of numbers.`
1732
+ );
1733
+ await this.scalar(i);
1734
+ }
1735
+ get vibrateAttributes() {
1736
+ var e;
1737
+ return ((e = this.messageAttributes.ScalarCmd) == null ? void 0 : e.filter(
1738
+ (t) => t.ActuatorType === ae.Vibrate
1739
+ )) ?? [];
1740
+ }
1741
+ async vibrate(e) {
1742
+ await this.scalarCommandBuilder(e, ae.Vibrate);
1743
+ }
1744
+ get oscillateAttributes() {
1745
+ var e;
1746
+ return ((e = this.messageAttributes.ScalarCmd) == null ? void 0 : e.filter(
1747
+ (t) => t.ActuatorType === ae.Oscillate
1748
+ )) ?? [];
1749
+ }
1750
+ async oscillate(e) {
1751
+ await this.scalarCommandBuilder(e, ae.Oscillate);
1752
+ }
1753
+ get rotateAttributes() {
1754
+ return this.messageAttributes.RotateCmd ?? [];
1755
+ }
1756
+ async rotate(e, t) {
1757
+ const n = this.messageAttributes.RotateCmd;
1758
+ if (!n || n.length === 0)
1759
+ throw new P(
1760
+ `Device ${this.name} has no Rotate capabilities`
1761
+ );
1762
+ let i;
1763
+ if (typeof e == "number")
1764
+ i = xe.Create(
1765
+ this.index,
1766
+ new Array(n.length).fill([e, t])
1767
+ );
1768
+ else if (Array.isArray(e))
1769
+ i = xe.Create(this.index, e);
1770
+ else
1771
+ throw new P(
1772
+ "SendRotateCmd can only take a number and boolean, or an array of number/boolean tuples"
1773
+ );
1774
+ await this.sendExpectOk(i);
1775
+ }
1776
+ get linearAttributes() {
1777
+ return this.messageAttributes.LinearCmd ?? [];
1778
+ }
1779
+ async linear(e, t) {
1780
+ const n = this.messageAttributes.LinearCmd;
1781
+ if (!n || n.length === 0)
1782
+ throw new P(
1783
+ `Device ${this.name} has no Linear capabilities`
1784
+ );
1785
+ let i;
1786
+ if (typeof e == "number")
1787
+ i = Ae.Create(
1788
+ this.index,
1789
+ new Array(n.length).fill([e, t])
1790
+ );
1791
+ else if (Array.isArray(e))
1792
+ i = Ae.Create(this.index, e);
1793
+ else
1794
+ throw new P(
1795
+ "SendLinearCmd can only take a number and number, or an array of number/number tuples"
1796
+ );
1797
+ await this.sendExpectOk(i);
1798
+ }
1799
+ async sensorRead(e, t) {
1800
+ const n = await this.send(
1801
+ new We(this.index, e, t)
1802
+ );
1803
+ switch (n.constructor) {
1804
+ case Ge:
1805
+ return n.Data;
1806
+ case Q:
1807
+ throw U.FromError(n);
1808
+ default:
1809
+ throw new fe(
1810
+ `Message type ${n.constructor} not handled by sensorRead`
1811
+ );
1812
+ }
1813
+ }
1814
+ get hasBattery() {
1815
+ var t;
1816
+ const e = (t = this.messageAttributes.SensorReadCmd) == null ? void 0 : t.filter(
1817
+ (n) => n.SensorType === ee.Battery
1818
+ );
1819
+ return e !== void 0 && e.length > 0;
1820
+ }
1821
+ async battery() {
1822
+ var n;
1823
+ if (!this.hasBattery)
1824
+ throw new P(
1825
+ `Device ${this.name} has no Battery capabilities`
1826
+ );
1827
+ const e = (n = this.messageAttributes.SensorReadCmd) == null ? void 0 : n.filter(
1828
+ (i) => i.SensorType === ee.Battery
1829
+ );
1830
+ return (await this.sensorRead(
1831
+ e[0].Index,
1832
+ ee.Battery
1833
+ ))[0] / 100;
1834
+ }
1835
+ get hasRssi() {
1836
+ var t;
1837
+ const e = (t = this.messageAttributes.SensorReadCmd) == null ? void 0 : t.filter(
1838
+ (n) => n.SensorType === ee.RSSI
1839
+ );
1840
+ return e !== void 0 && e.length === 0;
1841
+ }
1842
+ async rssi() {
1843
+ var n;
1844
+ if (!this.hasRssi)
1845
+ throw new P(
1846
+ `Device ${this.name} has no RSSI capabilities`
1847
+ );
1848
+ const e = (n = this.messageAttributes.SensorReadCmd) == null ? void 0 : n.filter(
1849
+ (i) => i.SensorType === ee.RSSI
1850
+ );
1851
+ return (await this.sensorRead(
1852
+ e[0].Index,
1853
+ ee.RSSI
1854
+ ))[0];
1855
+ }
1856
+ async rawRead(e, t, n) {
1857
+ if (!this.messageAttributes.RawReadCmd)
1858
+ throw new P(
1859
+ `Device ${this.name} has no raw read capabilities`
1860
+ );
1861
+ if (this.messageAttributes.RawReadCmd.Endpoints.indexOf(e) === -1)
1862
+ throw new P(
1863
+ `Device ${this.name} has no raw readable endpoint ${e}`
1864
+ );
1865
+ const i = await this.send(
1866
+ new ze(this.index, e, t, n)
1867
+ );
1868
+ switch (i.constructor) {
1869
+ case Ye:
1870
+ return new Uint8Array(i.Data);
1871
+ case Q:
1872
+ throw U.FromError(i);
1873
+ default:
1874
+ throw new fe(
1875
+ `Message type ${i.constructor} not handled by rawRead`
1876
+ );
1877
+ }
1878
+ }
1879
+ async rawWrite(e, t, n) {
1880
+ if (!this.messageAttributes.RawWriteCmd)
1881
+ throw new P(
1882
+ `Device ${this.name} has no raw write capabilities`
1883
+ );
1884
+ if (this.messageAttributes.RawWriteCmd.Endpoints.indexOf(e) === -1)
1885
+ throw new P(
1886
+ `Device ${this.name} has no raw writable endpoint ${e}`
1887
+ );
1888
+ await this.sendExpectOk(
1889
+ new Je(this.index, e, t, n)
1890
+ );
1891
+ }
1892
+ async rawSubscribe(e) {
1893
+ if (!this.messageAttributes.RawSubscribeCmd)
1894
+ throw new P(
1895
+ `Device ${this.name} has no raw subscribe capabilities`
1896
+ );
1897
+ if (this.messageAttributes.RawSubscribeCmd.Endpoints.indexOf(e) === -1)
1898
+ throw new P(
1899
+ `Device ${this.name} has no raw subscribable endpoint ${e}`
1900
+ );
1901
+ await this.sendExpectOk(new qe(this.index, e));
1902
+ }
1903
+ async rawUnsubscribe(e) {
1904
+ if (!this.messageAttributes.RawSubscribeCmd)
1905
+ throw new P(
1906
+ `Device ${this.name} has no raw unsubscribe capabilities`
1907
+ );
1908
+ if (this.messageAttributes.RawSubscribeCmd.Endpoints.indexOf(e) === -1)
1909
+ throw new P(
1910
+ `Device ${this.name} has no raw unsubscribable endpoint ${e}`
1911
+ );
1912
+ await this.sendExpectOk(
1913
+ new He(this.index, e)
1914
+ );
1915
+ }
1916
+ async stop() {
1917
+ await this.sendExpectOk(new Fe(this.index));
1918
+ }
1919
+ emitDisconnected() {
1920
+ this.emit("deviceremoved");
1921
+ }
1922
+ }
1923
+ /*!
1924
+ * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1925
+ * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1926
+ * project root for full license information.
1927
+ *
1928
+ * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1929
+ */
1930
+ class Zt {
1931
+ constructor(e) {
1932
+ this._useCounter = e, this._counter = 1, this._waitingMsgs = /* @__PURE__ */ new Map();
1933
+ }
1934
+ // One of the places we should actually return a promise, as we need to store
1935
+ // them while waiting for them to return across the line.
1936
+ // tslint:disable:promise-function-async
1937
+ PrepareOutgoingMessage(e) {
1938
+ this._useCounter && (e.Id = this._counter, this._counter += 1);
1939
+ let t, n;
1940
+ const i = new Promise(
1941
+ (u, a) => {
1942
+ t = u, n = a;
1943
+ }
1944
+ );
1945
+ return this._waitingMsgs.set(e.Id, [t, n]), i;
1946
+ }
1947
+ ParseIncomingMessages(e) {
1948
+ const t = [];
1949
+ for (const n of e)
1950
+ if (n.Id !== X && this._waitingMsgs.has(n.Id)) {
1951
+ const [i, u] = this._waitingMsgs.get(n.Id);
1952
+ if (n.Type === Q) {
1953
+ u(U.FromError(n));
1954
+ continue;
1955
+ }
1956
+ i(n);
1957
+ continue;
1958
+ } else
1959
+ t.push(n);
1960
+ return t;
1961
+ }
1962
+ }
1963
+ /*!
1964
+ * Buttplug JS Source Code File - Visit https://buttplug.io for more info about
1965
+ * the project. Licensed under the BSD 3-Clause license. See LICENSE file in the
1966
+ * project root for full license information.
1967
+ *
1968
+ * @copyright Copyright (c) Nonpolynomial Labs LLC. All rights reserved.
1969
+ */
1970
+ class Qt extends U {
1971
+ constructor(e) {
1972
+ super(e, z.ERROR_UNKNOWN);
1973
+ }
1974
+ }
1975
+ class rn extends ye {
1976
+ constructor(e = "Generic Buttplug Client") {
1977
+ super(), this._pingTimer = null, this._connector = null, this._devices = /* @__PURE__ */ new Map(), this._logger = Tt.Logger, this._isScanning = !1, this._sorter = new Zt(!0), this.connect = async (t) => {
1978
+ this._logger.Info(
1979
+ `ButtplugClient: Connecting using ${t.constructor.name}`
1980
+ ), await t.connect(), this._connector = t, this._connector.addListener("message", this.parseMessages), this._connector.addListener("disconnect", this.disconnectHandler), await this.initializeConnection();
1981
+ }, this.disconnect = async () => {
1982
+ this._logger.Debug("ButtplugClient: Disconnect called"), this.checkConnector(), await this.shutdownConnection(), await this._connector.disconnect();
1983
+ }, this.startScanning = async () => {
1984
+ this._logger.Debug("ButtplugClient: StartScanning called"), this._isScanning = !0, await this.sendMsgExpectOk(new Pe());
1985
+ }, this.stopScanning = async () => {
1986
+ this._logger.Debug("ButtplugClient: StopScanning called"), this._isScanning = !1, await this.sendMsgExpectOk(new ke());
1987
+ }, this.stopAllDevices = async () => {
1988
+ this._logger.Debug("ButtplugClient: StopAllDevices"), await this.sendMsgExpectOk(new Ue());
1989
+ }, this.disconnectHandler = () => {
1990
+ this._logger.Info("ButtplugClient: Disconnect event receieved."), this.emit("disconnect");
1991
+ }, this.parseMessages = (t) => {
1992
+ const n = this._sorter.ParseIncomingMessages(t);
1993
+ for (const i of n)
1994
+ switch (i.constructor) {
1995
+ case we: {
1996
+ const u = i, a = me.fromMsg(
1997
+ u,
1998
+ this.sendDeviceMessageClosure
1999
+ );
2000
+ this._devices.set(u.DeviceIndex, a), this.emit("deviceadded", a);
2001
+ break;
2002
+ }
2003
+ case Te: {
2004
+ const u = i;
2005
+ if (this._devices.has(u.DeviceIndex)) {
2006
+ const a = this._devices.get(u.DeviceIndex);
2007
+ a == null || a.emitDisconnected(), this._devices.delete(u.DeviceIndex), this.emit("deviceremoved", a);
2008
+ }
2009
+ break;
2010
+ }
2011
+ case je:
2012
+ this._isScanning = !1, this.emit("scanningfinished", i);
2013
+ break;
2014
+ }
2015
+ }, this.initializeConnection = async () => {
2016
+ this.checkConnector();
2017
+ const t = await this.sendMessage(
2018
+ new Be(
2019
+ this._clientName,
2020
+ le
2021
+ )
2022
+ );
2023
+ switch (t.constructor) {
2024
+ case $e: {
2025
+ const n = t;
2026
+ if (this._logger.Info(
2027
+ `ButtplugClient: Connected to Server ${n.ServerName}`
2028
+ ), n.MaxPingTime, n.MessageVersion < le)
2029
+ throw await this._connector.disconnect(), U.LogAndError(
2030
+ Ee,
2031
+ this._logger,
2032
+ `Server protocol version ${n.MessageVersion} is older than client protocol version ${le}. Please update server.`
2033
+ );
2034
+ return await this.requestDeviceList(), !0;
2035
+ }
2036
+ case Q: {
2037
+ await this._connector.disconnect();
2038
+ const n = t;
2039
+ throw U.LogAndError(
2040
+ Ee,
2041
+ this._logger,
2042
+ `Cannot connect to server. ${n.ErrorMessage}`
2043
+ );
2044
+ }
2045
+ }
2046
+ return !1;
2047
+ }, this.requestDeviceList = async () => {
2048
+ this.checkConnector(), this._logger.Debug("ButtplugClient: ReceiveDeviceList called"), (await this.sendMessage(
2049
+ new Ne()
2050
+ )).Devices.forEach((n) => {
2051
+ if (this._devices.has(n.DeviceIndex))
2052
+ this._logger.Debug(`ButtplugClient: Device already added: ${n}`);
2053
+ else {
2054
+ const i = me.fromMsg(
2055
+ n,
2056
+ this.sendDeviceMessageClosure
2057
+ );
2058
+ this._logger.Debug(`ButtplugClient: Adding Device: ${i}`), this._devices.set(n.DeviceIndex, i), this.emit("deviceadded", i);
2059
+ }
2060
+ });
2061
+ }, this.shutdownConnection = async () => {
2062
+ await this.stopAllDevices(), this._pingTimer !== null && (clearInterval(this._pingTimer), this._pingTimer = null);
2063
+ }, this.sendMsgExpectOk = async (t) => {
2064
+ const n = await this.sendMessage(t);
2065
+ switch (n.constructor) {
2066
+ case ve:
2067
+ return;
2068
+ case Q:
2069
+ throw U.FromError(n);
2070
+ default:
2071
+ throw U.LogAndError(
2072
+ fe,
2073
+ this._logger,
2074
+ `Message type ${n.constructor} not handled by SendMsgExpectOk`
2075
+ );
2076
+ }
2077
+ }, this.sendDeviceMessageClosure = async (t, n) => await this.sendDeviceMessage(t, n), this._clientName = e, this._logger.Debug(`ButtplugClient: Client ${e} created.`);
2078
+ }
2079
+ get connected() {
2080
+ return this._connector !== null && this._connector.Connected;
2081
+ }
2082
+ get devices() {
2083
+ this.checkConnector();
2084
+ const e = [];
2085
+ return this._devices.forEach((t) => {
2086
+ e.push(t);
2087
+ }), e;
2088
+ }
2089
+ get isScanning() {
2090
+ return this._isScanning;
2091
+ }
2092
+ async sendDeviceMessage(e, t) {
2093
+ if (this.checkConnector(), this._devices.get(e.index) === void 0)
2094
+ throw U.LogAndError(
2095
+ P,
2096
+ this._logger,
2097
+ `Device ${e.index} not available.`
2098
+ );
2099
+ return t.DeviceIndex = e.index, await this.sendMessage(t);
2100
+ }
2101
+ async sendMessage(e) {
2102
+ this.checkConnector();
2103
+ const t = this._sorter.PrepareOutgoingMessage(e);
2104
+ return await this._connector.send(e), await t;
2105
+ }
2106
+ checkConnector() {
2107
+ if (!this.connected)
2108
+ throw new Qt(
2109
+ "ButtplugClient not connected"
2110
+ );
2111
+ }
2112
+ }
2113
+ function Kt(r) {
2114
+ for (const e of Object.values(Ht))
2115
+ if (typeof e == "function" && "Name" in e && e.Name === r)
2116
+ return e;
2117
+ return null;
2118
+ }
2119
+ function it(r) {
2120
+ const e = JSON.parse(r), t = [];
2121
+ for (const n of Array.from(e)) {
2122
+ const i = Object.getOwnPropertyNames(n)[0], u = Kt(i);
2123
+ if (u) {
2124
+ const a = Ft(
2125
+ u,
2126
+ n[i]
2127
+ );
2128
+ a.update(), t.push(a);
2129
+ }
2130
+ }
2131
+ return t;
2132
+ }
2133
+ class Vt extends ye {
2134
+ constructor(e) {
2135
+ super(), this._url = e, this._websocketConstructor = null, this.connect = async () => {
2136
+ const t = new (this._websocketConstructor ?? WebSocket)(this._url);
2137
+ let n, i;
2138
+ const u = new Promise((f, l) => {
2139
+ n = f, i = l;
2140
+ }), a = () => i();
2141
+ return t.addEventListener("open", async () => {
2142
+ this._ws = t;
2143
+ try {
2144
+ await this.initialize(), this._ws.addEventListener("message", (f) => {
2145
+ this.parseIncomingMessage(f);
2146
+ }), this._ws.removeEventListener("close", a), this._ws.addEventListener("close", this.disconnect), n();
2147
+ } catch (f) {
2148
+ console.log(f), i();
2149
+ }
2150
+ }), t.addEventListener("close", a), u;
2151
+ }, this.disconnect = async () => {
2152
+ this.Connected && (this._ws.close(), this._ws = void 0, this.emit("disconnect"));
2153
+ }, this.initialize = async () => Promise.resolve();
2154
+ }
2155
+ get Connected() {
2156
+ return this._ws !== void 0;
2157
+ }
2158
+ sendMessage(e) {
2159
+ if (!this.Connected)
2160
+ throw new Error("ButtplugBrowserWebsocketConnector not connected");
2161
+ this._ws.send("[" + e.toJSON() + "]");
2162
+ }
2163
+ parseIncomingMessage(e) {
2164
+ if (typeof e.data == "string") {
2165
+ const t = it(e.data);
2166
+ this.emit("message", t);
2167
+ } else
2168
+ e.data instanceof Blob;
2169
+ }
2170
+ onReaderLoad(e) {
2171
+ const t = it(e.target.result);
2172
+ this.emit("message", t);
2173
+ }
2174
+ }
2175
+ class en extends Vt {
2176
+ constructor() {
2177
+ super(...arguments), this.send = (e) => {
2178
+ if (!this.Connected)
2179
+ throw new Error("ButtplugClient not connected");
2180
+ this.sendMessage(e);
2181
+ };
2182
+ }
2183
+ }
2184
+ var tn = function() {
2185
+ throw new Error(
2186
+ "ws does not work in the browser. Browser clients must use the native WebSocket object"
2187
+ );
2188
+ };
2189
+ class sn extends en {
2190
+ constructor() {
2191
+ super(...arguments), this._websocketConstructor = tn.WebSocket;
2192
+ }
2193
+ }
2194
+ export {
2195
+ ae as ActuatorType,
2196
+ en as ButtplugBrowserWebsocketClientConnector,
2197
+ rn as ButtplugClient,
2198
+ Qt as ButtplugClientConnectorException,
2199
+ me as ButtplugClientDevice,
2200
+ P as ButtplugDeviceError,
2201
+ J as ButtplugDeviceMessage,
2202
+ U as ButtplugError,
2203
+ Ee as ButtplugInitError,
2204
+ at as ButtplugLogLevel,
2205
+ Tt as ButtplugLogger,
2206
+ H as ButtplugMessage,
2207
+ fe as ButtplugMessageError,
2208
+ Zt as ButtplugMessageSorter,
2209
+ sn as ButtplugNodeWebsocketClientConnector,
2210
+ Yt as ButtplugPingError,
2211
+ ce as ButtplugSystemMessage,
2212
+ Xt as ButtplugUnknownError,
2213
+ D as DEFAULT_MESSAGE_ID,
2214
+ we as DeviceAdded,
2215
+ Re as DeviceInfo,
2216
+ De as DeviceList,
2217
+ Te as DeviceRemoved,
2218
+ Q as Error,
2219
+ z as ErrorClass,
2220
+ zt as GenericDeviceMessageAttributes,
2221
+ _e as GenericMessageSubcommand,
2222
+ Ae as LinearCmd,
2223
+ Dt as LogMessage,
2224
+ Gt as MAX_ID,
2225
+ le as MESSAGE_SPEC_VERSION,
2226
+ Ie as MessageAttributes,
2227
+ ve as Ok,
2228
+ ft as Ping,
2229
+ Jt as RawDeviceMessageAttributes,
2230
+ ze as RawReadCmd,
2231
+ Ye as RawReading,
2232
+ qe as RawSubscribeCmd,
2233
+ He as RawUnsubscribeCmd,
2234
+ Je as RawWriteCmd,
2235
+ Ne as RequestDeviceList,
2236
+ Be as RequestServerInfo,
2237
+ xe as RotateCmd,
2238
+ dt as RotateSubcommand,
2239
+ X as SYSTEM_MESSAGE_ID,
2240
+ ge as ScalarCmd,
2241
+ Ce as ScalarSubcommand,
2242
+ je as ScanningFinished,
2243
+ qt as SensorDeviceMessageAttributes,
2244
+ We as SensorReadCmd,
2245
+ Ge as SensorReading,
2246
+ ee as SensorType,
2247
+ $e as ServerInfo,
2248
+ Pe as StartScanning,
2249
+ Ue as StopAllDevices,
2250
+ Fe as StopDeviceCmd,
2251
+ ke as StopScanning,
2252
+ lt as VectorSubcommand,
2253
+ it as fromJSON
2254
+ };