een-api-toolkit 0.3.43 → 0.3.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.claude/agents/docs-accuracy-reviewer.md +35 -5
  2. package/.claude/agents/een-automations-agent.md +264 -0
  3. package/.claude/agents/een-devices-agent.md +5 -7
  4. package/.claude/agents/een-events-agent.md +30 -16
  5. package/.claude/agents/een-media-agent.md +12 -15
  6. package/.claude/agents/een-users-agent.md +2 -2
  7. package/CHANGELOG.md +6 -8
  8. package/dist/index.cjs +3 -3
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.ts +815 -0
  11. package/dist/index.js +986 -719
  12. package/dist/index.js.map +1 -1
  13. package/docs/AI-CONTEXT.md +17 -1
  14. package/docs/ai-reference/AI-AUTH.md +1 -1
  15. package/docs/ai-reference/AI-AUTOMATIONS.md +833 -0
  16. package/docs/ai-reference/AI-DEVICES.md +1 -1
  17. package/docs/ai-reference/AI-EVENTS.md +1 -1
  18. package/docs/ai-reference/AI-GROUPING.md +128 -66
  19. package/docs/ai-reference/AI-MEDIA.md +1 -1
  20. package/docs/ai-reference/AI-SETUP.md +1 -1
  21. package/docs/ai-reference/AI-USERS.md +1 -1
  22. package/examples/vue-automations/.env.example +11 -0
  23. package/examples/vue-automations/README.md +205 -0
  24. package/examples/vue-automations/e2e/app.spec.ts +83 -0
  25. package/examples/vue-automations/e2e/auth.spec.ts +468 -0
  26. package/examples/vue-automations/index.html +13 -0
  27. package/examples/vue-automations/package-lock.json +1722 -0
  28. package/examples/vue-automations/package.json +29 -0
  29. package/examples/vue-automations/playwright.config.ts +46 -0
  30. package/examples/vue-automations/src/App.vue +122 -0
  31. package/examples/vue-automations/src/main.ts +23 -0
  32. package/examples/vue-automations/src/router/index.ts +61 -0
  33. package/examples/vue-automations/src/views/Automations.vue +692 -0
  34. package/examples/vue-automations/src/views/Callback.vue +76 -0
  35. package/examples/vue-automations/src/views/Home.vue +172 -0
  36. package/examples/vue-automations/src/views/Login.vue +33 -0
  37. package/examples/vue-automations/src/views/Logout.vue +66 -0
  38. package/examples/vue-automations/src/vite-env.d.ts +1 -0
  39. package/examples/vue-automations/tsconfig.json +21 -0
  40. package/examples/vue-automations/tsconfig.node.json +10 -0
  41. package/examples/vue-automations/vite.config.ts +12 -0
  42. package/examples/vue-event-subscriptions/e2e/auth.spec.ts +8 -12
  43. package/package.json +1 -1
  44. package/scripts/setup-agents.ts +38 -19
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { defineStore as fe } from "pinia";
2
- import { ref as E, computed as N } from "vue";
3
- const _e = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, ge = () => {
1
+ import { defineStore as _e } from "pinia";
2
+ import { ref as E, computed as q } from "vue";
3
+ const he = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, ge = () => {
4
4
  try {
5
- return _e?.VITE_DEBUG === "true";
5
+ return he?.VITE_DEBUG === "true";
6
6
  } catch {
7
7
  return !1;
8
8
  }
9
9
  };
10
- function c(...e) {
10
+ function s(...e) {
11
11
  ge() && console.log("[een-api-toolkit]", ...e);
12
12
  }
13
- const be = {
13
+ const Ne = {
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 he {
18
+ class Re {
19
19
  store = /* @__PURE__ */ new Map();
20
20
  getItem(n) {
21
21
  return this.store.get(n) ?? null;
@@ -27,7 +27,7 @@ class he {
27
27
  this.store.delete(n);
28
28
  }
29
29
  }
30
- class X {
30
+ class Y {
31
31
  constructor(n) {
32
32
  this.storage = n;
33
33
  }
@@ -41,148 +41,148 @@ class X {
41
41
  this.storage.removeItem(n);
42
42
  }
43
43
  }
44
- let V = "localStorage", z = null;
45
- function Q() {
46
- return z || (z = new he()), z;
44
+ let W = "localStorage", Q = null;
45
+ function C() {
46
+ return Q || (Q = new Re()), Q;
47
47
  }
48
- function Re(e) {
49
- V = e;
48
+ function pe(e) {
49
+ W = e;
50
50
  }
51
- function Le() {
52
- return V;
51
+ function je() {
52
+ return W;
53
53
  }
54
54
  function x() {
55
- switch (V) {
55
+ switch (W) {
56
56
  case "memory":
57
- return Q();
57
+ return C();
58
58
  case "sessionStorage":
59
- return typeof sessionStorage < "u" ? new X(sessionStorage) : (c("sessionStorage unavailable, falling back to memory storage"), Q());
59
+ return typeof sessionStorage < "u" ? new Y(sessionStorage) : (s("sessionStorage unavailable, falling back to memory storage"), C());
60
60
  default:
61
- return typeof localStorage < "u" ? new X(localStorage) : (c("localStorage unavailable, falling back to memory storage"), Q());
61
+ return typeof localStorage < "u" ? new Y(localStorage) : (s("localStorage unavailable, falling back to memory storage"), C());
62
62
  }
63
63
  }
64
- const v = {};
65
- let k = {};
66
- function Ne(e = {}) {
64
+ const $ = {};
65
+ let b = {};
66
+ function qe(e = {}) {
67
67
  const n = e.storageStrategy ?? "localStorage";
68
- Re(n), k = {
69
- proxyUrl: e.proxyUrl ?? v?.VITE_PROXY_URL,
70
- clientId: e.clientId ?? v?.VITE_EEN_CLIENT_ID,
71
- redirectUri: e.redirectUri ?? v?.VITE_REDIRECT_URI,
68
+ pe(n), b = {
69
+ proxyUrl: e.proxyUrl ?? $?.VITE_PROXY_URL,
70
+ clientId: e.clientId ?? $?.VITE_EEN_CLIENT_ID,
71
+ redirectUri: e.redirectUri ?? $?.VITE_REDIRECT_URI,
72
72
  storageStrategy: n,
73
- debug: e.debug ?? v?.VITE_DEBUG === "true"
73
+ debug: e.debug ?? $?.VITE_DEBUG === "true"
74
74
  };
75
75
  }
76
- function je() {
77
- return k;
76
+ function Fe() {
77
+ return b;
78
78
  }
79
- function W() {
80
- return k.proxyUrl ?? v?.VITE_PROXY_URL;
79
+ function K() {
80
+ return b.proxyUrl ?? $?.VITE_PROXY_URL;
81
81
  }
82
- function pe() {
83
- return k.clientId ?? v?.VITE_EEN_CLIENT_ID;
82
+ function Ee() {
83
+ return b.clientId ?? $?.VITE_EEN_CLIENT_ID;
84
84
  }
85
- function Y() {
86
- return k.redirectUri ?? v?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
85
+ function Z() {
86
+ return b.redirectUri ?? $?.VITE_REDIRECT_URI ?? "http://127.0.0.1:3333";
87
87
  }
88
88
  function l(e) {
89
89
  return { data: e, error: null };
90
90
  }
91
- function r(e, n, t, i) {
92
- return { data: null, error: { code: e, message: n, status: t, details: i } };
91
+ function i(e, n, t, r) {
92
+ return { data: null, error: { code: e, message: n, status: t, details: r } };
93
93
  }
94
94
  function I(e) {
95
95
  return e.endsWith("+00:00") ? e : e.endsWith("Z") ? e.replace("Z", "+00:00") : e;
96
96
  }
97
- let C = null;
98
- function Ee() {
99
- return C || (C = Promise.resolve().then(() => ve).then((e) => e.refreshToken)), C;
97
+ let V = null;
98
+ function Ae() {
99
+ return V || (V = Promise.resolve().then(() => $e).then((e) => e.refreshToken)), V;
100
100
  }
101
- const f = fe("een-auth", () => {
102
- const e = E(null), n = E(null), t = E(null), i = E(null), a = E(null), o = E(443), s = E(null), d = E(null), h = E(!1);
101
+ const f = _e("een-auth", () => {
102
+ const e = E(null), n = E(null), t = E(null), r = E(null), a = E(null), o = E(443), c = E(null), d = E(null), g = E(!1);
103
103
  let A = null;
104
- const p = E(!1), _ = E(null), y = N(() => !!e.value), S = N(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), R = N(() => n.value ? Date.now() >= n.value : !0), B = N(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
105
- function P(u, g) {
106
- e.value = u, n.value = Date.now() + g * 1e3, O(), H(), c("Token set, expires in", g, "seconds");
104
+ const p = E(!1), _ = E(null), S = q(() => !!e.value), v = q(() => a.value ? o.value === 443 ? `https://${a.value}` : `https://${a.value}:${o.value}` : null), R = q(() => n.value ? Date.now() >= n.value : !0), P = q(() => n.value ? Math.max(0, n.value - Date.now()) : 0);
105
+ function H(u, h) {
106
+ e.value = u, n.value = Date.now() + h * 1e3, D(), z(), s("Token set, expires in", h, "seconds");
107
107
  }
108
- function b(u) {
109
- t.value = u, O();
108
+ function N(u) {
109
+ t.value = u, D();
110
110
  }
111
- function U(u) {
112
- i.value = u, O();
111
+ function y(u) {
112
+ r.value = u, D();
113
113
  }
114
- function $(u) {
114
+ function O(u) {
115
115
  if (typeof u == "string")
116
116
  try {
117
- const g = new URL(u.startsWith("http") ? u : `https://${u}`);
118
- a.value = g.hostname, o.value = g.port ? parseInt(g.port, 10) : 443;
119
- } catch (g) {
120
- c("Failed to parse URL, using as hostname:", g instanceof Error ? g.message : String(g)), a.value = u, o.value = 443;
117
+ const h = new URL(u.startsWith("http") ? u : `https://${u}`);
118
+ a.value = h.hostname, o.value = h.port ? parseInt(h.port, 10) : 443;
119
+ } catch (h) {
120
+ s("Failed to parse URL, using as hostname:", h instanceof Error ? h.message : String(h)), a.value = u, o.value = 443;
121
121
  }
122
122
  else
123
123
  a.value = u.hostname, o.value = u.port ?? 443;
124
- O(), c("Base URL set:", S.value);
124
+ D(), s("Base URL set:", v.value);
125
125
  }
126
126
  function T(u) {
127
- s.value = u, O();
127
+ c.value = u, D();
128
128
  }
129
- function H() {
129
+ function z() {
130
130
  if (d.value && (clearTimeout(d.value), d.value = null), !n.value || !e.value)
131
131
  return;
132
- const u = Date.now(), D = n.value - u, L = 300 * 1e3, ue = D / 2, de = Math.min(L, ue), le = Math.max(D - de, 60 * 1e3), J = Math.max(le, 5e3);
133
- c("Auto-refresh scheduled in", Math.round(J / 1e3), "seconds"), d.value = setTimeout(async () => {
134
- await ie();
135
- }, J);
132
+ const u = Date.now(), k = n.value - u, j = 300 * 1e3, de = k / 2, le = Math.min(j, de), fe = Math.max(k - le, 60 * 1e3), X = Math.max(fe, 5e3);
133
+ s("Auto-refresh scheduled in", Math.round(X / 1e3), "seconds"), d.value = setTimeout(async () => {
134
+ await oe();
135
+ }, X);
136
136
  }
137
- async function ie() {
138
- return A ? (c("Refresh already in progress, waiting for existing refresh"), A) : (h.value = !0, c("Performing auto-refresh"), A = (async () => {
137
+ async function oe() {
138
+ return A ? (s("Refresh already in progress, waiting for existing refresh"), A) : (g.value = !0, s("Performing auto-refresh"), A = (async () => {
139
139
  try {
140
- const g = await (await Ee())();
141
- g.error ? (p.value = !0, _.value = g.error.message, c("Auto-refresh failed:", g.error.message)) : (p.value = !1, _.value = null, c("Auto-refresh successful"));
140
+ const h = await (await Ae())();
141
+ h.error ? (p.value = !0, _.value = h.error.message, s("Auto-refresh failed:", h.error.message)) : (p.value = !1, _.value = null, s("Auto-refresh successful"));
142
142
  } catch (u) {
143
- p.value = !0, _.value = u instanceof Error ? u.message : String(u), c("Auto-refresh error:", u);
143
+ p.value = !0, _.value = u instanceof Error ? u.message : String(u), s("Auto-refresh error:", u);
144
144
  } finally {
145
- h.value = !1, A = null;
145
+ g.value = !1, A = null;
146
146
  }
147
147
  })(), A);
148
148
  }
149
- function oe() {
149
+ function ae() {
150
150
  p.value = !1, _.value = null;
151
151
  }
152
- function G() {
153
- d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, i.value = null, a.value = null, o.value = 443, s.value = null, p.value = !1, _.value = null, ce(), c("Logged out");
152
+ function J() {
153
+ d.value && (clearTimeout(d.value), d.value = null), e.value = null, n.value = null, t.value = null, r.value = null, a.value = null, o.value = 443, c.value = null, p.value = !1, _.value = null, ue(), s("Logged out");
154
154
  }
155
- function ae() {
156
- se(), e.value && !R.value ? (H(), c("Initialized from storage")) : e.value && R.value && (c("Stored token expired, clearing"), G());
155
+ function ce() {
156
+ se(), e.value && !R.value ? (z(), s("Initialized from storage")) : e.value && R.value && (s("Stored token expired, clearing"), J());
157
157
  }
158
- function O() {
158
+ function D() {
159
159
  try {
160
160
  const u = x();
161
- e.value && u.setItem("een_token", e.value), n.value && u.setItem("een_tokenExpiration", String(n.value)), t.value && u.setItem("een_refreshTokenMarker", t.value), i.value && u.setItem("een_sessionId", i.value), a.value && u.setItem("een_hostname", a.value), o.value !== 443 && u.setItem("een_port", String(o.value)), s.value && u.setItem("een_userProfile", JSON.stringify(s.value));
161
+ e.value && u.setItem("een_token", e.value), n.value && u.setItem("een_tokenExpiration", String(n.value)), t.value && u.setItem("een_refreshTokenMarker", t.value), r.value && u.setItem("een_sessionId", r.value), a.value && u.setItem("een_hostname", a.value), o.value !== 443 && u.setItem("een_port", String(o.value)), c.value && u.setItem("een_userProfile", JSON.stringify(c.value));
162
162
  } catch (u) {
163
- c("Failed to save to storage:", u instanceof Error ? u.message : String(u));
163
+ s("Failed to save to storage:", u instanceof Error ? u.message : String(u));
164
164
  }
165
165
  }
166
166
  function se() {
167
167
  try {
168
168
  const u = x();
169
169
  e.value = u.getItem("een_token");
170
- const g = u.getItem("een_tokenExpiration");
171
- n.value = g ? parseInt(g, 10) : null, t.value = u.getItem("een_refreshTokenMarker"), i.value = u.getItem("een_sessionId"), a.value = u.getItem("een_hostname");
172
- const D = u.getItem("een_port");
173
- o.value = D ? parseInt(D, 10) : 443;
174
- const L = u.getItem("een_userProfile");
175
- s.value = L ? JSON.parse(L) : null;
170
+ const h = u.getItem("een_tokenExpiration");
171
+ n.value = h ? parseInt(h, 10) : null, t.value = u.getItem("een_refreshTokenMarker"), r.value = u.getItem("een_sessionId"), a.value = u.getItem("een_hostname");
172
+ const k = u.getItem("een_port");
173
+ o.value = k ? parseInt(k, 10) : 443;
174
+ const j = u.getItem("een_userProfile");
175
+ c.value = j ? JSON.parse(j) : null;
176
176
  } catch (u) {
177
- c("Failed to load from storage:", u instanceof Error ? u.message : String(u));
177
+ s("Failed to load from storage:", u instanceof Error ? u.message : String(u));
178
178
  }
179
179
  }
180
- function ce() {
180
+ function ue() {
181
181
  try {
182
182
  const u = x();
183
183
  u.removeItem("een_token"), u.removeItem("een_tokenExpiration"), u.removeItem("een_refreshTokenMarker"), u.removeItem("een_sessionId"), u.removeItem("een_hostname"), u.removeItem("een_port"), u.removeItem("een_userProfile");
184
184
  } catch (u) {
185
- c("Failed to clear storage:", u instanceof Error ? u.message : String(u));
185
+ s("Failed to clear storage:", u instanceof Error ? u.message : String(u));
186
186
  }
187
187
  }
188
188
  return {
@@ -190,32 +190,32 @@ const f = fe("een-auth", () => {
190
190
  token: e,
191
191
  tokenExpiration: n,
192
192
  refreshTokenMarker: t,
193
- sessionId: i,
193
+ sessionId: r,
194
194
  hostname: a,
195
195
  port: o,
196
- userProfile: s,
197
- isRefreshing: h,
196
+ userProfile: c,
197
+ isRefreshing: g,
198
198
  refreshFailed: p,
199
199
  refreshFailedMessage: _,
200
200
  // Computed
201
- isAuthenticated: y,
202
- baseUrl: S,
201
+ isAuthenticated: S,
202
+ baseUrl: v,
203
203
  isTokenExpired: R,
204
- tokenExpiresIn: B,
204
+ tokenExpiresIn: P,
205
205
  // Actions
206
- setToken: P,
207
- setRefreshTokenMarker: b,
208
- setSessionId: U,
209
- setBaseUrl: $,
206
+ setToken: H,
207
+ setRefreshTokenMarker: N,
208
+ setSessionId: y,
209
+ setBaseUrl: O,
210
210
  setUserProfile: T,
211
- setupAutoRefresh: H,
212
- clearRefreshFailed: oe,
213
- logout: G,
214
- initialize: ae
211
+ setupAutoRefresh: z,
212
+ clearRefreshFailed: ae,
213
+ logout: J,
214
+ initialize: ce
215
215
  };
216
- }), Ae = "https://auth.eagleeyenetworks.com/oauth2/authorize";
217
- function Te() {
218
- const e = pe();
216
+ }), Te = "https://auth.eagleeyenetworks.com/oauth2/authorize";
217
+ function Ie() {
218
+ const e = Ee();
219
219
  if (!e)
220
220
  throw new Error("Client ID not configured. Call initEenToolkit() or set VITE_EEN_CLIENT_ID");
221
221
  const n = crypto.randomUUID();
@@ -227,127 +227,127 @@ function Te() {
227
227
  client_id: e,
228
228
  response_type: "code",
229
229
  scope: "vms.all",
230
- redirect_uri: Y(),
230
+ redirect_uri: Z(),
231
231
  state: n
232
232
  });
233
- return c("Generated auth URL with state:", n), `${Ae}?${t.toString()}`;
233
+ return s("Generated auth URL with state:", n), `${Te}?${t.toString()}`;
234
234
  }
235
- async function Z(e) {
236
- const n = W();
235
+ async function ee(e) {
236
+ const n = K();
237
237
  if (!n)
238
- return r("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
238
+ return i("AUTH_FAILED", "Proxy URL not configured. Call initEenToolkit() or set VITE_PROXY_URL");
239
239
  const t = new URLSearchParams({
240
240
  code: e,
241
- redirect_uri: Y()
241
+ redirect_uri: Z()
242
242
  });
243
243
  try {
244
- const i = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
244
+ const r = await fetch(`${n}/proxy/getAccessToken?${t.toString()}`, {
245
245
  method: "POST",
246
246
  credentials: "include",
247
247
  headers: {
248
248
  Accept: "application/json"
249
249
  }
250
250
  });
251
- if (!i.ok) {
252
- const o = await i.text().catch(() => "Unknown error");
253
- return r("AUTH_FAILED", `Token exchange failed: ${o}`, i.status);
251
+ if (!r.ok) {
252
+ const o = await r.text().catch(() => "Unknown error");
253
+ return i("AUTH_FAILED", `Token exchange failed: ${o}`, r.status);
254
254
  }
255
- const a = await i.json();
256
- return c("Token received, expires in:", a.expiresIn), l(a);
257
- } catch (i) {
258
- return r("NETWORK_ERROR", `Failed to exchange code: ${String(i)}`);
255
+ const a = await r.json();
256
+ return s("Token received, expires in:", a.expiresIn), l(a);
257
+ } catch (r) {
258
+ return i("NETWORK_ERROR", `Failed to exchange code: ${String(r)}`);
259
259
  }
260
260
  }
261
- async function Ie() {
262
- const e = W();
261
+ async function Ue() {
262
+ const e = K();
263
263
  if (!e)
264
- return r("AUTH_FAILED", "Proxy URL not configured");
264
+ return i("AUTH_FAILED", "Proxy URL not configured");
265
265
  const n = f();
266
266
  try {
267
267
  const t = {
268
268
  Accept: "application/json"
269
269
  };
270
270
  n.sessionId && (t.Authorization = `Bearer ${n.sessionId}`);
271
- const i = await fetch(`${e}/proxy/refreshAccessToken`, {
271
+ const r = await fetch(`${e}/proxy/refreshAccessToken`, {
272
272
  method: "POST",
273
273
  credentials: "include",
274
274
  headers: t
275
275
  });
276
- if (!i.ok) {
277
- const o = await i.text().catch(() => "Unknown error");
278
- return r("AUTH_FAILED", `Token refresh failed: ${o}`, i.status);
276
+ if (!r.ok) {
277
+ const o = await r.text().catch(() => "Unknown error");
278
+ return i("AUTH_FAILED", `Token refresh failed: ${o}`, r.status);
279
279
  }
280
- const a = await i.json();
281
- return n.setToken(a.accessToken, a.expiresIn), c("Token refreshed, expires in:", a.expiresIn), l(a);
280
+ const a = await r.json();
281
+ return n.setToken(a.accessToken, a.expiresIn), s("Token refreshed, expires in:", a.expiresIn), l(a);
282
282
  } catch (t) {
283
- return r("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
283
+ return i("NETWORK_ERROR", `Failed to refresh token: ${String(t)}`);
284
284
  }
285
285
  }
286
- async function Ue() {
287
- const e = W();
286
+ async function ye() {
287
+ const e = K();
288
288
  if (!e)
289
- return r("AUTH_FAILED", "Proxy URL not configured");
289
+ return i("AUTH_FAILED", "Proxy URL not configured");
290
290
  const n = f();
291
291
  try {
292
292
  const t = {
293
293
  Accept: "application/json"
294
294
  };
295
295
  n.sessionId && (t.Authorization = `Bearer ${n.sessionId}`);
296
- const i = await fetch(`${e}/proxy/revoke`, {
296
+ const r = await fetch(`${e}/proxy/revoke`, {
297
297
  method: "POST",
298
298
  credentials: "include",
299
299
  headers: t
300
300
  });
301
- if (n.logout(), !i.ok) {
302
- const a = await i.text().catch(() => "Unknown error");
303
- return r("AUTH_FAILED", `Token revocation failed: ${a}`, i.status);
301
+ if (n.logout(), !r.ok) {
302
+ const a = await r.text().catch(() => "Unknown error");
303
+ return i("AUTH_FAILED", `Token revocation failed: ${a}`, r.status);
304
304
  }
305
- return c("Token revoked"), l(void 0);
305
+ return s("Token revoked"), l(void 0);
306
306
  } catch (t) {
307
- return n.logout(), r("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
307
+ return n.logout(), i("NETWORK_ERROR", `Failed to revoke token: ${String(t)}`);
308
308
  }
309
309
  }
310
- async function ye(e, n) {
310
+ async function Se(e, n) {
311
311
  let t = null;
312
312
  try {
313
313
  t = sessionStorage.getItem("een_oauth_state"), sessionStorage.removeItem("een_oauth_state");
314
314
  } catch {
315
315
  }
316
316
  if (!t)
317
- return r("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
318
- if (!Se(n, t))
319
- return r("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
320
- c("State validated, exchanging code for token");
321
- const i = await Z(e);
322
- if (i.error)
323
- return i;
324
- const a = f(), o = i.data;
325
- return a.setToken(o.accessToken, o.expiresIn), a.setRefreshTokenMarker("present"), a.setSessionId(o.sessionId), a.setBaseUrl(o.httpsBaseUrl), c("Auth callback complete, user:", o.userEmail), l(o);
326
- }
327
- function Se(e, n) {
317
+ return i("AUTH_FAILED", "No OAuth state found. Please restart the login process.");
318
+ if (!ve(n, t))
319
+ return i("AUTH_FAILED", "Invalid OAuth state. Possible CSRF attack.");
320
+ s("State validated, exchanging code for token");
321
+ const r = await ee(e);
322
+ if (r.error)
323
+ return r;
324
+ const a = f(), o = r.data;
325
+ 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), l(o);
326
+ }
327
+ function ve(e, n) {
328
328
  if (e.length !== n.length)
329
329
  return !1;
330
330
  let t = 0;
331
- for (let i = 0; i < e.length; i++)
332
- t |= e.charCodeAt(i) ^ n.charCodeAt(i);
331
+ for (let r = 0; r < e.length; r++)
332
+ t |= e.charCodeAt(r) ^ n.charCodeAt(r);
333
333
  return t === 0;
334
334
  }
335
- const ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
335
+ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
336
336
  __proto__: null,
337
- getAccessToken: Z,
338
- getAuthUrl: Te,
339
- handleAuthCallback: ye,
340
- refreshToken: Ie,
341
- revokeToken: Ue
337
+ getAccessToken: ee,
338
+ getAuthUrl: Ie,
339
+ handleAuthCallback: Se,
340
+ refreshToken: Ue,
341
+ revokeToken: ye
342
342
  }, Symbol.toStringTag, { value: "Module" }));
343
- async function qe() {
343
+ async function me() {
344
344
  const e = f();
345
345
  if (!e.isAuthenticated)
346
- return r("AUTH_REQUIRED", "Authentication required");
346
+ return i("AUTH_REQUIRED", "Authentication required");
347
347
  if (!e.baseUrl)
348
- return r("AUTH_REQUIRED", "Base URL not configured");
348
+ return i("AUTH_REQUIRED", "Base URL not configured");
349
349
  const n = `${e.baseUrl}/api/v3.0/users/self`;
350
- c("Fetching current user:", n);
350
+ s("Fetching current user:", n);
351
351
  try {
352
352
  const t = await fetch(n, {
353
353
  method: "GET",
@@ -358,22 +358,22 @@ async function qe() {
358
358
  });
359
359
  if (!t.ok)
360
360
  return M(t);
361
- const i = await t.json();
362
- return c("Current user fetched:", i.email), e.setUserProfile(i), l(i);
361
+ const r = await t.json();
362
+ return s("Current user fetched:", r.email), e.setUserProfile(r), l(r);
363
363
  } catch (t) {
364
- return r("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
364
+ return i("NETWORK_ERROR", `Failed to fetch current user: ${String(t)}`);
365
365
  }
366
366
  }
367
- async function Fe(e) {
367
+ async function Be(e) {
368
368
  const n = f();
369
369
  if (!n.isAuthenticated)
370
- return r("AUTH_REQUIRED", "Authentication required");
370
+ return i("AUTH_REQUIRED", "Authentication required");
371
371
  if (!n.baseUrl)
372
- return r("AUTH_REQUIRED", "Base URL not configured");
372
+ return i("AUTH_REQUIRED", "Base URL not configured");
373
373
  const t = new URLSearchParams();
374
374
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.include && e.include.length > 0 && t.append("include", e.include.join(","));
375
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/users${i ? `?${i}` : ""}`;
376
- c("Fetching users:", a);
375
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/users${r ? `?${r}` : ""}`;
376
+ s("Fetching users:", a);
377
377
  try {
378
378
  const o = await fetch(a, {
379
379
  method: "GET",
@@ -384,72 +384,72 @@ async function Fe(e) {
384
384
  });
385
385
  if (!o.ok)
386
386
  return M(o);
387
- const s = await o.json();
388
- return c("Users fetched:", s.results?.length ?? 0, "users"), l(s);
387
+ const c = await o.json();
388
+ return s("Users fetched:", c.results?.length ?? 0, "users"), l(c);
389
389
  } catch (o) {
390
- return r("NETWORK_ERROR", `Failed to fetch users: ${String(o)}`);
390
+ return i("NETWORK_ERROR", `Failed to fetch users: ${String(o)}`);
391
391
  }
392
392
  }
393
- async function Be(e, n) {
393
+ async function Pe(e, n) {
394
394
  const t = f();
395
395
  if (!t.isAuthenticated)
396
- return r("AUTH_REQUIRED", "Authentication required");
396
+ return i("AUTH_REQUIRED", "Authentication required");
397
397
  if (!t.baseUrl)
398
- return r("AUTH_REQUIRED", "Base URL not configured");
398
+ return i("AUTH_REQUIRED", "Base URL not configured");
399
399
  if (!e)
400
- return r("VALIDATION_ERROR", "User ID is required");
401
- const i = new URLSearchParams();
402
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
403
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/users/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
404
- c("Fetching user:", o);
400
+ return i("VALIDATION_ERROR", "User ID is required");
401
+ const r = new URLSearchParams();
402
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
403
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/users/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
404
+ s("Fetching user:", o);
405
405
  try {
406
- const s = await fetch(o, {
406
+ const c = await fetch(o, {
407
407
  method: "GET",
408
408
  headers: {
409
409
  Accept: "application/json",
410
410
  Authorization: `Bearer ${t.token}`
411
411
  }
412
412
  });
413
- if (!s.ok)
414
- return M(s);
415
- const d = await s.json();
416
- return c("User fetched:", d.email), l(d);
417
- } catch (s) {
418
- return r("NETWORK_ERROR", `Failed to fetch user: ${String(s)}`);
413
+ if (!c.ok)
414
+ return M(c);
415
+ const d = await c.json();
416
+ return s("User fetched:", d.email), l(d);
417
+ } catch (c) {
418
+ return i("NETWORK_ERROR", `Failed to fetch user: ${String(c)}`);
419
419
  }
420
420
  }
421
421
  async function M(e) {
422
422
  const n = e.status;
423
423
  let t;
424
424
  try {
425
- const i = await e.json();
426
- t = i.message ?? i.error ?? e.statusText;
425
+ const r = await e.json();
426
+ t = r.message ?? r.error ?? e.statusText;
427
427
  } catch {
428
428
  t = e.statusText || "Unknown error";
429
429
  }
430
430
  switch (n) {
431
431
  case 401:
432
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
432
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
433
433
  case 403:
434
- return r("FORBIDDEN", `Access denied: ${t}`, n);
434
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
435
435
  case 404:
436
- return r("NOT_FOUND", `Not found: ${t}`, n);
436
+ return i("NOT_FOUND", `Not found: ${t}`, n);
437
437
  case 429:
438
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
438
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
439
439
  default:
440
- return r("API_ERROR", `API error: ${t}`, n);
440
+ return i("API_ERROR", `API error: ${t}`, n);
441
441
  }
442
442
  }
443
- async function Pe(e) {
443
+ async function He(e) {
444
444
  const n = f();
445
445
  if (!n.isAuthenticated)
446
- return r("AUTH_REQUIRED", "Authentication required");
446
+ return i("AUTH_REQUIRED", "Authentication required");
447
447
  if (!n.baseUrl)
448
- return r("AUTH_REQUIRED", "Base URL not configured");
448
+ return i("AUTH_REQUIRED", "Base URL not configured");
449
449
  const t = new URLSearchParams();
450
450
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), 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?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.bridgeId__in && e.bridgeId__in.length > 0 && t.append("bridgeId__in", e.bridgeId__in.join(",")), e?.multiCameraId && t.append("multiCameraId", e.multiCameraId), e?.multiCameraId__ne && t.append("multiCameraId__ne", e.multiCameraId__ne), e?.multiCameraId__in && e.multiCameraId__in.length > 0 && t.append("multiCameraId__in", e.multiCameraId__in.join(",")), e?.tags__contains && e.tags__contains.length > 0 && t.append("tags__contains", e.tags__contains.join(",")), e?.tags__any && e.tags__any.length > 0 && t.append("tags__any", e.tags__any.join(",")), e?.packages__contains && e.packages__contains.length > 0 && t.append("packages__contains", e.packages__contains.join(",")), e?.name && t.append("name", e.name), e?.name__contains && t.append("name__contains", e.name__contains), e?.name__in && e.name__in.length > 0 && t.append("name__in", e.name__in.join(",")), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.id__notIn && e.id__notIn.length > 0 && t.append("id__notIn", e.id__notIn.join(",")), e?.id__contains && t.append("id__contains", e.id__contains), e?.layoutId && t.append("layoutId", e.layoutId), typeof e?.shared == "boolean" && t.append("shareDetails.shared", String(e.shared)), e?.sharedCameraAccount && t.append("shareDetails.accountId", e.sharedCameraAccount), typeof e?.firstResponder == "boolean" && t.append("shareDetails.firstResponder", String(e.firstResponder)), typeof e?.directToCloud == "boolean" && t.append("deviceInfo.directToCloud", String(e.directToCloud)), e?.speakerId__in && e.speakerId__in.length > 0 && t.append("speakerId__in", e.speakerId__in.join(",")), e?.q && t.append("q", e.q), typeof e?.qRelevance__gte == "number" && t.append("qRelevance__gte", String(e.qRelevance__gte)), e?.enabledAnalytics__contains && e.enabledAnalytics__contains.length > 0 && t.append("enabledAnalytics__contains", e.enabledAnalytics__contains.join(",")), e?.status__in && e.status__in.length > 0 && t.append("status__in", e.status__in.join(",")), e?.status__ne && t.append("status__ne", e.status__ne);
451
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/cameras${i ? `?${i}` : ""}`;
452
- c("Fetching cameras:", a);
451
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/cameras${r ? `?${r}` : ""}`;
452
+ s("Fetching cameras:", a);
453
453
  try {
454
454
  const o = await fetch(a, {
455
455
  method: "GET",
@@ -459,73 +459,73 @@ async function Pe(e) {
459
459
  }
460
460
  });
461
461
  if (!o.ok)
462
- return ee(o);
463
- const s = await o.json();
464
- return c("Cameras fetched:", s.results?.length ?? 0, "cameras"), l(s);
462
+ return te(o);
463
+ const c = await o.json();
464
+ return s("Cameras fetched:", c.results?.length ?? 0, "cameras"), l(c);
465
465
  } catch (o) {
466
- return r("NETWORK_ERROR", `Failed to fetch cameras: ${String(o)}`);
466
+ return i("NETWORK_ERROR", `Failed to fetch cameras: ${String(o)}`);
467
467
  }
468
468
  }
469
- async function He(e, n) {
469
+ async function ze(e, n) {
470
470
  const t = f();
471
471
  if (!t.isAuthenticated)
472
- return r("AUTH_REQUIRED", "Authentication required");
472
+ return i("AUTH_REQUIRED", "Authentication required");
473
473
  if (!t.baseUrl)
474
- return r("AUTH_REQUIRED", "Base URL not configured");
474
+ return i("AUTH_REQUIRED", "Base URL not configured");
475
475
  if (!e)
476
- return r("VALIDATION_ERROR", "Camera ID is required");
477
- const i = new URLSearchParams();
478
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
479
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/cameras/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
480
- c("Fetching camera:", o);
476
+ return i("VALIDATION_ERROR", "Camera ID is required");
477
+ const r = new URLSearchParams();
478
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
479
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/cameras/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
480
+ s("Fetching camera:", o);
481
481
  try {
482
- const s = await fetch(o, {
482
+ const c = await fetch(o, {
483
483
  method: "GET",
484
484
  headers: {
485
485
  Accept: "application/json",
486
486
  Authorization: `Bearer ${t.token}`
487
487
  }
488
488
  });
489
- if (!s.ok)
490
- return ee(s);
491
- const d = await s.json();
492
- return c("Camera fetched:", d.name), l(d);
493
- } catch (s) {
494
- return r("NETWORK_ERROR", `Failed to fetch camera: ${String(s)}`);
489
+ if (!c.ok)
490
+ return te(c);
491
+ const d = await c.json();
492
+ return s("Camera fetched:", d.name), l(d);
493
+ } catch (c) {
494
+ return i("NETWORK_ERROR", `Failed to fetch camera: ${String(c)}`);
495
495
  }
496
496
  }
497
- async function ee(e) {
497
+ async function te(e) {
498
498
  const n = e.status;
499
499
  let t;
500
500
  try {
501
- const i = await e.json();
502
- t = i.message ?? i.error ?? e.statusText;
503
- } catch (i) {
504
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
501
+ const r = await e.json();
502
+ t = r.message ?? r.error ?? e.statusText;
503
+ } catch (r) {
504
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
505
505
  }
506
506
  switch (n) {
507
507
  case 401:
508
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
508
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
509
509
  case 403:
510
- return r("FORBIDDEN", `Access denied: ${t}`, n);
510
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
511
511
  case 404:
512
- return r("NOT_FOUND", `Not found: ${t}`, n);
512
+ return i("NOT_FOUND", `Not found: ${t}`, n);
513
513
  case 429:
514
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
514
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
515
515
  default:
516
- return r("API_ERROR", `API error: ${t}`, n);
516
+ return i("API_ERROR", `API error: ${t}`, n);
517
517
  }
518
518
  }
519
- async function ze(e) {
519
+ async function Qe(e) {
520
520
  const n = f();
521
521
  if (!n.isAuthenticated)
522
- return r("AUTH_REQUIRED", "Authentication required");
522
+ return i("AUTH_REQUIRED", "Authentication required");
523
523
  if (!n.baseUrl)
524
- return r("AUTH_REQUIRED", "Base URL not configured");
524
+ return i("AUTH_REQUIRED", "Base URL not configured");
525
525
  const t = new URLSearchParams();
526
526
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), 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?.locationId__in && e.locationId__in.length > 0 && t.append("locationId__in", e.locationId__in.join(",")), e?.tags__contains && e.tags__contains.length > 0 && t.append("tags__contains", e.tags__contains.join(",")), e?.tags__any && e.tags__any.length > 0 && t.append("tags__any", e.tags__any.join(",")), e?.name && t.append("name", e.name), e?.name__contains && t.append("name__contains", e.name__contains), e?.name__in && e.name__in.length > 0 && t.append("name__in", e.name__in.join(",")), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.id__notIn && e.id__notIn.length > 0 && t.append("id__notIn", e.id__notIn.join(",")), e?.q && t.append("q", e.q), typeof e?.qRelevance__gte == "number" && t.append("qRelevance__gte", String(e.qRelevance__gte)), e?.status__in && e.status__in.length > 0 && t.append("status__in", e.status__in.join(",")), e?.status__ne && t.append("status__ne", e.status__ne);
527
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/bridges${i ? `?${i}` : ""}`;
528
- c("Fetching bridges:", a);
527
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/bridges${r ? `?${r}` : ""}`;
528
+ s("Fetching bridges:", a);
529
529
  try {
530
530
  const o = await fetch(a, {
531
531
  method: "GET",
@@ -535,73 +535,73 @@ async function ze(e) {
535
535
  }
536
536
  });
537
537
  if (!o.ok)
538
- return te(o);
539
- const s = await o.json();
540
- return c("Bridges fetched:", s.results?.length ?? 0, "bridges"), l(s);
538
+ return ne(o);
539
+ const c = await o.json();
540
+ return s("Bridges fetched:", c.results?.length ?? 0, "bridges"), l(c);
541
541
  } catch (o) {
542
- return r("NETWORK_ERROR", `Failed to fetch bridges: ${String(o)}`);
542
+ return i("NETWORK_ERROR", `Failed to fetch bridges: ${String(o)}`);
543
543
  }
544
544
  }
545
- async function Qe(e, n) {
545
+ async function Ce(e, n) {
546
546
  const t = f();
547
547
  if (!t.isAuthenticated)
548
- return r("AUTH_REQUIRED", "Authentication required");
548
+ return i("AUTH_REQUIRED", "Authentication required");
549
549
  if (!t.baseUrl)
550
- return r("AUTH_REQUIRED", "Base URL not configured");
550
+ return i("AUTH_REQUIRED", "Base URL not configured");
551
551
  if (!e)
552
- return r("VALIDATION_ERROR", "Bridge ID is required");
553
- const i = new URLSearchParams();
554
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
555
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/bridges/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
556
- c("Fetching bridge:", o);
552
+ return i("VALIDATION_ERROR", "Bridge ID is required");
553
+ const r = new URLSearchParams();
554
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
555
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/bridges/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
556
+ s("Fetching bridge:", o);
557
557
  try {
558
- const s = await fetch(o, {
558
+ const c = await fetch(o, {
559
559
  method: "GET",
560
560
  headers: {
561
561
  Accept: "application/json",
562
562
  Authorization: `Bearer ${t.token}`
563
563
  }
564
564
  });
565
- if (!s.ok)
566
- return te(s);
567
- const d = await s.json();
568
- return c("Bridge fetched:", d.name), l(d);
569
- } catch (s) {
570
- return r("NETWORK_ERROR", `Failed to fetch bridge: ${String(s)}`);
565
+ if (!c.ok)
566
+ return ne(c);
567
+ const d = await c.json();
568
+ return s("Bridge fetched:", d.name), l(d);
569
+ } catch (c) {
570
+ return i("NETWORK_ERROR", `Failed to fetch bridge: ${String(c)}`);
571
571
  }
572
572
  }
573
- async function te(e) {
573
+ async function ne(e) {
574
574
  const n = e.status;
575
575
  let t;
576
576
  try {
577
- const i = await e.json();
578
- t = i.message ?? i.error ?? e.statusText;
579
- } catch (i) {
580
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
577
+ const r = await e.json();
578
+ t = r.message ?? r.error ?? e.statusText;
579
+ } catch (r) {
580
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
581
581
  }
582
582
  switch (n) {
583
583
  case 401:
584
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
584
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
585
585
  case 403:
586
- return r("FORBIDDEN", `Access denied: ${t}`, n);
586
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
587
587
  case 404:
588
- return r("NOT_FOUND", `Not found: ${t}`, n);
588
+ return i("NOT_FOUND", `Not found: ${t}`, n);
589
589
  case 429:
590
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
590
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
591
591
  default:
592
- return r("API_ERROR", `API error: ${t}`, n);
592
+ return i("API_ERROR", `API error: ${t}`, n);
593
593
  }
594
594
  }
595
595
  async function xe(e) {
596
596
  const n = f();
597
597
  if (!n.isAuthenticated)
598
- return r("AUTH_REQUIRED", "Authentication required");
598
+ return i("AUTH_REQUIRED", "Authentication required");
599
599
  if (!n.baseUrl)
600
- return r("AUTH_REQUIRED", "Base URL not configured");
600
+ return i("AUTH_REQUIRED", "Base URL not configured");
601
601
  const t = new URLSearchParams();
602
602
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), 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?.name && t.append("name", e.name), e?.name__in && e.name__in.length > 0 && t.append("name__in", e.name__in.join(",")), e?.name__contains && t.append("name__contains", e.name__contains), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.["layoutPanes.cameras.bridgeId"] && t.append("layoutPanes.cameras.bridgeId", e["layoutPanes.cameras.bridgeId"]), e?.q && t.append("q", e.q), typeof e?.qRelevance__gte == "number" && t.append("qRelevance__gte", String(e.qRelevance__gte));
603
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/layouts${i ? `?${i}` : ""}`;
604
- c("Fetching layouts:", a);
603
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/layouts${r ? `?${r}` : ""}`;
604
+ s("Fetching layouts:", a);
605
605
  try {
606
606
  const o = await fetch(a, {
607
607
  method: "GET",
@@ -611,58 +611,58 @@ async function xe(e) {
611
611
  }
612
612
  });
613
613
  if (!o.ok)
614
- return m(o);
615
- const s = await o.json();
616
- return c("Layouts fetched:", s.results?.length ?? 0, "layouts"), l(s);
614
+ return w(o);
615
+ const c = await o.json();
616
+ return s("Layouts fetched:", c.results?.length ?? 0, "layouts"), l(c);
617
617
  } catch (o) {
618
- return r("NETWORK_ERROR", `Failed to fetch layouts: ${String(o)}`);
618
+ return i("NETWORK_ERROR", `Failed to fetch layouts: ${String(o)}`);
619
619
  }
620
620
  }
621
- async function Ce(e, n) {
621
+ async function Ve(e, n) {
622
622
  const t = f();
623
623
  if (!t.isAuthenticated)
624
- return r("AUTH_REQUIRED", "Authentication required");
624
+ return i("AUTH_REQUIRED", "Authentication required");
625
625
  if (!t.baseUrl)
626
- return r("AUTH_REQUIRED", "Base URL not configured");
626
+ return i("AUTH_REQUIRED", "Base URL not configured");
627
627
  if (!e)
628
- return r("VALIDATION_ERROR", "Layout ID is required");
629
- const i = new URLSearchParams();
630
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
631
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/layouts/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
632
- c("Fetching layout:", o);
628
+ return i("VALIDATION_ERROR", "Layout ID is required");
629
+ const r = new URLSearchParams();
630
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
631
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/layouts/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
632
+ s("Fetching layout:", o);
633
633
  try {
634
- const s = await fetch(o, {
634
+ const c = await fetch(o, {
635
635
  method: "GET",
636
636
  headers: {
637
637
  Accept: "application/json",
638
638
  Authorization: `Bearer ${t.token}`
639
639
  }
640
640
  });
641
- if (!s.ok)
642
- return m(s);
643
- const d = await s.json();
644
- return c("Layout fetched:", d.name), l(d);
645
- } catch (s) {
646
- return r("NETWORK_ERROR", `Failed to fetch layout: ${String(s)}`);
641
+ if (!c.ok)
642
+ return w(c);
643
+ const d = await c.json();
644
+ return s("Layout fetched:", d.name), l(d);
645
+ } catch (c) {
646
+ return i("NETWORK_ERROR", `Failed to fetch layout: ${String(c)}`);
647
647
  }
648
648
  }
649
- async function Ve(e) {
649
+ async function We(e) {
650
650
  const n = f();
651
651
  if (!n.isAuthenticated)
652
- return r("AUTH_REQUIRED", "Authentication required");
652
+ return i("AUTH_REQUIRED", "Authentication required");
653
653
  if (!n.baseUrl)
654
- return r("AUTH_REQUIRED", "Base URL not configured");
654
+ return i("AUTH_REQUIRED", "Base URL not configured");
655
655
  if (!e.name)
656
- return r("VALIDATION_ERROR", "Layout name is required");
656
+ return i("VALIDATION_ERROR", "Layout name is required");
657
657
  if (!e.settings)
658
- return r("VALIDATION_ERROR", "Layout settings are required");
658
+ return i("VALIDATION_ERROR", "Layout settings are required");
659
659
  const t = `${n.baseUrl}/api/v3.0/layouts`;
660
- c("Creating layout:", e.name);
661
- const i = {
660
+ s("Creating layout:", e.name);
661
+ const r = {
662
662
  name: e.name,
663
663
  settings: e.settings
664
664
  };
665
- e.panes && (i.panes = e.panes);
665
+ e.panes && (r.panes = e.panes);
666
666
  try {
667
667
  const a = await fetch(t, {
668
668
  method: "POST",
@@ -671,32 +671,32 @@ async function Ve(e) {
671
671
  "Content-Type": "application/json",
672
672
  Authorization: `Bearer ${n.token}`
673
673
  },
674
- body: JSON.stringify(i)
674
+ body: JSON.stringify(r)
675
675
  });
676
676
  if (!a.ok)
677
- return m(a);
677
+ return w(a);
678
678
  const o = await a.json();
679
- return c("Layout created:", o.id, o.name), l(o);
679
+ return s("Layout created:", o.id, o.name), l(o);
680
680
  } catch (a) {
681
- return r("NETWORK_ERROR", `Failed to create layout: ${String(a)}`);
681
+ return i("NETWORK_ERROR", `Failed to create layout: ${String(a)}`);
682
682
  }
683
683
  }
684
- async function We(e, n) {
684
+ async function Ke(e, n) {
685
685
  const t = f();
686
686
  if (!t.isAuthenticated)
687
- return r("AUTH_REQUIRED", "Authentication required");
687
+ return i("AUTH_REQUIRED", "Authentication required");
688
688
  if (!t.baseUrl)
689
- return r("AUTH_REQUIRED", "Base URL not configured");
689
+ return i("AUTH_REQUIRED", "Base URL not configured");
690
690
  if (!e)
691
- return r("VALIDATION_ERROR", "Layout ID is required");
691
+ return i("VALIDATION_ERROR", "Layout ID is required");
692
692
  if (n.name === void 0 && n.settings === void 0 && n.panes === void 0)
693
- return r("VALIDATION_ERROR", "At least one field (name, settings, or panes) must be provided for update");
694
- const i = `${t.baseUrl}/api/v3.0/layouts/${encodeURIComponent(e)}`;
695
- c("Updating layout:", e);
693
+ return i("VALIDATION_ERROR", "At least one field (name, settings, or panes) must be provided for update");
694
+ const r = `${t.baseUrl}/api/v3.0/layouts/${encodeURIComponent(e)}`;
695
+ s("Updating layout:", e);
696
696
  const a = {};
697
697
  n.name !== void 0 && (a.name = n.name), n.settings !== void 0 && (a.settings = n.settings), n.panes !== void 0 && (a.panes = n.panes);
698
698
  try {
699
- const o = await fetch(i, {
699
+ const o = await fetch(r, {
700
700
  method: "PATCH",
701
701
  headers: {
702
702
  Accept: "application/json",
@@ -705,96 +705,96 @@ async function We(e, n) {
705
705
  },
706
706
  body: JSON.stringify(a)
707
707
  });
708
- return o.ok ? (c("Layout updated:", e), l(void 0)) : m(o);
708
+ return o.ok ? (s("Layout updated:", e), l(void 0)) : w(o);
709
709
  } catch (o) {
710
- return r("NETWORK_ERROR", `Failed to update layout: ${String(o)}`);
710
+ return i("NETWORK_ERROR", `Failed to update layout: ${String(o)}`);
711
711
  }
712
712
  }
713
713
  async function Me(e) {
714
714
  const n = f();
715
715
  if (!n.isAuthenticated)
716
- return r("AUTH_REQUIRED", "Authentication required");
716
+ return i("AUTH_REQUIRED", "Authentication required");
717
717
  if (!n.baseUrl)
718
- return r("AUTH_REQUIRED", "Base URL not configured");
718
+ return i("AUTH_REQUIRED", "Base URL not configured");
719
719
  if (!e)
720
- return r("VALIDATION_ERROR", "Layout ID is required");
720
+ return i("VALIDATION_ERROR", "Layout ID is required");
721
721
  const t = `${n.baseUrl}/api/v3.0/layouts/${encodeURIComponent(e)}`;
722
- c("Deleting layout:", e);
722
+ s("Deleting layout:", e);
723
723
  try {
724
- const i = await fetch(t, {
724
+ const r = await fetch(t, {
725
725
  method: "DELETE",
726
726
  headers: {
727
727
  Accept: "application/json",
728
728
  Authorization: `Bearer ${n.token}`
729
729
  }
730
730
  });
731
- return i.ok ? (c("Layout deleted:", e), l(void 0)) : m(i);
732
- } catch (i) {
733
- return r("NETWORK_ERROR", `Failed to delete layout: ${String(i)}`);
731
+ return r.ok ? (s("Layout deleted:", e), l(void 0)) : w(r);
732
+ } catch (r) {
733
+ return i("NETWORK_ERROR", `Failed to delete layout: ${String(r)}`);
734
734
  }
735
735
  }
736
- async function m(e) {
736
+ async function w(e) {
737
737
  const n = e.status;
738
738
  let t;
739
739
  try {
740
- const i = await e.json();
741
- t = i.message ?? i.error ?? e.statusText;
742
- } catch (i) {
743
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
740
+ const r = await e.json();
741
+ t = r.message ?? r.error ?? e.statusText;
742
+ } catch (r) {
743
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
744
744
  }
745
745
  switch (n) {
746
746
  case 400:
747
- return r("VALIDATION_ERROR", `Bad request: ${t}`, n);
747
+ return i("VALIDATION_ERROR", `Bad request: ${t}`, n);
748
748
  case 401:
749
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
749
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
750
750
  case 403:
751
- return r("FORBIDDEN", `Access denied: ${t}`, n);
751
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
752
752
  case 404:
753
- return r("NOT_FOUND", `Not found: ${t}`, n);
753
+ return i("NOT_FOUND", `Not found: ${t}`, n);
754
754
  case 429:
755
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
755
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
756
756
  default:
757
- return r("API_ERROR", `API error: ${t}`, n);
757
+ return i("API_ERROR", `API error: ${t}`, n);
758
758
  }
759
759
  }
760
- const $e = 3e4;
761
- function w(e = $e) {
760
+ const Oe = 3e4;
761
+ function L(e = Oe) {
762
762
  const n = new AbortController(), t = setTimeout(() => n.abort(), e);
763
763
  return { controller: n, timeoutId: t };
764
764
  }
765
- function ne(e) {
766
- const n = new Uint8Array(e), t = 8192, i = [];
765
+ function ie(e) {
766
+ const n = new Uint8Array(e), t = 8192, r = [];
767
767
  for (let o = 0; o < n.byteLength; o += t) {
768
- const s = n.subarray(o, Math.min(o + t, n.byteLength));
768
+ const c = n.subarray(o, Math.min(o + t, n.byteLength));
769
769
  let d = "";
770
- for (let h = 0; h < s.length; h++)
771
- d += String.fromCharCode(s[h]);
772
- i.push(d);
770
+ for (let g = 0; g < c.length; g++)
771
+ d += String.fromCharCode(c[g]);
772
+ r.push(d);
773
773
  }
774
- const a = i.join("");
774
+ const a = r.join("");
775
775
  return typeof btoa == "function" ? btoa(a) : Buffer.from(a, "binary").toString("base64");
776
776
  }
777
- async function Ke(e) {
777
+ async function Ge(e) {
778
778
  const n = f();
779
779
  if (!n.isAuthenticated)
780
- return r("AUTH_REQUIRED", "Authentication required");
780
+ return i("AUTH_REQUIRED", "Authentication required");
781
781
  if (!n.baseUrl)
782
- return r("AUTH_REQUIRED", "Base URL not configured");
782
+ return i("AUTH_REQUIRED", "Base URL not configured");
783
783
  if (!e.deviceId)
784
- return r("VALIDATION_ERROR", "Device ID is required");
784
+ return i("VALIDATION_ERROR", "Device ID is required");
785
785
  if (!e.type)
786
- return r("VALIDATION_ERROR", "Stream type is required (preview or main)");
786
+ return i("VALIDATION_ERROR", "Stream type is required (preview or main)");
787
787
  if (!e.mediaType)
788
- return r("VALIDATION_ERROR", "Media type is required (video or image)");
788
+ return i("VALIDATION_ERROR", "Media type is required (video or image)");
789
789
  if (!e.startTimestamp)
790
- return r("VALIDATION_ERROR", "Start timestamp is required");
790
+ return i("VALIDATION_ERROR", "Start timestamp is required");
791
791
  const t = new URLSearchParams();
792
792
  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));
793
- const i = `${n.baseUrl}/api/v3.0/media?${t.toString()}`;
794
- c("Fetching media intervals:", i);
795
- const { controller: a, timeoutId: o } = w();
793
+ const r = `${n.baseUrl}/api/v3.0/media?${t.toString()}`;
794
+ s("Fetching media intervals:", r);
795
+ const { controller: a, timeoutId: o } = L();
796
796
  try {
797
- const s = await fetch(i, {
797
+ const c = await fetch(r, {
798
798
  method: "GET",
799
799
  headers: {
800
800
  Accept: "application/json",
@@ -802,29 +802,29 @@ async function Ke(e) {
802
802
  },
803
803
  signal: a.signal
804
804
  });
805
- if (!s.ok)
806
- return j(s);
807
- const d = await s.json();
808
- return c("Media intervals fetched:", d.results?.length ?? 0, "intervals"), l(d);
809
- } catch (s) {
810
- return s instanceof Error && s.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch media intervals: ${String(s)}`);
805
+ if (!c.ok)
806
+ return F(c);
807
+ const d = await c.json();
808
+ return s("Media intervals fetched:", d.results?.length ?? 0, "intervals"), l(d);
809
+ } catch (c) {
810
+ return c instanceof Error && c.name === "AbortError" ? i("NETWORK_ERROR", "Request timed out") : i("NETWORK_ERROR", `Failed to fetch media intervals: ${String(c)}`);
811
811
  } finally {
812
812
  clearTimeout(o);
813
813
  }
814
814
  }
815
- async function Ge(e) {
815
+ async function Je(e) {
816
816
  const n = f();
817
817
  if (!n.isAuthenticated)
818
- return r("AUTH_REQUIRED", "Authentication required");
818
+ return i("AUTH_REQUIRED", "Authentication required");
819
819
  if (!n.baseUrl)
820
- return r("AUTH_REQUIRED", "Base URL not configured");
820
+ return i("AUTH_REQUIRED", "Base URL not configured");
821
821
  if (!e.deviceId)
822
- return r("VALIDATION_ERROR", "Device ID is required");
823
- const t = e.type ?? "preview", i = new URLSearchParams();
824
- i.append("deviceId", e.deviceId), i.append("type", t);
825
- const a = `${n.baseUrl}/api/v3.0/media/liveImage.jpeg?${i.toString()}`;
826
- c("Fetching live image:", a);
827
- const { controller: o, timeoutId: s } = w();
822
+ return i("VALIDATION_ERROR", "Device ID is required");
823
+ const t = e.type ?? "preview", r = new URLSearchParams();
824
+ r.append("deviceId", e.deviceId), r.append("type", t);
825
+ const a = `${n.baseUrl}/api/v3.0/media/liveImage.jpeg?${r.toString()}`;
826
+ s("Fetching live image:", a);
827
+ const { controller: o, timeoutId: c } = L();
828
828
  try {
829
829
  const d = await fetch(a, {
830
830
  method: "GET",
@@ -833,96 +833,96 @@ async function Ge(e) {
833
833
  Authorization: `Bearer ${n.token}`
834
834
  },
835
835
  signal: o.signal
836
- }), h = d.headers.get("X-Een-Timestamp"), A = d.headers.get("X-Een-PrevToken");
836
+ }), g = d.headers.get("X-Een-Timestamp"), A = d.headers.get("X-Een-PrevToken");
837
837
  if (!d.ok)
838
- return j(d);
839
- const p = await d.arrayBuffer(), y = `data:image/jpeg;base64,${ne(p)}`;
840
- return c("Live image fetched, timestamp:", h), l({
841
- imageData: y,
842
- timestamp: h,
838
+ return F(d);
839
+ const p = await d.arrayBuffer(), S = `data:image/jpeg;base64,${ie(p)}`;
840
+ return s("Live image fetched, timestamp:", g), l({
841
+ imageData: S,
842
+ timestamp: g,
843
843
  prevToken: A
844
844
  });
845
845
  } catch (d) {
846
- return d instanceof Error && d.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch live image: ${String(d)}`);
846
+ return d instanceof Error && d.name === "AbortError" ? i("NETWORK_ERROR", "Request timed out") : i("NETWORK_ERROR", `Failed to fetch live image: ${String(d)}`);
847
847
  } finally {
848
- clearTimeout(s);
848
+ clearTimeout(c);
849
849
  }
850
850
  }
851
- async function Je(e) {
851
+ async function Xe(e) {
852
852
  const n = f();
853
853
  if (!n.isAuthenticated)
854
- return r("AUTH_REQUIRED", "Authentication required");
854
+ return i("AUTH_REQUIRED", "Authentication required");
855
855
  if (!n.baseUrl)
856
- return r("AUTH_REQUIRED", "Base URL not configured");
856
+ return i("AUTH_REQUIRED", "Base URL not configured");
857
857
  if (!e.deviceId && !e.pageToken)
858
- return r("VALIDATION_ERROR", "Either deviceId or pageToken is required");
858
+ return i("VALIDATION_ERROR", "Either deviceId or pageToken is required");
859
859
  if (!e.pageToken && !(e.timestamp__lt || e.timestamp__lte || e.timestamp || e.timestamp__gte || e.timestamp__gt))
860
- return r("VALIDATION_ERROR", "At least one timestamp parameter is required");
860
+ return i("VALIDATION_ERROR", "At least one timestamp parameter is required");
861
861
  if (e.include?.includes("overlaySvgHeader") && (!e.overlayId__in || e.overlayId__in.length === 0))
862
- return r("VALIDATION_ERROR", "At least one overlayId must be provided when requesting overlay headers");
862
+ return i("VALIDATION_ERROR", "At least one overlayId must be provided when requesting overlay headers");
863
863
  const t = new URLSearchParams();
864
864
  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));
865
- const i = `${n.baseUrl}/api/v3.0/media/recordedImage.jpeg?${t.toString()}`;
866
- c("Fetching recorded image:", i);
867
- const { controller: a, timeoutId: o } = w();
865
+ const r = `${n.baseUrl}/api/v3.0/media/recordedImage.jpeg?${t.toString()}`;
866
+ s("Fetching recorded image:", r);
867
+ const { controller: a, timeoutId: o } = L();
868
868
  try {
869
- const s = await fetch(i, {
869
+ const c = await fetch(r, {
870
870
  method: "GET",
871
871
  headers: {
872
872
  Accept: "image/jpeg",
873
873
  Authorization: `Bearer ${n.token}`
874
874
  },
875
875
  signal: a.signal
876
- }), d = s.headers.get("X-Een-Timestamp"), h = s.headers.get("X-Een-NextToken"), A = s.headers.get("X-Een-PrevToken"), p = s.headers.get("X-Een-OverlaySvg");
877
- if (!s.ok)
878
- return j(s);
879
- const _ = await s.arrayBuffer(), S = `data:image/jpeg;base64,${ne(_)}`;
880
- return c("Recorded image fetched, timestamp:", d), l({
881
- imageData: S,
876
+ }), d = c.headers.get("X-Een-Timestamp"), g = c.headers.get("X-Een-NextToken"), A = c.headers.get("X-Een-PrevToken"), p = c.headers.get("X-Een-OverlaySvg");
877
+ if (!c.ok)
878
+ return F(c);
879
+ const _ = await c.arrayBuffer(), v = `data:image/jpeg;base64,${ie(_)}`;
880
+ return s("Recorded image fetched, timestamp:", d), l({
881
+ imageData: v,
882
882
  timestamp: d,
883
- nextToken: h,
883
+ nextToken: g,
884
884
  prevToken: A,
885
885
  overlaySvg: p
886
886
  });
887
- } catch (s) {
888
- return s instanceof Error && s.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch recorded image: ${String(s)}`);
887
+ } catch (c) {
888
+ return c instanceof Error && c.name === "AbortError" ? i("NETWORK_ERROR", "Request timed out") : i("NETWORK_ERROR", `Failed to fetch recorded image: ${String(c)}`);
889
889
  } finally {
890
890
  clearTimeout(o);
891
891
  }
892
892
  }
893
- async function j(e) {
893
+ async function F(e) {
894
894
  const n = e.status;
895
895
  let t;
896
896
  try {
897
- const i = await e.json();
898
- t = i.message ?? i.error ?? e.statusText;
897
+ const r = await e.json();
898
+ t = r.message ?? r.error ?? e.statusText;
899
899
  } catch {
900
900
  t = e.statusText || "Unknown error";
901
901
  }
902
902
  switch (n) {
903
903
  case 401:
904
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
904
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
905
905
  case 403:
906
- return r("FORBIDDEN", `Access denied: ${t}`, n);
906
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
907
907
  case 404:
908
- return r("NOT_FOUND", `Not found: ${t}`, n);
908
+ return i("NOT_FOUND", `Not found: ${t}`, n);
909
909
  case 429:
910
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
910
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
911
911
  case 503:
912
- return r("SERVICE_UNAVAILABLE", `Service unavailable: ${t}`, n);
912
+ return i("SERVICE_UNAVAILABLE", `Service unavailable: ${t}`, n);
913
913
  default:
914
- return r("API_ERROR", `API error: ${t}`, n);
914
+ return i("API_ERROR", `API error: ${t}`, n);
915
915
  }
916
916
  }
917
- async function Oe() {
917
+ async function De() {
918
918
  const e = f();
919
919
  if (!e.isAuthenticated)
920
- return r("AUTH_REQUIRED", "Authentication required");
920
+ return i("AUTH_REQUIRED", "Authentication required");
921
921
  if (!e.baseUrl)
922
- return r("AUTH_REQUIRED", "Base URL not configured");
922
+ return i("AUTH_REQUIRED", "Base URL not configured");
923
923
  const n = `${e.baseUrl}/api/v3.0/media/session`;
924
- c("Fetching media session:", n);
925
- const { controller: t, timeoutId: i } = w();
924
+ s("Fetching media session:", n);
925
+ const { controller: t, timeoutId: r } = L();
926
926
  try {
927
927
  const a = await fetch(n, {
928
928
  method: "GET",
@@ -933,31 +933,31 @@ async function Oe() {
933
933
  signal: t.signal
934
934
  });
935
935
  if (!a.ok)
936
- return j(a);
936
+ return F(a);
937
937
  const o = await a.json();
938
- return c("Media session URL received:", o.url), l(o);
938
+ return s("Media session URL received:", o.url), l(o);
939
939
  } catch (a) {
940
- return a instanceof Error && a.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out") : r("NETWORK_ERROR", `Failed to fetch media session: ${String(a)}`);
940
+ return a instanceof Error && a.name === "AbortError" ? i("NETWORK_ERROR", "Request timed out") : i("NETWORK_ERROR", `Failed to fetch media session: ${String(a)}`);
941
941
  } finally {
942
- clearTimeout(i);
942
+ clearTimeout(r);
943
943
  }
944
944
  }
945
- async function Xe() {
945
+ async function Ye() {
946
946
  const e = f();
947
947
  if (!e.isAuthenticated)
948
- return r("AUTH_REQUIRED", "Authentication required");
949
- const n = await Oe();
948
+ return i("AUTH_REQUIRED", "Authentication required");
949
+ const n = await De();
950
950
  if (n.error)
951
- return r(
951
+ return i(
952
952
  n.error.code,
953
953
  `Failed to get media session: ${n.error.message}`,
954
954
  n.error.status
955
955
  );
956
956
  if (!n.data?.url)
957
- return r("API_ERROR", "No session URL returned from media session endpoint");
957
+ return i("API_ERROR", "No session URL returned from media session endpoint");
958
958
  const t = n.data.url;
959
- c("Calling session URL to set cookie:", t);
960
- const { controller: i, timeoutId: a } = w();
959
+ s("Calling session URL to set cookie:", t);
960
+ const { controller: r, timeoutId: a } = L();
961
961
  try {
962
962
  const o = await fetch(t, {
963
963
  method: "GET",
@@ -967,39 +967,39 @@ async function Xe() {
967
967
  Accept: "*/*",
968
968
  Authorization: `Bearer ${e.token}`
969
969
  },
970
- signal: i.signal
970
+ signal: r.signal
971
971
  });
972
972
  if (!o.ok && o.status !== 204) {
973
- const s = o.status;
973
+ const c = o.status;
974
974
  let d;
975
975
  try {
976
- const h = await o.json();
977
- d = h.message ?? h.error ?? o.statusText;
976
+ const g = await o.json();
977
+ d = g.message ?? g.error ?? o.statusText;
978
978
  } catch {
979
979
  d = o.statusText || "Unknown error";
980
980
  }
981
- return r("API_ERROR", `Failed to set media session cookie: ${d}`, s);
981
+ return i("API_ERROR", `Failed to set media session cookie: ${d}`, c);
982
982
  }
983
- return c("Media session cookie set successfully"), l({
983
+ return s("Media session cookie set successfully"), l({
984
984
  success: !0,
985
985
  sessionUrl: t
986
986
  });
987
987
  } catch (o) {
988
- return o instanceof Error && o.name === "AbortError" ? r("NETWORK_ERROR", "Request timed out while setting session cookie") : r("NETWORK_ERROR", `Failed to set media session cookie: ${String(o)}`);
988
+ return o instanceof Error && o.name === "AbortError" ? i("NETWORK_ERROR", "Request timed out while setting session cookie") : i("NETWORK_ERROR", `Failed to set media session cookie: ${String(o)}`);
989
989
  } finally {
990
990
  clearTimeout(a);
991
991
  }
992
992
  }
993
- async function Ye(e) {
993
+ async function Ze(e) {
994
994
  const n = f();
995
995
  if (!n.isAuthenticated)
996
- return r("AUTH_REQUIRED", "Authentication required");
996
+ return i("AUTH_REQUIRED", "Authentication required");
997
997
  if (!n.baseUrl)
998
- return r("AUTH_REQUIRED", "Base URL not configured");
998
+ return i("AUTH_REQUIRED", "Base URL not configured");
999
999
  const t = new URLSearchParams();
1000
1000
  typeof e?.pageSize == "number" && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.deviceId && t.append("deviceId", e.deviceId), e?.deviceId__in && e.deviceId__in.length > 0 && t.append("deviceId__in", e.deviceId__in.join(",")), e?.type && t.append("type", e.type), e?.include && e.include.length > 0 && t.append("include", e.include.join(","));
1001
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/feeds${i ? `?${i}` : ""}`;
1002
- c("Fetching feeds:", a);
1001
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/feeds${r ? `?${r}` : ""}`;
1002
+ s("Fetching feeds:", a);
1003
1003
  try {
1004
1004
  const o = await fetch(a, {
1005
1005
  method: "GET",
@@ -1010,53 +1010,53 @@ async function Ye(e) {
1010
1010
  signal: e?.signal
1011
1011
  });
1012
1012
  if (!o.ok)
1013
- return De(o);
1014
- const s = await o.json();
1015
- return c("Feeds fetched:", s.results?.length ?? 0, "feeds"), l(s);
1013
+ return ke(o);
1014
+ const c = await o.json();
1015
+ return s("Feeds fetched:", c.results?.length ?? 0, "feeds"), l(c);
1016
1016
  } catch (o) {
1017
- return r("NETWORK_ERROR", `Failed to fetch feeds: ${String(o)}`);
1017
+ return i("NETWORK_ERROR", `Failed to fetch feeds: ${String(o)}`);
1018
1018
  }
1019
1019
  }
1020
- async function De(e) {
1020
+ async function ke(e) {
1021
1021
  const n = e.status;
1022
1022
  let t;
1023
1023
  try {
1024
- const i = await e.json();
1025
- t = i.message ?? i.error;
1026
- } catch (i) {
1027
- c("Failed to parse error response JSON:", i);
1024
+ const r = await e.json();
1025
+ t = r.message ?? r.error;
1026
+ } catch (r) {
1027
+ s("Failed to parse error response JSON:", r);
1028
1028
  }
1029
1029
  switch (n) {
1030
1030
  case 401:
1031
- return r("AUTH_REQUIRED", t || "Authentication failed", n);
1031
+ return i("AUTH_REQUIRED", t || "Authentication failed", n);
1032
1032
  case 403:
1033
- return r("FORBIDDEN", t || "Access denied", n);
1033
+ return i("FORBIDDEN", t || "Access denied", n);
1034
1034
  case 404:
1035
- return r("NOT_FOUND", t || "Not found", n);
1035
+ return i("NOT_FOUND", t || "Not found", n);
1036
1036
  case 429:
1037
- return r("RATE_LIMITED", t || "Rate limited", n);
1037
+ return i("RATE_LIMITED", t || "Rate limited", n);
1038
1038
  case 503:
1039
- return r("SERVICE_UNAVAILABLE", t || "Service unavailable", n);
1039
+ return i("SERVICE_UNAVAILABLE", t || "Service unavailable", n);
1040
1040
  default:
1041
- return r("API_ERROR", t || e.statusText || "API error", n);
1041
+ return i("API_ERROR", t || e.statusText || "API error", n);
1042
1042
  }
1043
1043
  }
1044
- async function Ze(e) {
1044
+ async function et(e) {
1045
1045
  const n = f();
1046
1046
  if (!n.isAuthenticated)
1047
- return r("AUTH_REQUIRED", "Authentication required");
1047
+ return i("AUTH_REQUIRED", "Authentication required");
1048
1048
  if (!n.baseUrl)
1049
- return r("AUTH_REQUIRED", "Base URL not configured");
1049
+ return i("AUTH_REQUIRED", "Base URL not configured");
1050
1050
  if (!e.actor)
1051
- return r("VALIDATION_ERROR", "actor parameter is required");
1051
+ return i("VALIDATION_ERROR", "actor parameter is required");
1052
1052
  if (!e.type__in || e.type__in.length === 0)
1053
- return r("VALIDATION_ERROR", "type__in parameter is required and must not be empty");
1053
+ return i("VALIDATION_ERROR", "type__in parameter is required and must not be empty");
1054
1054
  if (!e.startTimestamp__gte)
1055
- return r("VALIDATION_ERROR", "startTimestamp__gte parameter is required");
1055
+ return i("VALIDATION_ERROR", "startTimestamp__gte parameter is required");
1056
1056
  const t = new URLSearchParams();
1057
1057
  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(","));
1058
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/events${i ? `?${i}` : ""}`;
1059
- c("Fetching events:", a);
1058
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/events${r ? `?${r}` : ""}`;
1059
+ s("Fetching events:", a);
1060
1060
  try {
1061
1061
  const o = await fetch(a, {
1062
1062
  method: "GET",
@@ -1066,51 +1066,51 @@ async function Ze(e) {
1066
1066
  }
1067
1067
  });
1068
1068
  if (!o.ok)
1069
- return q(o);
1070
- const s = await o.json();
1071
- return c("Events fetched:", s.results?.length ?? 0, "events"), l(s);
1069
+ return m(o);
1070
+ const c = await o.json();
1071
+ return s("Events fetched:", c.results?.length ?? 0, "events"), l(c);
1072
1072
  } catch (o) {
1073
- return r("NETWORK_ERROR", `Failed to fetch events: ${String(o)}`);
1073
+ return i("NETWORK_ERROR", `Failed to fetch events: ${String(o)}`);
1074
1074
  }
1075
1075
  }
1076
- async function et(e, n) {
1076
+ async function tt(e, n) {
1077
1077
  const t = f();
1078
1078
  if (!t.isAuthenticated)
1079
- return r("AUTH_REQUIRED", "Authentication required");
1079
+ return i("AUTH_REQUIRED", "Authentication required");
1080
1080
  if (!t.baseUrl)
1081
- return r("AUTH_REQUIRED", "Base URL not configured");
1081
+ return i("AUTH_REQUIRED", "Base URL not configured");
1082
1082
  if (!e)
1083
- return r("VALIDATION_ERROR", "Event ID is required");
1084
- const i = new URLSearchParams();
1085
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
1086
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/events/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1087
- c("Fetching event:", o);
1083
+ return i("VALIDATION_ERROR", "Event ID is required");
1084
+ const r = new URLSearchParams();
1085
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
1086
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/events/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1087
+ s("Fetching event:", o);
1088
1088
  try {
1089
- const s = await fetch(o, {
1089
+ const c = await fetch(o, {
1090
1090
  method: "GET",
1091
1091
  headers: {
1092
1092
  Accept: "application/json",
1093
1093
  Authorization: `Bearer ${t.token}`
1094
1094
  }
1095
1095
  });
1096
- if (!s.ok)
1097
- return q(s);
1098
- const d = await s.json();
1099
- return c("Event fetched:", d.id), l(d);
1100
- } catch (s) {
1101
- return r("NETWORK_ERROR", `Failed to fetch event: ${String(s)}`);
1096
+ if (!c.ok)
1097
+ return m(c);
1098
+ const d = await c.json();
1099
+ return s("Event fetched:", d.id), l(d);
1100
+ } catch (c) {
1101
+ return i("NETWORK_ERROR", `Failed to fetch event: ${String(c)}`);
1102
1102
  }
1103
1103
  }
1104
- async function tt(e) {
1104
+ async function nt(e) {
1105
1105
  const n = f();
1106
1106
  if (!n.isAuthenticated)
1107
- return r("AUTH_REQUIRED", "Authentication required");
1107
+ return i("AUTH_REQUIRED", "Authentication required");
1108
1108
  if (!n.baseUrl)
1109
- return r("AUTH_REQUIRED", "Base URL not configured");
1109
+ return i("AUTH_REQUIRED", "Base URL not configured");
1110
1110
  const t = new URLSearchParams();
1111
1111
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.language && t.append("language", e.language);
1112
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventTypes${i ? `?${i}` : ""}`;
1113
- c("Fetching event types:", a);
1112
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventTypes${r ? `?${r}` : ""}`;
1113
+ s("Fetching event types:", a);
1114
1114
  try {
1115
1115
  const o = await fetch(a, {
1116
1116
  method: "GET",
@@ -1120,25 +1120,25 @@ async function tt(e) {
1120
1120
  }
1121
1121
  });
1122
1122
  if (!o.ok)
1123
- return q(o);
1124
- const s = await o.json();
1125
- return c("Event types fetched:", s.results?.length ?? 0, "types"), l(s);
1123
+ return m(o);
1124
+ const c = await o.json();
1125
+ return s("Event types fetched:", c.results?.length ?? 0, "types"), l(c);
1126
1126
  } catch (o) {
1127
- return r("NETWORK_ERROR", `Failed to fetch event types: ${String(o)}`);
1127
+ return i("NETWORK_ERROR", `Failed to fetch event types: ${String(o)}`);
1128
1128
  }
1129
1129
  }
1130
- async function nt(e) {
1130
+ async function it(e) {
1131
1131
  const n = f();
1132
1132
  if (!n.isAuthenticated)
1133
- return r("AUTH_REQUIRED", "Authentication required");
1133
+ return i("AUTH_REQUIRED", "Authentication required");
1134
1134
  if (!n.baseUrl)
1135
- return r("AUTH_REQUIRED", "Base URL not configured");
1135
+ return i("AUTH_REQUIRED", "Base URL not configured");
1136
1136
  if (!e.actor)
1137
- return r("VALIDATION_ERROR", "actor parameter is required");
1137
+ return i("VALIDATION_ERROR", "actor parameter is required");
1138
1138
  const t = new URLSearchParams();
1139
1139
  t.append("actor", e.actor);
1140
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/events:listFieldValues${i ? `?${i}` : ""}`;
1141
- c("Fetching event field values:", a);
1140
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/events:listFieldValues${r ? `?${r}` : ""}`;
1141
+ s("Fetching event field values:", a);
1142
1142
  try {
1143
1143
  const o = await fetch(a, {
1144
1144
  method: "GET",
@@ -1148,49 +1148,49 @@ async function nt(e) {
1148
1148
  }
1149
1149
  });
1150
1150
  if (!o.ok)
1151
- return q(o);
1152
- const s = await o.json();
1153
- return c("Event field values fetched:", s.type?.length ?? 0, "types"), l(s);
1151
+ return m(o);
1152
+ const c = await o.json();
1153
+ return s("Event field values fetched:", c.type?.length ?? 0, "types"), l(c);
1154
1154
  } catch (o) {
1155
- return r("NETWORK_ERROR", `Failed to fetch event field values: ${String(o)}`);
1155
+ return i("NETWORK_ERROR", `Failed to fetch event field values: ${String(o)}`);
1156
1156
  }
1157
1157
  }
1158
- async function q(e) {
1158
+ async function m(e) {
1159
1159
  const n = e.status;
1160
1160
  let t;
1161
1161
  try {
1162
- const i = await e.json();
1163
- t = i.message ?? i.error ?? e.statusText;
1164
- } catch (i) {
1165
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1162
+ const r = await e.json();
1163
+ t = r.message ?? r.error ?? e.statusText;
1164
+ } catch (r) {
1165
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1166
1166
  }
1167
1167
  switch (n) {
1168
1168
  case 401:
1169
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1169
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1170
1170
  case 403:
1171
- return r("FORBIDDEN", `Access denied: ${t}`, n);
1171
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
1172
1172
  case 404:
1173
- return r("NOT_FOUND", `Not found: ${t}`, n);
1173
+ return i("NOT_FOUND", `Not found: ${t}`, n);
1174
1174
  case 429:
1175
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1175
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
1176
1176
  default:
1177
- return r("API_ERROR", `API error: ${t}`, n);
1177
+ return i("API_ERROR", `API error: ${t}`, n);
1178
1178
  }
1179
1179
  }
1180
1180
  async function rt(e) {
1181
1181
  const n = f();
1182
1182
  if (!n.isAuthenticated)
1183
- return r("AUTH_REQUIRED", "Authentication required");
1183
+ return i("AUTH_REQUIRED", "Authentication required");
1184
1184
  if (!n.baseUrl)
1185
- return r("AUTH_REQUIRED", "Base URL not configured");
1185
+ return i("AUTH_REQUIRED", "Base URL not configured");
1186
1186
  if (!e.actor)
1187
- return r("VALIDATION_ERROR", "actor parameter is required");
1187
+ return i("VALIDATION_ERROR", "actor parameter is required");
1188
1188
  if (!e.eventType)
1189
- return r("VALIDATION_ERROR", "eventType parameter is required");
1189
+ return i("VALIDATION_ERROR", "eventType parameter is required");
1190
1190
  const t = new URLSearchParams();
1191
1191
  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));
1192
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventMetrics${i ? `?${i}` : ""}`;
1193
- c("Fetching event metrics:", a);
1192
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventMetrics${r ? `?${r}` : ""}`;
1193
+ s("Fetching event metrics:", a);
1194
1194
  try {
1195
1195
  const o = await fetch(a, {
1196
1196
  method: "GET",
@@ -1200,45 +1200,45 @@ async function rt(e) {
1200
1200
  }
1201
1201
  });
1202
1202
  if (!o.ok)
1203
- return ke(o);
1204
- const s = await o.json();
1205
- return c("Event metrics fetched:", s.length, "metrics"), l(s);
1203
+ return be(o);
1204
+ const c = await o.json();
1205
+ return s("Event metrics fetched:", c.length, "metrics"), l(c);
1206
1206
  } catch (o) {
1207
- return r("NETWORK_ERROR", `Failed to fetch event metrics: ${String(o)}`);
1207
+ return i("NETWORK_ERROR", `Failed to fetch event metrics: ${String(o)}`);
1208
1208
  }
1209
1209
  }
1210
- async function ke(e) {
1210
+ async function be(e) {
1211
1211
  const n = e.status;
1212
1212
  let t;
1213
1213
  try {
1214
- const i = await e.json();
1215
- t = i.message ?? i.error ?? e.statusText;
1216
- } catch (i) {
1217
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1214
+ const r = await e.json();
1215
+ t = r.message ?? r.error ?? e.statusText;
1216
+ } catch (r) {
1217
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1218
1218
  }
1219
1219
  switch (n) {
1220
1220
  case 401:
1221
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1221
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1222
1222
  case 403:
1223
- return r("FORBIDDEN", `Access denied: ${t}`, n);
1223
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
1224
1224
  case 404:
1225
- return r("NOT_FOUND", `Not found: ${t}`, n);
1225
+ return i("NOT_FOUND", `Not found: ${t}`, n);
1226
1226
  case 429:
1227
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1227
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
1228
1228
  default:
1229
- return r("API_ERROR", `API error: ${t}`, n);
1229
+ return i("API_ERROR", `API error: ${t}`, n);
1230
1230
  }
1231
1231
  }
1232
- async function it(e) {
1232
+ async function ot(e) {
1233
1233
  const n = f();
1234
1234
  if (!n.isAuthenticated)
1235
- return r("AUTH_REQUIRED", "Authentication required");
1235
+ return i("AUTH_REQUIRED", "Authentication required");
1236
1236
  if (!n.baseUrl)
1237
- return r("AUTH_REQUIRED", "Base URL not configured");
1237
+ return i("AUTH_REQUIRED", "Base URL not configured");
1238
1238
  const t = new URLSearchParams();
1239
1239
  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);
1240
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/alerts${i ? `?${i}` : ""}`;
1241
- c("Fetching alerts:", a);
1240
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alerts${r ? `?${r}` : ""}`;
1241
+ s("Fetching alerts:", a);
1242
1242
  try {
1243
1243
  const o = await fetch(a, {
1244
1244
  method: "GET",
@@ -1248,51 +1248,51 @@ async function it(e) {
1248
1248
  }
1249
1249
  });
1250
1250
  if (!o.ok)
1251
- return K(o);
1252
- const s = await o.json();
1253
- return c("Alerts fetched:", s.results?.length ?? 0, "alerts"), l(s);
1251
+ return G(o);
1252
+ const c = await o.json();
1253
+ return s("Alerts fetched:", c.results?.length ?? 0, "alerts"), l(c);
1254
1254
  } catch (o) {
1255
- return r("NETWORK_ERROR", `Failed to fetch alerts: ${String(o)}`);
1255
+ return i("NETWORK_ERROR", `Failed to fetch alerts: ${String(o)}`);
1256
1256
  }
1257
1257
  }
1258
- async function ot(e, n) {
1258
+ async function at(e, n) {
1259
1259
  const t = f();
1260
1260
  if (!t.isAuthenticated)
1261
- return r("AUTH_REQUIRED", "Authentication required");
1261
+ return i("AUTH_REQUIRED", "Authentication required");
1262
1262
  if (!t.baseUrl)
1263
- return r("AUTH_REQUIRED", "Base URL not configured");
1263
+ return i("AUTH_REQUIRED", "Base URL not configured");
1264
1264
  if (!e)
1265
- return r("VALIDATION_ERROR", "Alert ID is required");
1266
- const i = new URLSearchParams();
1267
- n?.include && n.include.length > 0 && i.append("include", n.include.join(","));
1268
- const a = i.toString(), o = `${t.baseUrl}/api/v3.0/alerts/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1269
- c("Fetching alert:", o);
1265
+ return i("VALIDATION_ERROR", "Alert ID is required");
1266
+ const r = new URLSearchParams();
1267
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
1268
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/alerts/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1269
+ s("Fetching alert:", o);
1270
1270
  try {
1271
- const s = await fetch(o, {
1271
+ const c = await fetch(o, {
1272
1272
  method: "GET",
1273
1273
  headers: {
1274
1274
  Accept: "application/json",
1275
1275
  Authorization: `Bearer ${t.token}`
1276
1276
  }
1277
1277
  });
1278
- if (!s.ok)
1279
- return K(s);
1280
- const d = await s.json();
1281
- return c("Alert fetched:", d.id), l(d);
1282
- } catch (s) {
1283
- return r("NETWORK_ERROR", `Failed to fetch alert: ${String(s)}`);
1278
+ if (!c.ok)
1279
+ return G(c);
1280
+ const d = await c.json();
1281
+ return s("Alert fetched:", d.id), l(d);
1282
+ } catch (c) {
1283
+ return i("NETWORK_ERROR", `Failed to fetch alert: ${String(c)}`);
1284
1284
  }
1285
1285
  }
1286
- async function at(e) {
1286
+ async function ct(e) {
1287
1287
  const n = f();
1288
1288
  if (!n.isAuthenticated)
1289
- return r("AUTH_REQUIRED", "Authentication required");
1289
+ return i("AUTH_REQUIRED", "Authentication required");
1290
1290
  if (!n.baseUrl)
1291
- return r("AUTH_REQUIRED", "Base URL not configured");
1291
+ return i("AUTH_REQUIRED", "Base URL not configured");
1292
1292
  const t = new URLSearchParams();
1293
1293
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken);
1294
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/alertTypes${i ? `?${i}` : ""}`;
1295
- c("Fetching alert types:", a);
1294
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alertTypes${r ? `?${r}` : ""}`;
1295
+ s("Fetching alert types:", a);
1296
1296
  try {
1297
1297
  const o = await fetch(a, {
1298
1298
  method: "GET",
@@ -1302,45 +1302,45 @@ async function at(e) {
1302
1302
  }
1303
1303
  });
1304
1304
  if (!o.ok)
1305
- return K(o);
1306
- const s = await o.json();
1307
- return c("Alert types fetched:", s.results?.length ?? 0, "types"), l(s);
1305
+ return G(o);
1306
+ const c = await o.json();
1307
+ return s("Alert types fetched:", c.results?.length ?? 0, "types"), l(c);
1308
1308
  } catch (o) {
1309
- return r("NETWORK_ERROR", `Failed to fetch alert types: ${String(o)}`);
1309
+ return i("NETWORK_ERROR", `Failed to fetch alert types: ${String(o)}`);
1310
1310
  }
1311
1311
  }
1312
- async function K(e) {
1312
+ async function G(e) {
1313
1313
  const n = e.status;
1314
1314
  let t;
1315
1315
  try {
1316
- const i = await e.json();
1317
- t = i.message ?? i.error ?? e.statusText;
1318
- } catch (i) {
1319
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1316
+ const r = await e.json();
1317
+ t = r.message ?? r.error ?? e.statusText;
1318
+ } catch (r) {
1319
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1320
1320
  }
1321
1321
  switch (n) {
1322
1322
  case 401:
1323
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1323
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1324
1324
  case 403:
1325
- return r("FORBIDDEN", `Access denied: ${t}`, n);
1325
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
1326
1326
  case 404:
1327
- return r("NOT_FOUND", `Not found: ${t}`, n);
1327
+ return i("NOT_FOUND", `Not found: ${t}`, n);
1328
1328
  case 429:
1329
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1329
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
1330
1330
  default:
1331
- return r("API_ERROR", `API error: ${t}`, n);
1331
+ return i("API_ERROR", `API error: ${t}`, n);
1332
1332
  }
1333
1333
  }
1334
1334
  async function st(e) {
1335
1335
  const n = f();
1336
1336
  if (!n.isAuthenticated)
1337
- return r("AUTH_REQUIRED", "Authentication required");
1337
+ return i("AUTH_REQUIRED", "Authentication required");
1338
1338
  if (!n.baseUrl)
1339
- return r("AUTH_REQUIRED", "Base URL not configured");
1339
+ return i("AUTH_REQUIRED", "Base URL not configured");
1340
1340
  const t = new URLSearchParams();
1341
1341
  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);
1342
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/notifications${i ? `?${i}` : ""}`;
1343
- c("Fetching notifications:", a);
1342
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/notifications${r ? `?${r}` : ""}`;
1343
+ s("Fetching notifications:", a);
1344
1344
  try {
1345
1345
  const o = await fetch(a, {
1346
1346
  method: "GET",
@@ -1351,70 +1351,70 @@ async function st(e) {
1351
1351
  });
1352
1352
  if (!o.ok)
1353
1353
  return re(o);
1354
- const s = await o.json();
1355
- return c("Notifications fetched:", s.results?.length ?? 0, "notifications"), l(s);
1354
+ const c = await o.json();
1355
+ return s("Notifications fetched:", c.results?.length ?? 0, "notifications"), l(c);
1356
1356
  } catch (o) {
1357
- return r("NETWORK_ERROR", `Failed to fetch notifications: ${String(o)}`);
1357
+ return i("NETWORK_ERROR", `Failed to fetch notifications: ${String(o)}`);
1358
1358
  }
1359
1359
  }
1360
- async function ct(e) {
1360
+ async function ut(e) {
1361
1361
  const n = f();
1362
1362
  if (!n.isAuthenticated)
1363
- return r("AUTH_REQUIRED", "Authentication required");
1363
+ return i("AUTH_REQUIRED", "Authentication required");
1364
1364
  if (!n.baseUrl)
1365
- return r("AUTH_REQUIRED", "Base URL not configured");
1365
+ return i("AUTH_REQUIRED", "Base URL not configured");
1366
1366
  if (!e)
1367
- return r("VALIDATION_ERROR", "Notification ID is required");
1367
+ return i("VALIDATION_ERROR", "Notification ID is required");
1368
1368
  const t = `${n.baseUrl}/api/v3.0/notifications/${encodeURIComponent(e)}`;
1369
- c("Fetching notification:", t);
1369
+ s("Fetching notification:", t);
1370
1370
  try {
1371
- const i = await fetch(t, {
1371
+ const r = await fetch(t, {
1372
1372
  method: "GET",
1373
1373
  headers: {
1374
1374
  Accept: "application/json",
1375
1375
  Authorization: `Bearer ${n.token}`
1376
1376
  }
1377
1377
  });
1378
- if (!i.ok)
1379
- return re(i);
1380
- const a = await i.json();
1381
- return c("Notification fetched:", a.id), l(a);
1382
- } catch (i) {
1383
- return r("NETWORK_ERROR", `Failed to fetch notification: ${String(i)}`);
1378
+ if (!r.ok)
1379
+ return re(r);
1380
+ const a = await r.json();
1381
+ return s("Notification fetched:", a.id), l(a);
1382
+ } catch (r) {
1383
+ return i("NETWORK_ERROR", `Failed to fetch notification: ${String(r)}`);
1384
1384
  }
1385
1385
  }
1386
1386
  async function re(e) {
1387
1387
  const n = e.status;
1388
1388
  let t;
1389
1389
  try {
1390
- const i = await e.json();
1391
- t = i.message ?? i.error ?? e.statusText;
1392
- } catch (i) {
1393
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1390
+ const r = await e.json();
1391
+ t = r.message ?? r.error ?? e.statusText;
1392
+ } catch (r) {
1393
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1394
1394
  }
1395
1395
  switch (n) {
1396
1396
  case 401:
1397
- return r("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1397
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1398
1398
  case 403:
1399
- return r("FORBIDDEN", `Access denied: ${t}`, n);
1399
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
1400
1400
  case 404:
1401
- return r("NOT_FOUND", `Not found: ${t}`, n);
1401
+ return i("NOT_FOUND", `Not found: ${t}`, n);
1402
1402
  case 429:
1403
- return r("RATE_LIMITED", `Rate limited: ${t}`, n);
1403
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
1404
1404
  default:
1405
- return r("API_ERROR", `API error: ${t}`, n);
1405
+ return i("API_ERROR", `API error: ${t}`, n);
1406
1406
  }
1407
1407
  }
1408
- async function ut(e) {
1408
+ async function dt(e) {
1409
1409
  const n = f();
1410
1410
  if (!n.isAuthenticated)
1411
- return r("AUTH_REQUIRED", "Authentication required");
1411
+ return i("AUTH_REQUIRED", "Authentication required");
1412
1412
  if (!n.baseUrl)
1413
- return r("AUTH_REQUIRED", "Base URL not configured");
1413
+ return i("AUTH_REQUIRED", "Base URL not configured");
1414
1414
  const t = new URLSearchParams();
1415
1415
  e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken);
1416
- const i = t.toString(), a = `${n.baseUrl}/api/v3.0/eventSubscriptions${i ? `?${i}` : ""}`;
1417
- c("Fetching event subscriptions:", a);
1416
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventSubscriptions${r ? `?${r}` : ""}`;
1417
+ s("Fetching event subscriptions:", a);
1418
1418
  try {
1419
1419
  const o = await fetch(a, {
1420
1420
  method: "GET",
@@ -1424,59 +1424,59 @@ async function ut(e) {
1424
1424
  }
1425
1425
  });
1426
1426
  if (!o.ok)
1427
- return F(o);
1428
- const s = await o.json();
1429
- return c("Event subscriptions fetched:", s.results?.length ?? 0, "subscriptions"), l(s);
1427
+ return B(o);
1428
+ const c = await o.json();
1429
+ return s("Event subscriptions fetched:", c.results?.length ?? 0, "subscriptions"), l(c);
1430
1430
  } catch (o) {
1431
- return r("NETWORK_ERROR", `Failed to fetch event subscriptions: ${String(o)}`);
1431
+ return i("NETWORK_ERROR", `Failed to fetch event subscriptions: ${String(o)}`);
1432
1432
  }
1433
1433
  }
1434
- async function dt(e) {
1434
+ async function lt(e) {
1435
1435
  const n = f();
1436
1436
  if (!n.isAuthenticated)
1437
- return r("AUTH_REQUIRED", "Authentication required");
1437
+ return i("AUTH_REQUIRED", "Authentication required");
1438
1438
  if (!n.baseUrl)
1439
- return r("AUTH_REQUIRED", "Base URL not configured");
1439
+ return i("AUTH_REQUIRED", "Base URL not configured");
1440
1440
  if (!e)
1441
- return r("VALIDATION_ERROR", "Subscription ID is required");
1441
+ return i("VALIDATION_ERROR", "Subscription ID is required");
1442
1442
  const t = `${n.baseUrl}/api/v3.0/eventSubscriptions/${encodeURIComponent(e)}`;
1443
- c("Fetching event subscription:", t);
1443
+ s("Fetching event subscription:", t);
1444
1444
  try {
1445
- const i = await fetch(t, {
1445
+ const r = await fetch(t, {
1446
1446
  method: "GET",
1447
1447
  headers: {
1448
1448
  Accept: "application/json",
1449
1449
  Authorization: `Bearer ${n.token}`
1450
1450
  }
1451
1451
  });
1452
- if (!i.ok)
1453
- return F(i);
1454
- const a = await i.json();
1455
- return c("Event subscription fetched:", a.id), l(a);
1456
- } catch (i) {
1457
- return r("NETWORK_ERROR", `Failed to fetch event subscription: ${String(i)}`);
1452
+ if (!r.ok)
1453
+ return B(r);
1454
+ const a = await r.json();
1455
+ return s("Event subscription fetched:", a.id), l(a);
1456
+ } catch (r) {
1457
+ return i("NETWORK_ERROR", `Failed to fetch event subscription: ${String(r)}`);
1458
1458
  }
1459
1459
  }
1460
- async function lt(e) {
1460
+ async function ft(e) {
1461
1461
  const n = f();
1462
1462
  if (!n.isAuthenticated)
1463
- return r("AUTH_REQUIRED", "Authentication required");
1463
+ return i("AUTH_REQUIRED", "Authentication required");
1464
1464
  if (!n.baseUrl)
1465
- return r("AUTH_REQUIRED", "Base URL not configured");
1465
+ return i("AUTH_REQUIRED", "Base URL not configured");
1466
1466
  if (!e.deliveryConfig)
1467
- return r("VALIDATION_ERROR", "deliveryConfig is required");
1467
+ return i("VALIDATION_ERROR", "deliveryConfig is required");
1468
1468
  if (!e.filters || e.filters.length === 0)
1469
- return r("VALIDATION_ERROR", "At least one filter is required");
1470
- for (const i of e.filters) {
1471
- if (!i.actors || i.actors.length === 0)
1472
- return r("VALIDATION_ERROR", "Each filter must have at least one actor");
1473
- if (!i.types || i.types.length === 0)
1474
- return r("VALIDATION_ERROR", "Each filter must have at least one event type");
1469
+ return i("VALIDATION_ERROR", "At least one filter is required");
1470
+ for (const r of e.filters) {
1471
+ if (!r.actors || r.actors.length === 0)
1472
+ return i("VALIDATION_ERROR", "Each filter must have at least one actor");
1473
+ if (!r.types || r.types.length === 0)
1474
+ return i("VALIDATION_ERROR", "Each filter must have at least one event type");
1475
1475
  }
1476
1476
  const t = `${n.baseUrl}/api/v3.0/eventSubscriptions`;
1477
- c("Creating event subscription:", t);
1477
+ s("Creating event subscription:", t);
1478
1478
  try {
1479
- const i = await fetch(t, {
1479
+ const r = await fetch(t, {
1480
1480
  method: "POST",
1481
1481
  headers: {
1482
1482
  Accept: "application/json",
@@ -1485,64 +1485,64 @@ async function lt(e) {
1485
1485
  },
1486
1486
  body: JSON.stringify(e)
1487
1487
  });
1488
- if (!i.ok)
1489
- return F(i);
1490
- const a = await i.json();
1491
- return c("Event subscription created:", a.id), l(a);
1492
- } catch (i) {
1493
- return r("NETWORK_ERROR", `Failed to create event subscription: ${String(i)}`);
1488
+ if (!r.ok)
1489
+ return B(r);
1490
+ const a = await r.json();
1491
+ return s("Event subscription created:", a.id), l(a);
1492
+ } catch (r) {
1493
+ return i("NETWORK_ERROR", `Failed to create event subscription: ${String(r)}`);
1494
1494
  }
1495
1495
  }
1496
- async function ft(e) {
1496
+ async function _t(e) {
1497
1497
  const n = f();
1498
1498
  if (!n.isAuthenticated)
1499
- return r("AUTH_REQUIRED", "Authentication required");
1499
+ return i("AUTH_REQUIRED", "Authentication required");
1500
1500
  if (!n.baseUrl)
1501
- return r("AUTH_REQUIRED", "Base URL not configured");
1501
+ return i("AUTH_REQUIRED", "Base URL not configured");
1502
1502
  if (!e)
1503
- return r("VALIDATION_ERROR", "Subscription ID is required");
1503
+ return i("VALIDATION_ERROR", "Subscription ID is required");
1504
1504
  const t = `${n.baseUrl}/api/v3.0/eventSubscriptions/${encodeURIComponent(e)}`;
1505
- c("Deleting event subscription:", t);
1505
+ s("Deleting event subscription:", t);
1506
1506
  try {
1507
- const i = await fetch(t, {
1507
+ const r = await fetch(t, {
1508
1508
  method: "DELETE",
1509
1509
  headers: {
1510
1510
  Accept: "application/json",
1511
1511
  Authorization: `Bearer ${n.token}`
1512
1512
  }
1513
1513
  });
1514
- return i.ok ? (c("Event subscription deleted:", e), l(void 0)) : F(i);
1515
- } catch (i) {
1516
- return r("NETWORK_ERROR", `Failed to delete event subscription: ${String(i)}`);
1514
+ return r.ok ? (s("Event subscription deleted:", e), l(void 0)) : B(r);
1515
+ } catch (r) {
1516
+ return i("NETWORK_ERROR", `Failed to delete event subscription: ${String(r)}`);
1517
1517
  }
1518
1518
  }
1519
- function _t(e, n) {
1519
+ function ht(e, n) {
1520
1520
  const t = f();
1521
1521
  if (!t.isAuthenticated)
1522
- return r("AUTH_REQUIRED", "Authentication required");
1522
+ return i("AUTH_REQUIRED", "Authentication required");
1523
1523
  if (!t.token)
1524
- return r("AUTH_REQUIRED", "Access token not available");
1524
+ return i("AUTH_REQUIRED", "Access token not available");
1525
1525
  if (!e)
1526
- return r("VALIDATION_ERROR", "SSE URL is required");
1526
+ return i("VALIDATION_ERROR", "SSE URL is required");
1527
1527
  try {
1528
1528
  const _ = new URL(e);
1529
1529
  if (![".eagleeyenetworks.com", ".een.cloud"].some(
1530
1530
  (R) => _.hostname === R.substring(1) || _.hostname.endsWith(R)
1531
1531
  ))
1532
- return r("VALIDATION_ERROR", `SSE URL domain not allowed: ${_.hostname}`);
1532
+ return i("VALIDATION_ERROR", `SSE URL domain not allowed: ${_.hostname}`);
1533
1533
  } catch {
1534
- return r("VALIDATION_ERROR", "Invalid SSE URL format");
1534
+ return i("VALIDATION_ERROR", "Invalid SSE URL format");
1535
1535
  }
1536
- const i = 1024 * 1024;
1537
- let a = "connecting", o = new AbortController(), s = !1;
1536
+ const r = 1024 * 1024;
1537
+ let a = "connecting", o = new AbortController(), c = !1;
1538
1538
  const d = (_) => {
1539
1539
  a = _, n.onStatusChange?.(a);
1540
- }, h = () => {
1541
- s || (s = !0, c("Closing SSE connection"), o?.abort(), o = null, d("disconnected"));
1540
+ }, g = () => {
1541
+ c || (c = !0, s("Closing SSE connection"), o?.abort(), o = null, d("disconnected"));
1542
1542
  };
1543
1543
  return (async () => {
1544
- if (!(s || !o)) {
1545
- d("connecting"), c("Connecting to SSE:", e);
1544
+ if (!(c || !o)) {
1545
+ d("connecting"), s("Connecting to SSE:", e);
1546
1546
  try {
1547
1547
  const _ = await fetch(e, {
1548
1548
  method: "GET",
@@ -1556,122 +1556,389 @@ function _t(e, n) {
1556
1556
  throw new Error(`HTTP ${_.status}: ${_.statusText}`);
1557
1557
  if (!_.body)
1558
1558
  throw new Error("Response body is not available");
1559
- d("connected"), c("SSE connected");
1560
- const y = _.body.getReader(), S = new TextDecoder();
1559
+ d("connected"), s("SSE connected");
1560
+ const S = _.body.getReader(), v = new TextDecoder();
1561
1561
  let R = "";
1562
- for (; !s; ) {
1563
- const { done: B, value: P } = await y.read();
1564
- if (B) {
1565
- c("SSE stream ended");
1562
+ for (; !c; ) {
1563
+ const { done: P, value: H } = await S.read();
1564
+ if (P) {
1565
+ s("SSE stream ended");
1566
1566
  break;
1567
1567
  }
1568
- if (R += S.decode(P, { stream: !0 }), R.length > i) {
1569
- c("SSE buffer exceeded maximum size, resetting"), R = "";
1568
+ if (R += v.decode(H, { stream: !0 }), R.length > r) {
1569
+ s("SSE buffer exceeded maximum size, resetting"), R = "";
1570
1570
  continue;
1571
1571
  }
1572
- const b = R.split(`
1572
+ const N = R.split(`
1573
1573
  `);
1574
- R = b.pop() || "";
1575
- let U = "";
1576
- for (const $ of b)
1577
- if ($.startsWith("data:")) {
1578
- const T = $.substring(5).trimStart();
1579
- U = U ? `${U}
1574
+ R = N.pop() || "";
1575
+ let y = "";
1576
+ for (const O of N)
1577
+ if (O.startsWith("data:")) {
1578
+ const T = O.substring(5).trimStart();
1579
+ y = y ? `${y}
1580
1580
  ${T}` : T;
1581
- } else if ($ === "" && U) {
1581
+ } else if (O === "" && y) {
1582
1582
  try {
1583
- const T = JSON.parse(U);
1584
- c("SSE event received:", T.type, T.actorId), n.onEvent(T);
1583
+ const T = JSON.parse(y);
1584
+ s("SSE event received:", T.type, T.actorId), n.onEvent(T);
1585
1585
  } catch (T) {
1586
- c("Failed to parse SSE event:", T);
1586
+ s("Failed to parse SSE event:", T);
1587
1587
  }
1588
- U = "";
1588
+ y = "";
1589
1589
  }
1590
1590
  }
1591
1591
  } catch (_) {
1592
- if (s || _ instanceof Error && _.name === "AbortError")
1592
+ if (c || _ instanceof Error && _.name === "AbortError")
1593
1593
  return;
1594
- c("SSE error:", _), d("error"), n.onError?.(_ instanceof Error ? _ : new Error(String(_)));
1594
+ s("SSE error:", _), d("error"), n.onError?.(_ instanceof Error ? _ : new Error(String(_)));
1595
1595
  }
1596
1596
  }
1597
1597
  })(), l({
1598
- close: h,
1598
+ close: g,
1599
1599
  get status() {
1600
1600
  return a;
1601
1601
  }
1602
1602
  });
1603
1603
  }
1604
- async function F(e) {
1604
+ async function B(e) {
1605
+ const n = e.status;
1606
+ let t;
1607
+ try {
1608
+ const r = await e.json();
1609
+ t = r.message ?? r.error ?? e.statusText;
1610
+ } catch (r) {
1611
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1612
+ }
1613
+ switch (n) {
1614
+ case 401:
1615
+ return i("AUTH_REQUIRED", t, n);
1616
+ case 403:
1617
+ return i("FORBIDDEN", t, n);
1618
+ case 404:
1619
+ return i("NOT_FOUND", t, n);
1620
+ case 429:
1621
+ return i("RATE_LIMITED", t, n);
1622
+ default:
1623
+ return i("API_ERROR", t, n);
1624
+ }
1625
+ }
1626
+ async function gt(e) {
1627
+ const n = f();
1628
+ if (!n.isAuthenticated)
1629
+ return i("AUTH_REQUIRED", "Authentication required");
1630
+ if (!n.baseUrl)
1631
+ return i("AUTH_REQUIRED", "Base URL not configured");
1632
+ const t = new URLSearchParams();
1633
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.enabled !== void 0 && t.append("enabled", String(e.enabled)), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.outputAlertType__in && e.outputAlertType__in.length > 0 && t.append("outputAlertType__in", e.outputAlertType__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));
1634
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventAlertConditionRules${r ? `?${r}` : ""}`;
1635
+ s("Fetching event alert condition rules:", a);
1636
+ try {
1637
+ const o = await fetch(a, {
1638
+ method: "GET",
1639
+ headers: {
1640
+ Accept: "application/json",
1641
+ Authorization: `Bearer ${n.token}`
1642
+ }
1643
+ });
1644
+ if (!o.ok)
1645
+ return U(o);
1646
+ const c = await o.json();
1647
+ return s("Event alert condition rules fetched:", c.results?.length ?? 0, "rules"), l(c);
1648
+ } catch (o) {
1649
+ return i("NETWORK_ERROR", `Failed to fetch event alert condition rules: ${String(o)}`);
1650
+ }
1651
+ }
1652
+ async function Rt(e) {
1653
+ const n = f();
1654
+ if (!n.isAuthenticated)
1655
+ return i("AUTH_REQUIRED", "Authentication required");
1656
+ if (!n.baseUrl)
1657
+ return i("AUTH_REQUIRED", "Base URL not configured");
1658
+ const t = new URLSearchParams();
1659
+ e?.enabled !== void 0 && t.append("enabled", String(e.enabled));
1660
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/eventAlertConditionRules:listFieldValues${r ? `?${r}` : ""}`;
1661
+ s("Fetching event alert condition rule field values:", a);
1662
+ try {
1663
+ const o = await fetch(a, {
1664
+ method: "GET",
1665
+ headers: {
1666
+ Accept: "application/json",
1667
+ Authorization: `Bearer ${n.token}`
1668
+ }
1669
+ });
1670
+ if (!o.ok)
1671
+ return U(o);
1672
+ const c = await o.json();
1673
+ return s("Event alert condition rule field values fetched"), l(c);
1674
+ } catch (o) {
1675
+ return i("NETWORK_ERROR", `Failed to fetch field values: ${String(o)}`);
1676
+ }
1677
+ }
1678
+ async function pt(e) {
1679
+ const n = f();
1680
+ if (!n.isAuthenticated)
1681
+ return i("AUTH_REQUIRED", "Authentication required");
1682
+ if (!n.baseUrl)
1683
+ return i("AUTH_REQUIRED", "Base URL not configured");
1684
+ if (!e)
1685
+ return i("VALIDATION_ERROR", "Rule ID is required");
1686
+ const t = `${n.baseUrl}/api/v3.0/eventAlertConditionRules/${encodeURIComponent(e)}`;
1687
+ s("Fetching event alert condition rule:", t);
1688
+ try {
1689
+ const r = await fetch(t, {
1690
+ method: "GET",
1691
+ headers: {
1692
+ Accept: "application/json",
1693
+ Authorization: `Bearer ${n.token}`
1694
+ }
1695
+ });
1696
+ if (!r.ok)
1697
+ return U(r);
1698
+ const a = await r.json();
1699
+ return s("Event alert condition rule fetched:", a.id), l(a);
1700
+ } catch (r) {
1701
+ return i("NETWORK_ERROR", `Failed to fetch event alert condition rule: ${String(r)}`);
1702
+ }
1703
+ }
1704
+ async function Et(e) {
1705
+ const n = f();
1706
+ if (!n.isAuthenticated)
1707
+ return i("AUTH_REQUIRED", "Authentication required");
1708
+ if (!n.baseUrl)
1709
+ return i("AUTH_REQUIRED", "Base URL not configured");
1710
+ const t = new URLSearchParams();
1711
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.enabled !== void 0 && t.append("enabled", String(e.enabled)), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.actorId__in && e.actorId__in.length > 0 && t.append("actorId__in", e.actorId__in.join(",")), e?.inputEventType__in && e.inputEventType__in.length > 0 && t.append("inputEventType__in", e.inputEventType__in.join(",")), e?.outputAlertType && t.append("outputAlertType", e.outputAlertType), e?.type && t.append("type", e.type), e?.include && e.include.length > 0 && t.append("include", e.include.join(","));
1712
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alertConditionRules${r ? `?${r}` : ""}`;
1713
+ s("Fetching alert condition rules:", a);
1714
+ try {
1715
+ const o = await fetch(a, {
1716
+ method: "GET",
1717
+ headers: {
1718
+ Accept: "application/json",
1719
+ Authorization: `Bearer ${n.token}`
1720
+ }
1721
+ });
1722
+ if (!o.ok)
1723
+ return U(o);
1724
+ const c = await o.json();
1725
+ return s("Alert condition rules fetched:", c.results?.length ?? 0, "rules"), l(c);
1726
+ } catch (o) {
1727
+ return i("NETWORK_ERROR", `Failed to fetch alert condition rules: ${String(o)}`);
1728
+ }
1729
+ }
1730
+ async function At(e, n) {
1731
+ const t = f();
1732
+ if (!t.isAuthenticated)
1733
+ return i("AUTH_REQUIRED", "Authentication required");
1734
+ if (!t.baseUrl)
1735
+ return i("AUTH_REQUIRED", "Base URL not configured");
1736
+ if (!e)
1737
+ return i("VALIDATION_ERROR", "Rule ID is required");
1738
+ const r = new URLSearchParams();
1739
+ n?.include && n.include.length > 0 && r.append("include", n.include.join(","));
1740
+ const a = r.toString(), o = `${t.baseUrl}/api/v3.0/alertConditionRules/${encodeURIComponent(e)}${a ? `?${a}` : ""}`;
1741
+ s("Fetching alert condition rule:", o);
1742
+ try {
1743
+ const c = await fetch(o, {
1744
+ method: "GET",
1745
+ headers: {
1746
+ Accept: "application/json",
1747
+ Authorization: `Bearer ${t.token}`
1748
+ }
1749
+ });
1750
+ if (!c.ok)
1751
+ return U(c);
1752
+ const d = await c.json();
1753
+ return s("Alert condition rule fetched:", d.id), l(d);
1754
+ } catch (c) {
1755
+ return i("NETWORK_ERROR", `Failed to fetch alert condition rule: ${String(c)}`);
1756
+ }
1757
+ }
1758
+ async function Tt(e) {
1759
+ const n = f();
1760
+ if (!n.isAuthenticated)
1761
+ return i("AUTH_REQUIRED", "Authentication required");
1762
+ if (!n.baseUrl)
1763
+ return i("AUTH_REQUIRED", "Base URL not configured");
1764
+ const t = new URLSearchParams();
1765
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.enabled !== void 0 && t.append("enabled", String(e.enabled)), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), 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?.alertActionId__in && e.alertActionId__in.length > 0 && t.append("alertActionId__in", e.alertActionId__in.join(",")), e?.ruleId__in && e.ruleId__in.length > 0 && t.append("ruleId__in", e.ruleId__in.join(","));
1766
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alertActionRules${r ? `?${r}` : ""}`;
1767
+ s("Fetching alert action rules:", a);
1768
+ try {
1769
+ const o = await fetch(a, {
1770
+ method: "GET",
1771
+ headers: {
1772
+ Accept: "application/json",
1773
+ Authorization: `Bearer ${n.token}`
1774
+ }
1775
+ });
1776
+ if (!o.ok)
1777
+ return U(o);
1778
+ const c = await o.json();
1779
+ return s("Alert action rules fetched:", c.results?.length ?? 0, "rules"), l(c);
1780
+ } catch (o) {
1781
+ return i("NETWORK_ERROR", `Failed to fetch alert action rules: ${String(o)}`);
1782
+ }
1783
+ }
1784
+ async function It(e) {
1785
+ const n = f();
1786
+ if (!n.isAuthenticated)
1787
+ return i("AUTH_REQUIRED", "Authentication required");
1788
+ if (!n.baseUrl)
1789
+ return i("AUTH_REQUIRED", "Base URL not configured");
1790
+ if (!e)
1791
+ return i("VALIDATION_ERROR", "Rule ID is required");
1792
+ const t = `${n.baseUrl}/api/v3.0/alertActionRules/${encodeURIComponent(e)}`;
1793
+ s("Fetching alert action rule:", t);
1794
+ try {
1795
+ const r = await fetch(t, {
1796
+ method: "GET",
1797
+ headers: {
1798
+ Accept: "application/json",
1799
+ Authorization: `Bearer ${n.token}`
1800
+ }
1801
+ });
1802
+ if (!r.ok)
1803
+ return U(r);
1804
+ const a = await r.json();
1805
+ return s("Alert action rule fetched:", a.id), l(a);
1806
+ } catch (r) {
1807
+ return i("NETWORK_ERROR", `Failed to fetch alert action rule: ${String(r)}`);
1808
+ }
1809
+ }
1810
+ async function Ut(e) {
1811
+ const n = f();
1812
+ if (!n.isAuthenticated)
1813
+ return i("AUTH_REQUIRED", "Authentication required");
1814
+ if (!n.baseUrl)
1815
+ return i("AUTH_REQUIRED", "Base URL not configured");
1816
+ const t = new URLSearchParams();
1817
+ e?.pageSize && t.append("pageSize", String(e.pageSize)), e?.pageToken && t.append("pageToken", e.pageToken), e?.enabled !== void 0 && t.append("enabled", String(e.enabled)), e?.id__in && e.id__in.length > 0 && t.append("id__in", e.id__in.join(",")), e?.type__in && e.type__in.length > 0 && t.append("type__in", e.type__in.join(","));
1818
+ const r = t.toString(), a = `${n.baseUrl}/api/v3.0/alertActions${r ? `?${r}` : ""}`;
1819
+ s("Fetching alert actions:", a);
1820
+ try {
1821
+ const o = await fetch(a, {
1822
+ method: "GET",
1823
+ headers: {
1824
+ Accept: "application/json",
1825
+ Authorization: `Bearer ${n.token}`
1826
+ }
1827
+ });
1828
+ if (!o.ok)
1829
+ return U(o);
1830
+ const c = await o.json();
1831
+ return s("Alert actions fetched:", c.results?.length ?? 0, "actions"), l(c);
1832
+ } catch (o) {
1833
+ return i("NETWORK_ERROR", `Failed to fetch alert actions: ${String(o)}`);
1834
+ }
1835
+ }
1836
+ async function yt(e) {
1837
+ const n = f();
1838
+ if (!n.isAuthenticated)
1839
+ return i("AUTH_REQUIRED", "Authentication required");
1840
+ if (!n.baseUrl)
1841
+ return i("AUTH_REQUIRED", "Base URL not configured");
1842
+ if (!e)
1843
+ return i("VALIDATION_ERROR", "Action ID is required");
1844
+ const t = `${n.baseUrl}/api/v3.0/alertActions/${encodeURIComponent(e)}`;
1845
+ s("Fetching alert action:", t);
1846
+ try {
1847
+ const r = await fetch(t, {
1848
+ method: "GET",
1849
+ headers: {
1850
+ Accept: "application/json",
1851
+ Authorization: `Bearer ${n.token}`
1852
+ }
1853
+ });
1854
+ if (!r.ok)
1855
+ return U(r);
1856
+ const a = await r.json();
1857
+ return s("Alert action fetched:", a.id), l(a);
1858
+ } catch (r) {
1859
+ return i("NETWORK_ERROR", `Failed to fetch alert action: ${String(r)}`);
1860
+ }
1861
+ }
1862
+ async function U(e) {
1605
1863
  const n = e.status;
1606
1864
  let t;
1607
1865
  try {
1608
- const i = await e.json();
1609
- t = i.message ?? i.error ?? e.statusText;
1610
- } catch (i) {
1611
- c("Failed to parse error response JSON:", i), t = e.statusText || "Unknown error";
1866
+ const r = await e.json();
1867
+ t = r.message ?? r.error ?? e.statusText;
1868
+ } catch (r) {
1869
+ s("Failed to parse error response JSON:", r), t = e.statusText || "Unknown error";
1612
1870
  }
1613
1871
  switch (n) {
1614
1872
  case 401:
1615
- return r("AUTH_REQUIRED", t, n);
1873
+ return i("AUTH_REQUIRED", `Authentication failed: ${t}`, n);
1616
1874
  case 403:
1617
- return r("FORBIDDEN", t, n);
1875
+ return i("FORBIDDEN", `Access denied: ${t}`, n);
1618
1876
  case 404:
1619
- return r("NOT_FOUND", t, n);
1877
+ return i("NOT_FOUND", `Not found: ${t}`, n);
1620
1878
  case 429:
1621
- return r("RATE_LIMITED", t, n);
1879
+ return i("RATE_LIMITED", `Rate limited: ${t}`, n);
1622
1880
  default:
1623
- return r("API_ERROR", t, n);
1881
+ return i("API_ERROR", `API error: ${t}`, n);
1624
1882
  }
1625
1883
  }
1626
1884
  export {
1627
- be as STORAGE_STRATEGY_DESCRIPTIONS,
1628
- _t as connectToEventSubscription,
1629
- lt as createEventSubscription,
1630
- Ve as createLayout,
1631
- ft as deleteEventSubscription,
1885
+ Ne as STORAGE_STRATEGY_DESCRIPTIONS,
1886
+ ht as connectToEventSubscription,
1887
+ ft as createEventSubscription,
1888
+ We as createLayout,
1889
+ _t as deleteEventSubscription,
1632
1890
  Me as deleteLayout,
1633
- r as failure,
1891
+ i as failure,
1634
1892
  I as formatTimestamp,
1635
- Z as getAccessToken,
1636
- ot as getAlert,
1637
- Te as getAuthUrl,
1638
- Qe as getBridge,
1639
- ze as getBridges,
1640
- He as getCamera,
1641
- Pe as getCameras,
1642
- pe as getClientId,
1643
- je as getConfig,
1644
- qe as getCurrentUser,
1645
- et as getEvent,
1893
+ ee as getAccessToken,
1894
+ at as getAlert,
1895
+ yt as getAlertAction,
1896
+ It as getAlertActionRule,
1897
+ At as getAlertConditionRule,
1898
+ Ie as getAuthUrl,
1899
+ Ce as getBridge,
1900
+ Qe as getBridges,
1901
+ ze as getCamera,
1902
+ He as getCameras,
1903
+ Ee as getClientId,
1904
+ Fe as getConfig,
1905
+ me as getCurrentUser,
1906
+ tt as getEvent,
1907
+ pt as getEventAlertConditionRule,
1908
+ Rt as getEventAlertConditionRuleFieldValues,
1646
1909
  rt as getEventMetrics,
1647
- dt as getEventSubscription,
1648
- Ce as getLayout,
1910
+ lt as getEventSubscription,
1911
+ Ve as getLayout,
1649
1912
  xe as getLayouts,
1650
- Ge as getLiveImage,
1651
- Oe as getMediaSession,
1652
- ct as getNotification,
1653
- W as getProxyUrl,
1654
- Je as getRecordedImage,
1655
- Y as getRedirectUri,
1656
- Le as getStorageStrategy,
1657
- Be as getUser,
1658
- Fe as getUsers,
1659
- ye as handleAuthCallback,
1660
- Ne as initEenToolkit,
1661
- Xe as initMediaSession,
1662
- at as listAlertTypes,
1663
- it as listAlerts,
1664
- nt as listEventFieldValues,
1665
- ut as listEventSubscriptions,
1666
- tt as listEventTypes,
1667
- Ze as listEvents,
1668
- Ye as listFeeds,
1669
- Ke as listMedia,
1913
+ Je as getLiveImage,
1914
+ De as getMediaSession,
1915
+ ut as getNotification,
1916
+ K as getProxyUrl,
1917
+ Xe as getRecordedImage,
1918
+ Z as getRedirectUri,
1919
+ je as getStorageStrategy,
1920
+ Pe as getUser,
1921
+ Be as getUsers,
1922
+ Se as handleAuthCallback,
1923
+ qe as initEenToolkit,
1924
+ Ye as initMediaSession,
1925
+ Tt as listAlertActionRules,
1926
+ Ut as listAlertActions,
1927
+ Et as listAlertConditionRules,
1928
+ ct as listAlertTypes,
1929
+ ot as listAlerts,
1930
+ gt as listEventAlertConditionRules,
1931
+ it as listEventFieldValues,
1932
+ dt as listEventSubscriptions,
1933
+ nt as listEventTypes,
1934
+ et as listEvents,
1935
+ Ze as listFeeds,
1936
+ Ge as listMedia,
1670
1937
  st as listNotifications,
1671
- Ie as refreshToken,
1672
- Ue as revokeToken,
1938
+ Ue as refreshToken,
1939
+ ye as revokeToken,
1673
1940
  l as success,
1674
- We as updateLayout,
1941
+ Ke as updateLayout,
1675
1942
  f as useAuthStore
1676
1943
  };
1677
1944
  //# sourceMappingURL=index.js.map