@busy-app/busy-lib 0.11.0 → 0.12.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.
package/dist/index.js CHANGED
@@ -1,66 +1,66 @@
1
1
  var G = Object.defineProperty;
2
- var P = (n, t, i) => t in n ? G(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
- var c = (n, t, i) => P(n, typeof t != "symbol" ? t + "" : t, i);
4
- import m from "openapi-fetch";
5
- const L = (n, t) => {
2
+ var v = (n, t, e) => t in n ? G(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var u = (n, t, e) => v(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import E from "openapi-fetch";
5
+ const O = (n, t) => {
6
6
  if (typeof FormData < "u" && n instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(n) || typeof File < "u" && n instanceof File || typeof Blob < "u" && n instanceof Blob || typeof ArrayBuffer < "u" && n instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(n))
7
7
  return n;
8
- let i;
9
- return t && (t instanceof Headers ? i = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (i = t["Content-Type"] ?? t["content-type"]), i === "application/x-www-form-urlencoded") ? n && typeof n == "object" && !(n instanceof URLSearchParams) ? new URLSearchParams(n).toString() : String(n) : JSON.stringify(n);
8
+ let e;
9
+ return t && (t instanceof Headers ? e = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (e = t["Content-Type"] ?? t["content-type"]), e === "application/x-www-form-urlencoded") ? n && typeof n == "object" && !(n instanceof URLSearchParams) ? new URLSearchParams(n).toString() : String(n) : JSON.stringify(n);
10
10
  };
11
11
  async function y(n) {
12
- const e = (n.headers.get("content-type") || "").includes("application/json") ? await n.clone().json() : await n.clone().text(), r = typeof e == "object" && e !== null ? e.error || e.message : typeof e == "string" ? e : void 0;
12
+ const i = (n.headers.get("content-type") || "").includes("application/json") ? await n.clone().json() : await n.clone().text(), r = typeof i == "object" && i !== null ? i.error || i.message : typeof i == "string" ? i : void 0;
13
13
  return Object.assign(new Error(r || `HTTP ${n.status} ${n.statusText}`), {
14
14
  status: n.status,
15
15
  statusText: n.statusText,
16
- body: e
16
+ body: i
17
17
  });
18
18
  }
19
19
  async function s(n, t = 3e3) {
20
20
  if (t <= 0)
21
21
  return await n();
22
- const i = new AbortController(), e = setTimeout(() => i.abort(), t);
22
+ const e = new AbortController(), i = setTimeout(() => e.abort(), t);
23
23
  try {
24
- return await n(i.signal);
24
+ return await n(e.signal);
25
25
  } catch (r) {
26
26
  throw r instanceof DOMException && r.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : r;
27
27
  } finally {
28
- clearTimeout(e);
28
+ clearTimeout(i);
29
29
  }
30
30
  }
31
- function O(n, t, i) {
32
- let e, r = i ?? void 0, o, a = null;
33
- const u = async () => {
34
- e || (a || (a = (async () => {
31
+ function L(n, t, e) {
32
+ let i, r = e ?? void 0, o, a = null;
33
+ const c = async () => {
34
+ i || (a || (a = (async () => {
35
35
  const h = await t();
36
36
  if (!h.api_semver)
37
37
  throw new Error("Empty API version");
38
- e = h.api_semver;
38
+ i = h.api_semver;
39
39
  })().finally(() => {
40
40
  a = null;
41
41
  })), await a);
42
- }, w = {
43
- async onRequest({ request: h, schemaPath: d }) {
44
- return r && h.headers.set("Authorization", `Bearer ${r}`), d !== "/version" && (await u(), e && h.headers.set("X-API-Sem-Ver", e), o && h.headers.set("X-API-Token", o)), h;
42
+ }, d = {
43
+ async onRequest({ request: h, schemaPath: w }) {
44
+ return r && h.headers.set("Authorization", `Bearer ${r}`), w !== "/version" && (await c(), i && h.headers.set("X-API-Sem-Ver", i), o && h.headers.set("X-API-Token", o)), h;
45
45
  },
46
- async onResponse({ request: h, response: d, options: b, schemaPath: v }) {
47
- if (d.ok)
48
- return d;
49
- if (v === "/version")
50
- throw await y(d);
51
- if (d.status !== 405)
52
- throw await y(d);
53
- e = void 0, await u(), e && h.headers.set("X-API-Sem-Ver", e), r && h.headers.set("Authorization", `Bearer ${r}`);
46
+ async onResponse({ request: h, response: w, options: b, schemaPath: P }) {
47
+ if (w.ok)
48
+ return w;
49
+ if (P === "/version")
50
+ throw await y(w);
51
+ if (w.status !== 405)
52
+ throw await y(w);
53
+ i = void 0, await c(), i && h.headers.set("X-API-Sem-Ver", i), r && h.headers.set("Authorization", `Bearer ${r}`);
54
54
  const l = await (b.fetch ?? fetch)(h);
55
55
  if (l.ok)
56
56
  return l;
57
57
  throw await y(l);
58
58
  }
59
- }, f = m({
59
+ }, f = E({
60
60
  baseUrl: n,
61
- bodySerializer: L
61
+ bodySerializer: O
62
62
  });
63
- return f.use(w), {
63
+ return f.use(d), {
64
64
  client: f,
65
65
  setApiKey: (h) => {
66
66
  o = h;
@@ -71,42 +71,42 @@ function O(n, t, i) {
71
71
  };
72
72
  }
73
73
  async function D(n, t) {
74
- const { data: i, error: e } = await s((r) => n.GET("/version", { signal: r }), t == null ? void 0 : t.timeout);
75
- if (e)
76
- throw e;
77
- return i;
74
+ const { data: e, error: i } = await s((r) => n.GET("/version", { signal: r }), t == null ? void 0 : t.timeout);
75
+ if (i)
76
+ throw i;
77
+ return e;
78
78
  }
79
79
  async function U(n, t) {
80
- const { data: i, error: e } = await s((r) => n.GET("/status", { signal: r }), t == null ? void 0 : t.timeout);
81
- if (e)
82
- throw e;
83
- return i;
80
+ const { data: e, error: i } = await s((r) => n.GET("/status", { signal: r }), t == null ? void 0 : t.timeout);
81
+ if (i)
82
+ throw i;
83
+ return e;
84
84
  }
85
85
  async function B(n, t) {
86
- const { data: i, error: e } = await s((r) => n.GET("/status/system", { signal: r }), t == null ? void 0 : t.timeout);
87
- if (e)
88
- throw e;
89
- return i;
86
+ const { data: e, error: i } = await s((r) => n.GET("/status/system", { signal: r }), t == null ? void 0 : t.timeout);
87
+ if (i)
88
+ throw i;
89
+ return e;
90
90
  }
91
- async function I(n, t) {
92
- const { data: i, error: e } = await s((r) => n.GET("/status/power", { signal: r }), t == null ? void 0 : t.timeout);
93
- if (e)
94
- throw e;
95
- return i;
91
+ async function _(n, t) {
92
+ const { data: e, error: i } = await s((r) => n.GET("/status/power", { signal: r }), t == null ? void 0 : t.timeout);
93
+ if (i)
94
+ throw i;
95
+ return e;
96
96
  }
97
97
  async function $(n, t) {
98
- const { data: i, error: e } = await s((r) => n.GET("/status/device", { signal: r }), t == null ? void 0 : t.timeout);
99
- if (e)
100
- throw e;
101
- return i;
98
+ const { data: e, error: i } = await s((r) => n.GET("/status/device", { signal: r }), t == null ? void 0 : t.timeout);
99
+ if (i)
100
+ throw i;
101
+ return e;
102
102
  }
103
- async function R(n, t) {
104
- const { data: i, error: e } = await s((r) => n.GET("/status/firmware", { signal: r }), t == null ? void 0 : t.timeout);
105
- if (e)
106
- throw e;
107
- return i;
103
+ async function I(n, t) {
104
+ const { data: e, error: i } = await s((r) => n.GET("/status/firmware", { signal: r }), t == null ? void 0 : t.timeout);
105
+ if (i)
106
+ throw i;
107
+ return e;
108
108
  }
109
- class K {
109
+ class R {
110
110
  /**
111
111
  * Get API version information.
112
112
  *
@@ -115,8 +115,8 @@ class K {
115
115
  * @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
116
116
  */
117
117
  async SystemVersionGet(t) {
118
- const i = await D(this.apiClient, t);
119
- return this.apiSemver = i.api_semver, i;
118
+ const e = await D(this.apiClient, t);
119
+ return this.apiSemver = e.api_semver, e;
120
120
  }
121
121
  /**
122
122
  * Get full status.
@@ -146,7 +146,7 @@ class K {
146
146
  * @returns {Promise<StatusPower>} Current power status.
147
147
  */
148
148
  async SystemStatusPowerGet(t) {
149
- return await I(this.apiClient, t);
149
+ return await _(this.apiClient, t);
150
150
  }
151
151
  /**
152
152
  * Get device status.
@@ -166,42 +166,42 @@ class K {
166
166
  * @returns {Promise<StatusFirmware>} Current firmware status.
167
167
  */
168
168
  async SystemStatusFirmwareGet(t) {
169
- return await R(this.apiClient, t);
169
+ return await I(this.apiClient, t);
170
170
  }
171
171
  }
172
- async function F(n, t) {
173
- const { file: i } = t, { data: e, error: r } = await s(
172
+ async function K(n, t) {
173
+ const { file: e } = t, { data: i, error: r } = await s(
174
174
  (o) => n.POST("/update", {
175
175
  headers: {
176
176
  "Content-Type": "application/octet-stream"
177
177
  },
178
- body: i,
178
+ body: e,
179
179
  signal: o
180
180
  }),
181
181
  t.timeout
182
182
  );
183
183
  if (r)
184
184
  throw r;
185
- return e;
186
- }
187
- async function _(n, t) {
188
- const { data: i, error: e } = await s((r) => n.POST("/update/check", { signal: r }), t == null ? void 0 : t.timeout);
189
- if (e)
190
- throw e;
191
185
  return i;
192
186
  }
187
+ async function F(n, t) {
188
+ const { data: e, error: i } = await s((r) => n.POST("/update/check", { signal: r }), t == null ? void 0 : t.timeout);
189
+ if (i)
190
+ throw i;
191
+ return e;
192
+ }
193
193
  async function W(n, t) {
194
- const { data: i, error: e } = await s((r) => n.GET("/update/status", { signal: r }), t == null ? void 0 : t.timeout);
195
- if (e)
196
- throw e;
197
- return i;
194
+ const { data: e, error: i } = await s((r) => n.GET("/update/status", { signal: r }), t == null ? void 0 : t.timeout);
195
+ if (i)
196
+ throw i;
197
+ return e;
198
198
  }
199
199
  async function M(n, t) {
200
- const { version: i } = t, { data: e, error: r } = await s(
200
+ const { version: e } = t, { data: i, error: r } = await s(
201
201
  (o) => n.GET("/update/changelog", {
202
202
  params: {
203
203
  query: {
204
- version: i
204
+ version: e
205
205
  }
206
206
  },
207
207
  signal: o
@@ -210,14 +210,14 @@ async function M(n, t) {
210
210
  );
211
211
  if (r)
212
212
  throw r;
213
- return e;
213
+ return i;
214
214
  }
215
- async function N(n, t) {
216
- const { version: i } = t, { data: e, error: r } = await s(
215
+ async function q(n, t) {
216
+ const { version: e } = t, { data: i, error: r } = await s(
217
217
  (o) => n.POST("/update/install", {
218
218
  params: {
219
219
  query: {
220
- version: i
220
+ version: e
221
221
  }
222
222
  },
223
223
  signal: o
@@ -226,25 +226,25 @@ async function N(n, t) {
226
226
  );
227
227
  if (r)
228
228
  throw r;
229
- return e;
230
- }
231
- async function q(n, t) {
232
- const { data: i, error: e } = await s((r) => n.POST("/update/abort_download", { signal: r }), t == null ? void 0 : t.timeout);
233
- if (e)
234
- throw e;
235
229
  return i;
236
230
  }
231
+ async function N(n, t) {
232
+ const { data: e, error: i } = await s((r) => n.POST("/update/abort_download", { signal: r }), t == null ? void 0 : t.timeout);
233
+ if (i)
234
+ throw i;
235
+ return e;
236
+ }
237
237
  async function x(n, t) {
238
- const { data: i, error: e } = await s((r) => n.GET("/update/autoupdate", { signal: r }), t == null ? void 0 : t.timeout);
239
- if (e)
240
- throw e;
241
- return i;
238
+ const { data: e, error: i } = await s((r) => n.GET("/update/autoupdate", { signal: r }), t == null ? void 0 : t.timeout);
239
+ if (i)
240
+ throw i;
241
+ return e;
242
242
  }
243
- async function V(n, t) {
244
- const { is_enabled: i, interval_start: e, interval_end: r } = t, { data: o, error: a } = await s(
245
- (u) => n.POST("/update/autoupdate", {
246
- body: { is_enabled: i, interval_start: e, interval_end: r },
247
- signal: u
243
+ async function H(n, t) {
244
+ const { is_enabled: e, interval_start: i, interval_end: r } = t, { data: o, error: a } = await s(
245
+ (c) => n.POST("/update/autoupdate", {
246
+ body: { is_enabled: e, interval_start: i, interval_end: r },
247
+ signal: c
248
248
  }),
249
249
  t.timeout
250
250
  );
@@ -252,7 +252,7 @@ async function V(n, t) {
252
252
  throw a;
253
253
  return o;
254
254
  }
255
- class j {
255
+ class V {
256
256
  /**
257
257
  * Upload firmware update package.
258
258
  *
@@ -262,7 +262,7 @@ class j {
262
262
  * @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
263
263
  */
264
264
  async UpdateFromFile(t) {
265
- return await F(this.apiClient, t);
265
+ return await K(this.apiClient, t);
266
266
  }
267
267
  /**
268
268
  * Start firmware update check.
@@ -272,7 +272,7 @@ class j {
272
272
  * @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
273
273
  */
274
274
  async UpdateCheck(t) {
275
- return await _(this.apiClient, t);
275
+ return await F(this.apiClient, t);
276
276
  }
277
277
  /**
278
278
  * Get firmware update status.
@@ -304,7 +304,7 @@ class j {
304
304
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
305
305
  */
306
306
  async UpdateInstall(t) {
307
- return await N(this.apiClient, t);
307
+ return await q(this.apiClient, t);
308
308
  }
309
309
  /**
310
310
  * Abort firmware update download.
@@ -314,7 +314,7 @@ class j {
314
314
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
315
315
  */
316
316
  async UpdateAbort(t) {
317
- return await q(this.apiClient, t);
317
+ return await N(this.apiClient, t);
318
318
  }
319
319
  /**
320
320
  * Get current auto-update settings.
@@ -337,54 +337,54 @@ class j {
337
337
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
338
338
  */
339
339
  async UpdateAutoUpdateSet(t) {
340
- return await V(this.apiClient, t);
340
+ return await H(this.apiClient, t);
341
341
  }
342
342
  }
343
- async function z(n, t) {
344
- const { data: i, error: e } = await s((r) => n.GET("/time", { signal: r }), t == null ? void 0 : t.timeout);
345
- if (e)
346
- throw e;
347
- return i;
343
+ async function j(n, t) {
344
+ const { data: e, error: i } = await s((r) => n.GET("/time", { signal: r }), t == null ? void 0 : t.timeout);
345
+ if (i)
346
+ throw i;
347
+ return e;
348
348
  }
349
- async function H(n, t) {
350
- const { data: i, error: e } = await s(
351
- (r) => n.POST("/time/timestamp", {
349
+ async function z(n, t) {
350
+ const { timestamp: e } = t, { data: i, error: r } = await s(
351
+ (o) => n.POST("/time/timestamp", {
352
352
  params: {
353
- query: { ...t, timeout: void 0 }
353
+ query: { timestamp: e }
354
354
  },
355
- signal: r
355
+ signal: o
356
356
  }),
357
357
  t.timeout
358
358
  );
359
- if (e)
360
- throw e;
359
+ if (r)
360
+ throw r;
361
361
  return i;
362
362
  }
363
363
  async function J(n, t) {
364
- const { data: i, error: e } = await s((r) => n.GET("/time/timezone", { signal: r }), t == null ? void 0 : t.timeout);
365
- if (e)
366
- throw e;
367
- return i;
364
+ const { data: e, error: i } = await s((r) => n.GET("/time/timezone", { signal: r }), t == null ? void 0 : t.timeout);
365
+ if (i)
366
+ throw i;
367
+ return e;
368
368
  }
369
369
  async function X(n, t) {
370
- const { data: i, error: e } = await s(
371
- (r) => n.POST("/time/timezone", {
370
+ const { timezone: e } = t, { data: i, error: r } = await s(
371
+ (o) => n.POST("/time/timezone", {
372
372
  params: {
373
- query: { ...t, timeout: void 0 }
373
+ query: { timezone: e }
374
374
  },
375
- signal: r
375
+ signal: o
376
376
  }),
377
377
  t.timeout
378
378
  );
379
- if (e)
380
- throw e;
379
+ if (r)
380
+ throw r;
381
381
  return i;
382
382
  }
383
383
  async function Y(n, t) {
384
- const { data: i, error: e } = await s((r) => n.GET("/time/tzlist", { signal: r }), t == null ? void 0 : t.timeout);
385
- if (e)
386
- throw e;
387
- return i;
384
+ const { data: e, error: i } = await s((r) => n.GET("/time/tzlist", { signal: r }), t == null ? void 0 : t.timeout);
385
+ if (i)
386
+ throw i;
387
+ return e;
388
388
  }
389
389
  class Q {
390
390
  /**
@@ -395,7 +395,7 @@ class Q {
395
395
  * @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
396
396
  */
397
397
  async TimeGet(t) {
398
- return await z(this.apiClient, t);
398
+ return await j(this.apiClient, t);
399
399
  }
400
400
  /**
401
401
  * Set system timestamp.
@@ -406,7 +406,7 @@ class Q {
406
406
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
407
407
  */
408
408
  async TimeTimestampSet(t) {
409
- return await H(this.apiClient, t);
409
+ return await z(this.apiClient, t);
410
410
  }
411
411
  /**
412
412
  * Get current timezone.
@@ -441,50 +441,51 @@ class Q {
441
441
  }
442
442
  }
443
443
  async function Z(n, t) {
444
- const { data: i, error: e } = await s((r) => n.GET("/account/status", { signal: r }), t == null ? void 0 : t.timeout);
445
- if (e)
446
- throw e;
447
- return i;
444
+ const { data: e, error: i } = await s((r) => n.GET("/account/status", { signal: r }), t == null ? void 0 : t.timeout);
445
+ if (i)
446
+ throw i;
447
+ return e;
448
448
  }
449
449
  async function tt(n, t) {
450
- const { data: i, error: e } = await s((r) => n.GET("/account/info", { signal: r }), t == null ? void 0 : t.timeout);
451
- if (e)
452
- throw e;
453
- return i;
450
+ const { data: e, error: i } = await s((r) => n.GET("/account/info", { signal: r }), t == null ? void 0 : t.timeout);
451
+ if (i)
452
+ throw i;
453
+ return e;
454
454
  }
455
455
  async function et(n, t) {
456
- const { data: i, error: e } = await s((r) => n.GET("/account/profile", { signal: r }), t == null ? void 0 : t.timeout);
457
- if (e)
458
- throw e;
459
- return i;
456
+ const { data: e, error: i } = await s((r) => n.GET("/account/profile", { signal: r }), t == null ? void 0 : t.timeout);
457
+ if (i)
458
+ throw i;
459
+ return e;
460
460
  }
461
461
  async function it(n, t) {
462
- const { profile: i } = t, { data: e, error: r } = await s(
463
- (o) => n.POST("/account/profile", {
462
+ const { profile: e, custom_url: i } = t, { data: r, error: o } = await s(
463
+ (a) => n.POST("/account/profile", {
464
464
  params: {
465
465
  query: {
466
- profile: i
466
+ profile: e,
467
+ custom_url: i
467
468
  }
468
469
  },
469
- signal: o
470
+ signal: a
470
471
  }),
471
472
  t.timeout
472
473
  );
473
- if (r)
474
- throw r;
475
- return e;
474
+ if (o)
475
+ throw o;
476
+ return r;
476
477
  }
477
478
  async function nt(n, t) {
478
- const { data: i, error: e } = await s((r) => n.DELETE("/account", { signal: r }), t == null ? void 0 : t.timeout);
479
- if (e)
480
- throw e;
481
- return i;
479
+ const { data: e, error: i } = await s((r) => n.DELETE("/account", { signal: r }), t == null ? void 0 : t.timeout);
480
+ if (i)
481
+ throw i;
482
+ return e;
482
483
  }
483
484
  async function rt(n, t) {
484
- const { data: i, error: e } = await s((r) => n.POST("/account/link", { signal: r }), t == null ? void 0 : t.timeout);
485
- if (e)
486
- throw e;
487
- return i;
485
+ const { data: e, error: i } = await s((r) => n.POST("/account/link", { signal: r }), t == null ? void 0 : t.timeout);
486
+ if (i)
487
+ throw i;
488
+ return e;
488
489
  }
489
490
  class ot {
490
491
  /**
@@ -502,7 +503,7 @@ class ot {
502
503
  *
503
504
  * @param {TimeoutOptions} [params] - Optional parameters.
504
505
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
505
- * @returns {Promise<AccountState>} A promise that resolves to the account state.
506
+ * @returns {Promise<AccountStatus>} A promise that resolves to the account state.
506
507
  */
507
508
  async AccountStateGet(t) {
508
509
  return await Z(this.apiClient, t);
@@ -521,7 +522,8 @@ class ot {
521
522
  * Set account profile.
522
523
  *
523
524
  * @param {SetAccountProfileParams} params - Parameters for setting the account profile.
524
- * @param {string} params.profile - Profile data string.
525
+ * @param {string} params.profile - Profile name.
526
+ * @param {string} [params.custom_url] - Custom profile URL.
525
527
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
526
528
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
527
529
  */
@@ -550,67 +552,76 @@ class ot {
550
552
  }
551
553
  }
552
554
  async function st(n, t) {
553
- const { appId: i, elements: e, priority: r = 6 } = t, { data: o, error: a } = await s(
554
- (u) => n.POST("/display/draw", {
555
+ const { application_name: e, elements: i, priority: r = 50, timeout: o } = t, { data: a, error: c } = await s(
556
+ (d) => n.POST("/display/draw", {
555
557
  body: {
556
- app_id: i,
558
+ application_name: e,
557
559
  priority: r,
558
- elements: e
560
+ elements: i
559
561
  },
560
- signal: u
562
+ signal: d
561
563
  }),
562
- t.timeout
564
+ o
563
565
  );
564
- if (a)
565
- throw a;
566
- return o;
566
+ if (c)
567
+ throw c;
568
+ return a;
567
569
  }
568
570
  async function at(n, t) {
569
- const { data: i, error: e } = await s((r) => n.DELETE("/display/draw", { signal: r }), t == null ? void 0 : t.timeout);
570
- if (e)
571
- throw e;
572
- return i;
571
+ const { data: e, error: i } = await s(
572
+ (r) => n.DELETE("/display/draw", {
573
+ params: {
574
+ query: {
575
+ application_name: t == null ? void 0 : t.application_name
576
+ }
577
+ },
578
+ signal: r
579
+ }),
580
+ t == null ? void 0 : t.timeout
581
+ );
582
+ if (i)
583
+ throw i;
584
+ return e;
573
585
  }
574
586
  async function ct(n, t) {
575
- const { display: i } = t, { data: e, error: r } = await s(
576
- (o) => n.GET("/screen", {
587
+ const { display: e, timeout: i } = t, { data: r, error: o } = await s(
588
+ (a) => n.GET("/screen", {
577
589
  params: {
578
590
  query: {
579
- display: i
591
+ display: e
580
592
  }
581
593
  },
582
594
  parseAs: "blob",
583
- signal: o
595
+ signal: a
584
596
  }),
585
- t.timeout
597
+ i
586
598
  );
587
- if (r)
588
- throw r;
589
- return e;
599
+ if (o)
600
+ throw o;
601
+ return r;
590
602
  }
591
603
  async function ut(n, t) {
592
- const { data: i, error: e } = await s((r) => n.GET("/display/brightness", { signal: r }), t == null ? void 0 : t.timeout);
593
- if (e)
594
- throw e;
595
- return i;
604
+ const { data: e, error: i } = await s((r) => n.GET("/display/brightness", { signal: r }), t == null ? void 0 : t.timeout);
605
+ if (i)
606
+ throw i;
607
+ return e;
596
608
  }
597
609
  async function ht(n, t) {
598
- const { value: i } = t, r = ((u) => {
599
- if (typeof u == "number") {
600
- if (u < 0 || u > 100)
610
+ const { value: e } = t, r = ((c) => {
611
+ if (typeof c == "number") {
612
+ if (c < 0 || c > 100)
601
613
  throw new Error("Brightness value must be between 0 and 100 or 'auto'");
602
- return String(u);
614
+ return String(c);
603
615
  }
604
- if (u === "auto")
605
- return "auto";
606
- })(i), { data: o, error: a } = await s(
607
- (u) => n.POST("/display/brightness", {
616
+ return "auto";
617
+ })(e), { data: o, error: a } = await s(
618
+ (c) => n.POST("/display/brightness", {
608
619
  params: {
609
620
  query: {
610
621
  value: r
611
622
  }
612
623
  },
613
- signal: u
624
+ signal: c
614
625
  }),
615
626
  t.timeout
616
627
  );
@@ -620,12 +631,12 @@ async function ht(n, t) {
620
631
  }
621
632
  class dt {
622
633
  /**
623
- * Draw on display. Starts the Canvas application if not running.
634
+ * Draw on display. Sends drawing data to the display. Supports JSON-defined display elements.
624
635
  *
625
636
  * @param {DrawParams} params - Parameters for the draw operation.
626
- * @param {DrawParams['appId']} params.appId - Application ID.
627
- * @param {DrawParams['elements']} params.elements - Display elements to draw.
628
- * @param {DrawParams['priority']} [params.priority=6] - Priority for the draw request (1-10).
637
+ * @param {string} params.application_name - Application ID for organizing assets.
638
+ * @param {Array} params.elements - Display elements to draw.
639
+ * @param {number} [params.priority=50] - Draw priority in the range [1, 100].
629
640
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
630
641
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
631
642
  */
@@ -633,9 +644,11 @@ class dt {
633
644
  return await st(this.apiClient, t);
634
645
  }
635
646
  /**
636
- * Clear display. Clears the display and stops the Canvas application if running.
647
+ * Clear display. Deletes display elements drawn by the Canvas application.
648
+ * If application_name is specified, only elements for that app are removed.
637
649
  *
638
- * @param {TimeoutOptions} [params] - Optional parameters.
650
+ * @param {ClearParams} [params] - Optional parameters.
651
+ * @param {string} [params.application_name] - Application identifier.
639
652
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
640
653
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
641
654
  */
@@ -646,7 +659,7 @@ class dt {
646
659
  * Get single frame for requested screen.
647
660
  *
648
661
  * @param {GetScreenFrameParams} params - Parameters for the frame request.
649
- * @param {string} params.display - Display identifier.
662
+ * @param {number} params.display - Type of the display (Front = 0, Back = 1).
650
663
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
651
664
  * @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
652
665
  */
@@ -666,8 +679,8 @@ class dt {
666
679
  /**
667
680
  * Set display brightness.
668
681
  *
669
- * @param {BrightnessParams} params - Brightness parameters:
670
- * @param {BrightnessParams['value']} [params.value] - Brightness (0-100 or "auto").
682
+ * @param {BrightnessParams} params - Brightness parameters.
683
+ * @param {number | 'auto'} params.value - Brightness (0-100 or "auto").
671
684
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
672
685
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
673
686
  */
@@ -675,13 +688,13 @@ class dt {
675
688
  return await ht(this.apiClient, t);
676
689
  }
677
690
  }
678
- async function ft(n, t) {
679
- const { appId: i, path: e } = t, { data: r, error: o } = await s(
691
+ async function wt(n, t) {
692
+ const { application_name: e, path: i } = t, { data: r, error: o } = await s(
680
693
  (a) => n.POST("/audio/play", {
681
694
  params: {
682
695
  query: {
683
- app_id: i,
684
- path: e
696
+ application_name: e,
697
+ path: i
685
698
  }
686
699
  },
687
700
  signal: a
@@ -692,27 +705,27 @@ async function ft(n, t) {
692
705
  throw o;
693
706
  return r;
694
707
  }
695
- async function wt(n, t) {
696
- const { data: i, error: e } = await s((r) => n.DELETE("/audio/play", { signal: r }), t == null ? void 0 : t.timeout);
697
- if (e)
698
- throw e;
699
- return i;
708
+ async function ft(n, t) {
709
+ const { data: e, error: i } = await s((r) => n.DELETE("/audio/play", { signal: r }), t == null ? void 0 : t.timeout);
710
+ if (i)
711
+ throw i;
712
+ return e;
700
713
  }
701
714
  async function lt(n, t) {
702
- const { data: i, error: e } = await s((r) => n.GET("/audio/volume", { signal: r }), t == null ? void 0 : t.timeout);
703
- if (e)
704
- throw e;
705
- return i;
715
+ const { data: e, error: i } = await s((r) => n.GET("/audio/volume", { signal: r }), t == null ? void 0 : t.timeout);
716
+ if (i)
717
+ throw i;
718
+ return e;
706
719
  }
707
720
  async function yt(n, t) {
708
- const { volume: i } = t;
709
- if (typeof i != "number" || i < 0 || i > 100)
721
+ const { volume: e } = t;
722
+ if (typeof e != "number" || e < 0 || e > 100)
710
723
  throw new Error("Volume must be a number between 0 and 100");
711
- const { data: e, error: r } = await s(
724
+ const { data: i, error: r } = await s(
712
725
  (o) => n.POST("/audio/volume", {
713
726
  params: {
714
727
  query: {
715
- volume: i
728
+ volume: e
716
729
  }
717
730
  },
718
731
  signal: o
@@ -721,20 +734,20 @@ async function yt(n, t) {
721
734
  );
722
735
  if (r)
723
736
  throw r;
724
- return e;
737
+ return i;
725
738
  }
726
739
  class pt {
727
740
  /**
728
741
  * Play audio file. Plays a file from internal storage.
729
742
  *
730
743
  * @param {AudioPlayParams} params - Parameters for audio playback.
731
- * @param {string} params.appId - Application ID.
744
+ * @param {string} params.application_name - Application name.
732
745
  * @param {string} params.path - Path to the audio file.
733
746
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
734
747
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
735
748
  */
736
749
  async AudioPlay(t) {
737
- return await ft(this.apiClient, t);
750
+ return await wt(this.apiClient, t);
738
751
  }
739
752
  /**
740
753
  * Stop audio playback. Stops any currently playing audio.
@@ -744,7 +757,7 @@ class pt {
744
757
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
745
758
  */
746
759
  async AudioStop(t) {
747
- return await wt(this.apiClient, t);
760
+ return await ft(this.apiClient, t);
748
761
  }
749
762
  /**
750
763
  * Get audio volume.
@@ -769,44 +782,39 @@ class pt {
769
782
  }
770
783
  }
771
784
  async function St(n, t) {
772
- const { data: i, error: e } = await s((r) => n.GET("/wifi/status", { signal: r }), t == null ? void 0 : t.timeout);
773
- if (e)
774
- throw e;
775
- return i;
785
+ const { data: e, error: i } = await s((r) => n.GET("/wifi/status", { signal: r }), t == null ? void 0 : t.timeout);
786
+ if (i)
787
+ throw i;
788
+ return e;
776
789
  }
777
- async function Tt(n, t) {
778
- const { data: i, error: e } = await s(
779
- (r) => n.POST("/wifi/connect", {
790
+ async function mt(n, t) {
791
+ const { ssid: e, password: i, security: r, ip_config: o } = t, { data: a, error: c } = await s(
792
+ (d) => n.POST("/wifi/connect", {
780
793
  body: {
781
- ssid: t.ssid,
782
- password: t.password,
783
- security: t.security,
784
- ip_config: {
785
- ip_method: t.ipConfig.ipMethod,
786
- address: t.ipConfig.address,
787
- mask: t.ipConfig.mask,
788
- gateway: t.ipConfig.gateway
789
- }
794
+ ssid: e,
795
+ password: i,
796
+ security: r,
797
+ ip_config: o
790
798
  },
791
- signal: r
799
+ signal: d
792
800
  }),
793
801
  t.timeout
794
802
  );
795
- if (e)
796
- throw e;
797
- return i;
803
+ if (c)
804
+ throw c;
805
+ return a;
798
806
  }
799
- async function Et(n, t) {
800
- const { data: i, error: e } = await s((r) => n.POST("/wifi/disconnect", { signal: r }), t == null ? void 0 : t.timeout);
801
- if (e)
802
- throw e;
803
- return i;
807
+ async function Tt(n, t) {
808
+ const { data: e, error: i } = await s((r) => n.POST("/wifi/disconnect", { signal: r }), t == null ? void 0 : t.timeout);
809
+ if (i)
810
+ throw i;
811
+ return e;
804
812
  }
805
- async function mt(n, t) {
806
- const { data: i, error: e } = await s((r) => n.GET("/wifi/networks", { signal: r }), t == null ? void 0 : t.timeout);
807
- if (e)
808
- throw e;
809
- return i;
813
+ async function Et(n, t) {
814
+ const { data: e, error: i } = await s((r) => n.GET("/wifi/networks", { signal: r }), t == null ? void 0 : t.timeout);
815
+ if (i)
816
+ throw i;
817
+ return e;
810
818
  }
811
819
  class Ct {
812
820
  /**
@@ -826,12 +834,12 @@ class Ct {
826
834
  * @param {string} params.ssid - Network SSID.
827
835
  * @param {string} params.password - Network password.
828
836
  * @param {WifiSecurityMethod} params.security - Security method.
829
- * @param {object} params.ipConfig - IP configuration.
837
+ * @param {object} [params.ip_config] - IP configuration.
830
838
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
831
839
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
832
840
  */
833
841
  async WifiConnect(t) {
834
- return await Tt(this.apiClient, t);
842
+ return await mt(this.apiClient, t);
835
843
  }
836
844
  /**
837
845
  * Disconnects from Wi-Fi.
@@ -841,7 +849,7 @@ class Ct {
841
849
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
842
850
  */
843
851
  async WifiDisconnect(t) {
844
- return await Et(this.apiClient, t);
852
+ return await Tt(this.apiClient, t);
845
853
  }
846
854
  /**
847
855
  * Scans environment for available Wi-Fi networks.
@@ -851,21 +859,21 @@ class Ct {
851
859
  * @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
852
860
  */
853
861
  async WifiNetworksGet(t) {
854
- return await mt(this.apiClient, t);
862
+ return await Et(this.apiClient, t);
855
863
  }
856
864
  }
857
865
  async function kt(n, t) {
858
- const { path: i, file: e } = t, { data: r, error: o } = await s(
866
+ const { path: e, file: i } = t, { data: r, error: o } = await s(
859
867
  (a) => n.POST("/storage/write", {
860
868
  params: {
861
869
  query: {
862
- path: i
870
+ path: e
863
871
  }
864
872
  },
865
873
  headers: {
866
874
  "Content-Type": "application/octet-stream"
867
875
  },
868
- body: e,
876
+ body: i,
869
877
  signal: a
870
878
  }),
871
879
  t.timeout
@@ -875,14 +883,14 @@ async function kt(n, t) {
875
883
  return r;
876
884
  }
877
885
  async function gt(n, t) {
878
- const { path: i, asArrayBuffer: e } = t, { data: r, error: o } = await s(
886
+ const { path: e, as_array_buffer: i } = t, { data: r, error: o } = await s(
879
887
  (a) => n.GET("/storage/read", {
880
888
  params: {
881
889
  query: {
882
- path: i
890
+ path: e
883
891
  }
884
892
  },
885
- parseAs: e ? "arrayBuffer" : "blob",
893
+ parseAs: i ? "arrayBuffer" : "blob",
886
894
  signal: a
887
895
  }),
888
896
  t.timeout
@@ -892,11 +900,11 @@ async function gt(n, t) {
892
900
  return r;
893
901
  }
894
902
  async function At(n, t) {
895
- const { path: i } = t, { data: e, error: r } = await s(
903
+ const { path: e } = t, { data: i, error: r } = await s(
896
904
  (o) => n.GET("/storage/list", {
897
905
  params: {
898
906
  query: {
899
- path: i
907
+ path: e
900
908
  }
901
909
  },
902
910
  signal: o
@@ -905,14 +913,14 @@ async function At(n, t) {
905
913
  );
906
914
  if (r)
907
915
  throw r;
908
- return e;
916
+ return i;
909
917
  }
910
918
  async function bt(n, t) {
911
- const { path: i } = t, { data: e, error: r } = await s(
919
+ const { path: e } = t, { data: i, error: r } = await s(
912
920
  (o) => n.DELETE("/storage/remove", {
913
921
  params: {
914
922
  query: {
915
- path: i
923
+ path: e
916
924
  }
917
925
  },
918
926
  signal: o
@@ -921,14 +929,14 @@ async function bt(n, t) {
921
929
  );
922
930
  if (r)
923
931
  throw r;
924
- return e;
932
+ return i;
925
933
  }
926
- async function vt(n, t) {
927
- const { path: i } = t, { data: e, error: r } = await s(
934
+ async function Pt(n, t) {
935
+ const { path: e } = t, { data: i, error: r } = await s(
928
936
  (o) => n.POST("/storage/mkdir", {
929
937
  params: {
930
938
  query: {
931
- path: i
939
+ path: e
932
940
  }
933
941
  },
934
942
  signal: o
@@ -937,21 +945,21 @@ async function vt(n, t) {
937
945
  );
938
946
  if (r)
939
947
  throw r;
940
- return e;
948
+ return i;
941
949
  }
942
950
  async function Gt(n, t) {
943
- const { data: i, error: e } = await s((r) => n.GET("/storage/status", { signal: r }), t == null ? void 0 : t.timeout);
944
- if (e)
945
- throw e;
946
- return i;
951
+ const { data: e, error: i } = await s((r) => n.GET("/storage/status", { signal: r }), t == null ? void 0 : t.timeout);
952
+ if (i)
953
+ throw i;
954
+ return e;
947
955
  }
948
- async function Pt(n, t) {
949
- const { path: i, new_path: e } = t, { data: r, error: o } = await s(
956
+ async function vt(n, t) {
957
+ const { path: e, new_path: i } = t, { data: r, error: o } = await s(
950
958
  (a) => n.POST("/storage/rename", {
951
959
  params: {
952
960
  query: {
953
- path: i,
954
- new_path: e
961
+ path: e,
962
+ new_path: i
955
963
  }
956
964
  },
957
965
  signal: a
@@ -962,7 +970,7 @@ async function Pt(n, t) {
962
970
  throw o;
963
971
  return r;
964
972
  }
965
- class Lt {
973
+ class Ot {
966
974
  /**
967
975
  * Upload file to internal storage. Uploads a file to a specified path.
968
976
  *
@@ -980,7 +988,7 @@ class Lt {
980
988
  *
981
989
  * @param {DownloadFileParams} params - Download parameters:
982
990
  * @param {string} params.path - Path to the file.
983
- * @param {boolean} [params.asArrayBuffer] - Whether to return ArrayBuffer instead of Blob.
991
+ * @param {boolean} [params.as_array_buffer] - Whether to return ArrayBuffer instead of Blob.
984
992
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
985
993
  * @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
986
994
  */
@@ -1018,7 +1026,7 @@ class Lt {
1018
1026
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
1019
1027
  */
1020
1028
  async StorageMkdir(t) {
1021
- return await vt(this.apiClient, t);
1029
+ return await Pt(this.apiClient, t);
1022
1030
  }
1023
1031
  /**
1024
1032
  * Show storage usage.
@@ -1040,54 +1048,54 @@ class Lt {
1040
1048
  * @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
1041
1049
  */
1042
1050
  async StorageRename(t) {
1043
- return await Pt(this.apiClient, t);
1051
+ return await vt(this.apiClient, t);
1044
1052
  }
1045
1053
  }
1046
- async function Ot(n, t) {
1047
- const { data: i, error: e } = await s((r) => n.GET("/access", { signal: r }), t == null ? void 0 : t.timeout);
1048
- if (e)
1049
- throw e;
1050
- return i;
1054
+ async function Lt(n, t) {
1055
+ const { data: e, error: i } = await s((r) => n.GET("/access", { signal: r }), t == null ? void 0 : t.timeout);
1056
+ if (i)
1057
+ throw i;
1058
+ return e;
1051
1059
  }
1052
1060
  async function Dt(n, t) {
1053
- let { mode: i, key: e } = t;
1054
- if (e = e ?? "", String(e).trim() && !/^\d{4,10}$/.test(String(e)))
1061
+ const { mode: e, key: i } = t, r = i ?? "";
1062
+ if (String(r).trim() && !/^\d{4,10}$/.test(String(r)))
1055
1063
  throw new Error("Key must be a string of 4 to 10 digits");
1056
- const { data: r, error: o } = await s(
1057
- (a) => n.POST("/access", {
1064
+ const { data: o, error: a } = await s(
1065
+ (c) => n.POST("/access", {
1058
1066
  params: {
1059
1067
  query: {
1060
- mode: i,
1061
- key: e
1068
+ mode: e,
1069
+ key: r
1062
1070
  }
1063
1071
  },
1064
- signal: a
1072
+ signal: c
1065
1073
  }),
1066
1074
  t.timeout
1067
1075
  );
1068
- if (o)
1069
- throw o;
1070
- return r;
1076
+ if (a)
1077
+ throw a;
1078
+ return o;
1071
1079
  }
1072
1080
  async function Ut(n, t) {
1073
- const { data: i, error: e } = await s((r) => n.GET("/name", { signal: r }), t == null ? void 0 : t.timeout);
1074
- if (e)
1075
- throw e;
1076
- return i;
1081
+ const { data: e, error: i } = await s((r) => n.GET("/name", { signal: r }), t == null ? void 0 : t.timeout);
1082
+ if (i)
1083
+ throw i;
1084
+ return e;
1077
1085
  }
1078
1086
  async function Bt(n, t) {
1079
- const { data: i, error: e } = await s(
1080
- (r) => n.POST("/name", {
1081
- body: t,
1082
- signal: r
1087
+ const { name: e } = t, { data: i, error: r } = await s(
1088
+ (o) => n.POST("/name", {
1089
+ body: { name: e },
1090
+ signal: o
1083
1091
  }),
1084
1092
  t.timeout
1085
1093
  );
1086
- if (e)
1087
- throw e;
1094
+ if (r)
1095
+ throw r;
1088
1096
  return i;
1089
1097
  }
1090
- class It {
1098
+ class _t {
1091
1099
  /**
1092
1100
  * Get HTTP API access over Wi-Fi configuration.
1093
1101
  *
@@ -1096,20 +1104,20 @@ class It {
1096
1104
  * @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
1097
1105
  */
1098
1106
  async SettingsAccessGet(t) {
1099
- return await Ot(this.apiClient, t);
1107
+ return await Lt(this.apiClient, t);
1100
1108
  }
1101
1109
  /**
1102
1110
  * Set HTTP API access over Wi-Fi configuration.
1103
1111
  *
1104
1112
  * @param {HttpAccessParams} params - Access parameters:
1105
1113
  * @param {boolean} params.mode - Enable/disable access.
1106
- * @param {string} params.key - Access key (4-10 digits).
1114
+ * @param {string} [params.key] - Access key (4-10 digits).
1107
1115
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1108
1116
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1109
1117
  */
1110
1118
  async SettingsAccessSet(t) {
1111
- const i = await Dt(this.apiClient, t);
1112
- return t.mode === "key" && t.key && this.setApiKey(t.key), i;
1119
+ const e = await Dt(this.apiClient, t);
1120
+ return t.mode === "key" && t.key && this.setApiKey(t.key), e;
1113
1121
  }
1114
1122
  /**
1115
1123
  * Get current device name.
@@ -1134,30 +1142,30 @@ class It {
1134
1142
  }
1135
1143
  }
1136
1144
  async function $t(n, t) {
1137
- const { data: i, error: e } = await s((r) => n.POST("/ble/enable", { signal: r }), t == null ? void 0 : t.timeout);
1138
- if (e)
1139
- throw e;
1140
- return i;
1145
+ const { data: e, error: i } = await s((r) => n.POST("/ble/enable", { signal: r }), t == null ? void 0 : t.timeout);
1146
+ if (i)
1147
+ throw i;
1148
+ return e;
1149
+ }
1150
+ async function It(n, t) {
1151
+ const { data: e, error: i } = await s((r) => n.POST("/ble/disable", { signal: r }), t == null ? void 0 : t.timeout);
1152
+ if (i)
1153
+ throw i;
1154
+ return e;
1141
1155
  }
1142
1156
  async function Rt(n, t) {
1143
- const { data: i, error: e } = await s((r) => n.POST("/ble/disable", { signal: r }), t == null ? void 0 : t.timeout);
1144
- if (e)
1145
- throw e;
1146
- return i;
1157
+ const { data: e, error: i } = await s((r) => n.DELETE("/ble/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1158
+ if (i)
1159
+ throw i;
1160
+ return e;
1147
1161
  }
1148
1162
  async function Kt(n, t) {
1149
- const { data: i, error: e } = await s((r) => n.DELETE("/ble/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1150
- if (e)
1151
- throw e;
1152
- return i;
1153
- }
1154
- async function Ft(n, t) {
1155
- const { data: i, error: e } = await s((r) => n.GET("/ble/status", { signal: r }), t == null ? void 0 : t.timeout);
1156
- if (e)
1157
- throw e;
1158
- return i;
1163
+ const { data: e, error: i } = await s((r) => n.GET("/ble/status", { signal: r }), t == null ? void 0 : t.timeout);
1164
+ if (i)
1165
+ throw i;
1166
+ return e;
1159
1167
  }
1160
- class _t {
1168
+ class Ft {
1161
1169
  /**
1162
1170
  * Enable BLE. Starts advertising.
1163
1171
  *
@@ -1176,7 +1184,7 @@ class _t {
1176
1184
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1177
1185
  */
1178
1186
  async BleDisable(t) {
1179
- return await Rt(this.apiClient, t);
1187
+ return await It(this.apiClient, t);
1180
1188
  }
1181
1189
  /**
1182
1190
  * Remove pairing. Remove pairing with previous device.
@@ -1186,7 +1194,7 @@ class _t {
1186
1194
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1187
1195
  */
1188
1196
  async BleUnpair(t) {
1189
- return await Kt(this.apiClient, t);
1197
+ return await Rt(this.apiClient, t);
1190
1198
  }
1191
1199
  /**
1192
1200
  * Returns current BLE status.
@@ -1196,15 +1204,15 @@ class _t {
1196
1204
  * @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
1197
1205
  */
1198
1206
  async BleStatusGet(t) {
1199
- return await Ft(this.apiClient, t);
1207
+ return await Kt(this.apiClient, t);
1200
1208
  }
1201
1209
  }
1202
1210
  async function Wt(n, t) {
1203
- const { keyName: i } = t, { data: e, error: r } = await s(
1211
+ const { key: e } = t, { data: i, error: r } = await s(
1204
1212
  (o) => n.POST("/input", {
1205
1213
  params: {
1206
1214
  query: {
1207
- key: i
1215
+ key: e
1208
1216
  }
1209
1217
  },
1210
1218
  signal: o
@@ -1213,14 +1221,14 @@ async function Wt(n, t) {
1213
1221
  );
1214
1222
  if (r)
1215
1223
  throw r;
1216
- return e;
1224
+ return i;
1217
1225
  }
1218
1226
  class Mt {
1219
1227
  /**
1220
1228
  * Send input event. Send single key press event.
1221
1229
  *
1222
1230
  * @param {InputKeyParams} params - Button press parameters:
1223
- * @param {KeyName} params.keyName - Name of the key to press.
1231
+ * @param {KeyName} params.key - Key name.
1224
1232
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1225
1233
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1226
1234
  */
@@ -1228,70 +1236,119 @@ class Mt {
1228
1236
  return await Wt(this.apiClient, t);
1229
1237
  }
1230
1238
  }
1231
- async function Nt(n, t) {
1232
- const { data: i, error: e } = await s((r) => n.GET("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1233
- if (e)
1234
- throw e;
1235
- return i;
1236
- }
1237
1239
  async function qt(n, t) {
1238
- const { data: i, error: e } = await s((r) => n.POST("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1239
- if (e)
1240
- throw e;
1241
- return i;
1240
+ const { data: e, error: i } = await s((r) => n.GET("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1241
+ if (i)
1242
+ throw i;
1243
+ return e;
1244
+ }
1245
+ async function Nt(n, t) {
1246
+ const { data: e, error: i } = await s((r) => n.POST("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1247
+ if (i)
1248
+ throw i;
1249
+ return e;
1242
1250
  }
1243
1251
  async function xt(n, t) {
1244
- const { data: i, error: e } = await s((r) => n.DELETE("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
1245
- if (e)
1246
- throw e;
1247
- return i;
1252
+ const { data: e, error: i } = await s((r) => n.DELETE("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
1253
+ if (i)
1254
+ throw i;
1255
+ return e;
1256
+ }
1257
+ async function Ht(n, t) {
1258
+ const { data: e, error: i } = await s((r) => n.GET("/smart_home/switch", { signal: r }), t == null ? void 0 : t.timeout);
1259
+ if (i)
1260
+ throw i;
1261
+ return e;
1262
+ }
1263
+ async function Vt(n, t) {
1264
+ const { timeout: e, ...i } = t, { data: r, error: o } = await s((a) => n.POST("/smart_home/switch", { body: i, signal: a }), e);
1265
+ if (o)
1266
+ throw o;
1267
+ return r;
1248
1268
  }
1249
- class Vt {
1269
+ class jt {
1250
1270
  /**
1251
- * Get Matter status.
1271
+ * Smart home commissioning status.
1252
1272
  *
1253
1273
  * @param {TimeoutOptions} [params] - Optional parameters.
1254
1274
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1255
- * @returns {Promise<MatterStatus>} A promise that resolves to the Matter status.
1275
+ * @returns {Promise<SmartHomePairingInfo>} A promise that resolves to the pairing info.
1256
1276
  */
1257
- async MatterStatusGet(t) {
1277
+ async SmartHomePairingGet(t) {
1278
+ return await qt(this.apiClient, t);
1279
+ }
1280
+ /**
1281
+ * Link device to a smart home.
1282
+ *
1283
+ * @param {TimeoutOptions} [params] - Optional timeout.
1284
+ * @returns {Promise<SmartHomePairingPayload>} A promise that resolves to the pairing payload.
1285
+ */
1286
+ async SmartHomePair(t) {
1258
1287
  return await Nt(this.apiClient, t);
1259
1288
  }
1260
1289
  /**
1261
- * Pair Matter device.
1290
+ * Erase all smart home links.
1262
1291
  *
1263
1292
  * @param {TimeoutOptions} [params] - Optional parameters.
1264
1293
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1265
- * @returns {Promise<MatterPairingInfo>} A promise that resolves on success.
1294
+ * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1266
1295
  */
1267
- async MatterPair(t) {
1268
- return await qt(this.apiClient, t);
1296
+ async SmartHomeErase(t) {
1297
+ return await xt(this.apiClient, t);
1269
1298
  }
1270
1299
  /**
1271
- * Erase Matter devices.
1300
+ * Get state of emulated smart home switch.
1272
1301
  *
1273
1302
  * @param {TimeoutOptions} [params] - Optional parameters.
1274
1303
  * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1304
+ * @returns {Promise<SmartHomeSwitchState>} A promise that resolves to the switch state.
1305
+ */
1306
+ async SmartHomeSwitchStateGet(t) {
1307
+ return await Ht(this.apiClient, t);
1308
+ }
1309
+ /**
1310
+ * Set state of emulated smart home switch.
1311
+ *
1312
+ * @param {SmartHomeSwitchState & TimeoutOptions} params - Switch state and optional timeout.
1275
1313
  * @returns {Promise<SuccessResponse>} A promise that resolves on success.
1276
1314
  */
1315
+ async SmartHomeSwitchStateSet(t) {
1316
+ return await Vt(this.apiClient, t);
1317
+ }
1318
+ // ALIASES for backward compatibility (Matter -> SmartHome)
1319
+ /**
1320
+ * @deprecated Use SmartHomePairingGet instead.
1321
+ */
1322
+ async MatterStatusGet(t) {
1323
+ return await this.SmartHomePairingGet(t);
1324
+ }
1325
+ /**
1326
+ * @deprecated Use SmartHomePair instead.
1327
+ */
1328
+ async MatterPair(t) {
1329
+ return await this.SmartHomePair(t);
1330
+ }
1331
+ /**
1332
+ * @deprecated Use SmartHomeErase instead.
1333
+ */
1277
1334
  async MatterErase(t) {
1278
- return await xt(this.apiClient, t);
1335
+ return await this.SmartHomeErase(t);
1279
1336
  }
1280
1337
  }
1281
- async function jt(n, t) {
1282
- const { appId: i, fileName: e, file: r } = t, { data: o, error: a } = await s(
1283
- (u) => n.POST("/assets/upload", {
1338
+ async function zt(n, t) {
1339
+ const { application_name: e, file: i, data: r } = t, { data: o, error: a } = await s(
1340
+ (c) => n.POST("/assets/upload", {
1284
1341
  params: {
1285
1342
  query: {
1286
- app_id: i,
1287
- file: e
1343
+ application_name: e,
1344
+ file: i
1288
1345
  }
1289
1346
  },
1290
1347
  headers: {
1291
1348
  "Content-Type": "application/octet-stream"
1292
1349
  },
1293
1350
  body: r,
1294
- signal: u
1351
+ signal: c
1295
1352
  }),
1296
1353
  t.timeout
1297
1354
  );
@@ -1299,12 +1356,12 @@ async function jt(n, t) {
1299
1356
  throw a;
1300
1357
  return o;
1301
1358
  }
1302
- async function zt(n, t) {
1303
- const { appId: i } = t, { data: e, error: r } = await s(
1359
+ async function Jt(n, t) {
1360
+ const { application_name: e } = t, { data: i, error: r } = await s(
1304
1361
  (o) => n.DELETE("/assets/upload", {
1305
1362
  params: {
1306
1363
  query: {
1307
- app_id: i
1364
+ application_name: e
1308
1365
  }
1309
1366
  },
1310
1367
  signal: o
@@ -1313,52 +1370,52 @@ async function zt(n, t) {
1313
1370
  );
1314
1371
  if (r)
1315
1372
  throw r;
1316
- return e;
1373
+ return i;
1317
1374
  }
1318
- class Ht {
1375
+ class Xt {
1319
1376
  /**
1320
1377
  * Upload asset file with app ID. Uploads a file to a specific app's assets directory.
1321
1378
  *
1322
1379
  * @param {UploadParams} params - Parameters for the upload.
1323
- * @param {UploadParams['appId']} params.appId - Application ID for organizing assets.
1324
- * @param {UploadParams['fileName']} params.fileName - Filename for the uploaded asset.
1325
- * @param {UploadParams['file']} params.file - File data to upload.
1326
- * @param {UploadParams['timeout']} [params.timeout] - Request timeout in milliseconds.
1380
+ * @param {string} params.application_name - Application name for organizing assets.
1381
+ * @param {string} params.file - Filename for the uploaded asset.
1382
+ * @param {BusyFile} params.data - File data to upload.
1383
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1327
1384
  * @returns {Promise<SuccessResponse>} Result of the upload operation.
1328
1385
  */
1329
1386
  async AssetsUpload(t) {
1330
- return await jt(this.apiClient, t);
1387
+ return await zt(this.apiClient, t);
1331
1388
  }
1332
1389
  /**
1333
1390
  * Delete app assets. Deletes all assets for a specific app ID.
1334
1391
  *
1335
1392
  * @param {DeleteParams} params - Parameters for the delete.
1336
- * @param {DeleteParams['appId']} params.appId - Application ID whose assets should be deleted.
1337
- * @param {DeleteParams['timeout']} [params.timeout] - Request timeout in milliseconds.
1393
+ * @param {string} params.application_name - Application name whose assets should be deleted.
1394
+ * @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
1338
1395
  * @returns {Promise<SuccessResponse>} Result of the delete operation.
1339
1396
  */
1340
1397
  async AssetsDelete(t) {
1341
- return await zt(this.apiClient, t);
1398
+ return await Jt(this.apiClient, t);
1342
1399
  }
1343
1400
  }
1344
- const S = "http://10.0.4.20", Jt = "https://proxy.busy.app", Xt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
1345
- function T(n) {
1401
+ const S = "http://10.0.4.20", Yt = "https://proxy.busy.app", Qt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
1402
+ function m(n) {
1346
1403
  const t = n.split(".");
1347
1404
  if (t.length !== 4)
1348
1405
  return !1;
1349
- for (const i of t) {
1350
- if (i.length === 0 || i.length > 1 && i[0] === "0" || !/^\d+$/.test(i))
1406
+ for (const e of t) {
1407
+ if (e.length === 0 || e.length > 1 && e[0] === "0" || !/^\d+$/.test(e))
1351
1408
  return !1;
1352
- const e = Number(i);
1353
- if (e < 0 || e > 255)
1409
+ const i = Number(e);
1410
+ if (i < 0 || i > 255)
1354
1411
  return !1;
1355
1412
  }
1356
1413
  return !0;
1357
1414
  }
1358
- function E(n) {
1415
+ function T(n) {
1359
1416
  return /\.local$/i.test(n);
1360
1417
  }
1361
- class Yt {
1418
+ class Zt {
1362
1419
  /**
1363
1420
  * Creates an instance of BUSY Bar.
1364
1421
  * Initializes the API client with the provided host address.
@@ -1387,38 +1444,38 @@ class Yt {
1387
1444
  * @type {BusyBarConfig['host']}
1388
1445
  * @readonly
1389
1446
  */
1390
- c(this, "addr");
1447
+ u(this, "addr");
1391
1448
  /**
1392
1449
  * Current API semantic version.
1393
1450
  * @type {ApiSemver}
1394
1451
  */
1395
- c(this, "apiSemver");
1452
+ u(this, "apiSemver");
1396
1453
  /**
1397
1454
  * API Client instance.
1398
1455
  */
1399
- c(this, "apiClient");
1400
- c(this, "setApiKeyFn");
1401
- c(this, "setTokenFn");
1456
+ u(this, "apiClient");
1457
+ u(this, "setApiKeyFn");
1458
+ u(this, "setTokenFn");
1402
1459
  /**
1403
1460
  * Detected connection type based on auth requirements.
1404
1461
  * - "wifi": Device requires authentication (returned 401/403).
1405
1462
  * - "usb": Device allows access without token (returned 200).
1406
1463
  * - "unknown": Detection failed or not yet completed.
1407
1464
  */
1408
- c(this, "connectionType", "unknown");
1465
+ u(this, "connectionType", "unknown");
1409
1466
  if (!t || !t.addr && !t.token)
1410
1467
  this.addr = S;
1411
1468
  else if (!t.addr)
1412
- this.addr = Jt;
1469
+ this.addr = Yt;
1413
1470
  else {
1414
1471
  let o = t.addr.trim();
1415
- if (/^https?:\/\//i.test(o) || (o = `http://${o}`), Xt.test(o) && !t.token)
1472
+ if (/^https?:\/\//i.test(o) || (o = `http://${o}`), Qt.test(o) && !t.token)
1416
1473
  throw new Error("Token is required. Please provide it.");
1417
1474
  this.addr = o;
1418
1475
  }
1419
1476
  this.apiSemver = "";
1420
- const { client: i, setApiKey: e, setToken: r } = O(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
1421
- this.apiClient = i, this.setApiKeyFn = e, this.setTokenFn = r, this.detectConnectionType();
1477
+ const { client: e, setApiKey: i, setToken: r } = L(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
1478
+ this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn = r, this.detectConnectionType();
1422
1479
  }
1423
1480
  /**
1424
1481
  * Probes the device to determine connection type.
@@ -1426,23 +1483,23 @@ class Yt {
1426
1483
  */
1427
1484
  async detectConnectionType() {
1428
1485
  const t = new URL(this.addr).hostname;
1429
- if (!T(t) && !E(t)) {
1486
+ if (!m(t) && !T(t)) {
1430
1487
  this.connectionType = "wifi";
1431
1488
  return;
1432
1489
  }
1433
- const i = m({
1490
+ const e = E({
1434
1491
  baseUrl: `${this.addr}/api/`
1435
1492
  });
1436
1493
  try {
1437
- const { response: e } = await i.GET("/name");
1438
- if (e.status === 401 || e.status === 403)
1494
+ const { response: i } = await e.GET("/name");
1495
+ if (i.status === 401 || i.status === 403)
1439
1496
  this.connectionType = "wifi";
1440
- else if (e.ok)
1497
+ else if (i.ok)
1441
1498
  this.connectionType = "usb";
1442
1499
  else
1443
- throw new Error(`Failed to detect connection type. Status: ${e.status}`);
1444
- } catch (e) {
1445
- throw e;
1500
+ throw new Error(`Failed to detect connection type. Status: ${i.status}`);
1501
+ } catch (i) {
1502
+ throw i;
1446
1503
  }
1447
1504
  }
1448
1505
  /**
@@ -1460,95 +1517,95 @@ class Yt {
1460
1517
  this.setTokenFn(t);
1461
1518
  }
1462
1519
  }
1463
- function Qt(n, t) {
1464
- t.forEach((i) => {
1465
- Object.getOwnPropertyNames(i.prototype).forEach((e) => {
1466
- Object.defineProperty(n.prototype, e, Object.getOwnPropertyDescriptor(i.prototype, e) || /* @__PURE__ */ Object.create(null));
1520
+ function te(n, t) {
1521
+ t.forEach((e) => {
1522
+ Object.getOwnPropertyNames(e.prototype).forEach((i) => {
1523
+ Object.defineProperty(n.prototype, i, Object.getOwnPropertyDescriptor(e.prototype, i) || /* @__PURE__ */ Object.create(null));
1467
1524
  });
1468
1525
  });
1469
1526
  }
1470
- Qt(Yt, [
1471
- K,
1472
- j,
1527
+ te(Zt, [
1528
+ R,
1529
+ V,
1473
1530
  Q,
1474
1531
  ot,
1475
1532
  dt,
1476
1533
  pt,
1477
1534
  Ct,
1478
- Lt,
1479
- It,
1535
+ Ot,
1480
1536
  _t,
1537
+ Ft,
1481
1538
  Mt,
1482
- Vt,
1483
- Ht
1539
+ jt,
1540
+ Xt
1484
1541
  ]);
1485
1542
  var p = /* @__PURE__ */ ((n) => (n[n.FRONT = 0] = "FRONT", n[n.BACK = 1] = "BACK", n))(p || {});
1486
1543
  const C = 3e3, k = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1487
1544
  function g(n, t) {
1488
1545
  if (t < 0 || t >= n.length)
1489
1546
  throw new Error(`Index ${t} is out of bounds (0…${n.length - 1})`);
1490
- const i = n[t];
1491
- if (i === void 0)
1547
+ const e = n[t];
1548
+ if (e === void 0)
1492
1549
  throw new Error(`Unexpected undefined at index ${t}`);
1493
- return i;
1550
+ return e;
1494
1551
  }
1495
- function Zt(n, t) {
1496
- let i = 0;
1497
- const e = n.length, r = [];
1498
- for (; i < e; ) {
1499
- const o = g(n, i);
1500
- if (i += 1, (o & 128) !== 0) {
1552
+ function ee(n, t) {
1553
+ let e = 0;
1554
+ const i = n.length, r = [];
1555
+ for (; e < i; ) {
1556
+ const o = g(n, e);
1557
+ if (e += 1, (o & 128) !== 0) {
1501
1558
  const a = o & 127;
1502
- for (let u = 0; u < a * t; u++)
1503
- r.push(n[i + u]);
1504
- i += a * t;
1559
+ for (let c = 0; c < a * t; c++)
1560
+ r.push(n[e + c]);
1561
+ e += a * t;
1505
1562
  } else {
1506
- const a = o, u = n.slice(i, i + t);
1507
- for (let w = 0; w < a; w++)
1563
+ const a = o, c = n.slice(e, e + t);
1564
+ for (let d = 0; d < a; d++)
1508
1565
  for (let f = 0; f < t; f++)
1509
- r.push(u[f]);
1510
- i += t;
1566
+ r.push(c[f]);
1567
+ e += t;
1511
1568
  }
1512
1569
  }
1513
1570
  return new Uint8Array(r);
1514
1571
  }
1515
- function te(n) {
1572
+ function ie(n) {
1516
1573
  const t = new Uint8Array(n.length * 2);
1517
- let i = 0, e = 0;
1518
- for (; i < n.length; ) {
1519
- const r = g(n, i), o = r & 15, a = r >> 4 & 15;
1520
- t[e] = o, t[e + 1] = a, i += 1, e += 2;
1574
+ let e = 0, i = 0;
1575
+ for (; e < n.length; ) {
1576
+ const r = g(n, e), o = r & 15, a = r >> 4 & 15;
1577
+ t[i] = o, t[i + 1] = a, e += 1, i += 2;
1521
1578
  }
1522
1579
  return t;
1523
1580
  }
1524
1581
  const A = () => typeof window < "u" && typeof window.document < "u";
1525
- class ne {
1582
+ class oe {
1526
1583
  constructor(t) {
1527
- c(this, "addr");
1528
- c(this, "connected", !1);
1584
+ u(this, "addr");
1585
+ u(this, "connected", !1);
1529
1586
  // @ts-ignore
1530
- c(this, "apiKey");
1587
+ u(this, "apiKey");
1531
1588
  // @ts-ignore
1532
- c(this, "apiSemver");
1533
- c(this, "dataListeners", []);
1534
- c(this, "stopListeners", []);
1535
- c(this, "errorListeners", []);
1536
- c(this, "socket", null);
1589
+ u(this, "apiSemver");
1590
+ u(this, "dataListeners", []);
1591
+ u(this, "stopListeners", []);
1592
+ u(this, "errorListeners", []);
1593
+ u(this, "socket", null);
1537
1594
  if (this.config = t, !A())
1538
1595
  throw new Error("not browser");
1539
1596
  if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1540
1597
  this.addr = S;
1541
1598
  else {
1542
- let i = t.addr.trim();
1543
- /^https?:\/\//i.test(i) || (i = `http://${i}`);
1599
+ let e = t.addr.trim();
1600
+ /^https?:\/\//i.test(e) || (e = `http://${e}`);
1544
1601
  try {
1545
- const r = new URL(i).hostname;
1546
- if (!T(r) && !E(r))
1602
+ const r = new URL(e).hostname;
1603
+ if (!m(r) && !T(r))
1547
1604
  throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
1548
- } catch (e) {
1549
- throw e instanceof Error && e.message.startsWith("Invalid address") ? e : new Error(`Invalid URL format: "${t.addr}"`);
1605
+ } catch (i) {
1606
+ throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1550
1607
  }
1551
- this.addr = i;
1608
+ this.addr = e;
1552
1609
  }
1553
1610
  }
1554
1611
  onData(t) {
@@ -1561,16 +1618,16 @@ class ne {
1561
1618
  this.errorListeners.push(t);
1562
1619
  }
1563
1620
  emitData(t) {
1564
- for (const i of this.dataListeners)
1565
- i(t);
1621
+ for (const e of this.dataListeners)
1622
+ e(t);
1566
1623
  }
1567
1624
  emitStop() {
1568
1625
  for (const t of this.stopListeners)
1569
1626
  t();
1570
1627
  }
1571
1628
  emitError(t) {
1572
- for (const i of this.errorListeners)
1573
- i(t);
1629
+ for (const e of this.errorListeners)
1630
+ e(t);
1574
1631
  }
1575
1632
  async openWebsocket() {
1576
1633
  this.socket && await this.closeWebsocket();
@@ -1579,35 +1636,35 @@ class ne {
1579
1636
  throw new Error("The WebSocket URL is not specified");
1580
1637
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1581
1638
  this.socket && (this.socket.send(JSON.stringify({ display: this.config.deviceScreen })), this.connected = !0);
1582
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1639
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1583
1640
  try {
1584
- if (typeof i.data == "string")
1641
+ if (typeof e.data == "string")
1585
1642
  return;
1586
- const e = new Uint8Array(i.data);
1643
+ const i = new Uint8Array(e.data);
1587
1644
  let r;
1588
1645
  const o = this.config.deviceScreen === p.FRONT ? 3 : 2;
1589
1646
  try {
1590
- const a = Zt(e, o);
1591
- this.config.deviceScreen === p.BACK ? r = te(a) : r = a, this.emitData(r);
1647
+ const a = ee(i, o);
1648
+ this.config.deviceScreen === p.BACK ? r = ie(a) : r = a, this.emitData(r);
1592
1649
  } catch {
1593
- this.emitData(e);
1650
+ this.emitData(i);
1594
1651
  }
1595
1652
  } catch {
1596
1653
  this.connected = !1, this.emitStop();
1597
1654
  }
1598
- }, this.socket.onerror = (i) => {
1655
+ }, this.socket.onerror = (e) => {
1599
1656
  this.connected = !1, this.emitError({
1600
1657
  code: 1006,
1601
1658
  // Standard «abnormal closure» code per RFC-6455
1602
1659
  message: "WebSocket error occurred",
1603
- raw: i
1660
+ raw: e
1604
1661
  }), this.emitStop();
1605
- }, this.socket.onclose = async (i) => {
1606
- if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1662
+ }, this.socket.onclose = async (e) => {
1663
+ if (this.socket = null, this.connected = !1, e.code === C || k.has(e.code)) {
1607
1664
  this.emitError({
1608
- code: i.code,
1609
- message: i.reason,
1610
- raw: i
1665
+ code: e.code,
1666
+ message: e.reason,
1667
+ raw: e
1611
1668
  });
1612
1669
  return;
1613
1670
  }
@@ -1622,34 +1679,34 @@ class ne {
1622
1679
  });
1623
1680
  }
1624
1681
  }
1625
- class re {
1682
+ class se {
1626
1683
  constructor(t) {
1627
- c(this, "addr");
1628
- c(this, "connected", !1);
1684
+ u(this, "addr");
1685
+ u(this, "connected", !1);
1629
1686
  // @ts-ignore
1630
- c(this, "apiKey");
1687
+ u(this, "apiKey");
1631
1688
  // @ts-ignore
1632
- c(this, "apiSemver");
1633
- c(this, "inputEvent");
1634
- c(this, "dataListeners", []);
1635
- c(this, "stopListeners", []);
1636
- c(this, "errorListeners", []);
1637
- c(this, "socket", null);
1689
+ u(this, "apiSemver");
1690
+ u(this, "inputEvent");
1691
+ u(this, "dataListeners", []);
1692
+ u(this, "stopListeners", []);
1693
+ u(this, "errorListeners", []);
1694
+ u(this, "socket", null);
1638
1695
  if (!A())
1639
1696
  throw new Error("not browser");
1640
1697
  if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
1641
1698
  this.addr = S;
1642
1699
  else {
1643
- let i = t.addr.trim();
1644
- /^https?:\/\//i.test(i) || (i = `http://${i}`);
1700
+ let e = t.addr.trim();
1701
+ /^https?:\/\//i.test(e) || (e = `http://${e}`);
1645
1702
  try {
1646
- const r = new URL(i).hostname;
1647
- if (!T(r) && !E(r))
1703
+ const r = new URL(e).hostname;
1704
+ if (!m(r) && !T(r))
1648
1705
  throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
1649
- } catch (e) {
1650
- throw e instanceof Error && e.message.startsWith("Invalid address") ? e : new Error(`Invalid URL format: "${t.addr}"`);
1706
+ } catch (i) {
1707
+ throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
1651
1708
  }
1652
- this.addr = i;
1709
+ this.addr = e;
1653
1710
  }
1654
1711
  this.inputEvent = {};
1655
1712
  }
@@ -1663,16 +1720,16 @@ class re {
1663
1720
  this.errorListeners.push(t);
1664
1721
  }
1665
1722
  emitData(t) {
1666
- for (const i of this.dataListeners)
1667
- i(t);
1723
+ for (const e of this.dataListeners)
1724
+ e(t);
1668
1725
  }
1669
1726
  emitStop() {
1670
1727
  for (const t of this.stopListeners)
1671
1728
  t();
1672
1729
  }
1673
1730
  emitError(t) {
1674
- for (const i of this.errorListeners)
1675
- i(t);
1731
+ for (const e of this.errorListeners)
1732
+ e(t);
1676
1733
  }
1677
1734
  async openWebsocket() {
1678
1735
  this.socket && await this.closeWebsocket();
@@ -1681,38 +1738,38 @@ class re {
1681
1738
  throw new Error("The WebSocket URL is not specified");
1682
1739
  this.socket = new WebSocket(t), this.socket.onopen = () => {
1683
1740
  this.socket && (this.connected = !0);
1684
- }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (i) => {
1741
+ }, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
1685
1742
  try {
1686
- if (typeof i.data == "string")
1743
+ if (typeof e.data == "string")
1687
1744
  return;
1688
- const e = new Uint8Array(i.data);
1689
- this.emitData(e);
1745
+ const i = new Uint8Array(e.data);
1746
+ this.emitData(i);
1690
1747
  } catch {
1691
1748
  this.connected = !1, this.emitStop();
1692
1749
  }
1693
- }, this.socket.onerror = (i) => {
1750
+ }, this.socket.onerror = (e) => {
1694
1751
  this.connected = !1, this.emitError({
1695
1752
  code: 1006,
1696
1753
  // Standard «abnormal closure» code per RFC-6455
1697
1754
  message: "WebSocket error occurred",
1698
- raw: i
1755
+ raw: e
1699
1756
  }), this.emitStop();
1700
- }, this.socket.onclose = async (i) => {
1701
- if (this.socket = null, this.connected = !1, i.code === C || k.has(i.code)) {
1757
+ }, this.socket.onclose = async (e) => {
1758
+ if (this.socket = null, this.connected = !1, e.code === C || k.has(e.code)) {
1702
1759
  this.emitError({
1703
- code: i.code,
1704
- message: i.reason,
1705
- raw: i
1760
+ code: e.code,
1761
+ message: e.reason,
1762
+ raw: e
1706
1763
  });
1707
1764
  return;
1708
1765
  }
1709
1766
  this.emitStop();
1710
1767
  };
1711
1768
  }
1712
- sendInput({ keyName: t, value: i }) {
1769
+ sendInput({ keyName: t, value: e }) {
1713
1770
  if (!this.socket || !this.connected)
1714
1771
  throw new Error("WebSocket: Not connected");
1715
- this.inputEvent[t] = i, this.socket.send(JSON.stringify(this.inputEvent)), i === 0 && delete this.inputEvent[t];
1772
+ this.inputEvent[t] = e, this.socket.send(JSON.stringify(this.inputEvent)), e === 0 && delete this.inputEvent[t];
1716
1773
  }
1717
1774
  closeWebsocket() {
1718
1775
  return this.connected = !1, new Promise((t) => {
@@ -1723,8 +1780,8 @@ class re {
1723
1780
  }
1724
1781
  }
1725
1782
  export {
1726
- Yt as BusyBar,
1783
+ Zt as BusyBar,
1727
1784
  p as DeviceScreen,
1728
- re as Input,
1729
- ne as ScreenStream
1785
+ se as Input,
1786
+ oe as ScreenStream
1730
1787
  };