@edusight/notification-widget 1.0.28 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,20 +1,20 @@
1
- import { jsx as d, jsxs as C } from "react/jsx-runtime";
2
- import L, { Component as B, useState as A, useCallback as h, useEffect as I, createContext as M, useReducer as V, useRef as z, useContext as q } from "react";
3
- import { io as H } from "socket.io-client";
4
- import { NotificationClient as $ } from "@edusight/notification-sdk";
5
- import { M as j, a as J, C as k, B as O, S as G, I as Q, L as X } from "./components-BJ465mfK.js";
6
- import { N as Te, P as Se } from "./components-BJ465mfK.js";
7
- import { u as Y, c as D } from "./hooks-DQflK_dw.js";
8
- const Z = ({ error: t, onRetry: r }) => /* @__PURE__ */ C(
1
+ import { jsx as d, jsxs as k } from "react/jsx-runtime";
2
+ import M, { Component as V, useState as C, useCallback as y, useEffect as b, createContext as z, useReducer as q, useRef as $, useContext as H } from "react";
3
+ import { io as J } from "socket.io-client";
4
+ import { NotificationClient as j } from "@edusight/notification-sdk";
5
+ import { M as G, a as Q, C as O, B as D, S as X, I as Y, L as Z } from "./components-DgV3nlCC.js";
6
+ import { N as Te, P as _e } from "./components-DgV3nlCC.js";
7
+ import { u as ee, c as x } from "./hooks-Cv5k48VE.js";
8
+ const te = ({ error: t, onRetry: r }) => /* @__PURE__ */ k(
9
9
  "div",
10
10
  {
11
11
  className: "p-4 bg-[var(--widget-error)]/10 border border-[var(--widget-error)]/20 rounded-lg",
12
12
  role: "alert",
13
13
  "data-testid": "error-boundary-fallback",
14
14
  children: [
15
- /* @__PURE__ */ C("div", { className: "flex items-center mb-2", children: [
15
+ /* @__PURE__ */ k("div", { className: "flex items-center mb-2", children: [
16
16
  /* @__PURE__ */ d(
17
- j,
17
+ G,
18
18
  {
19
19
  className: "w-6 h-6 text-[var(--widget-error)] mr-2",
20
20
  "aria-hidden": "true"
@@ -35,7 +35,7 @@ const Z = ({ error: t, onRetry: r }) => /* @__PURE__ */ C(
35
35
  children: "The notification widget encountered an error and couldn't load properly."
36
36
  }
37
37
  ),
38
- process.env.NODE_ENV === "development" && t && /* @__PURE__ */ C("details", { className: "mb-3", children: [
38
+ process.env.NODE_ENV === "development" && t && /* @__PURE__ */ k("details", { className: "mb-3", children: [
39
39
  /* @__PURE__ */ d(
40
40
  "summary",
41
41
  {
@@ -43,7 +43,7 @@ const Z = ({ error: t, onRetry: r }) => /* @__PURE__ */ C(
43
43
  children: "Error details (development only)"
44
44
  }
45
45
  ),
46
- /* @__PURE__ */ C(
46
+ /* @__PURE__ */ k(
47
47
  "pre",
48
48
  {
49
49
  className: "mt-2 text-xs bg-[var(--widget-error)]/5 p-2 rounded overflow-auto max-h-32 text-[var(--widget-error)]",
@@ -56,7 +56,7 @@ ${t.stack}`
56
56
  }
57
57
  )
58
58
  ] }),
59
- /* @__PURE__ */ C(
59
+ /* @__PURE__ */ k(
60
60
  "button",
61
61
  {
62
62
  type: "button",
@@ -65,7 +65,7 @@ ${t.stack}`
65
65
  "data-testid": "error-retry-button",
66
66
  children: [
67
67
  /* @__PURE__ */ d(
68
- J,
68
+ Q,
69
69
  {
70
70
  className: "mr-1 w-4 h-4",
71
71
  "aria-hidden": "true"
@@ -78,7 +78,7 @@ ${t.stack}`
78
78
  ]
79
79
  }
80
80
  );
81
- class ee extends B {
81
+ class ne extends V {
82
82
  constructor(r) {
83
83
  super(r), this.handleRetry = () => {
84
84
  this.setState({
@@ -105,7 +105,7 @@ class ee extends B {
105
105
  }
106
106
  render() {
107
107
  return this.state.hasError ? /* @__PURE__ */ d(
108
- Z,
108
+ te,
109
109
  {
110
110
  error: this.state.error,
111
111
  onRetry: this.handleRetry
@@ -113,25 +113,25 @@ class ee extends B {
113
113
  ) : this.props.children;
114
114
  }
115
115
  }
116
- const te = () => window.__notificationSDK?.client, ne = ({
116
+ const re = () => window.__notificationSDK?.client, ie = ({
117
117
  onPreferencesLoaded: t,
118
118
  onError: r
119
119
  }) => {
120
- const l = te(), [f, o] = A(!0), [i, n] = A(null), [c, p] = A(null), T = h(async () => {
120
+ const l = re(), [p, a] = C(!0), [i, n] = C(null), [s, f] = C(null), m = y(async () => {
121
121
  try {
122
- if (o(!0), n(null), !l)
122
+ if (a(!0), n(null), !l)
123
123
  throw new Error("Notification client not available");
124
124
  const u = window.__notificationSDK?.config;
125
125
  if (!u)
126
126
  throw new Error("SDK configuration not available");
127
- const { subscriberId: S, tenantId: N, environmentId: g } = u;
128
- if (!S || !N || !g)
127
+ const { subscriberId: g, tenantId: T, environmentId: w } = u;
128
+ if (!g || !T || !w)
129
129
  throw new Error("SubscriberId, TenantId or EnvironmentId not available in config");
130
130
  const E = await l.preferences.get(
131
- N,
132
- S,
133
- g
134
- ), w = {
131
+ T,
132
+ g,
133
+ w
134
+ ), N = {
135
135
  channels: {
136
136
  email: E.emailEnabled ?? !0,
137
137
  push: E.pushEnabled ?? !0,
@@ -148,23 +148,23 @@ const te = () => window.__notificationSDK?.client, ne = ({
148
148
  weekdays: [!0, !0, !0, !0, !0, !1, !1]
149
149
  }
150
150
  };
151
- E.categories && Object.entries(E.categories).forEach(([v, y]) => {
152
- w.subscriptions.push({
151
+ E.categories && Object.entries(E.categories).forEach(([v, _]) => {
152
+ N.subscriptions.push({
153
153
  workflowId: v,
154
154
  name: v,
155
155
  enabled: !0,
156
156
  channels: {
157
- email: y.emailEnabled ?? !0,
158
- push: y.pushEnabled ?? !0,
159
- sms: y.smsEnabled ?? !1,
160
- inApp: y.inAppEnabled ?? !0
157
+ email: _.emailEnabled ?? !0,
158
+ push: _.pushEnabled ?? !0,
159
+ sms: _.smsEnabled ?? !1,
160
+ inApp: _.inAppEnabled ?? !0
161
161
  }
162
162
  });
163
- }), p(w), t(w);
163
+ }), f(N), t(N);
164
164
  } catch (u) {
165
- const S = u instanceof Error ? u : new Error("Failed to load preferences");
166
- u?.response?.status === 404 || u?.status === 404 || (n(S), r?.(S));
167
- const g = {
165
+ const g = u instanceof Error ? u : new Error("Failed to load preferences");
166
+ u?.response?.status === 404 || u?.status === 404 || (n(g), r?.(g));
167
+ const w = {
168
168
  channels: {
169
169
  email: !0,
170
170
  push: !0,
@@ -181,24 +181,61 @@ const te = () => window.__notificationSDK?.client, ne = ({
181
181
  weekdays: [!0, !0, !0, !0, !0, !1, !1]
182
182
  }
183
183
  };
184
- p(g), t(g);
184
+ f(w), t(w);
185
185
  } finally {
186
- o(!1);
186
+ a(!1);
187
187
  }
188
188
  }, [l, t, r]);
189
- return I(() => {
190
- l && T();
191
- }, [l, T]), {
192
- isLoading: f,
189
+ return b(() => {
190
+ l && m();
191
+ }, [l, m]), {
192
+ isLoading: p,
193
193
  error: i,
194
- preferences: c
194
+ preferences: s
195
195
  };
196
- }, x = M(null), re = () => {
197
- const t = q(x);
196
+ }, oe = () => window.__notificationSDK?.client, ae = () => {
197
+ const t = oe(), [r, l] = C([]), [p, a] = C(!0), [i, n] = C(null), s = y(async () => {
198
+ try {
199
+ if (a(!0), n(null), !t)
200
+ throw new Error("Notification client not available");
201
+ const f = window.__notificationSDK?.config;
202
+ if (!f)
203
+ throw new Error("SDK configuration not available");
204
+ const { tenantId: m, environmentId: u } = f;
205
+ if (!m || !u)
206
+ throw new Error("TenantId or EnvironmentId not available in config");
207
+ const T = ((await t.workflows.list(
208
+ { status: "active" },
209
+ // Only load active workflows
210
+ m,
211
+ u
212
+ ))?.workflows || []).map((w) => ({
213
+ workflowId: w.workflowId,
214
+ name: w.name || w.workflowId,
215
+ description: w.description
216
+ }));
217
+ l(T);
218
+ } catch (f) {
219
+ const m = f instanceof Error ? f : new Error("Failed to load workflows");
220
+ n(m), l([]);
221
+ } finally {
222
+ a(!1);
223
+ }
224
+ }, [t]);
225
+ return b(() => {
226
+ t && s();
227
+ }, [t, s]), {
228
+ workflows: r,
229
+ isLoading: p,
230
+ error: i,
231
+ refetch: s
232
+ };
233
+ }, R = z(null), se = () => {
234
+ const t = H(R);
198
235
  if (!t)
199
236
  throw new Error("useSDK must be used within a NotificationWidget");
200
237
  return t;
201
- }, ie = {
238
+ }, ce = {
202
239
  notifications: [],
203
240
  unreadCount: 0,
204
241
  preferences: {
@@ -229,51 +266,51 @@ const te = () => window.__notificationSDK?.client, ne = ({
229
266
  connected: !1,
230
267
  reconnecting: !1
231
268
  }
232
- }, ae = ({
269
+ }, de = ({
233
270
  config: t,
234
271
  children: r
235
272
  }) => {
236
- const [l, f] = L.useState({
273
+ const [l, p] = M.useState({
237
274
  client: null,
238
275
  isInitialized: !1,
239
276
  error: null
240
277
  });
241
- return I(() => {
242
- let o = !0;
278
+ return b(() => {
279
+ let a = !0;
243
280
  return (async () => {
244
281
  try {
245
282
  const n = window.__notificationSDK;
246
283
  if (n?.client && JSON.stringify(n.config) === JSON.stringify(t)) {
247
- o && f({
284
+ a && p({
248
285
  client: n.client,
249
286
  isInitialized: !0,
250
287
  error: null
251
288
  });
252
289
  return;
253
290
  }
254
- const c = new $({
291
+ const s = new j({
255
292
  apiUrl: t.baseUrl,
256
293
  apiKey: t.apiKey,
257
294
  tenantId: t.tenantId,
258
295
  environmentId: t.environmentId
259
296
  });
260
- window.__notificationSDK = { client: c, config: t }, o && f({
261
- client: c,
297
+ window.__notificationSDK = { client: s, config: t }, a && p({
298
+ client: s,
262
299
  isInitialized: !0,
263
300
  error: null
264
301
  });
265
302
  } catch (n) {
266
- o && f({
303
+ a && p({
267
304
  client: null,
268
305
  isInitialized: !1,
269
306
  error: n
270
307
  });
271
308
  }
272
309
  })(), () => {
273
- o = !1;
310
+ a = !1;
274
311
  };
275
- }, [t]), /* @__PURE__ */ d(x.Provider, { value: l, children: r });
276
- }, oe = (t, r) => {
312
+ }, [t]), /* @__PURE__ */ d(R.Provider, { value: l, children: r });
313
+ }, le = (t, r) => {
277
314
  switch (r.type) {
278
315
  case "SET_NOTIFICATIONS":
279
316
  return {
@@ -289,20 +326,20 @@ const te = () => window.__notificationSDK?.client, ne = ({
289
326
  unreadCount: l.filter((i) => !i.isRead).length
290
327
  };
291
328
  case "UPDATE_NOTIFICATION":
292
- const f = t.notifications.map(
329
+ const p = t.notifications.map(
293
330
  (i) => i.id === r.payload.id ? { ...i, ...r.payload.updates } : i
294
331
  );
295
332
  return {
296
333
  ...t,
297
- notifications: f,
298
- unreadCount: f.filter((i) => !i.isRead).length
334
+ notifications: p,
335
+ unreadCount: p.filter((i) => !i.isRead).length
299
336
  };
300
337
  case "DELETE_NOTIFICATION":
301
- const o = t.notifications.filter((i) => i.id !== r.payload);
338
+ const a = t.notifications.filter((i) => i.id !== r.payload);
302
339
  return {
303
340
  ...t,
304
- notifications: o,
305
- unreadCount: o.filter((i) => !i.isRead).length
341
+ notifications: a,
342
+ unreadCount: a.filter((i) => !i.isRead).length
306
343
  };
307
344
  case "SET_PREFERENCES":
308
345
  return {
@@ -322,39 +359,63 @@ const te = () => window.__notificationSDK?.client, ne = ({
322
359
  default:
323
360
  return t;
324
361
  }
325
- }, se = ({
362
+ }, fe = ({
326
363
  position: t = "right",
327
364
  size: r = "medium",
328
365
  theme: l = "light",
329
- className: f = "",
330
- onError: o
366
+ className: p = "",
367
+ onError: a
331
368
  }) => {
332
- const [i, n] = V(oe, ie), { client: c, isInitialized: p, error: T } = re(), u = z(null), S = h((e) => {
369
+ const [i, n] = q(le, ce), { client: s, isInitialized: f, error: m } = se(), u = $(null), g = y((e) => {
333
370
  n({
334
371
  type: "SET_PREFERENCES",
335
372
  payload: e
336
373
  });
337
- }, []), N = h((e) => {
338
- o && o(e);
339
- }, [o]), { error: g } = ne({
340
- onPreferencesLoaded: S,
341
- onError: N
342
- }), { updatePreference: E, isSaving: w, error: v } = Y({
374
+ }, []), T = y((e) => {
375
+ a && a(e);
376
+ }, [a]), { error: w } = ie({
377
+ onPreferencesLoaded: g,
378
+ onError: T
379
+ }), { workflows: E, isLoading: N } = ae(), { updatePreference: v, isSaving: _, error: K } = ee({
343
380
  preferences: i.preferences,
344
- onPreferencesChange: S,
345
- onError: N
346
- }), y = h((e) => {
381
+ onPreferencesChange: g,
382
+ onError: T
383
+ });
384
+ b(() => {
385
+ if (!N && E.length > 0) {
386
+ const e = E.map((o) => i.preferences.subscriptions.find((I) => I.workflowId === o.workflowId) || {
387
+ workflowId: o.workflowId,
388
+ name: o.name,
389
+ enabled: !0,
390
+ // Default to enabled
391
+ channels: {
392
+ email: !0,
393
+ push: !0,
394
+ sms: !1,
395
+ inApp: !0
396
+ }
397
+ });
398
+ JSON.stringify(e) !== JSON.stringify(i.preferences.subscriptions) && n({
399
+ type: "SET_PREFERENCES",
400
+ payload: {
401
+ ...i.preferences,
402
+ subscriptions: e
403
+ }
404
+ });
405
+ }
406
+ }, [E, N, i.preferences]);
407
+ const A = y((e) => {
347
408
  try {
348
- const a = D();
409
+ const o = x();
349
410
  switch (e.type) {
350
411
  case "notification_received": {
351
- const s = e.data;
352
- if (!a.validateWebSocketPayload(s))
412
+ const c = e.data;
413
+ if (!o.validateWebSocketPayload(c))
353
414
  break;
354
- const _ = a.toWidgetNotificationFromWebSocket(s);
415
+ const I = o.toWidgetNotificationFromWebSocket(c);
355
416
  n({
356
417
  type: "ADD_NOTIFICATION",
357
- payload: _
418
+ payload: I
358
419
  });
359
420
  break;
360
421
  }
@@ -383,8 +444,8 @@ const te = () => window.__notificationSDK?.client, ne = ({
383
444
  }
384
445
  } catch {
385
446
  }
386
- }, []), K = h(async () => {
387
- if (!(!c || !p || u.current))
447
+ }, []), W = y(async () => {
448
+ if (!(!s || !f || u.current))
388
449
  try {
389
450
  n({
390
451
  type: "SET_WEBSOCKET_STATE",
@@ -393,7 +454,7 @@ const te = () => window.__notificationSDK?.client, ne = ({
393
454
  const e = window.__notificationSDK?.config;
394
455
  if (!e)
395
456
  throw new Error("SDK configuration not available for WebSocket connection");
396
- const _ = `${c.getApiHost()}/v1/notifications`, m = H(_, {
457
+ const I = `${s.getApiHost()}/v1/notifications`, h = J(I, {
397
458
  query: {
398
459
  tenantId: e.tenantId,
399
460
  subscriberId: e.subscriberId,
@@ -406,39 +467,39 @@ const te = () => window.__notificationSDK?.client, ne = ({
406
467
  reconnectionDelay: 1e3,
407
468
  reconnectionDelayMax: 5e3
408
469
  });
409
- u.current = m, m.on("notification", (b) => {
410
- y({
470
+ u.current = h, h.on("notification", (S) => {
471
+ A({
411
472
  type: "notification_received",
412
- data: b
473
+ data: S
413
474
  });
414
- }), m.on("connect", () => {
475
+ }), h.on("connect", () => {
415
476
  n({
416
477
  type: "SET_WEBSOCKET_STATE",
417
478
  payload: { connected: !0, reconnecting: !1 }
418
479
  });
419
- }), m.on("disconnect", (b) => {
480
+ }), h.on("disconnect", (S) => {
420
481
  n({
421
482
  type: "SET_WEBSOCKET_STATE",
422
483
  payload: { connected: !1, reconnecting: !1 }
423
484
  });
424
- }), m.on("reconnect_attempt", (b) => {
485
+ }), h.on("reconnect_attempt", (S) => {
425
486
  n({
426
487
  type: "SET_WEBSOCKET_STATE",
427
488
  payload: { connected: !1, reconnecting: !0 }
428
489
  });
429
- }), m.on("connect_error", (b) => {
490
+ }), h.on("connect_error", (S) => {
430
491
  n({
431
492
  type: "SET_WEBSOCKET_STATE",
432
493
  payload: { connected: !1, reconnecting: !1 }
433
- }), o && o(b);
434
- }), m.connect();
494
+ }), a && a(S);
495
+ }), h.connect();
435
496
  } catch (e) {
436
497
  n({
437
498
  type: "SET_WEBSOCKET_STATE",
438
499
  payload: { connected: !1, reconnecting: !1 }
439
- }), o && o(e);
500
+ }), a && a(e);
440
501
  }
441
- }, [c, p, y, o]), R = h(() => {
502
+ }, [s, f, A, a]), F = y(() => {
442
503
  if (u.current)
443
504
  try {
444
505
  u.current.disconnect && u.current.disconnect(), u.current = null, n({
@@ -447,45 +508,47 @@ const te = () => window.__notificationSDK?.client, ne = ({
447
508
  });
448
509
  } catch {
449
510
  }
450
- }, []), P = h(() => {
511
+ }, []), P = y(() => {
451
512
  n({
452
513
  type: "SET_UI_STATE",
453
514
  payload: { isOpen: !i.ui.isOpen }
454
515
  });
455
- }, [i.ui.isOpen]), F = h(() => {
516
+ }, [i.ui.isOpen]), U = y(() => {
456
517
  n({
457
518
  type: "SET_UI_STATE",
458
519
  payload: { isOpen: !1 }
459
520
  });
460
- }, []), U = h((e) => {
521
+ }, []), L = y((e) => {
461
522
  n({
462
523
  type: "SET_UI_STATE",
463
524
  payload: { currentView: e }
464
525
  });
465
- }, []), W = h(async (e, a) => {
466
- if (!c || !p)
526
+ }, []), B = y(async (e, o) => {
527
+ if (!s || !f)
467
528
  return;
468
- const s = window.__notificationSDK?.config;
469
- if (s)
529
+ const c = window.__notificationSDK?.config;
530
+ if (c) {
531
+ if (!e)
532
+ throw new Error("notificationId is required");
470
533
  try {
471
- switch (a.type) {
534
+ switch (o.type) {
472
535
  case "mark_read":
473
- await c.inbox.markAsRead(e, s.tenantId, s.environmentId, s.subscriberId);
536
+ await s.inbox.markAsRead(e, c.tenantId, c.environmentId, c.subscriberId);
474
537
  break;
475
538
  case "mark_unread":
476
- await c.inbox.markAsUnread(e, s.tenantId, s.environmentId, s.subscriberId);
539
+ await s.inbox.markAsUnread(e, c.tenantId, c.environmentId, c.subscriberId);
477
540
  break;
478
541
  case "archive":
479
- await c.inbox.archive(e, s.tenantId, s.environmentId, s.subscriberId);
542
+ await s.inbox.archive(e, c.tenantId, c.environmentId, c.subscriberId);
480
543
  break;
481
544
  case "delete":
482
- await c.inbox.delete(e, s.tenantId, s.environmentId, s.subscriberId);
545
+ await s.inbox.delete(e, c.tenantId, c.environmentId, c.subscriberId);
483
546
  break;
484
547
  default:
485
- a.handler && await a.handler(e);
548
+ o.handler && await o.handler(e);
486
549
  break;
487
550
  }
488
- switch (a.type) {
551
+ switch (o.type) {
489
552
  case "mark_read":
490
553
  n({
491
554
  type: "UPDATE_NOTIFICATION",
@@ -511,109 +574,110 @@ const te = () => window.__notificationSDK?.client, ne = ({
511
574
  });
512
575
  break;
513
576
  }
514
- } catch (_) {
515
- o && o(_);
577
+ } catch (I) {
578
+ a && a(I);
516
579
  }
517
- }, [c]);
518
- return I(() => {
519
- if (!c || !p) return;
580
+ }
581
+ }, [s]);
582
+ return b(() => {
583
+ if (!s || !f) return;
520
584
  (async () => {
521
585
  try {
522
586
  n({
523
587
  type: "SET_UI_STATE",
524
588
  payload: { isLoading: !0 }
525
589
  });
526
- const a = window.__notificationSDK?.config;
527
- if (!a)
590
+ const o = window.__notificationSDK?.config;
591
+ if (!o)
528
592
  throw new Error("SDK configuration not available");
529
- const s = D(), m = ((await c.inbox.getRenderedNotifications(
593
+ const c = x(), h = ((await s.inbox.getRenderedNotifications(
530
594
  {
531
595
  channel: "in_app",
532
596
  limit: 50,
533
597
  offset: 0
534
598
  },
535
- a.tenantId,
536
- a.environmentId,
537
- a.subscriberId
599
+ o.tenantId,
600
+ o.environmentId,
601
+ o.subscriberId
538
602
  ))?.items || []).map(
539
- (b) => s.toWidgetNotification(b)
603
+ (S) => c.toWidgetNotification(S)
540
604
  );
541
605
  n({
542
606
  type: "SET_NOTIFICATIONS",
543
- payload: m
607
+ payload: h
544
608
  }), n({
545
609
  type: "SET_UI_STATE",
546
610
  payload: { isLoading: !1, error: null }
547
611
  });
548
- } catch (a) {
612
+ } catch (o) {
549
613
  n({
550
614
  type: "SET_UI_STATE",
551
615
  payload: {
552
616
  isLoading: !1,
553
- error: a
617
+ error: o
554
618
  }
555
- }), o && o(a);
619
+ }), a && a(o);
556
620
  }
557
621
  })();
558
- }, [c, p, o]), I(() => (c && p && K(), () => {
559
- R();
560
- }), [c]), I(() => {
561
- if (!c || !p || i.websocket.connected) return;
622
+ }, [s, f, a]), b(() => (s && f && W(), () => {
623
+ F();
624
+ }), [s]), b(() => {
625
+ if (!s || !f || i.websocket.connected) return;
562
626
  const e = setInterval(async () => {
563
627
  try {
564
- const a = window.__notificationSDK?.config;
565
- if (!a)
628
+ const o = window.__notificationSDK?.config;
629
+ if (!o)
566
630
  return;
567
- const s = D(), m = ((await c.inbox.getRenderedNotifications(
631
+ const c = x(), h = ((await s.inbox.getRenderedNotifications(
568
632
  {
569
633
  channel: "in_app",
570
634
  limit: 50,
571
635
  offset: 0
572
636
  },
573
- a.tenantId,
574
- a.environmentId,
575
- a.subscriberId
637
+ o.tenantId,
638
+ o.environmentId,
639
+ o.subscriberId
576
640
  ))?.items || []).map(
577
- (b) => s.toWidgetNotification(b)
641
+ (S) => c.toWidgetNotification(S)
578
642
  );
579
643
  n({
580
644
  type: "SET_NOTIFICATIONS",
581
- payload: m
645
+ payload: h
582
646
  });
583
647
  } catch {
584
648
  }
585
649
  }, 3e4);
586
650
  return () => clearInterval(e);
587
- }, [c, i.websocket.connected]), I(() => {
588
- const e = (a) => {
589
- if (a.key === "notification_widget_sync" && a.newValue)
651
+ }, [s, i.websocket.connected]), b(() => {
652
+ const e = (o) => {
653
+ if (o.key === "notification_widget_sync" && o.newValue)
590
654
  try {
591
- const s = JSON.parse(a.newValue);
592
- y(s);
655
+ const c = JSON.parse(o.newValue);
656
+ A(c);
593
657
  } catch {
594
658
  }
595
659
  };
596
660
  return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
597
- }, [y]), I(() => {
661
+ }, [A]), b(() => {
598
662
  n({
599
663
  type: "SET_UI_STATE",
600
- payload: { isLoading: w }
664
+ payload: { isLoading: _ }
601
665
  });
602
- }, [w]), I(() => {
603
- const e = T || v || g;
666
+ }, [_]), b(() => {
667
+ const e = m || K || w;
604
668
  e && n({
605
669
  type: "SET_UI_STATE",
606
670
  payload: { error: e }
607
671
  });
608
- }, [T, v, g]), !p && !T ? /* @__PURE__ */ d(
672
+ }, [m, K, w]), !f && !m ? /* @__PURE__ */ d(
609
673
  "div",
610
674
  {
611
- className: `relative inline-block ${f}`,
675
+ className: `relative inline-block ${p}`,
612
676
  "data-widget-size": r || "small",
613
677
  "data-theme": l,
614
678
  "data-testid": "notification-widget",
615
- children: /* @__PURE__ */ d(k, { componentName: "BellComponent", children: /* @__PURE__ */ d(
616
- O,
679
+ children: /* @__PURE__ */ d(O, { componentName: "BellComponent", children: /* @__PURE__ */ d(
680
+ D,
617
681
  {
618
682
  unreadCount: 0,
619
683
  onClick: () => {
@@ -623,26 +687,26 @@ const te = () => window.__notificationSDK?.client, ne = ({
623
687
  }
624
688
  ) })
625
689
  }
626
- ) : T ? /* @__PURE__ */ d(
690
+ ) : m ? /* @__PURE__ */ d(
627
691
  "div",
628
692
  {
629
- className: `relative inline-block ${f}`,
693
+ className: `relative inline-block ${p}`,
630
694
  "data-widget-size": r || "small",
631
695
  "data-theme": l,
632
696
  "data-testid": "notification-widget",
633
697
  children: /* @__PURE__ */ d(
634
- k,
698
+ O,
635
699
  {
636
700
  componentName: "BellComponent",
637
701
  fallback: /* @__PURE__ */ d(
638
- G,
702
+ X,
639
703
  {
640
- error: T.message,
704
+ error: m.message,
641
705
  onRetry: () => window.location.reload()
642
706
  }
643
707
  ),
644
708
  children: /* @__PURE__ */ d(
645
- O,
709
+ D,
646
710
  {
647
711
  unreadCount: 0,
648
712
  onClick: () => {
@@ -654,16 +718,16 @@ const te = () => window.__notificationSDK?.client, ne = ({
654
718
  }
655
719
  )
656
720
  }
657
- ) : /* @__PURE__ */ C(
721
+ ) : /* @__PURE__ */ k(
658
722
  "div",
659
723
  {
660
- className: `relative inline-block ${f}`,
724
+ className: `relative inline-block ${p}`,
661
725
  "data-widget-size": r || "small",
662
726
  "data-theme": l,
663
727
  "data-testid": "notification-widget",
664
728
  children: [
665
- /* @__PURE__ */ d(k, { componentName: "BellComponent", children: /* @__PURE__ */ d(
666
- O,
729
+ /* @__PURE__ */ d(O, { componentName: "BellComponent", children: /* @__PURE__ */ d(
730
+ D,
667
731
  {
668
732
  unreadCount: i.unreadCount,
669
733
  onClick: P,
@@ -672,23 +736,23 @@ const te = () => window.__notificationSDK?.client, ne = ({
672
736
  }
673
737
  ) }),
674
738
  /* @__PURE__ */ d(
675
- k,
739
+ O,
676
740
  {
677
741
  componentName: "InboxPopover",
678
- fallback: /* @__PURE__ */ d(X, { message: "Unable to load notifications" }),
742
+ fallback: /* @__PURE__ */ d(Z, { message: "Unable to load notifications" }),
679
743
  children: /* @__PURE__ */ d(
680
- Q,
744
+ Y,
681
745
  {
682
746
  isOpen: i.ui.isOpen,
683
- onClose: F,
747
+ onClose: U,
684
748
  position: t,
685
749
  currentView: i.ui.currentView,
686
- onViewChange: U,
750
+ onViewChange: L,
687
751
  notifications: i.notifications,
688
- onNotificationAction: W,
752
+ onNotificationAction: B,
689
753
  preferences: i.preferences,
690
- onPreferenceChange: E,
691
- isPreferencesLoading: w
754
+ onPreferenceChange: v,
755
+ isPreferencesLoading: _
692
756
  }
693
757
  )
694
758
  }
@@ -696,18 +760,18 @@ const te = () => window.__notificationSDK?.client, ne = ({
696
760
  ]
697
761
  }
698
762
  );
699
- }, me = ({
763
+ }, ye = ({
700
764
  sdkConfig: t,
701
765
  ...r
702
- }) => /* @__PURE__ */ d(ee, { onError: r.onError, children: /* @__PURE__ */ d(ae, { config: t, children: /* @__PURE__ */ d(se, { ...r }) }) }), Ee = "3.0.0", he = "@edusight/notification-widget";
766
+ }) => /* @__PURE__ */ d(ne, { onError: r.onError, children: /* @__PURE__ */ d(de, { config: t, children: /* @__PURE__ */ d(fe, { ...r }) }) }), be = "3.0.0", ge = "@edusight/notification-widget";
703
767
  export {
704
- O as BellComponent,
705
- Q as InboxPopover,
768
+ D as BellComponent,
769
+ Y as InboxPopover,
706
770
  Te as NotificationItem,
707
- me as NotificationWidget,
708
- ee as NotificationWidgetErrorBoundary,
709
- Se as PreferencesView,
710
- Ee as VERSION,
711
- he as WIDGET_NAME
771
+ ye as NotificationWidget,
772
+ ne as NotificationWidgetErrorBoundary,
773
+ _e as PreferencesView,
774
+ be as VERSION,
775
+ ge as WIDGET_NAME
712
776
  };
713
777
  //# sourceMappingURL=index.esm.js.map