@novu/js 3.11.0-rc.1 → 3.11.1

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.
@@ -0,0 +1,793 @@
1
+ 'use strict';
2
+
3
+ var chunk7B52C2XE_js = require('./chunk-7B52C2XE.js');
4
+
5
+ // src/ui/internal/buildContextKey.ts
6
+ function buildContextKey(context) {
7
+ if (!context) {
8
+ return "";
9
+ }
10
+ const keys = [];
11
+ for (const [type, value] of Object.entries(context)) {
12
+ if (value) {
13
+ const id = typeof value === "string" ? value : value.id;
14
+ keys.push(`${type}:${id}`);
15
+ }
16
+ }
17
+ return keys.sort().join(",");
18
+ }
19
+
20
+ // src/ui/internal/buildSubscriber.ts
21
+ function buildSubscriber({
22
+ subscriberId,
23
+ subscriber
24
+ }) {
25
+ if (subscriber) {
26
+ return typeof subscriber === "string" ? { subscriberId: subscriber } : subscriber;
27
+ }
28
+ if (subscriberId) {
29
+ return { subscriberId };
30
+ }
31
+ return { subscriberId: "" };
32
+ }
33
+
34
+ // src/types.ts
35
+ var NotificationStatus = /* @__PURE__ */ ((NotificationStatus2) => {
36
+ NotificationStatus2["READ"] = "read";
37
+ NotificationStatus2["SEEN"] = "seen";
38
+ NotificationStatus2["SNOOZED"] = "snoozed";
39
+ NotificationStatus2["UNREAD"] = "unread";
40
+ NotificationStatus2["UNSEEN"] = "unseen";
41
+ NotificationStatus2["UNSNOOZED"] = "unsnoozed";
42
+ return NotificationStatus2;
43
+ })(NotificationStatus || {});
44
+ var PreferenceLevel = /* @__PURE__ */ ((PreferenceLevel2) => {
45
+ PreferenceLevel2["GLOBAL"] = "global";
46
+ PreferenceLevel2["TEMPLATE"] = "template";
47
+ return PreferenceLevel2;
48
+ })(PreferenceLevel || {});
49
+ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
50
+ ChannelType2["IN_APP"] = "in_app";
51
+ ChannelType2["EMAIL"] = "email";
52
+ ChannelType2["SMS"] = "sms";
53
+ ChannelType2["CHAT"] = "chat";
54
+ ChannelType2["PUSH"] = "push";
55
+ return ChannelType2;
56
+ })(ChannelType || {});
57
+ var WebSocketEvent = /* @__PURE__ */ ((WebSocketEvent2) => {
58
+ WebSocketEvent2["RECEIVED"] = "notification_received";
59
+ WebSocketEvent2["UNREAD"] = "unread_count_changed";
60
+ WebSocketEvent2["UNSEEN"] = "unseen_count_changed";
61
+ return WebSocketEvent2;
62
+ })(WebSocketEvent || {});
63
+ var SeverityLevelEnum = /* @__PURE__ */ ((SeverityLevelEnum2) => {
64
+ SeverityLevelEnum2["HIGH"] = "high";
65
+ SeverityLevelEnum2["MEDIUM"] = "medium";
66
+ SeverityLevelEnum2["LOW"] = "low";
67
+ SeverityLevelEnum2["NONE"] = "none";
68
+ return SeverityLevelEnum2;
69
+ })(SeverityLevelEnum || {});
70
+ var WorkflowCriticalityEnum = /* @__PURE__ */ ((WorkflowCriticalityEnum2) => {
71
+ WorkflowCriticalityEnum2["CRITICAL"] = "critical";
72
+ WorkflowCriticalityEnum2["NON_CRITICAL"] = "nonCritical";
73
+ WorkflowCriticalityEnum2["ALL"] = "all";
74
+ return WorkflowCriticalityEnum2;
75
+ })(WorkflowCriticalityEnum || {});
76
+
77
+ // src/utils/errors.ts
78
+ var NovuError = class extends Error {
79
+ constructor(message, originalError) {
80
+ super(message);
81
+ this.originalError = originalError;
82
+ }
83
+ };
84
+
85
+ // src/notifications/helpers.ts
86
+ var read = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
87
+ emitter,
88
+ apiService,
89
+ args
90
+ }) {
91
+ const { notificationId, optimisticValue } = getNotificationDetails(
92
+ args,
93
+ {
94
+ isRead: true,
95
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
96
+ isArchived: false,
97
+ archivedAt: void 0
98
+ },
99
+ {
100
+ emitter,
101
+ apiService
102
+ }
103
+ );
104
+ try {
105
+ emitter.emit("notification.read.pending", {
106
+ args,
107
+ data: optimisticValue
108
+ });
109
+ const response = yield apiService.read(notificationId);
110
+ const updatedNotification = new Notification(response, emitter, apiService);
111
+ emitter.emit("notification.read.resolved", { args, data: updatedNotification });
112
+ return { data: updatedNotification };
113
+ } catch (error) {
114
+ emitter.emit("notification.read.resolved", { args, error });
115
+ return { error: new NovuError("Failed to read notification", error) };
116
+ }
117
+ });
118
+ var unread = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
119
+ emitter,
120
+ apiService,
121
+ args
122
+ }) {
123
+ const { notificationId, optimisticValue } = getNotificationDetails(
124
+ args,
125
+ {
126
+ isRead: false,
127
+ readAt: null,
128
+ isArchived: false,
129
+ archivedAt: void 0
130
+ },
131
+ {
132
+ emitter,
133
+ apiService
134
+ }
135
+ );
136
+ try {
137
+ emitter.emit("notification.unread.pending", {
138
+ args,
139
+ data: optimisticValue
140
+ });
141
+ const response = yield apiService.unread(notificationId);
142
+ const updatedNotification = new Notification(response, emitter, apiService);
143
+ emitter.emit("notification.unread.resolved", { args, data: updatedNotification });
144
+ return { data: updatedNotification };
145
+ } catch (error) {
146
+ emitter.emit("notification.unread.resolved", { args, error });
147
+ return { error: new NovuError("Failed to unread notification", error) };
148
+ }
149
+ });
150
+ var seen = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
151
+ emitter,
152
+ apiService,
153
+ args
154
+ }) {
155
+ const { notificationId, optimisticValue } = getNotificationDetails(
156
+ args,
157
+ {
158
+ isSeen: true
159
+ },
160
+ {
161
+ emitter,
162
+ apiService
163
+ }
164
+ );
165
+ try {
166
+ emitter.emit("notification.seen.pending", {
167
+ args,
168
+ data: optimisticValue
169
+ });
170
+ yield apiService.seen(notificationId);
171
+ if (!optimisticValue) {
172
+ throw new Error("Failed to create optimistic value for notification");
173
+ }
174
+ const updatedNotification = new Notification(optimisticValue, emitter, apiService);
175
+ emitter.emit("notification.seen.resolved", { args, data: updatedNotification });
176
+ return { data: updatedNotification };
177
+ } catch (error) {
178
+ emitter.emit("notification.seen.resolved", { args, error });
179
+ return { error: new NovuError("Failed to mark notification as seen", error) };
180
+ }
181
+ });
182
+ var archive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
183
+ emitter,
184
+ apiService,
185
+ args
186
+ }) {
187
+ const { notificationId, optimisticValue } = getNotificationDetails(
188
+ args,
189
+ {
190
+ isArchived: true,
191
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
192
+ isRead: true,
193
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
194
+ },
195
+ {
196
+ emitter,
197
+ apiService
198
+ }
199
+ );
200
+ try {
201
+ emitter.emit("notification.archive.pending", {
202
+ args,
203
+ data: optimisticValue
204
+ });
205
+ const response = yield apiService.archive(notificationId);
206
+ const updatedNotification = new Notification(response, emitter, apiService);
207
+ emitter.emit("notification.archive.resolved", { args, data: updatedNotification });
208
+ return { data: updatedNotification };
209
+ } catch (error) {
210
+ emitter.emit("notification.archive.resolved", { args, error });
211
+ return { error: new NovuError("Failed to archive notification", error) };
212
+ }
213
+ });
214
+ var unarchive = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
215
+ emitter,
216
+ apiService,
217
+ args
218
+ }) {
219
+ const { notificationId, optimisticValue } = getNotificationDetails(
220
+ args,
221
+ {
222
+ isArchived: false,
223
+ archivedAt: null,
224
+ isRead: true,
225
+ readAt: (/* @__PURE__ */ new Date()).toISOString()
226
+ },
227
+ {
228
+ emitter,
229
+ apiService
230
+ }
231
+ );
232
+ try {
233
+ emitter.emit("notification.unarchive.pending", {
234
+ args,
235
+ data: optimisticValue
236
+ });
237
+ const response = yield apiService.unarchive(notificationId);
238
+ const updatedNotification = new Notification(response, emitter, apiService);
239
+ emitter.emit("notification.unarchive.resolved", { args, data: updatedNotification });
240
+ return { data: updatedNotification };
241
+ } catch (error) {
242
+ emitter.emit("notification.unarchive.resolved", { args, error });
243
+ return { error: new NovuError("Failed to unarchive notification", error) };
244
+ }
245
+ });
246
+ var snooze = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
247
+ emitter,
248
+ apiService,
249
+ args
250
+ }) {
251
+ const { notificationId, optimisticValue } = getNotificationDetails(
252
+ args,
253
+ {
254
+ isSnoozed: true,
255
+ snoozedUntil: args.snoozeUntil
256
+ },
257
+ {
258
+ emitter,
259
+ apiService
260
+ }
261
+ );
262
+ try {
263
+ emitter.emit("notification.snooze.pending", {
264
+ args,
265
+ data: optimisticValue
266
+ });
267
+ const response = yield apiService.snooze(notificationId, args.snoozeUntil);
268
+ const updatedNotification = new Notification(response, emitter, apiService);
269
+ emitter.emit("notification.snooze.resolved", { args, data: updatedNotification });
270
+ return { data: updatedNotification };
271
+ } catch (error) {
272
+ emitter.emit("notification.snooze.resolved", { args, error });
273
+ return { error: new NovuError("Failed to snooze notification", error) };
274
+ }
275
+ });
276
+ var unsnooze = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
277
+ emitter,
278
+ apiService,
279
+ args
280
+ }) {
281
+ const { notificationId, optimisticValue } = getNotificationDetails(
282
+ args,
283
+ {
284
+ isSnoozed: false,
285
+ snoozedUntil: null
286
+ },
287
+ {
288
+ emitter,
289
+ apiService
290
+ }
291
+ );
292
+ try {
293
+ emitter.emit("notification.unsnooze.pending", {
294
+ args,
295
+ data: optimisticValue
296
+ });
297
+ const response = yield apiService.unsnooze(notificationId);
298
+ const updatedNotification = new Notification(response, emitter, apiService);
299
+ emitter.emit("notification.unsnooze.resolved", { args, data: updatedNotification });
300
+ return { data: updatedNotification };
301
+ } catch (error) {
302
+ emitter.emit("notification.unsnooze.resolved", { args, error });
303
+ return { error: new NovuError("Failed to unsnooze notification", error) };
304
+ }
305
+ });
306
+ var completeAction = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
307
+ emitter,
308
+ apiService,
309
+ args,
310
+ actionType
311
+ }) {
312
+ const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
313
+ primaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
314
+ isCompleted: true
315
+ })
316
+ } : {
317
+ secondaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
318
+ isCompleted: true
319
+ })
320
+ };
321
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
322
+ emitter,
323
+ apiService
324
+ });
325
+ try {
326
+ emitter.emit("notification.complete_action.pending", {
327
+ args,
328
+ data: optimisticValue
329
+ });
330
+ const response = yield apiService.completeAction({ actionType, notificationId });
331
+ const updatedNotification = new Notification(response, emitter, apiService);
332
+ emitter.emit("notification.complete_action.resolved", { args, data: updatedNotification });
333
+ return { data: updatedNotification };
334
+ } catch (error) {
335
+ emitter.emit("notification.complete_action.resolved", { args, error });
336
+ return { error: new NovuError(`Failed to complete ${actionType} action on the notification`, error) };
337
+ }
338
+ });
339
+ var revertAction = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
340
+ emitter,
341
+ apiService,
342
+ args,
343
+ actionType
344
+ }) {
345
+ const optimisticUpdate = actionType === "primary" /* PRIMARY */ ? {
346
+ primaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.primaryAction : {}), {
347
+ isCompleted: false
348
+ })
349
+ } : {
350
+ secondaryAction: chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, "notification" in args ? args.notification.secondaryAction : {}), {
351
+ isCompleted: false
352
+ })
353
+ };
354
+ const { notificationId, optimisticValue } = getNotificationDetails(args, optimisticUpdate, {
355
+ emitter,
356
+ apiService
357
+ });
358
+ try {
359
+ emitter.emit("notification.revert_action.pending", {
360
+ args,
361
+ data: optimisticValue
362
+ });
363
+ const response = yield apiService.revertAction({ actionType, notificationId });
364
+ const updatedNotification = new Notification(response, emitter, apiService);
365
+ emitter.emit("notification.revert_action.resolved", { args, data: updatedNotification });
366
+ return { data: updatedNotification };
367
+ } catch (error) {
368
+ emitter.emit("notification.revert_action.resolved", { args, error });
369
+ return { error: new NovuError("Failed to fetch notifications", error) };
370
+ }
371
+ });
372
+ var getNotificationDetails = (args, update, dependencies) => {
373
+ if ("notification" in args) {
374
+ return {
375
+ notificationId: args.notification.id,
376
+ optimisticValue: new Notification(
377
+ chunk7B52C2XE_js.__spreadValues(chunk7B52C2XE_js.__spreadValues({}, args.notification), update),
378
+ dependencies.emitter,
379
+ dependencies.apiService
380
+ )
381
+ };
382
+ } else {
383
+ return {
384
+ notificationId: args.notificationId
385
+ };
386
+ }
387
+ };
388
+ var readAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
389
+ emitter,
390
+ inboxService,
391
+ notificationsCache,
392
+ tags,
393
+ data
394
+ }) {
395
+ try {
396
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
397
+ const optimisticNotifications = notifications.map(
398
+ (notification) => new Notification(
399
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
400
+ isRead: true,
401
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
402
+ isArchived: false,
403
+ archivedAt: void 0
404
+ }),
405
+ emitter,
406
+ inboxService
407
+ )
408
+ );
409
+ emitter.emit("notifications.read_all.pending", { args: { tags, data }, data: optimisticNotifications });
410
+ yield inboxService.readAll({ tags, data });
411
+ emitter.emit("notifications.read_all.resolved", { args: { tags, data }, data: optimisticNotifications });
412
+ return {};
413
+ } catch (error) {
414
+ emitter.emit("notifications.read_all.resolved", { args: { tags, data }, error });
415
+ return { error: new NovuError("Failed to read all notifications", error) };
416
+ }
417
+ });
418
+ var seenAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
419
+ emitter,
420
+ inboxService,
421
+ notificationsCache,
422
+ notificationIds,
423
+ tags,
424
+ data
425
+ }) {
426
+ try {
427
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
428
+ const filteredNotifications = notificationIds && notificationIds.length > 0 ? notifications.filter((notification) => notificationIds.includes(notification.id)) : notifications;
429
+ const optimisticNotifications = filteredNotifications.map(
430
+ (notification) => new Notification(
431
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
432
+ isSeen: true,
433
+ firstSeenAt: notification.firstSeenAt || (/* @__PURE__ */ new Date()).toISOString()
434
+ }),
435
+ emitter,
436
+ inboxService
437
+ )
438
+ );
439
+ emitter.emit("notifications.seen_all.pending", {
440
+ args: { notificationIds, tags, data },
441
+ data: optimisticNotifications
442
+ });
443
+ yield inboxService.markAsSeen({ notificationIds, tags, data });
444
+ emitter.emit("notifications.seen_all.resolved", {
445
+ args: { notificationIds, tags, data },
446
+ data: optimisticNotifications
447
+ });
448
+ return {};
449
+ } catch (error) {
450
+ emitter.emit("notifications.seen_all.resolved", { args: { notificationIds, tags, data }, error });
451
+ return { error: new NovuError("Failed to mark all notifications as seen", error) };
452
+ }
453
+ });
454
+ var archiveAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
455
+ emitter,
456
+ inboxService,
457
+ notificationsCache,
458
+ tags,
459
+ data
460
+ }) {
461
+ try {
462
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
463
+ const optimisticNotifications = notifications.map(
464
+ (notification) => new Notification(
465
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), {
466
+ isRead: true,
467
+ readAt: (/* @__PURE__ */ new Date()).toISOString(),
468
+ isArchived: true,
469
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString()
470
+ }),
471
+ emitter,
472
+ inboxService
473
+ )
474
+ );
475
+ emitter.emit("notifications.archive_all.pending", { args: { tags, data }, data: optimisticNotifications });
476
+ yield inboxService.archiveAll({ tags, data });
477
+ emitter.emit("notifications.archive_all.resolved", { args: { tags, data }, data: optimisticNotifications });
478
+ return {};
479
+ } catch (error) {
480
+ emitter.emit("notifications.archive_all.resolved", { args: { tags, data }, error });
481
+ return { error: new NovuError("Failed to archive all notifications", error) };
482
+ }
483
+ });
484
+ var archiveAllRead = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
485
+ emitter,
486
+ inboxService,
487
+ notificationsCache,
488
+ tags,
489
+ data
490
+ }) {
491
+ try {
492
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data, read: true });
493
+ const optimisticNotifications = notifications.map(
494
+ (notification) => new Notification(
495
+ chunk7B52C2XE_js.__spreadProps(chunk7B52C2XE_js.__spreadValues({}, notification), { isArchived: true, archivedAt: (/* @__PURE__ */ new Date()).toISOString() }),
496
+ emitter,
497
+ inboxService
498
+ )
499
+ );
500
+ emitter.emit("notifications.archive_all_read.pending", { args: { tags, data }, data: optimisticNotifications });
501
+ yield inboxService.archiveAllRead({ tags, data });
502
+ emitter.emit("notifications.archive_all_read.resolved", { args: { tags, data }, data: optimisticNotifications });
503
+ return {};
504
+ } catch (error) {
505
+ emitter.emit("notifications.archive_all_read.resolved", { args: { tags, data }, error });
506
+ return { error: new NovuError("Failed to archive all read notifications", error) };
507
+ }
508
+ });
509
+ var deleteNotification = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
510
+ emitter,
511
+ apiService,
512
+ args
513
+ }) {
514
+ const { notificationId } = getNotificationDetails(
515
+ args,
516
+ {},
517
+ {
518
+ emitter,
519
+ apiService
520
+ }
521
+ );
522
+ try {
523
+ emitter.emit("notification.delete.pending", {
524
+ args
525
+ });
526
+ yield apiService.delete(notificationId);
527
+ emitter.emit("notification.delete.resolved", { args });
528
+ return {};
529
+ } catch (error) {
530
+ emitter.emit("notification.delete.resolved", { args, error });
531
+ return { error: new NovuError("Failed to delete notification", error) };
532
+ }
533
+ });
534
+ var deleteAll = (_0) => chunk7B52C2XE_js.__async(void 0, [_0], function* ({
535
+ emitter,
536
+ inboxService,
537
+ notificationsCache,
538
+ tags,
539
+ data
540
+ }) {
541
+ try {
542
+ const notifications = notificationsCache.getUniqueNotifications({ tags, data });
543
+ emitter.emit("notifications.delete_all.pending", { args: { tags, data }, data: notifications });
544
+ yield inboxService.deleteAll({ tags, data });
545
+ emitter.emit("notifications.delete_all.resolved", { args: { tags, data } });
546
+ return {};
547
+ } catch (error) {
548
+ emitter.emit("notifications.delete_all.resolved", { args: { tags, data }, error });
549
+ return { error: new NovuError("Failed to delete all notifications", error) };
550
+ }
551
+ });
552
+
553
+ // src/notifications/notification.ts
554
+ var _emitter, _inboxService;
555
+ var Notification = class {
556
+ constructor(notification, emitter, inboxService) {
557
+ chunk7B52C2XE_js.__privateAdd(this, _emitter);
558
+ chunk7B52C2XE_js.__privateAdd(this, _inboxService);
559
+ chunk7B52C2XE_js.__privateSet(this, _emitter, emitter);
560
+ chunk7B52C2XE_js.__privateSet(this, _inboxService, inboxService);
561
+ this.id = notification.id;
562
+ this.transactionId = notification.transactionId;
563
+ this.subject = notification.subject;
564
+ this.body = notification.body;
565
+ this.to = notification.to;
566
+ this.isRead = notification.isRead;
567
+ this.isSeen = notification.isSeen;
568
+ this.isArchived = notification.isArchived;
569
+ this.isSnoozed = notification.isSnoozed;
570
+ this.snoozedUntil = notification.snoozedUntil;
571
+ this.deliveredAt = notification.deliveredAt;
572
+ this.createdAt = notification.createdAt;
573
+ this.readAt = notification.readAt;
574
+ this.firstSeenAt = notification.firstSeenAt;
575
+ this.archivedAt = notification.archivedAt;
576
+ this.avatar = notification.avatar;
577
+ this.primaryAction = notification.primaryAction;
578
+ this.secondaryAction = notification.secondaryAction;
579
+ this.channelType = notification.channelType;
580
+ this.tags = notification.tags;
581
+ this.redirect = notification.redirect;
582
+ this.data = notification.data;
583
+ this.workflow = notification.workflow;
584
+ this.severity = notification.severity;
585
+ }
586
+ read() {
587
+ return read({
588
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
589
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
590
+ args: {
591
+ notification: this
592
+ }
593
+ });
594
+ }
595
+ unread() {
596
+ return unread({
597
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
598
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
599
+ args: {
600
+ notification: this
601
+ }
602
+ });
603
+ }
604
+ seen() {
605
+ return seen({
606
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
607
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
608
+ args: {
609
+ notification: this
610
+ }
611
+ });
612
+ }
613
+ archive() {
614
+ return archive({
615
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
616
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
617
+ args: {
618
+ notification: this
619
+ }
620
+ });
621
+ }
622
+ unarchive() {
623
+ return unarchive({
624
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
625
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
626
+ args: {
627
+ notification: this
628
+ }
629
+ });
630
+ }
631
+ delete() {
632
+ return deleteNotification({
633
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
634
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
635
+ args: {
636
+ notification: this
637
+ }
638
+ });
639
+ }
640
+ snooze(snoozeUntil) {
641
+ return snooze({
642
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
643
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
644
+ args: {
645
+ notification: this,
646
+ snoozeUntil
647
+ }
648
+ });
649
+ }
650
+ unsnooze() {
651
+ return unsnooze({
652
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
653
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
654
+ args: { notification: this }
655
+ });
656
+ }
657
+ completePrimary() {
658
+ if (!this.primaryAction) {
659
+ throw new Error("Primary action is not available");
660
+ }
661
+ return completeAction({
662
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
663
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
664
+ args: {
665
+ notification: this
666
+ },
667
+ actionType: "primary" /* PRIMARY */
668
+ });
669
+ }
670
+ completeSecondary() {
671
+ if (!this.primaryAction) {
672
+ throw new Error("Secondary action is not available");
673
+ }
674
+ return completeAction({
675
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
676
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
677
+ args: {
678
+ notification: this
679
+ },
680
+ actionType: "secondary" /* SECONDARY */
681
+ });
682
+ }
683
+ revertPrimary() {
684
+ if (!this.primaryAction) {
685
+ throw new Error("Primary action is not available");
686
+ }
687
+ return revertAction({
688
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
689
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
690
+ args: {
691
+ notification: this
692
+ },
693
+ actionType: "primary" /* PRIMARY */
694
+ });
695
+ }
696
+ revertSecondary() {
697
+ if (!this.primaryAction) {
698
+ throw new Error("Secondary action is not available");
699
+ }
700
+ return revertAction({
701
+ emitter: chunk7B52C2XE_js.__privateGet(this, _emitter),
702
+ apiService: chunk7B52C2XE_js.__privateGet(this, _inboxService),
703
+ args: {
704
+ notification: this
705
+ },
706
+ actionType: "secondary" /* SECONDARY */
707
+ });
708
+ }
709
+ on(eventName, listener) {
710
+ const cleanup = chunk7B52C2XE_js.__privateGet(this, _emitter).on(eventName, listener);
711
+ return () => {
712
+ cleanup();
713
+ };
714
+ }
715
+ /**
716
+ * @deprecated
717
+ * Use the cleanup function returned by the "on" method instead.
718
+ */
719
+ off(eventName, listener) {
720
+ chunk7B52C2XE_js.__privateGet(this, _emitter).off(eventName, listener);
721
+ }
722
+ };
723
+ _emitter = new WeakMap();
724
+ _inboxService = new WeakMap();
725
+
726
+ // src/ui/internal/createNotification.ts
727
+ function createNotification({
728
+ emitter,
729
+ inboxService,
730
+ notification
731
+ }) {
732
+ return new Notification(notification, emitter, inboxService);
733
+ }
734
+
735
+ // src/ui/internal/parseMarkdown.tsx
736
+ var parseMarkdownIntoTokens = (text) => {
737
+ const tokens = [];
738
+ let buffer = "";
739
+ let inBold = false;
740
+ for (let i = 0; i < text.length; i += 1) {
741
+ if (text[i] === "\\" && text[i + 1] === "*") {
742
+ buffer += "*";
743
+ i += 1;
744
+ } else if (text[i] === "*" && text[i + 1] === "*") {
745
+ if (buffer) {
746
+ tokens.push({
747
+ type: inBold ? "bold" : "text",
748
+ content: buffer
749
+ });
750
+ buffer = "";
751
+ }
752
+ inBold = !inBold;
753
+ i += 1;
754
+ } else {
755
+ buffer += text[i];
756
+ }
757
+ }
758
+ if (buffer) {
759
+ tokens.push({
760
+ type: inBold ? "bold" : "text",
761
+ content: buffer
762
+ });
763
+ }
764
+ return tokens;
765
+ };
766
+
767
+ exports.ChannelType = ChannelType;
768
+ exports.Notification = Notification;
769
+ exports.NotificationStatus = NotificationStatus;
770
+ exports.NovuError = NovuError;
771
+ exports.PreferenceLevel = PreferenceLevel;
772
+ exports.SeverityLevelEnum = SeverityLevelEnum;
773
+ exports.WebSocketEvent = WebSocketEvent;
774
+ exports.WorkflowCriticalityEnum = WorkflowCriticalityEnum;
775
+ exports.archive = archive;
776
+ exports.archiveAll = archiveAll;
777
+ exports.archiveAllRead = archiveAllRead;
778
+ exports.buildContextKey = buildContextKey;
779
+ exports.buildSubscriber = buildSubscriber;
780
+ exports.completeAction = completeAction;
781
+ exports.createNotification = createNotification;
782
+ exports.deleteAll = deleteAll;
783
+ exports.deleteNotification = deleteNotification;
784
+ exports.parseMarkdownIntoTokens = parseMarkdownIntoTokens;
785
+ exports.read = read;
786
+ exports.readAll = readAll;
787
+ exports.revertAction = revertAction;
788
+ exports.seen = seen;
789
+ exports.seenAll = seenAll;
790
+ exports.snooze = snooze;
791
+ exports.unarchive = unarchive;
792
+ exports.unread = unread;
793
+ exports.unsnooze = unsnooze;