een-api-toolkit 0.3.70 → 0.3.78

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,21 +1,21 @@
1
- import { defineStore as ve } from "pinia";
2
- import { ref as E, computed as N } from "vue";
3
- const Ee = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, Ae = () => {
1
+ import { defineStore as Ae } from "pinia";
2
+ import { ref as A, computed as B } from "vue";
3
+ const Ie = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, Te = () => {
4
4
  try {
5
- return Ee?.VITE_DEBUG === "true";
5
+ return Ie?.VITE_DEBUG === "true";
6
6
  } catch {
7
7
  return !1;
8
8
  }
9
9
  };
10
10
  function s(...e) {
11
- Ae() && console.log("[een-api-toolkit]", ...e);
11
+ Te() && console.log("[een-api-toolkit]", ...e);
12
12
  }
13
- const Pe = {
13
+ const ze = {
14
14
  localStorage: "persists across sessions",
15
15
  sessionStorage: "per-tab, cleared on tab close",
16
16
  memory: "tokens lost on page refresh"
17
17
  };
18
- class Ie {
18
+ class Ue {
19
19
  store = /* @__PURE__ */ new Map();
20
20
  getItem(n) {
21
21
  return this.store.get(n) ?? null;
@@ -27,7 +27,7 @@ class Ie {
27
27
  this.store.delete(n);
28
28
  }
29
29
  }
30
- class ie {
30
+ class ce {
31
31
  constructor(n) {
32
32
  this.storage = n;
33
33
  }
@@ -41,31 +41,31 @@ class ie {
41
41
  this.storage.removeItem(n);
42
42
  }
43
43
  }
44
- let K = "localStorage", x = null;
45
- function W() {
46
- return x || (x = new Ie()), x;
44
+ let Y = "localStorage", K = null;
45
+ function G() {
46
+ return K || (K = new Ue()), K;
47
47
  }
48
- function Te(e) {
49
- K = e;
48
+ function ye(e) {
49
+ Y = e;
50
50
  }
51
- function Ce() {
52
- return K;
51
+ function Qe() {
52
+ return Y;
53
53
  }
54
- function V() {
55
- switch (K) {
54
+ function J() {
55
+ switch (Y) {
56
56
  case "memory":
57
- return W();
57
+ return G();
58
58
  case "sessionStorage":
59
- return typeof sessionStorage < "u" ? new ie(sessionStorage) : (s("sessionStorage unavailable, falling back to memory storage"), W());
59
+ return typeof sessionStorage < "u" ? new ce(sessionStorage) : (s("sessionStorage unavailable, falling back to memory storage"), G());
60
60
  default:
61
- return typeof localStorage < "u" ? new ie(localStorage) : (s("localStorage unavailable, falling back to memory storage"), W());
61
+ return typeof localStorage < "u" ? new ce(localStorage) : (s("localStorage unavailable, falling back to memory storage"), G());
62
62
  }
63
63
  }
64
64
  const D = {};
65
- let $ = {};
66
- function He(e = {}) {
65
+ let w = {};
66
+ function xe(e = {}) {
67
67
  const n = e.storageStrategy ?? "localStorage";
68
- Te(n), $ = {
68
+ ye(n), w = {
69
69
  proxyUrl: e.proxyUrl ?? D?.VITE_PROXY_URL,
70
70
  clientId: e.clientId ?? D?.VITE_EEN_CLIENT_ID,
71
71
  redirectUri: e.redirectUri ?? D?.VITE_REDIRECT_URI,
@@ -73,17 +73,17 @@ function He(e = {}) {
73
73
  debug: e.debug ?? D?.VITE_DEBUG === "true"
74
74
  };
75
75
  }
76
- function ze() {
77
- return $;
76
+ function We() {
77
+ return w;
78
78
  }
79
- function G() {
80
- return $.proxyUrl ?? D?.VITE_PROXY_URL;
79
+ function Z() {
80
+ return w.proxyUrl ?? D?.VITE_PROXY_URL;
81
81
  }
82
- function Ue() {
83
- return $.clientId ?? D?.VITE_EEN_CLIENT_ID;
82
+ function Se() {
83
+ return w.clientId ?? D?.VITE_EEN_CLIENT_ID;
84
84
  }
85
- function re() {
86
- return $.redirectUri ?? D?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
85
+ function se() {
86
+ return w.redirectUri ?? D?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
87
87
  }
88
88
  function d(e) {
89
89
  return { data: e, error: null };
@@ -91,60 +91,79 @@ function d(e) {
91
91
  function i(e, n, t, r) {
92
92
  return { data: null, error: { code: e, message: n, status: t, details: r } };
93
93
  }
94
- function Qe(e) {
94
+ function Ve(e) {
95
95
  if (e)
96
96
  return typeof e == "string" ? e : e.connectionStatus;
97
97
  }
98
- function xe(e) {
98
+ function Me(e) {
99
99
  return typeof e == "object" && e !== null;
100
100
  }
101
- function I(e) {
101
+ function T(e) {
102
102
  return e.endsWith("+00:00") ? e : e.endsWith("Z") ? e.replace("Z", "+00:00") : e;
103
103
  }
104
- let M = null;
105
- function ye() {
106
- return M || (M = Promise.resolve().then(() => ke).then((e) => e.refreshToken)), M;
104
+ const De = [".eagleeyenetworks.com", ".een.cloud"];
105
+ function P(e) {
106
+ if (!e || typeof e != "string")
107
+ return !1;
108
+ const n = e.toLowerCase().trim();
109
+ return n ? De.some(
110
+ (t) => n === t.substring(1) || n.endsWith(t)
111
+ ) : !1;
112
+ }
113
+ let X = null;
114
+ function Oe() {
115
+ return X || (X = Promise.resolve().then(() => Fe).then((e) => e.refreshToken)), X;
107
116
  }
108
- const f = ve("een-auth", () => {
109
- const e = E(null), n = E(null), t = E(null), r = E(null), a = E(null), o = E(443), c = E(null), u = E(null), h = E(!1);
117
+ const f = Ae("een-auth", () => {
118
+ const e = A(null), n = A(null), t = A(null), r = A(null), a = A(null), o = A(443), c = A(null), u = A(null), h = A(!1);
110
119
  let _ = null;
111
- const v = E(!1), g = E(null), y = N(() => !!e.value), S = N(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), p = N(() => n.value ? Date.now() >= n.value : !0), H = N(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
112
- function z(l, R) {
113
- e.value = l, n.value = Date.now() + R * 1e3, b(), Q(), s("Token set, expires in", R, "seconds");
120
+ const v = A(!1), g = A(null), O = B(() => !!e.value), b = B(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), U = B(() => n.value ? Date.now() >= n.value : !0), x = B(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
121
+ function W(l, R) {
122
+ e.value = l, n.value = Date.now() + R * 1e3, k(), V(), s("Token set, expires in", R, "seconds");
114
123
  }
115
- function F(l) {
116
- t.value = l, b();
124
+ function N(l) {
125
+ t.value = l, k();
117
126
  }
118
- function U(l) {
119
- r.value = l, b();
127
+ function S(l) {
128
+ r.value = l, k();
120
129
  }
121
- function O(l) {
130
+ function $(l) {
131
+ let R, p = 443;
122
132
  if (typeof l == "string")
123
133
  try {
124
- const R = new URL(l.startsWith("http") ? l : `https://${l}`);
125
- a.value = R.hostname, o.value = R.port ? parseInt(R.port, 10) : 443;
126
- } catch (R) {
127
- s("Failed to parse URL, using as hostname:", R instanceof Error ? R.message : String(R)), a.value = l, o.value = 443;
134
+ const E = new URL(l.startsWith("http") ? l : `https://${l}`);
135
+ R = E.hostname, p = E.port ? parseInt(E.port, 10) : 443;
136
+ } catch (E) {
137
+ console.warn(`[EEN API Toolkit] Rejected invalid URL: ${l}`), s("Failed to parse URL:", E instanceof Error ? E.message : String(E));
138
+ return;
128
139
  }
129
140
  else
130
- a.value = l.hostname, o.value = l.port ?? 443;
131
- b(), s("Base URL set:", S.value);
141
+ R = l.hostname.toLowerCase().trim(), p = l.port ?? 443;
142
+ if (typeof p != "number" || !Number.isInteger(p) || p < 1 || p > 65535) {
143
+ console.warn(`[EEN API Toolkit] Rejected invalid port: ${p}`);
144
+ return;
145
+ }
146
+ if (!P(R)) {
147
+ console.warn(`[EEN API Toolkit] Rejected hostname - not an allowed EEN domain: ${R}`);
148
+ return;
149
+ }
150
+ a.value = R, o.value = p, k(), s("Base URL set:", b.value);
132
151
  }
133
- function A(l) {
134
- c.value = l, b();
152
+ function I(l) {
153
+ c.value = l, k();
135
154
  }
136
- function Q() {
155
+ function V() {
137
156
  if (u.value && (clearTimeout(u.value), u.value = null), !n.value || !e.value)
138
157
  return;
139
- const l = Date.now(), m = n.value - l, L = 300 * 1e3, _e = m / 2, Re = Math.min(L, _e), pe = Math.max(m - Re, 60 * 1e3), ne = Math.max(pe, 5e3);
140
- s("Auto-refresh scheduled in", Math.round(ne / 1e3), "seconds"), u.value = setTimeout(async () => {
141
- await le();
142
- }, ne);
158
+ const l = Date.now(), p = n.value - l, E = 300 * 1e3, m = p / 2, q = Math.min(E, m), ve = Math.max(p - q, 60 * 1e3), ae = Math.max(ve, 5e3);
159
+ s("Auto-refresh scheduled in", Math.round(ae / 1e3), "seconds"), u.value = setTimeout(async () => {
160
+ await he();
161
+ }, ae);
143
162
  }
144
- async function le() {
163
+ async function he() {
145
164
  return _ ? (s("Refresh already in progress, waiting for existing refresh"), _) : (h.value = !0, s("Performing auto-refresh"), _ = (async () => {
146
165
  try {
147
- const R = await (await ye())();
166
+ const R = await (await Oe())();
148
167
  R.error ? (v.value = !0, g.value = R.error.message, s("Auto-refresh failed:", R.error.message)) : (v.value = !1, g.value = null, s("Auto-refresh successful"));
149
168
  } catch (l) {
150
169
  v.value = !0, g.value = l instanceof Error ? l.message : String(l), s("Auto-refresh error:", l);
@@ -153,40 +172,53 @@ const f = ve("een-auth", () => {
153
172
  }
154
173
  })(), _);
155
174
  }
156
- function de() {
175
+ function _e() {
157
176
  v.value = !1, g.value = null;
158
177
  }
159
- function te() {
160
- u.value && (clearTimeout(u.value), u.value = null), e.value = null, n.value = null, t.value = null, r.value = null, a.value = null, o.value = 443, c.value = null, v.value = !1, g.value = null, he(), s("Logged out");
178
+ function M() {
179
+ u.value && (clearTimeout(u.value), u.value = null), e.value = null, n.value = null, t.value = null, r.value = null, a.value = null, o.value = 443, c.value = null, v.value = !1, g.value = null, Ee();
180
+ }
181
+ function oe() {
182
+ M(), s("Logged out");
161
183
  }
162
- function fe() {
163
- ge(), e.value && !p.value ? (Q(), s("Initialized from storage")) : e.value && p.value && (s("Stored token expired, clearing"), te());
184
+ function Re() {
185
+ pe(), e.value && !U.value ? (V(), s("Initialized from storage")) : e.value && U.value && (s("Stored token expired, clearing"), oe());
164
186
  }
165
- function b() {
187
+ function k() {
166
188
  try {
167
- const l = V();
189
+ const l = J();
168
190
  e.value && l.setItem("een_token", e.value), n.value && l.setItem("een_tokenExpiration", String(n.value)), t.value && l.setItem("een_refreshTokenMarker", t.value), r.value && l.setItem("een_sessionId", r.value), a.value && l.setItem("een_hostname", a.value), o.value !== 443 && l.setItem("een_port", String(o.value)), c.value && l.setItem("een_userProfile", JSON.stringify(c.value));
169
191
  } catch (l) {
170
192
  s("Failed to save to storage:", l instanceof Error ? l.message : String(l));
171
193
  }
172
194
  }
173
- function ge() {
195
+ function pe() {
174
196
  try {
175
- const l = V();
197
+ const l = J();
176
198
  e.value = l.getItem("een_token");
177
199
  const R = l.getItem("een_tokenExpiration");
178
- n.value = R ? parseInt(R, 10) : null, t.value = l.getItem("een_refreshTokenMarker"), r.value = l.getItem("een_sessionId"), a.value = l.getItem("een_hostname");
179
- const m = l.getItem("een_port");
180
- o.value = m ? parseInt(m, 10) : 443;
181
- const L = l.getItem("een_userProfile");
182
- c.value = L ? JSON.parse(L) : null;
200
+ n.value = R ? parseInt(R, 10) : null, t.value = l.getItem("een_refreshTokenMarker"), r.value = l.getItem("een_sessionId");
201
+ const p = l.getItem("een_hostname");
202
+ if (p && !P(p)) {
203
+ console.warn(`[EEN API Toolkit] Rejected stored hostname - clearing all auth data: ${p}`), M();
204
+ return;
205
+ }
206
+ a.value = p;
207
+ const E = l.getItem("een_port"), m = E ? parseInt(E, 10) : 443;
208
+ if (!Number.isInteger(m) || m < 1 || m > 65535) {
209
+ console.warn(`[EEN API Toolkit] Rejected stored port - clearing all auth data: ${E}`), M();
210
+ return;
211
+ }
212
+ o.value = m;
213
+ const q = l.getItem("een_userProfile");
214
+ c.value = q ? JSON.parse(q) : null;
183
215
  } catch (l) {
184
216
  s("Failed to load from storage:", l instanceof Error ? l.message : String(l));
185
217
  }
186
218
  }
187
- function he() {
219
+ function Ee() {
188
220
  try {
189
- const l = V();
221
+ const l = J();
190
222
  l.removeItem("een_token"), l.removeItem("een_tokenExpiration"), l.removeItem("een_refreshTokenMarker"), l.removeItem("een_sessionId"), l.removeItem("een_hostname"), l.removeItem("een_port"), l.removeItem("een_userProfile");
191
223
  } catch (l) {
192
224
  s("Failed to clear storage:", l instanceof Error ? l.message : String(l));
@@ -205,24 +237,24 @@ const f = ve("een-auth", () => {
205
237
  refreshFailed: v,
206
238
  refreshFailedMessage: g,
207
239
  // Computed
208
- isAuthenticated: y,
209
- baseUrl: S,
210
- isTokenExpired: p,
211
- tokenExpiresIn: H,
240
+ isAuthenticated: O,
241
+ baseUrl: b,
242
+ isTokenExpired: U,
243
+ tokenExpiresIn: x,
212
244
  // Actions
213
- setToken: z,
214
- setRefreshTokenMarker: F,
215
- setSessionId: U,
216
- setBaseUrl: O,
217
- setUserProfile: A,
218
- setupAutoRefresh: Q,
219
- clearRefreshFailed: de,
220
- logout: te,
221
- initialize: fe
245
+ setToken: W,
246
+ setRefreshTokenMarker: N,
247
+ setSessionId: S,
248
+ setBaseUrl: $,
249
+ setUserProfile: I,
250
+ setupAutoRefresh: V,
251
+ clearRefreshFailed: _e,
252
+ logout: oe,
253
+ initialize: Re
222
254
  };
223
- }), Se = "https://auth.eagleeyenetworks.com/oauth2/authorize";
224
- function De() {
225
- const e = Ue();
255
+ }), be = "https://auth.eagleeyenetworks.com/oauth2/authorize";
256
+ function me() {
257
+ const e = Se();
226
258
  if (!e)
227
259
  throw new Error("Client ID not configured. Call initEenToolkit() or set VITE_EEN_CLIENT_ID");
228
260
  const n = crypto.randomUUID();
@@ -234,18 +266,18 @@ function De() {
234
266
  client_id: e,
235
267
  response_type: "code",
236
268
  scope: "vms.all",
237
- redirect_uri: re(),
269
+ redirect_uri: se(),
238
270
  state: n
239
271
  });
240
- return s("Generated auth URL with state:", n), `${Se}?${t.toString()}`;
272
+ return s("Generated auth URL with state:", n), `${be}?${t.toString()}`;
241
273
  }
242
- async function oe(e) {
243
- const n = G();
274
+ async function ue(e) {
275
+ const n = Z();
244
276
  if (!n)
245
277
  return i("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
246
278
  const t = new URLSearchParams({
247
279
  code: e,
248
- redirect_uri: re()
280
+ redirect_uri: se()
249
281
  });
250
282
  try {
251
283
  const r = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
@@ -265,8 +297,8 @@ async function oe(e) {
265
297
  return i("NETWORK_ERROR", `Failed to exchange code: ${String(r)}`);
266
298
  }
267
299
  }
268
- async function Oe() {
269
- const e = G();
300
+ async function $e() {
301
+ const e = Z();
270
302
  if (!e)
271
303
  return i("AUTH_FAILED", "Proxy URL not configured");
272
304
  const n = f();
@@ -290,8 +322,8 @@ async function Oe() {
290
322
  return i("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
291
323
  }
292
324
  }
293
- async function be() {
294
- const e = G();
325
+ async function ke() {
326
+ const e = Z();
295
327
  if (!e)
296
328
  return i("AUTH_FAILED", "Proxy URL not configured");
297
329
  const n = f();
@@ -314,7 +346,7 @@ async function be() {
314
346
  return n.logout(), i("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
315
347
  }
316
348
  }
317
- async function me(e, n) {
349
+ async function we(e, n) {
318
350
  let t = null;
319
351
  try {
320
352
  t = sessionStorage.getItem("een_oauth_state"), sessionStorage.removeItem("een_oauth_state");
@@ -322,16 +354,16 @@ async function me(e, n) {
322
354
  }
323
355
  if (!t)
324
356
  return i("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
325
- if (!$e(n, t))
357
+ if (!je(n, t))
326
358
  return i("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
327
359
  s("State validated, exchanging code for token");
328
- const r = await oe(e);
360
+ const r = await ue(e);
329
361
  if (r.error)
330
362
  return r;
331
363
  const a = f(), o = r.data;
332
364
  return a.setToken(o.accessToken, o.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(o.sessionId), a.setBaseUrl(o.httpsBaseUrl), s("Auth callback complete, user:", o.userEmail), d(o);
333
365
  }
334
- function $e(e, n) {
366
+ function je(e, n) {
335
367
  if (e.length !== n.length)
336
368
  return !1;
337
369
  let t = 0;
@@ -339,15 +371,15 @@ function $e(e, n) {
339
371
  t |= e.charCodeAt(r) ^ n.charCodeAt(r);
340
372
  return t === 0;
341
373
  }
342
- const ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
374
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
343
375
  __proto__: null,
344
- getAccessToken: oe,
345
- getAuthUrl: De,
346
- handleAuthCallback: me,
347
- refreshToken: Oe,
348
- revokeToken: be
376
+ getAccessToken: ue,
377
+ getAuthUrl: me,
378
+ handleAuthCallback: we,
379
+ refreshToken: $e,
380
+ revokeToken: ke
349
381
  }, Symbol.toStringTag, { value: "Module" }));
350
- async function We() {
382
+ async function Ke() {
351
383
  const e = f();
352
384
  if (!e.isAuthenticated)
353
385
  return i("AUTH_REQUIRED", "Authentication required");
@@ -364,14 +396,14 @@ async function We() {
364
396
  }
365
397
  });
366
398
  if (!t.ok)
367
- return J(t);
399
+ return ee(t);
368
400
  const r = await t.json();
369
401
  return s("Current user fetched:", r.email), e.setUserProfile(r), d(r);
370
402
  } catch (t) {
371
403
  return i("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
372
404
  }
373
405
  }
374
- async function Ve(e) {
406
+ async function Ge(e) {
375
407
  const n = f();
376
408
  if (!n.isAuthenticated)
377
409
  return i("AUTH_REQUIRED", "Authentication required");
@@ -390,14 +422,14 @@ async function Ve(e) {
390
422
  }
391
423
  });
392
424
  if (!o.ok)
393
- return J(o);
425
+ return ee(o);
394
426
  const c = await o.json();
395
427
  return s("Users fetched:", c.results?.length ?? 0, "users"), d(c);
396
428
  } catch (o) {
397
429
  return i("NETWORK_ERROR", `Failed to fetch users: ${String(o)}`);
398
430
  }
399
431
  }
400
- async function Me(e, n) {
432
+ async function Je(e, n) {
401
433
  const t = f();
402
434
  if (!t.isAuthenticated)
403
435
  return i("AUTH_REQUIRED", "Authentication required");
@@ -418,14 +450,14 @@ async function Me(e, n) {
418
450
  }
419
451
  });
420
452
  if (!c.ok)
421
- return J(c);
453
+ return ee(c);
422
454
  const u = await c.json();
423
455
  return s("User fetched:", u.email), d(u);
424
456
  } catch (c) {
425
457
  return i("NETWORK_ERROR", `Failed to fetch user: ${String(c)}`);
426
458
  }
427
459
  }
428
- async function J(e) {
460
+ async function ee(e) {
429
461
  const n = e.status;
430
462
  let t;
431
463
  try {
@@ -447,7 +479,7 @@ async function J(e) {
447
479
  return i("API_ERROR", `API error: ${t}`, n);
448
480
  }
449
481
  }
450
- async function Ke(e) {
482
+ async function Xe(e) {
451
483
  const n = f();
452
484
  if (!n.isAuthenticated)
453
485
  return i("AUTH_REQUIRED", "Authentication required");
@@ -466,14 +498,14 @@ async function Ke(e) {
466
498
  }
467
499
  });
468
500
  if (!o.ok)
469
- return X(o);
501
+ return te(o);
470
502
  const c = await o.json();
471
503
  return s("Cameras fetched:", c.results?.length ?? 0, "cameras"), d(c);
472
504
  } catch (o) {
473
505
  return i("NETWORK_ERROR", `Failed to fetch cameras: ${String(o)}`);
474
506
  }
475
507
  }
476
- async function Ge(e, n) {
508
+ async function Ye(e, n) {
477
509
  const t = f();
478
510
  if (!t.isAuthenticated)
479
511
  return i("AUTH_REQUIRED", "Authentication required");
@@ -494,14 +526,14 @@ async function Ge(e, n) {
494
526
  }
495
527
  });
496
528
  if (!c.ok)
497
- return X(c);
529
+ return te(c);
498
530
  const u = await c.json();
499
531
  return s("Camera fetched:", u.name), d(u);
500
532
  } catch (c) {
501
533
  return i("NETWORK_ERROR", `Failed to fetch camera: ${String(c)}`);
502
534
  }
503
535
  }
504
- async function Je(e, n) {
536
+ async function Ze(e, n) {
505
537
  const t = f();
506
538
  if (!t.isAuthenticated)
507
539
  return i("AUTH_REQUIRED", "Authentication required");
@@ -522,14 +554,14 @@ async function Je(e, n) {
522
554
  }
523
555
  });
524
556
  if (!c.ok)
525
- return X(c);
557
+ return te(c);
526
558
  const u = await c.json();
527
559
  return s("Camera settings fetched for:", e), d(u);
528
560
  } catch (c) {
529
561
  return i("NETWORK_ERROR", `Failed to fetch camera settings: ${String(c)}`);
530
562
  }
531
563
  }
532
- async function X(e) {
564
+ async function te(e) {
533
565
  const n = e.status;
534
566
  let t;
535
567
  try {
@@ -551,7 +583,7 @@ async function X(e) {
551
583
  return i("API_ERROR", `API error: ${t}`, n);
552
584
  }
553
585
  }
554
- async function Xe(e) {
586
+ async function et(e) {
555
587
  const n = f();
556
588
  if (!n.isAuthenticated)
557
589
  return i("AUTH_REQUIRED", "Authentication required");
@@ -570,14 +602,14 @@ async function Xe(e) {
570
602
  }
571
603
  });
572
604
  if (!o.ok)
573
- return ae(o);
605
+ return le(o);
574
606
  const c = await o.json();
575
607
  return s("Bridges fetched:", c.results?.length ?? 0, "bridges"), d(c);
576
608
  } catch (o) {
577
609
  return i("NETWORK_ERROR", `Failed to fetch bridges: ${String(o)}`);
578
610
  }
579
611
  }
580
- async function Ye(e, n) {
612
+ async function tt(e, n) {
581
613
  const t = f();
582
614
  if (!t.isAuthenticated)
583
615
  return i("AUTH_REQUIRED", "Authentication required");
@@ -598,14 +630,14 @@ async function Ye(e, n) {
598
630
  }
599
631
  });
600
632
  if (!c.ok)
601
- return ae(c);
633
+ return le(c);
602
634
  const u = await c.json();
603
635
  return s("Bridge fetched:", u.name), d(u);
604
636
  } catch (c) {
605
637
  return i("NETWORK_ERROR", `Failed to fetch bridge: ${String(c)}`);
606
638
  }
607
639
  }
608
- async function ae(e) {
640
+ async function le(e) {
609
641
  const n = e.status;
610
642
  let t;
611
643
  try {
@@ -627,7 +659,7 @@ async function ae(e) {
627
659
  return i("API_ERROR", `API error: ${t}`, n);
628
660
  }
629
661
  }
630
- async function Ze(e) {
662
+ async function nt(e) {
631
663
  const n = f();
632
664
  if (!n.isAuthenticated)
633
665
  return i("AUTH_REQUIRED", "Authentication required");
@@ -646,14 +678,14 @@ async function Ze(e) {
646
678
  }
647
679
  });
648
680
  if (!o.ok)
649
- return k(o);
681
+ return j(o);
650
682
  const c = await o.json();
651
683
  return s("Layouts fetched:", c.results?.length ?? 0, "layouts"), d(c);
652
684
  } catch (o) {
653
685
  return i("NETWORK_ERROR", `Failed to fetch layouts: ${String(o)}`);
654
686
  }
655
687
  }
656
- async function et(e, n) {
688
+ async function it(e, n) {
657
689
  const t = f();
658
690
  if (!t.isAuthenticated)
659
691
  return i("AUTH_REQUIRED", "Authentication required");
@@ -674,14 +706,14 @@ async function et(e, n) {
674
706
  }
675
707
  });
676
708
  if (!c.ok)
677
- return k(c);
709
+ return j(c);
678
710
  const u = await c.json();
679
711
  return s("Layout fetched:", u.name), d(u);
680
712
  } catch (c) {
681
713
  return i("NETWORK_ERROR", `Failed to fetch layout: ${String(c)}`);
682
714
  }
683
715
  }
684
- async function tt(e) {
716
+ async function rt(e) {
685
717
  const n = f();
686
718
  if (!n.isAuthenticated)
687
719
  return i("AUTH_REQUIRED", "Authentication required");
@@ -709,14 +741,14 @@ async function tt(e) {
709
741
  body: JSON.stringify(r)
710
742
  });
711
743
  if (!a.ok)
712
- return k(a);
744
+ return j(a);
713
745
  const o = await a.json();
714
746
  return s("Layout created:", o.id, o.name), d(o);
715
747
  } catch (a) {
716
748
  return i("NETWORK_ERROR", `Failed to create layout: ${String(a)}`);
717
749
  }
718
750
  }
719
- async function nt(e, n) {
751
+ async function ot(e, n) {
720
752
  const t = f();
721
753
  if (!t.isAuthenticated)
722
754
  return i("AUTH_REQUIRED", "Authentication required");
@@ -740,12 +772,12 @@ async function nt(e, n) {
740
772
  },
741
773
  body: JSON.stringify(a)
742
774
  });
743
- return o.ok ? (s("Layout updated:", e), d(void 0)) : k(o);
775
+ return o.ok ? (s("Layout updated:", e), d(void 0)) : j(o);
744
776
  } catch (o) {
745
777
  return i("NETWORK_ERROR", `Failed to update layout: ${String(o)}`);
746
778
  }
747
779
  }
748
- async function it(e) {
780
+ async function at(e) {
749
781
  const n = f();
750
782
  if (!n.isAuthenticated)
751
783
  return i("AUTH_REQUIRED", "Authentication required");
@@ -763,12 +795,12 @@ async function it(e) {
763
795
  Authorization: `Bearer ${n.token}`
764
796
  }
765
797
  });
766
- return r.ok ? (s("Layout deleted:", e), d(void 0)) : k(r);
798
+ return r.ok ? (s("Layout deleted:", e), d(void 0)) : j(r);
767
799
  } catch (r) {
768
800
  return i("NETWORK_ERROR", `Failed to delete layout: ${String(r)}`);
769
801
  }
770
802
  }
771
- async function k(e) {
803
+ async function j(e) {
772
804
  const n = e.status;
773
805
  let t;
774
806
  try {
@@ -792,12 +824,12 @@ async function k(e) {
792
824
  return i("API_ERROR", `API error: ${t}`, n);
793
825
  }
794
826
  }
795
- const we = 3e4;
796
- function w(e = we) {
827
+ const Le = 3e4;
828
+ function F(e = Le) {
797
829
  const n = new AbortController(), t = setTimeout(() => n.abort(), e);
798
830
  return { controller: n, timeoutId: t };
799
831
  }
800
- function ce(e) {
832
+ function de(e) {
801
833
  const n = new Uint8Array(e), t = 8192, r = [];
802
834
  for (let o = 0; o < n.byteLength; o += t) {
803
835
  const c = n.subarray(o, Math.min(o + t, n.byteLength));
@@ -809,7 +841,7 @@ function ce(e) {
809
841
  const a = r.join("");
810
842
  return typeof btoa == "function" ? btoa(a) : Buffer.from(a, "binary").toString("base64");
811
843
  }
812
- async function rt(e) {
844
+ async function ct(e) {
813
845
  const n = f();
814
846
  if (!n.isAuthenticated)
815
847
  return i("AUTH_REQUIRED", "Authentication required");
@@ -827,7 +859,7 @@ async function rt(e) {
827
859
  t.append("deviceId", e.deviceId), t.append("type", e.type), t.append("mediaType", e.mediaType), t.append("startTimestamp__gte", e.startTimestamp), e.endTimestamp && t.append("endTimestamp__lte", e.endTimestamp), typeof e.coalesce == "boolean" && t.append("coalesce", String(e.coalesce)), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), e.pageToken && t.append("pageToken", e.pageToken), typeof e.pageSize == "number" && t.append("pageSize", String(e.pageSize));
828
860
  const r = `${n.baseUrl}/api/v3.0/media?${t.toString()}`;
829
861
  s("Fetching media intervals:", r);
830
- const { controller: a, timeoutId: o } = w();
862
+ const { controller: a, timeoutId: o } = F();
831
863
  try {
832
864
  const c = await fetch(r, {
833
865
  method: "GET",
@@ -838,7 +870,7 @@ async function rt(e) {
838
870
  signal: a.signal
839
871
  });
840
872
  if (!c.ok)
841
- return q(c);
873
+ return C(c);
842
874
  const u = await c.json();
843
875
  return s("Media intervals fetched:", u.results?.length ?? 0, "intervals"), d(u);
844
876
  } catch (c) {
@@ -847,7 +879,7 @@ async function rt(e) {
847
879
  clearTimeout(o);
848
880
  }
849
881
  }
850
- async function ot(e) {
882
+ async function st(e) {
851
883
  const n = f();
852
884
  if (!n.isAuthenticated)
853
885
  return i("AUTH_REQUIRED", "Authentication required");
@@ -859,7 +891,7 @@ async function ot(e) {
859
891
  r.append("deviceId", e.deviceId), r.append("type", t);
860
892
  const a = `${n.baseUrl}/api/v3.0/media/liveImage.jpeg?${r.toString()}`;
861
893
  s("Fetching live image:", a);
862
- const { controller: o, timeoutId: c } = w();
894
+ const { controller: o, timeoutId: c } = F();
863
895
  try {
864
896
  const u = await fetch(a, {
865
897
  method: "GET",
@@ -870,10 +902,10 @@ async function ot(e) {
870
902
  signal: o.signal
871
903
  }), h = u.headers.get("X-Een-Timestamp"), _ = u.headers.get("X-Een-PrevToken");
872
904
  if (!u.ok)
873
- return q(u);
874
- const v = await u.arrayBuffer(), y = `data:image/jpeg;base64,${ce(v)}`;
905
+ return C(u);
906
+ const v = await u.arrayBuffer(), O = `data:image/jpeg;base64,${de(v)}`;
875
907
  return s("Live image fetched, timestamp:", h), d({
876
- imageData: y,
908
+ imageData: O,
877
909
  timestamp: h,
878
910
  prevToken: _
879
911
  });
@@ -883,7 +915,7 @@ async function ot(e) {
883
915
  clearTimeout(c);
884
916
  }
885
917
  }
886
- async function at(e) {
918
+ async function ut(e) {
887
919
  const n = f();
888
920
  if (!n.isAuthenticated)
889
921
  return i("AUTH_REQUIRED", "Authentication required");
@@ -899,7 +931,7 @@ async function at(e) {
899
931
  e.deviceId && t.append("deviceId", e.deviceId), e.pageToken && t.append("pageToken", e.pageToken), e.type && t.append("type", e.type), e.timestamp__lt && t.append("timestamp__lt", e.timestamp__lt), e.timestamp__lte && t.append("timestamp__lte", e.timestamp__lte), e.timestamp && t.append("timestamp", e.timestamp), e.timestamp__gte && t.append("timestamp__gte", e.timestamp__gte), e.timestamp__gt && t.append("timestamp__gt", e.timestamp__gt), e.overlayId__in && e.overlayId__in.length > 0 && t.append("overlayId__in", e.overlayId__in.join(",")), e.include && e.include.length > 0 && t.append("include", e.include.join(",")), typeof e.targetWidth == "number" && t.append("targetWidth", String(e.targetWidth)), typeof e.targetHeight == "number" && t.append("targetHeight", String(e.targetHeight));
900
932
  const r = `${n.baseUrl}/api/v3.0/media/recordedImage.jpeg?${t.toString()}`;
901
933
  s("Fetching recorded image:", r);
902
- const { controller: a, timeoutId: o } = w();
934
+ const { controller: a, timeoutId: o } = F();
903
935
  try {
904
936
  const c = await fetch(r, {
905
937
  method: "GET",
@@ -910,10 +942,10 @@ async function at(e) {
910
942
  signal: a.signal
911
943
  }), u = c.headers.get("X-Een-Timestamp"), h = c.headers.get("X-Een-NextToken"), _ = c.headers.get("X-Een-PrevToken"), v = c.headers.get("X-Een-OverlaySvg");
912
944
  if (!c.ok)
913
- return q(c);
914
- const g = await c.arrayBuffer(), S = `data:image/jpeg;base64,${ce(g)}`;
945
+ return C(c);
946
+ const g = await c.arrayBuffer(), b = `data:image/jpeg;base64,${de(g)}`;
915
947
  return s("Recorded image fetched, timestamp:", u), d({
916
- imageData: S,
948
+ imageData: b,
917
949
  timestamp: u,
918
950
  nextToken: h,
919
951
  prevToken: _,
@@ -925,7 +957,7 @@ async function at(e) {
925
957
  clearTimeout(o);
926
958
  }
927
959
  }
928
- async function q(e) {
960
+ async function C(e) {
929
961
  const n = e.status;
930
962
  let t;
931
963
  try {
@@ -949,7 +981,7 @@ async function q(e) {
949
981
  return i("API_ERROR", `API error: ${t}`, n);
950
982
  }
951
983
  }
952
- async function je() {
984
+ async function Ne() {
953
985
  const e = f();
954
986
  if (!e.isAuthenticated)
955
987
  return i("AUTH_REQUIRED", "Authentication required");
@@ -957,7 +989,7 @@ async function je() {
957
989
  return i("AUTH_REQUIRED", "Base URL not configured");
958
990
  const n = `${e.baseUrl}/api/v3.0/media/session`;
959
991
  s("Fetching media session:", n);
960
- const { controller: t, timeoutId: r } = w();
992
+ const { controller: t, timeoutId: r } = F();
961
993
  try {
962
994
  const a = await fetch(n, {
963
995
  method: "GET",
@@ -968,7 +1000,7 @@ async function je() {
968
1000
  signal: t.signal
969
1001
  });
970
1002
  if (!a.ok)
971
- return q(a);
1003
+ return C(a);
972
1004
  const o = await a.json();
973
1005
  return s("Media session URL received:", o.url), d(o);
974
1006
  } catch (a) {
@@ -977,11 +1009,11 @@ async function je() {
977
1009
  clearTimeout(r);
978
1010
  }
979
1011
  }
980
- async function ct() {
1012
+ async function lt() {
981
1013
  const e = f();
982
1014
  if (!e.isAuthenticated)
983
1015
  return i("AUTH_REQUIRED", "Authentication required");
984
- const n = await je();
1016
+ const n = await Ne();
985
1017
  if (n.error)
986
1018
  return i(
987
1019
  n.error.code,
@@ -994,14 +1026,12 @@ async function ct() {
994
1026
  s("Calling session URL to set cookie:", t);
995
1027
  try {
996
1028
  const o = new URL(t);
997
- if (![".eagleeyenetworks.com", ".een.cloud"].some(
998
- (h) => o.hostname === h.substring(1) || o.hostname.endsWith(h)
999
- ))
1029
+ if (!P(o.hostname))
1000
1030
  return i("VALIDATION_ERROR", `Session URL domain not allowed: ${o.hostname}`);
1001
1031
  } catch {
1002
1032
  return i("VALIDATION_ERROR", "Invalid session URL format");
1003
1033
  }
1004
- const { controller: r, timeoutId: a } = w();
1034
+ const { controller: r, timeoutId: a } = F();
1005
1035
  try {
1006
1036
  const o = await fetch(t, {
1007
1037
  method: "GET",
@@ -1034,7 +1064,7 @@ async function ct() {
1034
1064
  clearTimeout(a);
1035
1065
  }
1036
1066
  }
1037
- async function st(e) {
1067
+ async function dt(e) {
1038
1068
  const n = f();
1039
1069
  if (!n.isAuthenticated)
1040
1070
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1054,14 +1084,14 @@ async function st(e) {
1054
1084
  signal: e?.signal
1055
1085
  });
1056
1086
  if (!o.ok)
1057
- return Fe(o);
1087
+ return qe(o);
1058
1088
  const c = await o.json();
1059
1089
  return s("Feeds fetched:", c.results?.length ?? 0, "feeds"), d(c);
1060
1090
  } catch (o) {
1061
1091
  return i("NETWORK_ERROR", `Failed to fetch feeds: ${String(o)}`);
1062
1092
  }
1063
1093
  }
1064
- async function Fe(e) {
1094
+ async function qe(e) {
1065
1095
  const n = e.status;
1066
1096
  let t;
1067
1097
  try {
@@ -1085,7 +1115,7 @@ async function Fe(e) {
1085
1115
  return i("API_ERROR", t || e.statusText || "API error", n);
1086
1116
  }
1087
1117
  }
1088
- async function ut(e) {
1118
+ async function ft(e) {
1089
1119
  const n = f();
1090
1120
  if (!n.isAuthenticated)
1091
1121
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1098,7 +1128,7 @@ async function ut(e) {
1098
1128
  if (!e.startTimestamp__gte)
1099
1129
  return i("VALIDATION_ERROR", "startTimestamp__gte parameter is required");
1100
1130
  const t = new URLSearchParams();
1101
- t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte", I(e.startTimestamp__gte)), e.pageSize && t.append("pageSize", String(e.pageSize)), e.pageToken && t.append("pageToken", e.pageToken), e.startTimestamp__lte && t.append("startTimestamp__lte", I(e.startTimestamp__lte)), e.endTimestamp__gte && t.append("endTimestamp__gte", I(e.endTimestamp__gte)), e.endTimestamp__lte && t.append("endTimestamp__lte", I(e.endTimestamp__lte)), e.sort && t.append("sort", e.sort), e.include && e.include.length > 0 && t.append("include", e.include.join(","));
1131
+ t.append("actor", e.actor), t.append("type__in", e.type__in.join(",")), t.append("startTimestamp__gte", T(e.startTimestamp__gte)), e.pageSize && t.append("pageSize", String(e.pageSize)), e.pageToken && t.append("pageToken", e.pageToken), e.startTimestamp__lte && t.append("startTimestamp__lte", T(e.startTimestamp__lte)), e.endTimestamp__gte && t.append("endTimestamp__gte", T(e.endTimestamp__gte)), e.endTimestamp__lte && t.append("endTimestamp__lte", T(e.endTimestamp__lte)), e.sort && t.append("sort", e.sort), e.include && e.include.length > 0 && t.append("include", e.include.join(","));
1102
1132
  const r = t.toString(), a = `${n.baseUrl}/api/v3.0/events${r ? `?${r}` : ""}`;
1103
1133
  s("Fetching events:", a);
1104
1134
  try {
@@ -1110,14 +1140,14 @@ async function ut(e) {
1110
1140
  }
1111
1141
  });
1112
1142
  if (!o.ok)
1113
- return B(o);
1143
+ return H(o);
1114
1144
  const c = await o.json();
1115
1145
  return s("Events fetched:", c.results?.length ?? 0, "events"), d(c);
1116
1146
  } catch (o) {
1117
1147
  return i("NETWORK_ERROR", `Failed to fetch events: ${String(o)}`);
1118
1148
  }
1119
1149
  }
1120
- async function lt(e, n) {
1150
+ async function gt(e, n) {
1121
1151
  const t = f();
1122
1152
  if (!t.isAuthenticated)
1123
1153
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1138,14 +1168,14 @@ async function lt(e, n) {
1138
1168
  }
1139
1169
  });
1140
1170
  if (!c.ok)
1141
- return B(c);
1171
+ return H(c);
1142
1172
  const u = await c.json();
1143
1173
  return s("Event fetched:", u.id), d(u);
1144
1174
  } catch (c) {
1145
1175
  return i("NETWORK_ERROR", `Failed to fetch event: ${String(c)}`);
1146
1176
  }
1147
1177
  }
1148
- async function dt(e) {
1178
+ async function ht(e) {
1149
1179
  const n = f();
1150
1180
  if (!n.isAuthenticated)
1151
1181
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1164,14 +1194,14 @@ async function dt(e) {
1164
1194
  }
1165
1195
  });
1166
1196
  if (!o.ok)
1167
- return B(o);
1197
+ return H(o);
1168
1198
  const c = await o.json();
1169
1199
  return s("Event types fetched:", c.results?.length ?? 0, "types"), d(c);
1170
1200
  } catch (o) {
1171
1201
  return i("NETWORK_ERROR", `Failed to fetch event types: ${String(o)}`);
1172
1202
  }
1173
1203
  }
1174
- async function ft(e) {
1204
+ async function _t(e) {
1175
1205
  const n = f();
1176
1206
  if (!n.isAuthenticated)
1177
1207
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1192,14 +1222,14 @@ async function ft(e) {
1192
1222
  }
1193
1223
  });
1194
1224
  if (!o.ok)
1195
- return B(o);
1225
+ return H(o);
1196
1226
  const c = await o.json();
1197
1227
  return s("Event field values fetched:", c.type?.length ?? 0, "types"), d(c);
1198
1228
  } catch (o) {
1199
1229
  return i("NETWORK_ERROR", `Failed to fetch event field values: ${String(o)}`);
1200
1230
  }
1201
1231
  }
1202
- async function B(e) {
1232
+ async function H(e) {
1203
1233
  const n = e.status;
1204
1234
  let t;
1205
1235
  try {
@@ -1221,7 +1251,7 @@ async function B(e) {
1221
1251
  return i("API_ERROR", `API error: ${t}`, n);
1222
1252
  }
1223
1253
  }
1224
- const P = {
1254
+ const z = {
1225
1255
  // Detection events
1226
1256
  "een.motionDetectionEvent.v1": [
1227
1257
  "een.objectDetection.v1",
@@ -1555,38 +1585,38 @@ const P = {
1555
1585
  "een.handsUpDetectionEvent.v1": [],
1556
1586
  "een.vapeDetectionEvent.v1": []
1557
1587
  };
1558
- function se(e) {
1559
- return P[e] ?? [];
1588
+ function fe(e) {
1589
+ return z[e] ?? [];
1560
1590
  }
1561
- function gt(e) {
1591
+ function Rt(e) {
1562
1592
  const n = /* @__PURE__ */ new Set();
1563
1593
  for (const t of e) {
1564
- const r = se(t);
1594
+ const r = fe(t);
1565
1595
  for (const a of r)
1566
1596
  n.add(`data.${a}`);
1567
1597
  }
1568
1598
  return Array.from(n);
1569
1599
  }
1570
- function ht(e) {
1571
- return se(e).length > 0;
1600
+ function pt(e) {
1601
+ return fe(e).length > 0;
1572
1602
  }
1573
- function _t(e) {
1603
+ function Et(e) {
1574
1604
  const n = [];
1575
- for (const [t, r] of Object.entries(P))
1605
+ for (const [t, r] of Object.entries(z))
1576
1606
  r.includes(e) && n.push(t);
1577
1607
  return n;
1578
1608
  }
1579
- function Rt() {
1609
+ function vt() {
1580
1610
  const e = /* @__PURE__ */ new Set();
1581
- for (const n of Object.values(P))
1611
+ for (const n of Object.values(z))
1582
1612
  for (const t of n)
1583
1613
  e.add(t);
1584
1614
  return Array.from(e);
1585
1615
  }
1586
- function pt() {
1587
- return Object.keys(P);
1616
+ function At() {
1617
+ return Object.keys(z);
1588
1618
  }
1589
- async function vt(e) {
1619
+ async function It(e) {
1590
1620
  const n = f();
1591
1621
  if (!n.isAuthenticated)
1592
1622
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1597,7 +1627,7 @@ async function vt(e) {
1597
1627
  if (!e.eventType)
1598
1628
  return i("VALIDATION_ERROR", "eventType parameter is required");
1599
1629
  const t = new URLSearchParams();
1600
- t.append("actor", e.actor), t.append("eventType", e.eventType), e.timestamp__gte && t.append("timestamp__gte", I(e.timestamp__gte)), e.timestamp__lte && t.append("timestamp__lte", I(e.timestamp__lte)), e.aggregateByMinutes !== void 0 && t.append("aggregateByMinutes", String(e.aggregateByMinutes));
1630
+ t.append("actor", e.actor), t.append("eventType", e.eventType), e.timestamp__gte && t.append("timestamp__gte", T(e.timestamp__gte)), e.timestamp__lte && t.append("timestamp__lte", T(e.timestamp__lte)), e.aggregateByMinutes !== void 0 && t.append("aggregateByMinutes", String(e.aggregateByMinutes));
1601
1631
  const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventMetrics${r ? `?${r}` : ""}`;
1602
1632
  s("Fetching event metrics:", a);
1603
1633
  try {
@@ -1609,14 +1639,14 @@ async function vt(e) {
1609
1639
  }
1610
1640
  });
1611
1641
  if (!o.ok)
1612
- return Le(o);
1642
+ return Be(o);
1613
1643
  const c = await o.json();
1614
1644
  return s("Event metrics fetched:", c.length, "metrics"), d(c);
1615
1645
  } catch (o) {
1616
1646
  return i("NETWORK_ERROR", `Failed to fetch event metrics: ${String(o)}`);
1617
1647
  }
1618
1648
  }
1619
- async function Le(e) {
1649
+ async function Be(e) {
1620
1650
  const n = e.status;
1621
1651
  let t;
1622
1652
  try {
@@ -1638,14 +1668,14 @@ async function Le(e) {
1638
1668
  return i("API_ERROR", `API error: ${t}`, n);
1639
1669
  }
1640
1670
  }
1641
- async function Et(e) {
1671
+ async function Tt(e) {
1642
1672
  const n = f();
1643
1673
  if (!n.isAuthenticated)
1644
1674
  return i("AUTH_REQUIRED", "Authentication required");
1645
1675
  if (!n.baseUrl)
1646
1676
  return i("AUTH_REQUIRED", "Base URL not configured");
1647
1677
  const t = new URLSearchParams();
1648
- e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", I(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", I(e.timestamp__gte)), e?.creatorId && t.append("creatorId", e.creatorId), e?.alertType__in && e.alertType__in.length > 0 && t.append("alertType__in", e.alertType__in.join(",")), e?.actorId__in && e.actorId__in.length > 0 && t.append("actorId__in", e.actorId__in.join(",")), e?.actorType__in && e.actorType__in.length > 0 && t.append("actorType__in", e.actorType__in.join(",")), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.ruleId && t.append("ruleId", e.ruleId), e?.ruleId__in && e.ruleId__in.length > 0 && t.append("ruleId__in", e.ruleId__in.join(",")), e?.eventId && t.append("eventId", e.eventId), e?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.priority__gte !== void 0 && t.append("priority__gte", String(e.priority__gte)), e?.priority__lte !== void 0 && t.append("priority__lte", String(e.priority__lte)), e?.showInvalidAlerts !== void 0 && t.append("showInvalidAlerts", String(e.showInvalidAlerts)), e?.alertActionId__in && e.alertActionId__in.length > 0 && t.append("alertActionId__in", e.alertActionId__in.join(",")), e?.alertActionStatus__in && e.alertActionStatus__in.length > 0 && t.append("alertActionStatus__in", e.alertActionStatus__in.join(",")), e?.include && e.include.length > 0 && t.append("include", e.include.join(",")), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1678
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", T(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", T(e.timestamp__gte)), e?.creatorId && t.append("creatorId", e.creatorId), e?.alertType__in && e.alertType__in.length > 0 && t.append("alertType__in", e.alertType__in.join(",")), e?.actorId__in && e.actorId__in.length > 0 && t.append("actorId__in", e.actorId__in.join(",")), e?.actorType__in && e.actorType__in.length > 0 && t.append("actorType__in", e.actorType__in.join(",")), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.ruleId && t.append("ruleId", e.ruleId), e?.ruleId__in && e.ruleId__in.length > 0 && t.append("ruleId__in", e.ruleId__in.join(",")), e?.eventId && t.append("eventId", e.eventId), e?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.priority__gte !== void 0 && t.append("priority__gte", String(e.priority__gte)), e?.priority__lte !== void 0 && t.append("priority__lte", String(e.priority__lte)), e?.showInvalidAlerts !== void 0 && t.append("showInvalidAlerts", String(e.showInvalidAlerts)), e?.alertActionId__in && e.alertActionId__in.length > 0 && t.append("alertActionId__in", e.alertActionId__in.join(",")), e?.alertActionStatus__in && e.alertActionStatus__in.length > 0 && t.append("alertActionStatus__in", e.alertActionStatus__in.join(",")), e?.include && e.include.length > 0 && t.append("include", e.include.join(",")), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1649
1679
  const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alerts${r ? `?${r}` : ""}`;
1650
1680
  s("Fetching alerts:", a);
1651
1681
  try {
@@ -1657,14 +1687,14 @@ async function Et(e) {
1657
1687
  }
1658
1688
  });
1659
1689
  if (!o.ok)
1660
- return Y(o);
1690
+ return ne(o);
1661
1691
  const c = await o.json();
1662
1692
  return s("Alerts fetched:", c.results?.length ?? 0, "alerts"), d(c);
1663
1693
  } catch (o) {
1664
1694
  return i("NETWORK_ERROR", `Failed to fetch alerts: ${String(o)}`);
1665
1695
  }
1666
1696
  }
1667
- async function At(e, n) {
1697
+ async function Ut(e, n) {
1668
1698
  const t = f();
1669
1699
  if (!t.isAuthenticated)
1670
1700
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1685,14 +1715,14 @@ async function At(e, n) {
1685
1715
  }
1686
1716
  });
1687
1717
  if (!c.ok)
1688
- return Y(c);
1718
+ return ne(c);
1689
1719
  const u = await c.json();
1690
1720
  return s("Alert fetched:", u.id), d(u);
1691
1721
  } catch (c) {
1692
1722
  return i("NETWORK_ERROR", `Failed to fetch alert: ${String(c)}`);
1693
1723
  }
1694
1724
  }
1695
- async function It(e) {
1725
+ async function yt(e) {
1696
1726
  const n = f();
1697
1727
  if (!n.isAuthenticated)
1698
1728
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1711,14 +1741,14 @@ async function It(e) {
1711
1741
  }
1712
1742
  });
1713
1743
  if (!o.ok)
1714
- return Y(o);
1744
+ return ne(o);
1715
1745
  const c = await o.json();
1716
1746
  return s("Alert types fetched:", c.results?.length ?? 0, "types"), d(c);
1717
1747
  } catch (o) {
1718
1748
  return i("NETWORK_ERROR", `Failed to fetch alert types: ${String(o)}`);
1719
1749
  }
1720
1750
  }
1721
- async function Y(e) {
1751
+ async function ne(e) {
1722
1752
  const n = e.status;
1723
1753
  let t;
1724
1754
  try {
@@ -1740,14 +1770,14 @@ async function Y(e) {
1740
1770
  return i("API_ERROR", `API error: ${t}`, n);
1741
1771
  }
1742
1772
  }
1743
- async function Tt(e) {
1773
+ async function St(e) {
1744
1774
  const n = f();
1745
1775
  if (!n.isAuthenticated)
1746
1776
  return i("AUTH_REQUIRED", "Authentication required");
1747
1777
  if (!n.baseUrl)
1748
1778
  return i("AUTH_REQUIRED", "Base URL not configured");
1749
1779
  const t = new URLSearchParams();
1750
- e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", I(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", I(e.timestamp__gte)), e?.alertId && t.append("alertId", e.alertId), e?.alertType && t.append("alertType", e.alertType), e?.actorId && t.append("actorId", e.actorId), e?.actorType && t.append("actorType", e.actorType), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.category && t.append("category", e.category), e?.userId && t.append("userId", e.userId), e?.read !== void 0 && t.append("read", String(e.read)), e?.status && t.append("status", e.status), e?.includeV1Notifications !== void 0 && t.append("includeV1Notifications", String(e.includeV1Notifications)), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1780
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.timestamp__lte && t.append("timestamp__lte", T(e.timestamp__lte)), e?.timestamp__gte && t.append("timestamp__gte", T(e.timestamp__gte)), e?.alertId && t.append("alertId", e.alertId), e?.alertType && t.append("alertType", e.alertType), e?.actorId && t.append("actorId", e.actorId), e?.actorType && t.append("actorType", e.actorType), e?.actorAccountId && t.append("actorAccountId", e.actorAccountId), e?.category && t.append("category", e.category), e?.userId && t.append("userId", e.userId), e?.read !== void 0 && t.append("read", String(e.read)), e?.status && t.append("status", e.status), e?.includeV1Notifications !== void 0 && t.append("includeV1Notifications", String(e.includeV1Notifications)), e?.sort && e.sort.length > 0 && t.append("sort", e.sort.join(",")), e?.language && t.append("language", e.language);
1751
1781
  const r = t.toString(), a = `${n.baseUrl}/api/v3.0/notifications${r ? `?${r}` : ""}`;
1752
1782
  s("Fetching notifications:", a);
1753
1783
  try {
@@ -1759,14 +1789,14 @@ async function Tt(e) {
1759
1789
  }
1760
1790
  });
1761
1791
  if (!o.ok)
1762
- return ue(o);
1792
+ return ge(o);
1763
1793
  const c = await o.json();
1764
1794
  return s("Notifications fetched:", c.results?.length ?? 0, "notifications"), d(c);
1765
1795
  } catch (o) {
1766
1796
  return i("NETWORK_ERROR", `Failed to fetch notifications: ${String(o)}`);
1767
1797
  }
1768
1798
  }
1769
- async function Ut(e) {
1799
+ async function Dt(e) {
1770
1800
  const n = f();
1771
1801
  if (!n.isAuthenticated)
1772
1802
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1785,14 +1815,14 @@ async function Ut(e) {
1785
1815
  }
1786
1816
  });
1787
1817
  if (!r.ok)
1788
- return ue(r);
1818
+ return ge(r);
1789
1819
  const a = await r.json();
1790
1820
  return s("Notification fetched:", a.id), d(a);
1791
1821
  } catch (r) {
1792
1822
  return i("NETWORK_ERROR", `Failed to fetch notification: ${String(r)}`);
1793
1823
  }
1794
1824
  }
1795
- async function ue(e) {
1825
+ async function ge(e) {
1796
1826
  const n = e.status;
1797
1827
  let t;
1798
1828
  try {
@@ -1814,7 +1844,7 @@ async function ue(e) {
1814
1844
  return i("API_ERROR", `API error: ${t}`, n);
1815
1845
  }
1816
1846
  }
1817
- async function yt(e) {
1847
+ async function Ot(e) {
1818
1848
  const n = f();
1819
1849
  if (!n.isAuthenticated)
1820
1850
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1833,14 +1863,14 @@ async function yt(e) {
1833
1863
  }
1834
1864
  });
1835
1865
  if (!o.ok)
1836
- return C(o);
1866
+ return Q(o);
1837
1867
  const c = await o.json();
1838
1868
  return s("Event subscriptions fetched:", c.results?.length ?? 0, "subscriptions"), d(c);
1839
1869
  } catch (o) {
1840
1870
  return i("NETWORK_ERROR", `Failed to fetch event subscriptions: ${String(o)}`);
1841
1871
  }
1842
1872
  }
1843
- async function St(e) {
1873
+ async function bt(e) {
1844
1874
  const n = f();
1845
1875
  if (!n.isAuthenticated)
1846
1876
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1859,14 +1889,14 @@ async function St(e) {
1859
1889
  }
1860
1890
  });
1861
1891
  if (!r.ok)
1862
- return C(r);
1892
+ return Q(r);
1863
1893
  const a = await r.json();
1864
1894
  return s("Event subscription fetched:", a.id), d(a);
1865
1895
  } catch (r) {
1866
1896
  return i("NETWORK_ERROR", `Failed to fetch event subscription: ${String(r)}`);
1867
1897
  }
1868
1898
  }
1869
- async function Dt(e) {
1899
+ async function mt(e) {
1870
1900
  const n = f();
1871
1901
  if (!n.isAuthenticated)
1872
1902
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1895,14 +1925,14 @@ async function Dt(e) {
1895
1925
  body: JSON.stringify(e)
1896
1926
  });
1897
1927
  if (!r.ok)
1898
- return C(r);
1928
+ return Q(r);
1899
1929
  const a = await r.json();
1900
1930
  return s("Event subscription created:", a.id), d(a);
1901
1931
  } catch (r) {
1902
1932
  return i("NETWORK_ERROR", `Failed to create event subscription: ${String(r)}`);
1903
1933
  }
1904
1934
  }
1905
- async function Ot(e) {
1935
+ async function $t(e) {
1906
1936
  const n = f();
1907
1937
  if (!n.isAuthenticated)
1908
1938
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1920,12 +1950,12 @@ async function Ot(e) {
1920
1950
  Authorization: `Bearer ${n.token}`
1921
1951
  }
1922
1952
  });
1923
- return r.ok ? (s("Event subscription deleted:", e), d(void 0)) : C(r);
1953
+ return r.ok ? (s("Event subscription deleted:", e), d(void 0)) : Q(r);
1924
1954
  } catch (r) {
1925
1955
  return i("NETWORK_ERROR", `Failed to delete event subscription: ${String(r)}`);
1926
1956
  }
1927
1957
  }
1928
- function bt(e, n) {
1958
+ function kt(e, n) {
1929
1959
  const t = f();
1930
1960
  if (!t.isAuthenticated)
1931
1961
  return i("AUTH_REQUIRED", "Authentication required");
@@ -1935,9 +1965,7 @@ function bt(e, n) {
1935
1965
  return i("VALIDATION_ERROR", "SSE URL is required");
1936
1966
  try {
1937
1967
  const g = new URL(e);
1938
- if (![".eagleeyenetworks.com", ".een.cloud"].some(
1939
- (p) => g.hostname === p.substring(1) || g.hostname.endsWith(p)
1940
- ))
1968
+ if (!P(g.hostname))
1941
1969
  return i("VALIDATION_ERROR", `SSE URL domain not allowed: ${g.hostname}`);
1942
1970
  } catch {
1943
1971
  return i("VALIDATION_ERROR", "Invalid SSE URL format");
@@ -1966,35 +1994,35 @@ function bt(e, n) {
1966
1994
  if (!g.body)
1967
1995
  throw new Error("Response body is not available");
1968
1996
  u("connected"), s("SSE connected");
1969
- const y = g.body.getReader(), S = new TextDecoder();
1970
- let p = "";
1997
+ const O = g.body.getReader(), b = new TextDecoder();
1998
+ let U = "";
1971
1999
  for (; !c; ) {
1972
- const { done: H, value: z } = await y.read();
1973
- if (H) {
2000
+ const { done: x, value: W } = await O.read();
2001
+ if (x) {
1974
2002
  s("SSE stream ended");
1975
2003
  break;
1976
2004
  }
1977
- if (p += S.decode(z, { stream: !0 }), p.length > r) {
1978
- s("SSE buffer exceeded maximum size, resetting"), p = "";
2005
+ if (U += b.decode(W, { stream: !0 }), U.length > r) {
2006
+ s("SSE buffer exceeded maximum size, resetting"), U = "";
1979
2007
  continue;
1980
2008
  }
1981
- const F = p.split(`
2009
+ const N = U.split(`
1982
2010
  `);
1983
- p = F.pop() || "";
1984
- let U = "";
1985
- for (const O of F)
1986
- if (O.startsWith("data:")) {
1987
- const A = O.substring(5).trimStart();
1988
- U = U ? `${U}
1989
- ${A}` : A;
1990
- } else if (O === "" && U) {
2011
+ U = N.pop() || "";
2012
+ let S = "";
2013
+ for (const $ of N)
2014
+ if ($.startsWith("data:")) {
2015
+ const I = $.substring(5).trimStart();
2016
+ S = S ? `${S}
2017
+ ${I}` : I;
2018
+ } else if ($ === "" && S) {
1991
2019
  try {
1992
- const A = JSON.parse(U);
1993
- s("SSE event received:", A.type, A.actorId), n.onEvent(A);
1994
- } catch (A) {
1995
- s("Failed to parse SSE event:", A);
2020
+ const I = JSON.parse(S);
2021
+ s("SSE event received:", I.type, I.actorId), n.onEvent(I);
2022
+ } catch (I) {
2023
+ s("Failed to parse SSE event:", I);
1996
2024
  }
1997
- U = "";
2025
+ S = "";
1998
2026
  }
1999
2027
  }
2000
2028
  } catch (g) {
@@ -2010,7 +2038,7 @@ ${A}` : A;
2010
2038
  }
2011
2039
  });
2012
2040
  }
2013
- async function C(e) {
2041
+ async function Q(e) {
2014
2042
  const n = e.status;
2015
2043
  let t;
2016
2044
  try {
@@ -2032,7 +2060,7 @@ async function C(e) {
2032
2060
  return i("API_ERROR", t, n);
2033
2061
  }
2034
2062
  }
2035
- async function mt(e) {
2063
+ async function wt(e) {
2036
2064
  const n = f();
2037
2065
  if (!n.isAuthenticated)
2038
2066
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2051,14 +2079,14 @@ async function mt(e) {
2051
2079
  }
2052
2080
  });
2053
2081
  if (!o.ok)
2054
- return T(o);
2082
+ return y(o);
2055
2083
  const c = await o.json();
2056
2084
  return s("Event alert condition rules fetched:", c.results?.length ?? 0, "rules"), d(c);
2057
2085
  } catch (o) {
2058
2086
  return i("NETWORK_ERROR", `Failed to fetch event alert condition rules: ${String(o)}`);
2059
2087
  }
2060
2088
  }
2061
- async function $t(e) {
2089
+ async function jt(e) {
2062
2090
  const n = f();
2063
2091
  if (!n.isAuthenticated)
2064
2092
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2077,14 +2105,14 @@ async function $t(e) {
2077
2105
  }
2078
2106
  });
2079
2107
  if (!o.ok)
2080
- return T(o);
2108
+ return y(o);
2081
2109
  const c = await o.json();
2082
2110
  return s("Event alert condition rule field values fetched"), d(c);
2083
2111
  } catch (o) {
2084
2112
  return i("NETWORK_ERROR", `Failed to fetch field values: ${String(o)}`);
2085
2113
  }
2086
2114
  }
2087
- async function kt(e) {
2115
+ async function Ft(e) {
2088
2116
  const n = f();
2089
2117
  if (!n.isAuthenticated)
2090
2118
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2103,14 +2131,14 @@ async function kt(e) {
2103
2131
  }
2104
2132
  });
2105
2133
  if (!r.ok)
2106
- return T(r);
2134
+ return y(r);
2107
2135
  const a = await r.json();
2108
2136
  return s("Event alert condition rule fetched:", a.id), d(a);
2109
2137
  } catch (r) {
2110
2138
  return i("NETWORK_ERROR", `Failed to fetch event alert condition rule: ${String(r)}`);
2111
2139
  }
2112
2140
  }
2113
- async function wt(e) {
2141
+ async function Lt(e) {
2114
2142
  const n = f();
2115
2143
  if (!n.isAuthenticated)
2116
2144
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2129,14 +2157,14 @@ async function wt(e) {
2129
2157
  }
2130
2158
  });
2131
2159
  if (!o.ok)
2132
- return T(o);
2160
+ return y(o);
2133
2161
  const c = await o.json();
2134
2162
  return s("Alert condition rules fetched:", c.results?.length ?? 0, "rules"), d(c);
2135
2163
  } catch (o) {
2136
2164
  return i("NETWORK_ERROR", `Failed to fetch alert condition rules: ${String(o)}`);
2137
2165
  }
2138
2166
  }
2139
- async function jt(e, n) {
2167
+ async function Nt(e, n) {
2140
2168
  const t = f();
2141
2169
  if (!t.isAuthenticated)
2142
2170
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2157,14 +2185,14 @@ async function jt(e, n) {
2157
2185
  }
2158
2186
  });
2159
2187
  if (!c.ok)
2160
- return T(c);
2188
+ return y(c);
2161
2189
  const u = await c.json();
2162
2190
  return s("Alert condition rule fetched:", u.id), d(u);
2163
2191
  } catch (c) {
2164
2192
  return i("NETWORK_ERROR", `Failed to fetch alert condition rule: ${String(c)}`);
2165
2193
  }
2166
2194
  }
2167
- async function Ft(e) {
2195
+ async function qt(e) {
2168
2196
  const n = f();
2169
2197
  if (!n.isAuthenticated)
2170
2198
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2183,14 +2211,14 @@ async function Ft(e) {
2183
2211
  }
2184
2212
  });
2185
2213
  if (!o.ok)
2186
- return T(o);
2214
+ return y(o);
2187
2215
  const c = await o.json();
2188
2216
  return s("Alert action rules fetched:", c.results?.length ?? 0, "rules"), d(c);
2189
2217
  } catch (o) {
2190
2218
  return i("NETWORK_ERROR", `Failed to fetch alert action rules: ${String(o)}`);
2191
2219
  }
2192
2220
  }
2193
- async function Lt(e) {
2221
+ async function Bt(e) {
2194
2222
  const n = f();
2195
2223
  if (!n.isAuthenticated)
2196
2224
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2209,14 +2237,14 @@ async function Lt(e) {
2209
2237
  }
2210
2238
  });
2211
2239
  if (!r.ok)
2212
- return T(r);
2240
+ return y(r);
2213
2241
  const a = await r.json();
2214
2242
  return s("Alert action rule fetched:", a.id), d(a);
2215
2243
  } catch (r) {
2216
2244
  return i("NETWORK_ERROR", `Failed to fetch alert action rule: ${String(r)}`);
2217
2245
  }
2218
2246
  }
2219
- async function Nt(e) {
2247
+ async function Pt(e) {
2220
2248
  const n = f();
2221
2249
  if (!n.isAuthenticated)
2222
2250
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2235,14 +2263,14 @@ async function Nt(e) {
2235
2263
  }
2236
2264
  });
2237
2265
  if (!o.ok)
2238
- return T(o);
2266
+ return y(o);
2239
2267
  const c = await o.json();
2240
2268
  return s("Alert actions fetched:", c.results?.length ?? 0, "actions"), d(c);
2241
2269
  } catch (o) {
2242
2270
  return i("NETWORK_ERROR", `Failed to fetch alert actions: ${String(o)}`);
2243
2271
  }
2244
2272
  }
2245
- async function qt(e) {
2273
+ async function Ct(e) {
2246
2274
  const n = f();
2247
2275
  if (!n.isAuthenticated)
2248
2276
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2261,14 +2289,14 @@ async function qt(e) {
2261
2289
  }
2262
2290
  });
2263
2291
  if (!r.ok)
2264
- return T(r);
2292
+ return y(r);
2265
2293
  const a = await r.json();
2266
2294
  return s("Alert action fetched:", a.id), d(a);
2267
2295
  } catch (r) {
2268
2296
  return i("NETWORK_ERROR", `Failed to fetch alert action: ${String(r)}`);
2269
2297
  }
2270
2298
  }
2271
- async function T(e) {
2299
+ async function y(e) {
2272
2300
  const n = e.status;
2273
2301
  let t;
2274
2302
  try {
@@ -2290,7 +2318,7 @@ async function T(e) {
2290
2318
  return i("API_ERROR", `API error: ${t}`, n);
2291
2319
  }
2292
2320
  }
2293
- async function Bt(e) {
2321
+ async function Ht(e) {
2294
2322
  const n = f();
2295
2323
  if (!n.isAuthenticated)
2296
2324
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2336,14 +2364,14 @@ async function Bt(e) {
2336
2364
  body: JSON.stringify(o)
2337
2365
  });
2338
2366
  if (!c.ok)
2339
- return Ne(c);
2367
+ return Pe(c);
2340
2368
  const u = await c.json();
2341
2369
  return s("Export job created:", u.id), d(u);
2342
2370
  } catch (c) {
2343
2371
  return i("NETWORK_ERROR", `Failed to create export job: ${String(c)}`);
2344
2372
  }
2345
2373
  }
2346
- async function Ne(e) {
2374
+ async function Pe(e) {
2347
2375
  const n = e.status;
2348
2376
  let t;
2349
2377
  try {
@@ -2365,7 +2393,7 @@ async function Ne(e) {
2365
2393
  return i("API_ERROR", `API error: ${t}`, n);
2366
2394
  }
2367
2395
  }
2368
- async function Pt(e) {
2396
+ async function zt(e) {
2369
2397
  const n = f();
2370
2398
  if (!n.isAuthenticated)
2371
2399
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2384,14 +2412,14 @@ async function Pt(e) {
2384
2412
  }
2385
2413
  });
2386
2414
  if (!o.ok)
2387
- return Z(o);
2415
+ return ie(o);
2388
2416
  const c = await o.json();
2389
2417
  return s("Jobs fetched:", c.results?.length ?? 0, "jobs"), d(c);
2390
2418
  } catch (o) {
2391
2419
  return i("NETWORK_ERROR", `Failed to fetch jobs: ${String(o)}`);
2392
2420
  }
2393
2421
  }
2394
- async function Ct(e, n) {
2422
+ async function Qt(e, n) {
2395
2423
  const t = f();
2396
2424
  if (!t.isAuthenticated)
2397
2425
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2412,14 +2440,14 @@ async function Ct(e, n) {
2412
2440
  }
2413
2441
  });
2414
2442
  if (!c.ok)
2415
- return Z(c);
2443
+ return ie(c);
2416
2444
  const u = await c.json();
2417
2445
  return s("Job fetched:", u.arguments?.originalRequest?.name || u.id, "state:", u.state), d(u);
2418
2446
  } catch (c) {
2419
2447
  return i("NETWORK_ERROR", `Failed to fetch job: ${String(c)}`);
2420
2448
  }
2421
2449
  }
2422
- async function Ht(e) {
2450
+ async function xt(e) {
2423
2451
  const n = f();
2424
2452
  if (!n.isAuthenticated)
2425
2453
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2436,12 +2464,12 @@ async function Ht(e) {
2436
2464
  Authorization: `Bearer ${n.token}`
2437
2465
  }
2438
2466
  });
2439
- return r.ok ? (s("Job deleted:", e), d(void 0)) : Z(r);
2467
+ return r.ok ? (s("Job deleted:", e), d(void 0)) : ie(r);
2440
2468
  } catch (r) {
2441
2469
  return i("NETWORK_ERROR", `Failed to delete job: ${String(r)}`);
2442
2470
  }
2443
2471
  }
2444
- async function Z(e) {
2472
+ async function ie(e) {
2445
2473
  const n = e.status;
2446
2474
  let t;
2447
2475
  try {
@@ -2463,7 +2491,7 @@ async function Z(e) {
2463
2491
  return i("API_ERROR", `API error: ${t}`, n);
2464
2492
  }
2465
2493
  }
2466
- async function zt(e) {
2494
+ async function Wt(e) {
2467
2495
  const n = f();
2468
2496
  if (!n.isAuthenticated)
2469
2497
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2482,14 +2510,14 @@ async function zt(e) {
2482
2510
  }
2483
2511
  });
2484
2512
  if (!o.ok)
2485
- return j(o);
2513
+ return L(o);
2486
2514
  const c = await o.json();
2487
2515
  return s("Files fetched:", c.results?.length ?? 0, "files"), d(c);
2488
2516
  } catch (o) {
2489
2517
  return i("NETWORK_ERROR", `Failed to fetch files: ${String(o)}`);
2490
2518
  }
2491
2519
  }
2492
- async function Qt(e, n) {
2520
+ async function Vt(e, n) {
2493
2521
  const t = f();
2494
2522
  if (!t.isAuthenticated)
2495
2523
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2510,14 +2538,14 @@ async function Qt(e, n) {
2510
2538
  }
2511
2539
  });
2512
2540
  if (!c.ok)
2513
- return j(c);
2541
+ return L(c);
2514
2542
  const u = await c.json();
2515
2543
  return s("File fetched:", u.name), d(u);
2516
2544
  } catch (c) {
2517
2545
  return i("NETWORK_ERROR", `Failed to fetch file: ${String(c)}`);
2518
2546
  }
2519
2547
  }
2520
- async function xt(e) {
2548
+ async function Mt(e) {
2521
2549
  const n = f();
2522
2550
  if (!n.isAuthenticated)
2523
2551
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2542,14 +2570,14 @@ async function xt(e) {
2542
2570
  body: JSON.stringify(r)
2543
2571
  });
2544
2572
  if (!a.ok)
2545
- return j(a);
2573
+ return L(a);
2546
2574
  const o = await a.json();
2547
2575
  return s("File created:", o.id), d(o);
2548
2576
  } catch (a) {
2549
2577
  return i("NETWORK_ERROR", `Failed to create file: ${String(a)}`);
2550
2578
  }
2551
2579
  }
2552
- async function Wt(e) {
2580
+ async function Kt(e) {
2553
2581
  const n = f();
2554
2582
  if (!n.isAuthenticated)
2555
2583
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2567,7 +2595,7 @@ async function Wt(e) {
2567
2595
  }
2568
2596
  });
2569
2597
  if (!r.ok)
2570
- return j(r);
2598
+ return L(r);
2571
2599
  const a = await r.blob(), o = r.headers.get("Content-Disposition");
2572
2600
  let c = "download";
2573
2601
  if (o) {
@@ -2585,7 +2613,7 @@ async function Wt(e) {
2585
2613
  return i("NETWORK_ERROR", `Failed to download file: ${String(r)}`);
2586
2614
  }
2587
2615
  }
2588
- async function Vt(e) {
2616
+ async function Gt(e) {
2589
2617
  const n = f();
2590
2618
  if (!n.isAuthenticated)
2591
2619
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2602,12 +2630,12 @@ async function Vt(e) {
2602
2630
  Authorization: `Bearer ${n.token}`
2603
2631
  }
2604
2632
  });
2605
- return r.ok ? (s("File deleted (recycled):", e), d(void 0)) : j(r);
2633
+ return r.ok ? (s("File deleted (recycled):", e), d(void 0)) : L(r);
2606
2634
  } catch (r) {
2607
2635
  return i("NETWORK_ERROR", `Failed to delete file: ${String(r)}`);
2608
2636
  }
2609
2637
  }
2610
- async function j(e) {
2638
+ async function L(e) {
2611
2639
  const n = e.status;
2612
2640
  let t;
2613
2641
  try {
@@ -2629,7 +2657,7 @@ async function j(e) {
2629
2657
  return i("API_ERROR", `API error: ${t}`, n);
2630
2658
  }
2631
2659
  }
2632
- async function Mt(e) {
2660
+ async function Jt(e) {
2633
2661
  const n = f();
2634
2662
  if (!n.isAuthenticated)
2635
2663
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2648,14 +2676,14 @@ async function Mt(e) {
2648
2676
  }
2649
2677
  });
2650
2678
  if (!o.ok)
2651
- return ee(o);
2679
+ return re(o);
2652
2680
  const c = await o.json();
2653
2681
  return s("Downloads fetched:", c.results?.length ?? 0, "downloads"), d(c);
2654
2682
  } catch (o) {
2655
2683
  return i("NETWORK_ERROR", `Failed to fetch downloads: ${String(o)}`);
2656
2684
  }
2657
2685
  }
2658
- async function Kt(e, n) {
2686
+ async function Xt(e, n) {
2659
2687
  const t = f();
2660
2688
  if (!t.isAuthenticated)
2661
2689
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2676,14 +2704,14 @@ async function Kt(e, n) {
2676
2704
  }
2677
2705
  });
2678
2706
  if (!c.ok)
2679
- return ee(c);
2707
+ return re(c);
2680
2708
  const u = await c.json();
2681
2709
  return s("Download fetched:", u.name, "status:", u.status), d(u);
2682
2710
  } catch (c) {
2683
2711
  return i("NETWORK_ERROR", `Failed to fetch download: ${String(c)}`);
2684
2712
  }
2685
2713
  }
2686
- async function Gt(e) {
2714
+ async function Yt(e) {
2687
2715
  const n = f();
2688
2716
  if (!n.isAuthenticated)
2689
2717
  return i("AUTH_REQUIRED", "Authentication required");
@@ -2701,7 +2729,7 @@ async function Gt(e) {
2701
2729
  }
2702
2730
  });
2703
2731
  if (!r.ok)
2704
- return ee(r);
2732
+ return re(r);
2705
2733
  const a = await r.blob(), o = r.headers.get("Content-Disposition");
2706
2734
  let c = "download";
2707
2735
  if (o) {
@@ -2719,7 +2747,7 @@ async function Gt(e) {
2719
2747
  return i("NETWORK_ERROR", `Failed to download: ${String(r)}`);
2720
2748
  }
2721
2749
  }
2722
- async function ee(e) {
2750
+ async function re(e) {
2723
2751
  const n = e.status;
2724
2752
  let t;
2725
2753
  try {
@@ -2742,85 +2770,85 @@ async function ee(e) {
2742
2770
  }
2743
2771
  }
2744
2772
  export {
2745
- P as EVENT_TYPE_DATA_SCHEMAS,
2746
- Pe as STORAGE_STRATEGY_DESCRIPTIONS,
2747
- xt as addFile,
2748
- bt as connectToEventSubscription,
2749
- Dt as createEventSubscription,
2750
- Bt as createExportJob,
2751
- tt as createLayout,
2752
- Ot as deleteEventSubscription,
2753
- Vt as deleteFile,
2754
- Ht as deleteJob,
2755
- it as deleteLayout,
2756
- Gt as downloadDownload,
2757
- Wt as downloadFile,
2758
- ht as eventTypeHasDataSchemas,
2773
+ z as EVENT_TYPE_DATA_SCHEMAS,
2774
+ ze as STORAGE_STRATEGY_DESCRIPTIONS,
2775
+ Mt as addFile,
2776
+ kt as connectToEventSubscription,
2777
+ mt as createEventSubscription,
2778
+ Ht as createExportJob,
2779
+ rt as createLayout,
2780
+ $t as deleteEventSubscription,
2781
+ Gt as deleteFile,
2782
+ xt as deleteJob,
2783
+ at as deleteLayout,
2784
+ Yt as downloadDownload,
2785
+ Kt as downloadFile,
2786
+ pt as eventTypeHasDataSchemas,
2759
2787
  i as failure,
2760
- I as formatTimestamp,
2761
- oe as getAccessToken,
2762
- At as getAlert,
2763
- qt as getAlertAction,
2764
- Lt as getAlertActionRule,
2765
- jt as getAlertConditionRule,
2766
- Rt as getAllDataSchemas,
2767
- pt as getAllKnownEventTypes,
2768
- De as getAuthUrl,
2769
- Ye as getBridge,
2770
- Xe as getBridges,
2771
- Ge as getCamera,
2772
- Je as getCameraSettings,
2773
- Qe as getCameraStatusString,
2774
- Ke as getCameras,
2775
- Ue as getClientId,
2776
- ze as getConfig,
2777
- We as getCurrentUser,
2778
- se as getDataSchemasForEventType,
2779
- Kt as getDownload,
2780
- lt as getEvent,
2781
- kt as getEventAlertConditionRule,
2782
- $t as getEventAlertConditionRuleFieldValues,
2783
- vt as getEventMetrics,
2784
- St as getEventSubscription,
2785
- _t as getEventTypesForDataSchema,
2786
- Qt as getFile,
2787
- gt as getIncludeParameterForEventTypes,
2788
- Ct as getJob,
2789
- et as getLayout,
2790
- Ze as getLayouts,
2791
- ot as getLiveImage,
2792
- je as getMediaSession,
2793
- Ut as getNotification,
2794
- G as getProxyUrl,
2795
- at as getRecordedImage,
2796
- re as getRedirectUri,
2797
- Ce as getStorageStrategy,
2798
- Me as getUser,
2799
- Ve as getUsers,
2800
- me as handleAuthCallback,
2801
- He as initEenToolkit,
2802
- ct as initMediaSession,
2803
- xe as isStatusObject,
2804
- Ft as listAlertActionRules,
2805
- Nt as listAlertActions,
2806
- wt as listAlertConditionRules,
2807
- It as listAlertTypes,
2808
- Et as listAlerts,
2809
- Mt as listDownloads,
2810
- mt as listEventAlertConditionRules,
2811
- ft as listEventFieldValues,
2812
- yt as listEventSubscriptions,
2813
- dt as listEventTypes,
2814
- ut as listEvents,
2815
- st as listFeeds,
2816
- zt as listFiles,
2817
- Pt as listJobs,
2818
- rt as listMedia,
2819
- Tt as listNotifications,
2820
- Oe as refreshToken,
2821
- be as revokeToken,
2788
+ T as formatTimestamp,
2789
+ ue as getAccessToken,
2790
+ Ut as getAlert,
2791
+ Ct as getAlertAction,
2792
+ Bt as getAlertActionRule,
2793
+ Nt as getAlertConditionRule,
2794
+ vt as getAllDataSchemas,
2795
+ At as getAllKnownEventTypes,
2796
+ me as getAuthUrl,
2797
+ tt as getBridge,
2798
+ et as getBridges,
2799
+ Ye as getCamera,
2800
+ Ze as getCameraSettings,
2801
+ Ve as getCameraStatusString,
2802
+ Xe as getCameras,
2803
+ Se as getClientId,
2804
+ We as getConfig,
2805
+ Ke as getCurrentUser,
2806
+ fe as getDataSchemasForEventType,
2807
+ Xt as getDownload,
2808
+ gt as getEvent,
2809
+ Ft as getEventAlertConditionRule,
2810
+ jt as getEventAlertConditionRuleFieldValues,
2811
+ It as getEventMetrics,
2812
+ bt as getEventSubscription,
2813
+ Et as getEventTypesForDataSchema,
2814
+ Vt as getFile,
2815
+ Rt as getIncludeParameterForEventTypes,
2816
+ Qt as getJob,
2817
+ it as getLayout,
2818
+ nt as getLayouts,
2819
+ st as getLiveImage,
2820
+ Ne as getMediaSession,
2821
+ Dt as getNotification,
2822
+ Z as getProxyUrl,
2823
+ ut as getRecordedImage,
2824
+ se as getRedirectUri,
2825
+ Qe as getStorageStrategy,
2826
+ Je as getUser,
2827
+ Ge as getUsers,
2828
+ we as handleAuthCallback,
2829
+ xe as initEenToolkit,
2830
+ lt as initMediaSession,
2831
+ Me as isStatusObject,
2832
+ qt as listAlertActionRules,
2833
+ Pt as listAlertActions,
2834
+ Lt as listAlertConditionRules,
2835
+ yt as listAlertTypes,
2836
+ Tt as listAlerts,
2837
+ Jt as listDownloads,
2838
+ wt as listEventAlertConditionRules,
2839
+ _t as listEventFieldValues,
2840
+ Ot as listEventSubscriptions,
2841
+ ht as listEventTypes,
2842
+ ft as listEvents,
2843
+ dt as listFeeds,
2844
+ Wt as listFiles,
2845
+ zt as listJobs,
2846
+ ct as listMedia,
2847
+ St as listNotifications,
2848
+ $e as refreshToken,
2849
+ ke as revokeToken,
2822
2850
  d as success,
2823
- nt as updateLayout,
2851
+ ot as updateLayout,
2824
2852
  f as useAuthStore
2825
2853
  };
2826
2854
  //# sourceMappingURL=index.js.map