@burdenoff/microfe-notification 2026.624.1 → 2026.625.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.
@@ -10,9 +10,9 @@ import { useEffect as c, useMemo as l, useRef as u, useState as d } from "react"
10
10
  import { usePermissions as f } from "@burdenoff/fe-libs/shared/providers/shell";
11
11
  import { BellRing as p, Search as m, ToggleLeft as h, ToggleRight as g } from "lucide-react";
12
12
  import { jsx as _, jsxs as v } from "react/jsx-runtime";
13
- import { OptionalFields as y } from "@burdenoff/fe-libs/ui";
13
+ import { EmphasisPanel as y, OptionalFields as b } from "@burdenoff/fe-libs/ui";
14
14
  //#region src/pages/NotificationPreferencesPage.tsx
15
- var b = [
15
+ var x = [
16
16
  {
17
17
  value: "IN_APP",
18
18
  labelKey: "notifications.channelInApp",
@@ -43,7 +43,7 @@ var b = [
43
43
  labelKey: "notifications.channelSlack",
44
44
  label: "Slack"
45
45
  }
46
- ], x = [
46
+ ], S = [
47
47
  {
48
48
  value: "TRANSACTIONAL",
49
49
  labelKey: "notifications.typeTransactional",
@@ -65,82 +65,82 @@ var b = [
65
65
  label: "Marketing"
66
66
  }
67
67
  ];
68
- function S(e) {
68
+ function C(e) {
69
69
  return e.scope === "CHANNEL" ? `CHANNEL:${e.channel || ""}` : e.scope === "TYPE" ? `TYPE:${e.type || ""}` : e.scope === "TOPIC" ? `TOPIC:${e.topicId || ""}` : "GLOBAL";
70
70
  }
71
- function C() {
72
- let C = i(), { hasPermission: w, isLoading: T } = f(), { currentUser: E } = e(), { topics: D, isLoading: O } = r({
71
+ function w() {
72
+ let w = i(), { hasPermission: T, isLoading: E } = f(), { currentUser: D } = e(), { topics: O, isLoading: k } = r({
73
73
  type: "MARKETING",
74
74
  isActive: !0
75
- }), { preferencesByKey: k, isLoading: A, setPreference: j, deletePreference: M } = n(), { trackPreferenceUpdated: N } = t(), [P, F] = d(""), [I, L] = d(null), [R, z] = d(null), B = u(null), V = O || A;
75
+ }), { preferencesByKey: A, isLoading: j, setPreference: M, deletePreference: N } = n(), { trackPreferenceUpdated: P } = t(), [F, I] = d(""), [L, R] = d(null), [z, B] = d(null), V = u(null), H = k || j;
76
76
  c(() => () => {
77
- B.current && clearTimeout(B.current);
77
+ V.current && clearTimeout(V.current);
78
78
  }, []);
79
- let H = (e) => {
80
- B.current && clearTimeout(B.current), z(e), B.current = setTimeout(() => {
81
- z((t) => t?.key === e.key ? null : t), B.current = null;
79
+ let U = (e) => {
80
+ V.current && clearTimeout(V.current), B(e), V.current = setTimeout(() => {
81
+ B((t) => t?.key === e.key ? null : t), V.current = null;
82
82
  }, 2500);
83
- }, U = l(() => {
84
- if (!P.trim()) return D;
85
- let e = P.toLowerCase();
86
- return D.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
87
- }, [P, D]), W = async (e) => {
88
- let t = S(e), n = k.get(t), r = !(n?.enabled ?? !0);
89
- L(t), a("medium");
83
+ }, W = l(() => {
84
+ if (!F.trim()) return O;
85
+ let e = F.toLowerCase();
86
+ return O.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
87
+ }, [F, O]), G = async (e) => {
88
+ let t = C(e), n = A.get(t), r = !(n?.enabled ?? !0);
89
+ R(t), a("medium");
90
90
  try {
91
- await j({
91
+ await M({
92
92
  ...e,
93
93
  enabled: r,
94
94
  frequency: n?.frequency || "IMMEDIATE"
95
- }), N({
95
+ }), P({
96
96
  action: "set",
97
97
  scope: e.scope,
98
98
  channel: e.channel,
99
99
  type: e.type,
100
100
  enabled: r
101
- }), H({
101
+ }), U({
102
102
  key: t,
103
103
  type: "success",
104
- message: C("notifications.preferenceSaved", "Preference saved.")
104
+ message: w("notifications.preferenceSaved", "Preference saved.")
105
105
  }), o("success");
106
106
  } catch {
107
- H({
107
+ U({
108
108
  key: t,
109
109
  type: "error",
110
- message: C("notifications.preferenceSaveFailed", "Could not save preference.")
110
+ message: w("notifications.preferenceSaveFailed", "Could not save preference.")
111
111
  }), o("error");
112
112
  } finally {
113
- L(null);
113
+ R(null);
114
114
  }
115
- }, G = async (e) => {
116
- let t = k.get(e);
115
+ }, K = async (e) => {
116
+ let t = A.get(e);
117
117
  if (t) {
118
- L(e);
118
+ R(e);
119
119
  try {
120
- await M(t.id), N({
120
+ await N(t.id), P({
121
121
  action: "reset",
122
122
  scope: t.scope,
123
123
  channel: t.channel,
124
124
  type: t.type
125
- }), H({
125
+ }), U({
126
126
  key: e,
127
127
  type: "success",
128
- message: C("notifications.preferenceReset", "Preference reset.")
128
+ message: w("notifications.preferenceReset", "Preference reset.")
129
129
  });
130
130
  } catch {
131
- H({
131
+ U({
132
132
  key: e,
133
133
  type: "error",
134
- message: C("notifications.preferenceResetFailed", "Could not reset preference.")
134
+ message: w("notifications.preferenceResetFailed", "Could not reset preference.")
135
135
  });
136
136
  } finally {
137
- L(null);
137
+ R(null);
138
138
  }
139
139
  }
140
- }, K = (e) => {
141
- let t = k.get(e.key), n = t?.enabled ?? !0, r = I === e.key, i = R?.key === e.key ? R : null;
140
+ }, q = (e) => {
141
+ let t = A.get(e.key), n = t?.enabled ?? !0, r = L === e.key, i = z?.key === e.key ? z : null;
142
142
  return /* @__PURE__ */ v("div", {
143
- className: "rounded-lg border border-default bg-surface p-4 shadow-sm",
143
+ className: "rounded-lg border border-border-seam bg-gloss-card p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)]",
144
144
  children: [/* @__PURE__ */ v("div", {
145
145
  className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
146
146
  children: [/* @__PURE__ */ v("div", {
@@ -170,21 +170,21 @@ function C() {
170
170
  children: [t && /* @__PURE__ */ _("button", {
171
171
  type: "button",
172
172
  disabled: r,
173
- onClick: () => G(e.key),
173
+ onClick: () => K(e.key),
174
174
  className: "rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50",
175
- children: C("notifications.reset", "Reset")
175
+ children: w("notifications.reset", "Reset")
176
176
  }), /* @__PURE__ */ v("button", {
177
177
  type: "button",
178
178
  "aria-pressed": n,
179
179
  disabled: r,
180
- onClick: () => W({
180
+ onClick: () => G({
181
181
  scope: e.scope,
182
182
  channel: e.channel,
183
183
  type: e.type,
184
184
  topicId: e.topicId
185
185
  }),
186
186
  className: `inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${n ? "border-accent-primary bg-action-primary-bg text-text-inverse hover:opacity-90" : "border-default bg-bg-sunken text-secondary hover:bg-bg-sunken/80"} disabled:cursor-not-allowed disabled:opacity-50`,
187
- children: [_(n ? g : h, { size: 18 }), r ? C("notifications.saving", "Saving...") : n ? C("notifications.enabled", "Enabled") : C("notifications.disabled", "Disabled")]
187
+ children: [_(n ? g : h, { size: 18 }), r ? w("notifications.saving", "Saving...") : n ? w("notifications.enabled", "Enabled") : w("notifications.disabled", "Disabled")]
188
188
  })]
189
189
  })]
190
190
  }), /* @__PURE__ */ _("div", {
@@ -197,53 +197,53 @@ function C() {
197
197
  })]
198
198
  }, e.key);
199
199
  };
200
- return T ? /* @__PURE__ */ _("div", {
200
+ return E ? /* @__PURE__ */ _("div", {
201
201
  className: "flex h-64 items-center justify-center",
202
202
  children: /* @__PURE__ */ _("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
203
- }) : !w(s.NOTIFICATION_LIST) && !E?.id ? /* @__PURE__ */ _("div", {
203
+ }) : !T(s.NOTIFICATION_LIST) && !D?.id ? /* @__PURE__ */ _("div", {
204
204
  className: "p-8 text-center text-text-secondary",
205
- children: C("notifications.noPermissionPreferences", "You don't have permission to manage notification preferences.")
205
+ children: w("notifications.noPermissionPreferences", "You don't have permission to manage notification preferences.")
206
206
  }) : /* @__PURE__ */ v("div", {
207
207
  "data-tour": "notification-preferences-page",
208
208
  className: "space-y-6 p-4 sm:p-6",
209
209
  children: [
210
210
  /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h1", {
211
211
  className: "text-2xl font-bold text-primary",
212
- children: C("notifications.preferencesTitle", "Notification Preferences")
212
+ children: w("notifications.preferencesTitle", "Notification Preferences")
213
213
  }), /* @__PURE__ */ _("p", {
214
214
  className: "mt-1 text-sm text-secondary",
215
- children: C("notifications.preferencesSubtitle", "Control global, channel, type, and topic-level notification delivery.")
215
+ children: w("notifications.preferencesSubtitle", "Control global, channel, type, and topic-level notification delivery.")
216
216
  })] }),
217
- /* @__PURE__ */ v("section", {
217
+ /* @__PURE__ */ v(y, {
218
218
  "data-tour": "notification-preferences-global",
219
- className: "space-y-3",
219
+ className: "space-y-3 p-5 sm:p-6",
220
220
  children: [/* @__PURE__ */ _("h2", {
221
221
  className: "text-sm font-semibold uppercase tracking-wide text-tertiary",
222
- children: C("notifications.globalPreferences", "Global")
223
- }), K({
222
+ children: w("notifications.globalPreferences", "Global")
223
+ }), q({
224
224
  key: "GLOBAL",
225
225
  scope: "GLOBAL",
226
- title: C("notifications.allNotifications", "All notifications"),
227
- description: C("notifications.allNotificationsDescription", "Master preference for notification delivery across all channels and types.")
226
+ title: w("notifications.allNotifications", "All notifications"),
227
+ description: w("notifications.allNotificationsDescription", "Master preference for notification delivery across all channels and types.")
228
228
  })]
229
229
  }),
230
- /* @__PURE__ */ v(y, {
231
- title: C("notifications.advancedPreferences", "Advanced settings"),
232
- description: C("notifications.advancedPreferencesDescription", "Per-channel filter rules, notification-type filters, and quiet-hour overrides."),
230
+ /* @__PURE__ */ v(b, {
231
+ title: w("notifications.advancedPreferences", "Advanced settings"),
232
+ description: w("notifications.advancedPreferencesDescription", "Per-channel filter rules, notification-type filters, and quiet-hour overrides."),
233
233
  children: [/* @__PURE__ */ v("section", {
234
234
  "data-tour": "notification-preferences-channels",
235
235
  className: "space-y-3",
236
236
  children: [/* @__PURE__ */ _("h2", {
237
237
  className: "text-sm font-semibold uppercase tracking-wide text-tertiary",
238
- children: C("notifications.channelPreferences", "Channels")
238
+ children: w("notifications.channelPreferences", "Channels")
239
239
  }), /* @__PURE__ */ _("div", {
240
240
  className: "grid gap-3 lg:grid-cols-2",
241
- children: b.map((e) => K({
241
+ children: x.map((e) => q({
242
242
  key: `CHANNEL:${e.value}`,
243
243
  scope: "CHANNEL",
244
244
  channel: e.value,
245
- title: C(e.labelKey, e.label),
246
- description: C("notifications.channelPreferenceDescription", "Control delivery for this channel.")
245
+ title: w(e.labelKey, e.label),
246
+ description: w("notifications.channelPreferenceDescription", "Control delivery for this channel.")
247
247
  }))
248
248
  })]
249
249
  }), /* @__PURE__ */ v("section", {
@@ -251,15 +251,15 @@ function C() {
251
251
  className: "mt-6 space-y-3",
252
252
  children: [/* @__PURE__ */ _("h2", {
253
253
  className: "text-sm font-semibold uppercase tracking-wide text-tertiary",
254
- children: C("notifications.typePreferences", "Notification Types")
254
+ children: w("notifications.typePreferences", "Notification Types")
255
255
  }), /* @__PURE__ */ _("div", {
256
256
  className: "grid gap-3 lg:grid-cols-2",
257
- children: x.map((e) => K({
257
+ children: S.map((e) => q({
258
258
  key: `TYPE:${e.value}`,
259
259
  scope: "TYPE",
260
260
  type: e.value,
261
- title: C(e.labelKey, e.label),
262
- description: C("notifications.typePreferenceDescription", "Control delivery for this notification type.")
261
+ title: w(e.labelKey, e.label),
262
+ description: w("notifications.typePreferenceDescription", "Control delivery for this notification type.")
263
263
  }))
264
264
  })]
265
265
  })]
@@ -271,10 +271,10 @@ function C() {
271
271
  className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
272
272
  }), /* @__PURE__ */ _("input", {
273
273
  type: "text",
274
- value: P,
275
- onChange: (e) => F(e.target.value),
276
- "aria-label": C("notifications.searchTopics", "Search topics..."),
277
- placeholder: C("notifications.searchTopics", "Search topics..."),
274
+ value: F,
275
+ onChange: (e) => I(e.target.value),
276
+ "aria-label": w("notifications.searchTopics", "Search topics..."),
277
+ placeholder: w("notifications.searchTopics", "Search topics..."),
278
278
  className: "w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent"
279
279
  })]
280
280
  }),
@@ -283,14 +283,14 @@ function C() {
283
283
  className: "space-y-3",
284
284
  children: [/* @__PURE__ */ _("h2", {
285
285
  className: "text-sm font-semibold uppercase tracking-wide text-tertiary",
286
- children: C("notifications.topicPreferences", "Topics")
287
- }), V ? /* @__PURE__ */ _("div", {
286
+ children: w("notifications.topicPreferences", "Topics")
287
+ }), H ? /* @__PURE__ */ _("div", {
288
288
  className: "rounded-lg border border-default bg-surface p-6 text-sm text-secondary",
289
- children: C("notifications.loadingPreferences", "Loading preferences...")
290
- }) : U.length === 0 ? /* @__PURE__ */ _("div", {
289
+ children: w("notifications.loadingPreferences", "Loading preferences...")
290
+ }) : W.length === 0 ? /* @__PURE__ */ _("div", {
291
291
  className: "rounded-lg border border-default bg-surface p-6 text-sm text-secondary",
292
- children: C("notifications.noTopicsFound", "No promotional topics available right now.")
293
- }) : U.map((e) => K({
292
+ children: w("notifications.noTopicsFound", "No promotional topics available right now.")
293
+ }) : W.map((e) => q({
294
294
  key: `TOPIC:${e.id}`,
295
295
  scope: "TOPIC",
296
296
  topicId: e.id,
@@ -302,6 +302,6 @@ function C() {
302
302
  });
303
303
  }
304
304
  //#endregion
305
- export { C as NotificationPreferencesPage };
305
+ export { w as NotificationPreferencesPage };
306
306
 
307
307
  //# sourceMappingURL=NotificationPreferencesPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationPreferencesPage.js","names":[],"sources":["../../src/pages/NotificationPreferencesPage.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { BellRing, Search, ToggleLeft, ToggleRight } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { OptionalFields } from '@burdenoff/fe-libs/ui';\nimport { useNotificationPreferences, useNotificationTopics } from '../hooks';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationChannel, NotificationPreferenceScope, NotificationType } from '../types';\nimport { nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\nconst CHANNEL_OPTIONS: Array<{ value: NotificationChannel; labelKey: string; label: string }> = [\n { value: 'IN_APP', labelKey: 'notifications.channelInApp', label: 'In-app' },\n { value: 'EMAIL', labelKey: 'notifications.channelEmail', label: 'Email' },\n { value: 'PUSH', labelKey: 'notifications.channelPush', label: 'Push' },\n { value: 'SMS', labelKey: 'notifications.channelSms', label: 'SMS' },\n { value: 'WHATSAPP', labelKey: 'notifications.channelWhatsapp', label: 'WhatsApp' },\n { value: 'SLACK', labelKey: 'notifications.channelSlack', label: 'Slack' },\n];\n\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alerts' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\n\nfunction preferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n}) {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nexport function NotificationPreferencesPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics, isLoading: topicsLoading } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const {\n preferencesByKey,\n isLoading: preferencesLoading,\n setPreference,\n deletePreference,\n } = useNotificationPreferences();\n const { trackPreferenceUpdated } = useNotificationAnalytics();\n const [search, setSearch] = useState('');\n const [savingKey, setSavingKey] = useState<string | null>(null);\n const [saveFeedback, setSaveFeedback] = useState<{\n key: string;\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const feedbackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const isLoading = topicsLoading || preferencesLoading;\n\n useEffect(() => {\n return () => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n };\n }, []);\n\n const showSaveFeedback = (feedback: {\n key: string;\n type: 'success' | 'error';\n message: string;\n }) => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n\n setSaveFeedback(feedback);\n feedbackTimerRef.current = setTimeout(() => {\n setSaveFeedback((current) => (current?.key === feedback.key ? null : current));\n feedbackTimerRef.current = null;\n }, 2500);\n };\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n const togglePreference = async (input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const key = preferenceKey(input);\n const existing = preferencesByKey.get(key);\n const nextEnabled = !(existing?.enabled ?? true);\n setSavingKey(key);\n nativeImpact('medium');\n try {\n await setPreference({\n ...input,\n enabled: nextEnabled,\n frequency: existing?.frequency || 'IMMEDIATE',\n });\n trackPreferenceUpdated({\n action: 'set',\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: nextEnabled,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceSaved', 'Preference saved.'),\n });\n void nativeNotify('success');\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceSaveFailed', 'Could not save preference.'),\n });\n void nativeNotify('error');\n } finally {\n setSavingKey(null);\n }\n };\n\n const resetPreference = async (key: string) => {\n const existing = preferencesByKey.get(key);\n if (!existing) return;\n setSavingKey(key);\n try {\n await deletePreference(existing.id);\n trackPreferenceUpdated({\n action: 'reset',\n scope: existing.scope,\n channel: existing.channel,\n type: existing.type,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceReset', 'Preference reset.'),\n });\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceResetFailed', 'Could not reset preference.'),\n });\n } finally {\n setSavingKey(null);\n }\n };\n\n const renderPreferenceRow = (input: {\n key: string;\n title: string;\n description: string;\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const existing = preferencesByKey.get(input.key);\n const isEnabled = existing?.enabled ?? true;\n const isSaving = savingKey === input.key;\n const feedback = saveFeedback?.key === input.key ? saveFeedback : null;\n\n return (\n <div key={input.key} className=\"rounded-lg border border-default bg-surface p-4 shadow-sm\">\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <BellRing size={16} className=\"text-accent-primary\" />\n <h2 className=\"text-sm font-semibold text-primary\">{input.title}</h2>\n {existing && (\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {existing.frequency.replace('_', ' ').toLowerCase()}\n </span>\n )}\n </div>\n <p className=\"text-sm text-secondary\">{input.description}</p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {existing && (\n <button\n type=\"button\"\n disabled={isSaving}\n onClick={() => resetPreference(input.key)}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {tr('notifications.reset', 'Reset')}\n </button>\n )}\n <button\n type=\"button\"\n aria-pressed={isEnabled}\n disabled={isSaving}\n onClick={() =>\n togglePreference({\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n })\n }\n className={`inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${\n isEnabled\n ? 'border-accent-primary bg-action-primary-bg text-text-inverse hover:opacity-90'\n : 'border-default bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n } disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {isEnabled ? <ToggleRight size={18} /> : <ToggleLeft size={18} />}\n {isSaving\n ? tr('notifications.saving', 'Saving...')\n : isEnabled\n ? tr('notifications.enabled', 'Enabled')\n : tr('notifications.disabled', 'Disabled')}\n </button>\n </div>\n </div>\n <div className=\"mt-3 min-h-5\" aria-live=\"polite\">\n {feedback && (\n <p className={`text-xs ${feedback.type === 'success' ? 'text-success' : 'text-error'}`}>\n {feedback.message}\n </p>\n )}\n </div>\n </div>\n );\n };\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionPreferences',\n \"You don't have permission to manage notification preferences.\"\n )}\n </div>\n );\n }\n\n return (\n <div data-tour=\"notification-preferences-page\" className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.preferencesTitle', 'Notification Preferences')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.preferencesSubtitle',\n 'Control global, channel, type, and topic-level notification delivery.'\n )}\n </p>\n </div>\n\n <section data-tour=\"notification-preferences-global\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.globalPreferences', 'Global')}\n </h2>\n {renderPreferenceRow({\n key: 'GLOBAL',\n scope: 'GLOBAL',\n title: tr('notifications.allNotifications', 'All notifications'),\n description: tr(\n 'notifications.allNotificationsDescription',\n 'Master preference for notification delivery across all channels and types.'\n ),\n })}\n </section>\n\n {/* Advanced: per-channel filter rules / quiet hours / custom templates — collapse the long-tail knobs */}\n <OptionalFields\n title={tr('notifications.advancedPreferences', 'Advanced settings')}\n description={tr(\n 'notifications.advancedPreferencesDescription',\n 'Per-channel filter rules, notification-type filters, and quiet-hour overrides.'\n )}\n >\n <section data-tour=\"notification-preferences-channels\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.channelPreferences', 'Channels')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {CHANNEL_OPTIONS.map((channel) =>\n renderPreferenceRow({\n key: `CHANNEL:${channel.value}`,\n scope: 'CHANNEL',\n channel: channel.value,\n title: tr(channel.labelKey, channel.label),\n description: tr(\n 'notifications.channelPreferenceDescription',\n 'Control delivery for this channel.'\n ),\n })\n )}\n </div>\n </section>\n\n <section data-tour=\"notification-preferences-types\" className=\"mt-6 space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.typePreferences', 'Notification Types')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {TYPE_OPTIONS.map((type) =>\n renderPreferenceRow({\n key: `TYPE:${type.value}`,\n scope: 'TYPE',\n type: type.value,\n title: tr(type.labelKey, type.label),\n description: tr(\n 'notifications.typePreferenceDescription',\n 'Control delivery for this notification type.'\n ),\n })\n )}\n </div>\n </section>\n </OptionalFields>\n\n <div className=\"relative max-w-xl\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n aria-label={tr('notifications.searchTopics', 'Search topics...')}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <section data-tour=\"notification-preferences-topics\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.topicPreferences', 'Topics')}\n </h2>\n {isLoading ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.loadingPreferences', 'Loading preferences...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No promotional topics available right now.')}\n </div>\n ) : (\n filteredTopics.map((topic) =>\n renderPreferenceRow({\n key: `TOPIC:${topic.id}`,\n scope: 'TOPIC',\n topicId: topic.id,\n title: topic.name,\n description: topic.description || topic.slug,\n })\n )\n )}\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAM,IAA0F;CAC9F;EAAE,OAAO;EAAU,UAAU;EAA8B,OAAO;EAAU;CAC5E;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;EAAS;CAC1E;EAAE,OAAO;EAAQ,UAAU;EAA6B,OAAO;EAAQ;CACvE;EAAE,OAAO;EAAO,UAAU;EAA4B,OAAO;EAAO;CACpE;EAAE,OAAO;EAAY,UAAU;EAAiC,OAAO;EAAY;CACnF;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;EAAS;CAC3E,EAEK,IAAoF;CACxF;EAAE,OAAO;EAAiB,UAAU;EAAmC,OAAO;EAAiB;CAC/F;EAAE,OAAO;EAAU,UAAU;EAA4B,OAAO;EAAU;CAC1E;EAAE,OAAO;EAAS,UAAU;EAA2B,OAAO;EAAU;CACxE;EAAE,OAAO;EAAa,UAAU;EAA+B,OAAO;EAAa;CACpF;AAED,SAAS,EAAc,GAKpB;AAID,QAHI,EAAM,UAAU,YAAkB,WAAW,EAAM,WAAW,OAC9D,EAAM,UAAU,SAAe,QAAQ,EAAM,QAAQ,OACrD,E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AU,EAAM,OAAO,MAAM;KAClD,cAAY,EAAG,8BAA8B,mBAAmB;KAChE,aAAa,EAAG,8BAA8B,mBAAmB;KACjE,WAAU;KACV,CAAA,CACE;;GAEN,kBAAC,WAAD;IAAS,aAAU;IAAkC,WAAU;cAA/D,CACE,kBAAC,MAAD;KAAI,WAAU;eACX,EAAG,kCAAkC,SAAS;KAC5C,CAAA,EACJ,IACC,kBAAC,OAAD;KAAK,WAAU;eACZ,EAAG,oCAAoC,yBAAyB;KAC7D,CAAA,GACJ,EAAe,WAAW,IAC5B,kBAAC,OAAD;KAAK,WAAU;eACZ,EAAG,+BAA+B,6CAA6C;KAC5E,CAAA,GAEN,EAAe,KAAK,MAClB,EAAoB;KAClB,KAAK,SAAS,EAAM;KACpB,OAAO;KACP,SAAS,EAAM;KACf,OAAO,EAAM;KACb,aAAa,EAAM,eAAe,EAAM;KACzC,CAAC,CACH,CAEK;;GACN"}
1
+ {"version":3,"file":"NotificationPreferencesPage.js","names":[],"sources":["../../src/pages/NotificationPreferencesPage.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react';\nimport { BellRing, Search, ToggleLeft, ToggleRight } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { EmphasisPanel, OptionalFields } from '@burdenoff/fe-libs/ui';\nimport { useNotificationPreferences, useNotificationTopics } from '../hooks';\nimport { useNotificationAnalytics } from '../hooks/useNotificationAnalytics';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { NotificationChannel, NotificationPreferenceScope, NotificationType } from '../types';\nimport { nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\nconst CHANNEL_OPTIONS: Array<{ value: NotificationChannel; labelKey: string; label: string }> = [\n { value: 'IN_APP', labelKey: 'notifications.channelInApp', label: 'In-app' },\n { value: 'EMAIL', labelKey: 'notifications.channelEmail', label: 'Email' },\n { value: 'PUSH', labelKey: 'notifications.channelPush', label: 'Push' },\n { value: 'SMS', labelKey: 'notifications.channelSms', label: 'SMS' },\n { value: 'WHATSAPP', labelKey: 'notifications.channelWhatsapp', label: 'WhatsApp' },\n { value: 'SLACK', labelKey: 'notifications.channelSlack', label: 'Slack' },\n];\n\nconst TYPE_OPTIONS: Array<{ value: NotificationType; labelKey: string; label: string }> = [\n { value: 'TRANSACTIONAL', labelKey: 'notifications.typeTransactional', label: 'Transactional' },\n { value: 'SYSTEM', labelKey: 'notifications.typeSystem', label: 'System' },\n { value: 'ALERT', labelKey: 'notifications.typeAlert', label: 'Alerts' },\n { value: 'MARKETING', labelKey: 'notifications.typeMarketing', label: 'Marketing' },\n];\n\nfunction preferenceKey(input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n}) {\n if (input.scope === 'CHANNEL') return `CHANNEL:${input.channel || ''}`;\n if (input.scope === 'TYPE') return `TYPE:${input.type || ''}`;\n if (input.scope === 'TOPIC') return `TOPIC:${input.topicId || ''}`;\n return 'GLOBAL';\n}\n\nexport function NotificationPreferencesPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics, isLoading: topicsLoading } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const {\n preferencesByKey,\n isLoading: preferencesLoading,\n setPreference,\n deletePreference,\n } = useNotificationPreferences();\n const { trackPreferenceUpdated } = useNotificationAnalytics();\n const [search, setSearch] = useState('');\n const [savingKey, setSavingKey] = useState<string | null>(null);\n const [saveFeedback, setSaveFeedback] = useState<{\n key: string;\n type: 'success' | 'error';\n message: string;\n } | null>(null);\n const feedbackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const isLoading = topicsLoading || preferencesLoading;\n\n useEffect(() => {\n return () => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n };\n }, []);\n\n const showSaveFeedback = (feedback: {\n key: string;\n type: 'success' | 'error';\n message: string;\n }) => {\n if (feedbackTimerRef.current) {\n clearTimeout(feedbackTimerRef.current);\n }\n\n setSaveFeedback(feedback);\n feedbackTimerRef.current = setTimeout(() => {\n setSaveFeedback((current) => (current?.key === feedback.key ? null : current));\n feedbackTimerRef.current = null;\n }, 2500);\n };\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n const togglePreference = async (input: {\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const key = preferenceKey(input);\n const existing = preferencesByKey.get(key);\n const nextEnabled = !(existing?.enabled ?? true);\n setSavingKey(key);\n nativeImpact('medium');\n try {\n await setPreference({\n ...input,\n enabled: nextEnabled,\n frequency: existing?.frequency || 'IMMEDIATE',\n });\n trackPreferenceUpdated({\n action: 'set',\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n enabled: nextEnabled,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceSaved', 'Preference saved.'),\n });\n void nativeNotify('success');\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceSaveFailed', 'Could not save preference.'),\n });\n void nativeNotify('error');\n } finally {\n setSavingKey(null);\n }\n };\n\n const resetPreference = async (key: string) => {\n const existing = preferencesByKey.get(key);\n if (!existing) return;\n setSavingKey(key);\n try {\n await deletePreference(existing.id);\n trackPreferenceUpdated({\n action: 'reset',\n scope: existing.scope,\n channel: existing.channel,\n type: existing.type,\n });\n showSaveFeedback({\n key,\n type: 'success',\n message: tr('notifications.preferenceReset', 'Preference reset.'),\n });\n } catch {\n showSaveFeedback({\n key,\n type: 'error',\n message: tr('notifications.preferenceResetFailed', 'Could not reset preference.'),\n });\n } finally {\n setSavingKey(null);\n }\n };\n\n const renderPreferenceRow = (input: {\n key: string;\n title: string;\n description: string;\n scope: NotificationPreferenceScope;\n channel?: NotificationChannel;\n type?: NotificationType;\n topicId?: string;\n }) => {\n const existing = preferencesByKey.get(input.key);\n const isEnabled = existing?.enabled ?? true;\n const isSaving = savingKey === input.key;\n const feedback = saveFeedback?.key === input.key ? saveFeedback : null;\n\n return (\n <div\n key={input.key}\n className=\"rounded-lg border border-border-seam bg-gloss-card p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)]\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <BellRing size={16} className=\"text-accent-primary\" />\n <h2 className=\"text-sm font-semibold text-primary\">{input.title}</h2>\n {existing && (\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {existing.frequency.replace('_', ' ').toLowerCase()}\n </span>\n )}\n </div>\n <p className=\"text-sm text-secondary\">{input.description}</p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {existing && (\n <button\n type=\"button\"\n disabled={isSaving}\n onClick={() => resetPreference(input.key)}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {tr('notifications.reset', 'Reset')}\n </button>\n )}\n <button\n type=\"button\"\n aria-pressed={isEnabled}\n disabled={isSaving}\n onClick={() =>\n togglePreference({\n scope: input.scope,\n channel: input.channel,\n type: input.type,\n topicId: input.topicId,\n })\n }\n className={`inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors ${\n isEnabled\n ? 'border-accent-primary bg-action-primary-bg text-text-inverse hover:opacity-90'\n : 'border-default bg-bg-sunken text-secondary hover:bg-bg-sunken/80'\n } disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {isEnabled ? <ToggleRight size={18} /> : <ToggleLeft size={18} />}\n {isSaving\n ? tr('notifications.saving', 'Saving...')\n : isEnabled\n ? tr('notifications.enabled', 'Enabled')\n : tr('notifications.disabled', 'Disabled')}\n </button>\n </div>\n </div>\n <div className=\"mt-3 min-h-5\" aria-live=\"polite\">\n {feedback && (\n <p className={`text-xs ${feedback.type === 'success' ? 'text-success' : 'text-error'}`}>\n {feedback.message}\n </p>\n )}\n </div>\n </div>\n );\n };\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionPreferences',\n \"You don't have permission to manage notification preferences.\"\n )}\n </div>\n );\n }\n\n return (\n <div data-tour=\"notification-preferences-page\" className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.preferencesTitle', 'Notification Preferences')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.preferencesSubtitle',\n 'Control global, channel, type, and topic-level notification delivery.'\n )}\n </p>\n </div>\n\n <EmphasisPanel data-tour=\"notification-preferences-global\" className=\"space-y-3 p-5 sm:p-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.globalPreferences', 'Global')}\n </h2>\n {renderPreferenceRow({\n key: 'GLOBAL',\n scope: 'GLOBAL',\n title: tr('notifications.allNotifications', 'All notifications'),\n description: tr(\n 'notifications.allNotificationsDescription',\n 'Master preference for notification delivery across all channels and types.'\n ),\n })}\n </EmphasisPanel>\n\n {/* Advanced: per-channel filter rules / quiet hours / custom templates — collapse the long-tail knobs */}\n <OptionalFields\n title={tr('notifications.advancedPreferences', 'Advanced settings')}\n description={tr(\n 'notifications.advancedPreferencesDescription',\n 'Per-channel filter rules, notification-type filters, and quiet-hour overrides.'\n )}\n >\n <section data-tour=\"notification-preferences-channels\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.channelPreferences', 'Channels')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {CHANNEL_OPTIONS.map((channel) =>\n renderPreferenceRow({\n key: `CHANNEL:${channel.value}`,\n scope: 'CHANNEL',\n channel: channel.value,\n title: tr(channel.labelKey, channel.label),\n description: tr(\n 'notifications.channelPreferenceDescription',\n 'Control delivery for this channel.'\n ),\n })\n )}\n </div>\n </section>\n\n <section data-tour=\"notification-preferences-types\" className=\"mt-6 space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.typePreferences', 'Notification Types')}\n </h2>\n <div className=\"grid gap-3 lg:grid-cols-2\">\n {TYPE_OPTIONS.map((type) =>\n renderPreferenceRow({\n key: `TYPE:${type.value}`,\n scope: 'TYPE',\n type: type.value,\n title: tr(type.labelKey, type.label),\n description: tr(\n 'notifications.typePreferenceDescription',\n 'Control delivery for this notification type.'\n ),\n })\n )}\n </div>\n </section>\n </OptionalFields>\n\n <div className=\"relative max-w-xl\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n aria-label={tr('notifications.searchTopics', 'Search topics...')}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <section data-tour=\"notification-preferences-topics\" className=\"space-y-3\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-tertiary\">\n {tr('notifications.topicPreferences', 'Topics')}\n </h2>\n {isLoading ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.loadingPreferences', 'Loading preferences...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No promotional topics available right now.')}\n </div>\n ) : (\n filteredTopics.map((topic) =>\n renderPreferenceRow({\n key: `TOPIC:${topic.id}`,\n scope: 'TOPIC',\n topicId: topic.id,\n title: topic.name,\n description: topic.description || topic.slug,\n })\n )\n )}\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAM,IAA0F;CAC9F;EAAE,OAAO;EAAU,UAAU;EAA8B,OAAO;EAAU;CAC5E;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;EAAS;CAC1E;EAAE,OAAO;EAAQ,UAAU;EAA6B,OAAO;EAAQ;CACvE;EAAE,OAAO;EAAO,UAAU;EAA4B,OAAO;EAAO;CACpE;EAAE,OAAO;EAAY,UAAU;EAAiC,OAAO;EAAY;CACnF;EAAE,OAAO;EAAS,UAAU;EAA8B,OAAO;EAAS;CAC3E,EAEK,IAAoF;CACxF;EAAE,OAAO;EAAiB,UAAU;EAAmC,OAAO;EAAiB;CAC/F;EAAE,OAAO;EAAU,UAAU;EAA4B,OAAO;EAAU;CAC1E;EAAE,OAAO;EAAS,UAAU;EAA2B,OAAO;EAAU;CACxE;EAAE,OAAO;EAAa,UAAU;EAA+B,OAAO;EAAa;CACpF;AAED,SAAS,EAAc,GAKpB;AAID,QAHI,EAAM,UAAU,YAAkB,WAAW,EAAM,WAAW,OAC9D,EAAM,UAAU,SAAe,QAAQ,EAAM,QAAQ,OACrD,EAAM,UAAU,UAAgB,SAAS,EAAM,WAAW,OACvD;;AAGT,SAAgB,IAA8B;CAC5C,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,mBAAgB,GAAiB,EACnC,EAAE,WAAQ,WAAW,MAAkB,EAAsB;EACjE,MAAM;EACN,UAAU;EACX,CAAC,EACI,EACJ,qBAC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